@growthub/cli 0.3.19 → 0.3.20
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/runtime/server/ui-dist/assets/OnboardingWizard-aegE4bQH.js +834 -0
- package/dist/runtime/server/ui-dist/assets/OnboardingWizard-z80UuoAP.js +834 -0
- package/dist/runtime/server/ui-dist/assets/{_basePickBy-CycqvnCH.js → _basePickBy-C4Ps29xO.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/_basePickBy-zlPiZiIl.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{_baseUniq-jJI66QE5.js → _baseUniq-B_aRsKIx.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/_baseUniq-CLGVwfNH.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{arc-DAfOGkhs.js → arc-BrY66Xh9.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/arc-U3VJNepI.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{architectureDiagram-VXUJARFQ-Bseplhn_.js → architectureDiagram-VXUJARFQ-CVqxu6tT.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/architectureDiagram-VXUJARFQ-TYa7gEgg.js +36 -0
- package/dist/runtime/server/ui-dist/assets/{blockDiagram-VD42YOAC-CImRkHxE.js → blockDiagram-VD42YOAC-CE_U4VSL.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/blockDiagram-VD42YOAC-ChhaLrZq.js +122 -0
- package/dist/runtime/server/ui-dist/assets/{c4Diagram-YG6GDRKO-DocRJ0-4.js → c4Diagram-YG6GDRKO-CCNkfIs_.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/c4Diagram-YG6GDRKO-D59Snbbi.js +10 -0
- package/dist/runtime/server/ui-dist/assets/channel-B5blDtbh.js +1 -0
- package/dist/runtime/server/ui-dist/assets/channel-C3LKeIMD.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-4BX2VUAB-C_QZ3yOc.js → chunk-4BX2VUAB-B9_XUZoA.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-4BX2VUAB-CsDPLeIp.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-55IACEB6-B83lcfpC.js → chunk-55IACEB6-CV-uYDPm.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-55IACEB6-CqZfZuSl.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-B4BG7PRW-_ZGkSCBB.js → chunk-B4BG7PRW-BJ7SCTCg.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-B4BG7PRW-P5K7p-z1.js +165 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-DI55MBZ5-D84JXXQK.js → chunk-DI55MBZ5-DRfCUu2T.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-DI55MBZ5-DhoXwtcM.js +220 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-FMBD7UC4-MA5md7TF.js → chunk-FMBD7UC4-CuAhQfAl.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-FMBD7UC4-mphQHLyi.js +15 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-QN33PNHL-pBntDM8z.js → chunk-QN33PNHL-BjvOoEtf.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-QN33PNHL-DzRBdZ5S.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-QZHKN3VN-BaIMiSo-.js → chunk-QZHKN3VN-BoqSa9WP.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-QZHKN3VN-CD9knJBx.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{chunk-TZMSLE5B-CrjyhaCL.js → chunk-TZMSLE5B-C_XyV8fc.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/chunk-TZMSLE5B-DYH0SnWN.js +1 -0
- package/dist/runtime/server/ui-dist/assets/classDiagram-2ON5EDUG-0EIeYsv6.js +1 -0
- package/dist/runtime/server/ui-dist/assets/classDiagram-2ON5EDUG-BX8Ck5PY.js +1 -0
- package/dist/runtime/server/ui-dist/assets/classDiagram-v2-WZHVMYZB-0EIeYsv6.js +1 -0
- package/dist/runtime/server/ui-dist/assets/classDiagram-v2-WZHVMYZB-BX8Ck5PY.js +1 -0
- package/dist/runtime/server/ui-dist/assets/clone-9ZM8Q8yq.js +1 -0
- package/dist/runtime/server/ui-dist/assets/clone-D2WePZcd.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{cose-bilkent-S5V4N54A-mNFISgZf.js → cose-bilkent-S5V4N54A-B8C-ooP-.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/cose-bilkent-S5V4N54A-Bng95kAf.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{dagre-6UL2VRFP-BW8ACip_.js → dagre-6UL2VRFP-CxFvC9GZ.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/dagre-6UL2VRFP-PBYBIXep.js +4 -0
- package/dist/runtime/server/ui-dist/assets/{diagram-PSM6KHXK-ByQfKnwU.js → diagram-PSM6KHXK-Ci-IXmnT.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/diagram-PSM6KHXK-Ut4tY-KB.js +24 -0
- package/dist/runtime/server/ui-dist/assets/{diagram-QEK2KX5R-CVMlaNLR.js → diagram-QEK2KX5R-Be9fGxqt.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/diagram-QEK2KX5R-DDaYZ1PM.js +43 -0
- package/dist/runtime/server/ui-dist/assets/{diagram-S2PKOQOG-CfBIwKQh.js → diagram-S2PKOQOG-Ds30etl_.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/diagram-S2PKOQOG-MPGOqFqE.js +24 -0
- package/dist/runtime/server/ui-dist/assets/dx-root-I1SjeKcf.js +280 -0
- package/dist/runtime/server/ui-dist/assets/dx-root-a7U9cOiV.js +280 -0
- package/dist/runtime/server/ui-dist/assets/{erDiagram-Q2GNP2WA-DjZOGwrs.js → erDiagram-Q2GNP2WA-Biqo5EaP.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/erDiagram-Q2GNP2WA-Bmyd92kl.js +60 -0
- package/dist/runtime/server/ui-dist/assets/{flowDiagram-NV44I4VS-BpGnGwpO.js → flowDiagram-NV44I4VS-C-rc24VL.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/flowDiagram-NV44I4VS-DW1-MtQ6.js +162 -0
- package/dist/runtime/server/ui-dist/assets/{ganttDiagram-JELNMOA3-CpTGtCqK.js → ganttDiagram-JELNMOA3-D0MVK6Gd.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/ganttDiagram-JELNMOA3-FWLRNdF-.js +267 -0
- package/dist/runtime/server/ui-dist/assets/{gitGraphDiagram-V2S2FVAM-BQaWuAZj.js → gitGraphDiagram-V2S2FVAM-CI3pWfQH.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/gitGraphDiagram-V2S2FVAM-DOFM3Y0W.js +65 -0
- package/dist/runtime/server/ui-dist/assets/{graph-DXdHsjCL.js → graph-5c70dvh8.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/graph-BznlWlKn.js +1 -0
- package/dist/runtime/server/ui-dist/assets/gtm-root-BoVRYj0q.js +38 -0
- package/dist/runtime/server/ui-dist/assets/gtm-root-C2ixHsq-.js +43 -0
- package/dist/runtime/server/ui-dist/assets/{index-Bq-1_kyP.js → index-B1bimZfj.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-DRwidkWV.js → index-B3GZFuhh.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-B8I0xKWu.js → index-B5B040UY.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-BgVlUrJs.js → index-BIt4NjJj.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-D8pJptAs.js → index-BIue-fk7.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-B8TKmcyb.js → index-BSm4D1TE.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-CmWaG74-.js → index-BeGEpySa.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/index-Biidwxu-.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{index-CKSID6Zp.js → index-Bjf5Y1Fe.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-CQebjpNv.js → index-BnNeRMja.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-DKPn8Zd0.js → index-Bnoka1fN.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-D5QPPm5h.js → index-BqHZNDOZ.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-DwTdFnM5.js → index-BrMaMz52.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-CFpWwIka.js → index-Bxz7TALh.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/index-C0ZHu3gk.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{index-CpAx3Tjk.js → index-C7K8gvTL.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-BqPQYsKl.js → index-C8_BPRbZ.js} +2 -2
- package/dist/runtime/server/ui-dist/assets/index-C8iEq198.js +50 -0
- package/dist/runtime/server/ui-dist/assets/{index-LPZbBYTO.js → index-CG95CmvJ.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-BMSNv6QN.js → index-CON3OBgH.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/index-CQSAurWH.js +3 -0
- package/dist/runtime/server/ui-dist/assets/{index-Crtq9e3P.js → index-CWqjAAL4.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-BYHJbnHR.js → index-CYUZ1_Tf.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/index-Cjg85A30.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-CnlQhX7h.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{index-BzMyBmxt.js → index-CnnXkeW7.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-KhE_p8qv.js → index-Csek8Cyu.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-mMQEcPHs.js → index-CvrUXd8H.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/{index-nPSc8Rbx.js → index-D-MCAYSs.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/index-D0bgaO1N.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-D3dvWR7o.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-DKhRDjWZ.js +13 -0
- package/dist/runtime/server/ui-dist/assets/index-DWrCKJWt.css +1 -0
- package/dist/runtime/server/ui-dist/assets/index-DcPWTDzc.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-DgCAac5-.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-DivgBhQD.js +6 -0
- package/dist/runtime/server/ui-dist/assets/index-DqxEr_Vx.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-Dw6BKzoR.js +7 -0
- package/dist/runtime/server/ui-dist/assets/index-G-p3Qicx.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-Hj76Symk.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-IBxMhLi5.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-JNUAKAz7.js +2 -0
- package/dist/runtime/server/ui-dist/assets/index-f-3m6hoA.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-nw-N5ndS.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-pnFOOZaA.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-sqctevS8.js +1 -0
- package/dist/runtime/server/ui-dist/assets/index-wUECOpFa.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{infoDiagram-HS3SLOUP-Du9idGhC.js → infoDiagram-HS3SLOUP-Bmh0XPTA.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/infoDiagram-HS3SLOUP-OrIMfcTI.js +2 -0
- package/dist/runtime/server/ui-dist/assets/{journeyDiagram-XKPGCS4Q-DQHmnv0N.js → journeyDiagram-XKPGCS4Q-BIZPmhJX.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/journeyDiagram-XKPGCS4Q-Bjy7_Ftw.js +139 -0
- package/dist/runtime/server/ui-dist/assets/{kanban-definition-3W4ZIXB7-D1us-ZVV.js → kanban-definition-3W4ZIXB7-CWvvFuzh.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/kanban-definition-3W4ZIXB7-DKxlyJV6.js +89 -0
- package/dist/runtime/server/ui-dist/assets/{layout-CLyzF__I.js → layout-CKe7FFtd.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/layout-LzBPsYuQ.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{linear-DCEHrHNY.js → linear-B43ve9zv.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/linear-l0QAUUbU.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{mermaid.core-DPCeJESB.js → mermaid.core-B1Kc9vil.js} +4 -4
- package/dist/runtime/server/ui-dist/assets/mermaid.core-miwScivZ.js +256 -0
- package/dist/runtime/server/ui-dist/assets/{mindmap-definition-VGOIOE7T-BmEem54z.js → mindmap-definition-VGOIOE7T-CP7BTJ8W.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/mindmap-definition-VGOIOE7T-CR_z-QXj.js +68 -0
- package/dist/runtime/server/ui-dist/assets/{pieDiagram-ADFJNKIX-DjIZtNwx.js → pieDiagram-ADFJNKIX-CzFVi7LX.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/pieDiagram-ADFJNKIX-DutjHoKB.js +30 -0
- package/dist/runtime/server/ui-dist/assets/{quadrantDiagram-AYHSOK5B-ba-xD4cb.js → quadrantDiagram-AYHSOK5B-B01vhN11.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/quadrantDiagram-AYHSOK5B-DtsydQw_.js +7 -0
- package/dist/runtime/server/ui-dist/assets/{requirementDiagram-UZGBJVZJ-CB358t-a.js → requirementDiagram-UZGBJVZJ-CqpSkmHO.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/requirementDiagram-UZGBJVZJ-CzoU-_5n.js +64 -0
- package/dist/runtime/server/ui-dist/assets/{sankeyDiagram-TZEHDZUN-B0oPaNiW.js → sankeyDiagram-TZEHDZUN-Ch2uV89A.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/sankeyDiagram-TZEHDZUN-wv7zUmh6.js +10 -0
- package/dist/runtime/server/ui-dist/assets/{sequenceDiagram-WL72ISMW-D7n_ZO5c.js → sequenceDiagram-WL72ISMW-Pwm4LgC9.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/sequenceDiagram-WL72ISMW-jLVomywO.js +145 -0
- package/dist/runtime/server/ui-dist/assets/{stateDiagram-FKZM4ZOC-MkMtXK-v.js → stateDiagram-FKZM4ZOC-BoAqb30q.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/stateDiagram-FKZM4ZOC-DPIxY1yH.js +1 -0
- package/dist/runtime/server/ui-dist/assets/stateDiagram-v2-4FDKWEC3-Bk8ue2ZX.js +1 -0
- package/dist/runtime/server/ui-dist/assets/stateDiagram-v2-4FDKWEC3-DdHEax3l.js +1 -0
- package/dist/runtime/server/ui-dist/assets/{timeline-definition-IT6M3QCI-CjBjKaYS.js → timeline-definition-IT6M3QCI-B55SNKUD.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/timeline-definition-IT6M3QCI-SZgQDExY.js +61 -0
- package/dist/runtime/server/ui-dist/assets/{treemap-GDKQZRPO-JNjc1ydw.js → treemap-GDKQZRPO-C7_s0oRG.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/treemap-GDKQZRPO-Cfu1eBkO.js +162 -0
- package/dist/runtime/server/ui-dist/assets/{xychartDiagram-PRI3JC2R-DU-mF_06.js → xychartDiagram-PRI3JC2R-CV9C3rPp.js} +1 -1
- package/dist/runtime/server/ui-dist/assets/xychartDiagram-PRI3JC2R-iEMh7uFR.js +7 -0
- package/dist/runtime/server/ui-dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/runtime/server/ui-dist/assets/OnboardingWizard-DQqBk_u-.js +0 -839
- package/dist/runtime/server/ui-dist/assets/channel-BBXTGjGr.js +0 -1
- package/dist/runtime/server/ui-dist/assets/classDiagram-2ON5EDUG-BNttVhse.js +0 -1
- package/dist/runtime/server/ui-dist/assets/classDiagram-v2-WZHVMYZB-BNttVhse.js +0 -1
- package/dist/runtime/server/ui-dist/assets/clone-dcpmW7Wd.js +0 -1
- package/dist/runtime/server/ui-dist/assets/dx-root-DH9to-bY.js +0 -280
- package/dist/runtime/server/ui-dist/assets/gtm-root-Bz1qVp9E.js +0 -11
- package/dist/runtime/server/ui-dist/assets/index-CmOpk52T.css +0 -1
- package/dist/runtime/server/ui-dist/assets/stateDiagram-v2-4FDKWEC3-Cah7upY-.js +0 -1
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
var Vi=t=>{throw TypeError(t)};var pa=(t,s,n)=>s.has(t)||Vi("Cannot "+n);var Se=(t,s,n)=>(pa(t,s,"read from private field"),n?n.call(t):s.get(t)),Lt=(t,s,n)=>s.has(t)?Vi("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,n),ut=(t,s,n,r)=>(pa(t,s,"write to private field"),r?r.call(t,n):s.set(t,n),n),Ht=(t,s,n)=>(pa(t,s,"access private method"),n);import{r as c,a as Ne,j as e,R as rd}from"./index-C8iEq198.js";import{bJ as ad,bK as Da,bL as id,bM as ld,bN as no,Z as _e,bO as od,bP as cd,bQ as dd,bR as ud,bS as md,bT as xd,bU as Wi,bV as pd,bW as hd,K as ge,bX as $n,M as Me,aR as fe,aU as Ye,bY as Rt,aS as wt,bi as Tt,aG as P,bZ as gd,b_ as cs,b$ as ds,aq as Ae,c0 as us,a9 as z,b4 as ro,a_ as Cn,c1 as nr,ax as Q,c2 as ai,c3 as fd,c4 as Gr,c5 as Hr,aC as Ns,c6 as Jr,c7 as ao,c8 as Yr,c9 as mt,bq as ii,ca as _a,bg as Qn,cb as Sn,aF as Te,bh as dn,br as io,aw as Ve,V as F,cc as fs,b1 as Qs,cd as Ir,a$ as lo,ce as Wt,cf as ws,cg as bd,b3 as ks,ch as qn,ci as bt,cj as un,ck as Fs,cl as jd,cm as vd,cn as yd,co as Nd,cp as Gn,a0 as js,a2 as mn,a3 as xn,a4 as Bn,a1 as vs,cq as wd,cr as nt,cs as vn,ae as Gt,ct as Ue,cu as li,$ as re,bf as rr,cv as oo,cw as co,cx as uo,cy as Qi,cz as mo,cA as vt,cB as yt,bn as Pe,cC as Nt,cD as xo,cE as Fa,cF as _t,cG as po,cH as ho,a6 as oi,cI as ci,a7 as kd,aa as Cd,ab as Sd,ac as Id,ad as Ad,b0 as go,cJ as Pd,cK as fo,aE as Ar,cL as di,aZ as Td,aV as Cs,aB as he,b5 as Gi,b6 as Hi,b7 as Rd,aQ as Hn,b8 as bo,b9 as Ed,bF as Md,ba as Dd,bp as jo,bj as Ut,cM as _d,aA as bs,cN as Pr,aJ as Qt,aI as Ft,aH as zs,a8 as $s,cO as vo,W as In,cP as Fe,cQ as rt,cR as yo,cS as de,cT as xr,cU as Fd,cV as $d,cW as Od,cX as Ld,bm as ft,bl as At,ay as ui,cY as mi,cZ as Xr,c_ as No,be as Rs,a5 as Vt,c$ as Zr,d0 as ea,d1 as xi,d2 as ta,d3 as Ks,d4 as wo,at as Jt,bo as ar,d5 as ot,d6 as Yt,d7 as Gs,d8 as qd,d9 as gs,da as Bd,db as pi,dc as hi,dd as Us,de as Zs,df as Ds,dg as $t,dh as zd,di as Kd,dj as Ud,dk as $a,dl as Ji,ao as is,dm as on,bk as ko,Y as gi,dn as Vd,dp as zn,aM as Ie,dq as Wd,dr as Co,ds as fi,dt as Tr,du as ha,dv as Rr,dw as Pt,dx as Ke,dy as Qd,dz as So,dA as Gd,bd as pn,dB as bi,dC as Oa,dD as Hd,an as cn,O as Le,Q as tt,R as st,dE as Xt,S as jt,dF as He,U as qe,dG as ji,dH as Er,dI as Io,ap as Ce,dJ as Jd,dK as sa,dL as vi,dM as as,dN as Yd,dO as Xd,dP as Zd,dQ as eu,dR as tu,dS as su,dT as nu,dU as ru,dV as au,dW as iu,dX as lu,dY as yi,dZ as ou,d_ as hn,d$ as Yi,e0 as pr,e1 as cu,e2 as du,am as Dt,e3 as uu,e4 as mu,e5 as xu,e6 as pu,e7 as hu,e8 as gu,e9 as fu,ea as bu,eb as ju,ec as vu,ed as yu,ee as Nu,ef as ga,eg as Xi,eh as Zi,ei as wu,ej as ku,ek as Os,el as Ls,em as Cu,en as Su,eo as Ao,ag as kr,ep as el,eq as Iu,er as Au,es as Pu,et as tl,eu as na,ah as Po,ev as fa,ew as Tu,au as To,af as Ru,ai as Eu,aj as Mu,ak as Du,al as _u,_ as Fu,ex as $u,az as sl,ey as Ou,av as Lu,ez as qu,eA as Ro,aD as Bu,bc as La,aK as zu,aL as Y,aN as Ku,aO as Uu,aP as Vu,bG as Wu,aT as Eo,aW as Qu,aX as ba,aY as Gu,bs as Hu,bt as Ju,bu as Yu,bv as Xu,bw as Zu,bx as em,by as tm,bz as sm,bA as nm,bB as rm,bC as am,bD as im,bE as lm,bH as om,bI as cm}from"./OnboardingWizard-aegE4bQH.js";function nl(t,s){const n=new Set(s);return t.filter(r=>!n.has(r))}function dm(t,s,n){const r=t.slice(0);return r[s]=n,r}var fn,Mt,bn,jn,Bt,Es,Zn,er,tr,sr,ct,qa,Ba,za,Ka,Ua,so,um=(so=class extends ad{constructor(s,n,r){super();Lt(this,ct);Lt(this,fn);Lt(this,Mt);Lt(this,bn);Lt(this,jn);Lt(this,Bt);Lt(this,Es);Lt(this,Zn);Lt(this,er);Lt(this,tr);Lt(this,sr,[]);ut(this,fn,s),ut(this,jn,r),ut(this,bn,[]),ut(this,Bt,[]),ut(this,Mt,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&Se(this,Bt).forEach(s=>{s.subscribe(n=>{Ht(this,ct,Ka).call(this,s,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,Se(this,Bt).forEach(s=>{s.destroy()})}setQueries(s,n){ut(this,bn,s),ut(this,jn,n),Da.batch(()=>{const r=Se(this,Bt),a=Ht(this,ct,za).call(this,Se(this,bn));a.forEach(p=>p.observer.setOptions(p.defaultedQueryOptions));const i=a.map(p=>p.observer),l=i.map(p=>p.getCurrentResult()),o=r.length!==i.length,u=i.some((p,h)=>p!==r[h]),d=o||u,m=d?!0:l.some((p,h)=>{const x=Se(this,Mt)[h];return!x||!id(p,x)});!d&&!m||(d&&(ut(this,sr,a),ut(this,Bt,i)),ut(this,Mt,l),this.hasListeners()&&(d&&(nl(r,i).forEach(p=>{p.destroy()}),nl(i,r).forEach(p=>{p.subscribe(h=>{Ht(this,ct,Ka).call(this,p,h)})})),Ht(this,ct,Ua).call(this)))})}getCurrentResult(){return Se(this,Mt)}getQueries(){return Se(this,Bt).map(s=>s.getCurrentQuery())}getObservers(){return Se(this,Bt)}getOptimisticResult(s,n){const r=Ht(this,ct,za).call(this,s),a=r.map(l=>l.observer.getOptimisticResult(l.defaultedQueryOptions)),i=r.map(l=>l.defaultedQueryOptions.queryHash);return[a,l=>Ht(this,ct,Ba).call(this,l??a,n,i),()=>Ht(this,ct,qa).call(this,a,r)]}},fn=new WeakMap,Mt=new WeakMap,bn=new WeakMap,jn=new WeakMap,Bt=new WeakMap,Es=new WeakMap,Zn=new WeakMap,er=new WeakMap,tr=new WeakMap,sr=new WeakMap,ct=new WeakSet,qa=function(s,n){return n.map((r,a)=>{const i=s[a];return r.defaultedQueryOptions.notifyOnChangeProps?i:r.observer.trackResult(i,l=>{n.forEach(o=>{o.observer.trackProp(l)})})})},Ba=function(s,n,r){if(n){const a=Se(this,tr),i=r!==void 0&&a!==void 0&&(a.length!==r.length||r.some((l,o)=>l!==a[o]));return(!Se(this,Es)||Se(this,Mt)!==Se(this,er)||i||n!==Se(this,Zn))&&(ut(this,Zn,n),ut(this,er,Se(this,Mt)),r!==void 0&&ut(this,tr,r),ut(this,Es,ld(Se(this,Es),n(s)))),Se(this,Es)}return s},za=function(s){const n=new Map;Se(this,Bt).forEach(a=>{const i=a.options.queryHash;if(!i)return;const l=n.get(i);l?l.push(a):n.set(i,[a])});const r=[];return s.forEach(a=>{var u;const i=Se(this,fn).defaultQueryOptions(a),o=((u=n.get(i.queryHash))==null?void 0:u.shift())??new no(Se(this,fn),i);r.push({defaultedQueryOptions:i,observer:o})}),r},Ka=function(s,n){const r=Se(this,Bt).indexOf(s);r!==-1&&(ut(this,Mt,dm(Se(this,Mt),r,n)),Ht(this,ct,Ua).call(this))},Ua=function(){var s;if(this.hasListeners()){const n=Se(this,Es),r=Ht(this,ct,qa).call(this,Se(this,Mt),Se(this,sr)),a=Ht(this,ct,Ba).call(this,r,(s=Se(this,jn))==null?void 0:s.combine);n!==a&&Da.batch(()=>{this.listeners.forEach(i=>{i(Se(this,Mt))})})}},so);function rl({queries:t,...s},n){const r=_e(),a=od(),i=cd(),l=c.useMemo(()=>t.map(N=>{const b=r.defaultQueryOptions(N);return b._optimisticResults=a?"isRestoring":"optimistic",b}),[t,r,a]);l.forEach(N=>{dd(N);const b=r.getQueryCache().get(N.queryHash);ud(N,i,b)}),md(i);const[o]=c.useState(()=>new um(r,l,s)),[u,d,m]=o.getOptimisticResult(l,s.combine),p=!a&&s.subscribed!==!1;c.useSyncExternalStore(c.useCallback(N=>p?o.subscribe(Da.batchCalls(N)):xd,[o,p]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),c.useEffect(()=>{o.setQueries(l,s)},[l,s,o]);const x=u.some((N,b)=>Wi(l[b],N))?u.flatMap((N,b)=>{const g=l[b];if(g&&Wi(g,N)){const T=new no(r,g);return pd(g,T,i)}return[]}):[];if(x.length>0)throw Promise.all(x);const y=u.find((N,b)=>{const g=l[b];return g&&hd({result:N,errorResetBoundary:i,throwOnError:g.throwOnError,query:r.getQueryCache().get(g.queryHash),suspense:g.suspense})});if(y!=null&&y.error)throw y.error;return d(m())}/**
|
|
2
|
+
* @license lucide-react v0.574.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const mm=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],xm=ge("archive-restore",mm);/**
|
|
7
|
+
* @license lucide-react v0.574.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const pm=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],hm=ge("archive",pm);/**
|
|
12
|
+
* @license lucide-react v0.574.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const gm=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],fm=ge("arrow-down-left",gm);/**
|
|
17
|
+
* @license lucide-react v0.574.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const bm=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],jm=ge("arrow-up-down",bm);/**
|
|
22
|
+
* @license lucide-react v0.574.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const vm=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Va=ge("book-open",vm);/**
|
|
27
|
+
* @license lucide-react v0.574.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ym=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Nm=ge("calendar-clock",ym);/**
|
|
32
|
+
* @license lucide-react v0.574.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const wm=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],km=ge("calendar-days",wm);/**
|
|
37
|
+
* @license lucide-react v0.574.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const Cm=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Sm=ge("chevrons-right",Cm);/**
|
|
42
|
+
* @license lucide-react v0.574.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const Im=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Am=ge("circle-check-big",Im);/**
|
|
47
|
+
* @license lucide-react v0.574.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Pm=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],Mo=ge("clock-3",Pm);/**
|
|
52
|
+
* @license lucide-react v0.574.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const Tm=[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]],Wa=ge("coins",Tm);/**
|
|
57
|
+
* @license lucide-react v0.574.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Rm=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Em=ge("columns-3",Rm);/**
|
|
62
|
+
* @license lucide-react v0.574.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const Mm=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],Dm=ge("command",Mm);/**
|
|
67
|
+
* @license lucide-react v0.574.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const _m=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ls=ge("dollar-sign",_m);/**
|
|
72
|
+
* @license lucide-react v0.574.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Fm=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],ra=ge("flask-conical",Fm);/**
|
|
77
|
+
* @license lucide-react v0.574.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const $m=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Om=ge("funnel",$m);/**
|
|
82
|
+
* @license lucide-react v0.574.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const Lm=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],Cr=ge("git-pull-request",Lm);/**
|
|
87
|
+
* @license lucide-react v0.574.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const qm=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],al=ge("github",qm);/**
|
|
92
|
+
* @license lucide-react v0.574.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const Bm=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Jn=ge("history",Bm);/**
|
|
97
|
+
* @license lucide-react v0.574.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const zm=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Km=ge("house",zm);/**
|
|
102
|
+
* @license lucide-react v0.574.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const Um=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Do=ge("layers",Um);/**
|
|
107
|
+
* @license lucide-react v0.574.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const Vm=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Vs=ge("layout-dashboard",Vm);/**
|
|
112
|
+
* @license lucide-react v0.574.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const Wm=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Qm=ge("layout-grid",Wm);/**
|
|
117
|
+
* @license lucide-react v0.574.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const Gm=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Ni=ge("list",Gm);/**
|
|
122
|
+
* @license lucide-react v0.574.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const Hm=[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m14.305 7.53.923-.382",key:"1mlnsw"}],["path",{d:"m15.228 4.852-.923-.383",key:"82mpwg"}],["path",{d:"m16.852 3.228-.383-.924",key:"ln4sir"}],["path",{d:"m16.852 8.772-.383.923",key:"1dejw0"}],["path",{d:"m19.148 3.228.383-.924",key:"192kgf"}],["path",{d:"m19.53 9.696-.382-.924",key:"fiavlr"}],["path",{d:"m20.772 4.852.924-.383",key:"1j8mgp"}],["path",{d:"m20.772 7.148.924.383",key:"zix9be"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]],Jm=ge("monitor-cog",Hm);/**
|
|
127
|
+
* @license lucide-react v0.574.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const Ym=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],Xm=ge("octagon-alert",Ym);/**
|
|
132
|
+
* @license lucide-react v0.574.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const Zm=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],ex=ge("panels-top-left",Zm);/**
|
|
137
|
+
* @license lucide-react v0.574.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const tx=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Qa=ge("pencil",tx);/**
|
|
142
|
+
* @license lucide-react v0.574.0 - ISC
|
|
143
|
+
*
|
|
144
|
+
* This source code is licensed under the ISC license.
|
|
145
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
+
*/const sx=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],nx=ge("power",sx);/**
|
|
147
|
+
* @license lucide-react v0.574.0 - ISC
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the ISC license.
|
|
150
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
+
*/const rx=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],ax=ge("radio-tower",rx);/**
|
|
152
|
+
* @license lucide-react v0.574.0 - ISC
|
|
153
|
+
*
|
|
154
|
+
* This source code is licensed under the ISC license.
|
|
155
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
+
*/const ix=[["path",{d:"M13 16H8",key:"wsln4y"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z",key:"ycz6yz"}]],Ga=ge("receipt-text",ix);/**
|
|
157
|
+
* @license lucide-react v0.574.0 - ISC
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the ISC license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/const lx=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],wi=ge("shield-check",lx);/**
|
|
162
|
+
* @license lucide-react v0.574.0 - ISC
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the ISC license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/const ox=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],il=ge("square-activity",ox);/**
|
|
167
|
+
* @license lucide-react v0.574.0 - ISC
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the ISC license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/const cx=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],ki=ge("square-pen",cx);/**
|
|
172
|
+
* @license lucide-react v0.574.0 - ISC
|
|
173
|
+
*
|
|
174
|
+
* This source code is licensed under the ISC license.
|
|
175
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
+
*/const dx=[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ux=ge("trash",dx);/**
|
|
177
|
+
* @license lucide-react v0.574.0 - ISC
|
|
178
|
+
*
|
|
179
|
+
* This source code is licensed under the ISC license.
|
|
180
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
+
*/const mx=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ll=ge("upload",mx);/**
|
|
182
|
+
* @license lucide-react v0.574.0 - ISC
|
|
183
|
+
*
|
|
184
|
+
* This source code is licensed under the ISC license.
|
|
185
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
+
*/const xx=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],px=ge("user-plus",xx);/**
|
|
187
|
+
* @license lucide-react v0.574.0 - ISC
|
|
188
|
+
*
|
|
189
|
+
* This source code is licensed under the ISC license.
|
|
190
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
+
*/const hx=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],gx=ge("webhook",hx);function fx(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return c.useMemo(()=>r=>{s.forEach(a=>a(r))},s)}const aa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function An(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Ci(t){return"nodeType"in t}function kt(t){var s,n;return t?An(t)?t:Ci(t)&&(s=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?s:window:window}function Si(t){const{Document:s}=kt(t);return t instanceof s}function ir(t){return An(t)?!1:t instanceof kt(t).HTMLElement}function _o(t){return t instanceof kt(t).SVGElement}function Pn(t){return t?An(t)?t.document:Ci(t)?Si(t)?t:ir(t)||_o(t)?t.ownerDocument:document:document:document}const Zt=aa?c.useLayoutEffect:c.useEffect;function ia(t){const s=c.useRef(t);return Zt(()=>{s.current=t}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return s.current==null?void 0:s.current(...r)},[])}function bx(){const t=c.useRef(null),s=c.useCallback((r,a)=>{t.current=setInterval(r,a)},[]),n=c.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,n]}function Yn(t,s){s===void 0&&(s=[t]);const n=c.useRef(t);return Zt(()=>{n.current!==t&&(n.current=t)},s),n}function lr(t,s){const n=c.useRef();return c.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...s])}function Mr(t){const s=ia(t),n=c.useRef(null),r=c.useCallback(a=>{a!==n.current&&(s==null||s(a,n.current)),n.current=a},[]);return[n,r]}function Dr(t){const s=c.useRef();return c.useEffect(()=>{s.current=t},[t]),s.current}let ja={};function or(t,s){return c.useMemo(()=>{if(s)return s;const n=ja[t]==null?0:ja[t]+1;return ja[t]=n,t+"-"+n},[t,s])}function Fo(t){return function(s){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce((i,l)=>{const o=Object.entries(l);for(const[u,d]of o){const m=i[u];m!=null&&(i[u]=m+t*d)}return i},{...s})}}const gn=Fo(1),_r=Fo(-1);function jx(t){return"clientX"in t&&"clientY"in t}function la(t){if(!t)return!1;const{KeyboardEvent:s}=kt(t.target);return s&&t instanceof s}function vx(t){if(!t)return!1;const{TouchEvent:s}=kt(t.target);return s&&t instanceof s}function Fr(t){if(vx(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:n}=t.touches[0];return{x:s,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:n}=t.changedTouches[0];return{x:s,y:n}}}return jx(t)?{x:t.clientX,y:t.clientY}:null}const ms=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:n}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:n}=t;return"scaleX("+s+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[ms.Translate.toString(t),ms.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:n,easing:r}=t;return s+" "+n+"ms "+r}}}),ol="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yx(t){return t.matches(ol)?t:t.querySelector(ol)}const Nx={display:"none"};function wx(t){let{id:s,value:n}=t;return Ne.createElement("div",{id:s,style:Nx},n)}function kx(t){let{id:s,announcement:n,ariaLiveType:r="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ne.createElement("div",{id:s,style:a,role:"status","aria-live":r,"aria-atomic":!0},n)}function Cx(){const[t,s]=c.useState("");return{announce:c.useCallback(r=>{r!=null&&s(r)},[]),announcement:t}}const $o=c.createContext(null);function Sx(t){const s=c.useContext($o);c.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(t)},[t,s])}function Ix(){const[t]=c.useState(()=>new Set),s=c.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[c.useCallback(r=>{let{type:a,event:i}=r;t.forEach(l=>{var o;return(o=l[a])==null?void 0:o.call(l,i)})},[t]),s]}const Ax={draggable:`
|
|
192
|
+
To pick up a draggable item, press the space bar.
|
|
193
|
+
While dragging, use the arrow keys to move the item.
|
|
194
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
195
|
+
`},Px={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was moved over droppable area "+n.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:n}=t;return n?"Draggable item "+s.id+" was dropped over droppable area "+n.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Tx(t){let{announcements:s=Px,container:n,hiddenTextDescribedById:r,screenReaderInstructions:a=Ax}=t;const{announce:i,announcement:l}=Cx(),o=or("DndLiveRegion"),[u,d]=c.useState(!1);if(c.useEffect(()=>{d(!0)},[]),Sx(c.useMemo(()=>({onDragStart(p){let{active:h}=p;i(s.onDragStart({active:h}))},onDragMove(p){let{active:h,over:x}=p;s.onDragMove&&i(s.onDragMove({active:h,over:x}))},onDragOver(p){let{active:h,over:x}=p;i(s.onDragOver({active:h,over:x}))},onDragEnd(p){let{active:h,over:x}=p;i(s.onDragEnd({active:h,over:x}))},onDragCancel(p){let{active:h,over:x}=p;i(s.onDragCancel({active:h,over:x}))}}),[i,s])),!u)return null;const m=Ne.createElement(Ne.Fragment,null,Ne.createElement(wx,{id:r,value:a.draggable}),Ne.createElement(kx,{id:o,announcement:l}));return n?$n.createPortal(m,n):m}var Je;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Je||(Je={}));function $r(){}function Ii(t,s){return c.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function Ai(){for(var t=arguments.length,s=new Array(t),n=0;n<t;n++)s[n]=arguments[n];return c.useMemo(()=>[...s].filter(r=>r!=null),[...s])}const es=Object.freeze({x:0,y:0});function Rx(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function Ex(t,s){const n=Fr(t);if(!n)return"0 0";const r={x:(n.x-s.left)/s.width*100,y:(n.y-s.top)/s.height*100};return r.x+"% "+r.y+"%"}function Mx(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return n-r}function Dx(t,s){let{data:{value:n}}=t,{data:{value:r}}=s;return r-n}function _x(t,s){if(!t||t.length===0)return null;const[n]=t;return n[s]}function cl(t,s,n){return s===void 0&&(s=t.left),n===void 0&&(n=t.top),{x:s+t.width*.5,y:n+t.height*.5}}const Oo=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=cl(s,s.left,s.top),i=[];for(const l of r){const{id:o}=l,u=n.get(o);if(u){const d=Rx(cl(u),a);i.push({id:o,data:{droppableContainer:l,value:d}})}}return i.sort(Mx)};function Fx(t,s){const n=Math.max(s.top,t.top),r=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),i=Math.min(s.top+s.height,t.top+t.height),l=a-r,o=i-n;if(r<a&&n<i){const u=s.width*s.height,d=t.width*t.height,m=l*o,p=m/(u+d-m);return Number(p.toFixed(4))}return 0}const $x=t=>{let{collisionRect:s,droppableRects:n,droppableContainers:r}=t;const a=[];for(const i of r){const{id:l}=i,o=n.get(l);if(o){const u=Fx(o,s);u>0&&a.push({id:l,data:{droppableContainer:i,value:u}})}}return a.sort(Dx)};function Ox(t,s,n){return{...t,scaleX:s&&n?s.width/n.width:1,scaleY:s&&n?s.height/n.height:1}}function Lo(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:es}function Lx(t){return function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];return a.reduce((l,o)=>({...l,top:l.top+t*o.y,bottom:l.bottom+t*o.y,left:l.left+t*o.x,right:l.right+t*o.x}),{...n})}}const qx=Lx(1);function qo(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Bx(t,s,n){const r=qo(s);if(!r)return t;const{scaleX:a,scaleY:i,x:l,y:o}=r,u=t.left-l-(1-a)*parseFloat(n),d=t.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),m=a?t.width/a:t.width,p=i?t.height/i:t.height;return{width:m,height:p,top:d,right:u+m,bottom:d+p,left:u}}const zx={ignoreTransform:!1};function Tn(t,s){s===void 0&&(s=zx);let n=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:d,transformOrigin:m}=kt(t).getComputedStyle(t);d&&(n=Bx(n,d,m))}const{top:r,left:a,width:i,height:l,bottom:o,right:u}=n;return{top:r,left:a,width:i,height:l,bottom:o,right:u}}function dl(t){return Tn(t,{ignoreTransform:!0})}function Kx(t){const s=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:s,bottom:n,width:s,height:n}}function Ux(t,s){return s===void 0&&(s=kt(t).getComputedStyle(t)),s.position==="fixed"}function Vx(t,s){s===void 0&&(s=kt(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const i=s[a];return typeof i=="string"?n.test(i):!1})}function Pi(t,s){const n=[];function r(a){if(s!=null&&n.length>=s||!a)return n;if(Si(a)&&a.scrollingElement!=null&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!ir(a)||_o(a)||n.includes(a))return n;const i=kt(t).getComputedStyle(a);return a!==t&&Vx(a,i)&&n.push(a),Ux(a,i)?n:r(a.parentNode)}return t?r(t):n}function Bo(t){const[s]=Pi(t,1);return s??null}function va(t){return!aa||!t?null:An(t)?t:Ci(t)?Si(t)||t===Pn(t).scrollingElement?window:ir(t)?t:null:null}function zo(t){return An(t)?t.scrollX:t.scrollLeft}function Ko(t){return An(t)?t.scrollY:t.scrollTop}function Ha(t){return{x:zo(t),y:Ko(t)}}var et;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(et||(et={}));function Uo(t){return!aa||!t?!1:t===document.scrollingElement}function Vo(t){const s={x:0,y:0},n=Uo(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},a=t.scrollTop<=s.y,i=t.scrollLeft<=s.x,l=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:a,isLeft:i,isBottom:l,isRight:o,maxScroll:r,minScroll:s}}const Wx={x:.2,y:.2};function Qx(t,s,n,r,a){let{top:i,left:l,right:o,bottom:u}=n;r===void 0&&(r=10),a===void 0&&(a=Wx);const{isTop:d,isBottom:m,isLeft:p,isRight:h}=Vo(t),x={x:0,y:0},y={x:0,y:0},N={height:s.height*a.y,width:s.width*a.x};return!d&&i<=s.top+N.height?(x.y=et.Backward,y.y=r*Math.abs((s.top+N.height-i)/N.height)):!m&&u>=s.bottom-N.height&&(x.y=et.Forward,y.y=r*Math.abs((s.bottom-N.height-u)/N.height)),!h&&o>=s.right-N.width?(x.x=et.Forward,y.x=r*Math.abs((s.right-N.width-o)/N.width)):!p&&l<=s.left+N.width&&(x.x=et.Backward,y.x=r*Math.abs((s.left+N.width-l)/N.width)),{direction:x,speed:y}}function Gx(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:l}=window;return{top:0,left:0,right:i,bottom:l,width:i,height:l}}const{top:s,left:n,right:r,bottom:a}=t.getBoundingClientRect();return{top:s,left:n,right:r,bottom:a,width:t.clientWidth,height:t.clientHeight}}function Wo(t){return t.reduce((s,n)=>gn(s,Ha(n)),es)}function Hx(t){return t.reduce((s,n)=>s+zo(n),0)}function Jx(t){return t.reduce((s,n)=>s+Ko(n),0)}function Qo(t,s){if(s===void 0&&(s=Tn),!t)return;const{top:n,left:r,bottom:a,right:i}=s(t);Bo(t)&&(a<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Yx=[["x",["left","right"],Hx],["y",["top","bottom"],Jx]];class Ti{constructor(s,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Pi(n),a=Wo(r);this.rect={...s},this.width=s.width,this.height=s.height;for(const[i,l,o]of Yx)for(const u of l)Object.defineProperty(this,u,{get:()=>{const d=o(r),m=a[i]-d;return this.rect[u]+m},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Kn{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=s}add(s,n,r){var a;(a=this.target)==null||a.addEventListener(s,n,r),this.listeners.push([s,n,r])}}function Xx(t){const{EventTarget:s}=kt(t);return t instanceof s?t:Pn(t)}function ya(t,s){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof s=="number"?Math.sqrt(n**2+r**2)>s:"x"in s&&"y"in s?n>s.x&&r>s.y:"x"in s?n>s.x:"y"in s?r>s.y:!1}var Kt;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Kt||(Kt={}));function ul(t){t.preventDefault()}function Zx(t){t.stopPropagation()}var ke;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ke||(ke={}));const Go={start:[ke.Space,ke.Enter],cancel:[ke.Esc],end:[ke.Space,ke.Enter,ke.Tab]},ep=(t,s)=>{let{currentCoordinates:n}=s;switch(t.code){case ke.Right:return{...n,x:n.x+25};case ke.Left:return{...n,x:n.x-25};case ke.Down:return{...n,y:n.y+25};case ke.Up:return{...n,y:n.y-25}}};class Ho{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:n}}=s;this.props=s,this.listeners=new Kn(Pn(n)),this.windowListeners=new Kn(kt(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Kt.Resize,this.handleCancel),this.windowListeners.add(Kt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Kt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:n}=this.props,r=s.node.current;r&&Qo(r),n(es)}handleKeyDown(s){if(la(s)){const{active:n,context:r,options:a}=this.props,{keyboardCodes:i=Go,coordinateGetter:l=ep,scrollBehavior:o="smooth"}=a,{code:u}=s;if(i.end.includes(u)){this.handleEnd(s);return}if(i.cancel.includes(u)){this.handleCancel(s);return}const{collisionRect:d}=r.current,m=d?{x:d.left,y:d.top}:es;this.referenceCoordinates||(this.referenceCoordinates=m);const p=l(s,{active:n,context:r.current,currentCoordinates:m});if(p){const h=_r(p,m),x={x:0,y:0},{scrollableAncestors:y}=r.current;for(const N of y){const b=s.code,{isTop:g,isRight:T,isLeft:k,isBottom:C,maxScroll:f,minScroll:j}=Vo(N),v=Gx(N),U={x:Math.min(b===ke.Right?v.right-v.width/2:v.right,Math.max(b===ke.Right?v.left:v.left+v.width/2,p.x)),y:Math.min(b===ke.Down?v.bottom-v.height/2:v.bottom,Math.max(b===ke.Down?v.top:v.top+v.height/2,p.y))},A=b===ke.Right&&!T||b===ke.Left&&!k,B=b===ke.Down&&!C||b===ke.Up&&!g;if(A&&U.x!==p.x){const W=N.scrollLeft+h.x,S=b===ke.Right&&W<=f.x||b===ke.Left&&W>=j.x;if(S&&!h.y){N.scrollTo({left:W,behavior:o});return}S?x.x=N.scrollLeft-W:x.x=b===ke.Right?N.scrollLeft-f.x:N.scrollLeft-j.x,x.x&&N.scrollBy({left:-x.x,behavior:o});break}else if(B&&U.y!==p.y){const W=N.scrollTop+h.y,S=b===ke.Down&&W<=f.y||b===ke.Up&&W>=j.y;if(S&&!h.x){N.scrollTo({top:W,behavior:o});return}S?x.y=N.scrollTop-W:x.y=b===ke.Down?N.scrollTop-f.y:N.scrollTop-j.y,x.y&&N.scrollBy({top:-x.y,behavior:o});break}}this.handleMove(s,gn(_r(p,this.referenceCoordinates),x))}}}handleMove(s,n){const{onMove:r}=this.props;s.preventDefault(),r(n)}handleEnd(s){const{onEnd:n}=this.props;s.preventDefault(),this.detach(),n()}handleCancel(s){const{onCancel:n}=this.props;s.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ho.activators=[{eventName:"onKeyDown",handler:(t,s,n)=>{let{keyboardCodes:r=Go,onActivation:a}=s,{active:i}=n;const{code:l}=t.nativeEvent;if(r.start.includes(l)){const o=i.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function ml(t){return!!(t&&"distance"in t)}function xl(t){return!!(t&&"delay"in t)}class Ri{constructor(s,n,r){var a;r===void 0&&(r=Xx(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=n;const{event:i}=s,{target:l}=i;this.props=s,this.events=n,this.document=Pn(l),this.documentListeners=new Kn(this.document),this.listeners=new Kn(r),this.windowListeners=new Kn(kt(l)),this.initialCoordinates=(a=Fr(i))!=null?a:es,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Kt.Resize,this.handleCancel),this.windowListeners.add(Kt.DragStart,ul),this.windowListeners.add(Kt.VisibilityChange,this.handleCancel),this.windowListeners.add(Kt.ContextMenu,ul),this.documentListeners.add(Kt.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(xl(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(ml(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,n){const{active:r,onPending:a}=this.props;a(r,s,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:s}=this,{onStart:n}=this.props;s&&(this.activated=!0,this.documentListeners.add(Kt.Click,Zx,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Kt.SelectionChange,this.removeTextSelection),n(s))}handleMove(s){var n;const{activated:r,initialCoordinates:a,props:i}=this,{onMove:l,options:{activationConstraint:o}}=i;if(!a)return;const u=(n=Fr(s))!=null?n:es,d=_r(a,u);if(!r&&o){if(ml(o)){if(o.tolerance!=null&&ya(d,o.tolerance))return this.handleCancel();if(ya(d,o.distance))return this.handleStart()}if(xl(o)&&ya(d,o.tolerance))return this.handleCancel();this.handlePending(o,d);return}s.cancelable&&s.preventDefault(),l(u)}handleEnd(){const{onAbort:s,onEnd:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleCancel(){const{onAbort:s,onCancel:n}=this.props;this.detach(),this.activated||s(this.props.active),n()}handleKeydown(s){s.code===ke.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const tp={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class cr extends Ri{constructor(s){const{event:n}=s,r=Pn(n.target);super(s,tp,r)}}cr.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const sp={move:{name:"mousemove"},end:{name:"mouseup"}};var Ja;(function(t){t[t.RightClick=2]="RightClick"})(Ja||(Ja={}));class np extends Ri{constructor(s){super(s,sp,Pn(s.event.target))}}np.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;return n.button===Ja.RightClick?!1:(r==null||r({event:n}),!0)}}];const Na={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class rp extends Ri{constructor(s){super(s,Na)}static setup(){return window.addEventListener(Na.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Na.move.name,s)};function s(){}}}rp.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:n}=t,{onActivation:r}=s;const{touches:a}=n;return a.length>1?!1:(r==null||r({event:n}),!0)}}];var Un;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(Un||(Un={}));var Or;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Or||(Or={}));function ap(t){let{acceleration:s,activator:n=Un.Pointer,canScroll:r,draggingRect:a,enabled:i,interval:l=5,order:o=Or.TreeOrder,pointerCoordinates:u,scrollableAncestors:d,scrollableAncestorRects:m,delta:p,threshold:h}=t;const x=lp({delta:p,disabled:!i}),[y,N]=bx(),b=c.useRef({x:0,y:0}),g=c.useRef({x:0,y:0}),T=c.useMemo(()=>{switch(n){case Un.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case Un.DraggableRect:return a}},[n,a,u]),k=c.useRef(null),C=c.useCallback(()=>{const j=k.current;if(!j)return;const v=b.current.x*g.current.x,U=b.current.y*g.current.y;j.scrollBy(v,U)},[]),f=c.useMemo(()=>o===Or.TreeOrder?[...d].reverse():d,[o,d]);c.useEffect(()=>{if(!i||!d.length||!T){N();return}for(const j of f){if((r==null?void 0:r(j))===!1)continue;const v=d.indexOf(j),U=m[v];if(!U)continue;const{direction:A,speed:B}=Qx(j,U,T,s,h);for(const W of["x","y"])x[W][A[W]]||(B[W]=0,A[W]=0);if(B.x>0||B.y>0){N(),k.current=j,y(C,l),b.current=B,g.current=A;return}}b.current={x:0,y:0},g.current={x:0,y:0},N()},[s,C,r,N,i,l,JSON.stringify(T),JSON.stringify(x),y,d,f,m,JSON.stringify(h)])}const ip={x:{[et.Backward]:!1,[et.Forward]:!1},y:{[et.Backward]:!1,[et.Forward]:!1}};function lp(t){let{delta:s,disabled:n}=t;const r=Dr(s);return lr(a=>{if(n||!r||!a)return ip;const i={x:Math.sign(s.x-r.x),y:Math.sign(s.y-r.y)};return{x:{[et.Backward]:a.x[et.Backward]||i.x===-1,[et.Forward]:a.x[et.Forward]||i.x===1},y:{[et.Backward]:a.y[et.Backward]||i.y===-1,[et.Forward]:a.y[et.Forward]||i.y===1}}},[n,s,r])}function op(t,s){const n=s!=null?t.get(s):void 0,r=n?n.node.current:null;return lr(a=>{var i;return s==null?null:(i=r??a)!=null?i:null},[r,s])}function cp(t,s){return c.useMemo(()=>t.reduce((n,r)=>{const{sensor:a}=r,i=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,r)}));return[...n,...i]},[]),[t,s])}var Xn;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Xn||(Xn={}));var Ya;(function(t){t.Optimized="optimized"})(Ya||(Ya={}));const pl=new Map;function dp(t,s){let{dragging:n,dependencies:r,config:a}=s;const[i,l]=c.useState(null),{frequency:o,measure:u,strategy:d}=a,m=c.useRef(t),p=b(),h=Yn(p),x=c.useCallback(function(g){g===void 0&&(g=[]),!h.current&&l(T=>T===null?g:T.concat(g.filter(k=>!T.includes(k))))},[h]),y=c.useRef(null),N=lr(g=>{if(p&&!n)return pl;if(!g||g===pl||m.current!==t||i!=null){const T=new Map;for(let k of t){if(!k)continue;if(i&&i.length>0&&!i.includes(k.id)&&k.rect.current){T.set(k.id,k.rect.current);continue}const C=k.node.current,f=C?new Ti(u(C),C):null;k.rect.current=f,f&&T.set(k.id,f)}return T}return g},[t,i,n,p,u]);return c.useEffect(()=>{m.current=t},[t]),c.useEffect(()=>{p||x()},[n,p]),c.useEffect(()=>{i&&i.length>0&&l(null)},[JSON.stringify(i)]),c.useEffect(()=>{p||typeof o!="number"||y.current!==null||(y.current=setTimeout(()=>{x(),y.current=null},o))},[o,p,x,...r]),{droppableRects:N,measureDroppableContainers:x,measuringScheduled:i!=null};function b(){switch(d){case Xn.Always:return!1;case Xn.BeforeDragging:return n;default:return!n}}}function Ei(t,s){return lr(n=>t?n||(typeof s=="function"?s(t):t):null,[s,t])}function up(t,s){return Ei(t,s)}function mp(t){let{callback:s,disabled:n}=t;const r=ia(s),a=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return c.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function oa(t){let{callback:s,disabled:n}=t;const r=ia(s),a=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return c.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function xp(t){return new Ti(Tn(t),t)}function hl(t,s,n){s===void 0&&(s=xp);const[r,a]=c.useState(null);function i(){a(u=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=u??n)!=null?d:null}const m=s(t);return JSON.stringify(u)===JSON.stringify(m)?u:m})}const l=mp({callback(u){if(t)for(const d of u){const{type:m,target:p}=d;if(m==="childList"&&p instanceof HTMLElement&&p.contains(t)){i();break}}}}),o=oa({callback:i});return Zt(()=>{i(),t?(o==null||o.observe(t),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(o==null||o.disconnect(),l==null||l.disconnect())},[t]),r}function pp(t){const s=Ei(t);return Lo(t,s)}const gl=[];function hp(t){const s=c.useRef(t),n=lr(r=>t?r&&r!==gl&&t&&s.current&&t.parentNode===s.current.parentNode?r:Pi(t):gl,[t]);return c.useEffect(()=>{s.current=t},[t]),n}function gp(t){const[s,n]=c.useState(null),r=c.useRef(t),a=c.useCallback(i=>{const l=va(i.target);l&&n(o=>o?(o.set(l,Ha(l)),new Map(o)):null)},[]);return c.useEffect(()=>{const i=r.current;if(t!==i){l(i);const o=t.map(u=>{const d=va(u);return d?(d.addEventListener("scroll",a,{passive:!0}),[d,Ha(d)]):null}).filter(u=>u!=null);n(o.length?new Map(o):null),r.current=t}return()=>{l(t),l(i)};function l(o){o.forEach(u=>{const d=va(u);d==null||d.removeEventListener("scroll",a)})}},[a,t]),c.useMemo(()=>t.length?s?Array.from(s.values()).reduce((i,l)=>gn(i,l),es):Wo(t):es,[t,s])}function fl(t,s){s===void 0&&(s=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},s),c.useEffect(()=>{const r=t!==es;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?_r(t,n.current):es}function fp(t){c.useEffect(()=>{if(!aa)return;const s=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of s)n==null||n()}},t.map(s=>{let{sensor:n}=s;return n}))}function bp(t,s){return c.useMemo(()=>t.reduce((n,r)=>{let{eventName:a,handler:i}=r;return n[a]=l=>{i(l,s)},n},{}),[t,s])}function Jo(t){return c.useMemo(()=>t?Kx(t):null,[t])}const bl=[];function jp(t,s){s===void 0&&(s=Tn);const[n]=t,r=Jo(n?kt(n):null),[a,i]=c.useState(bl);function l(){i(()=>t.length?t.map(u=>Uo(u)?r:new Ti(s(u),u)):bl)}const o=oa({callback:l});return Zt(()=>{o==null||o.disconnect(),l(),t.forEach(u=>o==null?void 0:o.observe(u))},[t]),a}function Yo(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return ir(s)?s:t}function vp(t){let{measure:s}=t;const[n,r]=c.useState(null),a=c.useCallback(d=>{for(const{target:m}of d)if(ir(m)){r(p=>{const h=s(m);return p?{...p,width:h.width,height:h.height}:h});break}},[s]),i=oa({callback:a}),l=c.useCallback(d=>{const m=Yo(d);i==null||i.disconnect(),m&&(i==null||i.observe(m)),r(m?s(m):null)},[s,i]),[o,u]=Mr(l);return c.useMemo(()=>({nodeRef:o,rect:n,setRef:u}),[n,o,u])}const yp=[{sensor:cr,options:{}},{sensor:Ho,options:{}}],Np={current:{}},Sr={draggable:{measure:dl},droppable:{measure:dl,strategy:Xn.WhileDragging,frequency:Ya.Optimized},dragOverlay:{measure:Tn}};class Vn extends Map{get(s){var n;return s!=null&&(n=super.get(s))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:n}=s;return!n})}getNodeFor(s){var n,r;return(n=(r=this.get(s))==null?void 0:r.node.current)!=null?n:void 0}}const wp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Vn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:$r},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Sr,measureDroppableContainers:$r,windowRect:null,measuringScheduled:!1},Xo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:$r,draggableNodes:new Map,over:null,measureDroppableContainers:$r},dr=c.createContext(Xo),Zo=c.createContext(wp);function kp(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Vn}}}function Cp(t,s){switch(s.type){case Je.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Je.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case Je.DragEnd:case Je.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Je.RegisterDroppable:{const{element:n}=s,{id:r}=n,a=new Vn(t.droppable.containers);return a.set(r,n),{...t,droppable:{...t.droppable,containers:a}}}case Je.SetDroppableDisabled:{const{id:n,key:r,disabled:a}=s,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const l=new Vn(t.droppable.containers);return l.set(n,{...i,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case Je.UnregisterDroppable:{const{id:n,key:r}=s,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const i=new Vn(t.droppable.containers);return i.delete(n),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function Sp(t){let{disabled:s}=t;const{active:n,activatorEvent:r,draggableNodes:a}=c.useContext(dr),i=Dr(r),l=Dr(n==null?void 0:n.id);return c.useEffect(()=>{if(!s&&!r&&i&&l!=null){if(!la(i)||document.activeElement===i.target)return;const o=a.get(l);if(!o)return;const{activatorNode:u,node:d}=o;if(!u.current&&!d.current)return;requestAnimationFrame(()=>{for(const m of[u.current,d.current]){if(!m)continue;const p=yx(m);if(p){p.focus();break}}})}},[r,s,a,l,i]),null}function ec(t,s){let{transform:n,...r}=s;return t!=null&&t.length?t.reduce((a,i)=>i({transform:a,...r}),n):n}function Ip(t){return c.useMemo(()=>({draggable:{...Sr.draggable,...t==null?void 0:t.draggable},droppable:{...Sr.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Sr.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function Ap(t){let{activeNode:s,measure:n,initialRect:r,config:a=!0}=t;const i=c.useRef(!1),{x:l,y:o}=typeof a=="boolean"?{x:a,y:a}:a;Zt(()=>{if(!l&&!o||!s){i.current=!1;return}if(i.current||!r)return;const d=s==null?void 0:s.node.current;if(!d||d.isConnected===!1)return;const m=n(d),p=Lo(m,r);if(l||(p.x=0),o||(p.y=0),i.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const h=Bo(d);h&&h.scrollBy({top:p.y,left:p.x})}},[s,l,o,r,n])}const ca=c.createContext({...es,scaleX:1,scaleY:1});var Ts;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ts||(Ts={}));const Mi=c.memo(function(s){var n,r,a,i;let{id:l,accessibility:o,autoScroll:u=!0,children:d,sensors:m=yp,collisionDetection:p=$x,measuring:h,modifiers:x,...y}=s;const N=c.useReducer(Cp,void 0,kp),[b,g]=N,[T,k]=Ix(),[C,f]=c.useState(Ts.Uninitialized),j=C===Ts.Initialized,{draggable:{active:v,nodes:U,translate:A},droppable:{containers:B}}=b,W=v!=null?U.get(v):null,S=c.useRef({initial:null,translated:null}),w=c.useMemo(()=>{var Xe;return v!=null?{id:v,data:(Xe=W==null?void 0:W.data)!=null?Xe:Np,rect:S}:null},[v,W]),te=c.useRef(null),[G,K]=c.useState(null),[M,ee]=c.useState(null),L=Yn(y,Object.values(y)),ae=or("DndDescribedBy",l),oe=c.useMemo(()=>B.getEnabled(),[B]),q=Ip(h),{droppableRects:H,measureDroppableContainers:I,measuringScheduled:R}=dp(oe,{dragging:j,dependencies:[A.x,A.y],config:q.droppable}),D=op(U,v),Z=c.useMemo(()=>M?Fr(M):null,[M]),me=Rn(),xe=up(D,q.draggable.measure);Ap({activeNode:v!=null?U.get(v):null,config:me.layoutShiftCompensation,initialRect:xe,measure:q.draggable.measure});const $=hl(D,q.draggable.measure,xe),ce=hl(D?D.parentElement:null),ue=c.useRef({activatorEvent:null,active:null,activeNode:D,collisionRect:null,collisions:null,droppableRects:H,draggableNodes:U,draggingNode:null,draggingNodeRect:null,droppableContainers:B,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Re=B.getNodeFor((n=ue.current.over)==null?void 0:n.id),De=vp({measure:q.dragOverlay.measure}),We=(r=De.nodeRef.current)!=null?r:D,xt=j?(a=De.rect)!=null?a:$:null,Ct=!!(De.nodeRef.current&&De.rect),V=pp(Ct?null:$),pe=Jo(We?kt(We):null),ye=hp(j?Re??D:null),Ee=jp(ye),Be=ec(x,{transform:{x:A.x-V.x,y:A.y-V.y,scaleX:1,scaleY:1},activatorEvent:M,active:w,activeNodeRect:$,containerNodeRect:ce,draggingNodeRect:xt,over:ue.current.over,overlayNodeRect:De.rect,scrollableAncestors:ye,scrollableAncestorRects:Ee,windowRect:pe}),Ot=Z?gn(Z,A):null,O=gp(ye),ne=fl(O),ie=fl(O,[$]),se=gn(Be,ne),ve=xt?qx(xt,Be):null,ze=w&&ve?p({active:w,collisionRect:ve,droppableRects:H,droppableContainers:oe,pointerCoordinates:Ot}):null,pt=_x(ze,"id"),[Qe,xs]=c.useState(null),E=Ct?Be:gn(Be,ie),X=Ox(E,(i=Qe==null?void 0:Qe.rect)!=null?i:null,$),_=c.useRef(null),J=c.useCallback((Xe,dt)=>{let{sensor:ht,options:ts}=dt;if(te.current==null)return;const St=U.get(te.current);if(!St)return;const Et=Xe.nativeEvent,ss=new ht({active:te.current,activeNode:St,event:Et,options:ts,context:ue,onAbort(it){if(!U.get(it))return;const{onDragAbort:ns}=L.current,ps={id:it};ns==null||ns(ps),T({type:"onDragAbort",event:ps})},onPending(it,Ss,ns,ps){if(!U.get(it))return;const{onDragPending:Mn}=L.current,Is={id:it,constraint:Ss,initialCoordinates:ns,offset:ps};Mn==null||Mn(Is),T({type:"onDragPending",event:Is})},onStart(it){const Ss=te.current;if(Ss==null)return;const ns=U.get(Ss);if(!ns)return;const{onDragStart:ps}=L.current,En={activatorEvent:Et,active:{id:Ss,data:ns.data,rect:S}};$n.unstable_batchedUpdates(()=>{ps==null||ps(En),f(Ts.Initializing),g({type:Je.DragStart,initialCoordinates:it,active:Ss}),T({type:"onDragStart",event:En}),K(_.current),ee(Et)})},onMove(it){g({type:Je.DragMove,coordinates:it})},onEnd:Xs(Je.DragEnd),onCancel:Xs(Je.DragCancel)});_.current=ss;function Xs(it){return async function(){const{active:ns,collisions:ps,over:En,scrollAdjustedTranslate:Mn}=ue.current;let Is=null;if(ns&&Mn){const{cancelDrop:Dn}=L.current;Is={activatorEvent:Et,active:ns,collisions:ps,delta:Mn,over:En},it===Je.DragEnd&&typeof Dn=="function"&&await Promise.resolve(Dn(Is))&&(it=Je.DragCancel)}te.current=null,$n.unstable_batchedUpdates(()=>{g({type:it}),f(Ts.Uninitialized),xs(null),K(null),ee(null),_.current=null;const Dn=it===Je.DragEnd?"onDragEnd":"onDragCancel";if(Is){const xa=L.current[Dn];xa==null||xa(Is),T({type:Dn,event:Is})}})}}},[U]),le=c.useCallback((Xe,dt)=>(ht,ts)=>{const St=ht.nativeEvent,Et=U.get(ts);if(te.current!==null||!Et||St.dndKit||St.defaultPrevented)return;const ss={active:Et};Xe(ht,dt.options,ss)===!0&&(St.dndKit={capturedBy:dt.sensor},te.current=ts,J(ht,dt))},[U,J]),we=cp(m,le);fp(m),Zt(()=>{$&&C===Ts.Initializing&&f(Ts.Initialized)},[$,C]),c.useEffect(()=>{const{onDragMove:Xe}=L.current,{active:dt,activatorEvent:ht,collisions:ts,over:St}=ue.current;if(!dt||!ht)return;const Et={active:dt,activatorEvent:ht,collisions:ts,delta:{x:se.x,y:se.y},over:St};$n.unstable_batchedUpdates(()=>{Xe==null||Xe(Et),T({type:"onDragMove",event:Et})})},[se.x,se.y]),c.useEffect(()=>{const{active:Xe,activatorEvent:dt,collisions:ht,droppableContainers:ts,scrollAdjustedTranslate:St}=ue.current;if(!Xe||te.current==null||!dt||!St)return;const{onDragOver:Et}=L.current,ss=ts.get(pt),Xs=ss&&ss.rect.current?{id:ss.id,rect:ss.rect.current,data:ss.data,disabled:ss.disabled}:null,it={active:Xe,activatorEvent:dt,collisions:ht,delta:{x:St.x,y:St.y},over:Xs};$n.unstable_batchedUpdates(()=>{xs(Xs),Et==null||Et(it),T({type:"onDragOver",event:it})})},[pt]),Zt(()=>{ue.current={activatorEvent:M,active:w,activeNode:D,collisionRect:ve,collisions:ze,droppableRects:H,draggableNodes:U,draggingNode:We,draggingNodeRect:xt,droppableContainers:B,over:Qe,scrollableAncestors:ye,scrollAdjustedTranslate:se},S.current={initial:xt,translated:ve}},[w,D,ze,ve,U,We,xt,H,B,Qe,ye,se]),ap({...me,delta:A,draggingRect:ve,pointerCoordinates:Ot,scrollableAncestors:ye,scrollableAncestorRects:Ee});const $e=c.useMemo(()=>({active:w,activeNode:D,activeNodeRect:$,activatorEvent:M,collisions:ze,containerNodeRect:ce,dragOverlay:De,draggableNodes:U,droppableContainers:B,droppableRects:H,over:Qe,measureDroppableContainers:I,scrollableAncestors:ye,scrollableAncestorRects:Ee,measuringConfiguration:q,measuringScheduled:R,windowRect:pe}),[w,D,$,M,ze,ce,De,U,B,H,Qe,I,ye,Ee,q,R,pe]),at=c.useMemo(()=>({activatorEvent:M,activators:we,active:w,activeNodeRect:$,ariaDescribedById:{draggable:ae},dispatch:g,draggableNodes:U,over:Qe,measureDroppableContainers:I}),[M,we,w,$,g,ae,U,Qe,I]);return Ne.createElement($o.Provider,{value:k},Ne.createElement(dr.Provider,{value:at},Ne.createElement(Zo.Provider,{value:$e},Ne.createElement(ca.Provider,{value:X},d)),Ne.createElement(Sp,{disabled:(o==null?void 0:o.restoreFocus)===!1})),Ne.createElement(Tx,{...o,hiddenTextDescribedById:ae}));function Rn(){const Xe=(G==null?void 0:G.autoScrollEnabled)===!1,dt=typeof u=="object"?u.enabled===!1:u===!1,ht=j&&!Xe&&!dt;return typeof u=="object"?{...u,enabled:ht}:{enabled:ht}}}),Pp=c.createContext(null),jl="button",Tp="Draggable";function Rp(t){let{id:s,data:n,disabled:r=!1,attributes:a}=t;const i=or(Tp),{activators:l,activatorEvent:o,active:u,activeNodeRect:d,ariaDescribedById:m,draggableNodes:p,over:h}=c.useContext(dr),{role:x=jl,roleDescription:y="draggable",tabIndex:N=0}=a??{},b=(u==null?void 0:u.id)===s,g=c.useContext(b?ca:Pp),[T,k]=Mr(),[C,f]=Mr(),j=bp(l,s),v=Yn(n);Zt(()=>(p.set(s,{id:s,key:i,node:T,activatorNode:C,data:v}),()=>{const A=p.get(s);A&&A.key===i&&p.delete(s)}),[p,s]);const U=c.useMemo(()=>({role:x,tabIndex:N,"aria-disabled":r,"aria-pressed":b&&x===jl?!0:void 0,"aria-roledescription":y,"aria-describedby":m.draggable}),[r,x,N,b,y,m.draggable]);return{active:u,activatorEvent:o,activeNodeRect:d,attributes:U,isDragging:b,listeners:r?void 0:j,node:T,over:h,setNodeRef:k,setActivatorNodeRef:f,transform:g}}function tc(){return c.useContext(Zo)}const Ep="Droppable",Mp={timeout:25};function sc(t){let{data:s,disabled:n=!1,id:r,resizeObserverConfig:a}=t;const i=or(Ep),{active:l,dispatch:o,over:u,measureDroppableContainers:d}=c.useContext(dr),m=c.useRef({disabled:n}),p=c.useRef(!1),h=c.useRef(null),x=c.useRef(null),{disabled:y,updateMeasurementsFor:N,timeout:b}={...Mp,...a},g=Yn(N??r),T=c.useCallback(()=>{if(!p.current){p.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{d(Array.isArray(g.current)?g.current:[g.current]),x.current=null},b)},[b]),k=oa({callback:T,disabled:y||!l}),C=c.useCallback((U,A)=>{k&&(A&&(k.unobserve(A),p.current=!1),U&&k.observe(U))},[k]),[f,j]=Mr(C),v=Yn(s);return c.useEffect(()=>{!k||!f.current||(k.disconnect(),p.current=!1,k.observe(f.current))},[f,k]),c.useEffect(()=>(o({type:Je.RegisterDroppable,element:{id:r,key:i,disabled:n,node:f,rect:h,data:v}}),()=>o({type:Je.UnregisterDroppable,key:i,id:r})),[r]),c.useEffect(()=>{n!==m.current.disabled&&(o({type:Je.SetDroppableDisabled,id:r,key:i,disabled:n}),m.current.disabled=n)},[r,i,n,o]),{active:l,rect:h,isOver:(u==null?void 0:u.id)===r,node:f,over:u,setNodeRef:j}}function Dp(t){let{animation:s,children:n}=t;const[r,a]=c.useState(null),[i,l]=c.useState(null),o=Dr(n);return!n&&!r&&o&&a(o),Zt(()=>{if(!i)return;const u=r==null?void 0:r.key,d=r==null?void 0:r.props.id;if(u==null||d==null){a(null);return}Promise.resolve(s(d,i)).then(()=>{a(null)})},[s,r,i]),Ne.createElement(Ne.Fragment,null,n,r?c.cloneElement(r,{ref:l}):null)}const _p={x:0,y:0,scaleX:1,scaleY:1};function Fp(t){let{children:s}=t;return Ne.createElement(dr.Provider,{value:Xo},Ne.createElement(ca.Provider,{value:_p},s))}const $p={position:"fixed",touchAction:"none"},Op=t=>la(t)?"transform 250ms ease":void 0,Lp=c.forwardRef((t,s)=>{let{as:n,activatorEvent:r,adjustScale:a,children:i,className:l,rect:o,style:u,transform:d,transition:m=Op}=t;if(!o)return null;const p=a?d:{...d,scaleX:1,scaleY:1},h={...$p,width:o.width,height:o.height,top:o.top,left:o.left,transform:ms.Transform.toString(p),transformOrigin:a&&r?Ex(r,o):void 0,transition:typeof m=="function"?m(r):m,...u};return Ne.createElement(n,{className:l,style:h,ref:s},i)}),qp=t=>s=>{let{active:n,dragOverlay:r}=s;const a={},{styles:i,className:l}=t;if(i!=null&&i.active)for(const[o,u]of Object.entries(i.active))u!==void 0&&(a[o]=n.node.style.getPropertyValue(o),n.node.style.setProperty(o,u));if(i!=null&&i.dragOverlay)for(const[o,u]of Object.entries(i.dragOverlay))u!==void 0&&r.node.style.setProperty(o,u);return l!=null&&l.active&&n.node.classList.add(l.active),l!=null&&l.dragOverlay&&r.node.classList.add(l.dragOverlay),function(){for(const[u,d]of Object.entries(a))n.node.style.setProperty(u,d);l!=null&&l.active&&n.node.classList.remove(l.active)}},Bp=t=>{let{transform:{initial:s,final:n}}=t;return[{transform:ms.Transform.toString(s)},{transform:ms.Transform.toString(n)}]},zp={duration:250,easing:"ease",keyframes:Bp,sideEffects:qp({styles:{active:{opacity:"0"}}})};function Kp(t){let{config:s,draggableNodes:n,droppableContainers:r,measuringConfiguration:a}=t;return ia((i,l)=>{if(s===null)return;const o=n.get(i);if(!o)return;const u=o.node.current;if(!u)return;const d=Yo(l);if(!d)return;const{transform:m}=kt(l).getComputedStyle(l),p=qo(m);if(!p)return;const h=typeof s=="function"?s:Up(s);return Qo(u,a.draggable.measure),h({active:{id:i,data:o.data,node:u,rect:a.draggable.measure(u)},draggableNodes:n,dragOverlay:{node:l,rect:a.dragOverlay.measure(d)},droppableContainers:r,measuringConfiguration:a,transform:p})})}function Up(t){const{duration:s,easing:n,sideEffects:r,keyframes:a}={...zp,...t};return i=>{let{active:l,dragOverlay:o,transform:u,...d}=i;if(!s)return;const m={x:o.rect.left-l.rect.left,y:o.rect.top-l.rect.top},p={scaleX:u.scaleX!==1?l.rect.width*u.scaleX/o.rect.width:1,scaleY:u.scaleY!==1?l.rect.height*u.scaleY/o.rect.height:1},h={x:u.x-m.x,y:u.y-m.y,...p},x=a({...d,active:l,dragOverlay:o,transform:{initial:u,final:h}}),[y]=x,N=x[x.length-1];if(JSON.stringify(y)===JSON.stringify(N))return;const b=r==null?void 0:r({active:l,dragOverlay:o,...d}),g=o.node.animate(x,{duration:s,easing:n,fill:"forwards"});return new Promise(T=>{g.onfinish=()=>{b==null||b(),T()}})}}let vl=0;function Vp(t){return c.useMemo(()=>{if(t!=null)return vl++,vl},[t])}const Wp=Ne.memo(t=>{let{adjustScale:s=!1,children:n,dropAnimation:r,style:a,transition:i,modifiers:l,wrapperElement:o="div",className:u,zIndex:d=999}=t;const{activatorEvent:m,active:p,activeNodeRect:h,containerNodeRect:x,draggableNodes:y,droppableContainers:N,dragOverlay:b,over:g,measuringConfiguration:T,scrollableAncestors:k,scrollableAncestorRects:C,windowRect:f}=tc(),j=c.useContext(ca),v=Vp(p==null?void 0:p.id),U=ec(l,{activatorEvent:m,active:p,activeNodeRect:h,containerNodeRect:x,draggingNodeRect:b.rect,over:g,overlayNodeRect:b.rect,scrollableAncestors:k,scrollableAncestorRects:C,transform:j,windowRect:f}),A=Ei(h),B=Kp({config:r,draggableNodes:y,droppableContainers:N,measuringConfiguration:T}),W=A?b.setRef:void 0;return Ne.createElement(Fp,null,Ne.createElement(Dp,{animation:B},p&&v?Ne.createElement(Lp,{key:v,id:p.id,ref:W,as:o,activatorEvent:m,adjustScale:s,className:u,transition:i,rect:A,style:{zIndex:d,...a},transform:U},n):null))});function da(t,s,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(s,1)[0]),r}function Qp(t,s){return t.reduce((n,r,a)=>{const i=s.get(r);return i&&(n[a]=i),n},Array(t.length))}function hr(t){return t!==null&&t>=0}function Gp(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==s[n])return!1;return!0}function Hp(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const nc=t=>{let{rects:s,activeIndex:n,overIndex:r,index:a}=t;const i=da(s,r,n),l=s[a],o=i[a];return!o||!l?null:{x:o.left-l.left,y:o.top-l.top,scaleX:o.width/l.width,scaleY:o.height/l.height}},gr={scaleX:1,scaleY:1},Di=t=>{var s;let{activeIndex:n,activeNodeRect:r,index:a,rects:i,overIndex:l}=t;const o=(s=i[n])!=null?s:r;if(!o)return null;if(a===n){const d=i[l];return d?{x:0,y:n<l?d.top+d.height-(o.top+o.height):d.top-o.top,...gr}:null}const u=Jp(i,a,n);return a>n&&a<=l?{x:0,y:-o.height-u,...gr}:a<n&&a>=l?{x:0,y:o.height+u,...gr}:{x:0,y:0,...gr}};function Jp(t,s,n){const r=t[s],a=t[s-1],i=t[s+1];return r?n<s?a?r.top-(a.top+a.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):a?r.top-(a.top+a.height):0:0}const rc="Sortable",ac=Ne.createContext({activeIndex:-1,containerId:rc,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:nc,disabled:{draggable:!1,droppable:!1}});function _i(t){let{children:s,id:n,items:r,strategy:a=nc,disabled:i=!1}=t;const{active:l,dragOverlay:o,droppableRects:u,over:d,measureDroppableContainers:m}=tc(),p=or(rc,n),h=o.rect!==null,x=c.useMemo(()=>r.map(j=>typeof j=="object"&&"id"in j?j.id:j),[r]),y=l!=null,N=l?x.indexOf(l.id):-1,b=d?x.indexOf(d.id):-1,g=c.useRef(x),T=!Gp(x,g.current),k=b!==-1&&N===-1||T,C=Hp(i);Zt(()=>{T&&y&&m(x)},[T,x,y,m]),c.useEffect(()=>{g.current=x},[x]);const f=c.useMemo(()=>({activeIndex:N,containerId:p,disabled:C,disableTransforms:k,items:x,overIndex:b,useDragOverlay:h,sortedRects:Qp(x,u),strategy:a}),[N,p,C.draggable,C.droppable,k,x,b,u,h,a]);return Ne.createElement(ac.Provider,{value:f},s)}const Yp=t=>{let{id:s,items:n,activeIndex:r,overIndex:a}=t;return da(n,r,a).indexOf(s)},Xp=t=>{let{containerId:s,isSorting:n,wasDragging:r,index:a,items:i,newIndex:l,previousItems:o,previousContainerId:u,transition:d}=t;return!d||!r||o!==i&&a===l?!1:n?!0:l!==a&&s===u},Zp={duration:200,easing:"ease"},ic="transform",eh=ms.Transition.toString({property:ic,duration:0,easing:"linear"}),th={roleDescription:"sortable"};function sh(t){let{disabled:s,index:n,node:r,rect:a}=t;const[i,l]=c.useState(null),o=c.useRef(n);return Zt(()=>{if(!s&&n!==o.current&&r.current){const u=a.current;if(u){const d=Tn(r.current,{ignoreTransform:!0}),m={x:u.left-d.left,y:u.top-d.top,scaleX:u.width/d.width,scaleY:u.height/d.height};(m.x||m.y)&&l(m)}}n!==o.current&&(o.current=n)},[s,n,r,a]),c.useEffect(()=>{i&&l(null)},[i]),i}function Fi(t){let{animateLayoutChanges:s=Xp,attributes:n,disabled:r,data:a,getNewIndex:i=Yp,id:l,strategy:o,resizeObserverConfig:u,transition:d=Zp}=t;const{items:m,containerId:p,activeIndex:h,disabled:x,disableTransforms:y,sortedRects:N,overIndex:b,useDragOverlay:g,strategy:T}=c.useContext(ac),k=nh(r,x),C=m.indexOf(l),f=c.useMemo(()=>({sortable:{containerId:p,index:C,items:m},...a}),[p,a,C,m]),j=c.useMemo(()=>m.slice(m.indexOf(l)),[m,l]),{rect:v,node:U,isOver:A,setNodeRef:B}=sc({id:l,data:f,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:j,...u}}),{active:W,activatorEvent:S,activeNodeRect:w,attributes:te,setNodeRef:G,listeners:K,isDragging:M,over:ee,setActivatorNodeRef:L,transform:ae}=Rp({id:l,data:f,attributes:{...th,...n},disabled:k.draggable}),oe=fx(B,G),q=!!W,H=q&&!y&&hr(h)&&hr(b),I=!g&&M,R=I&&H?ae:null,Z=H?R??(o??T)({rects:N,activeNodeRect:w,activeIndex:h,overIndex:b,index:C}):null,me=hr(h)&&hr(b)?i({id:l,items:m,activeIndex:h,overIndex:b}):C,xe=W==null?void 0:W.id,$=c.useRef({activeId:xe,items:m,newIndex:me,containerId:p}),ce=m!==$.current.items,ue=s({active:W,containerId:p,isDragging:M,isSorting:q,id:l,index:C,items:m,newIndex:$.current.newIndex,previousItems:$.current.items,previousContainerId:$.current.containerId,transition:d,wasDragging:$.current.activeId!=null}),Re=sh({disabled:!ue,index:C,node:U,rect:v});return c.useEffect(()=>{q&&$.current.newIndex!==me&&($.current.newIndex=me),p!==$.current.containerId&&($.current.containerId=p),m!==$.current.items&&($.current.items=m)},[q,me,p,m]),c.useEffect(()=>{if(xe===$.current.activeId)return;if(xe!=null&&$.current.activeId==null){$.current.activeId=xe;return}const We=setTimeout(()=>{$.current.activeId=xe},50);return()=>clearTimeout(We)},[xe]),{active:W,activeIndex:h,attributes:te,data:f,rect:v,index:C,newIndex:me,items:m,isOver:A,isSorting:q,isDragging:M,listeners:K,node:U,overIndex:b,over:ee,setNodeRef:oe,setActivatorNodeRef:L,setDroppableNodeRef:B,setDraggableNodeRef:G,transform:Re??Z,transition:De()};function De(){if(Re||ce&&$.current.newIndex===C)return eh;if(!(I&&!la(S)||!d)&&(q||ue))return ms.Transition.toString({...d,property:ic})}}function nh(t,s){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t==null?void 0:t.draggable)!=null?n:s.draggable,droppable:(r=t==null?void 0:t.droppable)!=null?r:s.droppable}}ke.Down,ke.Right,ke.Up,ke.Left;const rh={get:t=>Me.get(`/companies/${t}/sidebar-badges`)},$i="paperclip.companyOrder";function ah(){try{const t=localStorage.getItem($i);if(t)return JSON.parse(t)}catch{}return[]}function ih(t){localStorage.setItem($i,JSON.stringify(t))}function yl(t){const s=ah();if(s.length===0)return t;const n=new Map(t.map(a=>[a.id,a])),r=[];for(const a of s){const i=n.get(a);i&&(r.push(i),n.delete(a))}for(const a of n.values())r.push(a);return r}function lh({company:t,isSelected:s,hasLiveAgents:n,hasUnreadInbox:r,onSelect:a}){const{attributes:i,listeners:l,setNodeRef:o,transform:u,transition:d,isDragging:m}=Fi({id:t.id}),p={transform:ms.Transform.toString(u),transition:d,zIndex:m?10:void 0,opacity:m?.8:1};return e.jsx("div",{ref:o,style:p,...i,...l,className:"overflow-visible",children:e.jsxs(cs,{delayDuration:300,children:[e.jsx(ds,{asChild:!0,children:e.jsxs("a",{href:`/${t.issuePrefix}/dashboard`,onClick:h=>{h.preventDefault(),a()},className:"relative flex items-center justify-center group overflow-visible",children:[e.jsx("div",{className:z("absolute left-[-14px] w-1 rounded-r-full bg-foreground transition-[height] duration-150",s?"h-5":"h-0 group-hover:h-2")}),e.jsxs("div",{className:z("relative overflow-visible transition-transform duration-150",m&&"scale-105"),children:[e.jsx(ro,{companyName:t.name,logoUrl:t.logoUrl,brandColor:t.brandColor,className:z(s?"rounded-[14px]":"rounded-[22px] group-hover:rounded-[14px]",m&&"shadow-lg")}),n&&e.jsx("span",{className:"pointer-events-none absolute -right-0.5 -top-0.5 z-10",children:e.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-pulse rounded-full bg-blue-400 opacity-80"}),e.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-blue-500 ring-2 ring-background"})]})}),r&&e.jsx("span",{className:"pointer-events-none absolute -bottom-0.5 -right-0.5 z-10 h-2.5 w-2.5 rounded-full bg-red-500 ring-2 ring-background"})]})]})}),e.jsx(us,{side:"right",sideOffset:8,children:e.jsx("p",{children:t.name})})]})})}function Nl(){const{companies:t,selectedCompanyId:s,setSelectedCompanyId:n}=fe(),{openOnboarding:r}=Ye(),a=Rt(),l=wt().pathname.startsWith("/instance/"),o=l?null:s,u=c.useMemo(()=>t.filter(k=>k.status!=="archived"),[t]),d=c.useMemo(()=>u.map(k=>k.id),[u]),m=rl({queries:d.map(k=>({queryKey:P.liveRuns(k),queryFn:()=>Tt.liveRunsForCompany(k),refetchInterval:1e4}))}),p=rl({queries:d.map(k=>({queryKey:P.sidebarBadges(k),queryFn:()=>rh.get(k),refetchInterval:15e3}))}),h=c.useMemo(()=>{const k=new Map;return d.forEach((C,f)=>{var j,v;k.set(C,(((v=(j=m[f])==null?void 0:j.data)==null?void 0:v.length)??0)>0)}),k},[d,m]),x=c.useMemo(()=>{const k=new Map;return d.forEach((C,f)=>{var j,v;k.set(C,(((v=(j=p[f])==null?void 0:j.data)==null?void 0:v.inbox)??0)>0)}),k},[d,p]),[y,N]=c.useState(()=>yl(u).map(k=>k.id));c.useEffect(()=>{if(u.length===0){N([]);return}N(yl(u).map(k=>k.id))},[u]),c.useEffect(()=>{const k=C=>{if(C.key===$i)try{const f=C.newValue?JSON.parse(C.newValue):[];N(f)}catch{}};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]);const b=c.useMemo(()=>{const k=new Map(u.map(f=>[f.id,f])),C=[];for(const f of y){const j=k.get(f);j&&(C.push(j),k.delete(f))}for(const f of k.values())C.push(f);return C},[u,y]),g=Ai(Ii(cr,{activationConstraint:{distance:8}})),T=c.useCallback(k=>{const{active:C,over:f}=k;if(!f||C.id===f.id)return;const j=b.map(B=>B.id),v=j.indexOf(C.id),U=j.indexOf(f.id);if(v===-1||U===-1)return;const A=da(j,v,U);N(A),ih(A)},[b]);return e.jsxs("div",{className:"flex flex-col items-center w-[72px] shrink-0 h-full bg-background border-r border-border",children:[e.jsx("div",{className:"flex items-center justify-center h-12 w-full shrink-0",children:e.jsx(gd,{className:"h-5 w-5 text-foreground"})}),e.jsx("div",{className:"flex-1 flex flex-col items-center gap-2 py-3 w-full overflow-y-auto overflow-x-hidden scrollbar-none",children:e.jsx(Mi,{sensors:g,collisionDetection:Oo,onDragEnd:T,children:e.jsx(_i,{items:b.map(k=>k.id),strategy:Di,children:b.map(k=>e.jsx(lh,{company:k,isSelected:k.id===o,hasLiveAgents:h.get(k.id)??!1,hasUnreadInbox:x.get(k.id)??!1,onSelect:()=>{n(k.id),l&&a(`/${k.issuePrefix}/dashboard`)}},k.id))})})}),e.jsx("div",{className:"w-8 h-px bg-border mx-auto shrink-0"}),e.jsx("div",{className:"flex items-center justify-center py-2 shrink-0",children:e.jsxs(cs,{delayDuration:300,children:[e.jsx(ds,{asChild:!0,children:e.jsx("button",{onClick:()=>r(),className:"flex items-center justify-center w-11 h-11 rounded-[22px] hover:rounded-[14px] border-2 border-dashed border-border text-muted-foreground hover:border-foreground/30 hover:text-foreground transition-[border-color,color,border-radius] duration-150","aria-label":"Add company",children:e.jsx(Ae,{className:"h-5 w-5"})})}),e.jsx(us,{side:"right",sideOffset:8,children:e.jsx("p",{children:"Add company"})})]})})]})}function wl({label:t,children:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium uppercase tracking-widest font-mono text-muted-foreground/60",children:t}),e.jsx("div",{className:"flex flex-col gap-0.5 mt-0.5",children:s})]})}function qt({to:t,label:s,icon:n,end:r,className:a,badge:i,badgeTone:l="default",alert:o=!1,liveCount:u}){const{isMobile:d,setSidebarOpen:m}=Cn();return e.jsxs(nr,{to:t,end:r,onClick:()=>{d&&m(!1)},className:({isActive:p})=>z("flex items-center gap-2.5 px-3 py-2 text-[13px] font-medium transition-colors",p?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground",a),children:[e.jsxs("span",{className:"relative shrink-0",children:[e.jsx(n,{className:"h-4 w-4"}),o&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 shadow-[0_0_0_2px_hsl(var(--background))]"})]}),e.jsx("span",{className:"flex-1 truncate",children:s}),u!=null&&u>0&&e.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),e.jsxs("span",{className:"text-[11px] font-medium text-blue-600 dark:text-blue-400",children:[u," live"]})]}),i!=null&&i>0&&e.jsx("span",{className:z("ml-auto rounded-full px-1.5 py-0.5 text-xs leading-none",l==="danger"?"bg-red-600/90 text-red-50":"bg-primary text-primary-foreground"),children:i})]})}function lc({title:t="Paused by budget"}){return e.jsx("span",{title:t,"aria-label":t,className:"ml-auto inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-red-500/90 text-white shadow-[0_0_0_1px_rgba(255,255,255,0.08)]",children:e.jsx(ls,{className:"h-3 w-3"})})}function oh({activeProjectRef:t,companyId:s,companyPrefix:n,isMobile:r,project:a,projectSidebarSlots:i,setSidebarOpen:l}){const{attributes:o,listeners:u,setNodeRef:d,transform:m,transition:p,isDragging:h}=Fi({id:a.id}),x=ao(a);return e.jsx("div",{ref:d,style:{transform:ms.Transform.toString(m),transition:p,zIndex:h?10:void 0},className:z(h&&"opacity-80"),...o,...u,children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(nr,{to:`/projects/${x}/issues`,onClick:()=>{r&&l(!1)},className:z("flex items-center gap-2.5 px-3 py-1.5 text-[13px] font-medium transition-colors",t===x||t===a.id?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[e.jsx("span",{className:"shrink-0 h-3.5 w-3.5 rounded-sm",style:{backgroundColor:a.color??"#6366f1"}}),e.jsx("span",{className:"flex-1 truncate",children:a.name}),a.pauseReason==="budget"?e.jsx(lc,{title:"Project paused by budget"}):null]}),i.length>0&&e.jsx("div",{className:"ml-5 flex flex-col gap-0.5",children:i.map(y=>e.jsx(Yr,{slot:y,context:{companyId:s,companyPrefix:n,projectId:a.id,projectRef:x,entityId:a.id,entityType:"project"},missingBehavior:"placeholder"},`${a.id}:${y.pluginKey}:${y.id}`))})]})})}function ch(){var k,C;const[t,s]=c.useState(!0),{selectedCompany:n,selectedCompanyId:r}=fe(),{openNewProject:a}=Ye(),{isMobile:i,setSidebarOpen:l}=Cn(),o=wt(),{data:u}=Q({queryKey:P.projects.list(r),queryFn:()=>mt.list(r),enabled:!!r}),{data:d}=Q({queryKey:P.auth.session,queryFn:()=>ii.getSession()}),{slots:m}=ai({slotTypes:["projectSidebarItem"],entityType:"project",enabled:!!r}),p=((k=d==null?void 0:d.user)==null?void 0:k.id)??((C=d==null?void 0:d.session)==null?void 0:C.userId)??null,h=c.useMemo(()=>(u??[]).filter(f=>!f.archivedAt),[u]),{orderedProjects:x,persistOrder:y}=fd({projects:h,companyId:r,userId:p}),N=o.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/),b=(N==null?void 0:N[1])??null,g=Ai(Ii(cr,{activationConstraint:{distance:8}})),T=c.useCallback(f=>{const{active:j,over:v}=f;if(!v||j.id===v.id)return;const U=x.map(W=>W.id),A=U.indexOf(j.id),B=U.indexOf(v.id);A===-1||B===-1||y(da(U,A,B))},[x,y]);return e.jsxs(Gr,{open:t,onOpenChange:s,children:[e.jsx("div",{className:"group",children:e.jsxs("div",{className:"flex items-center px-3 py-1.5",children:[e.jsxs(Hr,{className:"flex items-center gap-1 flex-1 min-w-0",children:[e.jsx(Ns,{className:z("h-3 w-3 text-muted-foreground/60 transition-transform opacity-0 group-hover:opacity-100",t&&"rotate-90")}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-widest font-mono text-muted-foreground/60",children:"Projects"})]}),e.jsx("button",{onClick:f=>{f.stopPropagation(),a()},className:"flex items-center justify-center h-4 w-4 rounded text-muted-foreground/60 hover:text-foreground hover:bg-accent/50 transition-colors","aria-label":"New project",children:e.jsx(Ae,{className:"h-3 w-3"})})]})}),e.jsx(Jr,{children:e.jsx(Mi,{sensors:g,collisionDetection:Oo,onDragEnd:T,children:e.jsx(_i,{items:x.map(f=>f.id),strategy:Di,children:e.jsx("div",{className:"flex flex-col gap-0.5 mt-0.5",children:x.map(f=>e.jsx(oh,{activeProjectRef:b,companyId:r,companyPrefix:(n==null?void 0:n.issuePrefix)??null,isMobile:i,project:f,projectSidebarSlots:m,setSidebarOpen:l},f.id))})})})})]})}function dh(t){const s=new Map(t.map(i=>[i.id,i])),n=new Map;for(const i of t){const l=i.reportsTo&&s.has(i.reportsTo)?i.reportsTo:null,o=n.get(l)??[];o.push(i),n.set(l,o)}const r=[],a=n.get(null)??[];for(;a.length>0;){const i=a.shift();r.push(i);const l=n.get(i.id);l&&a.push(...l)}return r}function uh(){const[t,s]=c.useState(!0),{selectedCompanyId:n}=fe(),{openNewAgent:r}=Ye(),{isMobile:a,setSidebarOpen:i}=Cn(),l=wt(),{data:o}=Q({queryKey:P.agents.list(n),queryFn:()=>Te.list(n),enabled:!!n}),{data:u}=Q({queryKey:P.liveRuns(n),queryFn:()=>Tt.liveRunsForCompany(n),enabled:!!n,refetchInterval:1e4}),d=c.useMemo(()=>{const x=new Map;for(const y of u??[])y.status!=="running"&&y.status!=="queued"||x.set(y.agentId,(x.get(y.agentId)??0)+1);return x},[u]),m=c.useMemo(()=>{const x=(o??[]).filter(y=>y.status!=="terminated");return dh(x)},[o]),p=l.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)/),h=(p==null?void 0:p[1])??null;return e.jsxs(Gr,{open:t,onOpenChange:s,children:[e.jsx("div",{className:"group",children:e.jsxs("div",{className:"flex items-center px-3 py-1.5",children:[e.jsxs(Hr,{className:"flex items-center gap-1 flex-1 min-w-0",children:[e.jsx(Ns,{className:z("h-3 w-3 text-muted-foreground/60 transition-transform opacity-0 group-hover:opacity-100",t&&"rotate-90")}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-widest font-mono text-muted-foreground/60",children:"Agents"})]}),e.jsx("button",{onClick:x=>{x.stopPropagation(),r()},className:"flex items-center justify-center h-4 w-4 rounded text-muted-foreground/60 hover:text-foreground hover:bg-accent/50 transition-colors","aria-label":"New agent",children:e.jsx(Ae,{className:"h-3 w-3"})})]})}),e.jsx(Jr,{children:e.jsx("div",{className:"flex flex-col gap-0.5 mt-0.5",children:m.map(x=>{const y=d.get(x.id)??0;return e.jsxs(nr,{to:Sn(x),onClick:()=>{a&&i(!1)},className:z("flex items-center gap-2.5 px-3 py-1.5 text-[13px] font-medium transition-colors",h===Qn(x)?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[e.jsx(_a,{icon:x.icon,className:"shrink-0 h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate",children:x.name}),(x.pauseReason==="budget"||y>0)&&e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[x.pauseReason==="budget"?e.jsx(lc,{title:"Agent paused by budget"}):null,y>0?e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}):null,y>0?e.jsxs("span",{className:"text-[11px] font-medium text-blue-600 dark:text-blue-400",children:[y," live"]}):null]})]},x.id)})})})]})}const gt={list:(t,s)=>Me.get(`/companies/${t}/approvals${s?`?status=${encodeURIComponent(s)}`:""}`),create:(t,s)=>Me.post(`/companies/${t}/approvals`,s),get:t=>Me.get(`/approvals/${t}`),approve:(t,s)=>Me.post(`/approvals/${t}/approve`,{decisionNote:s}),reject:(t,s)=>Me.post(`/approvals/${t}/reject`,{decisionNote:s}),requestRevision:(t,s)=>Me.post(`/approvals/${t}/request-revision`,{decisionNote:s}),resubmit:(t,s)=>Me.post(`/approvals/${t}/resubmit`,{payload:s}),listComments:t=>Me.get(`/approvals/${t}/comments`),addComment:(t,s)=>Me.post(`/approvals/${t}/comments`,{body:s}),listIssues:t=>Me.get(`/approvals/${t}/issues`)},Oi={summary:t=>Me.get(`/companies/${t}/dashboard`)},mh=100,xh=new Set(["failed","timed_out"]),Lr=new Set(["pending","revision_requested"]),oc="paperclip:inbox:dismissed",cc="paperclip:inbox:last-tab";function kl(){try{const t=localStorage.getItem(oc);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function ph(t){try{localStorage.setItem(oc,JSON.stringify([...t]))}catch{}}function hh(){try{const t=localStorage.getItem(cc);return t==="all"||t==="unread"||t==="recent"?t:"recent"}catch{return"recent"}}function gh(t){try{localStorage.setItem(cc,t)}catch{}}function dc(t){const s=[...t].sort((r,a)=>new Date(a.createdAt).getTime()-new Date(r.createdAt).getTime()),n=new Map;for(const r of s)n.has(r.agentId)||n.set(r.agentId,r);return Array.from(n.values()).filter(r=>xh.has(r.status))}function os(t){if(!t)return 0;const s=new Date(t).getTime();return Number.isFinite(s)?s:0}function Xa(t){const s=os(t.lastExternalCommentAt);if(s>0)return s;const n=os(t.updatedAt),r=os(t.myLastTouchAt);return r>0&&n<=r?0:n}function uc(t,s){const n=Xa(s)-Xa(t);return n!==0?n:os(s.updatedAt)-os(t.updatedAt)}function mc(t){return[...t].sort(uc).slice(0,mh)}function fh(t){return t.filter(s=>s.isUnreadForMe)}function bh(t,s,n){const r=[...t].sort((a,i)=>os(i.updatedAt)-os(a.updatedAt));return s==="recent"?r:s==="unread"?r.filter(a=>Lr.has(a.status)):n==="all"?r:r.filter(a=>{const i=Lr.has(a.status);return n==="actionable"?i:!i})}function wa(t){const s=os(t.updatedAt);return s>0?s:os(t.createdAt)}function jh({issues:t,approvals:s,failedRuns:n=[]}){return[...t.map(r=>({kind:"issue",timestamp:Xa(r),issue:r})),...s.map(r=>({kind:"approval",timestamp:wa(r),approval:r})),...n.map(r=>({kind:"failed_run",timestamp:os(r.createdAt),run:r}))].sort((r,a)=>{const i=a.timestamp-r.timestamp;return i!==0?i:r.kind==="issue"&&a.kind==="issue"?uc(r.issue,a.issue):r.kind==="approval"&&a.kind==="approval"?wa(a.approval)-wa(r.approval):r.kind==="approval"?-1:1})}function vh({tab:t,hasItems:s,showOnRecent:n,showOnUnread:r,showOnAll:a}){return s?t==="recent"?n:t==="unread"?r:a:!1}function yh({approvals:t,joinRequests:s,dashboard:n,heartbeatRuns:r,unreadIssues:a,dismissed:i}){const l=t.filter(N=>Lr.has(N.status)).length,o=dc(r).filter(N=>!i.has(`run:${N.id}`)).length,u=a.length,d=(n==null?void 0:n.agents.error)??0,m=(n==null?void 0:n.costs.monthBudgetCents)??0,p=(n==null?void 0:n.costs.monthUtilizationPercent)??0,h=d>0&&o===0&&!i.has("alert:agent-errors"),x=m>0&&p>=80&&!i.has("alert:budget"),y=Number(h)+Number(x);return{inbox:l+s.length+o+u+y,approvals:l,failedRuns:o,joinRequests:s.length,unreadTouchedIssues:u,alerts:y}}const Nh="backlog,todo,in_progress,in_review,blocked,done";function xc(){const[t,s]=c.useState(kl);return c.useEffect(()=>{const r=a=>{a.key==="paperclip:inbox:dismissed"&&s(kl())};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{dismissed:t,dismiss:r=>{s(a=>{const i=new Set(a);return i.add(r),ph(i),i})}}}function pc(t){const{dismissed:s}=xc(),{data:n=[]}=Q({queryKey:P.approvals.list(t),queryFn:()=>gt.list(t),enabled:!!t}),{data:r=[]}=Q({queryKey:P.access.joinRequests(t),queryFn:async()=>{try{return await dn.listJoinRequests(t,"pending_approval")}catch(u){if(u instanceof io&&(u.status===401||u.status===403))return[];throw u}},enabled:!!t,retry:!1}),{data:a}=Q({queryKey:P.dashboard(t),queryFn:()=>Oi.summary(t),enabled:!!t}),{data:i=[]}=Q({queryKey:P.issues.listTouchedByMe(t),queryFn:()=>Ve.list(t,{touchedByUserId:"me",status:Nh}),enabled:!!t}),l=c.useMemo(()=>fh(mc(i)),[i]),{data:o=[]}=Q({queryKey:P.heartbeats(t),queryFn:()=>Tt.list(t),enabled:!!t});return c.useMemo(()=>yh({approvals:n,joinRequests:r,dashboard:a,heartbeatRuns:o,unreadIssues:l,dismissed:s}),[n,r,a,o,l,s])}function Cl(){const{openNewIssue:t}=Ye(),{selectedCompanyId:s,selectedCompany:n}=fe(),r=pc(s),{data:a}=Q({queryKey:P.liveRuns(s),queryFn:()=>Tt.liveRunsForCompany(s),enabled:!!s,refetchInterval:1e4}),i=(a??[]).filter(u=>u.status==="running"||u.status==="queued").length;function l(){document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0}))}const o={companyId:s,companyPrefix:(n==null?void 0:n.issuePrefix)??null};return e.jsxs("aside",{className:"w-60 h-full min-h-0 border-r border-border bg-background flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 px-3 h-12 shrink-0",children:[(n==null?void 0:n.brandColor)&&e.jsx("div",{className:"w-4 h-4 rounded-sm shrink-0 ml-1",style:{backgroundColor:n.brandColor}}),e.jsx("span",{className:"flex-1 text-sm font-bold text-foreground truncate pl-1",children:(n==null?void 0:n.name)??"Select company"}),e.jsx(F,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground shrink-0",onClick:l,children:e.jsx(fs,{className:"h-4 w-4"})})]}),e.jsxs("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide flex flex-col gap-4 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("button",{onClick:()=>t(),className:"flex items-center gap-2.5 px-3 py-2 text-[13px] font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:[e.jsx(ki,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"New Issue"})]}),e.jsx(qt,{to:"/dashboard",label:"Dashboard",icon:Vs,liveCount:i}),e.jsx(qt,{to:"/inbox",label:"Inbox",icon:Qs,badge:r.inbox,badgeTone:r.failedRuns>0?"danger":"default",alert:r.failedRuns>0}),e.jsx(Ir,{slotTypes:["sidebar"],context:o,className:"flex flex-col gap-0.5",itemClassName:"text-[13px] font-medium",missingBehavior:"placeholder"})]}),e.jsxs(wl,{label:"Work",children:[e.jsx(qt,{to:"/tickets",label:"Tickets",icon:lo}),e.jsx(qt,{to:"/issues",label:"Issues",icon:Wt}),e.jsx(qt,{to:"/goals",label:"Goals",icon:ws})]}),e.jsx(ch,{}),e.jsx(uh,{}),e.jsxs(wl,{label:"Company",children:[e.jsx(qt,{to:"/org",label:"Org",icon:bd}),e.jsx(qt,{to:"/costs",label:"Costs",icon:ls}),e.jsx(qt,{to:"/activity",label:"Activity",icon:Jn}),e.jsx(qt,{to:"/company/settings",label:"Settings",icon:ks})]}),e.jsx(Ir,{slotTypes:["sidebarPanel"],context:o,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}function Sl(){const{data:t}=Q({queryKey:P.plugins.all,queryFn:()=>bt.list()});return e.jsxs("aside",{className:"w-60 h-full min-h-0 border-r border-border bg-background flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 shrink-0",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground shrink-0 ml-1"}),e.jsx("span",{className:"flex-1 text-sm font-bold text-foreground truncate",children:"Instance Settings"})]}),e.jsx("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide flex flex-col gap-4 px-3 py-2",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx(qt,{to:"/instance/settings/heartbeats",label:"Heartbeats",icon:Mo,end:!0}),e.jsx(qt,{to:"/instance/settings/experimental",label:"Experimental",icon:ra}),e.jsx(qt,{to:"/instance/settings/plugins",label:"Plugins",icon:qn}),(t??[]).length>0?e.jsx("div",{className:"ml-4 mt-1 flex flex-col gap-0.5 border-l border-border/70 pl-3",children:(t??[]).map(s=>e.jsx(nr,{to:`/instance/settings/plugins/${s.id}`,className:({isActive:n})=>["rounded-md px-2 py-1.5 text-xs transition-colors",n?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"].join(" "),children:s.manifestJson.displayName??s.packageName},s.id))}):null]})})]})}var Il=1,wh=.9,kh=.8,Ch=.17,ka=.1,Ca=.999,Sh=.9999,Ih=.99,Ah=/[\\\/_+.#"@\[\(\{&]/,Ph=/[\\\/_+.#"@\[\(\{&]/g,Th=/[\s-]/,hc=/[\s-]/g;function Za(t,s,n,r,a,i,l){if(i===s.length)return a===t.length?Il:Ih;var o=`${a},${i}`;if(l[o]!==void 0)return l[o];for(var u=r.charAt(i),d=n.indexOf(u,a),m=0,p,h,x,y;d>=0;)p=Za(t,s,n,r,d+1,i+1,l),p>m&&(d===a?p*=Il:Ah.test(t.charAt(d-1))?(p*=kh,x=t.slice(a,d-1).match(Ph),x&&a>0&&(p*=Math.pow(Ca,x.length))):Th.test(t.charAt(d-1))?(p*=wh,y=t.slice(a,d-1).match(hc),y&&a>0&&(p*=Math.pow(Ca,y.length))):(p*=Ch,a>0&&(p*=Math.pow(Ca,d-a))),t.charAt(d)!==s.charAt(i)&&(p*=Sh)),(p<ka&&n.charAt(d-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(d-1)!==r.charAt(i))&&(h=Za(t,s,n,r,d+1,i+2,l),h*ka>p&&(p=h*ka)),p>m&&(m=p),d=n.indexOf(u,d+1);return l[o]=m,m}function Al(t){return t.toLowerCase().replace(hc," ")}function Rh(t,s,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Za(t,s,Al(t),Al(s),0,0,{})}var _n='[cmdk-group=""]',Sa='[cmdk-group-items=""]',Eh='[cmdk-group-heading=""]',gc='[cmdk-item=""]',Pl=`${gc}:not([aria-disabled="true"])`,ei="cmdk-item-select",an="data-value",Mh=(t,s,n)=>Rh(t,s,n),fc=c.createContext(void 0),ur=()=>c.useContext(fc),bc=c.createContext(void 0),Li=()=>c.useContext(bc),jc=c.createContext(void 0),vc=c.forwardRef((t,s)=>{let n=ln(()=>{var q,H;return{search:"",value:(H=(q=t.value)!=null?q:t.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=ln(()=>new Set),a=ln(()=>new Map),i=ln(()=>new Map),l=ln(()=>new Set),o=yc(t),{label:u,children:d,value:m,onValueChange:p,filter:h,shouldFilter:x,loop:y,disablePointerSelection:N=!1,vimBindings:b=!0,...g}=t,T=un(),k=un(),C=un(),f=c.useRef(null),j=Uh();Hs(()=>{if(m!==void 0){let q=m.trim();n.current.value=q,v.emit()}},[m]),Hs(()=>{j(6,w)},[]);let v=c.useMemo(()=>({subscribe:q=>(l.current.add(q),()=>l.current.delete(q)),snapshot:()=>n.current,setState:(q,H,I)=>{var R,D,Z,me;if(!Object.is(n.current[q],H)){if(n.current[q]=H,q==="search")S(),B(),j(1,W);else if(q==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let xe=document.getElementById(C);xe?xe.focus():(R=document.getElementById(T))==null||R.focus()}if(j(7,()=>{var xe;n.current.selectedItemId=(xe=te())==null?void 0:xe.id,v.emit()}),I||j(5,w),((D=o.current)==null?void 0:D.value)!==void 0){let xe=H??"";(me=(Z=o.current).onValueChange)==null||me.call(Z,xe);return}}v.emit()}},emit:()=>{l.current.forEach(q=>q())}}),[]),U=c.useMemo(()=>({value:(q,H,I)=>{var R;H!==((R=i.current.get(q))==null?void 0:R.value)&&(i.current.set(q,{value:H,keywords:I}),n.current.filtered.items.set(q,A(H,I)),j(2,()=>{B(),v.emit()}))},item:(q,H)=>(r.current.add(q),H&&(a.current.has(H)?a.current.get(H).add(q):a.current.set(H,new Set([q]))),j(3,()=>{S(),B(),n.current.value||W(),v.emit()}),()=>{i.current.delete(q),r.current.delete(q),n.current.filtered.items.delete(q);let I=te();j(4,()=>{S(),(I==null?void 0:I.getAttribute("id"))===q&&W(),v.emit()})}),group:q=>(a.current.has(q)||a.current.set(q,new Set),()=>{i.current.delete(q),a.current.delete(q)}),filter:()=>o.current.shouldFilter,label:u||t["aria-label"],getDisablePointerSelection:()=>o.current.disablePointerSelection,listId:T,inputId:C,labelId:k,listInnerRef:f}),[]);function A(q,H){var I,R;let D=(R=(I=o.current)==null?void 0:I.filter)!=null?R:Mh;return q?D(q,n.current.search,H):0}function B(){if(!n.current.search||o.current.shouldFilter===!1)return;let q=n.current.filtered.items,H=[];n.current.filtered.groups.forEach(R=>{let D=a.current.get(R),Z=0;D.forEach(me=>{let xe=q.get(me);Z=Math.max(xe,Z)}),H.push([R,Z])});let I=f.current;G().sort((R,D)=>{var Z,me;let xe=R.getAttribute("id"),$=D.getAttribute("id");return((Z=q.get($))!=null?Z:0)-((me=q.get(xe))!=null?me:0)}).forEach(R=>{let D=R.closest(Sa);D?D.appendChild(R.parentElement===D?R:R.closest(`${Sa} > *`)):I.appendChild(R.parentElement===I?R:R.closest(`${Sa} > *`))}),H.sort((R,D)=>D[1]-R[1]).forEach(R=>{var D;let Z=(D=f.current)==null?void 0:D.querySelector(`${_n}[${an}="${encodeURIComponent(R[0])}"]`);Z==null||Z.parentElement.appendChild(Z)})}function W(){let q=G().find(I=>I.getAttribute("aria-disabled")!=="true"),H=q==null?void 0:q.getAttribute(an);v.setState("value",H||void 0)}function S(){var q,H,I,R;if(!n.current.search||o.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let D=0;for(let Z of r.current){let me=(H=(q=i.current.get(Z))==null?void 0:q.value)!=null?H:"",xe=(R=(I=i.current.get(Z))==null?void 0:I.keywords)!=null?R:[],$=A(me,xe);n.current.filtered.items.set(Z,$),$>0&&D++}for(let[Z,me]of a.current)for(let xe of me)if(n.current.filtered.items.get(xe)>0){n.current.filtered.groups.add(Z);break}n.current.filtered.count=D}function w(){var q,H,I;let R=te();R&&(((q=R.parentElement)==null?void 0:q.firstChild)===R&&((I=(H=R.closest(_n))==null?void 0:H.querySelector(Eh))==null||I.scrollIntoView({block:"nearest"})),R.scrollIntoView({block:"nearest"}))}function te(){var q;return(q=f.current)==null?void 0:q.querySelector(`${gc}[aria-selected="true"]`)}function G(){var q;return Array.from(((q=f.current)==null?void 0:q.querySelectorAll(Pl))||[])}function K(q){let H=G()[q];H&&v.setState("value",H.getAttribute(an))}function M(q){var H;let I=te(),R=G(),D=R.findIndex(me=>me===I),Z=R[D+q];(H=o.current)!=null&&H.loop&&(Z=D+q<0?R[R.length-1]:D+q===R.length?R[0]:R[D+q]),Z&&v.setState("value",Z.getAttribute(an))}function ee(q){let H=te(),I=H==null?void 0:H.closest(_n),R;for(;I&&!R;)I=q>0?zh(I,_n):Kh(I,_n),R=I==null?void 0:I.querySelector(Pl);R?v.setState("value",R.getAttribute(an)):M(q)}let L=()=>K(G().length-1),ae=q=>{q.preventDefault(),q.metaKey?L():q.altKey?ee(1):M(1)},oe=q=>{q.preventDefault(),q.metaKey?K(0):q.altKey?ee(-1):M(-1)};return c.createElement(Fs.div,{ref:s,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:q=>{var H;(H=g.onKeyDown)==null||H.call(g,q);let I=q.nativeEvent.isComposing||q.keyCode===229;if(!(q.defaultPrevented||I))switch(q.key){case"n":case"j":{b&&q.ctrlKey&&ae(q);break}case"ArrowDown":{ae(q);break}case"p":case"k":{b&&q.ctrlKey&&oe(q);break}case"ArrowUp":{oe(q);break}case"Home":{q.preventDefault(),K(0);break}case"End":{q.preventDefault(),L();break}case"Enter":{q.preventDefault();let R=te();if(R){let D=new Event(ei);R.dispatchEvent(D)}}}}},c.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:Wh},u),ua(t,q=>c.createElement(bc.Provider,{value:v},c.createElement(fc.Provider,{value:U},q))))}),Dh=c.forwardRef((t,s)=>{var n,r;let a=un(),i=c.useRef(null),l=c.useContext(jc),o=ur(),u=yc(t),d=(r=(n=u.current)==null?void 0:n.forceMount)!=null?r:l==null?void 0:l.forceMount;Hs(()=>{if(!d)return o.item(a,l==null?void 0:l.id)},[d]);let m=Nc(a,i,[t.value,t.children,i],t.keywords),p=Li(),h=_s(j=>j.value&&j.value===m.current),x=_s(j=>d||o.filter()===!1?!0:j.search?j.filtered.items.get(a)>0:!0);c.useEffect(()=>{let j=i.current;if(!(!j||t.disabled))return j.addEventListener(ei,y),()=>j.removeEventListener(ei,y)},[x,t.onSelect,t.disabled]);function y(){var j,v;N(),(v=(j=u.current).onSelect)==null||v.call(j,m.current)}function N(){p.setState("value",m.current,!0)}if(!x)return null;let{disabled:b,value:g,onSelect:T,forceMount:k,keywords:C,...f}=t;return c.createElement(Fs.div,{ref:Gn(i,s),...f,id:a,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||o.getDisablePointerSelection()?void 0:N,onClick:b?void 0:y},t.children)}),_h=c.forwardRef((t,s)=>{let{heading:n,children:r,forceMount:a,...i}=t,l=un(),o=c.useRef(null),u=c.useRef(null),d=un(),m=ur(),p=_s(x=>a||m.filter()===!1?!0:x.search?x.filtered.groups.has(l):!0);Hs(()=>m.group(l),[]),Nc(l,o,[t.value,t.heading,u]);let h=c.useMemo(()=>({id:l,forceMount:a}),[a]);return c.createElement(Fs.div,{ref:Gn(o,s),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&c.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),ua(t,x=>c.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},c.createElement(jc.Provider,{value:h},x))))}),Fh=c.forwardRef((t,s)=>{let{alwaysRender:n,...r}=t,a=c.useRef(null),i=_s(l=>!l.search);return!n&&!i?null:c.createElement(Fs.div,{ref:Gn(a,s),...r,"cmdk-separator":"",role:"separator"})}),$h=c.forwardRef((t,s)=>{let{onValueChange:n,...r}=t,a=t.value!=null,i=Li(),l=_s(d=>d.search),o=_s(d=>d.selectedItemId),u=ur();return c.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),c.createElement(Fs.input,{ref:s,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":o,id:u.inputId,type:"text",value:a?t.value:l,onChange:d=>{a||i.setState("search",d.target.value),n==null||n(d.target.value)}})}),Oh=c.forwardRef((t,s)=>{let{children:n,label:r="Suggestions",...a}=t,i=c.useRef(null),l=c.useRef(null),o=_s(d=>d.selectedItemId),u=ur();return c.useEffect(()=>{if(l.current&&i.current){let d=l.current,m=i.current,p,h=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let x=d.offsetHeight;m.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return h.observe(d),()=>{cancelAnimationFrame(p),h.unobserve(d)}}},[]),c.createElement(Fs.div,{ref:Gn(i,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":o,"aria-label":r,id:u.listId},ua(t,d=>c.createElement("div",{ref:Gn(l,u.listInnerRef),"cmdk-list-sizer":""},d)))}),Lh=c.forwardRef((t,s)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:l,...o}=t;return c.createElement(jd,{open:n,onOpenChange:r},c.createElement(vd,{container:l},c.createElement(yd,{"cmdk-overlay":"",className:a}),c.createElement(Nd,{"aria-label":t.label,"cmdk-dialog":"",className:i},c.createElement(vc,{ref:s,...o}))))}),qh=c.forwardRef((t,s)=>_s(n=>n.filtered.count===0)?c.createElement(Fs.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Bh=c.forwardRef((t,s)=>{let{progress:n,children:r,label:a="Loading...",...i}=t;return c.createElement(Fs.div,{ref:s,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},ua(t,l=>c.createElement("div",{"aria-hidden":!0},l)))}),Ys=Object.assign(vc,{List:Oh,Item:Dh,Input:$h,Group:_h,Separator:Fh,Dialog:Lh,Empty:qh,Loading:Bh});function zh(t,s){let n=t.nextElementSibling;for(;n;){if(n.matches(s))return n;n=n.nextElementSibling}}function Kh(t,s){let n=t.previousElementSibling;for(;n;){if(n.matches(s))return n;n=n.previousElementSibling}}function yc(t){let s=c.useRef(t);return Hs(()=>{s.current=t}),s}var Hs=typeof window>"u"?c.useEffect:c.useLayoutEffect;function ln(t){let s=c.useRef();return s.current===void 0&&(s.current=t()),s}function _s(t){let s=Li(),n=()=>t(s.snapshot());return c.useSyncExternalStore(s.subscribe,n,n)}function Nc(t,s,n,r=[]){let a=c.useRef(),i=ur();return Hs(()=>{var l;let o=(()=>{var d;for(let m of n){if(typeof m=="string")return m.trim();if(typeof m=="object"&&"current"in m)return m.current?(d=m.current.textContent)==null?void 0:d.trim():a.current}})(),u=r.map(d=>d.trim());i.value(t,o,u),(l=s.current)==null||l.setAttribute(an,o),a.current=o}),a}var Uh=()=>{let[t,s]=c.useState(),n=ln(()=>new Map);return Hs(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,a)=>{n.current.set(r,a),s({})}};function Vh(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function ua({asChild:t,children:s},n){return t&&c.isValidElement(s)?c.cloneElement(Vh(s),{ref:s.ref},n(s.props.children)):n(s)}var Wh={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function wc({className:t,...s}){return e.jsx(Ys,{"data-slot":"command",className:z("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...s})}function Qh({title:t="Command Palette",description:s="Search for a command to run...",children:n,className:r,showCloseButton:a=!0,...i}){return e.jsxs(js,{...i,children:[e.jsxs(mn,{className:"sr-only",children:[e.jsx(xn,{children:t}),e.jsx(Bn,{children:s})]}),e.jsxs(vs,{className:z("overflow-hidden p-0",r),showCloseButton:!1,children:[e.jsx(wc,{className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n}),a&&e.jsxs(wd,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-0 right-2 flex h-12 items-center rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e.jsx(nt,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function kc({className:t,...s}){return e.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[e.jsx(fs,{className:"size-4 shrink-0 opacity-50"}),e.jsx(Ys.Input,{"data-slot":"command-input",className:z("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...s})]})}function Cc({className:t,...s}){return e.jsx(Ys.List,{"data-slot":"command-list",className:z("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...s})}function Sc({...t}){return e.jsx(Ys.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function Bs({className:t,...s}){return e.jsx(Ys.Group,{"data-slot":"command-group",className:z("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...s})}function On({className:t,...s}){return e.jsx(Ys.Separator,{"data-slot":"command-separator",className:z("bg-border -mx-1 h-px",t),...s})}function Ze({className:t,...s}){return e.jsx(Ys.Item,{"data-slot":"command-item",className:z("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function Gh(){const[t,s]=c.useState(!1),[n,r]=c.useState(""),a=Rt(),{selectedCompanyId:i}=fe(),{openNewIssue:l,openNewAgent:o}=Ye(),{isMobile:u,setSidebarOpen:d}=Cn(),m=n.trim();c.useEffect(()=>{function k(C){C.key==="k"&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),s(!0),u&&d(!1))}return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[u,d]),c.useEffect(()=>{t||r("")},[t]);const{data:p=[]}=Q({queryKey:P.issues.list(i),queryFn:()=>Ve.list(i),enabled:!!i&&t}),{data:h=[]}=Q({queryKey:P.issues.search(i,m),queryFn:()=>Ve.list(i,{q:m}),enabled:!!i&&t&&m.length>0}),{data:x=[]}=Q({queryKey:P.agents.list(i),queryFn:()=>Te.list(i),enabled:!!i&&t}),{data:y=[]}=Q({queryKey:P.projects.list(i),queryFn:()=>mt.list(i),enabled:!!i&&t}),N=c.useMemo(()=>y.filter(k=>!k.archivedAt),[y]);function b(k){s(!1),a(k)}const g=k=>{var C;return k?((C=x.find(f=>f.id===k))==null?void 0:C.name)??null:null},T=c.useMemo(()=>m.length>0?h:p,[p,h,m]);return e.jsxs(Qh,{open:t,onOpenChange:k=>{s(k),k&&u&&d(!1)},children:[e.jsx(kc,{placeholder:"Search issues, agents, projects...",value:n,onValueChange:r}),e.jsxs(Cc,{children:[e.jsx(Sc,{children:"No results found."}),e.jsxs(Bs,{heading:"Actions",children:[e.jsxs(Ze,{onSelect:()=>{s(!1),l()},children:[e.jsx(ki,{className:"mr-2 h-4 w-4"}),"Create new issue",e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"C"})]}),e.jsxs(Ze,{onSelect:()=>{s(!1),o()},children:[e.jsx(Ae,{className:"mr-2 h-4 w-4"}),"Create new agent"]}),e.jsxs(Ze,{onSelect:()=>b("/projects"),children:[e.jsx(Ae,{className:"mr-2 h-4 w-4"}),"Create new project"]})]}),e.jsx(On,{}),e.jsxs(Bs,{heading:"Pages",children:[e.jsxs(Ze,{onSelect:()=>b("/dashboard"),children:[e.jsx(Vs,{className:"mr-2 h-4 w-4"}),"Dashboard"]}),e.jsxs(Ze,{onSelect:()=>b("/inbox"),children:[e.jsx(Qs,{className:"mr-2 h-4 w-4"}),"Inbox"]}),e.jsxs(Ze,{onSelect:()=>b("/issues"),children:[e.jsx(Wt,{className:"mr-2 h-4 w-4"}),"Issues"]}),e.jsxs(Ze,{onSelect:()=>b("/projects"),children:[e.jsx(vn,{className:"mr-2 h-4 w-4"}),"Projects"]}),e.jsxs(Ze,{onSelect:()=>b("/goals"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Goals"]}),e.jsxs(Ze,{onSelect:()=>b("/agents"),children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),"Agents"]}),e.jsxs(Ze,{onSelect:()=>b("/costs"),children:[e.jsx(ls,{className:"mr-2 h-4 w-4"}),"Costs"]}),e.jsxs(Ze,{onSelect:()=>b("/activity"),children:[e.jsx(Jn,{className:"mr-2 h-4 w-4"}),"Activity"]})]}),T.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(On,{}),e.jsx(Bs,{heading:"Issues",children:T.slice(0,10).map(k=>e.jsxs(Ze,{value:m.length>0?`${m} ${k.identifier??""} ${k.title}`:void 0,onSelect:()=>b(`/issues/${k.identifier??k.id}`),children:[e.jsx(Wt,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-muted-foreground mr-2 font-mono text-xs",children:k.identifier??k.id.slice(0,8)}),e.jsx("span",{className:"flex-1 truncate",children:k.title}),k.assigneeAgentId&&(()=>{const C=g(k.assigneeAgentId);return C?e.jsx(Ue,{name:C,size:"sm",className:"ml-2 hidden sm:inline-flex"}):null})()]},k.id))})]}),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(On,{}),e.jsx(Bs,{heading:"Agents",children:x.slice(0,10).map(k=>e.jsxs(Ze,{onSelect:()=>b(Sn(k)),children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),k.name,e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:k.role})]},k.id))})]}),N.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(On,{}),e.jsx(Bs,{heading:"Projects",children:N.slice(0,10).map(k=>e.jsxs(Ze,{onSelect:()=>b(li(k)),children:[e.jsx(vn,{className:"mr-2 h-4 w-4"}),k.name]},k.id))})]})]})]})}const Hh=[{value:"backlog",label:"Backlog"},{value:"planned",label:"Planned"},{value:"in_progress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"cancelled",label:"Cancelled"}];function Jh(){const{newProjectOpen:t,closeNewProject:s}=Ye(),{selectedCompanyId:n,selectedCompany:r}=fe(),a=_e(),[i,l]=c.useState(""),[o,u]=c.useState(""),[d,m]=c.useState("planned"),[p,h]=c.useState([]),[x,y]=c.useState(""),[N,b]=c.useState(!1),[g,T]=c.useState(""),[k,C]=c.useState(""),[f,j]=c.useState(null),[v,U]=c.useState(!1),[A,B]=c.useState(!1),W=c.useRef(null),{data:S}=Q({queryKey:P.goals.list(n),queryFn:()=>_t.list(n),enabled:!!n&&t}),w=re({mutationFn:I=>mt.create(n,I)}),te=re({mutationFn:async I=>{if(!n)throw new Error("No company selected");return rr.uploadImage(n,I,"projects/drafts")}});function G(){l(""),u(""),m("planned"),h([]),y(""),b(!1),T(""),C(""),j(null)}const K=I=>I.startsWith("/")||/^[A-Za-z]:[\\/]/.test(I),M=I=>{try{const R=new URL(I),D=R.hostname.toLowerCase();return D!=="github.com"&&D!=="www.github.com"?!1:R.pathname.split("/").filter(Boolean).length>=2}catch{return!1}},ee=I=>{const D=I.trim().replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return D[D.length-1]??"Local folder"},L=I=>{var R;try{const Z=new URL(I).pathname.split("/").filter(Boolean);return(((R=Z[Z.length-1])==null?void 0:R.replace(/\.git$/i,""))??"")||"GitHub repo"}catch{return"GitHub repo"}};async function ae(){if(!n||!i.trim())return;const I=g.trim(),R=k.trim();if(I&&!K(I)){j("Local folder must be a full absolute path.");return}if(R&&!M(R)){j("Repo must use a valid GitHub repo URL.");return}j(null);try{const D=await w.mutateAsync({name:i.trim(),description:o.trim()||void 0,status:d,color:Fa[Math.floor(Math.random()*Fa.length)],...p.length>0?{goalIds:p}:{},...x?{targetDate:x}:{}});if(I||R){const Z={name:I?ee(I):L(R),...I?{cwd:I}:{},...R?{repoUrl:R}:{}};await mt.createWorkspace(D.id,Z)}a.invalidateQueries({queryKey:P.projects.list(n)}),a.invalidateQueries({queryKey:P.projects.detail(D.id)}),G(),s()}catch{}}function oe(I){I.key==="Enter"&&(I.metaKey||I.ctrlKey)&&(I.preventDefault(),ae())}const q=(S??[]).filter(I=>p.includes(I.id)),H=(S??[]).filter(I=>!p.includes(I.id));return e.jsx(js,{open:t,onOpenChange:I=>{I||(G(),s())},children:e.jsxs(vs,{showCloseButton:!1,className:z("p-0 gap-0",N?"sm:max-w-2xl":"sm:max-w-lg"),onKeyDown:oe,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r&&e.jsx("span",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-medium",children:r.name.slice(0,3).toUpperCase()}),e.jsx("span",{className:"text-muted-foreground/60",children:"›"}),e.jsx("span",{children:"New project"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:()=>b(!N),children:N?e.jsx(oo,{className:"h-3.5 w-3.5"}):e.jsx(co,{className:"h-3.5 w-3.5"})}),e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:()=>{G(),s()},children:e.jsx("span",{className:"text-lg leading-none",children:"×"})})]})]}),e.jsx("div",{className:"px-4 pt-4 pb-2 shrink-0",children:e.jsx("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Project name",value:i,onChange:I=>l(I.target.value),onKeyDown:I=>{var R;I.key==="Tab"&&!I.shiftKey&&(I.preventDefault(),(R=W.current)==null||R.focus())},autoFocus:!0})}),e.jsx("div",{className:"px-4 pb-2",children:e.jsx(uo,{ref:W,value:o,onChange:u,placeholder:"Add description...",bordered:!1,contentClassName:z("text-sm text-muted-foreground",N?"min-h-[220px]":"min-h-[120px]"),imageUploadHandler:async I=>(await te.mutateAsync(I)).contentPath})}),e.jsxs("div",{className:"px-4 pt-3 pb-3 space-y-3 border-t border-border",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx("label",{className:"block text-xs text-muted-foreground",children:"Repo URL"}),e.jsx("span",{className:"text-xs text-muted-foreground/50",children:"optional"}),e.jsxs(cs,{delayDuration:300,children:[e.jsx(ds,{asChild:!0,children:e.jsx(Qi,{className:"h-3 w-3 text-muted-foreground/50 cursor-help"})}),e.jsx(us,{side:"top",className:"max-w-[240px] text-xs",children:"Link a GitHub repository so agents can clone, read, and push code for this project."})]})]}),e.jsx("input",{className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs outline-none",value:k,onChange:I=>{C(I.target.value),j(null)},placeholder:"https://github.com/org/repo"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx("label",{className:"block text-xs text-muted-foreground",children:"Local folder"}),e.jsx("span",{className:"text-xs text-muted-foreground/50",children:"optional"}),e.jsxs(cs,{delayDuration:300,children:[e.jsx(ds,{asChild:!0,children:e.jsx(Qi,{className:"h-3 w-3 text-muted-foreground/50 cursor-help"})}),e.jsx(us,{side:"top",className:"max-w-[240px] text-xs",children:"Set an absolute path on this machine where local agents will read and write files for this project."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",value:g,onChange:I=>{T(I.target.value),j(null)},placeholder:"/absolute/path/to/workspace"}),e.jsx(mo,{})]})]}),f&&e.jsx("p",{className:"text-xs text-destructive",children:f})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[e.jsxs(vt,{open:v,onOpenChange:U,children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:e.jsx(Pe,{status:d})})}),e.jsx(Nt,{className:"w-40 p-1",align:"start",children:Hh.map(I=>e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",I.value===d&&"bg-accent"),onClick:()=>{m(I.value),U(!1)},children:I.label},I.value))})]}),q.map(I=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs",children:[e.jsx(ws,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"max-w-[160px] truncate",children:I.title}),e.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>h(R=>R.filter(D=>D!==I.id)),"aria-label":`Remove goal ${I.title}`,type:"button",children:e.jsx(nt,{className:"h-3 w-3"})})]},I.id)),e.jsxs(vt,{open:A,onOpenChange:B,children:[e.jsx(yt,{asChild:!0,children:e.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors disabled:opacity-60",disabled:q.length>0&&H.length===0,children:[q.length>0?e.jsx(Ae,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(ws,{className:"h-3 w-3 text-muted-foreground"}),q.length>0?"+ Goal":"Goal"]})}),e.jsxs(Nt,{className:"w-56 p-1",align:"start",children:[q.length===0&&e.jsx("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:()=>B(!1),children:"No goal"}),H.map(I=>e.jsx("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",onClick:()=>{h(R=>[...R,I.id]),B(!1)},children:I.title},I.id)),q.length>0&&H.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All goals already selected."})]})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs",children:[e.jsx(xo,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{type:"date",className:"bg-transparent outline-none text-xs w-24",value:x,onChange:I=>y(I.target.value),placeholder:"Target date"})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-t border-border",children:[w.isError?e.jsx("p",{className:"text-xs text-destructive",children:"Failed to create project."}):e.jsx("span",{}),e.jsx(F,{size:"sm",disabled:!i.trim()||w.isPending,onClick:ae,children:w.isPending?"Creating…":"Create project"})]})]})})}const Tl={company:"Company",team:"Team",agent:"Agent",task:"Task"};function Yh(){const{newGoalOpen:t,newGoalDefaults:s,closeNewGoal:n}=Ye(),{selectedCompanyId:r,selectedCompany:a}=fe(),i=_e(),[l,o]=c.useState(""),[u,d]=c.useState(""),[m,p]=c.useState("planned"),[h,x]=c.useState("task"),[y,N]=c.useState(""),[b,g]=c.useState(!1),[T,k]=c.useState(!1),[C,f]=c.useState(!1),[j,v]=c.useState(!1),U=c.useRef(null),A=y||s.parentId||"",{data:B}=Q({queryKey:P.goals.list(r),queryFn:()=>_t.list(r),enabled:!!r&&t}),W=re({mutationFn:M=>_t.create(r,M),onSuccess:()=>{i.invalidateQueries({queryKey:P.goals.list(r)}),w(),n()}}),S=re({mutationFn:async M=>{if(!r)throw new Error("No company selected");return rr.uploadImage(r,M,"goals/drafts")}});function w(){o(""),d(""),p("planned"),x("task"),N(""),g(!1)}function te(){!r||!l.trim()||W.mutate({title:l.trim(),description:u.trim()||void 0,status:m,level:h,...A?{parentId:A}:{}})}function G(M){M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&(M.preventDefault(),te())}const K=(B??[]).find(M=>M.id===A);return e.jsx(js,{open:t,onOpenChange:M=>{M||(w(),n())},children:e.jsxs(vs,{showCloseButton:!1,className:z("p-0 gap-0",b?"sm:max-w-2xl":"sm:max-w-lg"),onKeyDown:G,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a&&e.jsx("span",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-medium",children:a.name.slice(0,3).toUpperCase()}),e.jsx("span",{className:"text-muted-foreground/60",children:"›"}),e.jsx("span",{children:s.parentId?"New sub-goal":"New goal"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:()=>g(!b),children:b?e.jsx(oo,{className:"h-3.5 w-3.5"}):e.jsx(co,{className:"h-3.5 w-3.5"})}),e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:()=>{w(),n()},children:e.jsx("span",{className:"text-lg leading-none",children:"×"})})]})]}),e.jsx("div",{className:"px-4 pt-4 pb-2 shrink-0",children:e.jsx("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Goal title",value:l,onChange:M=>o(M.target.value),onKeyDown:M=>{var ee;M.key==="Tab"&&!M.shiftKey&&(M.preventDefault(),(ee=U.current)==null||ee.focus())},autoFocus:!0})}),e.jsx("div",{className:"px-4 pb-2",children:e.jsx(uo,{ref:U,value:u,onChange:d,placeholder:"Add description...",bordered:!1,contentClassName:z("text-sm text-muted-foreground",b?"min-h-[220px]":"min-h-[120px]"),imageUploadHandler:async M=>(await S.mutateAsync(M)).contentPath})}),e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[e.jsxs(vt,{open:T,onOpenChange:k,children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:e.jsx(Pe,{status:m})})}),e.jsx(Nt,{className:"w-40 p-1",align:"start",children:po.map(M=>e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",M===m&&"bg-accent"),onClick:()=>{p(M),k(!1)},children:M},M))})]}),e.jsxs(vt,{open:C,onOpenChange:f,children:[e.jsx(yt,{asChild:!0,children:e.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[e.jsx(Do,{className:"h-3 w-3 text-muted-foreground"}),Tl[h]??h]})}),e.jsx(Nt,{className:"w-40 p-1",align:"start",children:ho.map(M=>e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",M===h&&"bg-accent"),onClick:()=>{x(M),f(!1)},children:Tl[M]??M},M))})]}),e.jsxs(vt,{open:j,onOpenChange:v,children:[e.jsx(yt,{asChild:!0,children:e.jsxs("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[e.jsx(ws,{className:"h-3 w-3 text-muted-foreground"}),K?K.title:"Parent goal"]})}),e.jsxs(Nt,{className:"w-48 p-1",align:"start",children:[e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!A&&"bg-accent"),onClick:()=>{N(""),v(!1)},children:"No parent"}),(B??[]).map(M=>e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",M.id===A&&"bg-accent"),onClick:()=>{N(M.id),v(!1)},children:M.title},M.id))]})]})]}),e.jsx("div",{className:"flex items-center justify-end px-4 py-2.5 border-t border-border",children:e.jsx(F,{size:"sm",disabled:!l.trim()||W.isPending,onClick:te,children:W.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}const Xh=[{value:"claude_local",label:"Claude Code",icon:oi,desc:"Local Claude agent",recommended:!0},{value:"codex_local",label:"Codex",icon:kd,desc:"Local Codex agent",recommended:!0},{value:"gemini_local",label:"Gemini CLI",icon:Cd,desc:"Local Gemini agent"},{value:"opencode_local",label:"OpenCode",icon:Sd,desc:"Local multi-provider agent"},{value:"pi_local",label:"Pi",icon:Id,desc:"Local Pi agent"},{value:"cursor",label:"Cursor",icon:Ad,desc:"Local Cursor agent"},{value:"openclaw_gateway",label:"OpenClaw Gateway",icon:Gt,desc:"Invoke OpenClaw via gateway protocol"}];function Zh(){const{newAgentOpen:t,closeNewAgent:s,openNewIssue:n}=Ye(),{selectedCompanyId:r}=fe(),a=Rt(),[i,l]=c.useState(!1),{data:o}=Q({queryKey:P.agents.list(r),queryFn:()=>Te.list(r),enabled:!!r&&t}),u=(o??[]).find(h=>h.role==="ceo");function d(){s(),n({assigneeAgentId:u==null?void 0:u.id,title:"Create a new agent",description:"(type in what kind of agent you want here)"})}function m(){l(!0)}function p(h){s(),l(!1),a(`/agents/new?adapterType=${encodeURIComponent(h)}`)}return e.jsx(js,{open:t,onOpenChange:h=>{h||(l(!1),s())},children:e.jsxs(vs,{showCloseButton:!1,className:"sm:max-w-md p-0 gap-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Add a new agent"}),e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:()=>{l(!1),s()},children:e.jsx("span",{className:"text-lg leading-none",children:"×"})})]}),e.jsx("div",{className:"p-6 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>l(!1),children:[e.jsx(ci,{className:"h-3.5 w-3.5"}),"Back"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose your adapter type for advanced setup."})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Xh.map(h=>e.jsxs("button",{className:z("flex flex-col items-center gap-1.5 rounded-md border border-border p-3 text-xs transition-colors hover:bg-accent/50 relative"),onClick:()=>p(h.value),children:[h.recommended&&e.jsx("span",{className:"absolute -top-1.5 right-1.5 bg-green-500 text-white text-[9px] font-semibold px-1.5 py-0.5 rounded-full leading-none",children:"Recommended"}),e.jsx(h.icon,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:h.label}),e.jsx("span",{className:"text-muted-foreground text-[10px]",children:h.desc})]},h.value))})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-accent",children:e.jsx(oi,{className:"h-6 w-6 text-foreground"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We recommend letting your CEO handle agent setup — they know the org structure and can configure reporting, permissions, and adapters."})]}),e.jsxs(F,{className:"w-full",size:"lg",onClick:d,children:[e.jsx(Gt,{className:"h-4 w-4 mr-2"}),"Ask the CEO to create a new agent"]}),e.jsx("div",{className:"text-center",children:e.jsx("button",{className:"text-xs text-muted-foreground hover:text-foreground underline underline-offset-2 transition-colors",onClick:m,children:"I want advanced configuration myself"})})]})})]})})}function eg({visible:t}){const s=wt(),{selectedCompanyId:n}=fe(),{openNewIssue:r}=Ye(),a=pc(n),i=c.useMemo(()=>[{type:"link",to:"/dashboard",label:"Home",icon:Km},{type:"link",to:"/issues",label:"Issues",icon:Wt},{type:"action",label:"Create",icon:ki,onClick:()=>r()},{type:"link",to:"/agents/all",label:"Agents",icon:go},{type:"link",to:"/inbox",label:"Inbox",icon:Qs,badge:a.inbox}],[r,a.inbox]);return e.jsx("nav",{className:z("fixed bottom-0 left-0 right-0 z-30 border-t border-border bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85 transition-transform duration-200 ease-out md:hidden pb-[env(safe-area-inset-bottom)]",t?"translate-y-0":"translate-y-full"),"aria-label":"Mobile navigation",children:e.jsx("div",{className:"grid h-16 grid-cols-5 px-1",children:i.map(l=>{if(l.type==="action"){const u=l.icon,d=/\/issues\/new(?:\/|$)/.test(s.pathname);return e.jsxs("button",{type:"button",onClick:l.onClick,className:z("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-[10px] font-medium transition-colors",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(u,{className:"h-[18px] w-[18px]"}),e.jsx("span",{className:"truncate",children:l.label})]},l.label)}const o=l.icon;return e.jsx(nr,{to:l.to,className:({isActive:u})=>z("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-[10px] font-medium transition-colors",u?"text-foreground":"text-muted-foreground hover:text-foreground"),children:({isActive:u})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"relative",children:[e.jsx(o,{className:z("h-[18px] w-[18px]",u&&"stroke-[2.3]")}),l.badge!=null&&l.badge>0&&e.jsx("span",{className:"absolute -right-2 -top-2 rounded-full bg-primary px-1.5 py-0.5 text-[10px] leading-none text-primary-foreground",children:l.badge>99?"99+":l.badge})]}),e.jsx("span",{className:"truncate",children:l.label})]})},l.label)})})})}function fr(t){var r;if(typeof document>"u")return null;const s=document.querySelector(`meta[name="${t}"]`),n=(r=s==null?void 0:s.getAttribute("content"))==null?void 0:r.trim();return n||null}function ti(t){if(!t)return null;const s=t.startsWith("#")?t.slice(1):t;return/^[0-9a-fA-F]{3}$/.test(s)?`#${s.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}function tg(t){const s=ti(t)??"#000000";return{r:Number.parseInt(s.slice(1,3),16),g:Number.parseInt(s.slice(3,5),16),b:Number.parseInt(s.slice(5,7),16)}}function Ia(t){const s=t/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4}function sg(t){const{r:s,g:n,b:r}=tg(t),a=.2126*Ia(s)+.7152*Ia(n)+.0722*Ia(r),i=1.05/(a+.05),l=(a+.05)/.05;return i>=l?"#f8fafc":"#111827"}function ng(){if(fr("paperclip-worktree-enabled")!=="true")return null;const t=fr("paperclip-worktree-name"),s=ti(fr("paperclip-worktree-color"));return!t||!s?null:{enabled:!0,name:t,color:s,textColor:ti(fr("paperclip-worktree-text-color"))??sg(s)}}function rg(){const t=ng();return t?e.jsx("div",{className:"relative overflow-hidden border-b px-3 py-1.5 text-[11px] font-medium tracking-[0.2em] uppercase",style:{backgroundColor:t.color,color:t.textColor,borderColor:`${t.textColor}22`,boxShadow:`inset 0 -1px 0 ${t.textColor}18`,backgroundImage:`linear-gradient(90deg, ${t.textColor}14, transparent 28%, transparent 72%, ${t.textColor}12), repeating-linear-gradient(135deg, transparent 0 10px, ${t.textColor}08 10px 20px)`},children:e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{className:"shrink-0 opacity-70",children:"Worktree"}),e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-70","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-semibold tracking-[0.12em]",children:t.name})]})}):null}function ag({onNewIssue:t,onToggleSidebar:s,onTogglePanel:n}){c.useEffect(()=>{function r(a){const i=a.target;i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable||(a.key==="c"&&!a.metaKey&&!a.ctrlKey&&!a.altKey&&(a.preventDefault(),t==null||t()),a.key==="["&&!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),s==null||s()),a.key==="]"&&!a.metaKey&&!a.ctrlKey&&(a.preventDefault(),n==null||n()))}return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,s,n])}const ig=new Set(["auth","invite","board-claim","docs"]);function Ic(t){const n=(t.split("?")[0]??"").split("/").filter(Boolean);if(n.length===0)return!0;const[r]=n;return!ig.has(r)}function lg(t){const s=Ar(t.companyPrefix);return t.companies.find(n=>Ar(n.issuePrefix)===s)??null}function og(t){var n;const s=Pd(t.pathname);return s?((n=lg({companies:t.companies,companyPrefix:s}))==null?void 0:n.id)??null:t.fallbackCompanyId}function cg(t){const s=t.path?fo(t.path):"/dashboard";if(!Ic(s))return"/dashboard";const r=(s.split("?")[0]??"").split("/").filter(Boolean),[a,i]=r;if(a==="issues"&&i){const l=/^([A-Za-z]+)-\d+$/.exec(i);if(l&&Ar(l[1]??"")!==Ar(t.companyPrefix))return"/dashboard"}return s}const Ac="paperclip.companyPaths";function Pc(){try{const t=localStorage.getItem(Ac);if(t)return JSON.parse(t)}catch{}return{}}function dg(t,s){const n=Pc();n[t]=s,localStorage.setItem(Ac,JSON.stringify(n))}function ug(){const{companies:t,selectedCompanyId:s,selectedCompany:n,selectionSource:r}=fe(),a=wt(),i=Rt(),l=c.useRef(s),o=c.useMemo(()=>og({companies:t,pathname:a.pathname,fallbackCompanyId:l.current}),[t,a.pathname]),u=a.pathname+a.search;c.useEffect(()=>{const d=o,m=fo(u);d&&Ic(m)&&dg(d,m)},[u,o]),c.useEffect(()=>{if(s){if(l.current!==null&&s!==l.current&&r!=="route_sync"&&n){const d=Pc(),m=cg({path:d[s],companyPrefix:n.issuePrefix});i(`/${n.issuePrefix}${m}`,{replace:!0})}l.current=s}},[n,s,r,i])}function mg(t){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:r}=t;return!(n===r||s==="manual"&&n)}const qr="/instance/settings/heartbeats";function Tc(t){if(!t)return qr;const s=t.match(/^([^?#]*)(\?[^#]*)?(#.*)?$/),n=(s==null?void 0:s[1])??t,r=(s==null?void 0:s[2])??"",a=(s==null?void 0:s[3])??"";return n==="/instance/settings/heartbeats"||n==="/instance/settings/plugins"||n==="/instance/settings/experimental"?`${n}${r}${a}`:/^\/instance\/settings\/plugins\/[^/?#]+$/.test(n)?`${n}${r}${a}`:qr}const Rc="paperclip.lastInstanceSettingsPath";function xg(){if(typeof window>"u")return qr;try{return Tc(window.localStorage.getItem(Rc))}catch{return qr}}function Rl(){const{sidebarOpen:t,setSidebarOpen:s,toggleSidebar:n,isMobile:r}=Cn(),{openNewIssue:a,openOnboarding:i}=Ye(),{togglePanelVisible:l}=di(),{companies:o,loading:u,selectedCompany:d,selectedCompanyId:m,selectionSource:p,setSelectedCompanyId:h}=fe(),{theme:x,toggleTheme:y}=Td(),{companyPrefix:N}=Cs(),b=Rt(),g=wt(),T=g.pathname.startsWith("/instance/"),k=c.useRef(!1),C=c.useRef(0),[f,j]=c.useState(!0),[v,U]=c.useState(()=>xg()),A=x==="dark"?"light":"dark",B=c.useMemo(()=>{if(!N)return null;const G=N.toUpperCase();return o.find(K=>K.issuePrefix.toUpperCase()===G)??null},[o,N]),W=!!N&&!u&&o.length>0&&!B,{data:S}=Q({queryKey:P.health,queryFn:()=>jo.get(),retry:!1});c.useEffect(()=>{u||k.current||(S==null?void 0:S.deploymentMode)!=="authenticated"&&o.length===0&&(k.current=!0,i())},[o,u,i,S==null?void 0:S.deploymentMode]),c.useEffect(()=>{if(!(!N||u||o.length===0)){if(!B){const G=(m?o.find(K=>K.id===m):null)??o[0]??null;G&&m!==G.id&&h(G.id,{source:"route_sync"});return}if(N!==B.issuePrefix){const G=g.pathname.replace(/^\/[^/]+/,"");b(`/${B.issuePrefix}${G}${g.search}`,{replace:!0});return}mg({selectionSource:p,selectedCompanyId:m,routeCompanyId:B.id})&&h(B.id,{source:"route_sync"})}},[N,o,u,B,g.pathname,g.search,b,p,m,h]);const w=l;ug(),ag({onNewIssue:()=>a(),onToggleSidebar:n,onTogglePanel:w}),c.useEffect(()=>{if(!r){j(!0);return}C.current=0,j(!0)},[r]),c.useEffect(()=>{if(!r)return;const G=30,K=50,M=75;let ee=0,L=0;const ae=q=>{const H=q.touches[0];ee=H.clientX,L=H.clientY},oe=q=>{const H=q.changedTouches[0],I=H.clientX-ee;if(!(Math.abs(H.clientY-L)>M)){if(!t&&ee<G&&I>K){s(!0);return}t&&I<-K&&s(!1)}};return document.addEventListener("touchstart",ae,{passive:!0}),document.addEventListener("touchend",oe,{passive:!0}),()=>{document.removeEventListener("touchstart",ae),document.removeEventListener("touchend",oe)}},[r,t,s]);const te=c.useCallback(G=>{const K=G-C.current;G<=24?j(!0):K>8?j(!1):K<-8&&j(!0),C.current=G},[]);return c.useEffect(()=>{if(!r){j(!0),C.current=0;return}const G=()=>{te(window.scrollY||document.documentElement.scrollTop||0)};return G(),window.addEventListener("scroll",G,{passive:!0}),()=>{window.removeEventListener("scroll",G)}},[r,te]),c.useEffect(()=>{const G=document.body.style.overflow;return document.body.style.overflow=r?"visible":"hidden",()=>{document.body.style.overflow=G}},[r]),c.useEffect(()=>{if(!g.pathname.startsWith("/instance/settings/"))return;const G=Tc(`${g.pathname}${g.search}${g.hash}`);U(G);try{window.localStorage.setItem(Rc,G)}catch{}},[g.hash,g.pathname,g.search]),e.jsxs("div",{className:z("bg-background text-foreground pt-[env(safe-area-inset-top)]",r?"min-h-dvh":"flex h-dvh flex-col overflow-hidden"),children:[e.jsx("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-[200] focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),e.jsx(rg,{}),e.jsxs("div",{className:z("min-h-0 flex-1",r?"w-full":"flex overflow-hidden"),children:[r&&t&&e.jsx("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:()=>s(!1),"aria-label":"Close sidebar"}),r?e.jsxs("div",{className:z("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-[env(safe-area-inset-top)] transition-transform duration-100 ease-out",t?"translate-x-0":"-translate-x-full"),children:[e.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[e.jsx(Nl,{}),T?e.jsx(Sl,{}):e.jsx(Cl,{})]}),e.jsx("div",{className:"border-t border-r border-border px-3 py-2 bg-background",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("a",{href:"https://docs.paperclip.ing/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2.5 px-3 py-2 text-[13px] font-medium transition-colors text-foreground/80 hover:bg-accent/50 hover:text-foreground flex-1 min-w-0",children:[e.jsx(Va,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Documentation"})]}),(S==null?void 0:S.version)&&e.jsxs(cs,{children:[e.jsx(ds,{asChild:!0,children:e.jsx("span",{className:"px-2 text-xs text-muted-foreground shrink-0 cursor-default",children:"v"})}),e.jsxs(us,{children:["v",S.version]})]}),e.jsx(F,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground shrink-0",asChild:!0,children:e.jsx(he,{to:v,"aria-label":"Instance settings",title:"Instance settings",onClick:()=>{r&&s(!1)},children:e.jsx(ks,{className:"h-4 w-4"})})}),e.jsx(F,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground shrink-0",onClick:y,"aria-label":`Switch to ${A} mode`,title:`Switch to ${A} mode`,children:x==="dark"?e.jsx(Gi,{className:"h-4 w-4"}):e.jsx(Hi,{className:"h-4 w-4"})})]})})]}):e.jsxs("div",{className:"flex h-full flex-col shrink-0",children:[e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(Nl,{}),e.jsx("div",{className:z("overflow-hidden transition-[width] duration-100 ease-out",t?"w-60":"w-0"),children:T?e.jsx(Sl,{}):e.jsx(Cl,{})})]}),e.jsx("div",{className:"border-t border-r border-border px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("a",{href:"https://docs.paperclip.ing/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2.5 px-3 py-2 text-[13px] font-medium transition-colors text-foreground/80 hover:bg-accent/50 hover:text-foreground flex-1 min-w-0",children:[e.jsx(Va,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:"Documentation"})]}),(S==null?void 0:S.version)&&e.jsxs(cs,{children:[e.jsx(ds,{asChild:!0,children:e.jsx("span",{className:"px-2 text-xs text-muted-foreground shrink-0 cursor-default",children:"v"})}),e.jsxs(us,{children:["v",S.version]})]}),e.jsx(F,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground shrink-0",asChild:!0,children:e.jsx(he,{to:v,"aria-label":"Instance settings",title:"Instance settings",onClick:()=>{r&&s(!1)},children:e.jsx(ks,{className:"h-4 w-4"})})}),e.jsx(F,{type:"button",variant:"ghost",size:"icon-sm",className:"text-muted-foreground shrink-0",onClick:y,"aria-label":`Switch to ${A} mode`,title:`Switch to ${A} mode`,children:x==="dark"?e.jsx(Gi,{className:"h-4 w-4"}):e.jsx(Hi,{className:"h-4 w-4"})})]})})]}),e.jsxs("div",{className:z("flex min-w-0 flex-col",r?"w-full":"h-full flex-1"),children:[e.jsx("div",{className:z(r&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:e.jsx(Rd,{})}),e.jsxs("div",{className:z(r?"block":"flex flex-1 min-h-0"),children:[e.jsx("main",{id:"main-content",tabIndex:-1,className:z("flex-1 p-4 md:p-6",r?"overflow-visible pb-[calc(5rem+env(safe-area-inset-bottom))]":"overflow-auto"),children:W?e.jsx(Hn,{scope:"invalid_company_prefix",requestedPrefix:N??(d==null?void 0:d.issuePrefix)}):e.jsx(bo,{})}),e.jsx(Ed,{})]})]})]}),r&&e.jsx(eg,{visible:f}),e.jsx(Gh,{}),e.jsx(Md,{}),e.jsx(Jh,{}),e.jsx(Yh,{}),e.jsx(Zh,{}),e.jsx(Dd,{})]})}function Ms({icon:t,value:s,label:n,description:r,to:a,onClick:i}){const l=!!(a||i),o=e.jsx("div",{className:`h-full px-4 py-4 sm:px-5 sm:py-5 rounded-lg transition-colors${l?" hover:bg-accent/50 cursor-pointer":""}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-2xl sm:text-3xl font-semibold tracking-tight tabular-nums",children:s}),e.jsx("p",{className:"text-xs sm:text-sm font-medium text-muted-foreground mt-1",children:n}),r&&e.jsx("div",{className:"text-xs text-muted-foreground/70 mt-1.5 hidden sm:block",children:r})]}),e.jsx(t,{className:"h-4 w-4 text-muted-foreground/50 shrink-0 mt-1.5"})]})});return a?e.jsx(he,{to:a,className:"no-underline text-inherit h-full",onClick:i,children:o}):i?e.jsx("div",{className:"h-full",onClick:i,children:o}):o}const pg={"issue.created":"created","issue.updated":"updated","issue.checked_out":"checked out","issue.released":"released","issue.comment_added":"commented on","issue.attachment_added":"attached file to","issue.attachment_removed":"removed attachment from","issue.document_created":"created document for","issue.document_updated":"updated document on","issue.document_deleted":"deleted document from","issue.commented":"commented on","issue.deleted":"deleted","agent.created":"created","agent.updated":"updated","agent.paused":"paused","agent.resumed":"resumed","agent.terminated":"terminated","agent.key_created":"created API key for","agent.budget_updated":"updated budget for","agent.runtime_session_reset":"reset session for","heartbeat.invoked":"invoked heartbeat for","heartbeat.cancelled":"cancelled heartbeat for","approval.created":"requested approval","approval.approved":"approved","approval.rejected":"rejected","project.created":"created","project.updated":"updated","project.deleted":"deleted","goal.created":"created","goal.updated":"updated","goal.deleted":"deleted","cost.reported":"reported cost for","cost.recorded":"recorded cost for","company.created":"created company","company.updated":"updated company","company.archived":"archived","company.budget_updated":"updated budget for"};function en(t){return typeof t!="string"?String(t??"none"):t.replace(/_/g," ")}function hg(t,s){if(t==="issue.updated"&&s){const n=s._previous??{};if(s.status!==void 0){const r=n.status;return r?`changed status from ${en(r)} to ${en(s.status)} on`:`changed status to ${en(s.status)} on`}if(s.priority!==void 0){const r=n.priority;return r?`changed priority from ${en(r)} to ${en(s.priority)} on`:`changed priority to ${en(s.priority)} on`}}return pg[t]??t.replace(/[._]/g," ")}function gg(t,s,n){switch(t){case"issue":return`/issues/${n??s}`;case"agent":return`/agents/${s}`;case"project":return`/projects/${_d(n,s)}`;case"goal":return`/goals/${s}`;case"approval":return`/approvals/${s}`;default:return null}}function Ec({event:t,agentMap:s,entityNameMap:n,entityTitleMap:r,className:a}){var N;const i=hg(t.action,t.details),l=t.entityType==="heartbeat_run",o=l?(N=t.details)==null?void 0:N.agentId:void 0,u=l?o?n.get(`agent:${o}`):null:n.get(`${t.entityType}:${t.entityId}`),d=r==null?void 0:r.get(`${t.entityType}:${t.entityId}`),m=l&&o?`/agents/${o}/runs/${t.entityId}`:gg(t.entityType,t.entityId,u),p=t.actorType==="agent"?s.get(t.actorId):null,h=(p==null?void 0:p.name)??(t.actorType==="system"?"System":t.actorType==="user"?"Board":t.actorId||"Unknown"),x=e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("p",{className:"flex-1 min-w-0 truncate",children:[e.jsx(Ue,{name:h,size:"xs",className:"align-baseline"}),e.jsxs("span",{className:"text-muted-foreground ml-1",children:[i," "]}),u&&e.jsx("span",{className:"font-medium",children:u}),d&&e.jsxs("span",{className:"text-muted-foreground ml-1",children:["— ",d]})]}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0 pt-0.5",children:Ut(t.createdAt)})]}),y=z("px-4 py-2 text-sm",m&&"cursor-pointer hover:bg-accent/50 transition-colors",a);return m?e.jsx(he,{to:m,className:z(y,"no-underline text-inherit block"),children:x}):e.jsx("div",{className:y,children:x})}const El=[{dot:"bg-violet-500",text:"text-violet-500",bg:"bg-violet-500/10",border:"border-violet-500/30"},{dot:"bg-blue-500",text:"text-blue-500",bg:"bg-blue-500/10",border:"border-blue-500/30"},{dot:"bg-amber-500",text:"text-amber-500",bg:"bg-amber-500/10",border:"border-amber-500/30"},{dot:"bg-orange-500",text:"text-orange-500",bg:"bg-orange-500/10",border:"border-orange-500/30"},{dot:"bg-green-500",text:"text-green-500",bg:"bg-green-500/10",border:"border-green-500/30"},{dot:"bg-pink-500",text:"text-pink-500",bg:"bg-pink-500/10",border:"border-pink-500/30"},{dot:"bg-cyan-500",text:"text-cyan-500",bg:"bg-cyan-500/10",border:"border-cyan-500/30"}];function fg(t){return El[t%El.length]}function bg(t){return t.charAt(0).toUpperCase()+t.slice(1)}const Ml=["planning","execution","review","qa","human"];function tn({label:t,children:s,className:n}){return e.jsxs("div",{className:z("space-y-2",n),children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:t}),s]})}function jg({companyId:t,selectedPr:s,onSelect:n}){const[r,a]=c.useState("antonioromero1220/gh-app"),[i,l]=c.useState(""),[o,u]=c.useState(!1),{data:d=[]}=Q({queryKey:["github-repos",t],queryFn:()=>bs.githubRepos(t),staleTime:6e4}),{data:m=[],isFetching:p}=Q({queryKey:["github-prs",t,r],queryFn:()=>bs.githubPrs(t,r),staleTime:3e4,enabled:!!r}),h=m.filter(x=>!i||x.title.toLowerCase().includes(i.toLowerCase())||String(x.number).includes(i));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:r,onChange:x=>{a(x.target.value),l(""),u(!0)},className:"flex-1 text-xs bg-background border border-border rounded-md px-2 py-1.5 outline-none text-foreground",children:[e.jsx("option",{value:"antonioromero1220/gh-app",children:"antonioromero1220/gh-app"}),e.jsx("option",{value:"antonioromero1220/growthub-core",children:"antonioromero1220/growthub-core"}),d.filter(x=>x.fullName!=="antonioromero1220/gh-app"&&x.fullName!=="antonioromero1220/growthub-core").slice(0,15).map(x=>e.jsx("option",{value:x.fullName,children:x.fullName},x.fullName))]}),e.jsxs("button",{type:"button",onClick:()=>u(x=>!x),className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md border border-border hover:bg-accent transition-colors",children:[e.jsx(Cr,{className:"h-3.5 w-3.5"}),p?e.jsx(Ft,{className:"h-3 w-3 animate-spin"}):"Browse PRs",e.jsx($s,{className:z("h-3 w-3 transition-transform",o&&"rotate-180")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-blue-500/30 bg-blue-500/5 px-3 py-2",children:[e.jsx(Cr,{className:"h-3.5 w-3.5 text-blue-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:s.title}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["#",s.number," · ",e.jsx(vo,{className:"inline h-2.5 w-2.5"})," ",s.branch]})]}),e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground",onClick:x=>x.stopPropagation(),children:e.jsx(In,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>n(null),className:"text-muted-foreground hover:text-foreground",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}),o&&e.jsxs("div",{className:"rounded-lg border border-border bg-card shadow-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[e.jsx(fs,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("input",{autoFocus:!0,value:i,onChange:x=>l(x.target.value),placeholder:"Search PRs…",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",onKeyDown:x=>x.key==="Escape"&&u(!1)}),p&&e.jsx(Ft,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"max-h-52 overflow-y-auto divide-y divide-border",children:h.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:p?"Loading…":"No open PRs found"}):h.map(x=>e.jsxs("button",{type:"button",onClick:()=>{n(x),u(!1),l("")},className:z("flex items-start gap-3 w-full px-3 py-2.5 text-left hover:bg-accent/50 transition-colors",(s==null?void 0:s.number)===x.number&&"bg-blue-500/5"),children:[e.jsx(Cr,{className:z("h-3.5 w-3.5 mt-0.5 shrink-0",x.draft?"text-muted-foreground":"text-green-500")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate leading-snug",children:x.title}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:["#",x.number," · ",x.branch," · ",x.user,x.draft&&" · Draft"]})]}),(s==null?void 0:s.number)===x.number&&e.jsx(Qt,{className:"h-3.5 w-3.5 text-blue-500 shrink-0 mt-0.5"})]},x.number))})]})]})}function Mc({open:t,onClose:s,companyId:n,onSuccess:r}){const a=_e(),i=c.useRef(null),[l,o]=c.useState(""),[u,d]=c.useState(""),[m,p]=c.useState(""),[h,x]=c.useState([...Ml]),[y,N]=c.useState(""),[b,g]=c.useState(!1),[T,k]=c.useState(""),[C,f]=c.useState(null);c.useEffect(()=>{t&&(o(""),d(""),p(""),x([...Ml]),k(""),f(null),N(""),g(!1),setTimeout(()=>{var w;return(w=i.current)==null?void 0:w.focus()},80))},[t]);const{data:j=[]}=Q({queryKey:P.agents.list(n),queryFn:()=>Te.list(n),enabled:t}),{mutate:v,isPending:U}=re({mutationFn:()=>bs.create(n,{title:l.trim(),description:u.trim()||void 0,stageOrder:h,instructions:m.trim()||void 0,leadAgentId:T||void 0,metadata:C?{linkedPr:{number:C.number,title:C.title,url:C.url,branch:C.branch,repo:C.repo}}:void 0}),onSuccess:w=>{a.invalidateQueries({queryKey:P.tickets.list(n)}),r==null||r(w.id),s()}});function A(){const w=y.trim().toLowerCase().replace(/\s+/g,"_");!w||h.includes(w)||(x(te=>[...te,w]),N(""),g(!1))}function B(w){h.length<=1||x(te=>te.filter(G=>G!==w))}const W={active:"bg-green-500",running:"bg-cyan-500",paused:"bg-amber-500",error:"bg-red-500"},S=j.find(w=>w.id===T);return e.jsx(js,{open:t,onOpenChange:w=>{w||s()},children:e.jsxs(vs,{showCloseButton:!0,className:"max-h-[90vh] overflow-y-auto p-0 gap-0",style:{width:"75vw",maxWidth:"75vw"},children:[e.jsxs(mn,{className:"px-6 pt-6 pb-4 border-b border-border",children:[e.jsxs(xn,{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Pr,{className:"h-4 w-4 text-primary"}),"New Ticket"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Define scope, bind a PR, assign agents, and configure the pipeline."})]}),e.jsxs("div",{className:"px-6 py-5 space-y-6",children:[e.jsx(tn,{label:"Title",children:e.jsx("input",{ref:i,value:l,onChange:w=>o(w.target.value),placeholder:"e.g. Winning Ads Image Mutation — GH MAX Mode",className:"w-full bg-background border border-border rounded-lg px-3 py-2.5 text-sm font-medium outline-none focus:border-primary/60 transition-colors placeholder:text-muted-foreground/50",onKeyDown:w=>w.key==="Enter"&&w.preventDefault()})}),e.jsx(tn,{label:"Scope & Description",children:e.jsx("textarea",{value:u,onChange:w=>d(w.target.value),rows:3,placeholder:"Describe what needs to be built, the problem being solved, and any constraints…",className:"w-full bg-background border border-border rounded-lg px-3 py-2.5 text-sm outline-none focus:border-primary/60 transition-colors resize-none placeholder:text-muted-foreground/50"})}),e.jsxs(tn,{label:"Linked GitHub PR",children:[e.jsx(jg,{companyId:n,selectedPr:C,onSelect:f}),!C&&e.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"Bind an open PR from your repos to give agents direct context on the active branch."})]}),e.jsx(tn,{label:"Pipeline Stages",children:e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[h.map((w,te)=>{const G=fg(te);return e.jsxs("span",{className:z("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full border text-xs font-medium",G.bg,G.border,G.text),children:[e.jsx("span",{className:z("h-1.5 w-1.5 rounded-full shrink-0",G.dot)}),bg(w),h.length>1&&e.jsx("button",{type:"button",onClick:()=>B(w),className:"opacity-60 hover:opacity-100 transition-opacity",children:e.jsx(nt,{className:"h-2.5 w-2.5"})})]},w)}),b?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:y,onChange:w=>N(w.target.value),placeholder:"stage",onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),A()),w.key==="Escape"&&g(!1)},className:"text-xs bg-background border border-border rounded-full px-2.5 py-1 outline-none w-24"}),e.jsx("button",{type:"button",onClick:A,className:"text-xs text-foreground/60 hover:text-foreground px-1",children:"+"}),e.jsx("button",{type:"button",onClick:()=>g(!1),children:e.jsx(nt,{className:"h-3 w-3 text-muted-foreground"})})]}):e.jsxs("button",{type:"button",onClick:()=>g(!0),className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full border border-dashed border-border text-xs text-muted-foreground hover:text-foreground hover:border-border/80 transition-colors",children:[e.jsx(Ae,{className:"h-3 w-3"})," Add stage"]})]})}),e.jsxs(tn,{label:"Lead Agent",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-48 overflow-y-auto",children:j.map(w=>e.jsxs("button",{type:"button",onClick:()=>k(te=>te===w.id?"":w.id),className:z("flex items-center gap-2.5 px-3 py-2.5 rounded-lg border text-left transition-all",T===w.id?"border-primary/60 bg-primary/5":"border-border hover:border-border/80 hover:bg-accent/40"),children:[e.jsx("span",{className:z("h-2 w-2 rounded-full shrink-0",W[w.status]??"bg-border")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:w.name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:w.role})]}),T===w.id&&e.jsx(Qt,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},w.id))}),j.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground/60",children:"No agents configured yet."})]}),e.jsx(tn,{label:"Agent Instructions",children:e.jsx("textarea",{value:m,onChange:w=>p(w.target.value),rows:3,placeholder:`Specific instructions for agents working this ticket…
|
|
196
|
+
e.g. "Follow the videoMutation pipeline pattern. Do not modify stable registry files. Use the brand kit ref images."`,className:"w-full bg-background border border-border rounded-lg px-3 py-2.5 text-sm outline-none focus:border-primary/60 transition-colors resize-none placeholder:text-muted-foreground/50 font-mono text-[13px]"})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-border flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground min-w-0",children:[C&&e.jsxs("span",{className:"flex items-center gap-1 text-blue-500",children:[e.jsx(Cr,{className:"h-3 w-3"})," PR #",C.number]}),S&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gt,{className:"h-3 w-3"})," ",S.name]}),e.jsxs("span",{className:"flex items-center gap-1",children:[h.length," stage",h.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{variant:"outline",size:"sm",onClick:s,disabled:U,children:"Cancel"}),e.jsx(F,{size:"sm",onClick:()=>v(),disabled:!l.trim()||U,className:"gap-1.5",children:U?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{className:"h-3.5 w-3.5"}),"Create Ticket"]})})]})]})]})})}function Dc(t){return Xr(t)}function ma(t,s){var r;const n=ui({stageDefinitions:t.stageDefinitions,stageOrder:t.stageOrder});return((r=mi(n,s))==null?void 0:r.label)??Dc(s)}function vg(t,s){const n=t.find(r=>r.stageOrder.includes(s)||r.currentStage===s);return n?ma(n,s):Dc(s)}function yg(t){const s=new Set,n=[];for(const r of t)for(const a of r.stageOrder)s.has(a)||(s.add(a),n.push(a));for(const r of t)s.has(r.currentStage)||(s.add(r.currentStage),n.push(r.currentStage));return n}function Ng({ticket:t}){const s=t.stageOrder.indexOf(t.currentStage),n=t.stageOrder.length>1?Math.round(s/(t.stageOrder.length-1)*100):0;return e.jsxs(he,{to:`/tickets/${t.id}`,className:"block rounded-lg border border-border bg-card p-3 hover:border-primary/30 hover:shadow-sm transition-all no-underline text-inherit group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsx("p",{className:"text-sm font-medium leading-snug line-clamp-2 flex-1",children:t.title}),e.jsx(zs,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:t.identifier}),e.jsx("span",{className:"text-[10px] text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0",children:ma(t,t.currentStage)})]}),t.stageOrder.length>1&&e.jsxs("div",{className:"flex items-center gap-0.5 mb-2",children:[t.stageOrder.map((r,a)=>e.jsxs("div",{className:"flex items-center gap-0.5",children:[a>0&&e.jsx("div",{className:z("h-px w-2",a<=s?"bg-primary/40":"bg-border")}),e.jsx("div",{className:z("h-1.5 w-1.5 rounded-full transition-colors",a<s&&"bg-primary/50",a===s&&"bg-primary",a>s&&"bg-border")})]},r)),e.jsxs("span",{className:"text-[10px] text-muted-foreground ml-1.5",children:[s+1,"/",t.stageOrder.length]})]}),t.stageOrder.length>1&&e.jsx("div",{className:"h-1 rounded-full bg-border overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary/40 transition-all",style:{width:`${n}%`}})})]})}function wg({tickets:t,stageOrder:s}){const n=c.useMemo(()=>{const r=new Map;for(const a of s)r.set(a,[]);for(const a of t){const i=r.get(a.currentStage)??[];i.push(a),r.set(a.currentStage,i)}return r},[t,s]);return s.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 border border-dashed border-border rounded-lg",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No active tickets. ",e.jsx(he,{to:"/tickets",className:"underline",children:"Create one"})]})}):e.jsx("div",{className:"overflow-x-auto pb-2",children:e.jsx("div",{className:"flex gap-3 min-w-max",children:s.map(r=>{const a=n.get(r)??[];return e.jsxs("div",{className:"w-64 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:vg(t,r)}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:a.length})]}),e.jsx("div",{className:"space-y-2",children:a.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-border p-3 text-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Empty"})}):a.map(i=>e.jsx(Ng,{ticket:i,stageOrder:s},i.id))})]},r)})})})}function kg({tickets:t,stageOrder:s}){if(t.length===0)return e.jsx("div",{className:"flex items-center justify-center h-24 border border-dashed border-border rounded-lg",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No active tickets. ",e.jsx(he,{to:"/tickets",className:"underline",children:"Create one"})]})});const n=[...t].sort((r,a)=>new Date(a.updatedAt).getTime()-new Date(r.updatedAt).getTime());return e.jsx("div",{className:"border border-border divide-y divide-border overflow-hidden rounded-lg",children:n.map(r=>{const a=r.stageOrder.indexOf(r.currentStage),i=r.stageOrder.length>1?a+1:1;return e.jsxs(he,{to:`/tickets/${r.id}`,className:"flex items-center gap-3 px-4 py-3 text-sm hover:bg-accent/50 transition-colors no-underline text-inherit",children:[e.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:r.stageOrder.map((l,o)=>e.jsxs("div",{className:"flex items-center gap-0.5",children:[o>0&&e.jsx("div",{className:z("h-px w-2",o<=a?"bg-primary/40":"bg-border")}),e.jsx("div",{className:z("h-1.5 w-1.5 rounded-full",o<a&&"bg-primary/50",o===a&&"bg-primary",o>a&&"bg-border")})]},l))}),e.jsx("span",{className:"flex-1 truncate font-medium",children:r.title}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[i,"/",r.stageOrder.length," stages"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0",children:ma(r,r.currentStage)}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:Ut(r.updatedAt)}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:r.identifier}),e.jsx(zs,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},r.id)})})}function Cg({tickets:t,stageOrder:s}){const[n,r]=c.useState("week"),a=new Date;function i(){const o=new Date(a);o.setDate(a.getDate()-a.getDay());const u=Array.from({length:7},(x,y)=>{const N=new Date(o);return N.setDate(o.getDate()+y),N}),d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m=x=>x.toISOString().slice(0,10),p=m(a),h=new Map;for(const x of u)h.set(m(x),[]);for(const x of t){const y=m(new Date(x.updatedAt));h.has(y)&&h.get(y).push(x)}return e.jsx("div",{className:"grid grid-cols-7 gap-1.5",children:u.map(x=>{const y=m(x),N=y===p,b=h.get(y)??[];return e.jsxs("div",{className:"min-h-[120px]",children:[e.jsxs("div",{className:z("text-center py-1.5 mb-2 rounded text-xs font-medium",N?"bg-primary/10 text-primary":"text-muted-foreground"),children:[e.jsx("div",{children:d[x.getDay()]}),e.jsx("div",{className:z("font-semibold tabular-nums",N&&"text-primary"),children:x.getDate()})]}),e.jsx("div",{className:"space-y-1",children:b.map(g=>e.jsxs(he,{to:`/tickets/${g.id}`,className:"block rounded border border-border bg-card px-2 py-1.5 hover:border-primary/30 transition-colors no-underline text-inherit",children:[e.jsx("p",{className:"text-[11px] font-medium truncate leading-snug",children:g.title}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:ma(g,g.currentStage)})]},g.id))})]},y)})})}function l(){var k;const o=a.getFullYear(),u=a.getMonth(),d=new Date(o,u,1),m=new Date(o,u+1,0),p=d.getDay(),h=m.getDate(),x=C=>C.toISOString().slice(0,10),y=x(a),N=["January","February","March","April","May","June","July","August","September","October","November","December"],b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g=new Map;for(let C=1;C<=h;C++)g.set(C,[]);for(const C of t){const f=new Date(C.updatedAt);f.getFullYear()===o&&f.getMonth()===u&&((k=g.get(f.getDate()))==null||k.push(C))}const T=[...Array(p).fill(null),...Array.from({length:h},(C,f)=>f+1)];for(;T.length%7!==0;)T.push(null);return e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-muted-foreground mb-3",children:[N[u]," ",o]}),e.jsxs("div",{className:"grid grid-cols-7 gap-px bg-border rounded-lg overflow-hidden border border-border",children:[b.map(C=>e.jsx("div",{className:"bg-background text-center text-[10px] font-medium text-muted-foreground py-1.5",children:C},C)),T.map((C,f)=>{if(!C)return e.jsx("div",{className:"bg-background h-20"},`pad-${f}`);const j=new Date(o,u,C),U=x(j)===y,A=g.get(C)??[];return e.jsxs("div",{className:z("bg-background h-20 p-1 overflow-hidden",U&&"bg-primary/5"),children:[e.jsx("span",{className:z("inline-flex h-5 w-5 items-center justify-center rounded-full text-[11px] font-medium mb-0.5",U?"bg-primary text-primary-foreground":"text-muted-foreground"),children:C}),e.jsxs("div",{className:"space-y-0.5",children:[A.slice(0,2).map(B=>e.jsx(he,{to:`/tickets/${B.id}`,className:"block rounded px-1 py-0.5 text-[10px] truncate font-medium no-underline border border-border bg-card text-foreground hover:border-primary/30 transition-colors",children:B.title},B.id)),A.length>2&&e.jsxs("span",{className:"text-[9px] text-muted-foreground pl-1",children:["+",A.length-2," more"]})]})]},C)})]})]})}return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-1 border border-border rounded-md overflow-hidden w-fit",children:["week","month"].map(o=>e.jsx("button",{onClick:()=>r(o),className:z("px-3 py-1.5 text-xs transition-colors capitalize",n===o?"bg-accent text-foreground font-medium":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),children:o},o))}),n==="week"?e.jsx(i,{}):e.jsx(l,{})]})}function Sg({companyId:t}){const[s,n]=c.useState("kanban"),[r,a]=c.useState(!1),{data:i,isLoading:l}=Q({queryKey:P.tickets.list(t),queryFn:()=>bs.list(t),refetchInterval:5e3,staleTime:0}),o=c.useMemo(()=>(i??[]).filter(m=>m.status==="active"),[i]),u=c.useMemo(()=>yg(o),[o]),d=[{id:"kanban",label:"Kanban",icon:Qm},{id:"list",label:"List",icon:Ni},{id:"roadmap",label:"Roadmap",icon:km}];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Tickets"}),i!==void 0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.length," active",i.length-o.length>0&&` · ${i.length-o.length} closed`]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex items-center border border-border rounded-md overflow-hidden",children:d.map(m=>{const p=m.icon;return e.jsxs("button",{onClick:()=>n(m.id),className:z("flex items-center gap-1.5 px-2.5 py-1.5 text-xs transition-colors",s===m.id?"bg-accent text-foreground font-medium":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),title:m.label,children:[e.jsx(p,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:m.label})]},m.id)})}),e.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex items-center gap-1 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-md hover:bg-accent/50 transition-colors",children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"New Ticket"})]})]})]}),l?e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[1,2,3].map(m=>e.jsx("div",{className:"h-32 rounded-lg bg-accent/30 animate-pulse"},m))}):e.jsxs(e.Fragment,{children:[s==="kanban"&&e.jsx(wg,{tickets:o,stageOrder:u}),s==="list"&&e.jsx(kg,{tickets:o,stageOrder:u}),s==="roadmap"&&e.jsx(Cg,{tickets:i??[],stageOrder:u})]}),e.jsx(Mc,{open:r,onClose:()=>a(!1),companyId:t})]})}function Ig(t){return[...t].sort((s,n)=>new Date(n.updatedAt).getTime()-new Date(s.updatedAt).getTime())}function Ag(){const{selectedCompanyId:t,companies:s}=fe(),{openOnboarding:n}=Ye(),{setBreadcrumbs:r}=Fe(),[a,i]=c.useState(new Set),l=c.useRef(new Set),o=c.useRef(!1),u=c.useRef([]),{data:d}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t});c.useEffect(()=>{r([{label:"Dashboard"}])},[r]);const{data:m}=Q({queryKey:P.dashboard(t),queryFn:()=>Oi.summary(t),enabled:!!t,retry:!1,staleTime:3e4}),{data:p}=Q({queryKey:P.activity(t),queryFn:()=>No.list(t),enabled:!!t}),{data:h}=Q({queryKey:P.issues.list(t),queryFn:()=>Ve.list(t),enabled:!!t}),{data:x}=Q({queryKey:P.projects.list(t),queryFn:()=>mt.list(t),enabled:!!t}),{data:y}=Q({queryKey:P.heartbeats(t),queryFn:()=>Tt.list(t),enabled:!!t}),N=h?Ig(h):[],b=c.useMemo(()=>(p??[]).slice(0,10),[p]);c.useEffect(()=>{for(const j of u.current)window.clearTimeout(j);u.current=[],l.current=new Set,o.current=!1,i(new Set)},[t]),c.useEffect(()=>{if(b.length===0)return;const j=l.current,v=b.map(B=>B.id);if(!o.current){for(const B of v)j.add(B);o.current=!0;return}const U=v.filter(B=>!j.has(B));if(U.length===0){for(const B of v)j.add(B);return}i(B=>{const W=new Set(B);for(const S of U)W.add(S);return W});for(const B of U)j.add(B);const A=window.setTimeout(()=>{i(B=>{const W=new Set(B);for(const S of U)W.delete(S);return W}),u.current=u.current.filter(B=>B!==A)},980);u.current.push(A)},[b]),c.useEffect(()=>()=>{for(const j of u.current)window.clearTimeout(j)},[]);const g=c.useMemo(()=>{const j=new Map;for(const v of d??[])j.set(v.id,v);return j},[d]),T=c.useMemo(()=>{const j=new Map;for(const v of h??[])j.set(`issue:${v.id}`,v.identifier??v.id.slice(0,8));for(const v of d??[])j.set(`agent:${v.id}`,v.name);for(const v of x??[])j.set(`project:${v.id}`,v.name);return j},[h,d,x]),k=c.useMemo(()=>{const j=new Map;for(const v of h??[])j.set(`issue:${v.id}`,v.title);return j},[h]),C=j=>{var v;return!j||!d?null:((v=d.find(U=>U.id===j))==null?void 0:v.name)??null};if(!t)return s.length===0?e.jsx(rt,{icon:Vs,message:"Welcome to Paperclip. Set up your first company and agent to get started.",action:"Get Started",onAction:n}):e.jsx(rt,{icon:Vs,message:"Create or select a company to view the dashboard."});const f=d!==void 0&&d.length===0;return e.jsxs("div",{className:"space-y-6",children:[f&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-4 py-3 dark:border-amber-500/25 dark:bg-amber-950/60",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Gt,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 shrink-0"}),e.jsx("p",{className:"text-sm text-amber-900 dark:text-amber-100",children:"You have no agents."})]}),e.jsx("button",{onClick:()=>n({initialStep:2,companyId:t}),className:"text-sm font-medium text-amber-700 hover:text-amber-900 dark:text-amber-300 dark:hover:text-amber-100 underline underline-offset-2 shrink-0",children:"Create one here"})]}),e.jsx(Sg,{companyId:t}),m&&e.jsxs(e.Fragment,{children:[m.budgets.activeIncidents>0?e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-xl border border-red-500/20 bg-[linear-gradient(180deg,rgba(255,80,80,0.12),rgba(255,255,255,0.02))] px-4 py-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(yo,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-300"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-red-50",children:[m.budgets.activeIncidents," active budget incident",m.budgets.activeIncidents===1?"":"s"]}),e.jsxs("p",{className:"text-xs text-red-100/70",children:[m.budgets.pausedAgents," agents paused · ",m.budgets.pausedProjects," projects paused · ",m.budgets.pendingApprovals," pending budget approvals"]})]})]}),e.jsx(he,{to:"/costs",className:"text-sm underline underline-offset-2 text-red-100",children:"Open budgets"})]}):null,e.jsxs("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-1 sm:gap-2",children:[e.jsx(Ms,{icon:Gt,value:m.agents.active+m.agents.running+m.agents.paused+m.agents.error,label:"Agents Enabled",to:"/agents",description:e.jsxs("span",{children:[m.agents.running," running",", ",m.agents.paused," paused",", ",m.agents.error," errors"]})}),e.jsx(Ms,{icon:Wt,value:m.tasks.inProgress,label:"Tasks In Progress",to:"/issues",description:e.jsxs("span",{children:[m.tasks.open," open",", ",m.tasks.blocked," blocked"]})}),e.jsx(Ms,{icon:ls,value:de(m.costs.monthSpendCents),label:"Month Spend",to:"/costs",description:e.jsx("span",{children:m.costs.monthBudgetCents>0?`${m.costs.monthUtilizationPercent}% of ${de(m.costs.monthBudgetCents)} budget`:"Unlimited budget"})}),e.jsx(Ms,{icon:wi,value:m.pendingApprovals+m.budgets.pendingApprovals,label:"Pending Approvals",to:"/approvals",description:e.jsx("span",{children:m.budgets.pendingApprovals>0?`${m.budgets.pendingApprovals} budget overrides awaiting board review`:"Awaiting board review"})})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(xr,{title:"Run Activity",subtitle:"Last 14 days",children:e.jsx(Fd,{runs:y??[]})}),e.jsx(xr,{title:"Issues by Priority",subtitle:"Last 14 days",children:e.jsx($d,{issues:h??[]})}),e.jsx(xr,{title:"Issues by Status",subtitle:"Last 14 days",children:e.jsx(Od,{issues:h??[]})}),e.jsx(xr,{title:"Success Rate",subtitle:"Last 14 days",children:e.jsx(Ld,{runs:y??[]})})]}),e.jsx(Ir,{slotTypes:["dashboardWidget"],context:{companyId:t},className:"grid gap-4 md:grid-cols-2",itemClassName:"rounded-lg border bg-card p-4 shadow-sm"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[b.length>0&&e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Recent Activity"}),e.jsx("div",{className:"border border-border divide-y divide-border overflow-hidden",children:b.map(j=>e.jsx(Ec,{event:j,agentMap:g,entityNameMap:T,entityTitleMap:k,className:a.has(j.id)?"activity-row-enter":void 0},j.id))})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:"Recent Tasks"}),N.length===0?e.jsx("div",{className:"border border-border p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No tasks yet."})}):e.jsx("div",{className:"border border-border divide-y divide-border overflow-hidden",children:N.slice(0,10).map(j=>e.jsx(he,{to:`/issues/${j.identifier??j.id}`,className:"px-4 py-3 text-sm cursor-pointer hover:bg-accent/50 transition-colors no-underline text-inherit block",children:e.jsxs("div",{className:"flex items-start gap-2 sm:items-center sm:gap-3",children:[e.jsx("span",{className:"shrink-0 sm:hidden",children:e.jsx(ft,{status:j.status})}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-1 sm:contents",children:[e.jsx("span",{className:"line-clamp-2 text-sm sm:order-2 sm:flex-1 sm:min-w-0 sm:line-clamp-none sm:truncate",children:j.title}),e.jsxs("span",{className:"flex items-center gap-2 sm:order-1 sm:shrink-0",children:[e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(At,{priority:j.priority})}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(ft,{status:j.status})}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:j.identifier??j.id.slice(0,8)}),j.assigneeAgentId&&(()=>{const v=C(j.assigneeAgentId);return v?e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(Ue,{name:v,size:"sm"})}):null})(),e.jsx("span",{className:"text-xs text-muted-foreground sm:hidden",children:"·"}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0 sm:order-last",children:Ut(j.updatedAt)})]})]})]})},j.id))})]})]})]})]})}function Pg(){const{companies:t,selectedCompanyId:s,setSelectedCompanyId:n,loading:r,error:a}=fe(),{openOnboarding:i}=Ye(),{setBreadcrumbs:l}=Fe(),o=_e(),{data:u}=Q({queryKey:P.companies.stats,queryFn:()=>Rs.stats()}),[d,m]=c.useState(null),[p,h]=c.useState(""),[x,y]=c.useState(null),N=re({mutationFn:({id:C,newName:f})=>Rs.update(C,{name:f}),onSuccess:()=>{o.invalidateQueries({queryKey:P.companies.all}),m(null)}}),b=re({mutationFn:C=>Rs.remove(C),onSuccess:()=>{o.invalidateQueries({queryKey:P.companies.all}),o.invalidateQueries({queryKey:P.companies.stats}),y(null)}});c.useEffect(()=>{l([{label:"Companies"}])},[l]);function g(C,f){m(C),h(f)}function T(){!d||!p.trim()||N.mutate({id:d,newName:p.trim()})}function k(){m(null),h("")}return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs(F,{size:"sm",onClick:()=>i(),children:[e.jsx(Ae,{className:"h-3.5 w-3.5 mr-1.5"}),"New Company"]})}),e.jsxs("div",{className:"h-6",children:[r&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading companies..."}),a&&e.jsx("p",{className:"text-sm text-destructive",children:a.message})]}),e.jsx("div",{className:"grid gap-4",children:t.map(C=>{const f=C.id===s,j=d===C.id,v=x===C.id,U=u==null?void 0:u[C.id],A=(U==null?void 0:U.agentCount)??0,B=(U==null?void 0:U.issueCount)??0,W=C.budgetMonthlyCents>0?Math.round(C.spentMonthlyCents/C.budgetMonthlyCents*100):0;return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>n(C.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),n(C.id))},className:`group text-left bg-card border rounded-lg p-5 transition-colors cursor-pointer ${f?"border-primary ring-1 ring-primary":"border-border hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[j?e.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[e.jsx(Vt,{value:p,onChange:S=>h(S.target.value),className:"h-7 text-sm",autoFocus:!0,onKeyDown:S=>{S.key==="Enter"&&T(),S.key==="Escape"&&k()}}),e.jsx(F,{variant:"ghost",size:"icon-xs",onClick:T,disabled:N.isPending,children:e.jsx(Qt,{className:"h-3.5 w-3.5 text-green-500"})}),e.jsx(F,{variant:"ghost",size:"icon-xs",onClick:k,children:e.jsx(nt,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-base",children:C.name}),e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${C.status==="active"?"bg-green-500/10 text-green-600 dark:text-green-400":C.status==="paused"?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-muted text-muted-foreground"}`,children:C.status}),e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground opacity-0 group-hover:opacity-100",onClick:S=>{S.stopPropagation(),g(C.id,C.name)},children:e.jsx(Qa,{className:"h-3 w-3"})})]}),C.description&&!j&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:C.description})]}),e.jsx("div",{onClick:S=>S.stopPropagation(),children:e.jsxs(Zr,{children:[e.jsx(ea,{asChild:!0,children:e.jsx(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100",children:e.jsx(xi,{className:"h-4 w-4"})})}),e.jsxs(ta,{align:"end",children:[e.jsxs(Ks,{onClick:()=>g(C.id,C.name),children:[e.jsx(Qa,{className:"h-3.5 w-3.5"}),"Rename"]}),e.jsx(wo,{}),e.jsxs(Ks,{variant:"destructive",onClick:()=>y(C.id),children:[e.jsx(Jt,{className:"h-3.5 w-3.5"}),"Delete Company"]})]})]})})]}),e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 mt-4 text-sm text-muted-foreground flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(go,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[A," ",A===1?"agent":"agents"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Wt,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[B," ",B===1?"issue":"issues"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 tabular-nums",children:[e.jsx(ls,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[de(C.spentMonthlyCents),C.budgetMonthlyCents>0?e.jsxs(e.Fragment,{children:[" / ",de(C.budgetMonthlyCents)," ",e.jsxs("span",{className:"text-xs",children:["(",W,"%)"]})]}):e.jsx("span",{className:"text-xs ml-1",children:"Unlimited budget"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[e.jsx(xo,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:["Created ",ar(C.createdAt)]})]})]}),v&&e.jsxs("div",{className:"mt-4 flex items-center justify-between bg-destructive/5 border border-destructive/20 rounded-md px-4 py-3",onClick:S=>S.stopPropagation(),children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:"Delete this company and all its data? This cannot be undone."}),e.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>y(null),disabled:b.isPending,children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:()=>b.mutate(C.id),disabled:b.isPending,children:b.isPending?"Deleting…":"Delete"})]})]})]},C.id)})})]})}const _c={claude_local:"Claude",codex_local:"Codex",gemini_local:"Gemini",opencode_local:"OpenCode",cursor:"Cursor",openclaw_gateway:"OpenClaw Gateway",process:"Process",http:"HTTP"},Fc=Bd;function $c(t,s,n){return t==="terminated"?n:s==="all"?!0:s==="active"?t==="active"||t==="running"||t==="idle":s==="paused"?t==="paused":s==="error"?t==="error":!0}function Tg(t,s,n){return t.filter(r=>$c(r.status,s,n))}function Oc(t,s,n){return t.reduce((r,a)=>{const i=Oc(a.reports,s,n);return($c(a.status,s,n)||i.length>0)&&r.push({...a,reports:i}),r},[])}function br(){const{selectedCompanyId:t}=fe(),{openNewAgent:s}=Ye(),{setBreadcrumbs:n}=Fe(),r=Rt(),a=wt(),{isMobile:i}=Cn(),l=a.pathname.split("/").pop()??"all",o=l==="all"||l==="active"||l==="paused"||l==="error"?l:"all",[u,d]=c.useState("org"),m=i,p=m?"list":u,[h,x]=c.useState(!1),[y,N]=c.useState(!1),{data:b,isLoading:g,error:T}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t}),{data:k}=Q({queryKey:P.org(t),queryFn:()=>Te.org(t),enabled:!!t&&p==="org"}),{data:C}=Q({queryKey:P.heartbeats(t),queryFn:()=>Tt.list(t),enabled:!!t,refetchInterval:15e3}),f=c.useMemo(()=>{const A=new Map;for(const B of C??[]){if(B.status!=="running"&&B.status!=="queued")continue;const W=A.get(B.agentId);if(W){W.liveCount+=1;continue}A.set(B.agentId,{runId:B.id,liveCount:1})}return A},[C]),j=c.useMemo(()=>{const A=new Map;for(const B of b??[])A.set(B.id,B);return A},[b]);if(c.useEffect(()=>{n([{label:"Agents"}])},[n]),!t)return e.jsx(rt,{icon:Gt,message:"Select a company to view agents."});if(g)return e.jsx(ot,{variant:"list"});const v=Tg(b??[],o,h),U=Oc(k??[],o,h);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(Yt,{value:o,onValueChange:A=>r(`/agents/${A}`),children:e.jsx(Gs,{items:[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"}],value:o,onValueChange:A=>r(`/agents/${A}`)})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("button",{className:z("flex items-center gap-1.5 px-2 py-1.5 text-xs transition-colors border border-border",y||h?"text-foreground bg-accent":"text-muted-foreground hover:bg-accent/50"),onClick:()=>N(!y),children:[e.jsx(qd,{className:"h-3 w-3"}),"Filters",h&&e.jsx("span",{className:"ml-0.5 px-1 bg-foreground/10 rounded text-[10px]",children:"1"})]}),y&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 w-48 border border-border bg-popover shadow-md p-1",children:e.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-xs text-left hover:bg-accent/50 transition-colors",onClick:()=>x(!h),children:[e.jsx("span",{className:z("flex items-center justify-center h-3.5 w-3.5 border border-border rounded-sm",h&&"bg-foreground"),children:h&&e.jsx("span",{className:"text-background text-[10px] leading-none",children:"✓"})}),"Show terminated"]})})]}),!m&&e.jsxs("div",{className:"flex items-center border border-border",children:[e.jsx("button",{className:z("p-1.5 transition-colors",p==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:()=>d("list"),children:e.jsx(Ni,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:z("p-1.5 transition-colors",p==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:()=>d("org"),children:e.jsx(vo,{className:"h-3.5 w-3.5"})})]}),e.jsxs(F,{size:"sm",variant:"outline",onClick:s,children:[e.jsx(Ae,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),v.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[v.length," agent",v.length!==1?"s":""]}),T&&e.jsx("p",{className:"text-sm text-destructive",children:T.message}),b&&b.length===0&&e.jsx(rt,{icon:Gt,message:"Create your first agent to get started.",action:"New Agent",onAction:s}),p==="list"&&v.length>0&&e.jsx("div",{className:"border border-border",children:v.map(A=>e.jsx(gs,{title:A.name,subtitle:`${Fc[A.role]??A.role}${A.title?` - ${A.title}`:""}`,to:Sn(A),leading:e.jsx("span",{className:"relative flex h-2.5 w-2.5",children:e.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full ${pi[A.status]??hi}`})}),trailing:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"sm:hidden",children:f.has(A.id)?e.jsx(Br,{agentRef:Qn(A),runId:f.get(A.id).runId,liveCount:f.get(A.id).liveCount}):e.jsx(Pe,{status:A.status})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-3",children:[f.has(A.id)&&e.jsx(Br,{agentRef:Qn(A),runId:f.get(A.id).runId,liveCount:f.get(A.id).liveCount}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono w-14 text-right",children:_c[A.adapterType]??A.adapterType}),e.jsx("span",{className:"text-xs text-muted-foreground w-16 text-right",children:A.lastHeartbeatAt?ar(A.lastHeartbeatAt):"—"}),e.jsx("span",{className:"w-20 flex justify-end",children:e.jsx(Pe,{status:A.status})})]})]})},A.id))}),p==="list"&&b&&b.length>0&&v.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected filter."}),p==="org"&&U.length>0&&e.jsx("div",{className:"border border-border py-1",children:U.map(A=>e.jsx(Lc,{node:A,depth:0,agentMap:j,liveRunByAgent:f},A.id))}),p==="org"&&k&&k.length>0&&U.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected filter."}),p==="org"&&k&&k.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."})]})}function Lc({node:t,depth:s,agentMap:n,liveRunByAgent:r}){const a=n.get(t.id),i=pi[t.status]??hi;return e.jsxs("div",{style:{paddingLeft:s*24},children:[e.jsxs(he,{to:a?Sn(a):`/agents/${t.id}`,className:"flex items-center gap-3 px-3 py-2 hover:bg-accent/30 transition-colors w-full text-left no-underline text-inherit",children:[e.jsx("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:e.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full ${i}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm font-medium",children:t.name}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:[Fc[t.role]??t.role,a!=null&&a.title?` - ${a.title}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("span",{className:"sm:hidden",children:r.has(t.id)?e.jsx(Br,{agentRef:a?Qn(a):t.id,runId:r.get(t.id).runId,liveCount:r.get(t.id).liveCount}):e.jsx(Pe,{status:t.status})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-3",children:[r.has(t.id)&&e.jsx(Br,{agentRef:a?Qn(a):t.id,runId:r.get(t.id).runId,liveCount:r.get(t.id).liveCount}),a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono w-14 text-right",children:_c[a.adapterType]??a.adapterType}),e.jsx("span",{className:"text-xs text-muted-foreground w-16 text-right",children:a.lastHeartbeatAt?ar(a.lastHeartbeatAt):"—"})]}),e.jsx("span",{className:"w-20 flex justify-end",children:e.jsx(Pe,{status:t.status})})]})]})]}),t.reports&&t.reports.length>0&&e.jsx("div",{className:"border-l border-border/50 ml-4",children:t.reports.map(l=>e.jsx(Lc,{node:l,depth:s+1,agentMap:n,liveRunByAgent:r},l.id))})]})}function Br({agentRef:t,runId:s,liveCount:n}){return e.jsxs(he,{to:`/agents/${t}/runs/${s}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:r=>r.stopPropagation(),children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),e.jsxs("span",{className:"text-[11px] font-medium text-blue-600 dark:text-blue-400",children:["Live",n>1?` (${n})`:""]})]})}function Rg(){const{selectedCompanyId:t}=fe(),{openNewProject:s}=Ye(),{setBreadcrumbs:n}=Fe();c.useEffect(()=>{n([{label:"Projects"}])},[n]);const{data:r,isLoading:a,error:i}=Q({queryKey:P.projects.list(t),queryFn:()=>mt.list(t),enabled:!!t}),l=c.useMemo(()=>(r??[]).filter(o=>!o.archivedAt),[r]);return t?a?e.jsx(ot,{variant:"list"}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs(F,{size:"sm",variant:"outline",onClick:s,children:[e.jsx(Ae,{className:"h-4 w-4 mr-1"}),"Add Project"]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i.message}),!a&&l.length===0&&e.jsx(rt,{icon:vn,message:"No projects yet.",action:"Add Project",onAction:s}),l.length>0&&e.jsx("div",{className:"border border-border",children:l.map(o=>e.jsx(gs,{title:o.name,subtitle:o.description??void 0,to:li(o),trailing:e.jsxs("div",{className:"flex items-center gap-3",children:[o.targetDate&&e.jsx("span",{className:"text-xs text-muted-foreground",children:Us(o.targetDate)}),e.jsx(Pe,{status:o.status})]})},o.id))})]}):e.jsx(rt,{icon:vn,message:"Select a company to view projects."})}const Eg=[{value:"backlog",label:"Backlog"},{value:"planned",label:"Planned"},{value:"in_progress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"cancelled",label:"Cancelled"}];function Ps({state:t}){return t==="saving"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[e.jsx(Ft,{className:"h-3 w-3 animate-spin"}),"Saving"]}):t==="saved"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-green-600 dark:text-green-400",children:[e.jsx(Qt,{className:"h-3 w-3"}),"Saved"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-destructive",children:[e.jsx(Ud,{className:"h-3 w-3"}),"Failed"]}):null}function qs({label:t,state:s}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e.jsx(Ps,{state:s})]})}function As({label:t,children:s,alignStart:n=!1,valueClassName:r=""}){return e.jsxs("div",{className:z("flex gap-3 py-1.5",n?"items-start":"items-center"),children:[e.jsx("div",{className:"shrink-0 w-20",children:t}),e.jsx("div",{className:z("min-w-0 flex-1",n?"pt-0.5":"flex items-center gap-1.5",r),children:s})]})}function Mg({status:t,onChange:s}){const[n,r]=c.useState(!1),a=zd[t]??Kd;return e.jsxs(vt,{open:n,onOpenChange:r,children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{className:z("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0 cursor-pointer hover:opacity-80 transition-opacity",a),children:t.replace("_"," ")})}),e.jsx(Nt,{className:"w-40 p-1",align:"start",children:Eg.map(i=>e.jsx(F,{variant:"ghost",size:"sm",className:z("w-full justify-start gap-2 text-xs",i.value===t&&"bg-accent"),onClick:()=>{s(i.value),r(!1)},children:i.label},i.value))})]})}function Dg({project:t,onArchive:s,archivePending:n}){const[r,a]=c.useState(!1),i=!t.archivedAt,l=i?"Archive":"Unarchive";return e.jsxs("div",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 px-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"Archive this project to hide it from the sidebar and project selectors.":"Unarchive this project to restore it in the sidebar and project selectors."}),n?e.jsxs(F,{size:"sm",variant:"destructive",disabled:!0,children:[e.jsx(Ft,{className:"h-3 w-3 animate-spin mr-1"}),i?"Archiving...":"Unarchiving..."]}):r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-destructive font-medium",children:[l," “",t.name,"”?"]}),e.jsx(F,{size:"sm",variant:"destructive",onClick:()=>{a(!1),s(i)},children:"Confirm"}),e.jsx(F,{size:"sm",variant:"outline",onClick:()=>a(!1),children:"Cancel"})]}):e.jsx(F,{size:"sm",variant:"destructive",onClick:()=>a(!0),children:i?e.jsxs(e.Fragment,{children:[e.jsx(hm,{className:"h-3 w-3 mr-1"}),l," project"]}):e.jsxs(e.Fragment,{children:[e.jsx(xm,{className:"h-3 w-3 mr-1"}),l," project"]})})]})}function _g({project:t,onUpdate:s,onFieldUpdate:n,getFieldSaveState:r,onArchive:a,archivePending:i}){var Ct;const{selectedCompanyId:l}=fe(),o=_e(),[u,d]=c.useState(!1),[m,p]=c.useState(!1),[h,x]=c.useState(null),[y,N]=c.useState(""),[b,g]=c.useState(""),[T,k]=c.useState(null),C=(V,pe)=>{if(n){n(V,pe);return}s==null||s(pe)},f=V=>(r==null?void 0:r(V))??"idle",{data:j}=Q({queryKey:P.goals.list(l),queryFn:()=>_t.list(l),enabled:!!l}),{data:v}=Q({queryKey:P.instance.experimentalSettings,queryFn:()=>$a.getExperimental()}),U=t.goalIds.length>0?t.goalIds:t.goalId?[t.goalId]:[],A=t.goals.length>0?t.goals:U.map(V=>{var pe;return{id:V,title:((pe=j==null?void 0:j.find(ye=>ye.id===V))==null?void 0:pe.title)??V.slice(0,8)}}),B=(j??[]).filter(V=>!U.includes(V.id)),W=t.workspaces??[],S=t.codebase,w=t.primaryWorkspace??null,te=W.some(V=>V.id!==(w==null?void 0:w.id)),G=t.executionWorkspacePolicy??null,K=(G==null?void 0:G.enabled)===!0,M=(v==null?void 0:v.enableIsolatedWorkspaces)===!0,ee=(G==null?void 0:G.defaultMode)==="isolated_workspace"?"isolated_workspace":"shared_workspace",L=(G==null?void 0:G.workspaceStrategy)??{type:"git_worktree",baseRef:"",branchTemplate:"",worktreeParentDir:""},ae=()=>{o.invalidateQueries({queryKey:P.projects.detail(t.id)}),t.urlKey!==t.id&&o.invalidateQueries({queryKey:P.projects.detail(t.urlKey)}),l&&o.invalidateQueries({queryKey:P.projects.list(l)})},oe=re({mutationFn:V=>mt.createWorkspace(t.id,V),onSuccess:()=>{N(""),g(""),x(null),k(null),ae()}}),q=re({mutationFn:V=>mt.removeWorkspace(t.id,V),onSuccess:()=>{N(""),g(""),x(null),k(null),ae()}}),H=re({mutationFn:({workspaceId:V,data:pe})=>mt.updateWorkspace(t.id,V,pe),onSuccess:()=>{N(""),g(""),x(null),k(null),ae()}}),I=V=>{!s&&!n||C("goals",{goalIds:U.filter(pe=>pe!==V)})},R=V=>{!s&&!n||U.includes(V)||(C("goals",{goalIds:[...U,V]}),d(!1))},D=V=>{if(!(!s&&!n))return{executionWorkspacePolicy:{enabled:K,defaultMode:ee,allowIssueOverride:(G==null?void 0:G.allowIssueOverride)??!0,...G,...V}}},Z=V=>V.startsWith("/")||/^[A-Za-z]:[\\/]/.test(V),me=V=>{try{const pe=new URL(V),ye=pe.hostname.toLowerCase();return ye!=="github.com"&&ye!=="www.github.com"?!1:pe.pathname.split("/").filter(Boolean).length>=2}catch{return!1}},xe=V=>{if(!V)return!1;try{const pe=new URL(V);return pe.protocol==="http:"||pe.protocol==="https:"}catch{return!1}},$=V=>{var pe;try{const ye=new URL(V),Ee=ye.pathname.split("/").filter(Boolean);if(Ee.length<2)return ye.host;const Be=Ee[0],Ot=(pe=Ee[1])==null?void 0:pe.replace(/\.git$/i,"");return!Be||!Ot?ye.host:`${ye.host}/${Be}/${Ot}`}catch{return V}},ce=(V,pe)=>{if(pe)return"git_repo";if(V)return"local_path"},ue=V=>{const pe=V.cwd!==void 0?V.cwd:S.localFolder,ye=V.repoUrl!==void 0?V.repoUrl:S.repoUrl;if(!pe&&!ye){w&&q.mutate(w.id);return}const Ee={...V.cwd!==void 0?{cwd:V.cwd}:{},...V.repoUrl!==void 0?{repoUrl:V.repoUrl}:{},...ce(pe,ye)?{sourceType:ce(pe,ye)}:{},isPrimary:!0};if(w){H.mutate({workspaceId:w.id,data:Ee});return}oe.mutate(Ee)},Re=()=>{const V=y.trim();if(!V){k(null),ue({cwd:null});return}if(!Z(V)){k("Local folder must be a full absolute path.");return}k(null),ue({cwd:V})},De=()=>{const V=b.trim();if(!V){k(null),ue({repoUrl:null});return}if(!me(V)){k("Repo must use a valid GitHub repo URL.");return}k(null),ue({repoUrl:V})},We=()=>{window.confirm(S.repoUrl?"Clear local folder from this workspace?":"Delete this workspace local folder?")&&ue({cwd:null})},xt=()=>{const V=!!S.localFolder;if(window.confirm(V?"Clear repo from this workspace?":"Delete this workspace repo?")){if(w&&V){H.mutate({workspaceId:w.id,data:{repoUrl:null,repoRef:null,defaultRef:null,sourceType:ce(S.localFolder,null)}});return}ue({repoUrl:null})}};return e.jsxs("div",{children:[e.jsxs("div",{className:"space-y-1 pb-4",children:[e.jsx(As,{label:e.jsx(qs,{label:"Name",state:f("name")}),children:s||n?e.jsx(Zs,{value:t.name,onCommit:V=>C("name",{name:V}),immediate:!0,className:"w-full rounded border border-border bg-transparent px-2 py-1 text-sm outline-none",placeholder:"Project name"}):e.jsx("span",{className:"text-sm",children:t.name})}),e.jsx(As,{label:e.jsx(qs,{label:"Description",state:f("description")}),alignStart:!0,valueClassName:"space-y-0.5",children:s||n?e.jsx(Ds,{value:t.description??"",onSave:V=>C("description",{description:V}),as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0}):e.jsx("p",{className:"text-sm text-muted-foreground",children:((Ct=t.description)==null?void 0:Ct.trim())||"No description"})}),e.jsx(As,{label:e.jsx(qs,{label:"Status",state:f("status")}),children:s||n?e.jsx(Mg,{status:t.status,onChange:V=>C("status",{status:V})}):e.jsx(Pe,{status:t.status})}),t.leadAgentId&&e.jsx(As,{label:"Lead",children:e.jsx("span",{className:"text-sm font-mono",children:t.leadAgentId.slice(0,8)})}),e.jsxs(As,{label:e.jsx(qs,{label:"Goals",state:f("goals")}),alignStart:!0,valueClassName:"space-y-2",children:[A.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(V=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs",children:[e.jsx(he,{to:`/goals/${V.id}`,className:"hover:underline max-w-[220px] truncate",children:V.title}),(s||n)&&e.jsx("button",{className:"text-muted-foreground hover:text-foreground",type:"button",onClick:()=>I(V.id),"aria-label":`Remove goal ${V.title}`,children:e.jsx(nt,{className:"h-3 w-3"})})]},V.id))}),(s||n)&&e.jsxs(vt,{open:u,onOpenChange:d,children:[e.jsx(yt,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"xs",className:z("h-6 w-fit px-2",A.length>0&&"ml-1"),disabled:B.length===0,children:[e.jsx(Ae,{className:"h-3 w-3 mr-1"}),"Goal"]})}),e.jsx(Nt,{className:"w-56 p-1",align:"start",children:B.length===0?e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All goals linked."}):B.map(V=>e.jsx("button",{className:"flex items-center w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",onClick:()=>R(V.id),children:V.title},V.id))})]})]}),e.jsx(As,{label:e.jsx(qs,{label:"Created",state:"idle"}),children:e.jsx("span",{className:"text-sm",children:Us(t.createdAt)})}),e.jsx(As,{label:e.jsx(qs,{label:"Updated",state:"idle"}),children:e.jsx("span",{className:"text-sm",children:Us(t.updatedAt)})}),t.targetDate&&e.jsx(As,{label:e.jsx(qs,{label:"Target Date",state:"idle"}),children:e.jsx("span",{className:"text-sm",children:Us(t.targetDate)})})]}),e.jsx($t,{className:"my-4"}),e.jsxs("div",{className:"space-y-1 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Codebase"}),e.jsxs(cs,{children:[e.jsx(ds,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-4 w-4 items-center justify-center rounded-full border border-border text-[10px] text-muted-foreground hover:text-foreground","aria-label":"Codebase help",children:"?"})}),e.jsx(us,{side:"top",children:"Repo identifies the source of truth. Local folder is the default place agents write code."})]})]}),e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 p-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Repo"}),S.repoUrl?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[xe(S.repoUrl)?e.jsxs("a",{href:S.repoUrl,target:"_blank",rel:"noreferrer",className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground hover:underline",children:[e.jsx(al,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:$(S.repoUrl)}),e.jsx(In,{className:"h-3 w-3 shrink-0"})]}):e.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(al,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:S.repoUrl})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{variant:"outline",size:"xs",className:"h-6 px-2",onClick:()=>{x("repo"),g(S.repoUrl??""),k(null)},children:"Change repo"}),e.jsx(F,{variant:"ghost",size:"icon-xs",onClick:xt,"aria-label":"Clear repo",children:e.jsx(Jt,{className:"h-3 w-3"})})]})]}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Not set."}),e.jsx(F,{variant:"outline",size:"xs",className:"h-6 px-2",onClick:()=>{x("repo"),g(S.repoUrl??""),k(null)},children:"Set repo"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Local folder"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",children:S.effectiveLocalFolder}),S.origin==="managed_checkout"&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Paperclip-managed folder."})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{variant:"outline",size:"xs",className:"h-6 px-2",onClick:()=>{x("local"),N(S.localFolder??""),k(null)},children:S.localFolder?"Change local folder":"Set local folder"}),S.localFolder?e.jsx(F,{variant:"ghost",size:"icon-xs",onClick:We,"aria-label":"Clear local folder",children:e.jsx(Jt,{className:"h-3 w-3"})}):null]})]})]}),te&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Additional legacy workspace records exist on this project. Paperclip is using the primary workspace as the codebase view."}),w!=null&&w.runtimeServices&&w.runtimeServices.length>0?e.jsx("div",{className:"space-y-1",children:w.runtimeServices.map(V=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border/60 px-2 py-1",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium",children:V.serviceName}),e.jsx("span",{className:z("rounded-full px-1.5 py-0.5 text-[10px] uppercase tracking-wide",V.status==="running"?"bg-green-500/15 text-green-700 dark:text-green-300":V.status==="failed"?"bg-red-500/15 text-red-700 dark:text-red-300":"bg-muted text-muted-foreground"),children:V.status})]}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:V.url?e.jsx("a",{href:V.url,target:"_blank",rel:"noreferrer",className:"hover:text-foreground hover:underline",children:V.url}):V.command??"No URL"})]}),e.jsx("div",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:V.lifecycle})]},V.id))}):null]}),h==="local"&&e.jsxs("div",{className:"space-y-1.5 rounded-md border border-border p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",value:y,onChange:V=>N(V.target.value),placeholder:"/absolute/path/to/workspace"}),e.jsx(mo,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{variant:"outline",size:"xs",className:"h-6 px-2",disabled:!y.trim()&&!w||oe.isPending||H.isPending,onClick:Re,children:"Save"}),e.jsx(F,{variant:"ghost",size:"xs",className:"h-6 px-2",onClick:()=>{x(null),N(""),k(null)},children:"Cancel"})]})]}),h==="repo"&&e.jsxs("div",{className:"space-y-1.5 rounded-md border border-border p-2",children:[e.jsx("input",{className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs outline-none",value:b,onChange:V=>g(V.target.value),placeholder:"https://github.com/org/repo"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{variant:"outline",size:"xs",className:"h-6 px-2",disabled:!b.trim()&&!w||oe.isPending||H.isPending,onClick:De,children:"Save"}),e.jsx(F,{variant:"ghost",size:"xs",className:"h-6 px-2",onClick:()=>{x(null),g(""),k(null)},children:"Cancel"})]})]}),T&&e.jsx("p",{className:"text-xs text-destructive",children:T}),oe.isError&&e.jsx("p",{className:"text-xs text-destructive",children:"Failed to save workspace."}),q.isError&&e.jsx("p",{className:"text-xs text-destructive",children:"Failed to delete workspace."}),H.isError&&e.jsx("p",{className:"text-xs text-destructive",children:"Failed to update workspace."})]}),M?e.jsxs(e.Fragment,{children:[e.jsx($t,{className:"my-4"}),e.jsxs("div",{className:"py-1.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Execution Workspaces"}),e.jsxs(cs,{children:[e.jsx(ds,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex h-4 w-4 items-center justify-center rounded-full border border-border text-[10px] text-muted-foreground hover:text-foreground","aria-label":"Execution workspaces help",children:"?"})}),e.jsx(us,{side:"top",children:"Project-owned defaults for isolated issue checkouts and execution workspace behavior."})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx("span",{children:"Enable isolated issue checkouts"}),e.jsx(Ps,{state:f("execution_workspace_enabled")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Let issues choose between the project's primary checkout and an isolated execution workspace."})]}),s||n?e.jsx("button",{className:z("relative inline-flex h-5 w-9 items-center rounded-full transition-colors",K?"bg-green-600":"bg-muted"),type:"button",onClick:()=>C("execution_workspace_enabled",D({enabled:!K})),children:e.jsx("span",{className:z("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",K?"translate-x-4.5":"translate-x-0.5")})}):e.jsx("span",{className:"text-xs text-muted-foreground",children:K?"Enabled":"Disabled"})]}),K?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{children:"New issues default to isolated checkout"}),e.jsx(Ps,{state:f("execution_workspace_default_mode")})]}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"If disabled, new issues stay on the project's primary checkout unless someone opts in."})]}),e.jsx("button",{className:z("relative inline-flex h-5 w-9 items-center rounded-full transition-colors",ee==="isolated_workspace"?"bg-green-600":"bg-muted"),type:"button",onClick:()=>C("execution_workspace_default_mode",D({defaultMode:ee==="isolated_workspace"?"shared_workspace":"isolated_workspace"})),children:e.jsx("span",{className:z("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",ee==="isolated_workspace"?"translate-x-4.5":"translate-x-0.5")})})]}),e.jsx("div",{className:"border-t border-border/60 pt-2",children:e.jsx("button",{type:"button",className:"flex w-full items-center gap-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",onClick:()=>p(V=>!V),children:m?"Hide advanced checkout settings":"Show advanced checkout settings"})}),m?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Host-managed implementation: ",e.jsx("span",{className:"text-foreground",children:"Git worktree"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 flex items-center gap-1.5",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Base ref"}),e.jsx(Ps,{state:f("execution_workspace_base_ref")})]})}),e.jsx(Zs,{value:L.baseRef??"",onCommit:V=>C("execution_workspace_base_ref",{...D({workspaceStrategy:{...L,type:"git_worktree",baseRef:V||null}})}),immediate:!0,className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",placeholder:"origin/main"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 flex items-center gap-1.5",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Branch template"}),e.jsx(Ps,{state:f("execution_workspace_branch_template")})]})}),e.jsx(Zs,{value:L.branchTemplate??"",onCommit:V=>C("execution_workspace_branch_template",{...D({workspaceStrategy:{...L,type:"git_worktree",branchTemplate:V||null}})}),immediate:!0,className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",placeholder:"{{issue.identifier}}-{{slug}}"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 flex items-center gap-1.5",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Worktree parent dir"}),e.jsx(Ps,{state:f("execution_workspace_worktree_parent_dir")})]})}),e.jsx(Zs,{value:L.worktreeParentDir??"",onCommit:V=>C("execution_workspace_worktree_parent_dir",{...D({workspaceStrategy:{...L,type:"git_worktree",worktreeParentDir:V||null}})}),immediate:!0,className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",placeholder:".paperclip/worktrees"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 flex items-center gap-1.5",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Provision command"}),e.jsx(Ps,{state:f("execution_workspace_provision_command")})]})}),e.jsx(Zs,{value:L.provisionCommand??"",onCommit:V=>C("execution_workspace_provision_command",{...D({workspaceStrategy:{...L,type:"git_worktree",provisionCommand:V||null}})}),immediate:!0,className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",placeholder:"bash ./scripts/provision-worktree.sh"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 flex items-center gap-1.5",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Teardown command"}),e.jsx(Ps,{state:f("execution_workspace_teardown_command")})]})}),e.jsx(Zs,{value:L.teardownCommand??"",onCommit:V=>C("execution_workspace_teardown_command",{...D({workspaceStrategy:{...L,type:"git_worktree",teardownCommand:V||null}})}),immediate:!0,className:"w-full rounded border border-border bg-transparent px-2 py-1 text-xs font-mono outline-none",placeholder:"bash ./scripts/teardown-worktree.sh"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Provision runs inside the derived worktree before agent execution. Teardown is stored here for future cleanup flows."})]}):null]}):null]})]})]}):null]}),a&&e.jsxs(e.Fragment,{children:[e.jsx($t,{className:"my-4"}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"text-xs font-medium text-destructive uppercase tracking-wide",children:"Danger Zone"}),e.jsx(Dg,{project:t,onArchive:a,archivePending:i})]})]})]})}function Aa(t,s){const n={};for(const r of t){const a=s(r);n[a]||(n[a]=[]),n[a].push(r)}return n}const Pa=["backlog","todo","in_progress","in_review","blocked","done","cancelled"];function Fg(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function $g({status:t,issues:s,agents:n,liveIssueIds:r}){const{setNodeRef:a,isOver:i}=sc({id:t});return e.jsxs("div",{className:"flex flex-col min-w-[260px] w-[260px] shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-2 mb-1",children:[e.jsx(ft,{status:t}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:Fg(t)}),e.jsx("span",{className:"text-xs text-muted-foreground/60 ml-auto tabular-nums",children:s.length})]}),e.jsx("div",{ref:a,className:`flex-1 min-h-[120px] rounded-md p-1 space-y-1 transition-colors ${i?"bg-accent/40":"bg-muted/20"}`,children:e.jsx(_i,{items:s.map(l=>l.id),strategy:Di,children:s.map(l=>e.jsx(qc,{issue:l,agents:n,isLive:r==null?void 0:r.has(l.id)},l.id))})})]})}function qc({issue:t,agents:s,isLive:n,isOverlay:r}){const{attributes:a,listeners:i,setNodeRef:l,transform:o,transition:u,isDragging:d}=Fi({id:t.id,data:{issue:t}}),m={transform:ms.Transform.toString(o),transition:u},p=h=>{var x;return!h||!s?null:((x=s.find(y=>y.id===h))==null?void 0:x.name)??null};return e.jsx("div",{ref:l,style:m,...a,...i,className:`rounded-md border bg-card p-2.5 cursor-grab active:cursor-grabbing transition-shadow ${d&&!r?"opacity-30":""} ${r?"shadow-lg ring-1 ring-primary/20":"hover:shadow-sm"}`,children:e.jsxs(he,{to:`/issues/${t.identifier??t.id}`,className:"block no-underline text-inherit",onClick:h=>{d&&h.preventDefault()},children:[e.jsxs("div",{className:"flex items-start gap-1.5 mb-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono shrink-0",children:t.identifier??t.id.slice(0,8)}),n&&e.jsxs("span",{className:"relative flex h-2 w-2 shrink-0 mt-0.5",children:[e.jsx("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]})]}),e.jsx("p",{className:"text-sm leading-snug line-clamp-2 mb-2",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{priority:t.priority}),t.assigneeAgentId&&(()=>{const h=p(t.assigneeAgentId);return h?e.jsx(Ue,{name:h,size:"xs"}):e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:t.assigneeAgentId.slice(0,8)})})()]})]})})}function Og({issues:t,agents:s,liveIssueIds:n,onUpdateIssue:r}){const[a,i]=c.useState(null),l=Ai(Ii(cr,{activationConstraint:{distance:5}})),o=c.useMemo(()=>{const h={};for(const x of Pa)h[x]=[];for(const x of t)h[x.status]&&h[x.status].push(x);return h},[t]),u=c.useMemo(()=>a?t.find(h=>h.id===a):null,[a,t]);function d(h){i(h.active.id)}function m(h){i(null);const{active:x,over:y}=h;if(!y)return;const N=x.id,b=t.find(T=>T.id===N);if(!b)return;let g=null;if(Pa.includes(y.id))g=y.id;else{const T=t.find(k=>k.id===y.id);T&&(g=T.status)}g&&g!==b.status&&r(N,{status:g})}function p(h){}return e.jsxs(Mi,{sensors:l,onDragStart:d,onDragOver:p,onDragEnd:m,children:[e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-4 -mx-2 px-2",children:Pa.map(h=>e.jsx($g,{status:h,issues:o[h]??[],agents:s,liveIssueIds:n},h))}),e.jsx(Wp,{children:u?e.jsx(qc,{issue:u,agents:s,isOverlay:!0}):null})]})}const zr=["in_progress","todo","backlog","in_review","blocked","done","cancelled"],Kr=["critical","high","medium","low"];function jr(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const Ur={statuses:[],priorities:[],assignees:[],labels:[],sortField:"updated",sortDir:"desc",groupBy:"none",viewMode:"list",collapsedGroups:[]},Lg=[{label:"All",statuses:[]},{label:"Active",statuses:["todo","in_progress","in_review","blocked"]},{label:"Backlog",statuses:["backlog"]},{label:"Done",statuses:["done","cancelled"]}];function Dl(t){try{const s=localStorage.getItem(t);if(s)return{...Ur,...JSON.parse(s)}}catch{}return{...Ur}}function qg(t,s){localStorage.setItem(t,JSON.stringify(s))}function Bg(t,s){if(t.length!==s.length)return!1;const n=[...t].sort(),r=[...s].sort();return n.every((a,i)=>a===r[i])}function sn(t,s){return t.includes(s)?t.filter(n=>n!==s):[...t,s]}function zg(t,s,n){let r=t;return s.statuses.length>0&&(r=r.filter(a=>s.statuses.includes(a.status))),s.priorities.length>0&&(r=r.filter(a=>s.priorities.includes(a.priority))),s.assignees.length>0&&(r=r.filter(a=>{for(const i of s.assignees)if(i==="__unassigned"&&!a.assigneeAgentId&&!a.assigneeUserId||i==="__me"&&n&&a.assigneeUserId===n||a.assigneeAgentId===i)return!0;return!1})),s.labels.length>0&&(r=r.filter(a=>(a.labelIds??[]).some(i=>s.labels.includes(i)))),r}function Kg(t,s){const n=[...t],r=s.sortDir==="asc"?1:-1;return n.sort((a,i)=>{switch(s.sortField){case"status":return r*(zr.indexOf(a.status)-zr.indexOf(i.status));case"priority":return r*(Kr.indexOf(a.priority)-Kr.indexOf(i.priority));case"title":return r*a.title.localeCompare(i.title);case"created":return r*(new Date(a.createdAt).getTime()-new Date(i.createdAt).getTime());case"updated":return r*(new Date(a.updatedAt).getTime()-new Date(i.updatedAt).getTime());default:return 0}}),n}function Ug(t){let s=0;return t.statuses.length>0&&s++,t.priorities.length>0&&s++,t.assignees.length>0&&s++,t.labels.length>0&&s++,s}function Bc({issues:t,isLoading:s,error:n,agents:r,liveIssueIds:a,projectId:i,viewStateKey:l,issueLinkState:o,initialAssignees:u,initialSearch:d,onSearchChange:m,onUpdateIssue:p}){var q,H;const{selectedCompanyId:h}=fe(),{openNewIssue:x}=Ye(),{data:y}=Q({queryKey:P.auth.session,queryFn:()=>ii.getSession()}),N=((q=y==null?void 0:y.user)==null?void 0:q.id)??((H=y==null?void 0:y.session)==null?void 0:H.userId)??null,b=h?`${l}:${h}`:l,[g,T]=c.useState(()=>u?{...Ur,assignees:u,statuses:[]}:Dl(b)),[k,C]=c.useState(null),[f,j]=c.useState(""),[v,U]=c.useState(d??""),[A,B]=c.useState(v),W=A.trim();c.useEffect(()=>{U(d??"")},[d]),c.useEffect(()=>{const I=window.setTimeout(()=>{B(v)},300);return()=>window.clearTimeout(I)},[v]);const S=c.useRef(b);c.useEffect(()=>{S.current!==b&&(S.current=b,T(u?{...Ur,assignees:u,statuses:[]}:Dl(b)))},[b,u]);const w=c.useCallback(I=>{T(R=>{const D={...R,...I};return qg(b,D),D})},[b]),{data:te=[]}=Q({queryKey:P.issues.search(h,W,i),queryFn:()=>Ve.list(h,{q:W,projectId:i}),enabled:!!h&&W.length>0}),G=c.useCallback(I=>{var R;return!I||!r?null:((R=r.find(D=>D.id===I))==null?void 0:R.name)??null},[r]),K=c.useMemo(()=>{const I=W.length>0?te:t,R=zg(I,g,N);return Kg(R,g)},[t,te,g,W,N]),{data:M}=Q({queryKey:P.issues.labels(h),queryFn:()=>Ve.listLabels(h),enabled:!!h}),ee=Ug(g),L=c.useMemo(()=>{if(g.groupBy==="none")return[{key:"__all",label:null,items:K}];if(g.groupBy==="status"){const R=Aa(K,D=>D.status);return zr.filter(D=>{var Z;return(Z=R[D])==null?void 0:Z.length}).map(D=>({key:D,label:jr(D),items:R[D]}))}if(g.groupBy==="priority"){const R=Aa(K,D=>D.priority);return Kr.filter(D=>{var Z;return(Z=R[D])==null?void 0:Z.length}).map(D=>({key:D,label:jr(D),items:R[D]}))}const I=Aa(K,R=>R.assigneeAgentId??(R.assigneeUserId?`__user:${R.assigneeUserId}`:"__unassigned"));return Object.keys(I).map(R=>({key:R,label:R==="__unassigned"?"Unassigned":R.startsWith("__user:")?Ji(R.slice(7),N)??"User":G(R)??R.slice(0,8),items:I[R]}))},[K,g.groupBy,r,G,N]),ae=I=>{const R={};return i&&(R.projectId=i),I&&(g.groupBy==="status"?R.status=I:g.groupBy==="priority"?R.priority=I:g.groupBy==="assignee"&&I!=="__unassigned"&&(I.startsWith("__user:")?R.assigneeUserId=I.slice(7):R.assigneeAgentId=I)),R},oe=(I,R,D=null)=>{p(I,{assigneeAgentId:R,assigneeUserId:D}),C(null),j("")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>x(ae()),children:[e.jsx(Ae,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"New Issue"})]}),e.jsxs("div",{className:"relative w-48 sm:w-64 md:w-80",children:[e.jsx(fs,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Vt,{value:v,onChange:I=>{U(I.target.value),m==null||m(I.target.value)},placeholder:"Search issues...",className:"pl-7 text-xs sm:text-sm","aria-label":"Search issues"})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1 shrink-0",children:[e.jsxs("div",{className:"flex items-center border border-border rounded-md overflow-hidden mr-1",children:[e.jsx("button",{className:`p-1.5 transition-colors ${g.viewMode==="list"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>w({viewMode:"list"}),title:"List view",children:e.jsx(Ni,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:`p-1.5 transition-colors ${g.viewMode==="board"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>w({viewMode:"board"}),title:"Board view",children:e.jsx(Em,{className:"h-3.5 w-3.5"})})]}),e.jsxs(vt,{children:[e.jsx(yt,{asChild:!0,children:e.jsxs(F,{variant:"ghost",size:"sm",className:`text-xs ${ee>0?"text-blue-600 dark:text-blue-400":""}`,children:[e.jsx(Om,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:ee>0?`Filters: ${ee}`:"Filter"}),ee>0&&e.jsx("span",{className:"sm:hidden text-[10px] font-medium ml-0.5",children:ee}),ee>0&&e.jsx(nt,{className:"h-3 w-3 ml-1 hidden sm:block",onClick:I=>{I.stopPropagation(),w({statuses:[],priorities:[],assignees:[],labels:[]})}})]})}),e.jsx(Nt,{align:"end",className:"w-[min(480px,calc(100vw-2rem))] p-0",children:e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Filters"}),ee>0&&e.jsx("button",{className:"text-xs text-muted-foreground hover:text-foreground",onClick:()=>w({statuses:[],priorities:[],assignees:[],labels:[]}),children:"Clear"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Quick filters"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Lg.map(I=>{const R=Bg(g.statuses,I.statuses);return e.jsx("button",{className:`px-2.5 py-1 text-xs rounded-full border transition-colors ${R?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:text-foreground hover:border-foreground/30"}`,onClick:()=>w({statuses:R?[]:[...I.statuses]}),children:I.label},I.label)})})]}),e.jsx("div",{className:"border-t border-border"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx("div",{className:"space-y-0.5",children:zr.map(I=>e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded-sm hover:bg-accent/50 cursor-pointer",children:[e.jsx(is,{checked:g.statuses.includes(I),onCheckedChange:()=>w({statuses:sn(g.statuses,I)})}),e.jsx(ft,{status:I}),e.jsx("span",{className:"text-sm",children:jr(I)})]},I))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Priority"}),e.jsx("div",{className:"space-y-0.5",children:Kr.map(I=>e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded-sm hover:bg-accent/50 cursor-pointer",children:[e.jsx(is,{checked:g.priorities.includes(I),onCheckedChange:()=>w({priorities:sn(g.priorities,I)})}),e.jsx(At,{priority:I}),e.jsx("span",{className:"text-sm",children:jr(I)})]},I))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Assignee"}),e.jsxs("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:[e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded-sm hover:bg-accent/50 cursor-pointer",children:[e.jsx(is,{checked:g.assignees.includes("__unassigned"),onCheckedChange:()=>w({assignees:sn(g.assignees,"__unassigned")})}),e.jsx("span",{className:"text-sm",children:"No assignee"})]}),N&&e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded-sm hover:bg-accent/50 cursor-pointer",children:[e.jsx(is,{checked:g.assignees.includes("__me"),onCheckedChange:()=>w({assignees:sn(g.assignees,"__me")})}),e.jsx(on,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:"Me"})]}),(r??[]).map(I=>e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded-sm hover:bg-accent/50 cursor-pointer",children:[e.jsx(is,{checked:g.assignees.includes(I.id),onCheckedChange:()=>w({assignees:sn(g.assignees,I.id)})}),e.jsx("span",{className:"text-sm",children:I.name})]},I.id))]})]}),M&&M.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Labels"}),e.jsx("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:M.map(I=>e.jsxs("label",{className:"flex items-center gap-2 px-2 py-1 rounded-sm hover:bg-accent/50 cursor-pointer",children:[e.jsx(is,{checked:g.labels.includes(I.id),onCheckedChange:()=>w({labels:sn(g.labels,I.id)})}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:I.color}}),e.jsx("span",{className:"text-sm",children:I.name})]},I.id))})]})]})]})]})})]}),g.viewMode==="list"&&e.jsxs(vt,{children:[e.jsx(yt,{asChild:!0,children:e.jsxs(F,{variant:"ghost",size:"sm",className:"text-xs",children:[e.jsx(jm,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Sort"})]})}),e.jsx(Nt,{align:"end",className:"w-48 p-0",children:e.jsx("div",{className:"p-2 space-y-0.5",children:[["status","Status"],["priority","Priority"],["title","Title"],["created","Created"],["updated","Updated"]].map(([I,R])=>e.jsxs("button",{className:`flex items-center justify-between w-full px-2 py-1.5 text-sm rounded-sm ${g.sortField===I?"bg-accent/50 text-foreground":"hover:bg-accent/50 text-muted-foreground"}`,onClick:()=>{g.sortField===I?w({sortDir:g.sortDir==="asc"?"desc":"asc"}):w({sortField:I,sortDir:"asc"})},children:[e.jsx("span",{children:R}),g.sortField===I&&e.jsx("span",{className:"text-xs text-muted-foreground",children:g.sortDir==="asc"?"↑":"↓"})]},I))})})]}),g.viewMode==="list"&&e.jsxs(vt,{children:[e.jsx(yt,{asChild:!0,children:e.jsxs(F,{variant:"ghost",size:"sm",className:"text-xs",children:[e.jsx(Do,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Group"})]})}),e.jsx(Nt,{align:"end",className:"w-44 p-0",children:e.jsx("div",{className:"p-2 space-y-0.5",children:[["status","Status"],["priority","Priority"],["assignee","Assignee"],["none","None"]].map(([I,R])=>e.jsxs("button",{className:`flex items-center justify-between w-full px-2 py-1.5 text-sm rounded-sm ${g.groupBy===I?"bg-accent/50 text-foreground":"hover:bg-accent/50 text-muted-foreground"}`,onClick:()=>w({groupBy:I}),children:[e.jsx("span",{children:R}),g.groupBy===I&&e.jsx(Qt,{className:"h-3.5 w-3.5"})]},I))})})]})]})]}),s&&e.jsx(ot,{variant:"issues-list"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n.message}),!s&&K.length===0&&g.viewMode==="list"&&e.jsx(rt,{icon:Wt,message:"No issues match the current filters or search.",action:"Create Issue",onAction:()=>x(ae())}),g.viewMode==="board"?e.jsx(Og,{issues:K,agents:r,liveIssueIds:a,onUpdateIssue:p}):L.map(I=>e.jsxs(Gr,{open:!g.collapsedGroups.includes(I.key),onOpenChange:R=>{w({collapsedGroups:R?g.collapsedGroups.filter(D=>D!==I.key):[...g.collapsedGroups,I.key]})},children:[I.label&&e.jsxs("div",{className:"flex items-center py-1.5 pl-1 pr-3",children:[e.jsxs(Hr,{className:"flex items-center gap-1.5",children:[e.jsx(Ns,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform [[data-state=open]>&]:rotate-90"}),e.jsx("span",{className:"text-sm font-semibold uppercase tracking-wide",children:I.label})]}),e.jsx(F,{variant:"ghost",size:"icon-xs",className:"ml-auto text-muted-foreground",onClick:()=>x(ae(I.key)),children:e.jsx(Ae,{className:"h-3 w-3"})})]}),e.jsx(Jr,{children:I.items.map(R=>e.jsx(ko,{issue:R,issueLinkState:o,desktopLeadingSpacer:!0,mobileLeading:e.jsx("span",{onClick:D=>{D.preventDefault(),D.stopPropagation()},children:e.jsx(ft,{status:R.status,onChange:D=>p(R.id,{status:D})})}),desktopMetaLeading:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(At,{priority:R.priority})}),e.jsx("span",{className:"hidden shrink-0 sm:inline-flex",onClick:D=>{D.preventDefault(),D.stopPropagation()},children:e.jsx(ft,{status:R.status,onChange:D=>p(R.id,{status:D})})}),e.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:R.identifier??R.id.slice(0,8)}),(a==null?void 0:a.has(R.id))&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-500/10 px-1.5 py-0.5 sm:gap-1.5 sm:px-2",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-pulse rounded-full bg-blue-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-blue-500"})]}),e.jsx("span",{className:"hidden text-[11px] font-medium text-blue-600 dark:text-blue-400 sm:inline",children:"Live"})]})]}),mobileMeta:Ut(R.updatedAt),desktopTrailing:e.jsxs(e.Fragment,{children:[(R.labels??[]).length>0&&e.jsxs("span",{className:"hidden items-center gap-1 overflow-hidden md:flex md:max-w-[240px]",children:[(R.labels??[]).slice(0,3).map(D=>e.jsx("span",{className:"inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium",style:{borderColor:D.color,color:D.color,backgroundColor:`${D.color}1f`},children:D.name},D.id)),(R.labels??[]).length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",(R.labels??[]).length-3]})]}),e.jsxs(vt,{open:k===R.id,onOpenChange:D=>{C(D?R.id:null),D||j("")},children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{className:"flex w-[180px] shrink-0 items-center rounded-md px-2 py-1 transition-colors hover:bg-accent/50",onClick:D=>{D.preventDefault(),D.stopPropagation()},children:R.assigneeAgentId&&G(R.assigneeAgentId)?e.jsx(Ue,{name:G(R.assigneeAgentId),size:"sm"}):R.assigneeUserId?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full border border-dashed border-muted-foreground/35 bg-muted/30",children:e.jsx(on,{className:"h-3 w-3"})}),Ji(R.assigneeUserId,N)??"User"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full border border-dashed border-muted-foreground/35 bg-muted/30",children:e.jsx(on,{className:"h-3 w-3"})}),"Assignee"]})})}),e.jsxs(Nt,{className:"w-56 p-1",align:"end",onClick:D=>D.stopPropagation(),onPointerDownOutside:()=>j(""),children:[e.jsx("input",{className:"mb-1 w-full border-b border-border bg-transparent px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground/50",placeholder:"Search assignees...",value:f,onChange:D=>j(D.target.value),autoFocus:!0}),e.jsxs("div",{className:"max-h-48 overflow-y-auto overscroll-contain",children:[e.jsx("button",{className:z("flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-accent/50",!R.assigneeAgentId&&!R.assigneeUserId&&"bg-accent"),onClick:D=>{D.preventDefault(),D.stopPropagation(),oe(R.id,null,null)},children:"No assignee"}),N&&e.jsxs("button",{className:z("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-accent/50",R.assigneeUserId===N&&"bg-accent"),onClick:D=>{D.preventDefault(),D.stopPropagation(),oe(R.id,null,N)},children:[e.jsx(on,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{children:"Me"})]}),(r??[]).filter(D=>f.trim()?D.name.toLowerCase().includes(f.toLowerCase()):!0).map(D=>e.jsx("button",{className:z("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-accent/50",R.assigneeAgentId===D.id&&"bg-accent"),onClick:Z=>{Z.preventDefault(),Z.stopPropagation(),oe(R.id,D.id,null)},children:e.jsx(Ue,{name:D.name,size:"sm",className:"min-w-0"})},D.id))]})]})]})]}),trailingMeta:Us(R.createdAt)},R.id))})]},I.key))]})}function zc({goal:t,children:s,allGoals:n,depth:r,goalLink:a,onSelect:i,onDelete:l}){const[o,u]=c.useState(!0),d=s.length>0,m=a==null?void 0:a(t),p=e.jsxs(e.Fragment,{children:[d?e.jsx("button",{className:"p-0.5",onClick:x=>{x.preventDefault(),x.stopPropagation(),u(!o)},children:e.jsx(Ns,{className:z("h-3 w-3 transition-transform",o&&"rotate-90")})}):e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:t.level}),e.jsx("span",{className:"flex-1 truncate",children:t.title}),e.jsx(Pe,{status:t.status}),l&&e.jsxs(Zr,{children:[e.jsx(ea,{asChild:!0,children:e.jsx("button",{className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-accent",onClick:x=>{x.preventDefault(),x.stopPropagation()},children:e.jsx(xi,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsx(ta,{align:"end",children:e.jsxs(Ks,{className:"text-destructive focus:text-destructive gap-2",onClick:x=>{x.stopPropagation(),l(t)},children:[e.jsx(Jt,{className:"h-3.5 w-3.5"}),"Delete goal"]})})]})]}),h=z("group flex items-center gap-2 px-3 py-1.5 text-sm transition-colors cursor-pointer hover:bg-accent/50");return e.jsxs("div",{children:[m?e.jsx(he,{to:m,className:z(h,"no-underline text-inherit"),style:{paddingLeft:`${r*16+12}px`},children:p}):e.jsx("div",{className:h,style:{paddingLeft:`${r*16+12}px`},onClick:()=>i==null?void 0:i(t),children:p}),d&&o&&e.jsx("div",{children:s.map(x=>e.jsx(zc,{goal:x,children:n.filter(y=>y.parentId===x.id),allGoals:n,depth:r+1,goalLink:a,onSelect:i,onDelete:l},x.id))})]})}function qi({goals:t,goalLink:s,onSelect:n,onDelete:r}){const a=new Set(t.map(l=>l.id)),i=t.filter(l=>!l.parentId||!a.has(l.parentId));return t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No goals."}):e.jsx("div",{className:"border border-border py-1",children:i.map(l=>e.jsx(zc,{goal:l,children:t.filter(o=>o.parentId===l.id),allGoals:t,depth:0,goalLink:s,onSelect:n,onDelete:r},l.id))})}function vr(t){return typeof t=="string"&&t.startsWith("plugin:")}function Vg(t,s){const n=t.split("/").filter(Boolean),r=n.indexOf("projects");if(r===-1||n[r+1]!==s)return null;const a=n[r+2];return a==="overview"?"overview":a==="configuration"?"configuration":a==="budget"?"budget":a==="issues"?"list":null}function Wg({project:t,goals:s,onUpdate:n,imageUploadHandler:r}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ds,{value:t.description??"",onSave:a=>n({description:a}),as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0,imageUploadHandler:r}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Status"}),e.jsx("div",{className:"mt-1",children:e.jsx(Pe,{status:t.status})})]}),t.targetDate&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Target Date"}),e.jsx("p",{children:t.targetDate})]})]}),s&&s.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Goals"}),e.jsx(qi,{goals:s,goalLink:a=>`/goals/${a.id}`})]})]})}function Qg({currentColor:t,onSelect:s}){const[n,r]=c.useState(!1),a=c.useRef(null);return c.useEffect(()=>{if(!n)return;function i(l){a.current&&!a.current.contains(l.target)&&r(!1)}return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n]),e.jsxs("div",{className:"relative",ref:a,children:[e.jsx("button",{onClick:()=>r(!n),className:"shrink-0 h-5 w-5 rounded-md cursor-pointer hover:ring-2 hover:ring-foreground/20 transition-[box-shadow]",style:{backgroundColor:t},"aria-label":"Change project color"}),n&&e.jsx("div",{className:"absolute top-full left-0 mt-2 p-2 bg-popover border border-border rounded-lg shadow-lg z-50 w-max",children:e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Fa.map(i=>e.jsx("button",{onClick:()=>{s(i),r(!1)},className:`h-6 w-6 rounded-md cursor-pointer transition-[transform,box-shadow] duration-150 hover:scale-110 ${i===t?"ring-2 ring-foreground ring-offset-1 ring-offset-background":"hover:ring-2 hover:ring-foreground/30"}`,style:{backgroundColor:i},"aria-label":`Select color ${i}`},i))})})]})}function Gg({projectId:t,companyId:s}){const n=_e(),{data:r}=Q({queryKey:P.agents.list(s),queryFn:()=>Te.list(s),enabled:!!s}),{data:a}=Q({queryKey:P.liveRuns(s),queryFn:()=>Tt.liveRunsForCompany(s),enabled:!!s,refetchInterval:5e3}),i=c.useMemo(()=>{const m=new Set;for(const p of a??[])p.issueId&&m.add(p.issueId);return m},[a]),{data:l,isLoading:o,error:u}=Q({queryKey:P.issues.listByProject(s,t),queryFn:()=>Ve.list(s,{projectId:t}),enabled:!!s}),d=re({mutationFn:({id:m,data:p})=>Ve.update(m,p),onSuccess:()=>{n.invalidateQueries({queryKey:P.issues.listByProject(s,t)}),n.invalidateQueries({queryKey:P.issues.list(s)})}});return e.jsx(Bc,{issues:l??[],isLoading:o,error:u,agents:r,liveIssueIds:i,projectId:t,viewStateKey:`paperclip:project-view:${t}`,onUpdateIssue:(m,p)=>d.mutate({id:m,data:p})})}function nn(){const{companyPrefix:t,projectId:s,filter:n}=Cs(),{companies:r,selectedCompanyId:a,setSelectedCompanyId:i}=fe(),{closePanel:l}=di(),{setBreadcrumbs:o}=Fe(),{pushToast:u}=gi(),d=_e(),m=Rt(),p=wt(),[h,x]=c.useState({}),y=c.useRef({}),N=c.useRef({}),b=s??"",T=c.useMemo(()=>{var ce;if(!t)return null;const $=t.toUpperCase();return((ce=r.find(ue=>ue.issuePrefix.toUpperCase()===$))==null?void 0:ce.id)??null},[r,t])??a??void 0,k=b.length>0&&(Vd(b)||!!T),C=b?Vg(p.pathname,b):null,f=c.useMemo(()=>{const $=new URLSearchParams(p.search).get("tab");return vr($)?$:null},[p.search]),j=C??f,{data:v,isLoading:U,error:A}=Q({queryKey:[...P.projects.detail(b),T??null],queryFn:()=>mt.get(b,T),enabled:k}),B=v?ao(v):b,W=(v==null?void 0:v.id)??b,S=(v==null?void 0:v.companyId)??a,{slots:w,isLoading:te}=ai({slotTypes:["detailTab"],entityType:"project",enabled:!!S}),G=c.useMemo(()=>w.map($=>({value:`plugin:${$.pluginKey}:${$.id}`,label:$.displayName,slot:$})),[w]),K=G.find($=>$.value===j)??null;c.useEffect(()=>{!(v!=null&&v.companyId)||v.companyId===a||i(v.companyId,{source:"route_sync"})},[v==null?void 0:v.companyId,a,i]);const M=()=>{d.invalidateQueries({queryKey:P.projects.detail(b)}),d.invalidateQueries({queryKey:P.projects.detail(W)}),S&&d.invalidateQueries({queryKey:P.projects.list(S)})},ee=re({mutationFn:$=>mt.update(W,$,S??T),onSuccess:M}),L=re({mutationFn:$=>mt.update(W,{archivedAt:$?new Date().toISOString():null},S??T),onSuccess:($,ce)=>{M();const ue=($==null?void 0:$.name)??(v==null?void 0:v.name)??"Project";ce?(u({title:`"${ue}" has been archived`,tone:"success"}),m("/dashboard")):u({title:`"${ue}" has been unarchived`,tone:"success"})},onError:($,ce)=>{u({title:ce?"Failed to archive project":"Failed to unarchive project",tone:"error"})}}),ae=re({mutationFn:async $=>{if(!S)throw new Error("No company selected");return rr.uploadImage(S,$,`projects/${W||"draft"}`)}}),{data:oe}=Q({queryKey:P.budgets.overview(S??"__none__"),queryFn:()=>zn.overview(S),enabled:!!S,refetchInterval:3e4,staleTime:5e3}),{data:q}=Q({queryKey:P.goals.list(S??"__none__"),queryFn:()=>_t.list(S),enabled:!!S&&j==="overview",staleTime:3e4}),H=c.useMemo(()=>{const $=new Set((v==null?void 0:v.goalIds)??[]);return(q??[]).filter(ce=>$.has(ce.id))},[q,v]);c.useEffect(()=>{o([{label:"Projects",href:"/projects"},{label:(v==null?void 0:v.name)??b??"Project"}])},[o,v,b]),c.useEffect(()=>{if(v&&b!==B){if(vr(j)){m(`/projects/${B}?tab=${encodeURIComponent(j)}`,{replace:!0});return}if(j==="overview"){m(`/projects/${B}/overview`,{replace:!0});return}if(j==="configuration"){m(`/projects/${B}/configuration`,{replace:!0});return}if(j==="budget"){m(`/projects/${B}/budget`,{replace:!0});return}if(j==="list"){if(n){m(`/projects/${B}/issues/${n}`,{replace:!0});return}m(`/projects/${B}/issues`,{replace:!0});return}m(`/projects/${B}`,{replace:!0})}},[v,b,B,j,n,m]),c.useEffect(()=>(l(),()=>l()),[l]),c.useEffect(()=>()=>{Object.values(N.current).forEach($=>{$&&clearTimeout($)})},[]);const I=c.useCallback(($,ce)=>{x(ue=>({...ue,[$]:ce}))},[]),R=c.useCallback(($,ce)=>{const ue=N.current[$];ue&&clearTimeout(ue),N.current[$]=setTimeout(()=>{x(Re=>{const De={...Re};return delete De[$],De}),delete N.current[$]},ce)},[]),D=c.useCallback(async($,ce)=>{const ue=(y.current[$]??0)+1;y.current[$]=ue,I($,"saving");try{if(await mt.update(W,ce,S??T),M(),y.current[$]!==ue)return;I($,"saved"),R($,1800)}catch(Re){if(y.current[$]!==ue)return;throw I($,"error"),R($,3e3),Re}},[M,T,W,S,R,I]),Z=c.useMemo(()=>{const $=oe==null?void 0:oe.policies.find(ce=>ce.scopeType==="project"&&ce.scopeId===((v==null?void 0:v.id)??b));return $||{policyId:"",companyId:S??"",scopeType:"project",scopeId:(v==null?void 0:v.id)??b,scopeName:(v==null?void 0:v.name)??"Project",metric:"billed_cents",windowKind:"lifetime",amount:0,observedAmount:0,remainingAmount:0,utilizationPercent:0,warnPercent:80,hardStopEnabled:!0,notifyEnabled:!0,isActive:!1,status:"ok",paused:!!(v!=null&&v.pausedAt),pauseReason:(v==null?void 0:v.pauseReason)??null,windowStart:new Date,windowEnd:new Date}},[oe==null?void 0:oe.policies,v,S,b]),me=re({mutationFn:$=>zn.upsertPolicy(S,{scopeType:"project",scopeId:(v==null?void 0:v.id)??b,amount:$,windowKind:"lifetime"}),onSuccess:()=>{S&&(d.invalidateQueries({queryKey:P.budgets.overview(S)}),d.invalidateQueries({queryKey:P.projects.detail(b)}),d.invalidateQueries({queryKey:P.projects.detail(W)}),d.invalidateQueries({queryKey:P.projects.list(S)}),d.invalidateQueries({queryKey:P.dashboard(S)}))}});if(f&&!te&&!K)return e.jsx(Ie,{to:`/projects/${B}/issues`,replace:!0});if(b&&j===null){let $=null;if(v!=null&&v.id)try{$=localStorage.getItem(`paperclip:project-tab:${v.id}`)}catch{}return $==="overview"?e.jsx(Ie,{to:`/projects/${B}/overview`,replace:!0}):$==="configuration"?e.jsx(Ie,{to:`/projects/${B}/configuration`,replace:!0}):$==="budget"?e.jsx(Ie,{to:`/projects/${B}/budget`,replace:!0}):vr($)?e.jsx(Ie,{to:`/projects/${B}?tab=${encodeURIComponent($)}`,replace:!0}):e.jsx(Ie,{to:`/projects/${B}/overview`,replace:!0})}if(U)return e.jsx(ot,{variant:"detail"});if(A)return e.jsx("p",{className:"text-sm text-destructive",children:A.message});if(!v)return null;const xe=$=>{if(v!=null&&v.id)try{localStorage.setItem(`paperclip:project-tab:${v.id}`,$)}catch{}if(vr($)){m(`/projects/${B}?tab=${encodeURIComponent($)}`);return}m($==="overview"?`/projects/${B}/overview`:$==="budget"?`/projects/${B}/budget`:$==="configuration"?`/projects/${B}/configuration`:`/projects/${B}/issues`)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-7 flex items-center",children:e.jsx(Qg,{currentColor:v.color??"#6366f1",onSelect:$=>ee.mutate({color:$})})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx(Ds,{value:v.name,onSave:$=>ee.mutate({name:$}),as:"h2",className:"text-xl font-bold"}),v.pauseReason==="budget"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-red-500/30 bg-red-500/10 px-3 py-1 text-[11px] font-medium uppercase tracking-[0.18em] text-red-200",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-400"}),"Paused by budget hard stop"]}):null]})]}),e.jsx(Ir,{slotTypes:["toolbarButton","contextMenuItem"],entityType:"project",context:{companyId:S??null,companyPrefix:t??null,projectId:v.id,projectRef:B,entityId:v.id,entityType:"project"},className:"flex flex-wrap gap-2",itemClassName:"inline-flex",missingBehavior:"placeholder"}),e.jsx(Wd,{placementZones:["toolbarButton"],entityType:"project",context:{companyId:S??null,companyPrefix:t??null,projectId:v.id,projectRef:B,entityId:v.id,entityType:"project"},className:"flex flex-wrap gap-2",itemClassName:"inline-flex"}),e.jsx(Yt,{value:j??"overview",onValueChange:$=>xe($),children:e.jsx(Gs,{items:[{value:"overview",label:"Overview"},{value:"list",label:"Issues"},{value:"configuration",label:"Configuration"},{value:"budget",label:"Budget"},...G.map($=>({value:$.value,label:$.label}))],align:"start",value:j??"overview",onValueChange:$=>xe($)})}),j==="overview"&&e.jsx(Wg,{project:v,goals:H,onUpdate:$=>ee.mutate($),imageUploadHandler:async $=>(await ae.mutateAsync($)).contentPath}),j==="list"&&(v==null?void 0:v.id)&&S&&e.jsx(Gg,{projectId:v.id,companyId:S}),j==="configuration"&&e.jsx("div",{className:"max-w-4xl",children:e.jsx(_g,{project:v,onUpdate:$=>ee.mutate($),onFieldUpdate:D,getFieldSaveState:$=>h[$]??"idle",onArchive:$=>L.mutate($),archivePending:L.isPending})}),j==="budget"&&S?e.jsx("div",{className:"max-w-3xl",children:e.jsx(Co,{summary:Z,variant:"plain",isSaving:me.isPending,onSave:$=>me.mutate($)})}):null,K&&e.jsx(Yr,{slot:K.slot,context:{companyId:S,companyPrefix:t??null,projectId:v.id,projectRef:B,entityId:v.id,entityType:"project"},missingBehavior:"placeholder"})]})}function Hg(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),n=wt(),[r]=fi(),a=_e(),i=r.get("q")??"",l=c.useRef(void 0),o=c.useCallback(b=>{clearTimeout(l.current),l.current=setTimeout(()=>{const g=b.trim();if((new URLSearchParams(window.location.search).get("q")??"")===g)return;const k=new URL(window.location.href);g?k.searchParams.set("q",g):k.searchParams.delete("q");const C=`${k.pathname}${k.search}${k.hash}`;window.history.replaceState(window.history.state,"",C)},300)},[]);c.useEffect(()=>()=>clearTimeout(l.current),[]);const{data:u}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t}),{data:d}=Q({queryKey:P.liveRuns(t),queryFn:()=>Tt.liveRunsForCompany(t),enabled:!!t,refetchInterval:5e3}),m=c.useMemo(()=>{const b=new Set;for(const g of d??[])g.issueId&&b.add(g.issueId);return b},[d]),p=c.useMemo(()=>Tr("Issues",`${n.pathname}${n.search}${n.hash}`),[n.pathname,n.search,n.hash]);c.useEffect(()=>{s([{label:"Issues"}])},[s]);const{data:h,isLoading:x,error:y}=Q({queryKey:P.issues.list(t),queryFn:()=>Ve.list(t),enabled:!!t}),N=re({mutationFn:({id:b,data:g})=>Ve.update(b,g),onSuccess:()=>{a.invalidateQueries({queryKey:P.issues.list(t)})}});return t?e.jsx(Bc,{issues:h??[],isLoading:x,error:y,agents:u,liveIssueIds:m,viewStateKey:"paperclip:issues-view",issueLinkState:p,initialAssignees:r.get("assignee")?[r.get("assignee")]:void 0,initialSearch:i,onSearchChange:o,onUpdateIssue:(b,g)=>N.mutate({id:b,data:g})}):e.jsx(rt,{icon:Wt,message:"Select a company to view issues."})}function Jg(t){if(!t)return!1;try{const s=new URL(t);return s.protocol==="http:"||s.protocol==="https:"}catch{return!1}}function rs({label:t,children:s}){return e.jsxs("div",{className:"flex items-start gap-3 py-1.5",children:[e.jsx("div",{className:"w-28 shrink-0 text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"min-w-0 flex-1 text-sm",children:s})]})}function Yg(){const{workspaceId:t}=Cs(),s=_e(),{pushToast:n}=gi(),{data:r,isLoading:a,error:i}=Q({queryKey:P.executionWorkspaces.detail(t),queryFn:()=>ha.get(t),enabled:!!t}),l=re({mutationFn:()=>ha.openLocal(t),onSuccess:u=>{n({title:`Opened in ${u.app}`,body:u.path,tone:"success"})}}),o=re({mutationFn:()=>ha.update(t,{status:"archived"}),onSuccess:async()=>{await s.invalidateQueries({queryKey:P.executionWorkspaces.detail(t)}),n({title:"Workspace archived",body:"Cleanup was triggered for the worktree and any runtime services.",tone:"success"})}});return a?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):i?e.jsx("p",{className:"text-sm text-destructive",children:i instanceof Error?i.message:"Failed to load workspace"}):r?e.jsxs("div",{className:"max-w-2xl space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Execution workspace"}),e.jsx("h1",{className:"text-2xl font-semibold",children:r.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[r.status," · ",r.mode," · ",r.providerType]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>l.mutate(),disabled:l.isPending,children:[l.isPending?e.jsx(Ft,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Open in Cursor"]}),r.status!=="archived"&&e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>o.mutate(),disabled:o.isPending,children:[o.isPending?e.jsx(Ft,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Archive & clean up"]})]})]}),e.jsxs("div",{className:"rounded-lg border border-border p-4",children:[e.jsx(rs,{label:"Project",children:r.projectId?e.jsx(he,{to:`/projects/${r.projectId}`,className:"hover:underline",children:r.projectId}):"None"}),e.jsx(rs,{label:"Source issue",children:r.sourceIssueId?e.jsx(he,{to:`/issues/${r.sourceIssueId}`,className:"hover:underline",children:r.sourceIssueId}):"None"}),e.jsx(rs,{label:"Branch",children:r.branchName??"None"}),e.jsx(rs,{label:"Base ref",children:r.baseRef??"None"}),e.jsx(rs,{label:"Working dir",children:e.jsx("span",{className:"break-all font-mono text-xs",children:r.cwd??"None"})}),e.jsx(rs,{label:"Provider ref",children:e.jsx("span",{className:"break-all font-mono text-xs",children:r.providerRef??"None"})}),e.jsx(rs,{label:"Repo URL",children:r.repoUrl&&Jg(r.repoUrl)?e.jsxs("a",{href:r.repoUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:underline",children:[r.repoUrl,e.jsx(In,{className:"h-3 w-3"})]}):r.repoUrl?e.jsx("span",{className:"break-all font-mono text-xs",children:r.repoUrl}):"None"}),e.jsx(rs,{label:"Opened",children:new Date(r.openedAt).toLocaleString()}),e.jsx(rs,{label:"Last used",children:new Date(r.lastUsedAt).toLocaleString()}),e.jsx(rs,{label:"Cleanup",children:r.cleanupEligibleAt?`${new Date(r.cleanupEligibleAt).toLocaleString()}${r.cleanupReason?` · ${r.cleanupReason}`:""}`:"Not scheduled"})]})]}):null}function Xg(){const{selectedCompanyId:t}=fe(),{openNewGoal:s}=Ye(),{setBreadcrumbs:n}=Fe(),r=_e();c.useEffect(()=>{n([{label:"Goals"}])},[n]);const{data:a,isLoading:i,error:l}=Q({queryKey:P.goals.list(t),queryFn:()=>_t.list(t),enabled:!!t}),o=re({mutationFn:d=>_t.remove(d.id),onSuccess:()=>{r.invalidateQueries({queryKey:P.goals.list(t)})}}),u=d=>{confirm(`Delete "${d.title}"? This cannot be undone.`)&&o.mutate(d)};return t?i?e.jsx(ot,{variant:"list"}):e.jsxs("div",{className:"space-y-4",children:[l&&e.jsx("p",{className:"text-sm text-destructive",children:l.message}),a&&a.length===0&&e.jsx(rt,{icon:ws,message:"No goals yet.",action:"Add Goal",onAction:()=>s()}),a&&a.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-start",children:e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>s(),children:[e.jsx(Ae,{className:"h-3.5 w-3.5 mr-1.5"}),"New Goal"]})}),e.jsx(qi,{goals:a,goalLink:d=>`/goals/${d.id}`,onDelete:u})]})]}):e.jsx(rt,{icon:ws,message:"Select a company to view goals."})}function rn({label:t,children:s}){return e.jsxs("div",{className:"flex items-center gap-3 py-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground shrink-0 w-20",children:t}),e.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:s})]})}function Zg(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function _l({current:t,options:s,onChange:n,children:r}){const[a,i]=c.useState(!1);return e.jsxs(vt,{open:a,onOpenChange:i,children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{className:"cursor-pointer hover:opacity-80 transition-opacity",children:r})}),e.jsx(Nt,{className:"w-40 p-1",align:"end",children:s.map(l=>e.jsx(F,{variant:"ghost",size:"sm",className:z("w-full justify-start text-xs",l===t&&"bg-accent"),onClick:()=>{n(l),i(!1)},children:Zg(l)},l))})]})}function ef({goal:t,onUpdate:s}){const{selectedCompanyId:n}=fe(),{data:r}=Q({queryKey:P.agents.list(n),queryFn:()=>Te.list(n),enabled:!!n}),{data:a}=Q({queryKey:P.goals.list(n),queryFn:()=>_t.list(n),enabled:!!n}),i=t.ownerAgentId?r==null?void 0:r.find(o=>o.id===t.ownerAgentId):null,l=t.parentId?a==null?void 0:a.find(o=>o.id===t.parentId):null;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(rn,{label:"Status",children:s?e.jsx(_l,{current:t.status,options:po,onChange:o=>s({status:o}),children:e.jsx(Pe,{status:t.status})}):e.jsx(Pe,{status:t.status})}),e.jsx(rn,{label:"Level",children:s?e.jsx(_l,{current:t.level,options:ho,onChange:o=>s({level:o}),children:e.jsx("span",{className:"text-sm capitalize",children:t.level})}):e.jsx("span",{className:"text-sm capitalize",children:t.level})}),e.jsx(rn,{label:"Owner",children:i?e.jsx(he,{to:Sn(i),className:"text-sm hover:underline",children:i.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"None"})}),t.parentId&&e.jsx(rn,{label:"Parent Goal",children:e.jsx(he,{to:`/goals/${t.parentId}`,className:"text-sm hover:underline",children:(l==null?void 0:l.title)??t.parentId.slice(0,8)})})]}),e.jsx($t,{}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(rn,{label:"Created",children:e.jsx("span",{className:"text-sm",children:Us(t.createdAt)})}),e.jsx(rn,{label:"Updated",children:e.jsx("span",{className:"text-sm",children:Us(t.updatedAt)})})]})]})}function tf(){const{goalId:t}=Cs(),{selectedCompanyId:s,setSelectedCompanyId:n}=fe(),{openNewGoal:r}=Ye(),{openPanel:a,closePanel:i}=di(),{setBreadcrumbs:l}=Fe(),o=_e(),u=Rt(),{data:d,isLoading:m,error:p}=Q({queryKey:P.goals.detail(t),queryFn:()=>_t.get(t),enabled:!!t}),h=(d==null?void 0:d.companyId)??s,{data:x}=Q({queryKey:P.goals.list(h),queryFn:()=>_t.list(h),enabled:!!h}),{data:y}=Q({queryKey:P.projects.list(h),queryFn:()=>mt.list(h),enabled:!!h});c.useEffect(()=>{!(d!=null&&d.companyId)||d.companyId===s||n(d.companyId,{source:"route_sync"})},[d==null?void 0:d.companyId,s,n]);const N=re({mutationFn:f=>_t.update(t,f),onSuccess:()=>{o.invalidateQueries({queryKey:P.goals.detail(t)}),h&&o.invalidateQueries({queryKey:P.goals.list(h)})}}),b=re({mutationFn:()=>_t.remove(t),onSuccess:()=>{h&&o.invalidateQueries({queryKey:P.goals.list(h)}),u("/goals")}}),g=re({mutationFn:f=>mt.update(f.id,{goalIds:[...f.goalIds??[],t]}),onSuccess:()=>{h&&o.invalidateQueries({queryKey:P.projects.list(h)})}}),T=re({mutationFn:async f=>{if(!h)throw new Error("No company selected");return rr.uploadImage(h,f,`goals/${t??"draft"}`)}}),k=(x??[]).filter(f=>f.parentId===t),C=(y??[]).filter(f=>t?f.goalIds.includes(t)||f.goals.some(j=>j.id===t)?!0:f.goalId===t:!1);return c.useEffect(()=>{l([{label:"Goals",href:"/goals"},{label:(d==null?void 0:d.title)??t??"Goal"}])},[l,d,t]),c.useEffect(()=>(d&&a(e.jsx(ef,{goal:d,onUpdate:f=>N.mutate(f)})),()=>i()),[d]),m?e.jsx(ot,{variant:"detail"}):p?e.jsx("p",{className:"text-sm text-destructive",children:p.message}):d?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase text-muted-foreground",children:d.level}),e.jsx(Pe,{status:d.status})]}),e.jsx(F,{size:"sm",variant:"ghost",className:"text-muted-foreground hover:text-destructive hover:bg-destructive/10 h-7 w-7 p-0",onClick:()=>{confirm("Delete this goal? This cannot be undone.")&&b.mutate()},disabled:b.isPending,children:e.jsx(Jt,{className:"h-3.5 w-3.5"})})]}),e.jsx(Ds,{value:d.title,onSave:f=>N.mutate({title:f}),as:"h2",className:"text-xl font-bold"}),e.jsx(Ds,{value:d.description??"",onSave:f=>N.mutate({description:f}),as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0,imageUploadHandler:async f=>(await T.mutateAsync(f)).contentPath})]}),e.jsxs(Yt,{defaultValue:"children",children:[e.jsxs(Rr,{children:[e.jsxs(Pt,{value:"children",children:["Sub-Goals (",k.length,")"]}),e.jsxs(Pt,{value:"projects",children:["Projects (",C.length,")"]})]}),e.jsxs(Ke,{value:"children",className:"mt-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-start",children:e.jsxs(F,{size:"sm",variant:"outline",onClick:()=>r({parentId:t}),children:[e.jsx(Ae,{className:"h-3.5 w-3.5 mr-1.5"}),"Sub Goal"]})}),k.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No sub-goals."}):e.jsx(qi,{goals:k,goalLink:f=>`/goals/${f.id}`})]}),e.jsxs(Ke,{value:"projects",className:"mt-4 space-y-3",children:[(()=>{const f=new Set(C.map(v=>v.id)),j=(y??[]).filter(v=>!f.has(v.id));return e.jsx("div",{className:"flex items-center justify-start",children:e.jsxs(Zr,{children:[e.jsx(ea,{asChild:!0,children:e.jsxs(F,{size:"sm",variant:"outline",disabled:j.length===0,children:[e.jsx(Qd,{className:"h-3.5 w-3.5 mr-1.5"}),"Link Project"]})}),e.jsx(ta,{align:"start",className:"max-h-64 overflow-y-auto",children:j.map(v=>e.jsx(Ks,{onClick:()=>g.mutate(v),children:v.name},v.id))})]})})})(),C.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No linked projects."}):e.jsx("div",{className:"border border-border",children:C.map(f=>e.jsx(gs,{title:f.name,subtitle:f.description??void 0,to:li(f),trailing:e.jsx(Pe,{status:f.status})},f.id))})]})]})]}):null}const sf={hire_agent:"Hire Agent",approve_ceo_strategy:"CEO Strategy",budget_override_required:"Budget Override"};function Bi(t,s){const n=sf[t]??t;return t==="hire_agent"&&(s!=null&&s.name)?`${n}: ${String(s.name)}`:n}const zi={hire_agent:px,approve_ceo_strategy:Gd,budget_override_required:So},Ki=wi;function Ws({label:t,value:s}){return s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground w-20 sm:w-24 shrink-0 text-xs",children:t}),e.jsx("span",{children:String(s)})]}):null}function nf({payload:t}){return e.jsxs("div",{className:"mt-3 space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground w-20 sm:w-24 shrink-0 text-xs",children:"Name"}),e.jsx("span",{className:"font-medium",children:String(t.name??"—")})]}),e.jsx(Ws,{label:"Role",value:t.role}),e.jsx(Ws,{label:"Title",value:t.title}),e.jsx(Ws,{label:"Icon",value:t.icon}),!!t.capabilities&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground w-20 sm:w-24 shrink-0 text-xs pt-0.5",children:"Capabilities"}),e.jsx("span",{className:"text-muted-foreground",children:String(t.capabilities)})]}),!!t.adapterType&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground w-20 sm:w-24 shrink-0 text-xs",children:"Adapter"}),e.jsx("span",{className:"font-mono text-xs bg-muted px-1.5 py-0.5 rounded",children:String(t.adapterType)})]})]})}function rf({payload:t}){const s=t.plan??t.description??t.strategy??t.text;return e.jsxs("div",{className:"mt-3 space-y-1.5 text-sm",children:[e.jsx(Ws,{label:"Title",value:t.title}),!!s&&e.jsx("div",{className:"mt-2 rounded-md bg-muted/40 px-3 py-2 text-sm text-muted-foreground whitespace-pre-wrap font-mono text-xs max-h-48 overflow-y-auto",children:String(s)}),!s&&e.jsx("pre",{className:"mt-2 rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground overflow-x-auto max-h-48",children:JSON.stringify(t,null,2)})]})}function af({payload:t}){const s=typeof t.budgetAmount=="number"?t.budgetAmount:null,n=typeof t.observedAmount=="number"?t.observedAmount:null;return e.jsxs("div",{className:"mt-3 space-y-1.5 text-sm",children:[e.jsx(Ws,{label:"Scope",value:t.scopeName??t.scopeType}),e.jsx(Ws,{label:"Window",value:t.windowKind}),e.jsx(Ws,{label:"Metric",value:t.metric}),s!==null||n!==null?e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:["Limit ",s!==null?de(s):"—"," · Observed ",n!==null?de(n):"—"]}):null,!!t.guidance&&e.jsx("p",{className:"text-muted-foreground",children:String(t.guidance)})]})}function Kc({type:t,payload:s}){return t==="hire_agent"?e.jsx(nf,{payload:s}):t==="budget_override_required"?e.jsx(af,{payload:s}):e.jsx(rf,{payload:s})}function lf(t){return t==="approved"?e.jsx(pn,{className:"h-3.5 w-3.5 text-green-600 dark:text-green-400"}):t==="rejected"?e.jsx(bi,{className:"h-3.5 w-3.5 text-red-600 dark:text-red-400"}):t==="revision_requested"?e.jsx(Oa,{className:"h-3.5 w-3.5 text-amber-600 dark:text-amber-400"}):t==="pending"?e.jsx(Oa,{className:"h-3.5 w-3.5 text-yellow-600 dark:text-yellow-400"}):null}function of({approval:t,requesterAgent:s,onApprove:n,onReject:r,onOpen:a,detailLink:i,isPending:l}){const o=zi[t.type]??Ki,u=Bi(t.type,t.payload),d=t.type!=="budget_override_required"&&(t.status==="pending"||t.status==="revision_requested");return e.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:u}),s&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["requested by ",e.jsx(Ue,{name:s.name,size:"sm",className:"inline-flex"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[lf(t.status),e.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:t.status}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",Ut(t.createdAt)]})]})]}),e.jsx(Kc,{type:t.type,payload:t.payload}),t.decisionNote&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground italic border-t border-border pt-2",children:["Note: ",t.decisionNote]}),d&&e.jsxs("div",{className:"flex gap-2 mt-4 pt-3 border-t border-border",children:[e.jsx(F,{size:"sm",className:"bg-green-700 hover:bg-green-600 text-white",onClick:n,disabled:l,children:"Approve"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:r,disabled:l,children:"Reject"})]}),e.jsx("div",{className:"mt-3",children:i?e.jsx(F,{variant:"ghost",size:"sm",className:"text-xs px-0",asChild:!0,children:e.jsx(he,{to:i,children:"View details"})}):e.jsx(F,{variant:"ghost",size:"sm",className:"text-xs px-0",onClick:a,children:"View details"})})]})}function Fl(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),n=_e(),r=Rt(),l=(wt().pathname.split("/").pop()??"pending")==="all"?"all":"pending",[o,u]=c.useState(null);c.useEffect(()=>{s([{label:"Approvals"}])},[s]);const{data:d,isLoading:m,error:p}=Q({queryKey:P.approvals.list(t),queryFn:()=>gt.list(t),enabled:!!t}),{data:h}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t}),x=re({mutationFn:g=>gt.approve(g),onSuccess:(g,T)=>{u(null),n.invalidateQueries({queryKey:P.approvals.list(t)}),r(`/approvals/${T}?resolved=approved`)},onError:g=>{u(g instanceof Error?g.message:"Failed to approve")}}),y=re({mutationFn:g=>gt.reject(g),onSuccess:()=>{u(null),n.invalidateQueries({queryKey:P.approvals.list(t)})},onError:g=>{u(g instanceof Error?g.message:"Failed to reject")}}),N=(d??[]).filter(g=>l==="all"||g.status==="pending"||g.status==="revision_requested").sort((g,T)=>new Date(T.createdAt).getTime()-new Date(g.createdAt).getTime()),b=(d??[]).filter(g=>g.status==="pending"||g.status==="revision_requested").length;return t?m?e.jsx(ot,{variant:"approvals"}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(Yt,{value:l,onValueChange:g=>r(`/approvals/${g}`),children:e.jsx(Gs,{items:[{value:"pending",label:e.jsxs(e.Fragment,{children:["Pending",b>0&&e.jsx("span",{className:z("ml-1.5 rounded-full px-1.5 py-0.5 text-[10px] font-medium","bg-yellow-500/20 text-yellow-500"),children:b})]})},{value:"all",label:"All"}]})})}),p&&e.jsx("p",{className:"text-sm text-destructive",children:p.message}),o&&e.jsx("p",{className:"text-sm text-destructive",children:o}),N.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(wi,{className:"h-8 w-8 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l==="pending"?"No pending approvals.":"No approvals yet."})]}),N.length>0&&e.jsx("div",{className:"grid gap-3",children:N.map(g=>e.jsx(of,{approval:g,requesterAgent:g.requestedByAgentId?(h??[]).find(T=>T.id===g.requestedByAgentId)??null:null,onApprove:()=>x.mutate(g.id),onReject:()=>y.mutate(g.id),detailLink:`/approvals/${g.id}`,isPending:x.isPending||y.isPending},g.id))})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a company first."})}function cf(){const{approvalId:t}=Cs(),{selectedCompanyId:s,setSelectedCompanyId:n}=fe(),{setBreadcrumbs:r}=Fe(),a=Rt(),[i]=fi(),l=_e(),[o,u]=c.useState(""),[d,m]=c.useState(null),[p,h]=c.useState(!1),{data:x,isLoading:y}=Q({queryKey:P.approvals.detail(t),queryFn:()=>gt.get(t),enabled:!!t}),N=(x==null?void 0:x.companyId)??s,{data:b}=Q({queryKey:P.approvals.comments(t),queryFn:()=>gt.listComments(t),enabled:!!t}),{data:g}=Q({queryKey:P.approvals.issues(t),queryFn:()=>gt.listIssues(t),enabled:!!t}),{data:T}=Q({queryKey:P.agents.list(N??""),queryFn:()=>Te.list(N??""),enabled:!!N});c.useEffect(()=>{!(x!=null&&x.companyId)||x.companyId===s||n(x.companyId,{source:"route_sync"})},[x==null?void 0:x.companyId,s,n]);const k=c.useMemo(()=>{const L=new Map;for(const ae of T??[])L.set(ae.id,ae.name);return L},[T]);c.useEffect(()=>{var L;r([{label:"Approvals",href:"/approvals"},{label:((L=x==null?void 0:x.id)==null?void 0:L.slice(0,8))??t??"Approval"}])},[r,x,t]);const C=()=>{t&&(l.invalidateQueries({queryKey:P.approvals.detail(t)}),l.invalidateQueries({queryKey:P.approvals.comments(t)}),l.invalidateQueries({queryKey:P.approvals.issues(t)}),x!=null&&x.companyId&&(l.invalidateQueries({queryKey:P.approvals.list(x.companyId)}),l.invalidateQueries({queryKey:P.approvals.list(x.companyId,"pending")}),l.invalidateQueries({queryKey:P.agents.list(x.companyId)})))},f=re({mutationFn:()=>gt.approve(t),onSuccess:()=>{m(null),C(),a(`/approvals/${t}?resolved=approved`,{replace:!0})},onError:L=>m(L instanceof Error?L.message:"Approve failed")}),j=re({mutationFn:()=>gt.reject(t),onSuccess:()=>{m(null),C()},onError:L=>m(L instanceof Error?L.message:"Reject failed")}),v=re({mutationFn:()=>gt.requestRevision(t),onSuccess:()=>{m(null),C()},onError:L=>m(L instanceof Error?L.message:"Revision request failed")}),U=re({mutationFn:()=>gt.resubmit(t),onSuccess:()=>{m(null),C()},onError:L=>m(L instanceof Error?L.message:"Resubmit failed")}),A=re({mutationFn:()=>gt.addComment(t,o.trim()),onSuccess:()=>{u(""),m(null),C()},onError:L=>m(L instanceof Error?L.message:"Comment failed")}),B=re({mutationFn:L=>Te.remove(L),onSuccess:()=>{m(null),C(),a("/approvals")},onError:L=>m(L instanceof Error?L.message:"Delete failed")});if(y)return e.jsx(ot,{variant:"detail"});if(!x)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"Approval not found."});const W=x.payload,S=typeof W.agentId=="string"?W.agentId:null,w=x.status==="pending"||x.status==="revision_requested",te=x.type==="budget_override_required",G=zi[x.type]??Ki,K=i.get("resolved")==="approved"&&x.status==="approved",M=(g==null?void 0:g[0])??null,ee=M?{label:((g==null?void 0:g.length)??0)>1?"Review linked issues":"Review linked issue",to:`/issues/${M.identifier??M.id}`}:S?{label:"Open hired agent",to:`/agents/${S}`}:{label:"Back to approvals",to:"/approvals"};return e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[K&&e.jsx("div",{className:"border border-green-300 dark:border-green-700/40 bg-green-50 dark:bg-green-900/20 rounded-lg px-4 py-3 animate-in fade-in zoom-in-95 duration-300",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"relative mt-0.5",children:[e.jsx(pn,{className:"h-4 w-4 text-green-600 dark:text-green-300"}),e.jsx(oi,{className:"h-3 w-3 text-green-500 dark:text-green-200 absolute -right-2 -top-1 animate-pulse"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-green-800 dark:text-green-100 font-medium",children:"Approval confirmed"}),e.jsx("p",{className:"text-xs text-green-700 dark:text-green-200/90",children:"Requesting agent was notified to review this approval and linked issues."})]})]}),e.jsx(F,{size:"sm",variant:"outline",className:"border-green-400 dark:border-green-600/50 text-green-800 dark:text-green-100 hover:bg-green-100 dark:hover:bg-green-900/30",onClick:()=>a(ee.to),children:ee.label})]})}),e.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:Bi(x.type,x.payload)}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:x.id})]})]}),e.jsx(Pe,{status:x.status})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[x.requestedByAgentId&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Requested by"}),e.jsx(Ue,{name:k.get(x.requestedByAgentId)??x.requestedByAgentId.slice(0,8),size:"sm"})]}),e.jsx(Kc,{type:x.type,payload:W}),e.jsxs("button",{type:"button",className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mt-2",onClick:()=>h(L=>!L),children:[e.jsx(Ns,{className:`h-3 w-3 transition-transform ${p?"rotate-90":""}`}),"See full request"]}),p&&e.jsx("pre",{className:"text-xs bg-muted/40 rounded-md p-3 overflow-x-auto",children:JSON.stringify(W,null,2)}),x.decisionNote&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Decision note: ",x.decisionNote]})]}),d&&e.jsx("p",{className:"text-sm text-destructive",children:d}),g&&g.length>0&&e.jsxs("div",{className:"pt-2 border-t border-border/60",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1.5",children:"Linked Issues"}),e.jsx("div",{className:"space-y-1.5",children:g.map(L=>e.jsxs(he,{to:`/issues/${L.identifier??L.id}`,className:"block text-xs rounded border border-border/70 px-2 py-1.5 hover:bg-accent/20",children:[e.jsx("span",{className:"font-mono text-muted-foreground mr-2",children:L.identifier??L.id.slice(0,8)}),e.jsx("span",{children:L.title})]},L.id))}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-2",children:"Linked issues remain open until the requesting agent follows up and closes them."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[w&&!te&&e.jsxs(e.Fragment,{children:[e.jsx(F,{size:"sm",className:"bg-green-700 hover:bg-green-600 text-white",onClick:()=>f.mutate(),disabled:f.isPending,children:"Approve"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:"Reject"})]}),te&&x.status==="pending"&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Resolve this budget stop from the budget controls on ",e.jsx(he,{to:"/costs",className:"underline underline-offset-2",children:"/costs"}),"."]}),x.status==="pending"&&e.jsx(F,{size:"sm",variant:"outline",onClick:()=>v.mutate(),disabled:v.isPending,children:"Request revision"}),x.status==="revision_requested"&&e.jsx(F,{size:"sm",variant:"outline",onClick:()=>U.mutate(),disabled:U.isPending,children:"Mark resubmitted"}),x.status==="rejected"&&x.type==="hire_agent"&&S&&e.jsx(F,{size:"sm",variant:"outline",className:"text-destructive border-destructive/40",onClick:()=>{window.confirm("Delete this disapproved agent? This cannot be undone.")&&B.mutate(S)},disabled:B.isPending,children:"Delete disapproved agent"})]})]}),e.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium",children:["Comments (",(b==null?void 0:b.length)??0,")"]}),e.jsx("div",{className:"space-y-2",children:(b??[]).map(L=>e.jsxs("div",{className:"border border-border/60 rounded-md p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[L.authorAgentId?e.jsx(he,{to:`/agents/${L.authorAgentId}`,className:"hover:underline",children:e.jsx(Ue,{name:k.get(L.authorAgentId)??L.authorAgentId.slice(0,8),size:"sm"})}):e.jsx(Ue,{name:"Board",size:"sm"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(L.createdAt).toLocaleString()})]}),e.jsx(Hd,{className:"text-sm",children:L.body})]},L.id))}),e.jsx(cn,{value:o,onChange:L=>u(L.target.value),placeholder:"Add a comment...",rows:3}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{size:"sm",onClick:()=>A.mutate(),disabled:!o.trim()||A.isPending,children:A.isPending?"Posting…":"Post comment"})})]})]})}function hs(t,s){const n=new URLSearchParams;t&&n.set("from",t),s&&n.set("to",s);const r=n.toString();return r?`?${r}`:""}const It={summary:(t,s,n)=>Me.get(`/companies/${t}/costs/summary${hs(s,n)}`),byAgent:(t,s,n)=>Me.get(`/companies/${t}/costs/by-agent${hs(s,n)}`),byAgentModel:(t,s,n)=>Me.get(`/companies/${t}/costs/by-agent-model${hs(s,n)}`),byProject:(t,s,n)=>Me.get(`/companies/${t}/costs/by-project${hs(s,n)}`),byProvider:(t,s,n)=>Me.get(`/companies/${t}/costs/by-provider${hs(s,n)}`),byBiller:(t,s,n)=>Me.get(`/companies/${t}/costs/by-biller${hs(s,n)}`),financeSummary:(t,s,n)=>Me.get(`/companies/${t}/costs/finance-summary${hs(s,n)}`),financeByBiller:(t,s,n)=>Me.get(`/companies/${t}/costs/finance-by-biller${hs(s,n)}`),financeByKind:(t,s,n)=>Me.get(`/companies/${t}/costs/finance-by-kind${hs(s,n)}`),financeEvents:(t,s,n,r=100)=>Me.get(`/companies/${t}/costs/finance-events${df(s,n,r)}`),windowSpend:t=>Me.get(`/companies/${t}/costs/window-spend`),quotaWindows:t=>Me.get(`/companies/${t}/costs/quota-windows`)};function df(t,s,n){const r=new URLSearchParams;t&&r.set("from",t),s&&r.set("to",s),n&&r.set("limit",String(n));const a=r.toString();return a?`?${a}`:""}function uf(t){return t>90?"bg-red-400":t>70?"bg-yellow-400":"bg-green-400"}function si({label:t,percentUsed:s,leftLabel:n,rightLabel:r,showDeficitNotch:a=!1,className:i}){const l=Math.min(100,Math.max(0,s)),o=Math.min(l,97);return e.jsxs("div",{className:z("space-y-1.5",i),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-xs font-medium tabular-nums",children:n}),r&&e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:r})]})]}),e.jsxs("div",{className:"relative h-2 w-full border border-border overflow-hidden",children:[e.jsx("div",{className:z("absolute inset-y-0 left-0 transition-[width,background-color] duration-150",uf(l)),style:{width:`${l}%`}}),a&&l>0&&e.jsx("div",{className:"absolute inset-y-0 w-[2px] bg-destructive z-10",style:{left:`${o}%`}})]})]})}function $l({row:t,weekSpendCents:s,budgetMonthlyCents:n,totalCompanySpendCents:r,providerRows:a}){const i=c.useMemo(()=>{const d=new Map;for(const m of a){const p=d.get(m.provider)??{provider:m.provider,costCents:0,inputTokens:0,outputTokens:0};p.costCents+=m.costCents,p.inputTokens+=m.inputTokens+m.cachedInputTokens,p.outputTokens+=m.outputTokens,d.set(m.provider,p)}return Array.from(d.values()).sort((m,p)=>p.costCents-m.costCents)},[a]),l=c.useMemo(()=>{const d=new Map;for(const m of a)d.set(m.billingType,(d.get(m.billingType)??0)+m.costCents);return Array.from(d.entries()).sort((m,p)=>p[1]-m[1])},[a]),o=n>0&&r>0?t.costCents/r*n:n,u=o>0?Math.min(100,t.costCents/o*100):0;return e.jsxs(Le,{children:[e.jsx(tt,{className:"px-4 pt-4 pb-0 gap-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(st,{className:"text-sm font-semibold",children:Xt(t.biller)}),e.jsxs(jt,{className:"text-xs mt-0.5",children:[e.jsx("span",{className:"font-mono",children:He(t.inputTokens+t.cachedInputTokens)})," in"," · ",e.jsx("span",{className:"font-mono",children:He(t.outputTokens)})," out"," · ",t.providerCount," provider",t.providerCount===1?"":"s"," · ",t.modelCount," model",t.modelCount===1?"":"s"]})]}),e.jsx("span",{className:"text-xl font-bold tabular-nums shrink-0",children:de(t.costCents)})]})}),e.jsxs(qe,{className:"px-4 pb-4 pt-3 space-y-4",children:[n>0&&e.jsx(si,{label:"Period spend",percentUsed:u,leftLabel:de(t.costCents),rightLabel:`${Math.round(u)}% of allocation`}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.apiRunCount>0?`${t.apiRunCount} metered run${t.apiRunCount===1?"":"s"}`:"0 metered runs"," · ",t.subscriptionRunCount>0?`${t.subscriptionRunCount} subscription run${t.subscriptionRunCount===1?"":"s"}`:"0 subscription runs"," · ",de(s)," this week"]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Billing types"}),e.jsx("div",{className:"space-y-1.5",children:l.map(([d,m])=>e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:ji(d)}),e.jsx("span",{className:"font-medium tabular-nums",children:de(m)})]},d))})]})]}),i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Upstream providers"}),e.jsx("div",{className:"space-y-1.5",children:i.map(d=>e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:Xt(d.provider)}),e.jsxs("div",{className:"text-right tabular-nums",children:[e.jsx("div",{className:"font-medium",children:de(d.costCents)}),e.jsxs("div",{className:"text-muted-foreground",children:[He(d.inputTokens+d.outputTokens)," tok"]})]})]},d.provider))})]})]})]})]})}function mf(t){return(t/100).toFixed(2)}function xf(t){const s=Number(t);return!Number.isFinite(s)||s<0?null:Math.round(s*100)}function Ol({incident:t,onRaiseAndResume:s,onKeepPaused:n,isMutating:r}){const[a,i]=c.useState(mf(Math.max(t.amountObserved+1e3,t.amountLimit))),l=xf(a);return e.jsxs(Le,{className:"overflow-hidden border-red-500/20 bg-[linear-gradient(180deg,rgba(255,70,70,0.10),rgba(255,255,255,0.02))]",children:[e.jsx(tt,{className:"px-5 pt-5 pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.22em] text-red-200/80",children:[t.scopeType," hard stop"]}),e.jsx(st,{className:"mt-1 text-base text-red-50",children:t.scopeName}),e.jsxs(jt,{className:"mt-1 text-red-100/70",children:["Spending reached ",de(t.amountObserved)," against a limit of ",de(t.amountLimit),"."]})]}),e.jsx("div",{className:"rounded-full border border-red-400/30 bg-red-500/10 p-2 text-red-200",children:e.jsx(Xm,{className:"h-4 w-4"})})]})}),e.jsxs(qe,{className:"space-y-4 px-5 pb-5 pt-0",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-red-400/20 bg-red-500/10 px-3 py-2 text-sm text-red-50/90",children:[e.jsx(yo,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:t.scopeType==="project"?"Project execution is paused. New work in this project will not start until you resolve the budget incident.":"This scope is paused. New heartbeats will not start until you resolve the budget incident."})]}),e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/60 p-3",children:[e.jsx("label",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:"New budget (USD)"}),e.jsxs("div",{className:"mt-2 flex flex-col gap-3 sm:flex-row",children:[e.jsx(Vt,{value:a,onChange:o=>i(o.target.value),inputMode:"decimal",placeholder:"0.00"}),e.jsxs(F,{className:"gap-2",disabled:r||l===null||l<=t.amountObserved,onClick:()=>{typeof l=="number"&&s(l)},children:[e.jsx(Er,{className:"h-4 w-4"}),r?"Applying...":"Raise budget & resume"]})]}),l!==null&&l<=t.amountObserved?e.jsx("p",{className:"mt-2 text-xs text-red-200/80",children:"The new budget must exceed current observed spend."}):null]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{variant:"ghost",className:"text-muted-foreground",disabled:r,onClick:n,children:"Keep paused"})})]})]})}function pf({row:t}){return e.jsxs(Le,{children:[e.jsx(tt,{className:"px-4 pt-4 pb-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(st,{className:"text-base",children:Xt(t.biller)}),e.jsxs(jt,{className:"mt-1 text-xs",children:[t.eventCount," event",t.eventCount===1?"":"s"," across ",t.kindCount," kind",t.kindCount===1?"":"s"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-lg font-semibold tabular-nums",children:de(t.netCents)}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-muted-foreground",children:"net"})]})]})}),e.jsx(qe,{className:"space-y-3 px-4 pb-4 pt-3",children:e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-3",children:[e.jsxs("div",{className:"border border-border p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:"debits"}),e.jsx("div",{className:"mt-1 font-medium tabular-nums",children:de(t.debitCents)})]}),e.jsxs("div",{className:"border border-border p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:"credits"}),e.jsx("div",{className:"mt-1 font-medium tabular-nums",children:de(t.creditCents)})]}),e.jsxs("div",{className:"border border-border p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:"estimated"}),e.jsx("div",{className:"mt-1 font-medium tabular-nums",children:de(t.estimatedDebitCents)})]})]})})]})}function hf({rows:t}){return e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-4 pt-4 pb-1",children:[e.jsx(st,{className:"text-base",children:"Financial event mix"}),e.jsx(jt,{children:"Account-level charges grouped by event kind."})]}),e.jsx(qe,{className:"space-y-2 px-4 pb-4 pt-3",children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No finance events in this period."}):t.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:Io(s.eventKind)}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.eventCount," event",s.eventCount===1?"":"s"," · ",s.billerCount," biller",s.billerCount===1?"":"s"]})]}),e.jsxs("div",{className:"text-right tabular-nums",children:[e.jsx("div",{className:"text-sm font-medium",children:de(s.netCents)}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[de(s.debitCents)," debits"]})]})]},s.eventKind))})]})}function Ll({rows:t,emptyMessage:s="No financial events in this period."}){return e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-4 pt-4 pb-1",children:[e.jsx(st,{className:"text-base",children:"Recent financial events"}),e.jsx(jt,{children:"Top-ups, fees, credits, commitments, and other non-request charges."})]}),e.jsx(qe,{className:"space-y-3 px-4 pb-4 pt-3",children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:s}):t.map(n=>e.jsx("div",{className:"border border-border p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",children:Io(n.eventKind)}),e.jsx(Ce,{variant:n.direction==="credit"?"outline":"secondary",children:Jd(n.direction)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:sa(n.occurredAt)})]}),e.jsxs("div",{className:"text-sm font-medium",children:[Xt(n.biller),n.provider?` -> ${Xt(n.provider)}`:"",n.model?e.jsx("span",{className:"ml-1 font-mono text-xs text-muted-foreground",children:n.model}):null]}),(n.description||n.externalInvoiceId||n.region||n.pricingTier)&&e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[n.description?e.jsx("div",{children:n.description}):null,n.externalInvoiceId?e.jsxs("div",{children:["invoice ",n.externalInvoiceId]}):null,n.region?e.jsxs("div",{children:["region ",n.region]}):null,n.pricingTier?e.jsxs("div",{children:["tier ",n.pricingTier]}):null]})]}),e.jsxs("div",{className:"text-right tabular-nums",children:[e.jsx("div",{className:"text-sm font-semibold",children:de(n.amountCents)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:n.currency}),n.estimated?e.jsx("div",{className:"text-[11px] uppercase tracking-[0.12em] text-amber-600",children:"estimated"}):null]})]})},n.id))})]})}const yr=["currentsession","currentweekallmodels","currentweeksonnetonly","currentweeksonnet","currentweekopusonly","currentweekopus","extrausage"];function ni(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"")}function gf(t){return typeof t.detail=="string"&&t.detail.trim().length>0?t.detail.trim():t.resetsAt?`Resets ${new Date(t.resetsAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}`:null}function ff(t){return[...t].sort((s,n)=>{const r=yr.indexOf(ni(s.label)),a=yr.indexOf(ni(n.label));return(r===-1?yr.length:r)-(a===-1?yr.length:a)})}function bf(t){return t==null?"bg-zinc-700":t>=90?"bg-red-400":t>=70?"bg-amber-400":"bg-primary/70"}function jf({windows:t,source:s=null,error:n=null}){const r=ff(t);return e.jsxs("div",{className:"border border-border px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.2em] text-muted-foreground",children:"Anthropic subscription"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Live Claude quota windows."})]}),s?e.jsx("span",{className:"shrink-0 border border-border px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:vi(s)}):null]}),n?e.jsx("div",{className:"mt-4 border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:n}):null,e.jsx("div",{className:"mt-4 space-y-4",children:r.map(a=>{const i=ni(a.label),l=gf(a);if(i==="extrausage")return e.jsxs("div",{className:"border border-border px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:a.label}),a.valueLabel?e.jsx("div",{className:"text-sm font-medium text-foreground",children:a.valueLabel}):null]}),l?e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:l}):null]},a.label);const o=Math.min(100,Math.max(0,a.usedPercent??0));return e.jsxs("div",{className:"border border-border px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:a.label}),l?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l}):null]}),a.usedPercent!=null?e.jsxs("div",{className:"shrink-0 text-sm font-semibold tabular-nums text-foreground",children:[a.usedPercent,"% used"]}):null]}),e.jsx("div",{className:"mt-3 h-2 overflow-hidden bg-muted",children:e.jsx("div",{className:z("h-full transition-[width] duration-200",bf(a.usedPercent)),style:{width:`${o}%`}})})]},a.label)})})]})}const Nr=["5hlimit","weeklylimit","credits"];function ri(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"")}function vf(t){return[...t].sort((s,n)=>{const r=ri(s.label).replace(/^gpt53codexspark/,""),a=ri(n.label).replace(/^gpt53codexspark/,""),i=Nr.indexOf(r),l=Nr.indexOf(a);return(i===-1?Nr.length:i)-(l===-1?Nr.length:l)})}function yf(t){return typeof t.detail=="string"&&t.detail.trim().length>0?t.detail.trim():t.resetsAt?`Resets ${new Date(t.resetsAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}`:null}function Nf(t){return t==null?"bg-zinc-700":t>=90?"bg-red-400":t>=70?"bg-amber-400":"bg-primary/70"}function ql(t){const s=ri(t);return s.includes("gpt53codexspark")||s.includes("gpt5")}function wf({windows:t,source:s=null,error:n=null}){const r=vf(t),a=r.filter(l=>!ql(l.label)),i=r.filter(l=>ql(l.label));return e.jsxs("div",{className:"border border-border px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.2em] text-muted-foreground",children:"Codex subscription"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Live Codex quota windows."})]}),s?e.jsx("span",{className:"shrink-0 border border-border px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:vi(s)}):null]}),n?e.jsx("div",{className:"mt-4 border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:n}):null,e.jsxs("div",{className:"mt-4 space-y-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Account windows"}),e.jsx("div",{className:"space-y-3",children:a.map(l=>e.jsx(Bl,{window:l},l.label))})]}),i.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Model windows"}),e.jsx("div",{className:"space-y-3",children:i.map(l=>e.jsx(Bl,{window:l},l.label))})]}):null]})]})}function Bl({window:t}){const s=yf(t);return t.usedPercent==null?e.jsxs("div",{className:"border border-border px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t.label}),t.valueLabel?e.jsx("div",{className:"text-sm font-semibold tabular-nums text-foreground",children:t.valueLabel}):null]}),s?e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:s}):null]}):e.jsxs("div",{className:"border border-border px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t.label}),s?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s}):null]}),e.jsxs("div",{className:"shrink-0 text-sm font-semibold tabular-nums text-foreground",children:[t.usedPercent,"% used"]})]}),e.jsx("div",{className:"mt-3 h-2 overflow-hidden bg-muted",children:e.jsx("div",{className:z("h-full transition-[width] duration-200",Nf(t.usedPercent)),style:{width:`${Math.max(0,Math.min(100,t.usedPercent))}%`}})})]})}const kf=["5h","24h","7d"];function zl({provider:t,rows:s,budgetMonthlyCents:n,totalCompanySpendCents:r,weekSpendCents:a,windowRows:i,showDeficitNotch:l,quotaWindows:o=[],quotaError:u=null,quotaSource:d=null,quotaLoading:m=!1}){const p=c.useMemo(()=>{let M=0,ee=0,L=0,ae=0,oe=0,q=0,H=0;for(const Z of s)M+=Z.inputTokens,ee+=Z.outputTokens,L+=Z.costCents,ae+=Z.apiRunCount,oe+=Z.subscriptionRunCount,q+=Z.subscriptionInputTokens,H+=Z.subscriptionOutputTokens;const I=M+ee,R=q+H,D=I+R;return{totalInputTokens:M,totalOutputTokens:ee,totalTokens:I,totalCostCents:L,totalApiRuns:ae,totalSubRuns:oe,totalSubInputTokens:q,totalSubOutputTokens:H,totalSubTokens:R,subSharePct:D>0?R/D*100:0}},[s]),{totalInputTokens:h,totalOutputTokens:x,totalTokens:y,totalCostCents:N,totalApiRuns:b,totalSubRuns:g,totalSubInputTokens:T,totalSubOutputTokens:k,totalSubTokens:C,subSharePct:f}=p,j=n>0&&r>0?N/r*n:n,v=j>0?Math.min(100,N/j*100):0,U=j>0?j/4.33:0,A=U>0?Math.min(100,a/U*100):0,B=n>0,W=c.useMemo(()=>new Map(i.map(M=>[M.window,M])),[i]),S=c.useMemo(()=>Math.max(...i.map(M=>M.costCents),0),[i]),w=t==="anthropic",te=t==="openai"&&(d==null?void 0:d.startsWith("codex-")),K=(t==="anthropic"||t==="openai")&&(m||o.length>0||u!=null);return e.jsxs(Le,{children:[e.jsx(tt,{className:"px-4 pt-4 pb-0 gap-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(st,{className:"text-sm font-semibold",children:Xt(t)}),e.jsxs(jt,{className:"text-xs mt-0.5",children:[e.jsx("span",{className:"font-mono",children:He(h)})," in"," · ",e.jsx("span",{className:"font-mono",children:He(x)})," out",(b>0||g>0)&&e.jsxs("span",{className:"ml-1.5",children:["·"," ",b>0&&`~${b} api`,b>0&&g>0&&" / ",g>0&&`~${g} sub`," runs"]})]})]}),e.jsx("span",{className:"text-xl font-bold tabular-nums shrink-0",children:de(N)})]})}),e.jsxs(qe,{className:"px-4 pb-4 pt-3 space-y-4",children:[B&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(si,{label:"Period spend",percentUsed:v,leftLabel:de(N),rightLabel:`${Math.round(v)}% of allocation`,showDeficitNotch:l}),e.jsx(si,{label:"This week",percentUsed:A,leftLabel:de(a),rightLabel:`~${de(Math.round(U))} / wk`,showDeficitNotch:A>=100})]}),i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Rolling windows"}),e.jsx("div",{className:"space-y-2.5",children:kf.map(M=>{const ee=W.get(M);if(!ee)return null;const L=ee.costCents,ae=ee.inputTokens+ee.outputTokens,oe=S>0?L/S*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-mono text-muted-foreground w-6 shrink-0",children:M}),e.jsxs("span",{className:"text-muted-foreground font-mono flex-1",children:[He(ae)," tok"]}),e.jsx("span",{className:"font-medium tabular-nums",children:de(L)})]}),e.jsx("div",{className:"h-2 w-full border border-border overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/60 transition-[width] duration-150",style:{width:`${oe}%`}})})]},M)})})]})]}),g>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Subscription"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono text-foreground",children:g})," runs"," · ",C>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-foreground",children:He(C)})," total"," · "]}),e.jsx("span",{className:"font-mono text-foreground",children:He(T)})," in"," · ",e.jsx("span",{className:"font-mono text-foreground",children:He(k)})," out"]}),f>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-full border border-border overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/60 transition-[width] duration-150",style:{width:`${f}%`}})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(f),"% of token usage via subscription"]})]})]})]}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border"}),e.jsx("div",{className:"space-y-3",children:s.map(M=>{const ee=M.inputTokens+M.outputTokens,L=y>0?ee/y*100:0,ae=N>0?M.costCents/N*100:0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-xs text-muted-foreground truncate font-mono block",children:M.model}),e.jsxs("span",{className:"text-[11px] text-muted-foreground truncate block",children:[Xt(M.biller)," · ",ji(M.billingType)]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 tabular-nums text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[He(ee)," tok"]}),e.jsx("span",{className:"font-medium",children:de(M.costCents)})]})]}),e.jsxs("div",{className:"relative h-2 w-full border border-border overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 bg-primary/60 transition-[width] duration-150",style:{width:`${L}%`},title:`${Math.round(L)}% of provider tokens`}),e.jsx("div",{className:"absolute inset-y-0 left-0 bg-primary/85 transition-[width] duration-150",style:{width:`${ae}%`},title:`${Math.round(ae)}% of provider cost`})]})]},`${M.provider}:${M.model}`)})})]}),K&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Subscription quota"}),d&&!w&&!te?e.jsx("span",{className:"text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:vi(d)}):null]}),m?e.jsx(Cf,{}):w?e.jsx(jf,{windows:o,source:d,error:u}):te?e.jsx(wf,{windows:o,source:d,error:u}):e.jsxs(e.Fragment,{children:[u?e.jsx("p",{className:"text-xs text-destructive",children:u}):null,e.jsx("div",{className:"space-y-2.5",children:o.map(M=>{const ee=M.usedPercent==null?null:M.usedPercent>=90?"bg-red-400":M.usedPercent>=70?"bg-yellow-400":"bg-green-400";return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"font-mono text-muted-foreground shrink-0",children:M.label}),e.jsx("span",{className:"flex-1"}),M.valueLabel!=null?e.jsx("span",{className:"font-medium tabular-nums",children:M.valueLabel}):M.usedPercent!=null?e.jsxs("span",{className:"font-medium tabular-nums",children:[M.usedPercent,"% used"]}):null]}),M.usedPercent!=null&&ee!=null&&e.jsx("div",{className:"h-2 w-full border border-border overflow-hidden",children:e.jsx("div",{className:`h-full transition-[width] duration-150 ${ee}`,style:{width:`${M.usedPercent}%`}})}),M.detail?e.jsx("p",{className:"text-xs text-muted-foreground",children:M.detail}):M.resetsAt?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["resets ",new Date(M.resetsAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})]}):null]},M.label)})})]})]})]})]})]})}function Cf(){return e.jsxs("div",{className:"border border-border px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border pb-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx(as,{className:"h-3 w-36"}),e.jsx(as,{className:"h-4 w-64 max-w-full"})]}),e.jsx(as,{className:"h-7 w-28"})]}),e.jsx("div",{className:"mt-4 space-y-3",children:Array.from({length:3}).map((t,s)=>e.jsxs("div",{className:"border border-border px-3.5 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx(as,{className:"h-4 w-32"}),e.jsx(as,{className:"h-3 w-44 max-w-full"})]}),e.jsx(as,{className:"h-4 w-20"})]}),e.jsx(as,{className:"mt-3 h-2 w-full"})]},s))})]})}const Sf={mtd:"Month to Date","7d":"Last 7 Days","30d":"Last 30 Days",ytd:"Year to Date",all:"All Time",custom:"Custom"},If=["mtd","7d","30d","ytd","all","custom"];function Af(t){const s=new Date,n=s.toISOString();switch(t){case"mtd":return{from:new Date(s.getFullYear(),s.getMonth(),1).toISOString(),to:n};case"7d":return{from:new Date(s.getFullYear(),s.getMonth(),s.getDate()-7,0,0,0,0).toISOString(),to:n};case"30d":return{from:new Date(s.getFullYear(),s.getMonth(),s.getDate()-30,0,0,0,0).toISOString(),to:n};case"ytd":return{from:new Date(s.getFullYear(),0,1).toISOString(),to:n};case"all":case"custom":return{from:"",to:""}}}function Ta(t){const s=new Date(t);return s.setSeconds(0,0),s.toISOString()}function Pf(){const[t,s]=c.useState("mtd"),[n,r]=c.useState(""),[a,i]=c.useState(""),l=c.useRef(null),[o,u]=c.useState(()=>Ta(new Date));c.useEffect(()=>{const h=new Date,x=(60-h.getSeconds())*1e3-h.getMilliseconds(),y=setTimeout(()=>{u(Ta(new Date)),l.current=setInterval(()=>u(Ta(new Date)),6e4)},x);return()=>{clearTimeout(y),l.current!=null&&clearInterval(l.current)}},[]);const{from:d,to:m}=c.useMemo(()=>{if(t!=="custom")return Af(t);const h=n?new Date(n+"T00:00:00"):null,x=a?new Date(a+"T23:59:59.999"):null;return{from:h?h.toISOString():"",to:x?x.toISOString():""}},[t,n,a,o]);return{preset:t,setPreset:s,customFrom:n,setCustomFrom:r,customTo:a,setCustomTo:i,from:d,to:m,customReady:t!=="custom"||!!n&&!!a}}const Tf="__none__";function Rf(){const t=new Date,s=t.getDay(),n=s===0?-6:1-s,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()+n,0,0,0,0),a=new Date(r.getFullYear(),r.getMonth(),r.getDate()+6,23,59,59,999);return{from:r.toISOString(),to:a.toISOString()}}function Ef({provider:t,rows:s}){const n=s.reduce((a,i)=>a+i.inputTokens+i.cachedInputTokens+i.outputTokens,0),r=s.reduce((a,i)=>a+i.costCents,0);return e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:Xt(t)}),e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:He(n)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:de(r)})]})}function Mf({biller:t,rows:s}){const n=s.reduce((a,i)=>a+i.inputTokens+i.cachedInputTokens+i.outputTokens,0),r=s.reduce((a,i)=>a+i.costCents,0);return e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:Xt(t)}),e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:He(n)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:de(r)})]})}function zt({label:t,value:s,subtitle:n,icon:r}){return e.jsx("div",{className:"border border-border p-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-muted-foreground",children:t}),e.jsx("div",{className:"mt-2 text-2xl font-semibold tabular-nums",children:s}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:n})]}),e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center border border-border",children:e.jsx(r,{className:"h-4 w-4 text-muted-foreground"})})]})})}function Kl({debitCents:t,creditCents:s,netCents:n,estimatedDebitCents:r,eventCount:a}){return e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-5 pt-5 pb-2",children:[e.jsx(st,{className:"text-base",children:"Finance ledger"}),e.jsx(jt,{children:"Account-level charges that do not map to a single inference request."})]}),e.jsxs(qe,{className:"grid gap-3 px-5 pb-5 pt-2 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(zt,{label:"Debits",value:de(t),subtitle:`${a} total event${a===1?"":"s"} in range`,icon:Er}),e.jsx(zt,{label:"Credits",value:de(s),subtitle:"Refunds, offsets, and credit returns",icon:fm}),e.jsx(zt,{label:"Net",value:de(n),subtitle:"Debit minus credit for the selected period",icon:Ga}),e.jsx(zt,{label:"Estimated",value:de(r),subtitle:"Estimated debits that are not yet invoice-authoritative",icon:Wa})]})]})}function Df(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),n=_e(),[r,a]=c.useState("overview"),[i,l]=c.useState("all"),[o,u]=c.useState("all"),{preset:d,setPreset:m,customFrom:p,setCustomFrom:h,customTo:x,setCustomTo:y,from:N,to:b,customReady:g}=Pf();c.useEffect(()=>{s([{label:"Costs"}])},[s]);const[T,k]=c.useState(()=>new Date().toDateString()),C=c.useRef(null);c.useEffect(()=>{const E=()=>{const X=new Date,_=new Date(X.getFullYear(),X.getMonth(),X.getDate()+1).getTime()-X.getTime();C.current=setTimeout(()=>{k(new Date().toDateString()),E()},_)};return E(),()=>{C.current!=null&&clearTimeout(C.current)}},[]);const f=c.useMemo(()=>Rf(),[T]),j=t??Tf,{data:v,isLoading:U,error:A}=Q({queryKey:P.budgets.overview(j),queryFn:()=>zn.overview(j),enabled:!!t&&g,refetchInterval:3e4,staleTime:5e3}),B=()=>{t&&(n.invalidateQueries({queryKey:P.budgets.overview(t)}),n.invalidateQueries({queryKey:P.dashboard(t)}),n.invalidateQueries({queryKey:P.agents.list(t)}),n.invalidateQueries({queryKey:P.projects.list(t)}))},W=re({mutationFn:E=>zn.upsertPolicy(j,{scopeType:E.scopeType,scopeId:E.scopeId,amount:E.amount,windowKind:E.windowKind}),onSuccess:B}),S=re({mutationFn:E=>zn.resolveIncident(j,E.incidentId,E),onSuccess:B}),{data:w,isLoading:te,error:G}=Q({queryKey:P.costs(j,N||void 0,b||void 0),queryFn:async()=>{const[E,X,_,J]=await Promise.all([It.summary(j,N||void 0,b||void 0),It.byAgent(j,N||void 0,b||void 0),It.byProject(j,N||void 0,b||void 0),It.byAgentModel(j,N||void 0,b||void 0)]);return{summary:E,byAgent:X,byProject:_,byAgentModel:J}},enabled:!!t&&g}),{data:K,isLoading:M,error:ee}=Q({queryKey:[P.financeSummary(j,N||void 0,b||void 0),P.financeByBiller(j,N||void 0,b||void 0),P.financeByKind(j,N||void 0,b||void 0),P.financeEvents(j,N||void 0,b||void 0,18)],queryFn:async()=>{const[E,X,_,J]=await Promise.all([It.financeSummary(j,N||void 0,b||void 0),It.financeByBiller(j,N||void 0,b||void 0),It.financeByKind(j,N||void 0,b||void 0),It.financeEvents(j,N||void 0,b||void 0,18)]);return{summary:E,byBiller:X,byKind:_,events:J}},enabled:!!t&&g}),[L,ae]=c.useState(new Set);c.useEffect(()=>{ae(new Set)},[j,N,b]);function oe(E){ae(X=>{const _=new Set(X);return _.has(E)?_.delete(E):_.add(E),_})}const q=c.useMemo(()=>{const E=new Map;for(const X of(w==null?void 0:w.byAgentModel)??[]){const _=E.get(X.agentId)??[];_.push(X),E.set(X.agentId,_)}for(const[X,_]of E)E.set(X,_.slice().sort((J,le)=>le.costCents-J.costCents));return E},[w==null?void 0:w.byAgentModel]),{data:H}=Q({queryKey:P.usageByProvider(j,N||void 0,b||void 0),queryFn:()=>It.byProvider(j,N||void 0,b||void 0),enabled:!!t&&g&&(r==="providers"||r==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:I}=Q({queryKey:P.usageByBiller(j,N||void 0,b||void 0),queryFn:()=>It.byBiller(j,N||void 0,b||void 0),enabled:!!t&&g&&r==="billers",refetchInterval:3e4,staleTime:1e4}),{data:R}=Q({queryKey:P.usageByProvider(j,f.from,f.to),queryFn:()=>It.byProvider(j,f.from,f.to),enabled:!!t&&(r==="providers"||r==="billers"),refetchInterval:3e4,staleTime:1e4}),{data:D}=Q({queryKey:P.usageByBiller(j,f.from,f.to),queryFn:()=>It.byBiller(j,f.from,f.to),enabled:!!t&&r==="billers",refetchInterval:3e4,staleTime:1e4}),{data:Z}=Q({queryKey:P.usageWindowSpend(j),queryFn:()=>It.windowSpend(j),enabled:!!t&&r==="providers",refetchInterval:3e4,staleTime:1e4}),{data:me,isLoading:xe}=Q({queryKey:P.usageQuotaWindows(j),queryFn:()=>It.quotaWindows(j),enabled:!!t&&r==="providers",refetchInterval:3e5,staleTime:6e4}),$=c.useMemo(()=>{const E=new Map;for(const X of H??[]){const _=E.get(X.provider)??[];_.push(X),E.set(X.provider,_)}return E},[H]),ce=c.useMemo(()=>{const E=new Map;for(const X of I??[]){const _=E.get(X.biller)??[];_.push(X),E.set(X.biller,_)}return E},[I]),ue=c.useMemo(()=>{const E=new Map;for(const X of R??[])E.set(X.provider,(E.get(X.provider)??0)+X.costCents);return E},[R]),Re=c.useMemo(()=>{const E=new Map;for(const X of D??[])E.set(X.biller,(E.get(X.biller)??0)+X.costCents);return E},[D]),De=c.useMemo(()=>{const E=new Map;for(const X of Z??[]){const _=E.get(X.provider)??[];_.push(X),E.set(X.provider,_)}return E},[Z]),We=c.useMemo(()=>{const E=new Map;for(const X of me??[])X.ok&&X.windows.length>0&&E.set(X.provider,X.windows);return E},[me]),xt=c.useMemo(()=>{const E=new Map;for(const X of me??[])!X.ok&&X.error&&E.set(X.provider,X.error);return E},[me]),Ct=c.useMemo(()=>{const E=new Map;for(const X of me??[])typeof X.source=="string"&&X.source.length>0&&E.set(X.provider,X.source);return E},[me]),V=c.useMemo(()=>{const E=new Map;if(d!=="mtd")return E;const X=(w==null?void 0:w.summary.budgetCents)??0;if(X<=0)return E;const _=(w==null?void 0:w.summary.spendCents)??0,J=new Date,le=J.getDate(),we=new Date(J.getFullYear(),J.getMonth()+1,0).getDate();for(const[$e,at]of $){const Rn=at.reduce((ts,St)=>ts+St.costCents,0),Xe=_>0?Rn/_:0,dt=X*Xe;if(dt<=0){E.set($e,!1);continue}const ht=Rn/Math.max(le,1);E.set($e,Rn+ht*(we-le)>dt)}return E},[d,w,$]),pe=c.useMemo(()=>Array.from($.keys()),[$]),ye=c.useMemo(()=>Array.from(ce.keys()),[ce]),Ee=i==="all"||pe.includes(i)?i:"all";c.useEffect(()=>{Ee!==i&&l("all")},[Ee,i]);const Be=o==="all"||ye.includes(o)?o:"all";c.useEffect(()=>{Be!==o&&u("all")},[Be,o]);const Ot=c.useMemo(()=>{const E=Array.from($.keys()),X=E.reduce((J,le)=>{var we;return J+(((we=$.get(le))==null?void 0:we.reduce(($e,at)=>$e+at.inputTokens+at.cachedInputTokens+at.outputTokens,0))??0)},0),_=E.reduce((J,le)=>{var we;return J+(((we=$.get(le))==null?void 0:we.reduce(($e,at)=>$e+at.costCents,0))??0)},0);return[{value:"all",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"All providers"}),E.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:He(X)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:de(_)})]}):null]})},...E.map(J=>({value:J,label:e.jsx(Ef,{provider:J,rows:$.get(J)??[]})}))]},[$]),O=c.useMemo(()=>{const E=Array.from(ce.keys()),X=E.reduce((J,le)=>{var we;return J+(((we=ce.get(le))==null?void 0:we.reduce(($e,at)=>$e+at.inputTokens+at.cachedInputTokens+at.outputTokens,0))??0)},0),_=E.reduce((J,le)=>{var we;return J+(((we=ce.get(le))==null?void 0:we.reduce(($e,at)=>$e+at.costCents,0))??0)},0);return[{value:"all",label:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"All billers"}),E.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:He(X)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:de(_)})]}):null]})},...E.map(J=>({value:J,label:e.jsx(Mf,{biller:J,rows:ce.get(J)??[]})}))]},[ce]),ne=((w==null?void 0:w.byAgent)??[]).reduce((E,X)=>E+X.inputTokens+X.cachedInputTokens+X.outputTokens,0),ie=(K==null?void 0:K.events)??[],se=(v==null?void 0:v.policies)??[],ve=(v==null?void 0:v.activeIncidents)??[],ze=c.useMemo(()=>({company:se.filter(E=>E.scopeType==="company"),agent:se.filter(E=>E.scopeType==="agent"),project:se.filter(E=>E.scopeType==="project")}),[se]);if(!t)return e.jsx(rt,{icon:ls,message:"Select a company to view costs."});const pt=d==="custom"&&!g,Qe=(te||M)&&g,xs=G??ee;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Costs"}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-muted-foreground",children:"Inference spend, platform fees, credits, and live quota windows."})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:If.map(E=>e.jsx(F,{variant:d===E?"secondary":"ghost",size:"sm",onClick:()=>m(E),children:Sf[E]},E))})]}),d==="custom"?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border border-border p-3",children:[e.jsx("input",{type:"date",value:p,onChange:E=>h(E.target.value),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx("input",{type:"date",value:x,onChange:E=>y(E.target.value),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground"})]}):null,e.jsxs("div",{className:"grid gap-3 lg:grid-cols-4",children:[e.jsx(zt,{label:"Inference spend",value:de((w==null?void 0:w.summary.spendCents)??0),subtitle:`${He(ne)} tokens across request-scoped events`,icon:ls}),e.jsx(zt,{label:"Budget",value:ve.length>0?String(ve.length):w!=null&&w.summary.budgetCents&&w.summary.budgetCents>0?`${w.summary.utilizationPercent}%`:"Open",subtitle:ve.length>0?`${(v==null?void 0:v.pausedAgentCount)??0} agents paused · ${(v==null?void 0:v.pausedProjectCount)??0} projects paused`:w!=null&&w.summary.budgetCents&&w.summary.budgetCents>0?`${de(w.summary.spendCents)} of ${de(w.summary.budgetCents)}`:"No monthly cap configured",icon:Wa}),e.jsx(zt,{label:"Finance net",value:de((K==null?void 0:K.summary.netCents)??0),subtitle:`${de((K==null?void 0:K.summary.debitCents)??0)} debits · ${de((K==null?void 0:K.summary.creditCents)??0)} credits`,icon:Ga}),e.jsx(zt,{label:"Finance events",value:String((K==null?void 0:K.summary.eventCount)??0),subtitle:`${de((K==null?void 0:K.summary.estimatedDebitCents)??0)} estimated in range`,icon:Er})]})]}),e.jsxs(Yt,{value:r,onValueChange:E=>a(E),children:[e.jsxs(Rr,{variant:"line",className:"justify-start",children:[e.jsx(Pt,{value:"overview",children:"Overview"}),e.jsx(Pt,{value:"budgets",children:"Budgets"}),e.jsx(Pt,{value:"providers",children:"Providers"}),e.jsx(Pt,{value:"billers",children:"Billers"}),e.jsx(Pt,{value:"finance",children:"Finance"})]}),e.jsx(Ke,{value:"overview",className:"mt-4 space-y-4",children:pt?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):Qe?e.jsx(ot,{variant:"costs"}):xs?e.jsx("p",{className:"text-sm text-destructive",children:xs.message}):e.jsxs(e.Fragment,{children:[ve.length>0?e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:ve.slice(0,2).map(E=>e.jsx(Ol,{incident:E,isMutating:S.isPending,onKeepPaused:()=>S.mutate({incidentId:E.id,action:"keep_paused"}),onRaiseAndResume:X=>S.mutate({incidentId:E.id,action:"raise_budget_and_resume",amount:X})},E.id))}):null,e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[1.3fr,1fr]",children:[e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-5 pt-5 pb-2",children:[e.jsx(st,{className:"text-base",children:"Inference ledger"}),e.jsx(jt,{children:"Request-scoped inference spend for the selected period."})]}),e.jsxs(qe,{className:"space-y-4 px-5 pb-5 pt-2",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-semibold tabular-nums",children:de((w==null?void 0:w.summary.spendCents)??0)}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:w!=null&&w.summary.budgetCents&&w.summary.budgetCents>0?`Budget ${de(w.summary.budgetCents)}`:"Unlimited budget"})]}),e.jsxs("div",{className:"border border-border px-4 py-3 text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:"usage"}),e.jsx("div",{className:"mt-1 text-lg font-medium tabular-nums",children:He(ne)})]})]}),w!=null&&w.summary.budgetCents&&w.summary.budgetCents>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 overflow-hidden bg-muted",children:e.jsx("div",{className:z("h-full transition-[width,background-color] duration-150",w.summary.utilizationPercent>90?"bg-red-400":w.summary.utilizationPercent>70?"bg-yellow-400":"bg-emerald-400"),style:{width:`${Math.min(100,w.summary.utilizationPercent)}%`}})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[w.summary.utilizationPercent,"% of monthly budget consumed in this range."]})]}):null]})]}),e.jsx(Kl,{debitCents:(K==null?void 0:K.summary.debitCents)??0,creditCents:(K==null?void 0:K.summary.creditCents)??0,netCents:(K==null?void 0:K.summary.netCents)??0,estimatedDebitCents:(K==null?void 0:K.summary.estimatedDebitCents)??0,eventCount:(K==null?void 0:K.summary.eventCount)??0})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[1.25fr,0.95fr]",children:[e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-5 pt-5 pb-2",children:[e.jsx(st,{className:"text-base",children:"By agent"}),e.jsx(jt,{children:"What each agent consumed in the selected period."})]}),e.jsx(qe,{className:"space-y-2 px-5 pb-5 pt-2",children:((w==null?void 0:w.byAgent.length)??0)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No cost events yet."}):w==null?void 0:w.byAgent.map(E=>{const X=q.get(E.agentId)??[],_=L.has(E.agentId),J=X.length>0;return e.jsxs("div",{className:"border border-border px-4 py-3",children:[e.jsxs("div",{className:z("flex items-start justify-between gap-3",J?"cursor-pointer select-none":""),onClick:()=>J&&oe(E.agentId),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[J?_?e.jsx($s,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(Ns,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx("span",{className:"h-3 w-3 shrink-0"}),e.jsx(Ue,{name:E.agentName??E.agentId,size:"sm"}),E.agentStatus==="terminated"?e.jsx(Pe,{status:"terminated"}):null]}),e.jsxs("div",{className:"text-right text-sm tabular-nums",children:[e.jsx("div",{className:"font-medium",children:de(E.costCents)}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["in ",He(E.inputTokens+E.cachedInputTokens)," · out ",He(E.outputTokens)]}),E.apiRunCount>0||E.subscriptionRunCount>0?e.jsxs("div",{className:"text-xs text-muted-foreground",children:[E.apiRunCount>0?`${E.apiRunCount} api`:"0 api"," · ",E.subscriptionRunCount>0?`${E.subscriptionRunCount} subscription`:"0 subscription"]}):null]})]}),_&&X.length>0?e.jsx("div",{className:"mt-3 space-y-2 border-l border-border pl-4",children:X.map(le=>{const we=E.costCents>0?Math.round(le.costCents/E.costCents*100):0;return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-xs",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate font-medium text-foreground",children:[Xt(le.provider),e.jsx("span",{className:"mx-1 text-border",children:"/"}),e.jsx("span",{className:"font-mono",children:le.model})]}),e.jsxs("div",{className:"truncate text-muted-foreground",children:[Xt(le.biller)," · ",ji(le.billingType)]})]}),e.jsxs("div",{className:"text-right tabular-nums",children:[e.jsxs("div",{className:"font-medium",children:[de(le.costCents),e.jsxs("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",we,"%)"]})]}),e.jsxs("div",{className:"text-muted-foreground",children:[He(le.inputTokens+le.cachedInputTokens+le.outputTokens)," tok"]})]})]},`${le.provider}:${le.model}:${le.billingType}`)})}):null]},E.agentId)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-5 pt-5 pb-2",children:[e.jsx(st,{className:"text-base",children:"By project"}),e.jsx(jt,{children:"Run costs attributed through project-linked issues."})]}),e.jsx(qe,{className:"space-y-2 px-5 pb-5 pt-2",children:((w==null?void 0:w.byProject.length)??0)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No project-attributed run costs yet."}):w==null?void 0:w.byProject.map((E,X)=>e.jsxs("div",{className:"flex items-center justify-between gap-3 border border-border px-3 py-2 text-sm",children:[e.jsx("span",{className:"truncate",children:E.projectName??E.projectId??"Unattributed"}),e.jsx("span",{className:"font-medium tabular-nums",children:de(E.costCents)})]},E.projectId??`unattributed-${X}`))})]}),e.jsx(Ll,{rows:ie.slice(0,6),emptyMessage:"No finance events yet. Add account-level charges once biller invoices or credits land."})]})]})]})}),e.jsx(Ke,{value:"budgets",className:"mt-4 space-y-4",children:U?e.jsx(ot,{variant:"costs"}):A?e.jsx("p",{className:"text-sm text-destructive",children:A.message}):e.jsxs(e.Fragment,{children:[e.jsxs(Le,{className:"border-border/70 bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.02))]",children:[e.jsxs(tt,{className:"px-5 pt-5 pb-3",children:[e.jsx(st,{className:"text-base",children:"Budget control plane"}),e.jsx(jt,{children:"Hard-stop spend limits for agents and projects. Provider subscription quota stays separate and appears under Providers."})]}),e.jsxs(qe,{className:"grid gap-3 px-5 pb-5 pt-0 md:grid-cols-4",children:[e.jsx(zt,{label:"Active incidents",value:String(ve.length),subtitle:"Open soft or hard threshold crossings",icon:Ga}),e.jsx(zt,{label:"Pending approvals",value:String((v==null?void 0:v.pendingApprovalCount)??0),subtitle:"Budget override approvals awaiting board action",icon:Er}),e.jsx(zt,{label:"Paused agents",value:String((v==null?void 0:v.pausedAgentCount)??0),subtitle:"Agent heartbeats blocked by budget",icon:Wa}),e.jsx(zt,{label:"Paused projects",value:String((v==null?void 0:v.pausedProjectCount)??0),subtitle:"Project execution blocked by budget",icon:ls})]})]}),ve.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Active incidents"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Resolve hard stops here by raising the budget or explicitly keeping the scope paused."})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:ve.map(E=>e.jsx(Ol,{incident:E,isMutating:S.isPending,onKeepPaused:()=>S.mutate({incidentId:E.id,action:"keep_paused"}),onRaiseAndResume:X=>S.mutate({incidentId:E.id,action:"raise_budget_and_resume",amount:X})},E.id))})]}):null,e.jsxs("div",{className:"space-y-5",children:[["company","agent","project"].map(E=>{const X=ze[E];return X.length===0?null:e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold capitalize",children:[E," budgets"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:E==="company"?"Company-wide monthly policy.":E==="agent"?"Recurring monthly spend policies for individual agents.":"Lifetime spend policies for execution-bound projects."})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:X.map(_=>e.jsx(Co,{summary:_,isSaving:W.isPending,onSave:J=>W.mutate({scopeType:_.scopeType,scopeId:_.scopeId,amount:J,windowKind:_.windowKind})},_.policyId))})]},E)}),se.length===0?e.jsx(Le,{children:e.jsx(qe,{className:"px-5 py-8 text-sm text-muted-foreground",children:"No budget policies yet. Set agent and project budgets from their detail pages, or use the existing company monthly budget control."})}):null]})]})}),e.jsx(Ke,{value:"providers",className:"mt-4 space-y-4",children:pt?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):e.jsx(e.Fragment,{children:e.jsxs(Yt,{value:Ee,onValueChange:l,children:[e.jsx(Gs,{items:Ot,value:Ee}),e.jsx(Ke,{value:"all",className:"mt-4",children:pe.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No cost events in this period."}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:pe.map(E=>e.jsx(zl,{provider:E,rows:$.get(E)??[],budgetMonthlyCents:(w==null?void 0:w.summary.budgetCents)??0,totalCompanySpendCents:(w==null?void 0:w.summary.spendCents)??0,weekSpendCents:ue.get(E)??0,windowRows:De.get(E)??[],showDeficitNotch:V.get(E)??!1,quotaWindows:We.get(E)??[],quotaError:xt.get(E)??null,quotaSource:Ct.get(E)??null,quotaLoading:xe},E))})}),pe.map(E=>e.jsx(Ke,{value:E,className:"mt-4",children:e.jsx(zl,{provider:E,rows:$.get(E)??[],budgetMonthlyCents:(w==null?void 0:w.summary.budgetCents)??0,totalCompanySpendCents:(w==null?void 0:w.summary.spendCents)??0,weekSpendCents:ue.get(E)??0,windowRows:De.get(E)??[],showDeficitNotch:V.get(E)??!1,quotaWindows:We.get(E)??[],quotaError:xt.get(E)??null,quotaSource:Ct.get(E)??null,quotaLoading:xe})},E))]})})}),e.jsx(Ke,{value:"billers",className:"mt-4 space-y-4",children:pt?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):e.jsx(e.Fragment,{children:e.jsxs(Yt,{value:Be,onValueChange:u,children:[e.jsx(Gs,{items:O,value:Be}),e.jsx(Ke,{value:"all",className:"mt-4",children:ye.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No billable events in this period."}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:ye.map(E=>{const X=(ce.get(E)??[])[0];if(!X)return null;const _=(H??[]).filter(J=>J.biller===E);return e.jsx($l,{row:X,weekSpendCents:Re.get(E)??0,budgetMonthlyCents:(w==null?void 0:w.summary.budgetCents)??0,totalCompanySpendCents:(w==null?void 0:w.summary.spendCents)??0,providerRows:_},E)})})}),ye.map(E=>{const X=(ce.get(E)??[])[0];if(!X)return null;const _=(H??[]).filter(J=>J.biller===E);return e.jsx(Ke,{value:E,className:"mt-4",children:e.jsx($l,{row:X,weekSpendCents:Re.get(E)??0,budgetMonthlyCents:(w==null?void 0:w.summary.budgetCents)??0,totalCompanySpendCents:(w==null?void 0:w.summary.spendCents)??0,providerRows:_})},E)})]})})}),e.jsx(Ke,{value:"finance",className:"mt-4 space-y-4",children:pt?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a start and end date to load data."}):M?e.jsx(ot,{variant:"costs"}):ee?e.jsx("p",{className:"text-sm text-destructive",children:ee.message}):e.jsxs(e.Fragment,{children:[e.jsx(Kl,{debitCents:(K==null?void 0:K.summary.debitCents)??0,creditCents:(K==null?void 0:K.summary.creditCents)??0,netCents:(K==null?void 0:K.summary.netCents)??0,estimatedDebitCents:(K==null?void 0:K.summary.estimatedDebitCents)??0,eventCount:(K==null?void 0:K.summary.eventCount)??0}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[1.2fr,0.95fr]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Le,{children:[e.jsxs(tt,{className:"px-5 pt-5 pb-2",children:[e.jsx(st,{className:"text-base",children:"By biller"}),e.jsx(jt,{children:"Account-level financial events grouped by who charged or credited them."})]}),e.jsx(qe,{className:"grid gap-4 px-5 pb-5 pt-2 md:grid-cols-2",children:((K==null?void 0:K.byBiller.length)??0)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No finance events yet."}):K==null?void 0:K.byBiller.map(E=>e.jsx(pf,{row:E},E.biller))})]}),e.jsx(Ll,{rows:ie})]}),e.jsx(hf,{rows:(K==null?void 0:K.byKind)??[]})]})]})})]})]})}function yn({...t}){return e.jsx(Yd,{"data-slot":"select",...t})}function Nn({...t}){return e.jsx(eu,{"data-slot":"select-value",...t})}function wn({className:t,size:s="default",children:n,...r}){return e.jsxs(Xd,{"data-slot":"select-trigger","data-size":s,className:z("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,e.jsx(Zd,{asChild:!0,children:e.jsx($s,{className:"size-4 opacity-50"})})]})}function kn({className:t,children:s,position:n="item-aligned",align:r="center",...a}){return e.jsx(tu,{children:e.jsxs(su,{"data-slot":"select-content",className:z("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,align:r,...a,children:[e.jsx(_f,{}),e.jsx(nu,{className:z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:s}),e.jsx(Ff,{})]})})}function Oe({className:t,children:s,...n}){return e.jsxs(ru,{"data-slot":"select-item",className:z("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[e.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(au,{children:e.jsx(Qt,{className:"size-4"})})}),e.jsx(iu,{children:s})]})}function _f({className:t,...s}){return e.jsx(lu,{"data-slot":"select-scroll-up-button",className:z("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(yi,{className:"size-4"})})}function Ff({className:t,...s}){return e.jsx(ou,{"data-slot":"select-scroll-down-button",className:z("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx($s,{className:"size-4"})})}function $f(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),[n,r]=c.useState("all");c.useEffect(()=>{s([{label:"Activity"}])},[s]);const{data:a,isLoading:i,error:l}=Q({queryKey:P.activity(t),queryFn:()=>No.list(t),enabled:!!t}),{data:o}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t}),{data:u}=Q({queryKey:P.issues.list(t),queryFn:()=>Ve.list(t),enabled:!!t}),{data:d}=Q({queryKey:P.projects.list(t),queryFn:()=>mt.list(t),enabled:!!t}),{data:m}=Q({queryKey:P.goals.list(t),queryFn:()=>_t.list(t),enabled:!!t}),p=c.useMemo(()=>{const b=new Map;for(const g of o??[])b.set(g.id,g);return b},[o]),h=c.useMemo(()=>{const b=new Map;for(const g of u??[])b.set(`issue:${g.id}`,g.identifier??g.id.slice(0,8));for(const g of o??[])b.set(`agent:${g.id}`,g.name);for(const g of d??[])b.set(`project:${g.id}`,g.name);for(const g of m??[])b.set(`goal:${g.id}`,g.title);return b},[u,o,d,m]),x=c.useMemo(()=>{const b=new Map;for(const g of u??[])b.set(`issue:${g.id}`,g.title);return b},[u]);if(!t)return e.jsx(rt,{icon:Jn,message:"Select a company to view activity."});if(i)return e.jsx(ot,{variant:"list"});const y=a&&n!=="all"?a.filter(b=>b.entityType===n):a,N=a?[...new Set(a.map(b=>b.entityType))].sort():[];return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs(yn,{value:n,onValueChange:r,children:[e.jsx(wn,{className:"w-[140px] h-8 text-xs",children:e.jsx(Nn,{placeholder:"Filter by type"})}),e.jsxs(kn,{children:[e.jsx(Oe,{value:"all",children:"All types"}),N.map(b=>e.jsx(Oe,{value:b,children:b.charAt(0).toUpperCase()+b.slice(1)},b))]})]})}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l.message}),y&&y.length===0&&e.jsx(rt,{icon:Jn,message:"No activity yet."}),y&&y.length>0&&e.jsx("div",{className:"border border-border divide-y divide-border",children:y.map(b=>e.jsx(Ec,{event:b,agentMap:p,entityNameMap:h,entityTitleMap:x},b.id))})]})}function Ul(t){return t?t.split(`
|
|
197
|
+
`).map(n=>n.trim()).find(Boolean)??null:null}function Of(t){return Ul(t.error)??Ul(t.stderrExcerpt)??"Run exited with an error."}function Lf(t){return t.replaceAll("_"," ")}function Uc(t){const s=t.contextSnapshot;if(!s)return null;const n=s.issueId;if(typeof n=="string"&&n.length>0)return n;const r=s.taskId;return typeof r=="string"&&r.length>0?r:null}function qf({run:t,issueById:s,agentName:n,issueLinkState:r,onDismiss:a,onRetry:i,isRetrying:l}){const o=Uc(t),u=o?s.get(o)??null:null,d=Of(t);return e.jsxs("div",{className:"group border-b border-border px-2 py-2.5 last:border-b-0 sm:px-1 sm:pr-3 sm:py-2",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:items-center",children:[e.jsxs(he,{to:`/agents/${t.agentId}/runs/${t.id}`,className:"flex min-w-0 flex-1 items-start gap-2 no-underline text-inherit transition-colors hover:bg-accent/50",children:[e.jsx("span",{className:"hidden h-2 w-2 shrink-0 sm:inline-flex","aria-hidden":"true"}),e.jsx("span",{className:"hidden h-3.5 w-3.5 shrink-0 sm:inline-flex","aria-hidden":"true"}),e.jsx("span",{className:"mt-0.5 shrink-0 rounded-md bg-red-500/20 p-1.5 sm:mt-0",children:e.jsx(bi,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"line-clamp-2 text-sm font-medium sm:truncate sm:line-clamp-none",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-muted-foreground mr-1.5",children:u.identifier??u.id.slice(0,8)}),u.title]}):e.jsxs(e.Fragment,{children:["Failed run",n?` — ${n}`:""]})}),e.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[e.jsx(Pe,{status:t.status}),n&&u?e.jsx("span",{children:n}):null,e.jsx("span",{className:"truncate max-w-[300px]",children:d}),e.jsx("span",{children:Ut(t.createdAt)})]})]})]}),e.jsxs("div",{className:"hidden shrink-0 items-center gap-2 sm:flex",children:[e.jsxs(F,{type:"button",variant:"outline",size:"sm",className:"h-8 shrink-0 px-2.5",onClick:i,disabled:l,children:[e.jsx(Yi,{className:"mr-1.5 h-3.5 w-3.5"}),l?"Retrying…":"Retry"]}),e.jsx("button",{type:"button",onClick:a,className:"rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100","aria-label":"Dismiss",children:e.jsx(nt,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-3 flex gap-2 sm:hidden",children:[e.jsxs(F,{type:"button",variant:"outline",size:"sm",className:"h-8 shrink-0 px-2.5",onClick:i,disabled:l,children:[e.jsx(Yi,{className:"mr-1.5 h-3.5 w-3.5"}),l?"Retrying…":"Retry"]}),e.jsx("button",{type:"button",onClick:a,className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":"Dismiss",children:e.jsx(nt,{className:"h-4 w-4"})})]})]})}function Bf({approval:t,requesterName:s,onApprove:n,onReject:r,isPending:a}){const i=zi[t.type]??Ki,l=Bi(t.type,t.payload),o=t.type!=="budget_override_required"&&Lr.has(t.status);return e.jsxs("div",{className:"border-b border-border px-2 py-2.5 last:border-b-0 sm:px-1 sm:pr-3 sm:py-2",children:[e.jsxs("div",{className:"flex items-start gap-2 sm:items-center",children:[e.jsxs(he,{to:`/approvals/${t.id}`,className:"flex min-w-0 flex-1 items-start gap-2 no-underline text-inherit transition-colors hover:bg-accent/50",children:[e.jsx("span",{className:"hidden h-2 w-2 shrink-0 sm:inline-flex","aria-hidden":"true"}),e.jsx("span",{className:"hidden h-3.5 w-3.5 shrink-0 sm:inline-flex","aria-hidden":"true"}),e.jsx("span",{className:"mt-0.5 shrink-0 rounded-md bg-muted p-1.5 sm:mt-0",children:e.jsx(i,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"line-clamp-2 text-sm font-medium sm:truncate sm:line-clamp-none",children:l}),e.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"capitalize",children:Lf(t.status)}),s?e.jsxs("span",{children:["requested by ",s]}):null,e.jsxs("span",{children:["updated ",Ut(t.updatedAt)]})]})]})]}),o?e.jsxs("div",{className:"hidden shrink-0 items-center gap-2 sm:flex",children:[e.jsx(F,{size:"sm",className:"h-8 bg-green-700 px-3 text-white hover:bg-green-600",onClick:n,disabled:a,children:"Approve"}),e.jsx(F,{variant:"destructive",size:"sm",className:"h-8 px-3",onClick:r,disabled:a,children:"Reject"})]}):null]}),o?e.jsxs("div",{className:"mt-3 flex gap-2 sm:hidden",children:[e.jsx(F,{size:"sm",className:"h-8 bg-green-700 px-3 text-white hover:bg-green-600",onClick:n,disabled:a,children:"Approve"}),e.jsx(F,{variant:"destructive",size:"sm",className:"h-8 px-3",onClick:r,disabled:a,children:"Reject"})]}):null]})}function Ra(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),n=Rt(),r=wt(),a=_e(),[i,l]=c.useState(null),[o,u]=c.useState("everything"),[d,m]=c.useState("all"),{dismissed:p,dismiss:h}=xc(),x=r.pathname.split("/").pop()??"recent",y=x==="all"||x==="unread"?x:"recent",N=c.useMemo(()=>Tr("Inbox",`${r.pathname}${r.search}${r.hash}`),[r.pathname,r.search,r.hash]),{data:b}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t});c.useEffect(()=>{s([{label:"Inbox"}])},[s]),c.useEffect(()=>{gh(y)},[y]);const{data:g,isLoading:T,error:k}=Q({queryKey:P.approvals.list(t),queryFn:()=>gt.list(t),enabled:!!t}),{data:C=[],isLoading:f}=Q({queryKey:P.access.joinRequests(t),queryFn:async()=>{try{return await dn.listJoinRequests(t,"pending_approval")}catch(_){if(_ instanceof io&&(_.status===403||_.status===401))return[];throw _}},enabled:!!t,retry:!1}),{data:j,isLoading:v}=Q({queryKey:P.dashboard(t),queryFn:()=>Oi.summary(t),enabled:!!t}),{data:U,isLoading:A}=Q({queryKey:P.issues.list(t),queryFn:()=>Ve.list(t),enabled:!!t}),{data:B=[],isLoading:W}=Q({queryKey:P.issues.listTouchedByMe(t),queryFn:()=>Ve.list(t,{touchedByUserId:"me",status:"backlog,todo,in_progress,in_review,blocked,done"}),enabled:!!t}),{data:S,isLoading:w}=Q({queryKey:P.heartbeats(t),queryFn:()=>Tt.list(t),enabled:!!t}),te=c.useMemo(()=>mc(B),[B]),G=c.useMemo(()=>te.filter(_=>_.isUnreadForMe),[te]),K=c.useMemo(()=>y==="unread"?G:te,[y,te,G]),M=c.useMemo(()=>{const _=new Map;for(const J of b??[])_.set(J.id,J.name);return _},[b]),ee=c.useMemo(()=>{const _=new Map;for(const J of U??[])_.set(J.id,J);return _},[U]),L=c.useMemo(()=>dc(S??[]).filter(_=>!p.has(`run:${_.id}`)),[S,p]),ae=c.useMemo(()=>{const _=new Set;for(const J of S??[]){if(J.status!=="running"&&J.status!=="queued")continue;const le=Uc(J);le&&_.add(le)}return _},[S]),oe=c.useMemo(()=>bh(g??[],y,d),[g,y,d]),q=o==="everything"||o==="join_requests",H=o==="everything"||o==="issues_i_touched",I=o==="everything"||o==="approvals",R=o==="everything"||o==="failed_runs",D=o==="everything"||o==="alerts",Z=c.useMemo(()=>y==="all"&&!R?[]:L,[L,y,R]),me=c.useMemo(()=>jh({issues:y==="all"&&!H?[]:K,approvals:y==="all"&&!I?[]:oe,failedRuns:Z}),[oe,K,I,H,y,Z]),xe=_=>_?M.get(_)??null:null,$=re({mutationFn:_=>gt.approve(_),onSuccess:(_,J)=>{l(null),a.invalidateQueries({queryKey:P.approvals.list(t)}),n(`/approvals/${J}?resolved=approved`)},onError:_=>{l(_ instanceof Error?_.message:"Failed to approve")}}),ce=re({mutationFn:_=>gt.reject(_),onSuccess:()=>{l(null),a.invalidateQueries({queryKey:P.approvals.list(t)})},onError:_=>{l(_ instanceof Error?_.message:"Failed to reject")}}),ue=re({mutationFn:_=>dn.approveJoinRequest(t,_.id),onSuccess:()=>{l(null),a.invalidateQueries({queryKey:P.access.joinRequests(t)}),a.invalidateQueries({queryKey:P.sidebarBadges(t)}),a.invalidateQueries({queryKey:P.agents.list(t)}),a.invalidateQueries({queryKey:P.companies.all})},onError:_=>{l(_ instanceof Error?_.message:"Failed to approve join request")}}),Re=re({mutationFn:_=>dn.rejectJoinRequest(t,_.id),onSuccess:()=>{l(null),a.invalidateQueries({queryKey:P.access.joinRequests(t)}),a.invalidateQueries({queryKey:P.sidebarBadges(t)})},onError:_=>{l(_ instanceof Error?_.message:"Failed to reject join request")}}),[De,We]=c.useState(new Set),xt=re({mutationFn:async _=>{const J={},le=_.contextSnapshot;le&&(typeof le.issueId=="string"&&le.issueId&&(J.issueId=le.issueId),typeof le.taskId=="string"&&le.taskId&&(J.taskId=le.taskId),typeof le.taskKey=="string"&&le.taskKey&&(J.taskKey=le.taskKey));const we=await Te.wakeup(_.agentId,{source:"on_demand",triggerDetail:"manual",reason:"retry_failed_run",payload:J});if(!("id"in we))throw new Error("Retry was skipped because the agent is not currently invokable.");return{newRun:we,originalRun:_}},onMutate:_=>{We(J=>new Set(J).add(_.id))},onSuccess:({newRun:_,originalRun:J})=>{a.invalidateQueries({queryKey:P.heartbeats(J.companyId)}),a.invalidateQueries({queryKey:P.heartbeats(J.companyId,J.agentId)}),n(`/agents/${J.agentId}/runs/${_.id}`)},onSettled:(_,J,le)=>{le&&We(we=>{const $e=new Set(we);return $e.delete(le.id),$e})}}),[Ct,V]=c.useState(new Set),pe=()=>{t&&(a.invalidateQueries({queryKey:P.issues.listTouchedByMe(t)}),a.invalidateQueries({queryKey:P.issues.listUnreadTouchedByMe(t)}),a.invalidateQueries({queryKey:P.sidebarBadges(t)}))},ye=re({mutationFn:_=>Ve.markRead(_),onMutate:_=>{V(J=>new Set(J).add(_))},onSuccess:()=>{pe()},onSettled:(_,J,le)=>{setTimeout(()=>{V(we=>{const $e=new Set(we);return $e.delete(le),$e})},300)}}),Ee=re({mutationFn:async _=>{await Promise.all(_.map(J=>Ve.markRead(J)))},onMutate:_=>{V(J=>{const le=new Set(J);for(const we of _)le.add(we);return le})},onSuccess:()=>{pe()},onSettled:(_,J,le)=>{setTimeout(()=>{V(we=>{const $e=new Set(we);for(const at of le)$e.delete(at);return $e})},300)}});if(!t)return e.jsx(rt,{icon:Qs,message:"Select a company to view inbox."});const Be=L.length>0,Ot=!!j&&j.agents.error>0&&!Be&&!p.has("alert:agent-errors"),O=!!j&&j.costs.monthBudgetCents>0&&j.costs.monthUtilizationPercent>=80&&!p.has("alert:budget"),ne=Ot||O,ie=C.length>0,se=me.length>0,ve=y==="all"?q&&ie:y==="unread"&&ie,ze=vh({tab:y,hasItems:ne,showOnRecent:ne,showOnUnread:ne,showOnAll:D&&ne}),pt=[ze?"alerts":null,ve?"join_requests":null,se?"work_items":null].filter(_=>_!==null),Qe=!f&&!T&&!v&&!A&&!W&&!w,xs=_=>pt.indexOf(_)>0,E=G.filter(_=>!Ct.has(_.id)).map(_=>_.id),X=E.length>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Yt,{value:y,onValueChange:_=>n(`/inbox/${_}`),children:e.jsx(Gs,{items:[{value:"recent",label:"Recent"},{value:"unread",label:"Unread"},{value:"all",label:"All"}]})}),X&&e.jsx(F,{type:"button",variant:"outline",size:"sm",className:"h-8 shrink-0",onClick:()=>Ee.mutate(E),disabled:Ee.isPending,children:Ee.isPending?"Marking…":"Mark all as read"})]}),y==="all"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:justify-end",children:[e.jsxs(yn,{value:o,onValueChange:_=>u(_),children:[e.jsx(wn,{className:"h-8 w-[170px] text-xs",children:e.jsx(Nn,{placeholder:"Category"})}),e.jsxs(kn,{children:[e.jsx(Oe,{value:"everything",children:"All categories"}),e.jsx(Oe,{value:"issues_i_touched",children:"My recent issues"}),e.jsx(Oe,{value:"join_requests",children:"Join requests"}),e.jsx(Oe,{value:"approvals",children:"Approvals"}),e.jsx(Oe,{value:"failed_runs",children:"Failed runs"}),e.jsx(Oe,{value:"alerts",children:"Alerts"})]})]}),I&&e.jsxs(yn,{value:d,onValueChange:_=>m(_),children:[e.jsx(wn,{className:"h-8 w-[170px] text-xs",children:e.jsx(Nn,{placeholder:"Approval status"})}),e.jsxs(kn,{children:[e.jsx(Oe,{value:"all",children:"All approval statuses"}),e.jsx(Oe,{value:"actionable",children:"Needs action"}),e.jsx(Oe,{value:"resolved",children:"Resolved"})]})]})]})]}),k&&e.jsx("p",{className:"text-sm text-destructive",children:k.message}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),!Qe&&pt.length===0&&e.jsx(ot,{variant:"inbox"}),Qe&&pt.length===0&&e.jsx(rt,{icon:Qs,message:y==="unread"?"No new inbox items.":y==="recent"?"No recent inbox items.":"No inbox items match these filters."}),se&&e.jsxs(e.Fragment,{children:[xs("work_items")&&e.jsx($t,{}),e.jsx("div",{children:e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card",children:me.map(_=>{if(_.kind==="approval")return e.jsx(Bf,{approval:_.approval,requesterName:xe(_.approval.requestedByAgentId),onApprove:()=>$.mutate(_.approval.id),onReject:()=>ce.mutate(_.approval.id),isPending:$.isPending||ce.isPending},`approval:${_.approval.id}`);if(_.kind==="failed_run")return e.jsx(qf,{run:_.run,issueById:ee,agentName:xe(_.run.agentId),issueLinkState:N,onDismiss:()=>h(`run:${_.run.id}`),onRetry:()=>xt.mutate(_.run),isRetrying:De.has(_.run.id)},`run:${_.run.id}`);const J=_.issue,le=J.isUnreadForMe&&!Ct.has(J.id),we=Ct.has(J.id);return e.jsx(ko,{issue:J,issueLinkState:N,desktopMetaLeading:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(At,{priority:J.priority})}),e.jsx("span",{className:"hidden shrink-0 sm:inline-flex",children:e.jsx(ft,{status:J.status})}),e.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:J.identifier??J.id.slice(0,8)}),ae.has(J.id)&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-500/10 px-1.5 py-0.5 sm:gap-1.5 sm:px-2",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-pulse rounded-full bg-blue-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-blue-500"})]}),e.jsx("span",{className:"hidden text-[11px] font-medium text-blue-600 dark:text-blue-400 sm:inline",children:"Live"})]})]}),mobileMeta:J.lastExternalCommentAt?`commented ${Ut(J.lastExternalCommentAt)}`:`updated ${Ut(J.updatedAt)}`,unreadState:le?"visible":we?"fading":"hidden",onMarkRead:()=>ye.mutate(J.id),trailingMeta:J.lastExternalCommentAt?`commented ${Ut(J.lastExternalCommentAt)}`:`updated ${Ut(J.updatedAt)}`},`issue:${J.id}`)})})})]}),ve&&e.jsxs(e.Fragment,{children:[xs("join_requests")&&e.jsx($t,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Join Requests"}),e.jsx("div",{className:"grid gap-3",children:C.map(_=>e.jsx("div",{className:"rounded-xl border border-border bg-card p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:_.requestType==="human"?"Human join request":`Agent join request${_.agentName?`: ${_.agentName}`:""}`}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["requested ",Ut(_.createdAt)," from IP ",_.requestIp]}),_.requestEmailSnapshot&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["email: ",_.requestEmailSnapshot]}),_.adapterType&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["adapter: ",_.adapterType]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{size:"sm",variant:"outline",disabled:ue.isPending||Re.isPending,onClick:()=>Re.mutate(_),children:"Reject"}),e.jsx(F,{size:"sm",disabled:ue.isPending||Re.isPending,onClick:()=>ue.mutate(_),children:"Approve"})]})]})},_.id))})]})]}),ze&&e.jsxs(e.Fragment,{children:[xs("alerts")&&e.jsx($t,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-3 text-sm font-semibold uppercase tracking-wide text-muted-foreground",children:"Alerts"}),e.jsxs("div",{className:"divide-y divide-border border border-border",children:[Ot&&e.jsxs("div",{className:"group/alert relative flex items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50",children:[e.jsxs(he,{to:"/agents",className:"flex flex-1 cursor-pointer items-center gap-3 no-underline text-inherit",children:[e.jsx(hn,{className:"h-4 w-4 shrink-0 text-red-600 dark:text-red-400"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:j.agents.error})," ",j.agents.error===1?"agent has":"agents have"," errors"]})]}),e.jsx("button",{type:"button",onClick:()=>h("alert:agent-errors"),className:"rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover/alert:opacity-100","aria-label":"Dismiss",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}),O&&e.jsxs("div",{className:"group/alert relative flex items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50",children:[e.jsxs(he,{to:"/costs",className:"flex flex-1 cursor-pointer items-center gap-3 no-underline text-inherit",children:[e.jsx(hn,{className:"h-4 w-4 shrink-0 text-yellow-400"}),e.jsxs("span",{className:"text-sm",children:["Budget at"," ",e.jsxs("span",{className:"font-medium",children:[j.costs.monthUtilizationPercent,"%"]})," ","utilization this month"]})]}),e.jsx("button",{type:"button",onClick:()=>h("alert:budget"),className:"rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover/alert:opacity-100","aria-label":"Dismiss",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]})]})]})]})]})}function zf(){const{companies:t,selectedCompany:s,selectedCompanyId:n,setSelectedCompanyId:r}=fe(),{setBreadcrumbs:a}=Fe(),i=_e(),[l,o]=c.useState(""),[u,d]=c.useState(""),[m,p]=c.useState(""),[h,x]=c.useState(""),[y,N]=c.useState(null);c.useEffect(()=>{s&&(o(s.name),d(s.description??""),p(s.brandColor??""),x(s.logoUrl??""))},[s]);const[b,g]=c.useState(null),[T,k]=c.useState(null),[C,f]=c.useState(!1),[j,v]=c.useState(0),U=!!s&&(l!==s.name||u!==(s.description??"")||m!==(s.brandColor??"")),A=re({mutationFn:L=>Rs.update(n,L),onSuccess:()=>{i.invalidateQueries({queryKey:P.companies.all})}}),B=re({mutationFn:L=>Rs.update(n,{requireBoardApprovalForNewAgents:L}),onSuccess:()=>{i.invalidateQueries({queryKey:P.companies.all})}}),W=re({mutationFn:()=>dn.createOpenClawInvitePrompt(n),onSuccess:async L=>{var I,R,D;g(null);const ae=window.location.origin.replace(/\/+$/,""),oe=L.onboardingTextUrl??L.onboardingTextPath??`/api/invites/${L.token}/onboarding.txt`,q=oe.startsWith("http")?oe:`${ae}${oe}`;f(!1),v(0);let H;try{const Z=await dn.getInviteOnboarding(L.token);H=Vl({onboardingTextUrl:q,connectionCandidates:((I=Z.onboarding.connectivity)==null?void 0:I.connectionCandidates)??null,testResolutionUrl:((D=(R=Z.onboarding.connectivity)==null?void 0:R.testResolutionEndpoint)==null?void 0:D.url)??null})}catch{H=Vl({onboardingTextUrl:q,connectionCandidates:null,testResolutionUrl:null})}k(H);try{await navigator.clipboard.writeText(H),f(!0),v(Z=>Z+1),setTimeout(()=>f(!1),2e3)}catch{}i.invalidateQueries({queryKey:P.sidebarBadges(n)})},onError:L=>{g(L instanceof Error?L.message:"Failed to create invite")}}),S=L=>{x(L??""),i.invalidateQueries({queryKey:P.companies.all})},w=re({mutationFn:L=>rr.uploadCompanyLogo(n,L).then(ae=>Rs.update(n,{logoAssetId:ae.assetId})),onSuccess:L=>{S(L.logoUrl),N(null)}}),te=re({mutationFn:()=>Rs.update(n,{logoAssetId:null}),onSuccess:L=>{N(null),S(L.logoUrl)}});function G(L){var oe;const ae=((oe=L.target.files)==null?void 0:oe[0])??null;L.currentTarget.value="",ae&&(N(null),w.mutate(ae))}function K(){te.mutate()}c.useEffect(()=>{g(null),k(null),f(!1),v(0)},[n]);const M=re({mutationFn:({companyId:L,nextCompanyId:ae})=>Rs.archive(L).then(()=>({nextCompanyId:ae})),onSuccess:async({nextCompanyId:L})=>{L&&r(L),await i.invalidateQueries({queryKey:P.companies.all}),await i.invalidateQueries({queryKey:P.companies.stats})}});if(c.useEffect(()=>{a([{label:(s==null?void 0:s.name)??"Company",href:"/dashboard"},{label:"Settings"}])},[a,s==null?void 0:s.name]),!s)return e.jsx("div",{className:"text-sm text-muted-foreground",children:"No company selected. Select a company from the switcher above."});function ee(){A.mutate({name:l.trim(),description:u.trim()||null,brandColor:m||null})}return e.jsxs("div",{className:"max-w-2xl space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h1",{className:"text-lg font-semibold",children:"Company Settings"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"General"}),e.jsxs("div",{className:"space-y-3 rounded-md border border-border px-4 py-4",children:[e.jsx(pr,{label:"Company name",hint:"The display name for your company.",children:e.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",value:l,onChange:L=>o(L.target.value)})}),e.jsx(pr,{label:"Description",hint:"Optional description shown in the company profile.",children:e.jsx("input",{className:"w-full rounded-md border border-border bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",value:u,placeholder:"Optional company description",onChange:L=>d(L.target.value)})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Appearance"}),e.jsx("div",{className:"space-y-3 rounded-md border border-border px-4 py-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"shrink-0",children:e.jsx(ro,{companyName:l||s.name,logoUrl:h||null,brandColor:m||null,className:"rounded-[14px]"})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(pr,{label:"Logo",hint:"Upload a PNG, JPEG, WEBP, GIF, or SVG logo image.",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,image/svg+xml",onChange:G,className:"w-full rounded-md border border-border bg-transparent px-2.5 py-1.5 text-sm outline-none file:mr-4 file:rounded-md file:border-0 file:bg-muted file:px-2.5 file:py-1 file:text-xs"}),h&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{size:"sm",variant:"outline",onClick:K,disabled:te.isPending,children:te.isPending?"Removing...":"Remove logo"})}),(w.isError||y)&&e.jsx("span",{className:"text-xs text-destructive",children:y??(w.error instanceof Error?w.error.message:"Logo upload failed")}),te.isError&&e.jsx("span",{className:"text-xs text-destructive",children:te.error.message}),w.isPending&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploading logo..."})]})}),e.jsx(pr,{label:"Brand color",hint:"Sets the hue for the company icon. Leave empty for auto-generated color.",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:m||"#6366f1",onChange:L=>p(L.target.value),className:"h-8 w-8 cursor-pointer rounded border border-border bg-transparent p-0"}),e.jsx("input",{type:"text",value:m,onChange:L=>{const ae=L.target.value;(ae===""||/^#[0-9a-fA-F]{0,6}$/.test(ae))&&p(ae)},placeholder:"Auto",className:"w-28 rounded-md border border-border bg-transparent px-2.5 py-1.5 text-sm font-mono outline-none"}),m&&e.jsx(F,{size:"sm",variant:"ghost",onClick:()=>p(""),className:"text-xs text-muted-foreground",children:"Clear"})]})})]})]})})]}),U&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{size:"sm",onClick:ee,disabled:A.isPending||!l.trim(),children:A.isPending?"Saving...":"Save changes"}),A.isSuccess&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Saved"}),A.isError&&e.jsx("span",{className:"text-xs text-destructive",children:A.error instanceof Error?A.error.message:"Failed to save"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Hiring"}),e.jsx("div",{className:"rounded-md border border-border px-4 py-3",children:e.jsx(cu,{label:"Require board approval for new hires",hint:"New agent hires stay pending until approved by board.",checked:!!s.requireBoardApprovalForNewAgents,onChange:L=>B.mutate(L)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Invites"}),e.jsxs("div",{className:"space-y-3 rounded-md border border-border px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Generate an OpenClaw agent invite snippet."}),e.jsx(du,{text:"Creates a short-lived OpenClaw agent invite and renders a copy-ready prompt."})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(F,{size:"sm",onClick:()=>W.mutate(),disabled:W.isPending,children:W.isPending?"Generating...":"Generate OpenClaw Invite Prompt"})}),b&&e.jsx("p",{className:"text-sm text-destructive",children:b}),T&&e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"OpenClaw Invite Prompt"}),C&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 animate-pulse",children:[e.jsx(Qt,{className:"h-3 w-3"}),"Copied"]},j)]}),e.jsxs("div",{className:"mt-1 space-y-1.5",children:[e.jsx("textarea",{className:"h-[28rem] w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none",value:T,readOnly:!0}),e.jsx("div",{className:"flex justify-end",children:e.jsx(F,{size:"sm",variant:"ghost",onClick:async()=>{try{await navigator.clipboard.writeText(T),f(!0),v(L=>L+1),setTimeout(()=>f(!1),2e3)}catch{}},children:C?"Copied snippet":"Copy snippet"})})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-xs font-medium text-destructive uppercase tracking-wide",children:"Danger Zone"}),e.jsxs("div",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 px-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Archive this company to hide it from the sidebar. This persists in the database."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{size:"sm",variant:"destructive",disabled:M.isPending||s.status==="archived",onClick:()=>{var oe;if(!n||!window.confirm(`Archive company "${s.name}"? It will be hidden from the sidebar.`))return;const ae=((oe=t.find(q=>q.id!==n&&q.status!=="archived"))==null?void 0:oe.id)??null;M.mutate({companyId:n,nextCompanyId:ae})},children:M.isPending?"Archiving...":s.status==="archived"?"Already archived":"Archive company"}),M.isError&&e.jsx("span",{className:"text-xs text-destructive",children:M.error instanceof Error?M.error.message:"Failed to archive company"})]})]})]})]})}function Vl(t){const s=Kf(t),n=Uf(t),r=s.length>0?s.map(l=>`- ${l}`).join(`
|
|
198
|
+
`):"- (No candidate URLs available yet.)",a=s.length===0?`No candidate URLs are available. Ask your user to configure a reachable hostname in Paperclip, then retry.
|
|
199
|
+
Suggested steps:
|
|
200
|
+
- choose a hostname that resolves to the Paperclip host from your runtime
|
|
201
|
+
- run: pnpm paperclipai allowed-hostname <host>
|
|
202
|
+
- restart Paperclip
|
|
203
|
+
- verify with: curl -fsS http://<host>:3100/api/health
|
|
204
|
+
- regenerate this invite snippet`:`If none are reachable, ask your user to add a reachable hostname in Paperclip, restart, and retry.
|
|
205
|
+
Suggested command:
|
|
206
|
+
- pnpm paperclipai allowed-hostname <host>
|
|
207
|
+
Then verify with: curl -fsS <base-url>/api/health`,i=n?`
|
|
208
|
+
You MUST test Paperclip-to-gateway reachability, call: ${n}?url=<urlencoded-gateway-url> (using the hostname that worked above). Do not assume your 172.x is necessarily reachable from Paperclip. Test it. `:"";return`You're invited to join a Paperclip organization.
|
|
209
|
+
|
|
210
|
+
The URLs you should try are:
|
|
211
|
+
${r}
|
|
212
|
+
|
|
213
|
+
Connectivity guidance:
|
|
214
|
+
If you are running on a different machine than Paperclip, Paperclip must be reachable at one of the hostnames used above.
|
|
215
|
+
Verify the hostname works from your runtime with: GET <base-url>/api/health
|
|
216
|
+
|
|
217
|
+
${a}
|
|
218
|
+
|
|
219
|
+
For your "agentName", just use your own agent name (OpenClaw or whatever your name is) and send it directly.
|
|
220
|
+
You also need to send a gateway URL that Paperclip can access. Check your config and include that URL.${i}
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
This onboarding flow is for OpenClaw Gateway.
|
|
225
|
+
When you submit the join request, use:
|
|
226
|
+
- \`adapterType: "openclaw_gateway"\`
|
|
227
|
+
- \`agentDefaultsPayload.url\` as your \`ws://\` or \`wss://\` gateway URL
|
|
228
|
+
- \`agentDefaultsPayload.headers["x-openclaw-token"]\` with your gateway token
|
|
229
|
+
- (legacy accepted) \`agentDefaultsPayload.headers["x-openclaw-auth"]\`
|
|
230
|
+
- Keep device auth enabled (recommended). If \`devicePrivateKeyPem\` is omitted, Paperclip will generate and persist one during join so pairing approvals remain stable.
|
|
231
|
+
- Only use \`disableDeviceAuth=true\` for special environments where pairing cannot be completed.
|
|
232
|
+
|
|
233
|
+
Do NOT use \`/v1/responses\` or \`/hooks/*\` in this join flow.
|
|
234
|
+
|
|
235
|
+
Before you do anything, please respond to your user that you understand the instructions and you're going to work on them. Then do the step above in another session called "paperclip-onboarding" and then tell your user when you're done. Update your user in intermediate steps along the way so they know what's going on.
|
|
236
|
+
|
|
237
|
+
Then after you've connected to Paperclip (exchanged keys etc.) you MUST review and follow the onboarding instructions in onboarding.txt they give you.
|
|
238
|
+
|
|
239
|
+
`}function Kf(t){const s=(t.connectionCandidates??[]).map(i=>i.trim()).filter(Boolean),n=new Set;let r=null;try{r=new URL(t.onboardingTextUrl),n.add(r.toString())}catch{const i=t.onboardingTextUrl.trim();i&&n.add(i)}if(!r){for(const i of s)n.add(i);return Array.from(n)}const a=`${r.pathname}${r.search}`;for(const i of s)try{const l=new URL(i);n.add(`${l.origin}${a}`)}catch{n.add(i)}return Array.from(n)}function Uf(t){var n;const s=(n=t.testResolutionUrl)==null?void 0:n.trim();if(s)return s;try{const r=new URL(t.onboardingTextUrl),a=r.pathname.replace(/\/onboarding\.txt$/,"/test-resolution");return`${r.origin}${a}`}catch{return null}}function Vf({filters:t,onRemove:s,onClear:n}){return t.length===0?null:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.map(r=>e.jsxs(Ce,{variant:"secondary",className:"gap-1 pr-1",children:[e.jsxs("span",{className:"text-muted-foreground",children:[r.label,":"]}),e.jsx("span",{children:r.value}),e.jsx("button",{className:"ml-1 rounded-full hover:bg-accent p-0.5",onClick:()=>s(r.key),children:e.jsx(nt,{className:"h-3 w-3"})})]},r.key)),e.jsx(F,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:n,children:"Clear all"})]})}function be({title:t,children:s}){return e.jsxs("section",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:t}),e.jsx($t,{}),s]})}function je({title:t,children:s}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium",children:t}),s]})}function Ge({name:t,cssVar:s}){return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-md border border-border shrink-0",style:{backgroundColor:`var(${s})`}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-mono",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})]})}function Wf(){const[t,s]=c.useState("todo"),[n,r]=c.useState("medium"),[a,i]=c.useState("in_progress"),[l,o]=c.useState(!0),[u,d]=c.useState(!1),[m,p]=c.useState("Click to edit this text"),[h,x]=c.useState("Editable Title"),[y,N]=c.useState("This is an editable description. Click to edit it — the textarea auto-sizes to fit the content without layout shift."),[b,g]=c.useState([{key:"status",label:"Status",value:"Active"},{key:"priority",label:"Priority",value:"High"}]);return e.jsxs("div",{className:"space-y-10 max-w-4xl",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Design Guide"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Every component, style, and pattern used across Paperclip."})]}),e.jsxs(be,{title:"Component Coverage",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This page should be updated when new UI primitives or app-level patterns ship."}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(je,{title:"UI primitives",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:["avatar","badge","breadcrumb","button","card","checkbox","collapsible","command","dialog","dropdown-menu","input","label","popover","scroll-area","select","separator","sheet","skeleton","tabs","textarea","tooltip"].map(T=>e.jsx(Ce,{variant:"outline",className:"font-mono text-[10px]",children:T},T))})}),e.jsx(je,{title:"App components",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:["StatusBadge","StatusIcon","PriorityIcon","EntityRow","EmptyState","MetricCard","FilterBar","InlineEditor","PageSkeleton","Identity","CommentThread","MarkdownEditor","PropertiesPanel","Sidebar","CommandPalette"].map(T=>e.jsx(Ce,{variant:"ghost",className:"font-mono text-[10px]",children:T},T))})})]})]}),e.jsxs(be,{title:"Colors",children:[e.jsx(je,{title:"Core",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(Ge,{name:"Background",cssVar:"--background"}),e.jsx(Ge,{name:"Foreground",cssVar:"--foreground"}),e.jsx(Ge,{name:"Card",cssVar:"--card"}),e.jsx(Ge,{name:"Primary",cssVar:"--primary"}),e.jsx(Ge,{name:"Primary foreground",cssVar:"--primary-foreground"}),e.jsx(Ge,{name:"Secondary",cssVar:"--secondary"}),e.jsx(Ge,{name:"Muted",cssVar:"--muted"}),e.jsx(Ge,{name:"Muted foreground",cssVar:"--muted-foreground"}),e.jsx(Ge,{name:"Accent",cssVar:"--accent"}),e.jsx(Ge,{name:"Destructive",cssVar:"--destructive"}),e.jsx(Ge,{name:"Border",cssVar:"--border"}),e.jsx(Ge,{name:"Ring",cssVar:"--ring"})]})}),e.jsx(je,{title:"Sidebar",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(Ge,{name:"Sidebar",cssVar:"--sidebar"}),e.jsx(Ge,{name:"Sidebar border",cssVar:"--sidebar-border"})]})}),e.jsx(je,{title:"Chart",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(Ge,{name:"Chart 1",cssVar:"--chart-1"}),e.jsx(Ge,{name:"Chart 2",cssVar:"--chart-2"}),e.jsx(Ge,{name:"Chart 3",cssVar:"--chart-3"}),e.jsx(Ge,{name:"Chart 4",cssVar:"--chart-4"}),e.jsx(Ge,{name:"Chart 5",cssVar:"--chart-5"})]})})]}),e.jsx(be,{title:"Typography",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-xl font-bold",children:"Page Title — text-xl font-bold"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Section Title — text-lg font-semibold"}),e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Section Heading — text-sm font-semibold uppercase tracking-wide"}),e.jsx("p",{className:"text-sm font-medium",children:"Card Title — text-sm font-medium"}),e.jsx("p",{className:"text-sm font-semibold",children:"Card Title Alt — text-sm font-semibold"}),e.jsx("p",{className:"text-sm",children:"Body text — text-sm"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Muted description — text-sm text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tiny label — text-xs text-muted-foreground"}),e.jsx("p",{className:"text-sm font-mono text-muted-foreground",children:"Mono identifier — text-sm font-mono text-muted-foreground"}),e.jsx("p",{className:"text-2xl font-bold",children:"Large stat — text-2xl font-bold"}),e.jsx("p",{className:"font-mono text-xs",children:"Log/code text — font-mono text-xs"})]})}),e.jsx(be,{title:"Radius",children:e.jsx("div",{className:"flex items-end gap-4 flex-wrap",children:[["sm","var(--radius-sm)"],["md","var(--radius-md)"],["lg","var(--radius-lg)"],["xl","var(--radius-xl)"],["full","9999px"]].map(([T,k])=>e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"h-12 w-12 bg-primary",style:{borderRadius:k}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T})]},T))})}),e.jsxs(be,{title:"Buttons",children:[e.jsx(je,{title:"Variants",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(F,{variant:"default",children:"Default"}),e.jsx(F,{variant:"secondary",children:"Secondary"}),e.jsx(F,{variant:"outline",children:"Outline"}),e.jsx(F,{variant:"ghost",children:"Ghost"}),e.jsx(F,{variant:"destructive",children:"Destructive"}),e.jsx(F,{variant:"link",children:"Link"})]})}),e.jsx(je,{title:"Sizes",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(F,{size:"xs",children:"Extra Small"}),e.jsx(F,{size:"sm",children:"Small"}),e.jsx(F,{size:"default",children:"Default"}),e.jsx(F,{size:"lg",children:"Large"})]})}),e.jsx(je,{title:"Icon buttons",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(F,{variant:"ghost",size:"icon-xs",children:e.jsx(fs,{})}),e.jsx(F,{variant:"ghost",size:"icon-sm",children:e.jsx(fs,{})}),e.jsx(F,{variant:"outline",size:"icon",children:e.jsx(fs,{})}),e.jsx(F,{variant:"outline",size:"icon-lg",children:e.jsx(fs,{})})]})}),e.jsx(je,{title:"With icons",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(F,{children:[e.jsx(Ae,{})," New Issue"]}),e.jsxs(F,{variant:"outline",children:[e.jsx(ll,{})," Upload"]}),e.jsxs(F,{variant:"destructive",children:[e.jsx(Jt,{})," Delete"]}),e.jsxs(F,{size:"sm",children:[e.jsx(Ae,{})," Add"]})]})}),e.jsx(je,{title:"States",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(F,{disabled:!0,children:"Disabled"}),e.jsx(F,{variant:"outline",disabled:!0,children:"Disabled Outline"})]})})]}),e.jsx(be,{title:"Badges",children:e.jsx(je,{title:"Variants",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ce,{variant:"default",children:"Default"}),e.jsx(Ce,{variant:"secondary",children:"Secondary"}),e.jsx(Ce,{variant:"outline",children:"Outline"}),e.jsx(Ce,{variant:"destructive",children:"Destructive"}),e.jsx(Ce,{variant:"ghost",children:"Ghost"})]})})}),e.jsxs(be,{title:"Status System",children:[e.jsx(je,{title:"StatusBadge (all statuses)",children:e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:["active","running","paused","idle","archived","planned","achieved","completed","failed","timed_out","succeeded","error","pending_approval","backlog","todo","in_progress","in_review","blocked","done","terminated","cancelled","pending","revision_requested","approved","rejected"].map(T=>e.jsx(Pe,{status:T},T))})}),e.jsxs(je,{title:"StatusIcon (interactive)",children:[e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:["backlog","todo","in_progress","in_review","done","cancelled","blocked"].map(T=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ft,{status:T}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T})]},T))}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(ft,{status:t,onChange:s}),e.jsxs("span",{className:"text-sm",children:["Click the icon to change status (current: ",t,")"]})]})]}),e.jsxs(je,{title:"PriorityIcon (interactive)",children:[e.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:["critical","high","medium","low"].map(T=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(At,{priority:T}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T})]},T))}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(At,{priority:n,onChange:r}),e.jsxs("span",{className:"text-sm",children:["Click the icon to change (current: ",n,")"]})]})]}),e.jsx(je,{title:"Agent status dots",children:e.jsx("div",{className:"flex items-center gap-4 flex-wrap",children:["running","active","paused","error","archived"].map(T=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"relative flex h-2.5 w-2.5",children:e.jsx("span",{className:`inline-flex h-full w-full rounded-full ${pi[T]??hi}`})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:T})]},T))})}),e.jsx(je,{title:"Run invocation badges",children:e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:[["timer","bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300"],["assignment","bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300"],["on_demand","bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300"],["automation","bg-muted text-muted-foreground"]].map(([T,k])=>e.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-[10px] font-medium ${k}`,children:T},T))})})]}),e.jsx(be,{title:"Form Elements",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(je,{title:"Input",children:[e.jsx(Vt,{placeholder:"Default input"}),e.jsx(Vt,{placeholder:"Disabled input",disabled:!0,className:"mt-2"})]}),e.jsx(je,{title:"Textarea",children:e.jsx(cn,{placeholder:"Write something..."})}),e.jsx(je,{title:"Checkbox & Label",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{id:"check1",defaultChecked:!0}),e.jsx(Dt,{htmlFor:"check1",children:"Checked item"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{id:"check2"}),e.jsx(Dt,{htmlFor:"check2",children:"Unchecked item"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{id:"check3",disabled:!0}),e.jsx(Dt,{htmlFor:"check3",children:"Disabled item"})]})]})}),e.jsx(je,{title:"Inline Editor",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Title (single-line)"}),e.jsx(Ds,{value:h,onSave:x,as:"h2",className:"text-xl font-bold"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Body text (single-line)"}),e.jsx(Ds,{value:m,onSave:p,as:"p",className:"text-sm"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Description (multiline, auto-sizing)"}),e.jsx(Ds,{value:y,onSave:N,as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0})]})]})})]})}),e.jsx(be,{title:"Select",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(je,{title:"Default size",children:[e.jsxs(yn,{value:a,onValueChange:i,children:[e.jsx(wn,{className:"w-full",children:e.jsx(Nn,{placeholder:"Select status"})}),e.jsxs(kn,{children:[e.jsx(Oe,{value:"backlog",children:"Backlog"}),e.jsx(Oe,{value:"todo",children:"Todo"}),e.jsx(Oe,{value:"in_progress",children:"In Progress"}),e.jsx(Oe,{value:"in_review",children:"In Review"}),e.jsx(Oe,{value:"done",children:"Done"})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current value: ",a]})]}),e.jsx(je,{title:"Small trigger",children:e.jsxs(yn,{defaultValue:"high",children:[e.jsx(wn,{size:"sm",className:"w-full",children:e.jsx(Nn,{})}),e.jsxs(kn,{children:[e.jsx(Oe,{value:"critical",children:"Critical"}),e.jsx(Oe,{value:"high",children:"High"}),e.jsx(Oe,{value:"medium",children:"Medium"}),e.jsx(Oe,{value:"low",children:"Low"})]})]})})]})}),e.jsx(be,{title:"Dropdown Menu",children:e.jsxs(Zr,{children:[e.jsx(ea,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",children:["Quick Actions",e.jsx($s,{className:"h-4 w-4"})]})}),e.jsxs(ta,{align:"start",className:"w-56",children:[e.jsxs(Ks,{children:[e.jsx(Qt,{className:"h-4 w-4"}),"Mark as done",e.jsx(uu,{children:"⌘D"})]}),e.jsxs(Ks,{children:[e.jsx(Va,{className:"h-4 w-4"}),"Open docs"]}),e.jsx(wo,{}),e.jsx(mu,{checked:l,onCheckedChange:T=>o(T===!0),children:"Watch issue"}),e.jsxs(Ks,{variant:"destructive",children:[e.jsx(Jt,{className:"h-4 w-4"}),"Delete issue"]})]})]})}),e.jsx(be,{title:"Popover",children:e.jsxs(vt,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"sm",children:"Open Popover"})}),e.jsxs(Nt,{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Agent heartbeat"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last run succeeded 24s ago. Next timer run in 9m."}),e.jsx(F,{size:"xs",children:"Wake now"})]})]})}),e.jsx(be,{title:"Collapsible",children:e.jsxs(Gr,{open:u,onOpenChange:d,className:"space-y-2",children:[e.jsx(Hr,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",children:[u?"Hide":"Show"," advanced filters"]})}),e.jsx(Jr,{className:"rounded-md border border-border p-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(Dt,{htmlFor:"owner-filter",children:"Owner"}),e.jsx(Vt,{id:"owner-filter",placeholder:"Filter by agent name"})]})})]})}),e.jsx(be,{title:"Sheet",children:e.jsxs(xu,{children:[e.jsx(pu,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"sm",children:"Open Side Panel"})}),e.jsxs(hu,{side:"right",children:[e.jsxs(gu,{children:[e.jsx(fu,{children:"Issue Properties"}),e.jsx(bu,{children:"Edit metadata without leaving the current page."})]}),e.jsxs("div",{className:"space-y-4 px-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(Dt,{htmlFor:"sheet-title",children:"Title"}),e.jsx(Vt,{id:"sheet-title",defaultValue:"Improve onboarding docs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Dt,{htmlFor:"sheet-description",children:"Description"}),e.jsx(cn,{id:"sheet-description",defaultValue:"Capture setup pitfalls and screenshots."})]})]}),e.jsxs(ju,{children:[e.jsx(F,{variant:"outline",children:"Cancel"}),e.jsx(F,{children:"Save"})]})]})]})}),e.jsx(be,{title:"Scroll Area",children:e.jsx(vu,{className:"h-36 rounded-md border border-border",children:e.jsx("div",{className:"space-y-2 p-3",children:Array.from({length:12}).map((T,k)=>e.jsxs("div",{className:"rounded-md border border-border p-2 text-sm",children:["Heartbeat run #",k+1,": completed successfully"]},k))})})}),e.jsx(be,{title:"Command (CMDK)",children:e.jsx("div",{className:"rounded-md border border-border",children:e.jsxs(wc,{children:[e.jsx(kc,{placeholder:"Type a command or search..."}),e.jsxs(Cc,{children:[e.jsx(Sc,{children:"No results found."}),e.jsxs(Bs,{heading:"Pages",children:[e.jsxs(Ze,{children:[e.jsx(Vs,{className:"h-4 w-4"}),"Dashboard"]}),e.jsxs(Ze,{children:[e.jsx(Wt,{className:"h-4 w-4"}),"Issues"]})]}),e.jsx(On,{}),e.jsxs(Bs,{heading:"Actions",children:[e.jsxs(Ze,{children:[e.jsx(Dm,{className:"h-4 w-4"}),"Open command palette"]}),e.jsxs(Ze,{children:[e.jsx(Ae,{className:"h-4 w-4"}),"Create new issue"]})]})]})]})})}),e.jsx(be,{title:"Breadcrumb",children:e.jsx(yu,{children:e.jsxs(Nu,{children:[e.jsx(ga,{children:e.jsx(Xi,{href:"#",children:"Projects"})}),e.jsx(Zi,{}),e.jsx(ga,{children:e.jsx(Xi,{href:"#",children:"Paperclip App"})}),e.jsx(Zi,{}),e.jsx(ga,{children:e.jsx(wu,{children:"Issue List"})})]})})}),e.jsxs(be,{title:"Cards",children:[e.jsx(je,{title:"Standard Card",children:e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsx(st,{children:"Card Title"}),e.jsx(jt,{children:"Card description with supporting text."})]}),e.jsx(qe,{children:e.jsx("p",{className:"text-sm",children:"Card content goes here. This is the main body area."})}),e.jsxs(ku,{className:"gap-2",children:[e.jsx(F,{size:"sm",children:"Action"}),e.jsx(F,{variant:"outline",size:"sm",children:"Cancel"})]})]})}),e.jsx(je,{title:"Metric Cards",children:e.jsxs("div",{className:"grid md:grid-cols-2 xl:grid-cols-4 gap-4",children:[e.jsx(Ms,{icon:Gt,value:12,label:"Active Agents",description:"+3 this week"}),e.jsx(Ms,{icon:Wt,value:48,label:"Open Issues"}),e.jsx(Ms,{icon:ls,value:"$1,234",label:"Monthly Cost",description:"Under budget"}),e.jsx(Ms,{icon:Pr,value:"99.9%",label:"Uptime"})]})})]}),e.jsxs(be,{title:"Tabs",children:[e.jsx(je,{title:"Default (pill) variant",children:e.jsxs(Yt,{defaultValue:"overview",children:[e.jsxs(Rr,{children:[e.jsx(Pt,{value:"overview",children:"Overview"}),e.jsx(Pt,{value:"runs",children:"Runs"}),e.jsx(Pt,{value:"config",children:"Config"}),e.jsx(Pt,{value:"costs",children:"Costs"})]}),e.jsx(Ke,{value:"overview",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Overview tab content."})}),e.jsx(Ke,{value:"runs",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Runs tab content."})}),e.jsx(Ke,{value:"config",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Config tab content."})}),e.jsx(Ke,{value:"costs",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Costs tab content."})})]})}),e.jsx(je,{title:"Line variant",children:e.jsxs(Yt,{defaultValue:"summary",children:[e.jsxs(Rr,{variant:"line",children:[e.jsx(Pt,{value:"summary",children:"Summary"}),e.jsx(Pt,{value:"details",children:"Details"}),e.jsx(Pt,{value:"comments",children:"Comments"})]}),e.jsx(Ke,{value:"summary",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Summary content with underline tabs."})}),e.jsx(Ke,{value:"details",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Details content."})}),e.jsx(Ke,{value:"comments",children:e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"Comments content."})})]})})]}),e.jsx(be,{title:"Entity Rows",children:e.jsxs("div",{className:"border border-border rounded-md",children:[e.jsx(gs,{leading:e.jsxs(e.Fragment,{children:[e.jsx(ft,{status:"in_progress"}),e.jsx(At,{priority:"high"})]}),identifier:"PAP-001",title:"Implement authentication flow",subtitle:"Assigned to Agent Alpha",trailing:e.jsx(Pe,{status:"in_progress"}),onClick:()=>{}}),e.jsx(gs,{leading:e.jsxs(e.Fragment,{children:[e.jsx(ft,{status:"done"}),e.jsx(At,{priority:"medium"})]}),identifier:"PAP-002",title:"Set up CI/CD pipeline",subtitle:"Completed 2 days ago",trailing:e.jsx(Pe,{status:"done"}),onClick:()=>{}}),e.jsx(gs,{leading:e.jsxs(e.Fragment,{children:[e.jsx(ft,{status:"todo"}),e.jsx(At,{priority:"low"})]}),identifier:"PAP-003",title:"Write API documentation",trailing:e.jsx(Pe,{status:"todo"}),onClick:()=>{}}),e.jsx(gs,{leading:e.jsxs(e.Fragment,{children:[e.jsx(ft,{status:"blocked"}),e.jsx(At,{priority:"critical"})]}),identifier:"PAP-004",title:"Deploy to production",subtitle:"Blocked by PAP-001",trailing:e.jsx(Pe,{status:"blocked"}),selected:!0})]})}),e.jsxs(be,{title:"Filter Bar",children:[e.jsx(Vf,{filters:b,onRemove:T=>g(k=>k.filter(C=>C.key!==T)),onClear:()=>g([])}),b.length===0&&e.jsx(F,{variant:"outline",size:"sm",onClick:()=>g([{key:"status",label:"Status",value:"Active"},{key:"priority",label:"Priority",value:"High"}]),children:"Reset filters"})]}),e.jsxs(be,{title:"Avatars",children:[e.jsx(je,{title:"Sizes",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Os,{size:"sm",children:e.jsx(Ls,{children:"SM"})}),e.jsx(Os,{children:e.jsx(Ls,{children:"DF"})}),e.jsx(Os,{size:"lg",children:e.jsx(Ls,{children:"LG"})})]})}),e.jsx(je,{title:"Group",children:e.jsxs(Cu,{children:[e.jsx(Os,{children:e.jsx(Ls,{children:"A1"})}),e.jsx(Os,{children:e.jsx(Ls,{children:"A2"})}),e.jsx(Os,{children:e.jsx(Ls,{children:"A3"})}),e.jsx(Su,{children:"+5"})]})})]}),e.jsxs(be,{title:"Identity",children:[e.jsx(je,{title:"Sizes",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(Ue,{name:"Agent Alpha",size:"sm"}),e.jsx(Ue,{name:"Agent Alpha"}),e.jsx(Ue,{name:"Agent Alpha",size:"lg"})]})}),e.jsx(je,{title:"Initials derivation",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ue,{name:"CEO Agent",size:"sm"}),e.jsx(Ue,{name:"Alpha",size:"sm"}),e.jsx(Ue,{name:"Quality Assurance Lead",size:"sm"})]})}),e.jsx(je,{title:"Custom initials",children:e.jsx(Ue,{name:"Backend Service",initials:"BS",size:"sm"})})]}),e.jsx(be,{title:"Tooltips",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(cs,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"sm",children:"Hover me"})}),e.jsx(us,{children:"This is a tooltip"})]}),e.jsxs(cs,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(F,{variant:"ghost",size:"icon-sm",children:e.jsx(ks,{})})}),e.jsx(us,{children:"Settings"})]})]})}),e.jsx(be,{title:"Dialog",children:e.jsxs(js,{children:[e.jsx(Ao,{asChild:!0,children:e.jsx(F,{variant:"outline",children:"Open Dialog"})}),e.jsxs(vs,{children:[e.jsxs(mn,{children:[e.jsx(xn,{children:"Dialog Title"}),e.jsx(Bn,{children:"This is a sample dialog showing the standard layout with header, content, and footer."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(Dt,{children:"Name"}),e.jsx(Vt,{placeholder:"Enter a name",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(Dt,{children:"Description"}),e.jsx(cn,{placeholder:"Describe...",className:"mt-1.5"})]})]}),e.jsxs(kr,{children:[e.jsx(F,{variant:"outline",children:"Cancel"}),e.jsx(F,{children:"Save"})]})]})]})}),e.jsx(be,{title:"Empty State",children:e.jsx("div",{className:"border border-border rounded-md",children:e.jsx(rt,{icon:Qs,message:"No items to show. Create your first one to get started.",action:"Create Item",onAction:()=>{}})})}),e.jsx(be,{title:"Progress Bars (Budget)",children:e.jsx("div",{className:"space-y-3",children:[{label:"Under budget (40%)",pct:40,color:"bg-green-400"},{label:"Warning (75%)",pct:75,color:"bg-yellow-400"},{label:"Over budget (95%)",pct:95,color:"bg-red-400"}].map(({label:T,pct:k,color:C})=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:T}),e.jsxs("span",{className:"text-xs font-mono",children:[k,"%"]})]}),e.jsx("div",{className:"w-full h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-[width,background-color] duration-150 ${C}`,style:{width:`${k}%`}})})]},T))})}),e.jsx(be,{title:"Log Viewer",children:e.jsxs("div",{className:"bg-neutral-950 rounded-lg p-3 font-mono text-xs max-h-80 overflow-y-auto",children:[e.jsx("div",{className:"text-foreground",children:"[12:00:01] INFO Agent started successfully"}),e.jsx("div",{className:"text-foreground",children:"[12:00:02] INFO Processing task PAP-001"}),e.jsx("div",{className:"text-yellow-400",children:"[12:00:05] WARN Rate limit approaching (80%)"}),e.jsx("div",{className:"text-foreground",children:"[12:00:08] INFO Task PAP-001 completed"}),e.jsx("div",{className:"text-red-400",children:"[12:00:12] ERROR Connection timeout to upstream service"}),e.jsx("div",{className:"text-blue-300",children:"[12:00:12] SYS Retrying connection in 5s..."}),e.jsx("div",{className:"text-foreground",children:"[12:00:17] INFO Reconnected successfully"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-cyan-400 animate-pulse"}),e.jsx("span",{className:"inline-flex h-full w-full rounded-full bg-cyan-400"})]}),e.jsx("span",{className:"text-cyan-400",children:"Live"})]})]})}),e.jsx(be,{title:"Property Row Pattern",children:e.jsxs("div",{className:"border border-border rounded-md p-4 space-y-1 max-w-sm",children:[e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Status"}),e.jsx(Pe,{status:"active"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Priority"}),e.jsx(At,{priority:"high"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Assignee"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Os,{size:"sm",children:e.jsx(Ls,{children:"A"})}),e.jsx("span",{className:"text-xs",children:"Agent Alpha"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Created"}),e.jsx("span",{className:"text-xs",children:"Jan 15, 2025"})]})]})}),e.jsxs(be,{title:"Navigation Patterns",children:[e.jsx(je,{title:"Sidebar nav items",children:e.jsxs("div",{className:"w-60 border border-border rounded-md p-3 space-y-0.5 bg-card",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium bg-accent text-accent-foreground",children:[e.jsx(Vs,{className:"h-4 w-4"}),"Dashboard"]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[e.jsx(Wt,{className:"h-4 w-4"}),"Issues",e.jsx("span",{className:"ml-auto text-xs bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:"12"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[e.jsx(Gt,{className:"h-4 w-4"}),"Agents"]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[e.jsx(vn,{className:"h-4 w-4"}),"Projects"]})]})}),e.jsx(je,{title:"View toggle",children:e.jsxs("div",{className:"flex items-center border border-border rounded-md w-fit",children:[e.jsxs("button",{className:"px-3 py-1.5 text-xs font-medium bg-accent text-foreground rounded-l-md",children:[e.jsx(el,{className:"h-3.5 w-3.5 inline mr-1"}),"List"]}),e.jsxs("button",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent/50 rounded-r-md",children:[e.jsx(ws,{className:"h-3.5 w-3.5 inline mr-1"}),"Org"]})]})})]}),e.jsx(be,{title:"Grouped List (Issues pattern)",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted/50 rounded-t-md",children:[e.jsx(ft,{status:"in_progress"}),e.jsx("span",{className:"text-sm font-medium",children:"In Progress"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"2"})]}),e.jsxs("div",{className:"border border-border rounded-b-md",children:[e.jsx(gs,{leading:e.jsx(At,{priority:"high"}),identifier:"PAP-101",title:"Build agent heartbeat system",onClick:()=>{}}),e.jsx(gs,{leading:e.jsx(At,{priority:"medium"}),identifier:"PAP-102",title:"Add cost tracking dashboard",onClick:()=>{}})]})]})}),e.jsx(be,{title:"Comment Thread Pattern",children:e.jsxs("div",{className:"space-y-3 max-w-2xl",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Comments (2)"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Jan 15, 2025"})]}),e.jsx("p",{className:"text-sm",children:"Started working on the authentication module. Will need API keys configured."})]}),e.jsxs("div",{className:"rounded-md border border-border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Human"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Jan 16, 2025"})]}),e.jsx("p",{className:"text-sm",children:"API keys have been added to the vault. Please proceed."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(cn,{placeholder:"Leave a comment...",rows:3}),e.jsx(F,{size:"sm",children:"Comment"})]})]})}),e.jsx(be,{title:"Cost Table Pattern",children:e.jsx("div",{className:"border border-border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"border-b border-border bg-accent/20",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Model"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Tokens"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Cost"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("td",{className:"px-3 py-2",children:"claude-sonnet-4-20250514"}),e.jsx("td",{className:"px-3 py-2 font-mono",children:"1.2M"}),e.jsx("td",{className:"px-3 py-2 font-mono",children:"$18.00"})]}),e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("td",{className:"px-3 py-2",children:"claude-haiku-4-20250506"}),e.jsx("td",{className:"px-3 py-2 font-mono",children:"500k"}),e.jsx("td",{className:"px-3 py-2 font-mono",children:"$1.25"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-medium",children:"Total"}),e.jsx("td",{className:"px-3 py-2 font-mono",children:"1.7M"}),e.jsx("td",{className:"px-3 py-2 font-mono font-medium",children:"$19.25"})]})]})]})})}),e.jsxs(be,{title:"Skeletons",children:[e.jsx(je,{title:"Individual",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(as,{className:"h-4 w-48"}),e.jsx(as,{className:"h-8 w-full max-w-sm"}),e.jsx(as,{className:"h-20 w-full"})]})}),e.jsx(je,{title:"Page Skeleton (list)",children:e.jsx("div",{className:"border border-border rounded-md p-4",children:e.jsx(ot,{variant:"list"})})}),e.jsx(je,{title:"Page Skeleton (detail)",children:e.jsx("div",{className:"border border-border rounded-md p-4",children:e.jsx(ot,{variant:"detail"})})})]}),e.jsx(be,{title:"Separator",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Horizontal"}),e.jsx($t,{}),e.jsxs("div",{className:"flex items-center gap-4 h-8",children:[e.jsx("span",{className:"text-sm",children:"Left"}),e.jsx($t,{orientation:"vertical"}),e.jsx("span",{className:"text-sm",children:"Right"})]})]})}),e.jsx(be,{title:"Common Icons (Lucide)",children:e.jsx("div",{className:"grid grid-cols-4 md:grid-cols-6 gap-4",children:[["Inbox",Qs],["ListTodo",el],["CircleDot",Wt],["Hexagon",vn],["Target",ws],["LayoutDashboard",Vs],["Bot",Gt],["DollarSign",ls],["History",Jn],["Search",fs],["Plus",Ae],["Trash2",Jt],["Settings",ks],["User",on],["Mail",Iu],["Upload",ll],["Zap",Pr]].map(([T,k])=>{const C=k;return e.jsxs("div",{className:"flex flex-col items-center gap-1.5 p-2",children:[e.jsx(C,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:T})]},T)})})}),e.jsx(be,{title:"Keyboard Shortcuts",children:e.jsx("div",{className:"border border-border rounded-md divide-y divide-border text-sm",children:[["Cmd+K / Ctrl+K","Open Command Palette"],["C","New Issue (outside inputs)"],["[","Toggle Sidebar"],["]","Toggle Properties Panel"],["Cmd+Enter / Ctrl+Enter","Submit markdown comment"]].map(([T,k])=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"text-muted-foreground",children:k}),e.jsx("kbd",{className:"px-2 py-0.5 text-xs font-mono bg-muted rounded border border-border",children:T})]},T))})})]})}function Wl(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function Qf(t){return t.replaceAll("_"," ")}function Ql(t){return`/${t.companyIssuePrefix}/agents/${encodeURIComponent(t.agentUrlKey)}`}function Gf(){const{setBreadcrumbs:t}=Fe(),s=_e(),[n,r]=c.useState(null);c.useEffect(()=>{t([{label:"Instance Settings"},{label:"Heartbeats"}])},[t]);const a=Q({queryKey:P.instance.schedulerHeartbeats,queryFn:()=>Tt.listInstanceSchedulerAgents(),refetchInterval:15e3}),i=re({mutationFn:async m=>{const p=await Te.get(m.id,m.companyId),h=Wl(p.runtimeConfig)??{},x=Wl(h.heartbeat)??{};return Te.update(m.id,{runtimeConfig:{...h,heartbeat:{...x,enabled:!m.heartbeatEnabled}}},m.companyId)},onSuccess:async(m,p)=>{r(null),await Promise.all([s.invalidateQueries({queryKey:P.instance.schedulerHeartbeats}),s.invalidateQueries({queryKey:P.agents.list(p.companyId)}),s.invalidateQueries({queryKey:P.agents.detail(p.id)})])},onError:m=>{r(m instanceof Error?m.message:"Failed to update heartbeat.")}}),l=a.data??[],o=l.filter(m=>m.schedulerActive).length,u=l.length-o,d=c.useMemo(()=>{const m=new Map;for(const p of l){let h=m.get(p.companyId);h||(h={companyName:p.companyName,agents:[]},m.set(p.companyId,h)),h.agents.push(p)}return[...m.values()]},[l]);return a.isLoading?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading scheduler heartbeats..."}):a.error?e.jsx("div",{className:"text-sm text-destructive",children:a.error instanceof Error?a.error.message:"Failed to load scheduler heartbeats."}):e.jsxs("div",{className:"max-w-5xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ks,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h1",{className:"text-lg font-semibold",children:"Scheduler Heartbeats"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Agents with a timer heartbeat enabled across all of your companies."})]}),e.jsxs("div",{className:"flex gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-foreground",children:o})," active"]}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-foreground",children:u})," disabled"]}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-foreground",children:d.length})," ",d.length===1?"company":"companies"]})]}),n&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:n}),l.length===0?e.jsx(rt,{icon:Mo,message:"No scheduler heartbeats match the current criteria."}):e.jsx("div",{className:"space-y-4",children:d.map(m=>e.jsx(Le,{children:e.jsxs(qe,{className:"p-0",children:[e.jsx("div",{className:"border-b px-3 py-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:m.companyName}),e.jsx("div",{className:"divide-y",children:m.agents.map(p=>{var x;const h=i.isPending&&((x=i.variables)==null?void 0:x.id)===p.id;return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-sm",children:[e.jsx(Ce,{variant:p.schedulerActive?"default":"outline",className:"shrink-0 text-[10px] px-1.5 py-0",children:p.schedulerActive?"On":"Off"}),e.jsx(he,{to:Ql(p),className:"font-medium truncate hover:underline",children:p.agentName}),e.jsx("span",{className:"hidden sm:inline text-muted-foreground truncate",children:Qf(p.title??p.role)}),e.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:[p.intervalSec,"s"]}),e.jsx("span",{className:"hidden md:inline text-muted-foreground truncate",title:p.lastHeartbeatAt?sa(p.lastHeartbeatAt):void 0,children:p.lastHeartbeatAt?ar(p.lastHeartbeatAt):"never"}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[e.jsx(he,{to:Ql(p),className:"text-muted-foreground hover:text-foreground",title:"Full agent config",children:e.jsx(In,{className:"h-3.5 w-3.5"})}),e.jsx(F,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",disabled:h,onClick:()=>i.mutate(p),children:h?"...":p.heartbeatEnabled?"Disable Timer Heartbeat":"Enable Timer Heartbeat"})]})]},p.id)})})]})},m.companyName))})]})}function Hf(){var o;const{setBreadcrumbs:t}=Fe(),s=_e(),[n,r]=c.useState(null);c.useEffect(()=>{t([{label:"Instance Settings"},{label:"Experimental"}])},[t]);const a=Q({queryKey:P.instance.experimentalSettings,queryFn:()=>$a.getExperimental()}),i=re({mutationFn:async u=>$a.updateExperimental({enableIsolatedWorkspaces:u}),onSuccess:async()=>{r(null),await s.invalidateQueries({queryKey:P.instance.experimentalSettings})},onError:u=>{r(u instanceof Error?u.message:"Failed to update experimental settings.")}});if(a.isLoading)return e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading experimental settings..."});if(a.error)return e.jsx("div",{className:"text-sm text-destructive",children:a.error instanceof Error?a.error.message:"Failed to load experimental settings."});const l=((o=a.data)==null?void 0:o.enableIsolatedWorkspaces)===!0;return e.jsxs("div",{className:"max-w-4xl space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h1",{className:"text-lg font-semibold",children:"Experimental"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Opt into features that are still being evaluated before they become default behavior."})]}),n&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:n}),e.jsx("section",{className:"rounded-xl border border-border bg-card p-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Enabled Isolated Workspaces"}),e.jsx("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Show execution workspace controls in project configuration and allow isolated workspace behavior for new and existing issue runs."})]}),e.jsx("button",{type:"button","aria-label":"Toggle isolated workspaces experimental setting",disabled:i.isPending,className:z("relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60",l?"bg-green-600":"bg-muted"),onClick:()=>i.mutate(!l),children:e.jsx("span",{className:z("inline-block h-4.5 w-4.5 rounded-full bg-white transition-transform",l?"translate-x-6":"translate-x-0.5")})})]})})]})}function Jf(t){return t?t.split(/\r?\n/).map(n=>n.trim()).find(Boolean)??null:null}function Gl(t){return Jf(t.lastError)??"Plugin entered an error state without a stored error message."}function Yf(){const{selectedCompany:t}=fe(),{setBreadcrumbs:s}=Fe(),n=_e(),{pushToast:r}=gi(),[a,i]=c.useState(""),[l,o]=c.useState(!1),[u,d]=c.useState(null),[m,p]=c.useState(""),[h,x]=c.useState(null);c.useEffect(()=>{s([{label:(t==null?void 0:t.name)??"Company",href:"/dashboard"},{label:"Settings",href:"/instance/settings/heartbeats"},{label:"Plugins"}])},[t==null?void 0:t.name,s]);const{data:y,isLoading:N,error:b}=Q({queryKey:P.plugins.all,queryFn:()=>bt.list()}),g=Q({queryKey:P.plugins.examples,queryFn:()=>bt.listExamples()}),T=()=>{n.invalidateQueries({queryKey:P.plugins.all}),n.invalidateQueries({queryKey:P.plugins.examples}),n.invalidateQueries({queryKey:P.plugins.uiContributions})},k=re({mutationFn:S=>bt.install(S),onSuccess:()=>{T(),o(!1),i(""),r({title:"Plugin installed successfully",tone:"success"})},onError:S=>{r({title:"Failed to install plugin",body:S.message,tone:"error"})}}),C=re({mutationFn:S=>bt.uninstall(S),onSuccess:()=>{T(),r({title:"Plugin uninstalled successfully",tone:"success"})},onError:S=>{r({title:"Failed to uninstall plugin",body:S.message,tone:"error"})}}),f=re({mutationFn:S=>bt.enable(S),onSuccess:()=>{T(),r({title:"Plugin enabled",tone:"success"})},onError:S=>{r({title:"Failed to enable plugin",body:S.message,tone:"error"})}}),j=re({mutationFn:S=>bt.disable(S),onSuccess:()=>{T(),r({title:"Plugin disabled",tone:"info"})},onError:S=>{r({title:"Failed to disable plugin",body:S.message,tone:"error"})}}),v=y??[],U=g.data??[],A=new Map(v.map(S=>[S.packageName,S])),B=new Set(U.map(S=>S.packageName)),W=c.useMemo(()=>new Map(v.map(S=>[S.id,Gl(S)])),[v]);return N?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugins..."}):b?e.jsx("div",{className:"p-4 text-sm text-destructive",children:"Failed to load plugins."}):e.jsxs("div",{className:"space-y-6 max-w-5xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qn,{className:"h-6 w-6 text-muted-foreground"}),e.jsx("h1",{className:"text-xl font-semibold",children:"Plugin Manager"})]}),e.jsxs(js,{open:l,onOpenChange:o,children:[e.jsx(Ao,{asChild:!0,children:e.jsxs(F,{size:"sm",className:"gap-2",children:[e.jsx(Ae,{className:"h-4 w-4"}),"Install Plugin"]})}),e.jsxs(vs,{children:[e.jsxs(mn,{children:[e.jsx(xn,{children:"Install Plugin"}),e.jsx(Bn,{children:"Enter the npm package name of the plugin you wish to install."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Dt,{htmlFor:"packageName",children:"npm Package Name"}),e.jsx(Vt,{id:"packageName",placeholder:"@paperclipai/plugin-example",value:a,onChange:S=>i(S.target.value)})]})}),e.jsxs(kr,{children:[e.jsx(F,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(F,{onClick:()=>k.mutate({packageName:a}),disabled:!a||k.isPending,children:k.isPending?"Installing...":"Install"})]})]})]})]}),e.jsx("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hn,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:"Plugins are alpha."}),e.jsx("p",{className:"text-muted-foreground",children:"The plugin runtime and API surface are still changing. Expect breaking changes while this feature settles."})]})]})}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h2",{className:"text-base font-semibold",children:"Available Plugins"}),e.jsx(Ce,{variant:"outline",children:"Examples"})]}),g.isLoading?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading bundled examples..."}):g.error?e.jsx("div",{className:"text-sm text-destructive",children:"Failed to load bundled examples."}):U.length===0?e.jsx("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground",children:"No bundled example plugins were found in this checkout."}):e.jsx("ul",{className:"divide-y rounded-md border bg-card",children:U.map(S=>{var G;const w=A.get(S.packageName),te=k.isPending&&((G=k.variables)==null?void 0:G.isLocalPath)&&k.variables.packageName===S.localPath;return e.jsx("li",{children:e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:S.displayName}),e.jsx(Ce,{variant:"outline",children:"Example"}),w?e.jsx(Ce,{variant:w.status==="ready"?"default":"secondary",className:w.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:w.status}):e.jsx(Ce,{variant:"secondary",children:"Not installed"})]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:S.description}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:S.packageName})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:w?e.jsxs(e.Fragment,{children:[w.status!=="ready"&&e.jsx(F,{variant:"outline",size:"sm",disabled:f.isPending,onClick:()=>f.mutate(w.id),children:"Enable"}),e.jsx(F,{variant:"outline",size:"sm",asChild:!0,children:e.jsx(he,{to:`/instance/settings/plugins/${w.id}`,children:w.status==="ready"?"Open Settings":"Review"})})]}):e.jsx(F,{size:"sm",disabled:te||k.isPending,onClick:()=>k.mutate({packageName:S.localPath,isLocalPath:!0}),children:te?"Installing...":"Install Example"})})]})},S.packageName)})})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qn,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h2",{className:"text-base font-semibold",children:"Installed Plugins"})]}),v.length?e.jsx("ul",{className:"divide-y rounded-md border bg-card",children:v.map(S=>e.jsx("li",{children:e.jsxs("div",{className:"flex items-start gap-4 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(he,{to:`/instance/settings/plugins/${S.id}`,className:"font-medium hover:underline truncate block",title:S.manifestJson.displayName??S.packageName,children:S.manifestJson.displayName??S.packageName}),B.has(S.packageName)&&e.jsx(Ce,{variant:"outline",children:"Example"})]}),e.jsx("div",{children:e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",title:S.packageName,children:[S.packageName," · v",S.manifestJson.version??S.version]})}),e.jsx("p",{className:"text-sm text-muted-foreground truncate mt-0.5",title:S.manifestJson.description,children:S.manifestJson.description||"No description provided."}),S.status==="error"&&e.jsx("div",{className:"mt-3 rounded-md border border-red-500/25 bg-red-500/[0.06] px-3 py-2",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300",children:[e.jsx(hn,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:"Plugin error"})]}),e.jsx("p",{className:"mt-1 text-sm text-red-700/90 dark:text-red-200/90 break-words",title:S.lastError??void 0,children:W.get(S.id)})]}),e.jsx(F,{variant:"outline",size:"sm",className:"border-red-500/30 bg-background/60 text-red-700 hover:bg-red-500/10 hover:text-red-800 dark:text-red-200 dark:hover:text-red-100",onClick:()=>x(S),children:"View full error"})]})})]}),e.jsx("div",{className:"flex shrink-0 self-center",children:e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:S.status==="ready"?"default":S.status==="error"?"destructive":"secondary",className:z("shrink-0",S.status==="ready"?"bg-green-600 hover:bg-green-700":""),children:S.status}),e.jsx(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:S.status==="ready"?"Disable":"Enable",onClick:()=>{S.status==="ready"?j.mutate(S.id):f.mutate(S.id)},disabled:f.isPending||j.isPending,children:e.jsx(nx,{className:z("h-4 w-4",S.status==="ready"?"text-green-600":"")})}),e.jsx(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Uninstall",onClick:()=>{d(S.id),p(S.manifestJson.displayName??S.packageName)},disabled:C.isPending,children:e.jsx(ux,{className:"h-4 w-4"})})]}),e.jsx(F,{variant:"outline",size:"sm",className:"mt-2 h-8",asChild:!0,children:e.jsxs(he,{to:`/instance/settings/plugins/${S.id}`,children:[e.jsx(ks,{className:"h-4 w-4"}),"Configure"]})})]})})]})},S.id))}):e.jsx(Le,{className:"bg-muted/30",children:e.jsxs(qe,{className:"flex flex-col items-center justify-center py-10",children:[e.jsx(qn,{className:"h-10 w-10 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm font-medium",children:"No plugins installed"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Install a plugin to extend functionality."})]})})]}),e.jsx(js,{open:u!==null,onOpenChange:S=>{S||d(null)},children:e.jsxs(vs,{children:[e.jsxs(mn,{children:[e.jsx(xn,{children:"Uninstall Plugin"}),e.jsxs(Bn,{children:["Are you sure you want to uninstall ",e.jsx("strong",{children:m}),"? This action cannot be undone."]})]}),e.jsxs(kr,{children:[e.jsx(F,{variant:"outline",onClick:()=>d(null),children:"Cancel"}),e.jsx(F,{variant:"destructive",disabled:C.isPending,onClick:()=>{u&&C.mutate(u,{onSettled:()=>d(null)})},children:C.isPending?"Uninstalling...":"Uninstall"})]})]})}),e.jsx(js,{open:h!==null,onOpenChange:S=>{S||x(null)},children:e.jsxs(vs,{className:"sm:max-w-2xl",children:[e.jsxs(mn,{children:[e.jsx(xn,{children:"Error Details"}),e.jsxs(Bn,{children:[(h==null?void 0:h.manifestJson.displayName)??(h==null?void 0:h.packageName)??"Plugin"," hit an error state."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border border-red-500/25 bg-red-500/[0.06] px-4 py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hn,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700 dark:text-red-300"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsx("p",{className:"font-medium text-red-700 dark:text-red-300",children:"What errored"}),e.jsx("p",{className:"text-red-700/90 dark:text-red-200/90 break-words",children:h?Gl(h):"No error summary available."})]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Full error output"}),e.jsx("pre",{className:"max-h-[50vh] overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-5 whitespace-pre-wrap break-words",children:(h==null?void 0:h.lastError)??"No stored error message."})]})]}),e.jsx(kr,{children:e.jsx(F,{variant:"outline",onClick:()=>x(null),children:"Close"})})]})})]})}const Xf=200;function Js(t){return t.enum?"enum":t.const!==void 0?"const":t.format==="secret-ref"?"secret-ref":Array.isArray(t.type)?t.type.find(s=>s!=="null")??"string":t.type??"string"}function Zf(t,s){return s.title?s.title:t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Ui(t){var n;if(t.default!==void 0)return t.default;switch(Js(t)){case"string":case"secret-ref":return"";case"number":case"integer":return t.minimum??0;case"boolean":return!1;case"enum":return((n=t.enum)==null?void 0:n[0])??"";case"array":return[];case"object":{if(!t.properties)return{};const r={};for(const[a,i]of Object.entries(t.properties))r[a]=Ui(i);return r}default:return""}}function Hl(t,s,n){const r=Js(s);if(n&&(t==null||t===""))return"This field is required";if(t==null||t==="")return null;if(r==="string"||r==="secret-ref"){const a=String(t);if(s.minLength!=null&&a.length<s.minLength)return`Must be at least ${s.minLength} characters`;if(s.maxLength!=null&&a.length>s.maxLength)return`Must be at most ${s.maxLength} characters`;if(s.pattern&&s.pattern.length<=512)try{if(!new RegExp(s.pattern).test(a))return`Must match pattern: ${s.pattern}`}catch{}}if(r==="number"||r==="integer"){const a=Number(t);if(isNaN(a))return"Must be a valid number";if(s.minimum!=null&&a<s.minimum)return`Must be at least ${s.minimum}`;if(s.maximum!=null&&a>s.maximum)return`Must be at most ${s.maximum}`;if(s.exclusiveMinimum!=null&&a<=s.exclusiveMinimum)return`Must be greater than ${s.exclusiveMinimum}`;if(s.exclusiveMaximum!=null&&a>=s.exclusiveMaximum)return`Must be less than ${s.exclusiveMaximum}`;if(r==="integer"&&!Number.isInteger(a))return"Must be a whole number";if(s.multipleOf!=null&&a%s.multipleOf!==0)return`Must be a multiple of ${s.multipleOf}`}if(r==="array"){const a=t;if(s.minItems!=null&&a.length<s.minItems)return`Must have at least ${s.minItems} items`;if(s.maxItems!=null&&a.length>s.maxItems)return`Must have at most ${s.maxItems} items`}return null}function Vr(t,s,n=[]){const r={},a=t.properties??{},i=new Set(t.required??[]);for(const[l,o]of Object.entries(a)){const u=[...n,l],d=`/${u.join("/")}`,m=s[l],p=i.has(l),h=Js(o),x=Hl(m,o,p);if(x&&(r[d]=x),h==="object"&&o.properties&&typeof m=="object"&&m!==null&&Object.assign(r,Vr(o,m,u)),h==="array"&&o.items&&Array.isArray(m)){const y=o.items,N=Js(y)==="object";m.forEach((b,g)=>{const T=[...u,String(g)],k=`/${T.join("/")}`;if(N)Object.assign(r,Vr(y,b,T));else{const C=Hl(b,y,!1);C&&(r[k]=C)}})}}return r}function Ea(t){const s={},n=t.properties??{};for(const[r,a]of Object.entries(n)){const i=Ui(a);i!==void 0&&(s[r]=i)}return s}const mr=Ne.memo(({label:t,description:s,required:n,error:r,disabled:a,children:i})=>e.jsxs("div",{className:z("space-y-2",a&&"opacity-60"),children:[e.jsx("div",{className:"flex items-center justify-between",children:t&&e.jsxs(Dt,{className:"text-sm font-medium",children:[t,n&&e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]})}),i,s&&e.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed",children:s}),r&&e.jsx("p",{className:"text-[12px] font-medium text-destructive",children:r})]}));mr.displayName="FieldWrapper";const Vc=Ne.memo(({id:t,value:s,onChange:n,disabled:r,label:a,isRequired:i,description:l,error:o})=>e.jsxs("div",{className:"flex items-start space-x-3 space-y-0",children:[e.jsx(is,{id:t,checked:!!s,onCheckedChange:n,disabled:r}),e.jsxs("div",{className:"grid gap-1.5 leading-none",children:[a&&e.jsxs(Dt,{htmlFor:t,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:[a,i&&e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l}),o&&e.jsx("p",{className:"text-xs font-medium text-destructive",children:o})]})]}));Vc.displayName="BooleanField";const Wc=Ne.memo(({value:t,onChange:s,disabled:n,label:r,isRequired:a,description:i,error:l,options:o})=>e.jsx(mr,{label:r,description:i,required:a,error:l,disabled:n,children:e.jsxs(yn,{value:String(t??""),onValueChange:s,disabled:n,children:[e.jsx(wn,{className:"w-full",children:e.jsx(Nn,{placeholder:"Select an option"})}),e.jsx(kn,{children:o.map(u=>e.jsx(Oe,{value:String(u),children:String(u)},String(u)))})]})}));Wc.displayName="EnumField";const Qc=Ne.memo(({value:t,onChange:s,disabled:n,label:r,isRequired:a,description:i,error:l,defaultValue:o})=>{const[u,d]=c.useState(!1);return e.jsx(mr,{label:r,description:i||"This secret is stored securely via the Paperclip secret provider.",required:a,error:l,disabled:n,children:e.jsxs("div",{className:"relative",children:[e.jsx(Vt,{type:u?"text":"password",value:String(t??""),onChange:m=>s(m.target.value),placeholder:String(o??""),disabled:n,className:"pr-10","aria-invalid":!!l}),e.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>d(!u),disabled:n,children:[u?e.jsx(Au,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Pu,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"sr-only",children:u?"Hide secret":"Show secret"})]})]})})});Qc.displayName="SecretField";const Gc=Ne.memo(({value:t,onChange:s,disabled:n,label:r,isRequired:a,description:i,error:l,defaultValue:o,type:u})=>e.jsx(mr,{label:r,description:i,required:a,error:l,disabled:n,children:e.jsx(Vt,{type:"number",step:u==="integer"?"1":"any",value:t!==void 0?String(t):"",onChange:d=>{const m=d.target.value;s(m===""?void 0:Number(m))},placeholder:String(o??""),disabled:n,"aria-invalid":!!l})}));Gc.displayName="NumberField";const Hc=Ne.memo(({value:t,onChange:s,disabled:n,label:r,isRequired:a,description:i,error:l,defaultValue:o,format:u,maxLength:d})=>{const m=u==="textarea"||d&&d>Xf;return e.jsx(mr,{label:r,description:i,required:a,error:l,disabled:n,children:m?e.jsx(cn,{value:String(t??""),onChange:p=>s(p.target.value),placeholder:String(o??""),disabled:n,className:"min-h-[100px]","aria-invalid":!!l}):e.jsx(Vt,{type:"text",value:String(t??""),onChange:p=>s(p.target.value),placeholder:String(o??""),disabled:n,"aria-invalid":!!l})})});Hc.displayName="StringField";const Jc=Ne.memo(({propSchema:t,value:s,onChange:n,error:r,disabled:a,label:i,errors:l,path:o})=>{const u=Array.isArray(s)?s:[],d=t.items,m=Js(d)==="object";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Dt,{className:"text-sm font-medium",children:i}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsxs(F,{type:"button",variant:"outline",size:"sm",disabled:a||t.maxItems!==void 0&&u.length>=t.maxItems,onClick:()=>{const p=Ui(d);n([...u,p])},children:[e.jsx(Ae,{className:"mr-2 h-4 w-4"}),m?"Add item":"Add"]})]}),e.jsxs("div",{className:"space-y-3",children:[u.map((p,h)=>e.jsxs("div",{className:"group relative flex items-start space-x-2 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:["Item ",h+1]}),e.jsx(Wr,{propSchema:d,value:p,label:"",path:`${o}/${h}`,onChange:x=>{const y=[...u];y[h]=x,n(y)},disabled:a,errors:l})]}),e.jsxs(F,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:a||t.minItems!==void 0&&u.length<=t.minItems,onClick:()=>{const x=[...u];x.splice(h,1),n(x)},children:[e.jsx(Jt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Remove item"})]})]},h)),u.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed p-4 text-center text-xs text-muted-foreground",children:"No items added yet."})]}),r&&e.jsx("p",{className:"text-xs font-medium text-destructive",children:r})]})});Jc.displayName="ArrayField";const Yc=Ne.memo(({propSchema:t,value:s,onChange:n,disabled:r,label:a,errors:i,path:l})=>{const[o,u]=c.useState(!1),d=m=>{n(m)};return e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between",onClick:()=>u(!o),children:[e.jsxs("div",{className:"text-left",children:[e.jsx(Dt,{className:"cursor-pointer text-sm font-semibold",children:a}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t.description})]}),o?e.jsx(Ns,{className:"h-4 w-4 text-muted-foreground"}):e.jsx($s,{className:"h-4 w-4 text-muted-foreground"})]}),!o&&e.jsx("div",{className:"pt-2",children:e.jsx(Xc,{schema:t,values:s??{},onChange:d,disabled:r,errors:Object.fromEntries(Object.entries(i).filter(([m])=>m.startsWith(`${l}/`)).map(([m,p])=>[m.replace(l,""),p]))})})]})});Yc.displayName="ObjectField";const Wr=Ne.memo(({propSchema:t,value:s,onChange:n,error:r,disabled:a,label:i,isRequired:l,errors:o,path:u})=>{const d=Js(t),m=a||t.readOnly===!0;switch(d){case"boolean":return e.jsx(Vc,{id:u,value:s,onChange:n,disabled:m,label:i,isRequired:l,description:t.description,error:r});case"enum":return e.jsx(Wc,{value:s,onChange:n,disabled:m,label:i,isRequired:l,description:t.description,error:r,options:t.enum??[]});case"secret-ref":return e.jsx(Qc,{value:s,onChange:n,disabled:m,label:i,isRequired:l,description:t.description,error:r,defaultValue:t.default});case"number":case"integer":return e.jsx(Gc,{value:s,onChange:n,disabled:m,label:i,isRequired:l,description:t.description,error:r,defaultValue:t.default,type:d});case"array":return e.jsx(Jc,{propSchema:t,value:s,onChange:n,error:r,disabled:m,label:i,errors:o,path:u});case"object":return e.jsx(Yc,{propSchema:t,value:s,onChange:n,disabled:m,label:i,errors:o,path:u});default:return e.jsx(Hc,{value:s,onChange:n,disabled:m,label:i,isRequired:l,description:t.description,error:r,defaultValue:t.default,format:t.format,maxLength:t.maxLength})}});Wr.displayName="FormField";function Xc({schema:t,values:s,onChange:n,errors:r={},disabled:a,className:i}){const l=Js(t),o=c.useCallback(p=>{n(p)},[n]);if(l!=="object")return e.jsx("div",{className:i,children:e.jsx(Wr,{propSchema:t,value:s,label:"",path:"",onChange:o,disabled:a,errors:r})});const u=c.useMemo(()=>t.properties??{},[t.properties]),d=c.useMemo(()=>new Set(t.required??[]),[t.required]),m=c.useCallback((p,h)=>{n({...s,[p]:h})},[n,s]);return Object.keys(u).length===0?e.jsx("div",{className:z("py-4 text-center text-sm text-muted-foreground",i),children:"No configuration options available."}):e.jsx("div",{className:z("space-y-6",i),children:Object.entries(u).map(([p,h])=>{const x=s[p],y=d.has(p),N=r[`/${p}`],b=Zf(p,h),g=`/${p}`;return e.jsx(Wr,{propSchema:h,value:x,onChange:T=>m(p,T),error:N,disabled:a,label:b,isRequired:y,errors:r,path:g},p)})})}function eb(){var U;const{selectedCompany:t,selectedCompanyId:s}=fe(),{setBreadcrumbs:n}=Fe(),{companyPrefix:r,pluginId:a}=Cs(),[i,l]=c.useState("configuration"),{data:o,isLoading:u}=Q({queryKey:P.plugins.detail(a),queryFn:()=>bt.get(a),enabled:!!a}),{data:d,isLoading:m}=Q({queryKey:P.plugins.health(a),queryFn:()=>bt.health(a),enabled:!!a&&(o==null?void 0:o.status)==="ready",refetchInterval:3e4}),{data:p}=Q({queryKey:P.plugins.dashboard(a),queryFn:()=>bt.dashboard(a),enabled:!!a,refetchInterval:3e4}),{data:h}=Q({queryKey:P.plugins.logs(a),queryFn:()=>bt.logs(a,{limit:50}),enabled:!!a&&(o==null?void 0:o.status)==="ready",refetchInterval:3e4}),x=(U=o==null?void 0:o.manifestJson)==null?void 0:U.instanceConfigSchema,y=x&&x.properties&&Object.keys(x.properties).length>0,{data:N,isLoading:b}=Q({queryKey:P.plugins.config(a),queryFn:()=>bt.getConfig(a),enabled:!!a&&!!y}),{slots:g}=ai({slotTypes:["settingsPage"],enabled:!!s}),T=g.filter(A=>A.pluginId===a),k=T.length>0;if(c.useEffect(()=>{var A;n([{label:(t==null?void 0:t.name)??"Company",href:"/dashboard"},{label:"Settings",href:"/instance/settings/heartbeats"},{label:"Plugins",href:"/instance/settings/plugins"},{label:((A=o==null?void 0:o.manifestJson)==null?void 0:A.displayName)??(o==null?void 0:o.packageName)??"Plugin Details"}])},[t==null?void 0:t.name,n,r,o]),c.useEffect(()=>{l("configuration")},[a]),u)return e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugin details..."});if(!o)return e.jsx(Ie,{to:"/instance/settings/plugins",replace:!0});const C=o.status,f=o.status==="ready"?"default":o.status==="error"?"destructive":"secondary",j=o.manifestJson.description||"No description provided.",v=o.manifestJson.capabilities??[];return e.jsxs("div",{className:"space-y-6 max-w-5xl",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(he,{to:"/instance/settings/plugins",children:e.jsx(F,{variant:"outline",size:"icon",className:"h-8 w-8",children:e.jsx(ci,{className:"h-4 w-4"})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qn,{className:"h-6 w-6 text-muted-foreground"}),e.jsx("h1",{className:"text-xl font-semibold",children:o.manifestJson.displayName??o.packageName}),e.jsx(Ce,{variant:f,className:"ml-2",children:C}),e.jsxs(Ce,{variant:"outline",className:"ml-1",children:["v",o.manifestJson.version??o.version]})]})]}),e.jsxs(Yt,{value:i,onValueChange:A=>l(A),className:"space-y-6",children:[e.jsx(Gs,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:i,onValueChange:A=>l(A)}),e.jsx(Ke,{value:"configuration",className:"space-y-6",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"space-y-5",children:[e.jsx("h2",{className:"text-base font-semibold",children:"About"}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-[minmax(0,1.4fr)_minmax(220px,0.8fr)]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),e.jsx("p",{className:"text-sm leading-6 text-foreground/90",children:j})]}),e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"font-medium text-muted-foreground",children:"Author"}),e.jsx("p",{className:"text-foreground",children:o.manifestJson.author})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-muted-foreground",children:"Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:o.categories.length>0?o.categories.map(A=>e.jsx(Ce,{variant:"outline",className:"capitalize",children:A},A)):e.jsx("span",{className:"text-foreground",children:"None"})})]})]})]})]}),e.jsx($t,{}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("h2",{className:"text-base font-semibold",children:"Settings"})}),k?e.jsx("div",{className:"space-y-3",children:T.map(A=>e.jsx(Yr,{slot:A,context:{companyId:s,companyPrefix:r??null},missingBehavior:"placeholder"},`${A.pluginKey}:${A.id}`))}):y?e.jsx(tb,{pluginId:a,schema:x,initialValues:N==null?void 0:N.configJson,isLoading:b,pluginStatus:o.status,supportsConfigTest:o.supportsConfigTest===!0}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not require any settings."})]})]})}),e.jsx(Ke,{value:"status",className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_320px]",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(st,{className:"text-base flex items-center gap-1.5",children:[e.jsx(tl,{className:"h-4 w-4"}),"Runtime Dashboard"]}),e.jsx(jt,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),e.jsx(qe,{className:"space-y-6",children:p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[e.jsx(tl,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Worker Process"]}),p.worker?e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Status"}),e.jsx(Ce,{variant:p.worker.status==="running"?"default":"secondary",children:p.worker.status})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"PID"}),e.jsx("span",{className:"font-mono text-xs",children:p.worker.pid??"—"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Uptime"}),e.jsx("span",{className:"text-xs",children:sb(p.worker.uptime)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Pending RPCs"}),e.jsx("span",{className:"text-xs",children:p.worker.pendingRequests})]}),p.worker.totalCrashes>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),e.jsxs("span",{className:"text-xs",children:[p.worker.consecutiveCrashes," consecutive / ",p.worker.totalCrashes," total"]})]}),p.worker.lastCrashAt&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last Crash"}),e.jsx("span",{className:"text-xs",children:nb(p.worker.lastCrashAt)})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No worker process registered."})]}),e.jsx($t,{}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[e.jsx(Nm,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Job Runs"]}),p.recentJobRuns.length>0?e.jsx("div",{className:"space-y-2",children:p.recentJobRuns.map(A=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(rb,{status:A.status}),e.jsx("span",{className:"truncate font-mono text-xs",title:A.jobKey??A.jobId,children:A.jobKey??A.jobId.slice(0,8)}),e.jsx(Ce,{variant:"outline",className:"px-1 py-0 text-[10px]",children:A.trigger})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[A.durationMs!=null?e.jsx("span",{children:Jl(A.durationMs)}):null,e.jsx("span",{title:A.createdAt,children:Yl(A.createdAt)})]})]},A.id))}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No job runs recorded yet."})]}),e.jsx($t,{}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[e.jsx(gx,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Webhook Deliveries"]}),p.recentWebhookDeliveries.length>0?e.jsx("div",{className:"space-y-2",children:p.recentWebhookDeliveries.map(A=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ab,{status:A.status}),e.jsx("span",{className:"truncate font-mono text-xs",title:A.webhookKey,children:A.webhookKey})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[A.durationMs!=null?e.jsx("span",{children:Jl(A.durationMs)}):null,e.jsx("span",{title:A.createdAt,children:Yl(A.createdAt)})]})]},A.id))}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No webhook deliveries recorded yet."})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/50 pt-2 text-xs text-muted-foreground",children:[e.jsx(Oa,{className:"h-3 w-3"}),"Last checked: ",new Date(p.checkedAt).toLocaleTimeString()]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Runtime diagnostics are unavailable right now."})})]}),h&&h.length>0?e.jsxs(Le,{children:[e.jsxs(tt,{children:[e.jsxs(st,{className:"text-base flex items-center gap-1.5",children:[e.jsx(il,{className:"h-4 w-4"}),"Recent Logs"]}),e.jsxs(jt,{children:["Last ",h.length," log entries"]})]}),e.jsx(qe,{children:e.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:h.map(A=>e.jsxs("div",{className:`flex gap-2 py-0.5 ${A.level==="error"?"text-destructive":A.level==="warn"?"text-yellow-600 dark:text-yellow-400":A.level==="debug"?"text-muted-foreground/60":"text-muted-foreground"}`,children:[e.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:new Date(A.createdAt).toLocaleTimeString()}),e.jsx(Ce,{variant:"outline",className:"h-4 shrink-0 px-1 text-[10px]",children:A.level}),e.jsx("span",{className:"truncate",title:A.message,children:A.message})]},A.id))})})]}):null]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(st,{className:"text-base flex items-center gap-1.5",children:[e.jsx(il,{className:"h-4 w-4"}),"Health Status"]})}),e.jsx(qe,{children:m?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking health..."}):d?e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Overall"}),e.jsx(Ce,{variant:d.healthy?"default":"destructive",children:d.status})]}),d.checks.length>0?e.jsx("div",{className:"space-y-2 border-t border-border/50 pt-2",children:d.checks.map((A,B)=>e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:"truncate text-muted-foreground",title:A.name,children:A.name}),A.passed?e.jsx(Am,{className:"h-4 w-4 shrink-0 text-green-500"}):e.jsx(bi,{className:"h-4 w-4 shrink-0 text-destructive"})]},B))}):null,d.lastError?e.jsx("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:d.lastError}):null]}):e.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Lifecycle"}),e.jsx(Ce,{variant:f,children:C})]}),e.jsx("p",{children:"Health checks run once the plugin is ready."}),o.lastError?e.jsx("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:o.lastError}):null]})})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsx(st,{className:"text-base",children:"Details"})}),e.jsxs(qe,{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{children:"Plugin ID"}),e.jsx("span",{className:"font-mono text-xs text-right",children:o.id})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{children:"Plugin Key"}),e.jsx("span",{className:"font-mono text-xs text-right",children:o.pluginKey})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{children:"NPM Package"}),e.jsx("span",{className:"max-w-[170px] truncate text-right text-xs",title:o.packageName,children:o.packageName})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{children:"Version"}),e.jsxs("span",{className:"text-right text-foreground",children:["v",o.manifestJson.version??o.version]})]})]})]}),e.jsxs(Le,{children:[e.jsx(tt,{children:e.jsxs(st,{className:"text-base flex items-center gap-1.5",children:[e.jsx(So,{className:"h-4 w-4"}),"Permissions"]})}),e.jsx(qe,{children:v.length>0?e.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground",children:v.map(A=>e.jsx("li",{className:"rounded-md bg-muted/40 px-2.5 py-2 font-mono text-xs text-foreground/85",children:A},A))}):e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No special permissions requested."})})]})]})]})})]})]})}function tb({pluginId:t,schema:s,initialValues:n,isLoading:r,pluginStatus:a,supportsConfigTest:i}){const l=_e(),[o,u]=c.useState(()=>({...Ea(s),...n??{}})),d=c.useRef(!1);c.useEffect(()=>{n&&!d.current&&(d.current=!0,u({...Ea(s),...n}))},[n,s]);const[m,p]=c.useState({}),[h,x]=c.useState(null),[y,N]=c.useState(null),b=JSON.stringify(o)!==JSON.stringify({...Ea(s),...n??{}}),g=re({mutationFn:j=>bt.saveConfig(t,j),onSuccess:()=>{x({type:"success",text:"Configuration saved."}),N(null),l.invalidateQueries({queryKey:P.plugins.config(t)}),setTimeout(()=>x(null),3e3)},onError:j=>{x({type:"error",text:j.message||"Failed to save configuration."})}}),T=re({mutationFn:j=>bt.testConfig(t,j),onSuccess:j=>{j.valid?N({type:"success",text:"Configuration test passed."}):N({type:"error",text:j.message||"Configuration test failed."})},onError:j=>{N({type:"error",text:j.message||"Configuration test failed."})}}),k=c.useCallback(j=>{u(j),p({}),x(null)},[]),C=c.useCallback(()=>{const j=Vr(s,o);if(Object.keys(j).length>0){p(j);return}p({}),g.mutate(o)},[s,o,g]),f=c.useCallback(()=>{const j=Vr(s,o);if(Object.keys(j).length>0){p(j);return}p({}),N(null),T.mutate(o)},[s,o,T]);return r?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[e.jsx(Ft,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Xc,{schema:s,values:o,onChange:k,errors:m,disabled:g.isPending}),h&&e.jsx("div",{className:`text-sm p-2 rounded border ${h.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:h.text}),y&&e.jsx("div",{className:`text-sm p-2 rounded border ${y.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:y.text}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx(F,{onClick:C,disabled:g.isPending||!b,size:"sm",children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),a==="ready"&&i&&e.jsx(F,{variant:"outline",onClick:f,disabled:T.isPending,size:"sm",children:T.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}function sb(t){if(t==null)return"—";const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const n=Math.floor(s/60);if(n<60)return`${n}m ${s%60}s`;const r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function Jl(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}function Yl(t){const s=Date.now(),n=new Date(t).getTime(),r=s-n;if(r<0)return"just now";const a=Math.floor(r/1e3);if(a<60)return`${a}s ago`;const i=Math.floor(a/60);if(i<60)return`${i}m ago`;const l=Math.floor(i/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function nb(t){return new Date(t).toLocaleString()}function rb({status:t}){const s=t==="success"||t==="succeeded"?"bg-green-500":t==="failed"?"bg-red-500":t==="running"?"bg-blue-500 animate-pulse":t==="cancelled"?"bg-gray-400":"bg-amber-500";return e.jsx("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s}`,title:t})}function ab({status:t}){const s=t==="processed"||t==="success"?"bg-green-500":t==="failed"?"bg-red-500":t==="received"?"bg-blue-500":"bg-amber-500";return e.jsx("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s}`,title:t})}function Xl(){const{companyPrefix:t,pluginId:s,pluginRoutePath:n}=Cs(),{companies:r,selectedCompanyId:a}=fe(),{setBreadcrumbs:i}=Fe(),l=c.useMemo(()=>{if(!t)return null;const x=t.toUpperCase();return r.find(y=>y.issuePrefix.toUpperCase()===x)??null},[r,t]),o=!!t&&!l,u=c.useMemo(()=>l?l.id:t?null:a??null,[l,t,a]),d=c.useMemo(()=>{var x;return u?((x=r.find(y=>y.id===u))==null?void 0:x.issuePrefix)??null:null},[r,u]),{data:m}=Q({queryKey:P.plugins.uiContributions,queryFn:()=>bt.listUiContributions(),enabled:!!u&&(!!s||!!n)}),p=c.useMemo(()=>{if(!m)return null;if(s){const y=m.find(b=>b.pluginId===s);if(!y)return null;const N=y.slots.find(b=>b.type==="page");return N?{...N,pluginId:y.pluginId,pluginKey:y.pluginKey,pluginDisplayName:y.displayName,pluginVersion:y.version}:null}if(!n)return null;const x=m.flatMap(y=>{const N=y.slots.find(b=>b.type==="page"&&b.routePath===n);return N?[{...N,pluginId:y.pluginId,pluginKey:y.pluginKey,pluginDisplayName:y.displayName,pluginVersion:y.version}]:[]});return x.length!==1?null:x[0]??null},[s,n,m]),h=c.useMemo(()=>({companyId:u??null,companyPrefix:d}),[u,d]);if(c.useEffect(()=>{p&&i([{label:"Plugins",href:"/instance/settings/plugins"},{label:p.pluginDisplayName}])},[p,d,i]),!u)return o?e.jsx(Hn,{scope:"invalid_company_prefix",requestedPrefix:t}):e.jsx("div",{className:"space-y-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a company to view this page."})});if(!m)return e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading…"});if(!s&&n&&m.filter(y=>y.slots.some(N=>N.type==="page"&&N.routePath===n)).length>1)return e.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Multiple plugins declare the route ",e.jsx("code",{children:n}),". Use the plugin-id route until the conflict is resolved."]});if(!p){if(n)return e.jsx(Hn,{scope:"board"});const x=s?`/instance/settings/plugins/${s}`:"/instance/settings/plugins";return e.jsx(Ie,{to:x,replace:!0})}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs(he,{to:d?`/${d}/dashboard`:"/dashboard",children:[e.jsx(ci,{className:"h-4 w-4 mr-1"}),"Back"]})})}),e.jsx(Yr,{slot:p,context:h,className:"min-h-[200px]",missingBehavior:"placeholder"})]})}const ys={sourceRunId:"65a79d5d-5f85-4392-a5cc-8fb48beb9e71",agentName:"CodexCoder",issueIdentifier:"PAP-473",issueTitle:"Humanize run transcripts across run detail and live surfaces",startedAt:"2026-03-11T15:21:05.948Z"},Wn=[{kind:"stderr",ts:"2026-03-11T15:21:05.594Z",text:'[paperclip] Skipping saved session resume for task "PAP-473" because wake reason is issue_assigned.'},{kind:"init",ts:"2026-03-11T15:21:05.948Z",model:"codex",sessionId:"sess_fixture_01"},{kind:"system",ts:"2026-03-11T15:21:07.249Z",text:"turn started"},{kind:"assistant",ts:"2026-03-11T15:21:18.851Z",text:"I’m starting with the Paperclip heartbeat procedure and the repo-required docs so I can see what task is actually assigned and then work only on that scope."},{kind:"tool_call",ts:"2026-03-11T15:21:19.026Z",name:"command_execution",toolUseId:"item_1",input:{command:"sed -n '1,220p' doc/GOAL.md",cwd:"/workspace/paperclip"}},{kind:"tool_call",ts:"2026-03-11T15:21:19.026Z",name:"command_execution",toolUseId:"item_2",input:{command:"sed -n '1,320p' doc/SPEC-implementation.md",cwd:"/workspace/paperclip"}},{kind:"tool_result",ts:"2026-03-11T15:21:19.034Z",toolUseId:"item_1",content:`command: sed -n '1,220p' doc/GOAL.md
|
|
240
|
+
status: completed
|
|
241
|
+
exit_code: 0
|
|
242
|
+
|
|
243
|
+
# Paperclip
|
|
244
|
+
|
|
245
|
+
Paperclip is the backbone of the autonomous economy.`,isError:!1},{kind:"tool_result",ts:"2026-03-11T15:21:19.035Z",toolUseId:"item_2",content:`command: sed -n '1,320p' doc/SPEC-implementation.md
|
|
246
|
+
status: completed
|
|
247
|
+
exit_code: 0
|
|
248
|
+
|
|
249
|
+
# Paperclip V1 Implementation Spec
|
|
250
|
+
|
|
251
|
+
Paperclip V1 must provide a full control-plane loop for autonomous agents.`,isError:!1},{kind:"assistant",ts:"2026-03-11T15:22:08.806Z",text:"I’ve got the rendering entry points. I’m reading the existing transcript parser and the three UI surfaces together so I can collapse them onto one renderer instead of layering another one-off view."},{kind:"thinking",ts:"2026-03-11T15:22:12.044Z",text:"The current transcript UX duplicates parsing logic in multiple surfaces. A shared presentation layer will make the detail page and live surfaces behave the same way while keeping raw fallback available."},{kind:"tool_call",ts:"2026-03-11T15:22:15.401Z",name:"command_execution",toolUseId:"item_3",input:{command:'rg -n "LiveRunWidget|ActiveAgentsPanel|buildTranscript|TranscriptEntry|transcript" ui/src server/src packages',cwd:"/workspace/paperclip"}},{kind:"tool_result",ts:"2026-03-11T15:22:15.982Z",toolUseId:"item_3",content:`command: rg -n ...
|
|
252
|
+
status: completed
|
|
253
|
+
exit_code: 0
|
|
254
|
+
|
|
255
|
+
ui/src/components/ActiveAgentsPanel.tsx
|
|
256
|
+
ui/src/components/LiveRunWidget.tsx
|
|
257
|
+
ui/src/pages/AgentDetail.tsx`,isError:!1},{kind:"system",ts:"2026-03-11T15:22:21.617Z",text:"item started: web_search (id=ws_fixture_reasoning_ui)"},{kind:"system",ts:"2026-03-11T15:22:24.806Z",text:"item completed: web_search (id=ws_fixture_reasoning_ui)"},{kind:"assistant",ts:"2026-03-11T15:22:29.214Z",text:"I’ve confirmed the duplication: the run page has the only full transcript renderer, while live surfaces still collapse output into feed strings. I’m pulling markdown utilities and adapter shapes now so the new renderer can stay shared."},{kind:"tool_call",ts:"2026-03-11T15:23:04.251Z",name:"command_execution",toolUseId:"item_4",input:{command:"pnpm -r typecheck",cwd:"/workspace/paperclip"}},{kind:"tool_result",ts:"2026-03-11T15:23:26.903Z",toolUseId:"item_4",content:`command: pnpm -r typecheck
|
|
258
|
+
status: completed
|
|
259
|
+
exit_code: 0
|
|
260
|
+
|
|
261
|
+
packages/adapter-utils typecheck: Done
|
|
262
|
+
server typecheck: Done
|
|
263
|
+
ui typecheck: Done
|
|
264
|
+
cli typecheck: Done`,isError:!1},{kind:"assistant",ts:"2026-03-11T15:23:34.102Z",text:"Typecheck is clean. I’m running the remaining repo checks now so the transcript work is verified under the full workspace build, not just the UI package."},{kind:"tool_call",ts:"2026-03-11T15:23:40.511Z",name:"command_execution",toolUseId:"item_5",input:{command:"pnpm test:run",cwd:"/workspace/paperclip"}},{kind:"tool_result",ts:"2026-03-11T15:23:56.944Z",toolUseId:"item_5",content:`command: pnpm test:run
|
|
265
|
+
status: failed
|
|
266
|
+
exit_code: 1
|
|
267
|
+
|
|
268
|
+
FAIL packages/db/src/runtime-config.test.ts
|
|
269
|
+
FAIL src/__tests__/worktree.test.ts
|
|
270
|
+
|
|
271
|
+
All transcript-adapter tests passed after snapshot updates.`,isError:!0},{kind:"thinking",ts:"2026-03-11T15:24:02.188Z",text:"The remaining failures are unrelated to transcript rendering, so I should isolate them in the handoff and keep the UI change set focused."},{kind:"assistant",ts:"2026-03-11T15:24:08.490Z",text:"The new parser metadata changed a few adapter test snapshots exactly where expected, and the remaining red tests are outside this change set. I’m keeping the transcript patch focused and shipping with that caveat called out."},{kind:"tool_call",ts:"2026-03-11T15:24:21.327Z",name:"command_execution",toolUseId:"item_6",input:{command:"pnpm build",cwd:"/workspace/paperclip"}},{kind:"tool_result",ts:"2026-03-11T15:24:44.030Z",toolUseId:"item_6",content:`command: pnpm build
|
|
272
|
+
status: completed
|
|
273
|
+
exit_code: 0
|
|
274
|
+
|
|
275
|
+
ui build: built successfully
|
|
276
|
+
cli build: Done`,isError:!1},{kind:"tool_call",ts:"2026-03-11T15:24:52.504Z",name:"command_execution",toolUseId:"item_7",input:{command:'git commit -m "Humanize run transcripts across run detail and live surfaces"',cwd:"/workspace/paperclip"}},{kind:"tool_result",ts:"2026-03-11T15:24:53.104Z",toolUseId:"item_7",content:`command: git commit ...
|
|
277
|
+
status: completed
|
|
278
|
+
exit_code: 0
|
|
279
|
+
|
|
280
|
+
87b8e21 Humanize run transcripts across run detail and live surfaces`,isError:!1},{kind:"assistant",ts:"2026-03-11T15:25:00.908Z",text:"Implemented the transcript UI refactor and switched the run detail page, issue live widget, and dashboard agent card onto the same rendering language."},{kind:"result",ts:"2026-03-11T15:25:05.440Z",text:"Transcript rollout complete with shared nice/raw rendering and compact live variants.",inputTokens:11240,outputTokens:3460,cachedTokens:520,costUsd:.048121,subtype:"success",isError:!1,errors:[]}],Ma=[{id:"detail",label:"Run Detail",eyebrow:"Full transcript",description:"The long-form run page with the `Nice | Raw` toggle and the most inspectable transcript view.",icon:Jm},{id:"live",label:"Issue Widget",eyebrow:"Live stream",description:"The issue-detail live run widget, optimized for following an active run without leaving the task page.",icon:ax},{id:"dashboard",label:"Dashboard Card",eyebrow:"Dense card",description:"The active-agents dashboard card, tuned for compact scanning while keeping the same transcript language.",icon:ex}];function Zc(t){return t==="dashboard"?Wn.slice(-9):t==="live"?Wn.slice(-14):Wn}function ib({mode:t,streaming:s,density:n}){return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-background/80 shadow-[0_24px_60px_rgba(15,23,42,0.08)]",children:[e.jsxs("div",{className:"border-b border-border/60 bg-background/90 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ce,{variant:"outline",className:"uppercase tracking-[0.18em] text-[10px]",children:"Run Detail"}),e.jsx(Pe,{status:s?"running":"succeeded"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:sa(ys.startedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm font-medium",children:["Transcript (",Wn.length,")"]})]}),e.jsx("div",{className:"max-h-[720px] overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(8,145,178,0.08),transparent_36%),radial-gradient(circle_at_bottom_right,rgba(245,158,11,0.10),transparent_28%)] p-5",children:e.jsx(na,{entries:Wn,mode:t,density:n,streaming:s})})]})}function lb({streaming:t,mode:s,density:n}){return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-cyan-500/25 bg-background/85 shadow-[0_20px_50px_rgba(6,182,212,0.10)]",children:[e.jsxs("div",{className:"border-b border-border/60 bg-cyan-500/[0.05] px-5 py-4",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.2em] text-cyan-700 dark:text-cyan-300",children:"Live Runs"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Compact live transcript stream for the issue detail page."})]}),e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(Ue,{name:ys.agentName,size:"sm"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"rounded-full border border-border/70 bg-background/70 px-2 py-1 font-mono",children:ys.sourceRunId.slice(0,8)}),e.jsx(Pe,{status:t?"running":"succeeded"}),e.jsx("span",{children:sa(ys.startedAt)})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/70 bg-background/70 px-2.5 py-1 text-[11px] text-muted-foreground",children:["Open run",e.jsx(In,{className:"h-3 w-3"})]})]}),e.jsx("div",{className:"max-h-[460px] overflow-y-auto pr-1",children:e.jsx(na,{entries:Zc("live"),mode:s,density:n,limit:n==="compact"?10:12,streaming:t})})]})]})}function ob({streaming:t,mode:s,density:n}){return e.jsx("div",{className:"max-w-md",children:e.jsxs("div",{className:z("flex h-[320px] flex-col overflow-hidden rounded-xl border shadow-[0_20px_40px_rgba(15,23,42,0.10)]",t?"border-cyan-500/25 bg-cyan-500/[0.04]":"border-border bg-background/75"),children:[e.jsxs("div",{className:"border-b border-border/60 px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:z("inline-flex h-2.5 w-2.5 rounded-full",t?"bg-cyan-500 shadow-[0_0_0_6px_rgba(34,211,238,0.12)]":"bg-muted-foreground/35")}),e.jsx(Ue,{name:ys.agentName,size:"sm"})]}),e.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:t?"Live now":"Finished 2m ago"})]}),e.jsx("span",{className:"rounded-full border border-border/70 bg-background/70 px-2 py-1 text-[10px] text-muted-foreground",children:e.jsx(In,{className:"h-2.5 w-2.5"})})]}),e.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-background/60 px-3 py-2 text-xs text-cyan-700 dark:text-cyan-300",children:[ys.issueIdentifier," - ",ys.issueTitle]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:e.jsx(na,{entries:Zc("dashboard"),mode:s,density:n,limit:n==="compact"?6:8,streaming:t})})]})})}function cb(){const[t,s]=c.useState("detail"),[n,r]=c.useState("nice"),[a,i]=c.useState(!0),[l,o]=c.useState("comfortable"),u=Ma.find(d=>d.id===t)??Ma[0];return e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[linear-gradient(135deg,rgba(8,145,178,0.08),transparent_28%),linear-gradient(180deg,rgba(245,158,11,0.08),transparent_40%),var(--background)] shadow-[0_28px_70px_rgba(15,23,42,0.10)]",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[260px_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"border-b border-border/60 bg-background/75 p-5 lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cyan-500/25 bg-cyan-500/[0.08] px-3 py-1 text-[10px] font-semibold uppercase tracking-[0.24em] text-cyan-700 dark:text-cyan-300",children:[e.jsx(ra,{className:"h-3.5 w-3.5"}),"UX Lab"]}),e.jsx("h1",{className:"mt-4 text-2xl font-semibold tracking-tight",children:"Run Transcript Fixtures"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Built from a real Paperclip development run, then sanitized so no secrets, local paths, or environment details survive into the fixture."})]}),e.jsx("div",{className:"space-y-2",children:Ma.map(d=>{const m=d.icon;return e.jsx("button",{type:"button",onClick:()=>s(d.id),className:z("w-full rounded-xl border px-4 py-3 text-left transition-all",t===d.id?"border-cyan-500/35 bg-cyan-500/[0.10] shadow-[0_12px_24px_rgba(6,182,212,0.12)]":"border-border/70 bg-background/70 hover:border-cyan-500/20 hover:bg-cyan-500/[0.04]"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"rounded-lg border border-current/15 p-2 text-cyan-700 dark:text-cyan-300",children:e.jsx(m,{className:"h-4 w-4"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:d.eyebrow}),e.jsx("span",{className:"mt-1 block text-sm font-medium",children:d.label}),e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:d.description})]})]})},d.id)})})]}),e.jsxs("main",{className:"min-w-0 p-5",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:u.eyebrow}),e.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:u.label}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm text-muted-foreground",children:u.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Ce,{variant:"outline",className:"rounded-full px-3 py-1 text-[10px] uppercase tracking-[0.18em]",children:["Source run ",ys.sourceRunId.slice(0,8)]}),e.jsx(Ce,{variant:"outline",className:"rounded-full px-3 py-1 text-[10px] uppercase tracking-[0.18em]",children:ys.issueIdentifier})]})]}),e.jsxs("div",{className:"mb-5 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Controls"}),e.jsx("div",{className:"inline-flex rounded-full border border-border/70 bg-background/80 p-1",children:["nice","raw"].map(d=>e.jsx("button",{type:"button",className:z("rounded-full px-3 py-1 text-xs font-medium capitalize transition-colors",n===d?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>r(d),children:d},d))}),e.jsx("div",{className:"inline-flex rounded-full border border-border/70 bg-background/80 p-1",children:["comfortable","compact"].map(d=>e.jsx("button",{type:"button",className:z("rounded-full px-3 py-1 text-xs font-medium capitalize transition-colors",l===d?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(d),children:d},d))}),e.jsx(F,{variant:"outline",size:"sm",className:"rounded-full",onClick:()=>i(d=>!d),children:a?"Show settled state":"Show streaming state"})]}),t==="detail"?e.jsx("div",{className:z(l==="compact"&&"max-w-5xl"),children:e.jsx(ib,{mode:n,streaming:a,density:l})}):t==="live"?e.jsx("div",{className:z(l==="compact"&&"max-w-4xl"),children:e.jsx(lb,{streaming:a,mode:n,density:l})}):e.jsx(ob,{streaming:a,mode:n,density:l})]})]})})})}const db=new Set(["claude_local","codex_local","gemini_local","opencode_local","pi_local","cursor","openclaw_gateway"]);function ub(t){const{adapterType:s,...n}=Po,r={...n,adapterType:t};return t==="codex_local"?(r.model=Eu,r.dangerouslyBypassSandbox=Mu):t==="gemini_local"?r.model=Du:t==="cursor"?r.model=_u:t==="opencode_local"&&(r.model=""),r}function mb(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),n=_e(),r=Rt(),[a]=fi(),i=a.get("adapterType"),[l,o]=c.useState(""),[u,d]=c.useState(""),[m,p]=c.useState("general"),[h,x]=c.useState(""),[y,N]=c.useState(Po),[b,g]=c.useState(!1),[T,k]=c.useState(!1),[C,f]=c.useState(null),{data:j}=Q({queryKey:P.agents.list(t),queryFn:()=>Te.list(t),enabled:!!t}),{data:v,error:U,isLoading:A,isFetching:B}=Q({queryKey:t?P.agents.adapterModels(t,y.adapterType):["agents","none","adapter-models",y.adapterType],queryFn:()=>Te.adapterModels(t,y.adapterType),enabled:!!t}),W=!j||j.length===0,S=W?"ceo":m;c.useEffect(()=>{s([{label:"Agents",href:"/agents"},{label:"New Agent"}])},[s]),c.useEffect(()=>{W&&(l||o("CEO"),u||d("CEO"))},[W]),c.useEffect(()=>{const M=i;M&&db.has(M)&&N(ee=>ee.adapterType===M?ee:ub(M))},[i]);const w=re({mutationFn:M=>Te.hire(t,M),onSuccess:M=>{n.invalidateQueries({queryKey:P.agents.list(t)}),n.invalidateQueries({queryKey:P.approvals.list(t)}),r(Sn(M.agent))},onError:M=>{f(M instanceof Error?M.message:"Failed to create agent")}});function te(){return Fu(y.adapterType).buildAdapterConfig(y)}function G(){if(!(!t||!l.trim())){if(f(null),y.adapterType==="opencode_local"){const M=y.model.trim();if(!M){f("OpenCode requires an explicit model in provider/model format.");return}if(U){f(U instanceof Error?U.message:"Failed to load OpenCode models.");return}if(A||B){f("OpenCode models are still loading. Please wait and try again.");return}const ee=v??[];if(!ee.some(L=>L.id===M)){f(ee.length===0?"No OpenCode models discovered. Run `opencode models` and authenticate providers.":`Configured OpenCode model is unavailable: ${M}`);return}}w.mutate({name:l.trim(),role:S,...u.trim()?{title:u.trim()}:{},...h?{reportsTo:h}:{},adapterType:y.adapterType,adapterConfig:te(),runtimeConfig:{heartbeat:{enabled:y.heartbeatEnabled,intervalSec:y.intervalSec,wakeOnDemand:!0,cooldownSec:10,maxConcurrentRuns:1}},budgetMonthlyCents:0})}}const K=(j??[]).find(M=>M.id===h);return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold",children:"New Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Advanced agent configuration"})]}),e.jsxs("div",{className:"border border-border",children:[e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsx("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Agent name",value:l,onChange:M=>o(M.target.value),autoFocus:!0})}),e.jsx("div",{className:"px-4 pb-2",children:e.jsx("input",{className:"w-full bg-transparent outline-none text-sm text-muted-foreground placeholder:text-muted-foreground/40",placeholder:"Title (e.g. VP of Engineering)",value:u,onChange:M=>d(M.target.value)})}),e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[e.jsxs(vt,{open:b,onOpenChange:g,children:[e.jsx(yt,{asChild:!0,children:e.jsxs("button",{className:z("inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",W&&"opacity-60 cursor-not-allowed"),disabled:W,children:[e.jsx(Tu,{className:"h-3 w-3 text-muted-foreground"}),fa[S]??S]})}),e.jsx(Nt,{className:"w-36 p-1",align:"start",children:To.map(M=>e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",M===m&&"bg-accent"),onClick:()=>{p(M),g(!1)},children:fa[M]??M},M))})]}),e.jsxs(vt,{open:T,onOpenChange:k,children:[e.jsx(yt,{asChild:!0,children:e.jsx("button",{className:z("inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",W&&"opacity-60 cursor-not-allowed"),disabled:W,children:K?e.jsxs(e.Fragment,{children:[e.jsx(_a,{icon:K.icon,className:"h-3 w-3 text-muted-foreground"}),`Reports to ${K.name}`]}):e.jsxs(e.Fragment,{children:[e.jsx(on,{className:"h-3 w-3 text-muted-foreground"}),W?"Reports to: N/A (CEO)":"Reports to..."]})})}),e.jsxs(Nt,{className:"w-48 p-1",align:"start",children:[e.jsx("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!h&&"bg-accent"),onClick:()=>{x(""),k(!1)},children:"No manager"}),(j??[]).map(M=>e.jsxs("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",M.id===h&&"bg-accent"),onClick:()=>{x(M.id),k(!1)},children:[e.jsx(_a,{icon:M.icon,className:"shrink-0 h-3 w-3 text-muted-foreground"}),M.name,e.jsx("span",{className:"text-muted-foreground ml-auto",children:fa[M.role]??M.role})]},M.id))]})]})]}),e.jsx(Ru,{mode:"create",values:y,onChange:M=>N(ee=>({...ee,...M})),adapterModels:v}),e.jsxs("div",{className:"border-t border-border px-4 py-3",children:[W&&e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"This will be the CEO"}),C&&e.jsx("p",{className:"text-xs text-destructive mb-2",children:C}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(F,{variant:"outline",size:"sm",onClick:()=>r("/agents"),children:"Cancel"}),e.jsx(F,{size:"sm",disabled:!l.trim()||w.isPending,onClick:G,children:w.isPending?"Creating…":"Create agent"})]})]})]})]})}const Zl=[{dot:"bg-violet-500",badge:"text-violet-500 bg-violet-500/10 border-violet-500/20"},{dot:"bg-blue-500",badge:"text-blue-500 bg-blue-500/10 border-blue-500/20"},{dot:"bg-amber-500",badge:"text-amber-500 bg-amber-500/10 border-amber-500/20"},{dot:"bg-orange-500",badge:"text-orange-500 bg-orange-500/10 border-orange-500/20"},{dot:"bg-green-500",badge:"text-green-500 bg-green-500/10 border-green-500/20"},{dot:"bg-pink-500",badge:"text-pink-500 bg-pink-500/10 border-pink-500/20"},{dot:"bg-cyan-500",badge:"text-cyan-500 bg-cyan-500/10 border-cyan-500/20"}];function xb(t){return Xr(t)}function ed(t,s){const n=s.indexOf(t);return Zl[(n>=0?n:0)%Zl.length]}function pb(t,s){var r;const n=ui({stageDefinitions:t.stageDefinitions,stageOrder:t.stageOrder});return((r=mi(n,s))==null?void 0:r.label)??xb(s)}function hb({ticket:t}){const s=t.stageOrder,n=s.indexOf(t.currentStage);return e.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:s.map((r,a)=>{const i=ed(r,s);return e.jsxs("div",{className:"flex items-center gap-0.5",children:[a>0&&e.jsx("div",{className:z("h-px w-3",a<=n?"bg-green-500/50":"bg-border")}),e.jsx("div",{className:z("h-2 w-2 rounded-full",a<n&&"bg-green-500/70",a===n&&i.dot,a>n&&"bg-border")})]},r)})})}function eo({ticket:t,liveCount:s}){const n=ed(t.currentStage,t.stageOrder),r=t.status==="done"||t.status==="cancelled";return e.jsxs(he,{to:`/tickets/${t.id}`,className:"flex items-center gap-4 px-4 py-3 text-sm hover:bg-accent/50 transition-colors no-underline text-inherit group",children:[e.jsx(hb,{ticket:t}),e.jsx("span",{className:z("flex-1 truncate font-medium",r&&"text-muted-foreground line-through decoration-muted-foreground/40"),children:t.title}),s>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-cyan-600 dark:text-cyan-400 font-medium shrink-0",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-cyan-400 opacity-70"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-cyan-500"})]}),s," live"]}),r&&e.jsx(pn,{className:"h-3.5 w-3.5 text-muted-foreground/40 shrink-0"}),e.jsx("span",{className:z("text-xs border rounded px-1.5 py-0.5 shrink-0",n.badge),children:pb(t,t.currentStage)}),e.jsx("span",{className:"text-xs font-mono text-muted-foreground/50 shrink-0",children:t.identifier}),e.jsx(zs,{className:"h-3.5 w-3.5 text-muted-foreground/40 shrink-0 group-hover:text-muted-foreground transition-colors"})]})}function gb(){const{selectedCompanyId:t}=fe(),{setBreadcrumbs:s}=Fe(),[n,r]=c.useState(!1),[a,i]=c.useState(!1);c.useEffect(()=>{s([{label:"Tickets"}])},[s]);const{data:l,isLoading:o}=Q({queryKey:P.tickets.list(t),queryFn:()=>bs.list(t),enabled:!!t,refetchInterval:5e3}),{data:u=[]}=Q({queryKey:P.liveRuns(t),queryFn:()=>Tt.liveRunsForCompany(t,100),enabled:!!t,refetchInterval:5e3}),d=c.useMemo(()=>{const x=new Map;for(const y of u){if(y.status!=="running"&&y.status!=="queued")continue;const N=y.ticketId;N&&x.set(N,(x.get(N)??0)+1)}return x},[u]);if(o)return e.jsx(ot,{variant:"list"});const m=(l==null?void 0:l.filter(x=>x.status==="active"))??[],p=(l==null?void 0:l.filter(x=>x.status!=="active"))??[],h=m.reduce((x,y)=>x+(d.get(y.id)??0),0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Tickets"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[m.length," active",h>0&&e.jsxs("span",{className:"ml-2 text-cyan-600 dark:text-cyan-400 font-medium",children:["· ",h," agent",h!==1?"s":""," live"]}),p.length>0&&` · ${p.length} closed`]})]}),e.jsxs(F,{size:"sm",onClick:()=>r(!0),children:[e.jsx(Ae,{className:"h-4 w-4 mr-1"})," New Ticket"]})]}),e.jsx(Mc,{open:n,onClose:()=>r(!1),companyId:t,onSuccess:x=>{r(!1),window.location.href=`/tickets/${x}`}}),!l||l.length===0?e.jsx(rt,{icon:lo,message:"No tickets yet. Create one to group issues across your agent pipeline.",action:"New Ticket",onAction:()=>r(!0)}):e.jsxs("div",{className:"space-y-5",children:[m.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Active"}),e.jsx("div",{className:"border border-border divide-y divide-border overflow-hidden rounded-lg",children:m.map(x=>e.jsx(eo,{ticket:x,liveCount:d.get(x.id)??0},x.id))})]}),p.length>0&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>i(x=>!x),className:"flex items-center gap-2 text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2 hover:text-foreground transition-colors",children:[a?"▾":"▸"," Closed (",p.length,")"]}),a&&e.jsx("div",{className:"border border-border divide-y divide-border overflow-hidden rounded-lg opacity-60",children:p.map(x=>e.jsx(eo,{ticket:x,liveCount:0},x.id))})]})]})]})}const to=[{dot:"bg-violet-500",ring:"ring-violet-500/30",text:"text-violet-500"},{dot:"bg-blue-500",ring:"ring-blue-500/30",text:"text-blue-500"},{dot:"bg-amber-500",ring:"ring-amber-500/30",text:"text-amber-500"},{dot:"bg-orange-500",ring:"ring-orange-500/30",text:"text-orange-500"},{dot:"bg-green-500",ring:"ring-green-500/30",text:"text-green-500"},{dot:"bg-pink-500",ring:"ring-pink-500/30",text:"text-pink-500"},{dot:"bg-cyan-500",ring:"ring-cyan-500/30",text:"text-cyan-500"}];function Fn(t,s){const n=s.indexOf(t);return to[(n>=0?n:0)%to.length]}function wr(t){return Xr(t)}function Ln({value:t,onSave:s,className:n,multiline:r,placeholder:a}){const[i,l]=c.useState(!1),[o,u]=c.useState(t),d=c.useRef(null);c.useEffect(()=>{var h;i&&((h=d.current)==null||h.focus())},[i]);function m(){const h=o.trim();h&&h!==t&&s(h),l(!1)}if(!i)return e.jsxs("button",{onClick:()=>{u(t),l(!0)},className:z("group text-left hover:bg-accent/40 rounded px-1 -mx-1 transition-colors cursor-text flex items-start gap-1 w-full",n),children:[e.jsx("span",{className:z(!t&&"text-muted-foreground/40 italic"),children:t||a||"Click to edit…"}),e.jsx(Qa,{className:"h-3 w-3 mt-0.5 opacity-0 group-hover:opacity-40 shrink-0 transition-opacity"})]});const p={ref:d,value:o,onChange:h=>u(h.target.value),onBlur:m,onKeyDown:h=>{h.key==="Enter"&&!r&&(h.preventDefault(),m()),h.key==="Escape"&&l(!1)},className:z("w-full bg-background border border-border rounded px-2 py-1 outline-none text-inherit resize-none",n)};return r?e.jsx("textarea",{...p,rows:3}):e.jsx("input",{...p})}function td({onConfirm:t,children:s,confirmLabel:n="Confirm",danger:r=!1,className:a}){const[i,l]=c.useState(!1);return i?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{l(!1),t()},className:z("text-xs px-2 py-0.5 rounded border font-medium",r?"border-red-500/40 text-red-500 hover:bg-red-500/10":"border-border text-foreground hover:bg-accent"),children:n}),e.jsx("button",{onClick:()=>l(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:e.jsx(nt,{className:"h-3 w-3"})})]}):e.jsx("button",{onClick:()=>l(!0),className:a,children:s})}const fb={todo:"in_progress",in_progress:"done",done:"todo",backlog:"todo",in_review:"done",blocked:"todo"};function bb({issue:t,agents:s,activeRun:n,isDispatching:r,transcript:a,hasOutput:i,onDispatch:l,onStop:o,onUpdateIssue:u,onDeleteIssue:d,stages:m,currentStage:p,issueLinkState:h}){const x=Rt(),[y,N]=c.useState(!1),b=!!n,g=!b&&!r,T=`/issues/${t.identifier??t.id}`,k=()=>x(T,{state:h});c.useEffect(()=>{b&&N(!0)},[b]);const C=s.find(f=>f.id===t.assigneeAgentId);return e.jsxs("div",{className:z("transition-colors",b?"bg-cyan-500/[0.03] border-l-2 border-l-cyan-500/40":"hover:bg-accent/20"),children:[e.jsxs("div",{className:"flex cursor-pointer items-center gap-3 px-4 py-3",onClick:k,children:[e.jsx("button",{onClick:f=>{f.stopPropagation(),u({status:fb[t.status]??"todo"})},title:`${t.status} — click to cycle`,className:"shrink-0 hover:scale-110 transition-transform",children:e.jsx(ft,{status:t.status})}),e.jsx("div",{className:"flex-1 min-w-0",onClick:f=>f.stopPropagation(),children:e.jsx(Ln,{value:t.title,onSave:f=>u({title:f}),className:"text-sm font-medium"})}),b&&n&&e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:f=>{f.stopPropagation(),N(j=>!j)},className:"flex items-center gap-1.5 text-[11px] text-cyan-600 dark:text-cyan-400 font-medium hover:underline",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-cyan-400 opacity-70"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-cyan-500"})]}),n.agentName," · ",ar(n.createdAt),y?e.jsx(yi,{className:"h-3 w-3"}):e.jsx($s,{className:"h-3 w-3"})]}),e.jsxs("button",{onClick:f=>{f.stopPropagation(),o(n.id)},className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground border border-border rounded px-1.5 py-0.5 transition-colors",children:[e.jsx(Ro,{className:"h-2.5 w-2.5 fill-current"})," Stop"]})]}),g&&t.assigneeAgentId&&e.jsx("button",{onClick:f=>{f.stopPropagation(),l(t.assigneeAgentId)},disabled:r,className:"flex items-center gap-1 text-[11px] font-medium text-foreground border border-border hover:bg-accent rounded-md px-2 py-1 transition-colors shrink-0",title:`Run with ${(C==null?void 0:C.name)??"agent"}`,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"h-3 w-3 animate-spin"})," Running…"]}):e.jsxs(e.Fragment,{children:[e.jsx(La,{className:"h-3 w-3 fill-current"})," Run"]})}),e.jsx(he,{to:T,state:h,onClick:f=>f.stopPropagation(),className:"text-xs font-mono text-muted-foreground/40 shrink-0 hover:text-foreground transition-colors",children:t.identifier??t.id.slice(0,8)}),e.jsx(td,{onConfirm:d,confirmLabel:"Delete",danger:!0,className:"shrink-0 text-muted-foreground/30 hover:text-red-500 transition-colors",children:e.jsx(Jt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex cursor-pointer items-center gap-2 px-4 pb-2.5 pl-11",onClick:k,children:[e.jsx("span",{className:"text-[11px] text-muted-foreground/50 shrink-0",children:"Agent"}),e.jsxs("select",{value:t.assigneeAgentId??"",onClick:f=>f.stopPropagation(),onChange:f=>{f.stopPropagation(),u({assigneeAgentId:f.target.value||null})},className:"text-xs bg-background border border-border rounded px-2 py-0.5 outline-none text-foreground cursor-pointer max-w-[240px]",children:[e.jsx("option",{value:"",children:"— Unassigned —"}),s.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]}),g&&!t.assigneeAgentId&&e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"← assign then Run"}),t.assigneeAgentId&&g&&e.jsxs("button",{onClick:f=>{f.stopPropagation(),l(t.assigneeAgentId)},className:"flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded border border-border hover:bg-accent transition-colors",children:[e.jsx(La,{className:"h-2.5 w-2.5 fill-current"})," Run"]})]}),y&&e.jsxs("div",{className:"mx-4 mb-3 rounded-lg border border-cyan-500/20 bg-background/60 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border/50",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Live output"}),e.jsx("button",{onClick:()=>N(!1),className:"text-muted-foreground hover:text-foreground",children:e.jsx(nt,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto p-3",children:e.jsx(na,{entries:a,density:"compact",limit:12,streaming:b,collapseStdout:!0,thinkingClassName:"!text-[10px] !leading-4",emptyMessage:i?"Parsing output…":b?"Waiting for agent output…":"No transcript captured."})})]})]})}function jb({agents:t,spawning:s,onSubmit:n,onCancel:r}){var u;const[a,i]=c.useState(""),[l,o]=c.useState(((u=t[0])==null?void 0:u.id)??"");return e.jsxs("div",{className:"mx-4 mb-3 rounded-lg border border-border bg-background p-3 space-y-3",children:[e.jsx("input",{autoFocus:!0,placeholder:"Task title…",value:a,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&a.trim()&&n(a.trim(),l),d.key==="Escape"&&r()},className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground/60 border-b border-border pb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:l,onChange:d=>o(d.target.value),className:"flex-1 text-xs bg-background border border-border rounded-md px-2 py-1.5 outline-none",children:[e.jsx("option",{value:"",children:"— No agent —"}),t.map(d=>e.jsx("option",{value:d.id,children:d.name},d.id))]}),e.jsx(F,{size:"sm",disabled:!a.trim()||s,onClick:()=>n(a.trim(),l),className:"gap-1.5 shrink-0",children:s?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"h-3.5 w-3.5 animate-spin"})," Creating…"]}):l?e.jsxs(e.Fragment,{children:[e.jsx(La,{className:"h-3.5 w-3.5"})," Create & Run"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"h-3.5 w-3.5"})," Create"]})}),e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground shrink-0",children:e.jsx(nt,{className:"h-4 w-4"})})]}),l&&e.jsx("p",{className:"text-[11px] text-muted-foreground/40",children:"Agent will be dispatched immediately after creation."})]})}function vb(){const{ticketId:t}=Cs(),s=Rt(),{selectedCompanyId:n}=fe(),{setBreadcrumbs:r}=Fe(),a=_e(),[i,l]=c.useState(null),[o,u]=c.useState(!1),[d,m]=c.useState(""),[p,h]=c.useState(!1),[x,y]=c.useState(null),[N,b]=c.useState(!1),{data:g,isLoading:T}=Q({queryKey:P.tickets.detail(t),queryFn:()=>bs.get(n,t),enabled:!!n&&!!t,refetchInterval:6e3}),{data:k=[]}=Q({queryKey:P.agents.list(n),queryFn:()=>Te.list(n),enabled:!!n}),{data:C=[]}=Q({queryKey:P.liveRuns(n),queryFn:()=>Tt.liveRunsForCompany(n,50),enabled:!!n,refetchInterval:3e3}),f=g,j=f?Tr([{label:"Tickets",href:"/tickets"},{label:f.identifier??f.id.slice(0,8),href:`/tickets/${f.id}`}]):Tr("Tickets","/tickets"),v=new Set(((f==null?void 0:f.issues)??[]).flatMap(O=>C.filter(ne=>ne.issueId===O.id).map(ne=>ne.id))),U=C.filter(O=>v.has(O.id)&&(O.status==="running"||O.status==="queued")),{transcriptByRun:A,hasOutputForRun:B}=$u({runs:U,companyId:n,maxChunksPerRun:150});function W(){a.invalidateQueries({queryKey:P.tickets.detail(t)}),a.invalidateQueries({queryKey:P.tickets.list(n)})}function S(O){a.setQueryData(P.tickets.list(n),ne=>O(ne??[]))}const w=ui({stageDefinitions:f==null?void 0:f.stageDefinitions,stageOrder:f==null?void 0:f.stageOrder});function te(O){var ne;return((ne=mi(w,O))==null?void 0:ne.label)??wr(O)}function G(O,ne=(f==null?void 0:f.currentStage)??null){const ie=sl(O),se=ne&&ie.includes(ne)?ne:ie[0];se&&K({stageDefinitions:O,currentStage:se})}const{mutate:K}=re({mutationFn:O=>bs.update(n,t,O),onSuccess:O=>{S(ne=>ne.map(ie=>ie.id===t?{...ie,...O}:ie)),W()}}),{mutate:M}=re({mutationFn:()=>bs.remove(n,t),onSuccess:()=>{S(O=>O.filter(ne=>ne.id!==t)),s("/tickets")}}),{mutate:ee,isPending:L}=re({mutationFn:()=>bs.advanceStage(n,t),onSuccess:O=>{S(ne=>ne.map(ie=>ie.id===t?{...ie,...O}:ie)),W()}}),{mutate:ae,isPending:oe}=re({mutationFn:async({title:O,agentId:ne,stage:ie})=>{const se=await Ve.create(n,{title:O,assigneeAgentId:ne||void 0,ticketId:t,ticketStage:ie,status:"todo"});return ne&&(se!=null&&se.id)&&await Te.wakeup(ne,{source:"assignment",triggerDetail:"manual",reason:"ticket_task_created",payload:{issueId:se.id}}),se},onSuccess:()=>{W(),a.invalidateQueries({queryKey:P.issues.list(n)}),l(null)}}),{mutate:q}=re({mutationFn:({id:O,patch:ne})=>Ve.update(O,ne),onSuccess:W}),{mutate:H}=re({mutationFn:O=>Ve.remove(O),onSuccess:()=>{W(),a.invalidateQueries({queryKey:P.issues.list(n)})}}),{mutate:I}=re({mutationFn:async({issueId:O,agentId:ne})=>(await Ve.update(O,{assigneeAgentId:ne,status:"todo"}),Te.wakeup(ne,{source:"assignment",triggerDetail:"manual",reason:"ticket_dispatch",payload:{issueId:O}})),onMutate:({issueId:O})=>y(O),onSettled:()=>y(null),onSuccess:()=>{W(),a.invalidateQueries({queryKey:P.issues.list(n)}),a.invalidateQueries({queryKey:P.liveRuns(n)})}}),{mutate:R}=re({mutationFn:O=>Tt.cancel(O),onSuccess:()=>{a.invalidateQueries({queryKey:P.liveRuns(n)})}});if(c.useEffect(()=>{f&&r([{label:"Tickets",href:"/tickets"},{label:f.identifier??f.id.slice(0,8)}])},[f,r]),T||!f)return e.jsx(ot,{variant:"detail"});const D=sl(w),Z=D.indexOf(f.currentStage),me=Z===D.length-1,xe=f.status==="done"||f.status==="cancelled",$=D.reduce((O,ne)=>(O[ne]=(f.issues??[]).filter(ie=>ie.ticketStage===ne),O),{}),ce=new Map;for(const O of C)O.issueId&&(O.status==="running"||O.status==="queued")&&(ce.has(O.issueId)||ce.set(O.issueId,O));const ue=$[f.currentStage]??[],Re=ue.filter(O=>ce.has(O.id)).length,De=ue.length>0&&ue.every(O=>O.status==="done"),We=ue.filter(O=>O.assigneeAgentId&&!ce.has(O.id)&&x!==O.id);async function xt(){if(We.length){b(!0);try{await Promise.all(We.map(async O=>{await Ve.update(O.id,{assigneeAgentId:O.assigneeAgentId,status:"todo"}),await Te.wakeup(O.assigneeAgentId,{source:"assignment",triggerDetail:"manual",reason:"ticket_run_all",payload:{issueId:O.id}})})),W(),a.invalidateQueries({queryKey:P.liveRuns(n)})}finally{b(!1)}}}async function Ct(){const O=ue.map(ne=>ce.get(ne.id)).filter(Boolean);for(const ne of O)await Tt.cancel(ne.id);a.invalidateQueries({queryKey:P.liveRuns(n)})}function V(){const O=Bu(d);!O||D.includes(O)||(G([...w,{key:O,label:Xr(d),kind:"custom",handoffMode:"manual"}]),m(""),u(!1))}function pe(O){var ie;if(D.length<=1)return;const ne=w.filter(se=>se.key!==O);G(ne,O===((f==null?void 0:f.currentStage)??null)?((ie=ne[0])==null?void 0:ie.key)??null:(f==null?void 0:f.currentStage)??null)}function ye(O,ne){const ie=ne.trim();ie&&G(w.map(se=>se.key===O?{...se,label:ie}:se),(f==null?void 0:f.currentStage)??null)}function Ee(O,ne){const ie=w.findIndex(pt=>pt.key===O),se=ie+ne;if(ie===-1||se<0||se>=w.length)return;const ve=[...w],[ze]=ve.splice(ie,1);ve.splice(se,0,ze),G(ve,(f==null?void 0:f.currentStage)??null)}function Be(O,ne){G(w.map(ie=>ie.key===O?{...ie,...ne}:ie),(f==null?void 0:f.currentStage)??null)}const Ot=Fn(f.currentStage,D);return e.jsxs("div",{className:"space-y-5 max-w-3xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-mono text-muted-foreground",children:f.identifier}),e.jsx(Ln,{value:f.title,onSave:O=>K({title:O}),className:"text-xl font-semibold"}),e.jsx(Ln,{value:f.description??"",onSave:O=>K({description:O}),className:"text-sm text-muted-foreground",multiline:!0,placeholder:"Add description…"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!xe&&!me&&e.jsxs(F,{size:"sm",onClick:()=>ee(),disabled:L,className:z(De&&"ring-2 ring-offset-2 ring-foreground/20"),children:[e.jsx(zs,{className:"h-4 w-4 mr-1.5"}),te(D[Z+1])]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>h(O=>!O),className:"flex items-center justify-center h-8 w-8 rounded-md border border-border hover:bg-accent transition-colors",children:e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),e.jsxs("div",{className:"absolute right-0 top-9 z-20 w-48 rounded-lg border border-border bg-popover shadow-lg py-1 text-sm",children:[xe?e.jsxs("button",{onClick:()=>{h(!1),K({status:"active"})},className:"flex items-center gap-2 w-full px-3 py-2 hover:bg-accent text-left",children:[e.jsx(zs,{className:"h-3.5 w-3.5"})," Reopen"]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{h(!1),K({status:"paused"})},className:"flex items-center gap-2 w-full px-3 py-2 hover:bg-accent text-left",children:"Pause ticket"}),e.jsxs("button",{onClick:()=>{h(!1),K({status:"done"})},className:"flex items-center gap-2 w-full px-3 py-2 hover:bg-accent text-left",children:[e.jsx(pn,{className:"h-3.5 w-3.5 text-green-500"})," Close ticket"]})]}),e.jsx("div",{className:"border-t border-border my-1"}),e.jsxs("div",{className:"flex items-center gap-2 w-full px-3 py-2 hover:bg-red-500/10 text-red-500 cursor-pointer",children:[e.jsx(Jt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(td,{onConfirm:()=>{h(!1),M()},confirmLabel:"Delete",danger:!0,className:"text-red-500 text-sm",children:"Delete ticket…"})]})]})]})]})]})]}),xe&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-accent/40 px-4 py-2.5 text-sm",children:[e.jsx(pn,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("span",{className:"text-muted-foreground font-medium",children:["Ticket ",f.status==="cancelled"?"cancelled":"closed"]}),e.jsx("button",{onClick:()=>K({status:"active"}),className:"ml-auto text-xs text-muted-foreground hover:text-foreground underline",children:"Reopen"})]}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-wrap",children:[D.map((O,ne)=>{const ie=Fn(O,D),se=ne<Z,ve=ne===Z;return e.jsxs("div",{className:"flex items-center gap-0.5 group/stage",children:[ne>0&&e.jsx(Ns,{className:"h-3 w-3 text-border mx-0.5 shrink-0"}),e.jsxs("div",{onClick:()=>O!==f.currentStage&&K({currentStage:O}),className:z("flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-all cursor-pointer select-none",ve&&"border border-border bg-accent",se&&"text-muted-foreground hover:bg-accent/50",!ve&&!se&&"text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/40"),children:[se?e.jsx(Qt,{className:"h-3 w-3 text-muted-foreground shrink-0"}):e.jsx("div",{className:z("h-1.5 w-1.5 rounded-full shrink-0",ve?ie.dot:"bg-border/50")}),e.jsx("span",{onClick:ze=>ze.stopPropagation(),children:e.jsx(Ln,{value:te(O),onSave:ze=>ye(O,ze),className:"text-xs font-medium"})}),D.length>1&&e.jsx("button",{onClick:ze=>{ze.stopPropagation(),pe(O)},className:"opacity-0 group-hover/stage:opacity-60 hover:!opacity-100 transition-opacity ml-0.5",children:e.jsx(nt,{className:"h-2.5 w-2.5"})})]})]},O)}),o?e.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[e.jsx(Ns,{className:"h-3 w-3 text-border"}),e.jsx("input",{autoFocus:!0,value:d,onChange:O=>m(O.target.value),placeholder:"stage name",onKeyDown:O=>{O.key==="Enter"&&V(),O.key==="Escape"&&u(!1)},className:"text-xs bg-background border border-border rounded px-2 py-0.5 outline-none w-24"}),e.jsx("button",{onClick:V,className:"text-xs text-foreground/60 hover:text-foreground px-1",children:"+"}),e.jsx("button",{onClick:()=>u(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:e.jsx(nt,{className:"h-3 w-3"})})]}):e.jsxs("button",{onClick:()=>u(!0),className:"ml-2 text-xs text-muted-foreground/40 hover:text-muted-foreground flex items-center gap-1 transition-colors",children:[e.jsx(Ae,{className:"h-3 w-3"})," Add stage"]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card/70 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Stage Contract"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"User-facing labels, owner roles, handoff mode, and per-stage instructions stay attached to the ticket."})]}),e.jsxs("span",{className:"text-[11px] font-mono text-muted-foreground",children:[w.length," stages"]})]}),e.jsx("div",{className:"space-y-3",children:w.map((O,ne)=>{const ie=O.key===f.currentStage;return e.jsxs("div",{className:"rounded-lg border border-border bg-background/60 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:z("h-2 w-2 rounded-full",Fn(O.key,D).dot)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(Ln,{value:O.label,onSave:se=>ye(O.key,se),className:"text-sm font-medium"}),e.jsx("p",{className:"text-[11px] font-mono text-muted-foreground mt-1",children:O.key})]}),ie&&e.jsx("span",{className:"rounded-full border border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:"current"}),e.jsx("button",{type:"button",onClick:()=>Ee(O.key,-1),disabled:ne===0,className:"rounded border border-border p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:e.jsx(yi,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:()=>Ee(O.key,1),disabled:ne===w.length-1,className:"rounded border border-border p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:e.jsx($s,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("label",{className:"space-y-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Kind"}),e.jsx("select",{value:O.kind??"custom",onChange:se=>Be(O.key,{kind:se.target.value}),className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none",children:Ou.map(se=>e.jsx("option",{value:se,children:wr(se)},se))})]}),e.jsxs("label",{className:"space-y-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Owner role"}),e.jsxs("select",{value:O.ownerRole??"",onChange:se=>Be(O.key,{ownerRole:se.target.value||null}),className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none",children:[e.jsx("option",{value:"",children:"Ticket lead fallback"}),To.map(se=>e.jsx("option",{value:se,children:wr(se)},se))]})]}),e.jsxs("label",{className:"space-y-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Handoff mode"}),e.jsxs("select",{value:O.handoffMode??"",onChange:se=>Be(O.key,{handoffMode:se.target.value||null}),className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none",children:[e.jsx("option",{value:"",children:"Default"}),Lu.map(se=>e.jsx("option",{value:se,children:wr(se)},se))]})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("label",{className:"space-y-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Stage instructions"}),e.jsx("textarea",{defaultValue:O.instructions??"",onBlur:se=>Be(O.key,{instructions:se.target.value.trim()||null}),placeholder:"Instructions for the stage issue bootstrap.",rows:3,className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none resize-y"})]}),e.jsxs("label",{className:"space-y-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Exit criteria"}),e.jsx("textarea",{defaultValue:O.exitCriteria??"",onBlur:se=>Be(O.key,{exitCriteria:se.target.value.trim()||null}),placeholder:"What must be true before this stage is advanced?",rows:3,className:"w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none resize-y"})]})]})]},O.key)})})]}),(()=>{const O=f.currentStage,ne=$[O]??[];return e.jsxs("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("div",{className:z("h-2 w-2 rounded-full",Ot.dot)}),e.jsx("span",{className:"text-sm font-semibold",children:te(O)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"— active"}),Re>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-cyan-600 dark:text-cyan-400 font-medium",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-cyan-400 opacity-70"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-cyan-500"})]}),Re," agent",Re!==1?"s":""," live"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Z>0&&e.jsx("button",{onClick:()=>K({currentStage:D[Z-1]}),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground border border-border rounded-md px-2 py-1 transition-colors",title:"Back one stage",children:e.jsx(qu,{className:"h-3.5 w-3.5"})}),Re>0&&e.jsxs("button",{onClick:Ct,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground border border-border rounded-md px-2.5 py-1.5 transition-colors",children:[e.jsx(Ro,{className:"h-3 w-3 fill-current"})," Stop all"]}),We.length>0&&e.jsx("button",{onClick:xt,disabled:N,className:"flex items-center gap-1.5 text-xs font-semibold px-2.5 py-1.5 rounded-md border border-border bg-foreground text-background hover:opacity-90 transition-opacity disabled:opacity-50",children:N?e.jsxs(e.Fragment,{children:[e.jsx(Ft,{className:"h-3.5 w-3.5 animate-spin"})," Running…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sm,{className:"h-3.5 w-3.5"})," Run all (",We.length,")"]})}),e.jsxs("button",{onClick:()=>l(i===O?null:O),className:"flex items-center gap-1.5 text-xs font-medium px-2.5 py-1.5 rounded-md border border-border hover:bg-accent transition-colors",children:[e.jsx(Pr,{className:"h-3.5 w-3.5"})," New Task"]})]})]}),i===O&&e.jsx(jb,{agents:k,spawning:oe,onSubmit:(ie,se)=>ae({title:ie,agentId:se,stage:O}),onCancel:()=>l(null)}),ne.length===0&&i!==O?e.jsxs("div",{className:"px-4 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground/50 mb-3",children:"No tasks in this stage yet."}),e.jsxs("button",{onClick:()=>l(O),className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground border border-dashed border-border rounded-md px-3 py-1.5 transition-colors",children:[e.jsx(Ae,{className:"h-3.5 w-3.5"})," Add first task"]})]}):e.jsx("div",{className:"divide-y divide-border/40",children:ne.map(ie=>{const se=ce.get(ie.id),ve=se==null?void 0:se.id,ze=ve?A.get(ve)??[]:[],pt=ve?B(ve):!1;return e.jsx(bb,{issue:ie,agents:k,activeRun:se,isDispatching:x===ie.id,transcript:ze,hasOutput:pt,onDispatch:Qe=>I({issueId:ie.id,agentId:Qe}),onStop:Qe=>R(Qe),onUpdateIssue:Qe=>q({id:ie.id,patch:Qe}),onDeleteIssue:()=>H(ie.id),stages:D,currentStage:O,issueLinkState:j},ie.id)})}),De&&!me&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-green-500/5",children:[e.jsx(Qt,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground font-medium flex-1",children:"All tasks done — ready to advance"}),e.jsxs(F,{size:"sm",onClick:()=>ee(),disabled:L,children:[e.jsx(zs,{className:"h-3.5 w-3.5 mr-1.5"}),"Advance to ",te(D[Z+1])]})]}),De&&me&&!xe&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-green-500/5",children:[e.jsx(Qt,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground font-medium flex-1",children:"All stages complete"}),e.jsxs(F,{size:"sm",onClick:()=>K({status:"done"}),children:[e.jsx(pn,{className:"h-3.5 w-3.5 mr-1.5"})," Close ticket"]})]})]})})(),Z>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground/50 uppercase tracking-wide px-1",children:"Completed"}),D.slice(0,Z).map(O=>{const ne=$[O]??[],ie=ne.filter(ve=>ve.status==="done").length,se=Fn(O,D);return e.jsxs("button",{onClick:()=>K({currentStage:O}),className:"flex items-center gap-3 px-4 py-2.5 rounded-lg border border-border/50 bg-accent/20 text-sm w-full text-left hover:bg-accent/50 transition-colors",children:[e.jsx(Qt,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0"}),e.jsx("div",{className:z("h-1.5 w-1.5 rounded-full shrink-0",se.dot)}),e.jsx("span",{className:"font-medium text-muted-foreground",children:te(O)}),e.jsxs("span",{className:"text-xs text-muted-foreground/50",children:[ie,"/",ne.length," tasks done"]}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/30",children:"revisit →"})]},O)})]}),Z<D.length-1&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold text-muted-foreground/30 uppercase tracking-wide px-1",children:"Up next"}),D.slice(Z+1).map(O=>{const ne=Fn(O,D),ie=$[O]??[];return e.jsxs("button",{onClick:()=>K({currentStage:O}),className:"flex items-center gap-3 px-4 py-2.5 rounded-lg border border-border/30 text-sm opacity-40 hover:opacity-70 transition-opacity w-full text-left",children:[e.jsx("div",{className:z("h-1.5 w-1.5 rounded-full shrink-0",ne.dot)}),e.jsx("span",{className:"font-medium",children:te(O)}),ie.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground/50",children:[ie.length," task",ie.length!==1?"s":""]}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/30",children:"jump ahead →"})]},O)})]})]})}function yb({hasActiveInvite:t=!1}){return e.jsx("div",{className:"mx-auto max-w-xl py-10",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Instance setup required"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:t?"No instance admin exists yet. A bootstrap invite is already active. Check your Paperclip startup logs for the first admin invite URL, or run this command to rotate it:":"No instance admin exists yet. Run this command in your Paperclip environment to generate the first admin invite URL:"}),e.jsx("pre",{className:"mt-4 overflow-x-auto rounded-md border border-border bg-muted/30 p-3 text-xs",children:"pnpm paperclipai auth bootstrap-ceo"})]})})}function Nb(){var a,i;const t=wt(),s=Q({queryKey:P.health,queryFn:()=>jo.get(),retry:!1,refetchInterval:l=>{const o=l.state.data;return(o==null?void 0:o.deploymentMode)==="authenticated"&&o.bootstrapStatus==="bootstrap_pending"?2e3:!1},refetchIntervalInBackground:!0}),n=((a=s.data)==null?void 0:a.deploymentMode)==="authenticated",r=Q({queryKey:P.auth.session,queryFn:()=>ii.getSession(),enabled:n,retry:!1});if(s.isLoading||n&&r.isLoading)return e.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading..."});if(s.error)return e.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:s.error instanceof Error?s.error.message:"Failed to load app state"});if(n&&((i=s.data)==null?void 0:i.bootstrapStatus)==="bootstrap_pending")return e.jsx(yb,{hasActiveInvite:s.data.bootstrapInviteActive});if(n&&!r.data){const l=encodeURIComponent(`${t.pathname}${t.search}`);return e.jsx(Ie,{to:`/auth?next=${l}`,replace:!0})}return e.jsx(bo,{})}function wb(){return e.jsxs(e.Fragment,{children:[e.jsx(Y,{index:!0,element:e.jsx(Ie,{to:"dashboard",replace:!0})}),e.jsx(Y,{path:"dashboard",element:e.jsx(Ag,{})}),e.jsx(Y,{path:"onboarding",element:e.jsx(sd,{})}),e.jsx(Y,{path:"companies",element:e.jsx(Pg,{})}),e.jsx(Y,{path:"company/settings",element:e.jsx(zf,{})}),e.jsx(Y,{path:"settings",element:e.jsx(Qr,{})}),e.jsx(Y,{path:"settings/*",element:e.jsx(Qr,{})}),e.jsx(Y,{path:"plugins/:pluginId",element:e.jsx(Xl,{})}),e.jsx(Y,{path:"org",element:e.jsx(Qu,{})}),e.jsx(Y,{path:"agents",element:e.jsx(Ie,{to:"/agents/all",replace:!0})}),e.jsx(Y,{path:"agents/all",element:e.jsx(br,{})}),e.jsx(Y,{path:"agents/active",element:e.jsx(br,{})}),e.jsx(Y,{path:"agents/paused",element:e.jsx(br,{})}),e.jsx(Y,{path:"agents/error",element:e.jsx(br,{})}),e.jsx(Y,{path:"agents/new",element:e.jsx(mb,{})}),e.jsx(Y,{path:"agents/:agentId",element:e.jsx(ba,{})}),e.jsx(Y,{path:"agents/:agentId/:tab",element:e.jsx(ba,{})}),e.jsx(Y,{path:"agents/:agentId/runs/:runId",element:e.jsx(ba,{})}),e.jsx(Y,{path:"projects",element:e.jsx(Rg,{})}),e.jsx(Y,{path:"projects/:projectId",element:e.jsx(nn,{})}),e.jsx(Y,{path:"projects/:projectId/overview",element:e.jsx(nn,{})}),e.jsx(Y,{path:"projects/:projectId/issues",element:e.jsx(nn,{})}),e.jsx(Y,{path:"projects/:projectId/issues/:filter",element:e.jsx(nn,{})}),e.jsx(Y,{path:"projects/:projectId/configuration",element:e.jsx(nn,{})}),e.jsx(Y,{path:"projects/:projectId/budget",element:e.jsx(nn,{})}),e.jsx(Y,{path:"tickets",element:e.jsx(gb,{})}),e.jsx(Y,{path:"tickets/:ticketId",element:e.jsx(vb,{})}),e.jsx(Y,{path:"issues",element:e.jsx(Hg,{})}),e.jsx(Y,{path:"issues/all",element:e.jsx(Ie,{to:"/issues",replace:!0})}),e.jsx(Y,{path:"issues/active",element:e.jsx(Ie,{to:"/issues",replace:!0})}),e.jsx(Y,{path:"issues/backlog",element:e.jsx(Ie,{to:"/issues",replace:!0})}),e.jsx(Y,{path:"issues/done",element:e.jsx(Ie,{to:"/issues",replace:!0})}),e.jsx(Y,{path:"issues/recent",element:e.jsx(Ie,{to:"/issues",replace:!0})}),e.jsx(Y,{path:"issues/:issueId",element:e.jsx(Gu,{})}),e.jsx(Y,{path:"execution-workspaces/:workspaceId",element:e.jsx(Yg,{})}),e.jsx(Y,{path:"goals",element:e.jsx(Xg,{})}),e.jsx(Y,{path:"goals/:goalId",element:e.jsx(tf,{})}),e.jsx(Y,{path:"approvals",element:e.jsx(Ie,{to:"/approvals/pending",replace:!0})}),e.jsx(Y,{path:"approvals/pending",element:e.jsx(Fl,{})}),e.jsx(Y,{path:"approvals/all",element:e.jsx(Fl,{})}),e.jsx(Y,{path:"approvals/:approvalId",element:e.jsx(cf,{})}),e.jsx(Y,{path:"costs",element:e.jsx(Df,{})}),e.jsx(Y,{path:"activity",element:e.jsx($f,{})}),e.jsx(Y,{path:"inbox",element:e.jsx(kb,{})}),e.jsx(Y,{path:"inbox/recent",element:e.jsx(Ra,{})}),e.jsx(Y,{path:"inbox/unread",element:e.jsx(Ra,{})}),e.jsx(Y,{path:"inbox/all",element:e.jsx(Ra,{})}),e.jsx(Y,{path:"inbox/new",element:e.jsx(Ie,{to:"/inbox/recent",replace:!0})}),e.jsx(Y,{path:"design-guide",element:e.jsx(Wf,{})}),e.jsx(Y,{path:"tests/ux/runs",element:e.jsx(cb,{})}),e.jsx(Y,{path:":pluginRoutePath",element:e.jsx(Xl,{})}),e.jsx(Y,{path:"*",element:e.jsx(Hn,{scope:"board"})})]})}function kb(){return e.jsx(Ie,{to:`/inbox/${hh()}`,replace:!0})}function Qr(){const t=wt();return e.jsx(Ie,{to:`/instance/settings/heartbeats${t.search}${t.hash}`,replace:!0})}function sd(){const{companies:t}=fe(),{openOnboarding:s}=Ye(),{companyPrefix:n}=Cs(),r=n?t.find(l=>l.issuePrefix.toUpperCase()===n.toUpperCase())??null:null,a=r?`Add another agent to ${r.name}`:t.length>0?"Create another company":"Create your first company",i=r?"Run onboarding again to add an agent and a starter task for this company.":t.length>0?"Run onboarding again to create another company and seed its first agent.":"Get started by creating a company and your first agent.";return e.jsx("div",{className:"mx-auto max-w-xl py-10",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[e.jsx("h1",{className:"text-xl font-semibold",children:a}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:i}),e.jsx("div",{className:"mt-4",children:e.jsx(F,{onClick:()=>r?s({initialStep:2,companyId:r.id}):s(),children:r?"Add Agent":"Start Onboarding"})})]})})}function Cb(){const{companies:t,selectedCompany:s,loading:n}=fe(),r=wt();if(n)return e.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading..."});const a=s??t[0]??null;return a?e.jsx(Ie,{to:`/${a.issuePrefix}/dashboard`,replace:!0}):Eo({pathname:r.pathname,hasCompanies:!1})?e.jsx(Ie,{to:"/onboarding",replace:!0}):e.jsx(nd,{})}function lt(){const t=wt(),{companies:s,selectedCompany:n,loading:r}=fe();if(r)return e.jsx("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading..."});const a=n??s[0]??null;return a?e.jsx(Ie,{to:`/${a.issuePrefix}${t.pathname}${t.search}${t.hash}`,replace:!0}):Eo({pathname:t.pathname,hasCompanies:!1})?e.jsx(Ie,{to:"/onboarding",replace:!0}):e.jsx(nd,{})}function nd(){const{openOnboarding:t}=Ye();return e.jsx("div",{className:"mx-auto max-w-xl py-10",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Create your first company"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Get started by creating a company."}),e.jsx("div",{className:"mt-4",children:e.jsx(F,{onClick:()=>t(),children:"New Company"})})]})})}function Sb(){return e.jsxs(e.Fragment,{children:[e.jsxs(zu,{children:[e.jsx(Y,{path:"auth",element:e.jsx(Ku,{})}),e.jsx(Y,{path:"board-claim/:token",element:e.jsx(Uu,{})}),e.jsx(Y,{path:"invite/:token",element:e.jsx(Vu,{})}),e.jsxs(Y,{element:e.jsx(Nb,{}),children:[e.jsx(Y,{index:!0,element:e.jsx(Cb,{})}),e.jsx(Y,{path:"onboarding",element:e.jsx(sd,{})}),e.jsx(Y,{path:"instance",element:e.jsx(Ie,{to:"/instance/settings/heartbeats",replace:!0})}),e.jsxs(Y,{path:"instance/settings",element:e.jsx(Rl,{}),children:[e.jsx(Y,{index:!0,element:e.jsx(Ie,{to:"heartbeats",replace:!0})}),e.jsx(Y,{path:"heartbeats",element:e.jsx(Gf,{})}),e.jsx(Y,{path:"experimental",element:e.jsx(Hf,{})}),e.jsx(Y,{path:"plugins",element:e.jsx(Yf,{})}),e.jsx(Y,{path:"plugins/:pluginId",element:e.jsx(eb,{})})]}),e.jsx(Y,{path:"companies",element:e.jsx(lt,{})}),e.jsx(Y,{path:"tickets",element:e.jsx(lt,{})}),e.jsx(Y,{path:"tickets/:ticketId",element:e.jsx(lt,{})}),e.jsx(Y,{path:"issues",element:e.jsx(lt,{})}),e.jsx(Y,{path:"issues/:issueId",element:e.jsx(lt,{})}),e.jsx(Y,{path:"settings",element:e.jsx(Qr,{})}),e.jsx(Y,{path:"settings/*",element:e.jsx(Qr,{})}),e.jsx(Y,{path:"agents",element:e.jsx(lt,{})}),e.jsx(Y,{path:"agents/new",element:e.jsx(lt,{})}),e.jsx(Y,{path:"agents/:agentId",element:e.jsx(lt,{})}),e.jsx(Y,{path:"agents/:agentId/:tab",element:e.jsx(lt,{})}),e.jsx(Y,{path:"agents/:agentId/runs/:runId",element:e.jsx(lt,{})}),e.jsx(Y,{path:"projects",element:e.jsx(lt,{})}),e.jsx(Y,{path:"projects/:projectId",element:e.jsx(lt,{})}),e.jsx(Y,{path:"projects/:projectId/overview",element:e.jsx(lt,{})}),e.jsx(Y,{path:"projects/:projectId/issues",element:e.jsx(lt,{})}),e.jsx(Y,{path:"projects/:projectId/issues/:filter",element:e.jsx(lt,{})}),e.jsx(Y,{path:"projects/:projectId/configuration",element:e.jsx(lt,{})}),e.jsx(Y,{path:"tests/ux/runs",element:e.jsx(lt,{})}),e.jsx(Y,{path:":companyPrefix",element:e.jsx(Rl,{}),children:wb()}),e.jsx(Y,{path:"*",element:e.jsx(Hn,{scope:"global"})})]})]}),e.jsx(Wu,{})]})}om(rd,cm);const Ib=new Ju({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!0}}});function Rb(){return e.jsx(Hu,{client:Ib,children:e.jsx(Yu,{children:e.jsx(Xu,{children:e.jsx(Zu,{children:e.jsx(em,{children:e.jsx(tm,{children:e.jsx(sm,{children:e.jsx(nm,{children:e.jsx(rm,{children:e.jsx(am,{children:e.jsx(im,{children:e.jsx(lm,{children:e.jsx(Sb,{})})})})})})})})})})})})})}export{Rb as DxRoot};
|