@workflow/web 4.1.0-beta.34 → 4.1.0-beta.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/build/client/assets/{_basePickBy-DHDscq_f.js → _basePickBy-B1BDxiOZ.js} +1 -1
  2. package/build/client/assets/{_baseUniq-BKX8gPoI.js → _baseUniq-8k2kDiDO.js} +1 -1
  3. package/build/client/assets/{arc--nRtbI8K.js → arc-GEaYFOjf.js} +1 -1
  4. package/build/client/assets/{architectureDiagram-VXUJARFQ-_Qc-tmxG.js → architectureDiagram-VXUJARFQ-DL4sQscp.js} +1 -1
  5. package/build/client/assets/{blockDiagram-VD42YOAC-dlWy-WHR.js → blockDiagram-VD42YOAC-Prv_51qN.js} +1 -1
  6. package/build/client/assets/{c4Diagram-YG6GDRKO-KwMhvreD.js → c4Diagram-YG6GDRKO-CA7cLdzM.js} +1 -1
  7. package/build/client/assets/channel-csNrGTKG.js +1 -0
  8. package/build/client/assets/{chunk-4BX2VUAB-B4nDiCVl.js → chunk-4BX2VUAB-DNnh70rt.js} +1 -1
  9. package/build/client/assets/{chunk-55IACEB6-C255NtjG.js → chunk-55IACEB6-BF9zOAOM.js} +1 -1
  10. package/build/client/assets/{chunk-B4BG7PRW-DrawBXGd.js → chunk-B4BG7PRW-oOVMnMFa.js} +1 -1
  11. package/build/client/assets/{chunk-DI55MBZ5-06r_lbX1.js → chunk-DI55MBZ5-CjBPrbih.js} +1 -1
  12. package/build/client/assets/{chunk-FMBD7UC4-BC40KRYB.js → chunk-FMBD7UC4-B91VGbrx.js} +1 -1
  13. package/build/client/assets/{chunk-QN33PNHL-sjb1wNJd.js → chunk-QN33PNHL-OReYjUUh.js} +1 -1
  14. package/build/client/assets/{chunk-QZHKN3VN-DnAziOBQ.js → chunk-QZHKN3VN-BnMvYB9T.js} +1 -1
  15. package/build/client/assets/{chunk-TZMSLE5B-VkRv8IvH.js → chunk-TZMSLE5B-BVg2QNgA.js} +1 -1
  16. package/build/client/assets/classDiagram-2ON5EDUG-Cw1pUtEI.js +1 -0
  17. package/build/client/assets/classDiagram-v2-WZHVMYZB-Cw1pUtEI.js +1 -0
  18. package/build/client/assets/clone-Gr2LAXmK.js +1 -0
  19. package/build/client/assets/{code-block-IT6T5CEO-BOexmHI_.js → code-block-IT6T5CEO-BGc7juPG.js} +1 -1
  20. package/build/client/assets/{cose-bilkent-S5V4N54A-Bt5Edg9U.js → cose-bilkent-S5V4N54A-BXeeqrEz.js} +1 -1
  21. package/build/client/assets/{dagre-6UL2VRFP-YWTvJR0y.js → dagre-6UL2VRFP-WWCtKdTv.js} +1 -1
  22. package/build/client/assets/{diagram-PSM6KHXK-BLq_k4Yr.js → diagram-PSM6KHXK-BiypSgqf.js} +1 -1
  23. package/build/client/assets/{diagram-QEK2KX5R-BI3cylAU.js → diagram-QEK2KX5R-s-DyJmJB.js} +1 -1
  24. package/build/client/assets/{diagram-S2PKOQOG-Edzm6MKm.js → diagram-S2PKOQOG-B62ZpY2c.js} +1 -1
  25. package/build/client/assets/{erDiagram-Q2GNP2WA-Cnz8iVxF.js → erDiagram-Q2GNP2WA-mGjemxYQ.js} +1 -1
  26. package/build/client/assets/{flowDiagram-NV44I4VS-HZaVPGp0.js → flowDiagram-NV44I4VS-u6wZbrvs.js} +1 -1
  27. package/build/client/assets/{ganttDiagram-JELNMOA3-tGMRJ7F2.js → ganttDiagram-JELNMOA3-C6QHTFif.js} +1 -1
  28. package/build/client/assets/{gitGraphDiagram-NY62KEGX-BWBaaTab.js → gitGraphDiagram-NY62KEGX-DvuNA9fs.js} +1 -1
  29. package/build/client/assets/{graph-Cjwr8MRV.js → graph-D_8R-uEc.js} +1 -1
  30. package/build/client/assets/home-BaR2keeX.js +35 -0
  31. package/build/client/assets/{infoDiagram-WHAUD3N6-zxf98IY_.js → infoDiagram-WHAUD3N6-CvIUVR8S.js} +1 -1
  32. package/build/client/assets/{journeyDiagram-XKPGCS4Q-BYSsRfkq.js → journeyDiagram-XKPGCS4Q-D8y_eiuW.js} +1 -1
  33. package/build/client/assets/{kanban-definition-3W4ZIXB7-DwifGaQE.js → kanban-definition-3W4ZIXB7-CfdpNYS5.js} +1 -1
  34. package/build/client/assets/{layout-ZKGw0hWT.js → layout-wHJRCoBo.js} +1 -1
  35. package/build/client/assets/{manifest-9c74fca4.js → manifest-51f10d68.js} +1 -1
  36. package/build/client/assets/{mermaid-VLURNSYL-DFbTcPsZ.js → mermaid-VLURNSYL-OCFFn9G-.js} +33 -33
  37. package/build/client/assets/{mermaid.core-CAJGJsUa.js → mermaid.core-CIxEZ4Im.js} +5 -5
  38. package/build/client/assets/{mindmap-definition-VGOIOE7T-Brr4Ue8p.js → mindmap-definition-VGOIOE7T-D3gTunm1.js} +1 -1
  39. package/build/client/assets/{pieDiagram-ADFJNKIX-BZBT_6SI.js → pieDiagram-ADFJNKIX-B85xOamx.js} +1 -1
  40. package/build/client/assets/{quadrantDiagram-AYHSOK5B-B5SsXhND.js → quadrantDiagram-AYHSOK5B-C3aCr011.js} +1 -1
  41. package/build/client/assets/{requirementDiagram-UZGBJVZJ-C_2tqoJn.js → requirementDiagram-UZGBJVZJ-37j0JWP4.js} +1 -1
  42. package/build/client/assets/{root-Dj7SY8Pc.js → root-DHMpTxJj.js} +1 -1
  43. package/build/client/assets/root-Dr_TuMgh.css +1 -0
  44. package/build/client/assets/run-detail-D1ou1d9Y.js +36 -0
  45. package/build/client/assets/{sankeyDiagram-TZEHDZUN-DDokcrb5.js → sankeyDiagram-TZEHDZUN-DzUbFRqR.js} +1 -1
  46. package/build/client/assets/{sequenceDiagram-WL72ISMW-bQjozZq_.js → sequenceDiagram-WL72ISMW-CRN-wOEK.js} +1 -1
  47. package/build/client/assets/server-build-CgcbAXmU.css +1 -0
  48. package/build/client/assets/{stateDiagram-FKZM4ZOC-BsdcjN4g.js → stateDiagram-FKZM4ZOC-CoutTkF0.js} +1 -1
  49. package/build/client/assets/stateDiagram-v2-4FDKWEC3-BgLFQ5nj.js +1 -0
  50. package/build/client/assets/{timeline-definition-IT6M3QCI-BdQl6KLI.js → timeline-definition-IT6M3QCI-DOHM22it.js} +1 -1
  51. package/build/client/assets/{treemap-KMMF4GRG-BlxmRVP8.js → treemap-KMMF4GRG-Cuj8ISKR.js} +1 -1
  52. package/build/client/assets/use-workflow-graph-6AriCYol.js +166 -0
  53. package/build/client/assets/{xychartDiagram-PRI3JC2R-SMO1MIZH.js → xychartDiagram-PRI3JC2R-Hi349Uif.js} +1 -1
  54. package/build/server/assets/{_basePickBy-DDu9sZ05.js → _basePickBy-5Pche2g8.js} +2 -2
  55. package/build/server/assets/{_baseUniq-CPezvtNf.js → _baseUniq-rVBkHQhs.js} +1 -1
  56. package/build/server/assets/{app-tswq4nS6.js → app-TS-XEo7V.js} +1 -1
  57. package/build/server/assets/{arc-COFK4tNT.js → arc-CGnYt3XY.js} +1 -1
  58. package/build/server/assets/{architecture-U656AL7Q-D8-7L2pd.js → architecture-U656AL7Q-DbvOs0nV.js} +9 -9
  59. package/build/server/assets/{architectureDiagram-VXUJARFQ-Dmds_6dm.js → architectureDiagram-VXUJARFQ-L2BPr4gg.js} +10 -10
  60. package/build/server/assets/{blockDiagram-VD42YOAC-CXaPa5qT.js → blockDiagram-VD42YOAC-l-T_FUvw.js} +10 -10
  61. package/build/server/assets/{c4Diagram-YG6GDRKO-C3a1-A9U.js → c4Diagram-YG6GDRKO-CCfxLCAa.js} +6 -6
  62. package/build/server/assets/{channel-Cqc0_Vqq.js → channel-BQnGOmwG.js} +1 -1
  63. package/build/server/assets/{chunk-4BX2VUAB-BgHKdQkc.js → chunk-4BX2VUAB-DTDtI7wT.js} +1 -1
  64. package/build/server/assets/{chunk-55IACEB6-BS3kwVef.js → chunk-55IACEB6-Cu3JOMp-.js} +2 -2
  65. package/build/server/assets/{chunk-B4BG7PRW-DRp6hZKh.js → chunk-B4BG7PRW-SbWvmNEI.js} +5 -5
  66. package/build/server/assets/{chunk-DI55MBZ5-D-k1Hmln.js → chunk-DI55MBZ5-CX8cmhH0.js} +3 -3
  67. package/build/server/assets/{chunk-FMBD7UC4-ypfWW--F.js → chunk-FMBD7UC4-C9fGUos-.js} +1 -1
  68. package/build/server/assets/{chunk-QN33PNHL-vSeUi0io.js → chunk-QN33PNHL-Bdz8spTx.js} +1 -1
  69. package/build/server/assets/{chunk-QZHKN3VN-CJweWAVV.js → chunk-QZHKN3VN-Bvso0miA.js} +1 -1
  70. package/build/server/assets/{chunk-TZMSLE5B-BG7b2aOM.js → chunk-TZMSLE5B-BAVS6CcD.js} +1 -1
  71. package/build/server/assets/{classDiagram-2ON5EDUG-B1pjby_P.js → classDiagram-2ON5EDUG-EK2Wq1-A.js} +9 -9
  72. package/build/server/assets/{classDiagram-v2-WZHVMYZB-B1pjby_P.js → classDiagram-v2-WZHVMYZB-EK2Wq1-A.js} +9 -9
  73. package/build/server/assets/{clone-CXCQCPMW.js → clone-CzKKfZSJ.js} +1 -1
  74. package/build/server/assets/{code-block-IT6T5CEO-CFv2mhYI.js → code-block-IT6T5CEO-BVYAbkuh.js} +4 -4
  75. package/build/server/assets/{cose-bilkent-S5V4N54A-Cjbmp-ES.js → cose-bilkent-S5V4N54A-BB9VlwzB.js} +5 -5
  76. package/build/server/assets/{dagre-6UL2VRFP-BbWNd8fN.js → dagre-6UL2VRFP-CYzOrfDZ.js} +10 -10
  77. package/build/server/assets/{diagram-PSM6KHXK-Dl23OO_-.js → diagram-PSM6KHXK-B5hvksz9.js} +11 -11
  78. package/build/server/assets/{diagram-QEK2KX5R-CNO3f8cc.js → diagram-QEK2KX5R-D9NM-JnM.js} +10 -10
  79. package/build/server/assets/{diagram-S2PKOQOG-Drj3AuMx.js → diagram-S2PKOQOG-Cr1LrnWq.js} +10 -10
  80. package/build/server/assets/{erDiagram-Q2GNP2WA-BrRdaTe4.js → erDiagram-Q2GNP2WA-D9urh_DL.js} +8 -8
  81. package/build/server/assets/{flowDiagram-NV44I4VS-eQV3TE_c.js → flowDiagram-NV44I4VS-47DMtQX0.js} +9 -9
  82. package/build/server/assets/{ganttDiagram-JELNMOA3-D4gxbiXq.js → ganttDiagram-JELNMOA3-Bsc3oYoY.js} +6 -6
  83. package/build/server/assets/{gitGraph-F6HP7TQM-x0JoiISN.js → gitGraph-F6HP7TQM-DR3t7ywR.js} +9 -9
  84. package/build/server/assets/{gitGraphDiagram-NY62KEGX-OFqTvfp8.js → gitGraphDiagram-NY62KEGX-B3LBhYEd.js} +11 -11
  85. package/build/server/assets/{graph-gP5x0CkQ.js → graph-DylIm937.js} +2 -2
  86. package/build/server/assets/{info-NVLQJR56-r2B6fs17.js → info-NVLQJR56-BpEwOtm0.js} +9 -9
  87. package/build/server/assets/{infoDiagram-WHAUD3N6-ClKO2as2.js → infoDiagram-WHAUD3N6-aoS2Y2jd.js} +9 -9
  88. package/build/server/assets/{journeyDiagram-XKPGCS4Q-Br1X2sDn.js → journeyDiagram-XKPGCS4Q-IKNlIiEJ.js} +8 -8
  89. package/build/server/assets/{kanban-definition-3W4ZIXB7-DpE4JZsR.js → kanban-definition-3W4ZIXB7-BPbBbUFa.js} +6 -6
  90. package/build/server/assets/{layout-oT-uoF-3.js → layout-CdgQaV3q.js} +4 -4
  91. package/build/server/assets/{linear-BOu-nm13.js → linear-BEcSsqfJ.js} +1 -1
  92. package/build/server/assets/{mermaid-VLURNSYL-BBI-ZyxS.js → mermaid-VLURNSYL-BeYPeEV-.js} +4 -4
  93. package/build/server/assets/{mermaid-parser.core-COrs4xZP.js → mermaid-parser.core-0sQrJr73.js} +11 -11
  94. package/build/server/assets/{mermaid.core-DSfg9DTI.js → mermaid.core-a_62q6mh.js} +32 -32
  95. package/build/server/assets/{mindmap-definition-VGOIOE7T-Dls2nsge.js → mindmap-definition-VGOIOE7T-BcPZjvCY.js} +7 -7
  96. package/build/server/assets/{packet-BFZMPI3H-DYdsV9oG.js → packet-BFZMPI3H-Bj_jRmt5.js} +9 -9
  97. package/build/server/assets/{pie-7BOR55EZ-Ib4gWu3n.js → pie-7BOR55EZ-0UCmP5Sy.js} +9 -9
  98. package/build/server/assets/{pieDiagram-ADFJNKIX-B2HEjzVX.js → pieDiagram-ADFJNKIX-hQksKgCm.js} +11 -11
  99. package/build/server/assets/{quadrantDiagram-AYHSOK5B-DAo4x7XW.js → quadrantDiagram-AYHSOK5B-Bv8MfwUr.js} +6 -6
  100. package/build/server/assets/{radar-NHE76QYJ-EcIj4-c2.js → radar-NHE76QYJ-oyha2y6i.js} +9 -9
  101. package/build/server/assets/{requirementDiagram-UZGBJVZJ-5NKwD2mU.js → requirementDiagram-UZGBJVZJ-3ZJa8elX.js} +7 -7
  102. package/build/server/assets/{sankeyDiagram-TZEHDZUN-CLeMeI5j.js → sankeyDiagram-TZEHDZUN-CfrKwCjE.js} +5 -5
  103. package/build/server/assets/{sequenceDiagram-WL72ISMW-ow3l4Fri.js → sequenceDiagram-WL72ISMW-D5pKv8dS.js} +7 -7
  104. package/build/server/assets/{server-build-CuKE6nMq.js → server-build-B-CBDnz2.js} +2790 -2743
  105. package/build/server/assets/{stateDiagram-FKZM4ZOC-DzFqDl8d.js → stateDiagram-FKZM4ZOC-CIIJ2ueM.js} +12 -12
  106. package/build/server/assets/{stateDiagram-v2-4FDKWEC3-CvVm2xRM.js → stateDiagram-v2-4FDKWEC3-C07hzSfC.js} +8 -8
  107. package/build/server/assets/{timeline-definition-IT6M3QCI-Bl1QIB4i.js → timeline-definition-IT6M3QCI-DV3mTTlt.js} +6 -6
  108. package/build/server/assets/{token-B0LCPjeP.js → token-BNw18NRr.js} +3 -3
  109. package/build/server/assets/{token-util-Cu8l3cno.js → token-util-C21noM9f.js} +2 -2
  110. package/build/server/assets/{token-util-CIfvkrUB.js → token-util-D2PY2sBO.js} +1 -1
  111. package/build/server/assets/{treemap-KMMF4GRG-DwpOgdit.js → treemap-KMMF4GRG-C5IwFfHK.js} +9 -9
  112. package/build/server/assets/{xychartDiagram-PRI3JC2R--odlRvS3.js → xychartDiagram-PRI3JC2R-BCtn2EPg.js} +6 -6
  113. package/build/server/index.js +1 -1
  114. package/package.json +10 -6
  115. package/build/client/assets/channel-Dzz8OuVo.js +0 -1
  116. package/build/client/assets/classDiagram-2ON5EDUG-DABRK9Qx.js +0 -1
  117. package/build/client/assets/classDiagram-v2-WZHVMYZB-DABRK9Qx.js +0 -1
  118. package/build/client/assets/clone-j6wLTJEP.js +0 -1
  119. package/build/client/assets/home-DjQfihAH.js +0 -40
  120. package/build/client/assets/root-1lSMDQJV.css +0 -1
  121. package/build/client/assets/run-detail-CjlkBO0W.js +0 -34
  122. package/build/client/assets/server-build-CSzEkmuy.css +0 -1
  123. package/build/client/assets/stateDiagram-v2-4FDKWEC3-zx6ygxzt.js +0 -1
  124. package/build/client/assets/use-workflow-graph-jEZXDidH.js +0 -161
@@ -0,0 +1,36 @@
1
+ import{R as K,v as n,b as m,B as Wo,f as $o,y as ja,z as Vo,A as ka,w as Sa,D as Ca}from"./index-DS8xNWtl.js";import{U as rr,V as nr,B as bt,j as Uo,q as Go,Y as Ta,Z as Ea,S as Ko,R as qo,p as Aa,o as Ra,X as Yo,Q as Ot,_ as Da,G as Ma,$ as Ee,u as gr,W as Tt,a0 as La,v as dt,a1 as br,a2 as _a,t as Xo,a3 as Ha,s as Oa,a4 as Wr,w as wn,l as Fa,m as Pa,a5 as Ba,a6 as za,a7 as Wa,a8 as $a,a9 as Va,aa as Ua,ab as Ga,ac as Ka,ad as zn,J as wr,ae as Zo,af as qa,ag as Ya,ah as Wn,ai as nt,aj as ot,F as an,ak as Xa,al as Za,am as Ja,an as Qa,r as ei,A as ln,C as cn,c as dn,d as un,a as Ct,ao as ti,e as ri,b as lr,T as ni,M as oi,N as cr,K as si,O as dr,y as ai,ap as ii,I as li}from"./use-workflow-graph-6AriCYol.js";import{c as Lr,t as me,Z as At,$ as Re,a0 as Ir,a1 as ci,a2 as di,a3 as ui,a4 as fi,a5 as Rt,a6 as it,a7 as ee,a8 as mi,a9 as pi,aa as $r,ab as We,ac as ur,ad as Nr,ae as Ft,af as vt,ag as Jo,ah as Vt,ai as Vr,aj as hi,ak as gi,al as xi,am as vi,an as yi,ao as bi,ap as wi,aq as Ii,ar as $n,as as Ni,at as Qo,k as jr,z as fn,au as ji,av as Ur,i as Gr,E as Kt,aw as ki,ax as In,y as It,ay as Si,d as Ge,az as es,aA as Ci,aB as Ti,T as ts,a as rs,b as ns,aC as Ei,L as kr,u as Ai,aD as Ri}from"./mermaid-VLURNSYL-OCFFn9G-.js";import"./transform-BcRQlmJM.js";import"./value-BxRBhsAB.js";/**
2
+ * @license lucide-react v0.469.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 Di=Lr("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
7
+ * @license lucide-react v0.469.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 Mi=Lr("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
12
+ * @license lucide-react v0.469.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 Kr=Lr("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
17
+ * @license lucide-react v0.469.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 Li=Lr("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),_r=0,Nt=1,Wt=2,os=4;function Vn(e){return()=>e}function _i(e){e()}function ss(e,t){return r=>e(t(r))}function Un(e,t){return()=>e(t)}function Hi(e,t){return r=>e(t,r)}function Nn(e){return e!==void 0}function Oi(...e){return()=>{e.map(_i)}}function $t(){}function Hr(e,t){return t(e),e}function Fi(e,t){return t(e)}function ve(...e){return e}function he(e,t){return e(Nt,t)}function ae(e,t){e(_r,t)}function jn(e){e(Wt)}function _e(e){return e(os)}function Y(e,t){return he(e,Hi(t,_r))}function at(e,t){const r=e(Nt,o=>{r(),t(o)});return r}function Gn(e){let t,r;return o=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{o(t)},e)}}function as(e,t){return e===t}function xe(e=as){let t;return r=>o=>{e(t,o)||(t=o,r(o))}}function te(e){return t=>r=>{e(r)&&t(r)}}function U(e){return t=>ss(t,e)}function rt(e){return t=>()=>{t(e)}}function L(e,...t){const r=Pi(...t);return(o,s)=>{switch(o){case Wt:jn(e);return;case Nt:return he(e,r(s))}}}function st(e,t){return r=>o=>{r(t=e(t,o))}}function zt(e){return t=>r=>{e>0?e--:t(r)}}function yt(e){let t=null,r;return o=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,o(t)},e))}}function le(...e){const t=new Array(e.length);let r=0,o=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);he(a,d=>{const c=r;r=r|l,t[i]=d,c!==s&&r===s&&o&&(o(),o=null)})}),a=>i=>{const l=()=>{a([i].concat(t))};r===s?l():o=l}}function Pi(...e){return t=>e.reduceRight(Fi,t)}function Bi(e){let t,r;const o=()=>t==null?void 0:t();return function(s,a){switch(s){case Nt:return a?r===a?void 0:(o(),r=a,t=he(e,a),t):(o(),$t);case Wt:o(),r=null;return}}}function F(e){let t=e;const r=ue();return(o,s)=>{switch(o){case _r:t=s;break;case Nt:{s(t);break}case os:return t}return r(o,s)}}function He(e,t){return Hr(F(t),r=>Y(e,r))}function ue(){const e=[];return(t,r)=>{switch(t){case _r:e.slice().forEach(o=>{o(r)});return;case Wt:e.splice(0,e.length);return;case Nt:return e.push(r),()=>{const o=e.indexOf(r);o>-1&&e.splice(o,1)}}}}function Ve(e){return Hr(ue(),t=>Y(e,t))}function pe(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:zi(),singleton:r}}const zi=()=>Symbol();function Wi(e){const t=new Map,r=({constructor:o,dependencies:s,id:a,singleton:i})=>{if(i&&t.has(a))return t.get(a);const l=o(s.map(d=>r(d)));return i&&t.set(a,l),l};return r(e)}function Te(...e){const t=ue(),r=new Array(e.length);let o=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);he(a,d=>{r[i]=d,o=o|l,o===s&&ae(t,r)})}),function(a,i){switch(a){case Wt:{jn(t);return}case Nt:return o===s&&i(r),he(t,i)}}}function re(e,t=as){return L(e,xe(t))}function Kn(...e){return function(t,r){switch(t){case Wt:return;case Nt:return Oi(...e.map(o=>he(o,r)))}}}var Ue=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ue||{});const $i={0:"debug",3:"error",1:"log",2:"warn"},Vi=()=>typeof globalThis>"u"?window:globalThis,jt=pe(()=>{const e=F(3);return{log:F((t,r,o=1)=>{var s;const a=(s=Vi().VIRTUOSO_LOG_LEVEL)!=null?s:_e(e);o>=a&&console[$i[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function Mt(e,t,r){return kn(e,t,r).callbackRef}function kn(e,t,r){const o=K.useRef(null);let s=i=>{};const a=K.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const d=i[0].target;d.offsetParent!==null&&e(d)};r?l():requestAnimationFrame(l)}):null,[e,r]);return s=i=>{i&&t?(a==null||a.observe(i),o.current=i):(o.current&&(a==null||a.unobserve(o.current)),o.current=null)},{callbackRef:s,ref:o}}function Ui(e,t,r,o,s,a,i,l,d){const c=K.useCallback(u=>{const f=Gi(u.children,t,l?"offsetWidth":"offsetHeight",s);let p=u.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const g=p.lastElementChild.dataset.viewportType==="window";let v;g&&(v=p.ownerDocument.defaultView);const y=i?l?i.scrollLeft:i.scrollTop:g?l?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:l?p.scrollLeft:p.scrollTop,N=i?l?i.scrollWidth:i.scrollHeight:g?l?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:l?p.scrollWidth:p.scrollHeight,x=i?l?i.offsetWidth:i.offsetHeight:g?l?v.innerWidth:v.innerHeight:l?p.offsetWidth:p.offsetHeight;o({scrollHeight:N,scrollTop:Math.max(y,0),viewportHeight:x}),a==null||a(l?qn("column-gap",getComputedStyle(u).columnGap,s):qn("row-gap",getComputedStyle(u).rowGap,s)),f!==null&&e(f)},[e,t,s,a,i,o,l]);return kn(c,r,d)}function Gi(e,t,r,o){const s=e.length;if(s===0)return null;const a=[];for(let i=0;i<s;i++){const l=e.item(i);if(l.dataset.index===void 0)continue;const d=parseInt(l.dataset.index),c=parseFloat(l.dataset.knownSize),u=t(l,r);if(u===0&&o("Zero-sized element, this should not happen",{child:l},Ue.ERROR),u===c)continue;const f=a[a.length-1];a.length===0||f.size!==u||f.endIndex!==d-1?a.push({endIndex:d,size:u,startIndex:d}):a[a.length-1].endIndex++}return a}function qn(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Ue.WARN),t==="normal"?0:parseInt(t??"0",10)}function is(e,t,r){const o=K.useRef(null),s=K.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const c=d.getBoundingClientRect(),u=c.width;let f,p;if(t){const g=t.getBoundingClientRect(),v=c.top-g.top;p=g.height-Math.max(0,v),f=v+t.scrollTop}else{const g=i.current.ownerDocument.defaultView;p=g.innerHeight-Math.max(0,c.top),f=c.top+g.scrollY}o.current={offsetTop:f,visibleHeight:p,visibleWidth:u},e(o.current)},[e,t]),{callbackRef:a,ref:i}=kn(s,!0,r),l=K.useCallback(()=>{s(i.current)},[s,i]);return K.useEffect(()=>{var d;if(t){t.addEventListener("scroll",l);const c=new ResizeObserver(()=>{requestAnimationFrame(l)});return c.observe(t),()=>{t.removeEventListener("scroll",l),c.unobserve(t)}}else{const c=(d=i.current)==null?void 0:d.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",l),c==null||c.addEventListener("resize",l),()=>{c==null||c.removeEventListener("scroll",l),c==null||c.removeEventListener("resize",l)}}},[l,t,i]),a}const Be=pe(()=>{const e=ue(),t=ue(),r=F(0),o=ue(),s=F(0),a=ue(),i=ue(),l=F(0),d=F(0),c=F(0),u=F(0),f=ue(),p=ue(),g=F(!1),v=F(!1),y=F(!1);return Y(L(e,U(({scrollTop:N})=>N)),t),Y(L(e,U(({scrollHeight:N})=>N)),i),Y(t,s),{deviation:r,fixedFooterHeight:c,fixedHeaderHeight:d,footerHeight:u,headerHeight:l,horizontalDirection:v,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:g,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:y,smoothScrollTargetReached:o,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),Xt={lvl:0};function ls(e,t){const r=e.length;if(r===0)return[];let{index:o,value:s}=t(e[0]);const a=[];for(let i=1;i<r;i++){const{index:l,value:d}=t(e[i]);a.push({end:l-1,start:o,value:s}),o=l,s=d}return a.push({end:1/0,start:o,value:s}),a}function ge(e){return e===Xt}function Zt(e,t){if(!ge(e))return t===e.k?e.v:t<e.k?Zt(e.l,t):Zt(e.r,t)}function Qe(e,t,r="k"){if(ge(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const o=Qe(e.r,t,r);return o[0]===-1/0?[e.k,e.v]:o}return Qe(e.l,t,r)}function $e(e,t,r){return ge(e)?us(t,r,1):t===e.k?Ce(e,{k:t,v:r}):t<e.k?Yn(Ce(e,{l:$e(e.l,t,r)})):Yn(Ce(e,{r:$e(e.r,t,r)}))}function Pt(){return Xt}function Or(e,t,r){if(ge(e))return[];const o=Qe(e,t)[0];return Ki(pn(e,o,r))}function mn(e,t){if(ge(e))return Xt;const{k:r,l:o,r:s}=e;if(t===r){if(ge(o))return s;if(ge(s))return o;{const[a,i]=ds(o);return xr(Ce(e,{k:a,l:cs(o),v:i}))}}else return t<r?xr(Ce(e,{l:mn(o,t)})):xr(Ce(e,{r:mn(s,t)}))}function Et(e){return ge(e)?[]:[...Et(e.l),{k:e.k,v:e.v},...Et(e.r)]}function pn(e,t,r){if(ge(e))return[];const{k:o,l:s,r:a,v:i}=e;let l=[];return o>t&&(l=l.concat(pn(s,t,r))),o>=t&&o<=r&&l.push({k:o,v:i}),o<=r&&(l=l.concat(pn(a,t,r))),l}function xr(e){const{l:t,lvl:r,r:o}=e;if(o.lvl>=r-1&&t.lvl>=r-1)return e;if(r>o.lvl+1){if(qr(t))return fs(Ce(e,{lvl:r-1}));if(!ge(t)&&!ge(t.r))return Ce(t.r,{l:Ce(t,{r:t.r.l}),lvl:r,r:Ce(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(qr(e))return hn(Ce(e,{lvl:r-1}));if(!ge(o)&&!ge(o.l)){const s=o.l,a=qr(s)?o.lvl-1:o.lvl;return Ce(s,{l:Ce(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:hn(Ce(o,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Ce(e,t){return us(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function cs(e){return ge(e.r)?e.l:xr(Ce(e,{r:cs(e.r)}))}function qr(e){return ge(e)||e.lvl>e.r.lvl}function ds(e){return ge(e.r)?[e.k,e.v]:ds(e.r)}function us(e,t,r,o=Xt,s=Xt){return{k:e,l:o,lvl:r,r:s,v:t}}function Yn(e){return hn(fs(e))}function fs(e){const{l:t}=e;return!ge(t)&&t.lvl===e.lvl?Ce(t,{r:Ce(e,{l:t.r})}):e}function hn(e){const{lvl:t,r}=e;return!ge(r)&&!ge(r.r)&&r.lvl===t&&r.r.lvl===t?Ce(r,{l:Ce(e,{r:r.l}),lvl:t+1}):e}function Ki(e){return ls(e,({k:t,v:r})=>({index:t,value:r}))}function ms(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Jt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Sn=pe(()=>({recalcInProgress:F(!1)}),[],{singleton:!0});function ps(e,t,r){return e[Sr(e,t,r)]}function Sr(e,t,r,o=0){let s=e.length-1;for(;o<=s;){const a=Math.floor((o+s)/2),i=e[a],l=r(i,t);if(l===0)return a;if(l===-1){if(s-o<2)return a-1;s=a-1}else{if(s===o)return a;o=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function qi(e,t,r,o){const s=Sr(e,t,o),a=Sr(e,r,o,s);return e.slice(s,a+1)}function wt(e,t){return Math.round(e.getBoundingClientRect()[t])}function Fr(e){return!ge(e.groupOffsetTree)}function Cn({index:e},t){return t===e?0:t<e?-1:1}function Yi(){return{groupIndices:[],groupOffsetTree:Pt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Pt()}}function Xi(e,t){let r=ge(e)?0:1/0;for(const o of t){const{endIndex:s,size:a,startIndex:i}=o;if(r=Math.min(r,i),ge(e)){e=$e(e,0,a);continue}const l=Or(e,i-1,s+1);if(l.some(nl(o)))continue;let d=!1,c=!1;for(const{end:u,start:f,value:p}of l)d?(s>=f||a===p)&&(e=mn(e,f)):(c=p!==a,d=!0),u>s&&s>=f&&p!==a&&(e=$e(e,s+1,p));c&&(e=$e(e,i,a))}return[e,r]}function Zi(e){return typeof e.groupIndex<"u"}function Ji({offset:e},t){return t===e?0:t<e?-1:1}function Qt(e,t,r){if(t.length===0)return 0;const{index:o,offset:s,size:a}=ps(t,e,Cn),i=e-o,l=a*i+(i-1)*r+s;return l>0?l+r:l}function hs(e,t){if(!Fr(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function gs(e,t,r){if(Zi(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?r:e.index;let s=hs(o,t);return s=Math.max(0,s,Math.min(r,s)),s}}function Qi(e,t,r,o=0){return o>0&&(t=Math.max(t,ps(e,o,Cn).offset)),ls(qi(e,t,r,Ji),rl)}function el(e,[t,r,o,s]){t.length>0&&o("received item sizes",t,Ue.DEBUG);const a=e.sizeTree;let i=a,l=0;if(r.length>0&&ge(a)&&t.length===2){const p=t[0].size,g=t[1].size;i=r.reduce((v,y)=>$e($e(v,y,p),y+1,g),i)}else[i,l]=Xi(i,t);if(i===a)return e;const{lastIndex:d,lastOffset:c,lastSize:u,offsetTree:f}=gn(e.offsetTree,l,i,s);return{groupIndices:r,groupOffsetTree:r.reduce((p,g)=>$e(p,g,Qt(g,f,s)),Pt()),lastIndex:d,lastOffset:c,lastSize:u,offsetTree:f,sizeTree:i}}function tl(e){return Et(e).map(({k:t,v:r},o,s)=>{const a=s[o+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function Xn(e,t){let r=0,o=0;for(;r<e;)r+=t[o+1]-t[o]-1,o++;return o-(r===e?0:1)}function gn(e,t,r,o){let s=e,a=0,i=0,l=0,d=0;if(t!==0){d=Sr(s,t-1,Cn),l=s[d].offset;const c=Qe(r,t-1);a=c[0],i=c[1],s.length&&s[d].size===Qe(r,t)[1]&&(d-=1),s=s.slice(0,d+1)}else s=[];for(const{start:c,value:u}of Or(r,t,1/0)){const f=c-a,p=f*i+l+f*o;s.push({index:c,offset:p,size:u}),a=c,l=p,i=u}return{lastIndex:a,lastOffset:l,lastSize:i,offsetTree:s}}function rl(e){return{index:e.index,value:e}}function nl(e){const{endIndex:t,size:r,startIndex:o}=e;return s=>s.start===o&&(s.end===t||s.end===1/0)&&s.value===r}const ol={offsetHeight:"height",offsetWidth:"width"},lt=pe(([{log:e},{recalcInProgress:t}])=>{const r=ue(),o=ue(),s=He(o,0),a=ue(),i=ue(),l=F(0),d=F([]),c=F(void 0),u=F(void 0),f=F((k,b)=>wt(k,ol[b])),p=F(void 0),g=F(0),v=Yi(),y=He(L(r,le(d,e,g),st(el,v),xe()),v),N=He(L(d,xe(),st((k,b)=>({current:b,prev:k.current}),{current:[],prev:[]}),U(({prev:k})=>k)),[]);Y(L(d,te(k=>k.length>0),le(y,g),U(([k,b,I])=>{const S=k.reduce((C,R,D)=>$e(C,R,Qt(R,b.offsetTree,I)||D),Pt());return{...b,groupIndices:k,groupOffsetTree:S}})),y),Y(L(o,le(y),te(([k,{lastIndex:b}])=>k<b),U(([k,{lastIndex:b,lastSize:I}])=>[{endIndex:b,size:I,startIndex:k}])),r),Y(c,u);const x=He(L(c,U(k=>k===void 0)),!0);Y(L(u,te(k=>k!==void 0&&ge(_e(y).sizeTree)),U(k=>[{endIndex:0,size:k,startIndex:0}])),r);const h=Ve(L(r,le(y),st(({sizes:k},[b,I])=>({changed:I!==k,sizes:I}),{changed:!1,sizes:v}),U(k=>k.changed)));he(L(l,st((k,b)=>({diff:k.prev-b,prev:b}),{diff:0,prev:0}),U(k=>k.diff)),k=>{const{groupIndices:b}=_e(y);if(k>0)ae(t,!0),ae(a,k+Xn(k,b));else if(k<0){const I=_e(N);I.length>0&&(k-=Xn(-k,I)),ae(i,k)}}),he(L(l,le(e)),([k,b])=>{k<0&&b("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},Ue.ERROR)});const w=Ve(a);Y(L(a,le(y),U(([k,b])=>{const I=b.groupIndices.length>0,S=[],C=b.lastSize;if(I){const R=Zt(b.sizeTree,0);let D=0,B=0;for(;D<k;){const T=b.groupIndices[B],_=b.groupIndices.length===B+1?1/0:b.groupIndices[B+1]-T-1;S.push({endIndex:T,size:R,startIndex:T}),S.push({endIndex:T+1+_-1,size:C,startIndex:T+1}),B++,D+=_+1}const E=Et(b.sizeTree);return D!==k&&E.shift(),E.reduce((T,{k:_,v:O})=>{let $=T.ranges;return T.prevSize!==0&&($=[...T.ranges,{endIndex:_+k-1,size:T.prevSize,startIndex:T.prevIndex}]),{prevIndex:_+k,prevSize:O,ranges:$}},{prevIndex:k,prevSize:0,ranges:S}).ranges}return Et(b.sizeTree).reduce((R,{k:D,v:B})=>({prevIndex:D+k,prevSize:B,ranges:[...R.ranges,{endIndex:D+k-1,size:R.prevSize,startIndex:R.prevIndex}]}),{prevIndex:0,prevSize:C,ranges:[]}).ranges})),r);const j=Ve(L(i,le(y,g),U(([k,{offsetTree:b},I])=>{const S=-k;return Qt(S,b,I)})));return Y(L(i,le(y,g),U(([k,b,I])=>{if(b.groupIndices.length>0){if(ge(b.sizeTree))return b;let S=Pt();const C=_e(N);let R=0,D=0,B=0;for(;R<-k;){B=C[D];const E=C[D+1]-B-1;D++,R+=E+1}if(S=Et(b.sizeTree).reduce((E,{k:T,v:_})=>$e(E,Math.max(0,T+k),_),S),R!==-k){const E=Zt(b.sizeTree,B);S=$e(S,0,E);const T=Qe(b.sizeTree,-k+1)[1];S=$e(S,1,T)}return{...b,sizeTree:S,...gn(b.offsetTree,0,S,I)}}else{const S=Et(b.sizeTree).reduce((C,{k:R,v:D})=>$e(C,Math.max(0,R+k),D),Pt());return{...b,sizeTree:S,...gn(b.offsetTree,0,S,I)}}})),y),{beforeUnshiftWith:w,data:p,defaultItemSize:u,firstItemIndex:l,fixedItemSize:c,gap:g,groupIndices:d,itemSize:f,listRefresh:h,shiftWith:i,shiftWithOffset:j,sizeRanges:r,sizes:y,statefulTotalCount:s,totalCount:o,trackItemSizes:x,unshiftWith:a}},ve(jt,Sn),{singleton:!0});function sl(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const xs=pe(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:o,scrollTop:s}])=>{const a=ue(),i=ue(),l=Ve(L(a,U(sl)));return Y(L(l,U(d=>d.totalCount)),r),Y(L(l,U(d=>d.groupIndices)),e),Y(L(Te(s,t,o),te(([d,c])=>Fr(c)),U(([d,c,u])=>Qe(c.groupOffsetTree,Math.max(d-u,0),"v")[0]),xe(),U(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},ve(lt,Be)),kt=pe(([{log:e}])=>{const t=F(!1),r=Ve(L(t,te(o=>o),xe()));return he(t,o=>{o&&_e(e)("props updated",{},Ue.DEBUG)}),{didMount:r,propsReady:t}},ve(jt),{singleton:!0}),al=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function vs(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!al)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const or=pe(([{gap:e,listRefresh:t,sizes:r,totalCount:o},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:i,headerHeight:l,scrollingInProgress:d,scrollTo:c,smoothScrollTargetReached:u,viewportHeight:f},{log:p}])=>{const g=ue(),v=ue(),y=F(0);let N=null,x=null,h=null;function w(){N&&(N(),N=null),h&&(h(),h=null),x&&(clearTimeout(x),x=null),ae(d,!1)}return Y(L(g,le(r,f,o,y,l,i,p),le(e,a,s),U(([[j,k,b,I,S,C,R,D],B,E,T])=>{const _=vs(j),{align:O,behavior:$,offset:z}=_,V=I-1,P=gs(_,k,V);let M=Qt(P,k.offsetTree,B)+C;O==="end"?(M+=E+Qe(k.sizeTree,P)[1]-b+T,P===V&&(M+=R)):O==="center"?M+=(E+Qe(k.sizeTree,P)[1]-b+T)/2:M-=S,z&&(M+=z);const H=J=>{w(),J?(D("retrying to scroll to",{location:j},Ue.DEBUG),ae(g,j)):(ae(v,!0),D("list did not change, scroll successful",{},Ue.DEBUG))};if(w(),$==="smooth"){let J=!1;h=he(t,se=>{J=J||se}),N=at(u,()=>{H(J)})}else N=at(L(t,il(150)),H);return x=setTimeout(()=>{w()},1200),ae(d,!0),D("scrolling from index to",{behavior:$,index:P,top:M},Ue.DEBUG),{behavior:$,top:M}})),c),{scrollTargetReached:v,scrollToIndex:g,topListHeight:y}},ve(lt,Be,jt),{singleton:!0});function il(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(r))}}}function Tn(e,t){e==0?t():requestAnimationFrame(()=>{Tn(e-1,t)})}function En(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const sr=pe(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:o},{scrollTargetReached:s,scrollToIndex:a},{didMount:i}])=>{const l=F(!0),d=F(0),c=F(!0);return Y(L(i,le(d),te(([u,f])=>!!f),rt(!1)),l),Y(L(i,le(d),te(([u,f])=>!!f),rt(!1)),c),he(L(Te(t,i),le(l,r,e,c),te(([[,u],f,{sizeTree:p},g,v])=>u&&(!ge(p)||Nn(g))&&!f&&!v),le(d)),([,u])=>{at(s,()=>{ae(c,!0)}),Tn(4,()=>{at(o,()=>{ae(l,!0)}),ae(a,u)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:l}},ve(lt,Be,or,kt),{singleton:!0});function ys(e,t){return Math.abs(e-t)<1.01}const er="up",qt="down",ll="none",cl={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},dl=0,ar=pe(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:o,scrollTop:s,viewportHeight:a}])=>{const i=F(!1),l=F(!0),d=ue(),c=ue(),u=F(4),f=F(dl),p=He(L(Kn(L(re(s),zt(1),rt(!0)),L(re(s),zt(1),rt(!1),Gn(100))),xe()),!1),g=He(L(Kn(L(r,rt(!0)),L(r,rt(!1),Gn(200))),xe()),!1);Y(L(Te(re(s),re(f)),U(([h,w])=>h<=w),xe()),l),Y(L(l,yt(50)),c);const v=Ve(L(Te(o,re(a),re(t),re(e),re(u)),st((h,[{scrollHeight:w,scrollTop:j},k,b,I,S])=>{const C=j+k-w>-S,R={scrollHeight:w,scrollTop:j,viewportHeight:k};if(C){let B,E;return j>h.state.scrollTop?(B="SCROLLED_DOWN",E=h.state.scrollTop-j):(B="SIZE_DECREASED",E=h.state.scrollTop-j||h.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:E,state:R}}let D;return R.scrollHeight>h.state.scrollHeight?D="SIZE_INCREASED":k<h.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":j<h.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:R}},cl),xe((h,w)=>h&&h.atBottom===w.atBottom))),y=He(L(o,st((h,{scrollHeight:w,scrollTop:j,viewportHeight:k})=>{if(ys(h.scrollHeight,w))return{changed:!1,jump:0,scrollHeight:w,scrollTop:j};{const b=w-(j+k)<1;return h.scrollTop!==j&&b?{changed:!0,jump:h.scrollTop-j,scrollHeight:w,scrollTop:j}:{changed:!0,jump:0,scrollHeight:w,scrollTop:j}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),te(h=>h.changed),U(h=>h.jump)),0);Y(L(v,U(h=>h.atBottom)),i),Y(L(i,yt(50)),d);const N=F(qt);Y(L(o,U(({scrollTop:h})=>h),xe(),st((h,w)=>_e(g)?{direction:h.direction,prevScrollTop:w}:{direction:w<h.prevScrollTop?er:qt,prevScrollTop:w},{direction:qt,prevScrollTop:0}),U(h=>h.direction)),N),Y(L(o,yt(50),rt(ll)),N);const x=F(0);return Y(L(p,te(h=>!h),rt(0)),x),Y(L(s,yt(100),le(p),te(([h,w])=>!!w),st(([h,w],[j])=>[w,j],[0,0]),U(([h,w])=>w-h)),x),{atBottomState:v,atBottomStateChange:d,atBottomThreshold:u,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:y,scrollDirection:N,scrollVelocity:x}},ve(Be)),Cr="top",Tr="bottom",Zn="none";function Jn(e,t,r){return typeof e=="number"?r===er&&t===Cr||r===qt&&t===Tr?e:0:r===er?t===Cr?e.main:e.reverse:t===Tr?e.main:e.reverse}function Qn(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const An=pe(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:o,viewportHeight:s}])=>{const a=ue(),i=F(0),l=F(0),d=F(0),c=He(L(Te(re(o),re(s),re(r),re(a,Jt),re(d),re(i),re(t),re(e),re(l)),U(([u,f,p,[g,v],y,N,x,h,w])=>{const j=u-h,k=N+x,b=Math.max(p-j,0);let I=Zn;const S=Qn(w,Cr),C=Qn(w,Tr);return g-=h,g+=p+x,v+=p+x,v-=h,g>u+k-S&&(I=er),v<u-b+f+C&&(I=qt),I!==Zn?[Math.max(j-p-Jn(y,Cr,I)-S,0),j-b-x+f+Jn(y,Tr,I)+C]:null}),te(u=>u!=null),xe(Jt)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:c}},ve(Be),{singleton:!0});function ul(e,t,r){if(Fr(t)){const o=hs(e,t);return[{index:Qe(t.groupOffsetTree,o)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:o,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const Yr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function vr(e,t,r,o,s,a){const{lastIndex:i,lastOffset:l,lastSize:d}=s;let c=0,u=0;if(e.length>0){c=e[0].offset;const y=e[e.length-1];u=y.offset+y.size}const f=r-i,p=l+f*d+(f-1)*o,g=c,v=p-u;return{bottom:u,firstItemIndex:a,items:eo(e,s,a),offsetBottom:v,offsetTop:c,top:g,topItems:eo(t,s,a),topListHeight:t.reduce((y,N)=>N.size+y,0),totalCount:r}}function bs(e,t,r,o,s,a){let i=0;if(r.groupIndices.length>0)for(const u of r.groupIndices){if(u-i>=e)break;i++}const l=e+i,d=En(t,l),c=Array.from({length:l}).map((u,f)=>({data:a[f+d],index:f+d,offset:0,size:0}));return vr(c,[],l,s,r,o)}function eo(e,t,r){if(e.length===0)return[];if(!Fr(t))return e.map(c=>({...c,index:c.index+r,originalIndex:c.index}));const o=e[0].index,s=e[e.length-1].index,a=[],i=Or(t.groupOffsetTree,o,s);let l,d=0;for(const c of e){(!l||l.end<c.index)&&(l=i.shift(),d=t.groupIndices.indexOf(l.start));let u;c.index===l.start?u={index:d,type:"group"}:u={groupIndex:d,index:c.index-(d+1)+r},a.push({...u,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return a}const Lt=pe(([{data:e,firstItemIndex:t,gap:r,sizes:o,totalCount:s},a,{listBoundary:i,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:c,scrolledToInitialItem:u},{topListHeight:f},p,{didMount:g},{recalcInProgress:v}])=>{const y=F([]),N=F(0),x=ue();Y(a.topItemsIndexes,y);const h=He(L(Te(g,v,re(d,Jt),re(s),re(o),re(c),u,re(y),re(t),re(r),e),te(([b,I,,S,,,,,,,C])=>{const R=C&&C.length!==S;return b&&!I&&!R}),U(([,,[b,I],S,C,R,D,B,E,T,_])=>{const O=C,{offsetTree:$,sizeTree:z}=O,V=_e(N);if(S===0)return{...Yr,totalCount:S};if(b===0&&I===0)return V===0?{...Yr,totalCount:S}:bs(V,R,C,E,T,_||[]);if(ge(z))return V>0?null:vr(ul(En(R,S),O,_),[],S,T,O,E);const P=[];if(B.length>0){const X=B[0],G=B[B.length-1];let Z=0;for(const A of Or(z,X,G)){const W=A.value,oe=Math.max(A.start,X),ce=Math.min(A.end,G);for(let ie=oe;ie<=ce;ie++)P.push({data:_==null?void 0:_[ie],index:ie,offset:Z,size:W}),Z+=W}}if(!D)return vr([],P,S,T,O,E);const M=B.length>0?B[B.length-1]+1:0,H=Qi($,b,I,M);if(H.length===0)return null;const J=S-1,se=Hr([],X=>{for(const G of H){const Z=G.value;let A=Z.offset,W=G.start;const oe=Z.size;if(Z.offset<b){W+=Math.floor((b-Z.offset+T)/(oe+T));const ie=W-G.start;A+=ie*oe+ie*T}W<M&&(A+=(M-W)*oe,W=M);const ce=Math.min(G.end,J);for(let ie=W;ie<=ce&&!(A>=I);ie++)X.push({data:_==null?void 0:_[ie],index:ie,offset:A,size:oe}),A+=oe+T}});return vr(se,P,S,T,O,E)}),te(b=>b!==null),xe()),Yr);Y(L(e,te(Nn),U(b=>b==null?void 0:b.length)),s),Y(L(h,U(b=>b.topListHeight)),f),Y(f,l),Y(L(h,U(b=>[b.top,b.bottom])),i),Y(L(h,U(b=>b.items)),x);const w=Ve(L(h,te(({items:b})=>b.length>0),le(s,e),te(([{items:b},I])=>b[b.length-1].originalIndex===I-1),U(([,b,I])=>[b-1,I]),xe(Jt),U(([b])=>b))),j=Ve(L(h,yt(200),te(({items:b,topItems:I})=>b.length>0&&b[0].originalIndex===I.length),U(({items:b})=>b[0].index),xe())),k=Ve(L(h,te(({items:b})=>b.length>0),U(({items:b})=>{let I=0,S=b.length-1;for(;b[I].type==="group"&&I<S;)I++;for(;b[S].type==="group"&&S>I;)S--;return{endIndex:b[S].index,startIndex:b[I].index}}),xe(ms)));return{endReached:w,initialItemCount:N,itemsRendered:x,listState:h,rangeChanged:k,startReached:j,topItemsIndexes:y,...p}},ve(lt,xs,An,sr,or,ar,kt,Sn),{singleton:!0}),ws=pe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:o},{listState:s}])=>{const a=ue(),i=He(L(Te(r,e,o,t,s),U(([l,d,c,u,f])=>l+d+c+u+f.offsetBottom+f.bottom)),0);return Y(re(i),a),{totalListHeight:i,totalListHeightChanged:a}},ve(Be,Lt),{singleton:!0}),fl=pe(([{viewportHeight:e},{totalListHeight:t}])=>{const r=F(!1),o=He(L(Te(r,e,t),te(([s])=>s),U(([,s,a])=>Math.max(0,s-a)),yt(0),xe()),0);return{alignToBottom:r,paddingTopAddition:o}},ve(Be,ws),{singleton:!0});function to(e){return e?e==="smooth"?"smooth":"auto":!1}const ml=(e,t)=>typeof e=="function"?to(e(t)):t&&to(e),pl=pe(([{listRefresh:e,totalCount:t},{atBottomState:r,isAtBottom:o},{scrollToIndex:s},{scrolledToInitialItem:a},{didMount:i,propsReady:l},{log:d},{scrollingInProgress:c}])=>{const u=F(!1),f=ue();let p=null;function g(y){ae(s,{align:"end",behavior:y,index:"LAST"})}he(L(Te(L(re(t),zt(1)),i),le(re(u),o,a,c),U(([[y,N],x,h,w,j])=>{let k=N&&w,b="auto";return k&&(b=ml(x,h||j),k=k&&!!b),{followOutputBehavior:b,shouldFollow:k,totalCount:y}}),te(({shouldFollow:y})=>y)),({followOutputBehavior:y,totalCount:N})=>{p&&(p(),p=null),p=at(e,()=>{_e(d)("following output to ",{totalCount:N},Ue.DEBUG),g(y),p=null})});function v(y){const N=at(r,x=>{y&&!x.atBottom&&x.notAtBottomBecause==="SIZE_INCREASED"&&!p&&(_e(d)("scrolling to bottom due to increased size",{},Ue.DEBUG),g("auto"))});setTimeout(N,100)}return he(L(Te(re(u),t,l),te(([y,,N])=>y&&N),st(({value:y},[,N])=>({refreshed:y===N,value:N}),{refreshed:!1,value:0}),te(({refreshed:y})=>y),le(u,t)),([,y])=>{_e(a)&&v(y!==!1)}),he(f,()=>{v(_e(u)!==!1)}),he(Te(re(u),r),([y,N])=>{y&&!N.atBottom&&N.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")}),{autoscrollToBottom:f,followOutput:u}},ve(lt,ar,or,sr,kt,jt,Be)),hl=pe(([{data:e,firstItemIndex:t,gap:r,sizes:o},{initialTopMostItemIndex:s},{initialItemCount:a,listState:i},{didMount:l}])=>(Y(L(l,le(a),te(([,d])=>d!==0),le(s,o,t,r,e),U(([[,d],c,u,f,p,g=[]])=>bs(d,c,u,f,p,g))),i),{}),ve(lt,sr,Lt,kt),{singleton:!0}),gl=pe(([{didMount:e},{scrollTo:t},{listState:r}])=>{const o=F(0);return he(L(e,le(o),te(([,s])=>s!==0),U(([,s])=>({top:s}))),s=>{at(L(r,zt(1),te(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{ae(t,s)})})}),{initialScrollTop:o}},ve(kt,Be,Lt),{singleton:!0}),xl=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:o,...s},viewportBottom:a,viewportTop:i})=>t<i?{...s,align:r??"start",behavior:o}:e>a?{...s,align:r??"end",behavior:o}:null,vl=pe(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:i,scrollTop:l,viewportHeight:d},{scrollToIndex:c}])=>{const u=ue();return Y(L(u,le(t,d,r,a,s,o,l),le(e),U(([[f,p,g,v,y,N,x,h],w])=>{const{align:j,behavior:k,calculateViewLocation:b=xl,done:I,...S}=f,C=gs(f,p,v-1),R=Qt(C,p.offsetTree,w)+y+N,D=R+Qe(p.sizeTree,C)[1],B=h+N,E=h+g-x,T=b({itemBottom:D,itemTop:R,locationParams:{align:j,behavior:k,...S},viewportBottom:E,viewportTop:B});return T?I&&at(L(i,te(_=>!_),zt(_e(i)?1:2)),I):I&&I(),T}),te(f=>f!==null)),c),{scrollIntoView:u}},ve(lt,Be,or,Lt,jt),{singleton:!0}),Is=pe(([{scrollVelocity:e}])=>{const t=F(!1),r=ue(),o=F(!1);return Y(L(e,le(o,t,r),te(([s,a])=>!!a),U(([s,a,i,l])=>{const{enter:d,exit:c}=a;if(i){if(c(s,l))return!1}else if(d(s,l))return!0;return i}),xe()),t),he(L(Te(t,e,r),le(o)),([[s,a,i],l])=>{s&&l&&l.change&&l.change(a,i)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:r,scrollVelocity:e}},ve(ar),{singleton:!0}),Rn=pe(([{scrollContainerState:e,scrollTo:t}])=>{const r=ue(),o=ue(),s=ue(),a=F(!1),i=F(void 0);return Y(L(Te(r,o),U(([{scrollHeight:l,scrollTop:d,viewportHeight:c},{offsetTop:u}])=>({scrollHeight:l,scrollTop:Math.max(0,d-u),viewportHeight:c}))),e),Y(L(t,le(o),U(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),s),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:o}},ve(Be)),yl=pe(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:o},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:d}])=>{const c=ue(),u=F(void 0),f=F(null),p=F(null);return Y(l,f),Y(d,p),he(L(c,le(t,o,i,f,p,r)),([g,v,y,N,x,h,w])=>{const j=tl(v.sizeTree);N&&x!==null&&h!==null&&(y=x.scrollTop-h.offsetTop),y-=w,g({ranges:j,scrollTop:y})}),Y(L(u,te(Nn),U(bl)),s),Y(L(a,le(u),te(([,g])=>g!==void 0),xe(),U(([,g])=>g.ranges)),e),{getState:c,restoreStateFrom:u}},ve(lt,Be,sr,kt,Rn));function bl(e){return{align:"start",index:0,offset:e.scrollTop}}const wl=pe(([{topItemsIndexes:e}])=>{const t=F(0);return Y(L(t,te(r=>r>=0),U(r=>Array.from({length:r}).map((o,s)=>s))),e),{topItemCount:t}},ve(Lt));function Ns(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const Il=Ns(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Nl=pe(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:o},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:l},{listState:d},{beforeUnshiftWith:c,gap:u,shiftWithOffset:f,sizes:p},{log:g},{recalcInProgress:v}])=>{const y=Ve(L(d,le(i),st(([,x,h,w],[{bottom:j,items:k,offsetBottom:b,totalCount:I},S])=>{const C=j+b;let R=0;return h===I&&x.length>0&&k.length>0&&(k[0].originalIndex===0&&x[0].originalIndex===0||(R=C-w,R!==0&&(R+=S))),[R,k,I,C]},[0,[],0,0]),te(([x])=>x!==0),le(o,l,r,s,g,v),te(([,x,h,w,,,j])=>!j&&!w&&x!==0&&h===er),U(([[x],,,,,h])=>(h("Upward scrolling compensation",{amount:x},Ue.DEBUG),x))));function N(x){x>0?(ae(t,{behavior:"auto",top:-x}),ae(e,0)):(ae(e,0),ae(t,{behavior:"auto",top:-x}))}return he(L(y,le(e,a)),([x,h,w])=>{w&&Il()?ae(e,h-x):N(-x)}),he(L(Te(He(a,!1),e,v),te(([x,h,w])=>!x&&!w&&h!==0),U(([x,h])=>h),yt(1)),N),Y(L(f,U(x=>({top:-x}))),t),he(L(c,le(p,u),U(([x,{groupIndices:h,lastSize:w,sizeTree:j},k])=>{function b(I){return I*(w+k)}if(h.length===0)return b(x);{let I=0;const S=Zt(j,0);let C=0,R=0;for(;C<x;){C++,I+=S;let D=h.length===R+1?1/0:h[R+1]-h[R]-1;C+D>x&&(I-=S,D=x-C+1),C+=D,I+=b(D),R++}return I}})),x=>{ae(e,x),requestAnimationFrame(()=>{ae(t,{top:x}),requestAnimationFrame(()=>{ae(e,0),ae(v,!1)})})}),{deviation:e}},ve(Be,ar,Lt,lt,jt,Sn)),jl=pe(([e,t,r,o,s,a,i,l,d,c])=>({...e,...t,...r,...o,...s,...a,...i,...l,...d,...c}),ve(An,hl,kt,Is,ws,gl,fl,Rn,vl,jt)),js=pe(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:o,gap:s,groupIndices:a,itemSize:i,sizeRanges:l,sizes:d,statefulTotalCount:c,totalCount:u,trackItemSizes:f},{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:v},y,N,x,{listState:h,topItemsIndexes:w,...j},{scrollToIndex:k},b,{topItemCount:I},{groupCounts:S},C])=>(Y(j.rangeChanged,C.scrollSeekRangeChanged),Y(L(C.windowViewportRect,U(R=>R.visibleHeight)),y.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:o,gap:s,groupCounts:S,initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:v,sizeRanges:l,topItemCount:I,topItemsIndexes:w,totalCount:u,...x,groupIndices:a,itemSize:i,listState:h,scrollToIndex:k,statefulTotalCount:c,trackItemSizes:f,...j,...C,...y,sizes:d,...N}),ve(lt,sr,Be,yl,pl,Lt,or,Nl,wl,xs,jl));function kl(e,t){const r={},o={};let s=0;const a=e.length;for(;s<a;)o[e[s]]=1,s+=1;for(const i in t)Object.hasOwn(o,i)||(r[i]=t[i]);return r}const fr=typeof document<"u"?K.useLayoutEffect:K.useEffect;function ks(e,t,r){const o=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),l=K.createContext({});function d(N,x){N.propsReady&&ae(N.propsReady,!1);for(const h of o){const w=N[t.required[h]];ae(w,x[h])}for(const h of s)if(h in x){const w=N[t.optional[h]];ae(w,x[h])}N.propsReady&&ae(N.propsReady,!0)}function c(N){return a.reduce((x,h)=>(x[h]=w=>{const j=N[t.methods[h]];ae(j,w)},x),{})}function u(N){return i.reduce((x,h)=>(x[h]=Bi(N[t.events[h]]),x),{})}const f=K.forwardRef((N,x)=>{const{children:h,...w}=N,[j]=K.useState(()=>Hr(Wi(e),I=>{d(I,w)})),[k]=K.useState(Un(u,j));fr(()=>{for(const I of i)I in w&&he(k[I],w[I]);return()=>{Object.values(k).map(jn)}},[w,k,j]),fr(()=>{d(j,w)}),K.useImperativeHandle(x,Vn(c(j)));const b=r;return n.jsx(l.Provider,{value:j,children:r?n.jsx(b,{...kl([...o,...s,...i],w),children:h}):h})}),p=N=>{const x=K.useContext(l);return K.useCallback(h=>{ae(x[N],h)},[x,N])},g=N=>{const x=K.useContext(l)[N],h=K.useCallback(w=>he(x,w),[x]);return K.useSyncExternalStore(h,()=>_e(x),()=>_e(x))},v=N=>{const x=K.useContext(l)[N],[h,w]=K.useState(Un(_e,x));return fr(()=>he(x,j=>{j!==h&&w(Vn(j))}),[x,h]),h},y=K.version.startsWith("18")?g:v;return{Component:f,useEmitter:(N,x)=>{const h=K.useContext(l)[N];fr(()=>he(h,x),[x,h])},useEmitterValue:y,usePublisher:p}}const Ss=K.createContext(void 0),Cs=K.createContext(void 0),Ts=typeof document<"u"?K.useLayoutEffect:K.useEffect;function Xr(e){return"self"in e}function Sl(e){return"body"in e}function Es(e,t,r,o=$t,s,a){const i=K.useRef(null),l=K.useRef(null),d=K.useRef(null),c=K.useCallback(p=>{let g,v,y;const N=p.target;if(Sl(N)||Xr(N)){const h=Xr(N)?N:N.defaultView;y=a?h.scrollX:h.scrollY,g=a?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight,v=a?h.innerWidth:h.innerHeight}else y=a?N.scrollLeft:N.scrollTop,g=a?N.scrollWidth:N.scrollHeight,v=a?N.offsetWidth:N.offsetHeight;const x=()=>{e({scrollHeight:g,scrollTop:Math.max(y,0),viewportHeight:v})};p.suppressFlushSync?x():Wo.flushSync(x),l.current!==null&&(y===l.current||y<=0||y===g-v)&&(l.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);K.useEffect(()=>{const p=s||i.current;return o(s||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{o(null),p.removeEventListener("scroll",c)}},[i,c,r,o,s]);function u(p){const g=i.current;if(!g||(a?"offsetWidth"in g&&g.offsetWidth===0:"offsetHeight"in g&&g.offsetHeight===0))return;const v=p.behavior==="smooth";let y,N,x;Xr(g)?(N=Math.max(wt(g.document.documentElement,a?"width":"height"),a?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight),y=a?g.innerWidth:g.innerHeight,x=a?window.scrollX:window.scrollY):(N=g[a?"scrollWidth":"scrollHeight"],y=wt(g,a?"width":"height"),x=g[a?"scrollLeft":"scrollTop"]);const h=N-y;if(p.top=Math.ceil(Math.max(Math.min(h,p.top),0)),ys(y,N)||p.top===x){e({scrollHeight:N,scrollTop:x,viewportHeight:y}),v&&t(!0);return}v?(l.current=p.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,t(!0)},1e3)):l.current=null,a&&(p={behavior:p.behavior,left:p.top}),g.scrollTo(p)}function f(p){a&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:u}}const Zr="-webkit-sticky",ro="sticky",As=Ns(()=>{if(typeof document>"u")return ro;const e=document.createElement("div");return e.style.position=Zr,e.style.position===Zr?Zr:ro});function Dn(e){return e}const Cl=pe(()=>{const e=F(d=>`Item ${d}`),t=F(null),r=F(d=>`Group ${d}`),o=F({}),s=F(Dn),a=F("div"),i=F($t),l=(d,c=null)=>He(L(o,U(u=>u[d]),xe()),c);return{components:o,computeItemKey:s,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FooterComponent:l("Footer"),GroupComponent:l("Group","div"),groupContent:r,HeaderComponent:l("Header"),HeaderFooterTag:a,ItemComponent:l("Item","div"),itemContent:e,ListComponent:l("List","div"),ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TopItemListComponent:l("TopItemList")}}),Tl=pe(([e,t])=>({...e,...t}),ve(js,Cl)),El=({height:e})=>n.jsx("div",{style:{height:e}}),Al={overflowAnchor:"none",position:As(),zIndex:1},Rs={overflowAnchor:"none"},Rl={...Rs,display:"inline-block",height:"100%"},no=K.memo(function({showTopList:e=!1}){const t=ne("listState"),r=Ye("sizeRanges"),o=ne("useWindowScroll"),s=ne("customScrollParent"),a=Ye("windowScrollContainerState"),i=Ye("scrollContainerState"),l=s||o?a:i,d=ne("itemContent"),c=ne("context"),u=ne("groupContent"),f=ne("trackItemSizes"),p=ne("itemSize"),g=ne("log"),v=Ye("gap"),y=ne("horizontalDirection"),{callbackRef:N}=Ui(r,p,f,e?$t:l,g,v,s,y,ne("skipAnimationFrameInResizeObserver")),[x,h]=K.useState(0);Mn("deviation",T=>{x!==T&&h(T)});const w=ne("EmptyPlaceholder"),j=ne("ScrollSeekPlaceholder")||El,k=ne("ListComponent"),b=ne("ItemComponent"),I=ne("GroupComponent"),S=ne("computeItemKey"),C=ne("isSeeking"),R=ne("groupIndices").length>0,D=ne("alignToBottom"),B=ne("initialItemFinalLocationReached"),E=e?{}:{boxSizing:"border-box",...y?{display:"inline-block",height:"100%",marginLeft:x!==0?x:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&w?n.jsx(w,{...De(w,c)}):n.jsx(k,{...De(k,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:N,style:E,children:(e?t.topItems:t.items).map(T=>{const _=T.originalIndex,O=S(_+t.firstItemIndex,T.data,c);return C?m.createElement(j,{...De(j,c),height:T.size,index:T.index,key:O,type:T.type||"item",...T.type==="group"?{}:{groupIndex:T.groupIndex}}):T.type==="group"?m.createElement(I,{...De(I,c),"data-index":_,"data-item-index":T.index,"data-known-size":T.size,key:O,style:Al},u(T.index,c)):m.createElement(b,{...De(b,c),..._l(b,T.data),"data-index":_,"data-item-group-index":T.groupIndex,"data-item-index":T.index,"data-known-size":T.size,key:O,style:y?Rl:Rs},R?d(T.index,T.groupIndex,T.data,c):d(T.index,T.data,c))})})}),Dl={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ml={outline:"none",overflowX:"auto",position:"relative"},Pr=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ll={position:As(),top:0,width:"100%",zIndex:1};function De(e,t){if(typeof e!="string")return{context:t}}function _l(e,t){return{item:typeof e=="string"?void 0:t}}const Hl=K.memo(function(){const e=ne("HeaderComponent"),t=Ye("headerHeight"),r=ne("HeaderFooterTag"),o=Mt(K.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,ne("skipAnimationFrameInResizeObserver")),s=ne("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null}),Ol=K.memo(function(){const e=ne("FooterComponent"),t=Ye("footerHeight"),r=ne("HeaderFooterTag"),o=Mt(K.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,ne("skipAnimationFrameInResizeObserver")),s=ne("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null});function Ds({useEmitter:e,useEmitterValue:t,usePublisher:r}){return K.memo(function({children:o,style:s,...a}){const i=r("scrollContainerState"),l=t("ScrollerComponent"),d=r("smoothScrollTargetReached"),c=t("scrollerRef"),u=t("context"),f=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:g,scrollToCallback:v}=Es(i,d,l,c,void 0,f);return e("scrollTo",v),e("scrollBy",p),n.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:g,style:{...f?Ml:Dl,...s},tabIndex:0,...a,...De(l,u),children:o})})}function Ms({useEmitter:e,useEmitterValue:t,usePublisher:r}){return K.memo(function({children:o,style:s,...a}){const i=r("windowScrollContainerState"),l=t("ScrollerComponent"),d=r("smoothScrollTargetReached"),c=t("totalListHeight"),u=t("deviation"),f=t("customScrollParent"),p=t("context"),g=K.useRef(null),v=t("scrollerRef"),{scrollByCallback:y,scrollerRef:N,scrollToCallback:x}=Es(i,d,l,v,f);return Ts(()=>{var h;return N.current=f||((h=g.current)==null?void 0:h.ownerDocument.defaultView),()=>{N.current=null}},[N,f]),e("windowScrollTo",x),e("scrollBy",y),n.jsx(l,{ref:g,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...c!==0?{height:c+u}:{}},...a,...De(l,p),children:o})})}const Fl=({children:e})=>{const t=K.useContext(Ss),r=Ye("viewportHeight"),o=Ye("fixedItemHeight"),s=ne("alignToBottom"),a=ne("horizontalDirection"),i=K.useMemo(()=>ss(r,d=>wt(d,a?"width":"height")),[r,a]),l=Mt(i,!0,ne("skipAnimationFrameInResizeObserver"));return K.useEffect(()=>{t&&(r(t.viewportHeight),o(t.itemHeight))},[t,r,o]),n.jsx("div",{"data-viewport-type":"element",ref:l,style:Pr(s),children:e})},Pl=({children:e})=>{const t=K.useContext(Ss),r=Ye("windowViewportRect"),o=Ye("fixedItemHeight"),s=ne("customScrollParent"),a=is(r,s,ne("skipAnimationFrameInResizeObserver")),i=ne("alignToBottom");return K.useEffect(()=>{t&&(o(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,o]),n.jsx("div",{"data-viewport-type":"window",ref:a,style:Pr(i),children:e})},Bl=({children:e})=>{const t=ne("TopItemListComponent")||"div",r=ne("headerHeight"),o={...Ll,marginTop:`${r}px`},s=ne("context");return n.jsx(t,{style:o,...De(t,s),children:e})},zl=K.memo(function(e){const t=ne("useWindowScroll"),r=ne("topItemsIndexes").length>0,o=ne("customScrollParent"),s=ne("context"),a=o||t?Vl:$l,i=o||t?Pl:Fl;return n.jsxs(a,{...e,...De(a,s),children:[r&&n.jsx(Bl,{children:n.jsx(no,{showTopList:!0})}),n.jsxs(i,{children:[n.jsx(Hl,{}),n.jsx(no,{}),n.jsx(Ol,{})]})]})}),{Component:Wl,useEmitter:Mn,useEmitterValue:ne,usePublisher:Ye}=ks(Tl,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},zl),$l=Ds({useEmitter:Mn,useEmitterValue:ne,usePublisher:Ye}),Vl=Ms({useEmitter:Mn,useEmitterValue:ne,usePublisher:Ye}),Ul=Wl,Gl=pe(()=>{const e=F(d=>n.jsxs("td",{children:["Item $",d]})),t=F(null),r=F(null),o=F(null),s=F({}),a=F(Dn),i=F($t),l=(d,c=null)=>He(L(s,U(u=>u[d]),xe()),c);return{components:s,computeItemKey:a,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr")}});ve(js,Gl);const oo={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Kl={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:so,floor:Er,max:Yt,min:Jr,round:ao}=Math;function io(e,t,r){return Array.from({length:t-e+1}).map((o,s)=>({data:r===null?null:r[s+e],index:s+e}))}function ql(e){return{...Kl,items:e}}function mr(e,t){return e&&e.width===t.width&&e.height===t.height}function Yl(e,t){return e&&e.column===t.column&&e.row===t.row}const Xl=pe(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:o},{footerHeight:s,headerHeight:a,scrollBy:i,scrollContainerState:l,scrollTo:d,scrollTop:c,smoothScrollTargetReached:u,viewportHeight:f},p,g,{didMount:v,propsReady:y},{customScrollParent:N,useWindowScroll:x,windowScrollContainerState:h,windowScrollTo:w,windowViewportRect:j},k])=>{const b=F(0),I=F(0),S=F(oo),C=F({height:0,width:0}),R=F({height:0,width:0}),D=ue(),B=ue(),E=F(0),T=F(null),_=F({column:0,row:0}),O=ue(),$=ue(),z=F(!1),V=F(0),P=F(!0),M=F(!1),H=F(!1);he(L(v,le(V),te(([A,W])=>!!W)),()=>{ae(P,!1)}),he(L(Te(v,P,R,C,V,M),te(([A,W,oe,ce,,ie])=>A&&!W&&oe.height!==0&&ce.height!==0&&!ie)),([,,,,A])=>{ae(M,!0),Tn(1,()=>{ae(D,A)}),at(L(c),()=>{ae(t,[0,0]),ae(P,!0)})}),Y(L($,te(A=>A!=null&&A.scrollTop>0),rt(0)),I),he(L(v,le($),te(([,A])=>A!=null)),([,A])=>{A&&(ae(C,A.viewport),ae(R,A.item),ae(_,A.gap),A.scrollTop>0&&(ae(z,!0),at(L(c,zt(1)),W=>{ae(z,!1)}),ae(d,{top:A.scrollTop})))}),Y(L(C,U(({height:A})=>A)),f),Y(L(Te(re(C,mr),re(R,mr),re(_,(A,W)=>A&&A.column===W.column&&A.row===W.row),re(c)),U(([A,W,oe,ce])=>({gap:oe,item:W,scrollTop:ce,viewport:A}))),O),Y(L(Te(re(b),o,re(_,Yl),re(R,mr),re(C,mr),re(T),re(I),re(z),re(P),re(V)),te(([,,,,,,,A])=>!A),U(([A,[W,oe],ce,ie,Q,de,Ne,,Ae,je])=>{const{column:we,row:Me}=ce,{height:Ke,width:q}=ie,{width:Ie}=Q;if(Ne===0&&(A===0||Ie===0))return oo;if(q===0){const ct=En(je,A),pt=ct+Math.max(Ne-1,0);return ql(io(ct,pt,de))}const ye=Ls(Ie,q,we);let ke,fe;Ae?W===0&&oe===0&&Ne>0?(ke=0,fe=Ne-1):(ke=ye*Er((W+Me)/(Ke+Me)),fe=ye*so((oe+Me)/(Ke+Me))-1,fe=Jr(A-1,Yt(fe,ye-1)),ke=Jr(fe,Yt(0,ke))):(ke=0,fe=-1);const Le=io(ke,fe,de),{bottom:Oe,top:Ze}=lo(Q,ce,ie,Le),qe=so(A/ye),mt=qe*Ke+(qe-1)*Me-Oe;return{bottom:Oe,itemHeight:Ke,items:Le,itemWidth:q,offsetBottom:mt,offsetTop:Ze,top:Ze}})),S),Y(L(T,te(A=>A!==null),U(A=>A.length)),b),Y(L(Te(C,R,S,_),te(([A,W,{items:oe}])=>oe.length>0&&W.height!==0&&A.height!==0),U(([A,W,{items:oe},ce])=>{const{bottom:ie,top:Q}=lo(A,ce,W,oe);return[Q,ie]}),xe(Jt)),t);const J=F(!1);Y(L(c,le(J),U(([A,W])=>W||A!==0)),J);const se=Ve(L(Te(S,b),te(([{items:A}])=>A.length>0),le(J),te(([[A,W],oe])=>{const ce=A.items[A.items.length-1].index===W-1;return(oe||A.bottom>0&&A.itemHeight>0&&A.offsetBottom===0&&A.items.length===W)&&ce}),U(([[,A]])=>A-1),xe())),X=Ve(L(re(S),te(({items:A})=>A.length>0&&A[0].index===0),rt(0),xe())),G=Ve(L(re(S),le(z),te(([{items:A},W])=>A.length>0&&!W),U(([{items:A}])=>({endIndex:A[A.length-1].index,startIndex:A[0].index})),xe(ms),yt(0)));Y(G,g.scrollSeekRangeChanged),Y(L(D,le(C,R,b,_),U(([A,W,oe,ce,ie])=>{const Q=vs(A),{align:de,behavior:Ne,offset:Ae}=Q;let je=Q.index;je==="LAST"&&(je=ce-1),je=Yt(0,je,Jr(ce-1,je));let we=xn(W,ie,oe,je);return de==="end"?we=ao(we-W.height+oe.height):de==="center"&&(we=ao(we-W.height/2+oe.height/2)),Ae&&(we+=Ae),{behavior:Ne,top:we}})),d);const Z=He(L(S,U(A=>A.offsetBottom+A.bottom)),0);return Y(L(j,U(A=>({height:A.visibleHeight,width:A.visibleWidth}))),C),{customScrollParent:N,data:T,deviation:E,footerHeight:s,gap:_,headerHeight:a,increaseViewportBy:e,initialItemCount:I,itemDimensions:R,overscan:r,restoreStateFrom:$,scrollBy:i,scrollContainerState:l,scrollHeight:B,scrollTo:d,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:u,totalCount:b,useWindowScroll:x,viewportDimensions:C,windowScrollContainerState:h,windowScrollTo:w,windowViewportRect:j,...g,gridState:S,horizontalDirection:H,initialTopMostItemIndex:V,totalListHeight:Z,...p,endReached:se,propsReady:y,rangeChanged:G,startReached:X,stateChanged:O,stateRestoreInProgress:z,...k}},ve(An,Be,ar,Is,kt,Rn,jt));function Ls(e,t,r){return Yt(1,Er((e+r)/(Er(t)+r)))}function lo(e,t,r,o){const{height:s}=r;if(s===void 0||o.length===0)return{bottom:0,top:0};const a=xn(e,t,r,o[0].index);return{bottom:xn(e,t,r,o[o.length-1].index)+s,top:a}}function xn(e,t,r,o){const s=Ls(e.width,r.width,t.column),a=Er(o/s),i=a*r.height+Yt(0,a-1)*t.row;return i>0?i+t.row:i}const Zl=pe(()=>{const e=F(f=>`Item ${f}`),t=F({}),r=F(null),o=F("virtuoso-grid-item"),s=F("virtuoso-grid-list"),a=F(Dn),i=F("div"),l=F($t),d=(f,p=null)=>He(L(t,U(g=>g[f]),xe()),p),c=F(!1),u=F(!1);return Y(re(u),c),{components:t,computeItemKey:a,context:r,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:i,itemClassName:o,ItemComponent:d("Item","div"),itemContent:e,listClassName:s,ListComponent:d("List","div"),readyStateChanged:c,reportReadyState:u,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),Jl=pe(([e,t])=>({...e,...t}),ve(Xl,Zl)),Ql=K.memo(function(){const e=be("gridState"),t=be("listClassName"),r=be("itemClassName"),o=be("itemContent"),s=be("computeItemKey"),a=be("isSeeking"),i=Xe("scrollHeight"),l=be("ItemComponent"),d=be("ListComponent"),c=be("ScrollSeekPlaceholder"),u=be("context"),f=Xe("itemDimensions"),p=Xe("gap"),g=be("log"),v=be("stateRestoreInProgress"),y=Xe("reportReadyState"),N=Mt(K.useMemo(()=>x=>{const h=x.parentElement.parentElement.scrollHeight;i(h);const w=x.firstChild;if(w){const{height:j,width:k}=w.getBoundingClientRect();f({height:j,width:k})}p({column:co("column-gap",getComputedStyle(x).columnGap,g),row:co("row-gap",getComputedStyle(x).rowGap,g)})},[i,f,p,g]),!0,!1);return Ts(()=>{e.itemHeight>0&&e.itemWidth>0&&y(!0)},[e]),v?null:n.jsx(d,{className:t,ref:N,...De(d,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const h=s(x.index,x.data,u);return a?n.jsx(c,{...De(c,u),height:e.itemHeight,index:x.index,width:e.itemWidth},h):m.createElement(l,{...De(l,u),className:r,"data-index":x.index,key:h},o(x.index,x.data,u))})})}),ec=K.memo(function(){const e=be("HeaderComponent"),t=Xe("headerHeight"),r=be("headerFooterTag"),o=Mt(K.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,!1),s=be("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null}),tc=K.memo(function(){const e=be("FooterComponent"),t=Xe("footerHeight"),r=be("headerFooterTag"),o=Mt(K.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,!1),s=be("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null}),rc=({children:e})=>{const t=K.useContext(Cs),r=Xe("itemDimensions"),o=Xe("viewportDimensions"),s=Mt(K.useMemo(()=>a=>{o(a.getBoundingClientRect())},[o]),!0,!1);return K.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,o,r]),n.jsx("div",{ref:s,style:Pr(!1),children:e})},nc=({children:e})=>{const t=K.useContext(Cs),r=Xe("windowViewportRect"),o=Xe("itemDimensions"),s=be("customScrollParent"),a=is(r,s,!1);return K.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,o]),n.jsx("div",{ref:a,style:Pr(!1),children:e})},oc=K.memo(function({...e}){const t=be("useWindowScroll"),r=be("customScrollParent"),o=r||t?ac:sc,s=r||t?nc:rc,a=be("context");return n.jsx(o,{...e,...De(o,a),children:n.jsxs(s,{children:[n.jsx(ec,{}),n.jsx(Ql,{}),n.jsx(tc,{})]})})}),{useEmitter:_s,useEmitterValue:be,usePublisher:Xe}=ks(Jl,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},oc),sc=Ds({useEmitter:_s,useEmitterValue:be,usePublisher:Xe}),ac=Ms({useEmitter:_s,useEmitterValue:be,usePublisher:Xe});function co(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Ue.WARN),t==="normal"?0:parseInt(t??"0",10)}function tr(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function Ar({value:e}){const t=e.stack,r=typeof e.message=="string"?e.message:void 0,o=r?`${r}
22
+
23
+ ${t}`:t;return n.jsxs("div",{className:"relative overflow-x-auto rounded-md border p-3 pt-9",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("button",{type:"button","aria-label":"Copy error",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border !bg-[var(--ds-background-100)] !text-[var(--ds-gray-800)] transition-transform transition-colors duration-100 hover:!bg-[var(--ds-gray-alpha-200)] active:!scale-95 active:!bg-[var(--ds-gray-alpha-300)]",style:{borderColor:"var(--ds-gray-300)"},onClick:()=>{navigator.clipboard.writeText(o).then(()=>{me.success("Copied to clipboard")}).catch(()=>{me.error("Failed to copy")})},children:n.jsx(rr,{size:12})}),r&&n.jsx("p",{className:"pb-2 mb-2 text-xs font-semibold font-mono",style:{color:"var(--ds-red-900)",borderBottom:"1px solid var(--ds-gray-300)"},children:r}),n.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words overflow-auto m-0",style:{color:"var(--ds-gray-1000)"},children:t})]})}const ic=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),Ln={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},Hs="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function lc(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function cc(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function dc(e){return e==="step_failed"||e==="run_failed"||e==="workflow_failed"?"var(--ds-red-700)":e==="run_cancelled"||e==="step_retrying"?"var(--ds-amber-700)":e==="step_completed"||e==="run_completed"||e==="workflow_completed"||e==="hook_disposed"||e==="wait_completed"?"var(--ds-green-700)":e==="step_started"||e==="run_started"||e==="workflow_started"||e==="hook_received"?"var(--ds-blue-700)":"var(--ds-gray-600)"}function uc(e,t){var s;const r=new Map;if(e)for(const a of e){const i=nr(String(a.stepName));r.set(a.stepId,(i==null?void 0:i.shortName)??a.stepName)}const o=t!=null&&t.workflowName?((s=bt(t.workflowName))==null?void 0:s.shortName)??t.workflowName:null;return{correlationNameMap:r,workflowName:o}}function fc(e){const t=new Map,r=new Map,o=new Map;for(const s of e){const a=new Date(s.createdAt).getTime(),i=s.correlationId??"__run__",l=s.eventType;if((l==="step_created"||l==="run_created")&&t.set(i,a),l==="step_started"||l==="run_started"||l==="workflow_started"){r.set(i,a),t.has(i)||t.set(i,a);const d=t.get(i),c=o.get(i)??{};d!==void 0&&(c.queued=a-d),o.set(i,c)}if(l==="step_completed"||l==="step_failed"||l==="run_completed"||l==="run_failed"||l==="run_cancelled"||l==="workflow_completed"||l==="workflow_failed"||l==="wait_completed"||l==="hook_disposed"){const d=r.get(i),c=o.get(i)??{};d!==void 0&&(c.ran=a-d),o.set(i,c)}}return o}function vn(e){return e==="run_created"||e==="run_started"||e==="run_completed"||e==="run_failed"||e==="run_cancelled"||e==="workflow_started"||e==="workflow_completed"||e==="workflow_failed"}const yn=36,mc=20,Qr="var(--ds-gray-500)";function uo({isFirst:e,isLast:t,isRunLevel:r,statusDotColor:o,pulse:s=!1,hasSelection:a,showBranch:i,showLaneLine:l,isLaneStart:d,isLaneEnd:c,continuationOnly:u=!1}){const f=r?8:6,p=r?5:6,g=a&&!i&&!r?.3:1;return n.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:yn,minHeight:u?0:void 0},children:[n.jsx("div",{style:{position:"absolute",left:8,top:u?0:e?"50%":0,bottom:u?0:t?"50%":0,width:2,backgroundColor:Qr,zIndex:0}}),!u&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{position:"absolute",left:p,top:"50%",transform:"translateY(-50%)",width:f,height:f,zIndex:2},children:[n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:"var(--ds-background-100)",zIndex:0}}),s&&n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:o,opacity:.75*g,animation:Hs,zIndex:1}}),n.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:o,opacity:g,transition:"opacity 150ms",zIndex:2}})]}),i&&n.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:yn-9,height:2,backgroundColor:Qr,zIndex:0}})]}),l&&n.jsx("div",{style:{position:"absolute",left:mc,top:u?0:d?"50%":0,bottom:u?0:c?"50%":0,width:2,backgroundColor:Qr,zIndex:0}})]})}function fo({value:e,className:t}){const[r,o]=m.useState(!1),s=m.useRef(null);m.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const a=m.useCallback(i=>{i.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{o(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(!1),s.current=null},1500)})},[e]);return n.jsxs("div",{className:`group/copy flex items-center gap-1 flex-1 min-w-0 px-4 ${t??""}`,children:[n.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:e||"-"}),e?n.jsx("button",{type:"button",onClick:a,className:"flex-shrink-0 opacity-0 group-hover/copy:opacity-100 transition-opacity p-0.5 rounded hover:bg-[var(--ds-gray-alpha-200)]",style:Ln,"aria-label":`Copy ${e}`,children:r?n.jsx(Go,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):n.jsx(rr,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function yr(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return yr(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(yr);if(e!==null&&typeof e=="object"){const t={};for(const[r,o]of Object.entries(e))t[r]=yr(o);return t}return e}function pc(e,t){if(!t||!ic.has(t)||e==null||typeof e!="object")return null;const r=e;return tr(r.error)?r.error:tr(r)?r:null}function hc({data:e,eventType:t}){const r=m.useMemo(()=>pc(e,t),[e,t]),[o,s]=m.useState(!1),a=m.useRef(null),i=m.useMemo(()=>yr(e),[e]);m.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const l=m.useMemo(()=>{try{return JSON.stringify(i,null,2)}catch{return String(i)}},[i]),d=m.useCallback(c=>{c.stopPropagation(),navigator.clipboard.writeText(l).then(()=>{s(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{s(!1),a.current=null},1500)})},[l]);return r?n.jsx("div",{className:"p-2",children:n.jsx(Ar,{value:r})}):n.jsxs("div",{className:"relative group/payload",children:[n.jsx("div",{className:"overflow-x-auto p-2 text-[11px]",style:{color:"var(--ds-gray-1000)"},children:n.jsx(Ir,{data:i,expandLevel:2})}),n.jsx("button",{type:"button",onClick:d,className:"absolute bottom-2 right-2 opacity-0 group-hover/payload:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-md text-xs hover:bg-[var(--ds-gray-alpha-200)]",style:{...Ln,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:o?n.jsxs(n.Fragment,{children:[n.jsx(Go,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}),n.jsx("span",{style:{color:"var(--ds-green-700)"},children:"Copied"})]}):n.jsxs(n.Fragment,{children:[n.jsx(rr,{className:"h-3 w-3"}),n.jsx("span",{children:"Copy"})]})})]})}function gc({event:e,index:t,isFirst:r,isLast:o,activeGroupKey:s,selectedGroupKey:a,selectedGroupRange:i,correlationNameMap:l,workflowName:d,durationMap:c,onSelectGroup:u,onHoverGroup:f,onLoadEventData:p}){const[g,v]=m.useState(!1),[y,N]=m.useState(!1),[x,h]=m.useState(null),[w,j]=m.useState(null),[k,b]=m.useState(!1),I=e.correlationId??(vn(e.eventType)?"__run__":void 0);m.useEffect(()=>{a!==void 0&&a!==I&&v(!1)},[a,I]);const S=dc(e.eventType),C=new Date(e.createdAt),R="eventData"in e&&e.eventData!=null,D=vn(e.eventType),B=D?d??"-":e.correlationId?l.get(e.correlationId)??"-":"-",E=e.correlationId??(D?"__run__":""),T=E?c.get(E):void 0,_=s!==void 0,O=I!==void 0&&I===s,$=_&&!O,z=_&&O,V=_&&O&&!D,P=i!==null&&t>=i.first&&t<=i.last,M=i!==null&&t===i.first,H=i!==null&&t===i.last,J=m.useCallback(async()=>{if(!(x!==null||R)){N(!0),j(null);try{if(!p){j("Event details unavailable");return}const A=await p(e);A!=null&&h(A)}catch(A){j(A instanceof Error?A.message:"Failed to load event details")}finally{N(!1),b(!0)}}},[e,x,R,p]),se=m.useCallback(A=>{A.stopPropagation();const W=!g;v(W),W&&x===null&&!R&&J()},[g,x,R,J]),X=m.useCallback(()=>{u(a===I?void 0:I)},[a,I,u]),G=R?e.eventData:x,Z=$?.3:1;return n.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>f(I),onMouseLeave:()=>f(void 0),children:[n.jsxs("div",{role:"button",tabIndex:0,onClick:X,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&X()},className:"w-full text-left flex items-center gap-0 text-sm hover:bg-[var(--ds-gray-alpha-100)] transition-colors cursor-pointer",style:{minHeight:40},children:[n.jsx(uo,{isFirst:r,isLast:o&&!g,isRunLevel:D,statusDotColor:S,pulse:z,hasSelection:_,showBranch:V,showLaneLine:P,isLaneStart:M,isLaneEnd:H}),n.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:Z,transition:"opacity 150ms"},children:[n.jsx("button",{type:"button",onClick:se,className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded hover:bg-[var(--ds-gray-alpha-200)] transition-colors",style:{...Ln,border:"1px solid var(--ds-gray-alpha-400)"},"aria-label":g?"Collapse details":"Expand details",children:n.jsx(Uo,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-700)",transform:g?"rotate(90deg)":"rotate(0deg)"}})}),n.jsx("div",{className:"text-xs tabular-nums flex-1 min-w-0 px-4",style:{color:"var(--ds-gray-900)"},children:lc(C)}),n.jsx("div",{className:"text-xs font-medium flex-1 min-w-0 px-4",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--ds-gray-900)"},children:[n.jsxs("span",{style:{position:"relative",display:"inline-flex",width:6,height:6,flexShrink:0},children:[z&&n.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:S,opacity:.75,animation:Hs}}),n.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:S}})]}),cc(e.eventType)]})}),n.jsx("div",{className:"text-xs flex-1 min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",title:B!=="-"?B:void 0,children:B}),n.jsx(fo,{value:e.correlationId||"",className:"font-mono text-xs"}),n.jsx(fo,{value:e.eventId,className:"font-mono text-xs"})]})]}),g&&n.jsxs("div",{className:"flex",children:[n.jsx(uo,{isFirst:!1,isLast:o,isRunLevel:D,hasSelection:_,showBranch:!1,showLaneLine:P&&!H,isLaneStart:!1,isLaneEnd:!1,continuationOnly:!0}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsxs("div",{className:"flex-1 my-1.5 mr-3 ml-2 py-2 rounded-md border overflow-hidden",style:{borderColor:"var(--ds-gray-alpha-200)",opacity:Z,transition:"opacity 150ms"},children:[((T==null?void 0:T.queued)!==void 0||(T==null?void 0:T.ran)!==void 0)&&n.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[T.queued!==void 0&&T.queued>0&&n.jsxs("span",{children:["Queued for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(T.queued)})]}),T.ran!==void 0&&n.jsxs("span",{children:["Ran for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(T.ran)})]})]}),G!=null?n.jsx(hc,{data:G,eventType:e.eventType}):w?n.jsx("div",{className:"rounded-md border p-3 text-xs",style:{borderColor:"var(--ds-red-400)",backgroundColor:"var(--ds-red-100)",color:"var(--ds-red-900)"},children:w}):y||!R&&!k&&e.correlationId?n.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[n.jsx(Re,{className:"h-3",style:{width:"75%"}}),n.jsx(Re,{className:"h-3",style:{width:"50%"}}),n.jsx(Re,{className:"h-3",style:{width:"60%"}})]}):n.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function xc({events:e,steps:t,run:r,onLoadEventData:o,hasMoreEvents:s=!1,isLoadingMoreEvents:a=!1,onLoadMoreEvents:i}){const l=m.useMemo(()=>!e||e.length===0?[]:[...e].sort((I,S)=>new Date(I.createdAt).getTime()-new Date(S.createdAt).getTime()),[e]),{correlationNameMap:d,workflowName:c}=m.useMemo(()=>uc(t??null,r??null),[t,r]),u=m.useMemo(()=>fc(l),[l]),[f,p]=m.useState(void 0),[g,v]=m.useState(void 0),y=m.useCallback(I=>{p(I)},[]),N=m.useCallback(I=>{v(I)},[]),x=f??g,h=m.useMemo(()=>{if(!x||x==="__run__")return null;let I=-1,S=-1;for(let C=0;C<l.length;C++)l[C].correlationId===x&&(I===-1&&(I=C),S=C);return I>=0?{first:I,last:S}:null},[x,l]),[w,j]=m.useState(""),k=m.useRef(null),b=m.useMemo(()=>{const I=[];for(let S=0;S<l.length;S++){const C=l[S];I.push({text:[C.eventId,C.correlationId??""].join(" ").toLowerCase(),groupKey:C.correlationId??(vn(C.eventType)?"__run__":void 0),eventId:C.eventId,index:S})}return I},[l]);return m.useEffect(()=>{var C;const I=w.trim().toLowerCase();if(!I){p(void 0);return}const S=b.find(R=>R.text.includes(I));S&&(p(S.groupKey),(C=k.current)==null||C.scrollToIndex({index:S.index,align:"center",behavior:"smooth"}))},[w,b]),!e||e.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--ds-gray-700)"},children:"No events found"}):n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[n.jsx("style",{children:"@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}"}),n.jsx("div",{style:{padding:6,backgroundColor:"var(--ds-background-100)"},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,boxShadow:"0 0 0 1px var(--ds-gray-alpha-400)",background:"var(--ds-background-100)",height:40},children:[n.jsx("div",{style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ds-gray-800)",flexShrink:0},children:n.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),n.jsx("input",{type:"search",placeholder:"Search by event ID or correlation ID…",value:w,onChange:I=>j(I.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]})}),n.jsxs("div",{className:"flex items-center gap-0 text-sm font-medium h-10 border-b flex-shrink-0",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx("div",{className:"flex-shrink-0",style:{width:yn}}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Time"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event Type"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Name"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Correlation ID"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event ID"})]}),n.jsx(Ul,{ref:k,totalCount:l.length,overscan:20,defaultItemHeight:40,endReached:()=>{!s||a||i==null||i()},itemContent:I=>n.jsx(gc,{event:l[I],index:I,isFirst:I===0,isLast:I===l.length-1,activeGroupKey:x,selectedGroupKey:f,selectedGroupRange:h,correlationNameMap:d,workflowName:c,durationMap:u,onSelectGroup:y,onHoverGroup:N,onLoadEventData:o}),components:{Footer:()=>n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"px-3 pt-3 flex justify-center",children:n.jsx("button",{type:"button",onClick:()=>void(i==null?void 0:i()),disabled:a,className:"h-8 px-3 text-xs rounded-md border transition-colors disabled:opacity-60 disabled:cursor-not-allowed",style:{borderColor:"var(--ds-gray-alpha-400)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:a?"Loading more events...":"Load more"})}),n.jsxs("div",{className:"mt-4 pt-3 border-t text-xs px-3",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)"},children:[l.length," event",l.length!==1?"s":""," total"]})]})},style:{flex:1,minHeight:0}})]})}function vc({messages:e}){return e.length===0?n.jsx("div",{className:"text-center py-8 text-[11px]",style:{color:"var(--ds-gray-600)"},children:"No messages"}):n.jsx("div",{className:"flex flex-col gap-3 p-3",children:e.map((t,r)=>n.jsx(yc,{message:t},r))})}function yc({message:e}){const t=e.role,r=Ic(e.content),o=wc(t);return n.jsxs("div",{className:"rounded-md border text-[11px]",style:{backgroundColor:o.bg,borderColor:o.border},children:[n.jsx("div",{className:"px-2.5 py-1 border-b text-[10px] font-medium uppercase tracking-wide",style:{borderColor:o.border,color:o.label},children:t}),n.jsx("div",{className:"px-2.5 py-2 space-y-2",children:r.map((s,a)=>n.jsx(bc,{part:s,role:t},a))})]})}function bc({part:e,role:t}){return e.type==="text"?e.text?t==="assistant"?n.jsx("div",{className:"prose prose-sm max-w-none text-[11px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",style:{color:"var(--ds-gray-1000)"},children:n.jsx(ci,{children:e.text})}):n.jsx("div",{className:"whitespace-pre-wrap break-words",style:{color:"var(--ds-gray-1000)"},children:e.text}):null:e.type==="tool-call"?n.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-purple-100)",borderColor:"var(--ds-purple-300)"},children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[n.jsx("span",{children:"🔧"}),n.jsx("span",{style:{color:"var(--ds-purple-900)"},children:e.toolName})]}),e.input!=null&&n.jsx("div",{className:"mt-1.5 overflow-x-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.input=="string"?n.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.input}):n.jsx(Ir,{data:e.input})})]}):e.type==="tool-result"?n.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-green-100)",borderColor:"var(--ds-green-300)"},children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[n.jsx("span",{children:"✓"}),n.jsxs("span",{style:{color:"var(--ds-green-900)"},children:[e.toolName," result"]})]}),e.output!=null&&n.jsx("div",{className:"mt-1.5 overflow-x-auto max-h-[200px] overflow-y-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.output=="string"?n.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.output}):n.jsx(Ir,{data:e.output,expandLevel:1})})]}):null}function wc(e){switch(e){case"user":return{bg:"var(--ds-blue-100)",border:"var(--ds-blue-300)",label:"var(--ds-blue-700)"};case"assistant":return{bg:"var(--ds-gray-100)",border:"var(--ds-gray-300)",label:"var(--ds-gray-700)"};case"system":return{bg:"var(--ds-amber-100)",border:"var(--ds-amber-300)",label:"var(--ds-amber-700)"};case"tool":return{bg:"var(--ds-green-50)",border:"var(--ds-green-300)",label:"var(--ds-green-700)"};default:return{bg:"var(--ds-gray-100)",border:"var(--ds-gray-300)",label:"var(--ds-gray-700)"}}}function Ic(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.map(t=>typeof t=="string"?{type:"text",text:t}:(t==null?void 0:t.type)==="text"?{type:"text",text:String(t.text??"")}:(t==null?void 0:t.type)==="tool-call"?{type:"tool-call",toolName:t.toolName,input:t.input}:(t==null?void 0:t.type)==="tool-result"?{type:"tool-result",toolName:t.toolName,output:t.output}:{type:"text",text:""}):[]}const Nc=e=>{if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||e===null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}};function Os({data:e}){return n.jsxs("div",{className:"relative overflow-x-auto rounded-md border p-3 pt-9",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("button",{type:"button","aria-label":"Copy data",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border !bg-[var(--ds-background-100)] !text-[var(--ds-gray-800)] transition-transform transition-colors duration-100 hover:!bg-[var(--ds-gray-alpha-200)] active:!scale-95 active:!bg-[var(--ds-gray-alpha-300)]",style:{borderColor:"var(--ds-gray-300)"},onClick:()=>{navigator.clipboard.writeText(Nc(e)).then(()=>{me.success("Copied to clipboard")}).catch(()=>{me.error("Failed to copy")})},children:n.jsx(rr,{size:12})}),n.jsx(Ir,{data:e})]})}function Pe({summary:e,children:t,onToggle:r,disabled:o=!1,summaryClassName:s,contentClassName:a}){return o?n.jsx("div",{className:`rounded-md border px-2.5 py-1.5 text-xs ${s??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)",cursor:"not-allowed",opacity:.8},children:e}):n.jsxs("details",{className:"group",onToggle:i=>r==null?void 0:r(i.target.open),children:[n.jsx("summary",{className:`cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 ${s??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)"},children:e}),n.jsxs("div",{className:`relative pl-6 mt-3 ${a??""}`,children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3",style:{backgroundColor:"var(--ds-gray-400)"}}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg",style:{borderColor:"var(--ds-gray-400)"}}),n.jsx("div",{className:"absolute left-6 top-3 w-0 h-px -translate-y-px",style:{backgroundColor:"var(--ds-gray-400)"}}),n.jsx("div",{children:t})]})]})}function jc({active:e,onClick:t,children:r}){return n.jsx("button",{type:"button",role:"tab","aria-selected":e,tabIndex:e?0:-1,onClick:t,className:"px-3 py-1.5 text-[11px] font-medium transition-colors -mb-px",style:{backgroundColor:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:`2px solid ${e?"var(--ds-blue-600)":"transparent"}`,borderRadius:0,outline:"none",boxShadow:"none",cursor:"pointer",color:e?"var(--ds-gray-1000)":"var(--ds-gray-600)"},children:r})}function kc({tabs:e,activeTab:t,onTabChange:r,ariaLabel:o,children:s}){const a=m.useCallback(i=>{if(i.key!=="ArrowRight"&&i.key!=="ArrowLeft")return;i.preventDefault();const l=e.findIndex(c=>c.id===t),d=i.key==="ArrowRight"?(l+1)%e.length:(l-1+e.length)%e.length;r(e[d].id)},[e,t,r]);return n.jsxs("div",{className:"rounded-md border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:[n.jsx("div",{className:"flex gap-1 border-b",role:"tablist","aria-label":o,onKeyDown:a,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:e.map(i=>n.jsx(jc,{active:t===i.id,onClick:()=>r(i.id),children:i.label},i.id))}),n.jsx("div",{role:"tabpanel",children:s})]})}const Sc=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function Cc({conversation:e,args:t}){const[r,o]=m.useState("conversation");return n.jsx(Pe,{summary:`Input (${e.length} messages)`,children:n.jsx(kc,{tabs:Sc,activeTab:r,onTabChange:o,ariaLabel:"Conversation view",children:r==="conversation"?n.jsx(vc,{messages:e}):n.jsx("div",{className:"p-3",children:Array.isArray(t)?t.map((s,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:ze(s)},a)):ze(t)})})})}function ze(e){return n.jsx(Os,{data:e})}const ht=e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0,mo=["workflowName","moduleSpecifier","stepName","status","stepId","hookId","eventId","runId","attempt","token","correlationId","eventType","deploymentId","specVersion","workflowCoreVersion","ownerId","projectId","environment","executionContext","createdAt","startedAt","updatedAt","completedAt","expiredAt","retryAfter","error","metadata","eventData","input","output","resumeAt"],po=(e,t)=>{const r=mo.indexOf(e)||0,o=mo.indexOf(t)||0;return r-o},Tc={workflowCoreVersion:"@workflow/core version"},Ec=e=>Tc[e]??e,Ac=e=>{const t=String(e),r=nr(t);if(r)return r.moduleSpecifier;const o=bt(t);return o?o.moduleSpecifier:t},gt=e=>{let t;return e instanceof Date?t=e:typeof e=="number"?t=new Date(e):typeof e=="string"?t=new Date(e):t=new Date(String(e)),t.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3})},Ut={workflowName:e=>{var t;return((t=bt(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>Ac(e),stepName:e=>{var t;return((t=nr(String(e)))==null?void 0:t.shortName)??"?"},runId:e=>String(e),stepId:e=>String(e),hookId:e=>String(e),eventId:e=>String(e),status:e=>String(e),attempt:e=>String(e),token:e=>String(e),eventType:e=>String(e),correlationId:e=>String(e),deploymentId:e=>String(e),specVersion:e=>String(e),workflowCoreVersion:e=>String(e),ownerId:e=>null,projectId:e=>null,environment:e=>null,executionContext:e=>null,createdAt:gt,startedAt:gt,updatedAt:gt,completedAt:gt,expiredAt:gt,retryAfter:gt,resumeAt:gt,metadata:e=>ht(e)?ze(e):null,input:(e,t)=>{if(e&&typeof e=="object"&&"args"in e){const{args:s,closureVars:a,thisVal:i}=e,l=Array.isArray(s)?s.length:0,d=l===1?"argument":"arguments",c=ht(a),u=ht(i),f=ht(s);if(t!=null&&t.stepName&&ui(t.stepName)){const p=fi(s);if(p&&p.length>0)return n.jsxs(n.Fragment,{children:[n.jsx(Cc,{conversation:p,args:s}),c&&n.jsx(Pe,{summary:"Closure Variables",children:ze(a)}),u&&n.jsx(Pe,{summary:"This Value",children:ze(i)})]})}return!f&&!c&&!u?n.jsx(Pe,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):n.jsxs(n.Fragment,{children:[n.jsx(Pe,{summary:`Input (${l} ${d})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(s)?s.map((p,g)=>n.jsx("div",{className:"mt-2 first:mt-0",children:ze(p)},g)):ze(s)}),c&&n.jsx(Pe,{summary:"Closure Variables",children:ze(a)}),u&&n.jsx(Pe,{summary:"this",children:ze(i)})]})}const r=Array.isArray(e)?e.length:0,o=r===1?"argument":"arguments";return ht(e)?n.jsx(Pe,{summary:`Input (${r} ${o})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(e)?e.map((s,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:ze(s)},a)):ze(e)}):n.jsx(Pe,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>ht(e)?n.jsx(Pe,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:ze(e)}):null,error:e=>ht(e)?tr(e)?n.jsx(Pe,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:n.jsx(Ar,{value:e})}):n.jsx(Pe,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:ze(e)}):null,eventData:e=>ht(e)?n.jsx(Pe,{summary:"Event Data",children:ze(e)}):null},ho=["input","output","error","metadata","eventData"],Rc=()=>n.jsx("div",{className:"text-copy-12 rounded-md border p-4 my-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:n.jsx("span",{children:"The data for this run has expired and is no longer available."})}),Dc=({attribute:e,value:t,isLoading:r,inline:o=!1,context:s})=>{if(r&&(e==="input"||e==="output"||e==="eventData")){const d=e==="eventData"?"Event Data":e==="output"?"Output":"Input";return n.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"?"gap-2 my-3.5":"gap-0"}`,children:[n.jsx("span",{className:`${e==="input"||e==="output"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),n.jsx(Pe,{summary:d,summaryClassName:"text-base py-2",disabled:!0}),n.jsxs("div",{className:"overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx(Re,{className:"h-4 w-[38%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[88%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[72%]"})]})]})}const i=Ut[e];if(!i)return null;const l=i(t,s);return l?o?n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:e}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--ds-gray-1000)"},children:l})]}):n.jsxs("div",{className:"relative",children:[typeof r=="boolean"&&r&&n.jsx("div",{className:"absolute top-9 right-4",children:n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2",style:{borderColor:"var(--ds-gray-900)"}})}),n.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"||e==="error"?"gap-2 my-3.5":"gap-0"}`,children:[n.jsx("span",{className:`${e==="input"||e==="output"||e==="error"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),n.jsx("span",{className:"text-xs",style:{color:"var(--ds-gray-1000)"},children:l})]},e)]}):null},Mc=({data:e,moduleSpecifier:t,isLoading:r,error:o,expiredAt:s,onStreamClick:a})=>{const i=m.useMemo(()=>{const v={...e},y=e.executionContext;return y!=null&&y.workflowCoreVersion&&(v.workflowCoreVersion=y.workflowCoreVersion),t?v.moduleSpecifier=t:typeof e.stepName=="string"?v.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(v.moduleSpecifier=e.workflowName),v},[e,t]),l=s!=null&&new Date(s)<new Date,d=Object.keys(i).filter(v=>!ho.includes(v)).sort(po),c=Object.keys(i).filter(v=>ho.includes(v)).sort(po),u=d.filter(v=>{const y=Ut[v];return y?y(i[v])!==null:!1}),f=m.useMemo(()=>{const v=[...u],y=v.indexOf("moduleSpecifier");if(y===-1)return v;v.splice(y,1);const N=v.indexOf("workflowName");if(N!==-1)return v.splice(N+1,0,"moduleSpecifier"),v;const x=v.indexOf("stepName");return x!==-1?(v.splice(x+1,0,"moduleSpecifier"),v):(v.unshift("moduleSpecifier"),v)},[u]),p=m.useMemo(()=>({stepName:i.stepName}),[i.stepName]),g=m.useCallback(v=>{navigator.clipboard.writeText(v).then(()=>{me.success("moduleSpecifier copied")}).catch(()=>{me.error("Failed to copy moduleSpecifier")})},[]);return n.jsx(di.Provider,{value:a,children:n.jsxs("div",{children:[u.length>0&&n.jsx("div",{className:"mb-3 flex flex-col overflow-hidden rounded-lg border",style:{borderColor:"var(--ds-gray-300)"},children:f.map((v,y)=>{var j;const N=(j=Ut[v])==null?void 0:j.call(Ut,i[v]),x=v==="moduleSpecifier",h=typeof N=="string"?N:String(N??i.moduleSpecifier??""),w=y<f.length-1;return n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 rounded-sm px-2.5 py-1",children:[n.jsx("span",{className:"text-[14px] first-letter:uppercase",style:{color:"var(--ds-gray-700)"},children:Ec(v)}),x?n.jsx("button",{type:"button",className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)",background:"transparent",border:"none",padding:0},title:h,onClick:()=>g(h),children:h}):n.jsx("span",{className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},children:N})]}),w?n.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},v)})}),o?n.jsx(Ta,{title:"Failed to load resource details",details:o.message,className:"my-4"}):l?n.jsx(Rc,{}):c.map(v=>n.jsx(Dc,{isLoading:r,attribute:v,value:i[v],context:p},v))]})})},Lc=new Set(["step_failed","step_retrying"]),_c=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function Hc({event:e,onLoadEventData:t}){const[r,o]=m.useState(null),[s,a]=m.useState(!1),[i,l]=m.useState(null),d="eventData"in e&&e.eventData!=null?e.eventData:null,c=d??r,u=_c.has(e.eventType),f=m.useCallback(async()=>{if(!(d||r!==null||s)&&!(!t||!e.correlationId||!e.eventId))try{a(!0),l(null);const g=await t(e.correlationId,e.eventId);o(g)}catch(g){l(g instanceof Error?g.message:String(g))}finally{a(!1)}},[d,r,s,t,e.correlationId,e.eventId]),p=new Date(e.createdAt);return n.jsxs(Pe,{summaryClassName:"text-base py-2",summary:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",style:{color:"var(--ds-gray-1000)"},children:e.eventType})," ","-"," ",n.jsx("span",{style:{color:"var(--ds-gray-700)"},children:gt(p.getTime())})]}),onToggle:u?g=>{g&&f()}:void 0,children:[n.jsxs("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"eventId"}),n.jsx("span",{className:"max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},title:e.eventId,children:e.eventId})]}),e.correlationId&&n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"correlationId"}),n.jsx("span",{className:"max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},title:e.correlationId,children:e.correlationId})]})]}),s&&n.jsxs("div",{className:"mt-2 rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx(Re,{className:"h-4 w-[35%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[90%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[75%]"})]}),i&&n.jsx("div",{className:"mt-2 rounded-md border p-2 text-sm",style:{borderColor:"var(--ds-red-300)",color:"var(--ds-red-700)"},children:i}),c!=null&&n.jsx("div",{className:"mt-2",children:n.jsx(Oc,{eventType:e.eventType,data:c})})]})}function Oc({eventType:e,data:t}){if(Lc.has(e)&&t!=null&&typeof t=="object"){const r=t;if(tr(r.error))return n.jsx(Ar,{value:r.error});if(tr(r))return n.jsx(Ar,{value:r})}return n.jsx(Os,{data:t})}function Fc({events:e,isLoading:t=!1,error:r,onLoadEventData:o}){const s=m.useMemo(()=>[...e].sort((a,i)=>new Date(a.createdAt).getTime()-new Date(i.createdAt).getTime()),[e]);return n.jsxs("div",{className:"mt-2",style:{color:"var(--ds-gray-1000)"},children:[n.jsxs("h3",{className:"text-heading-16 font-medium mt-4 mb-2",style:{color:"var(--ds-gray-1000)"},children:["Events ",!t&&`(${s.length})`]}),t?n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(Re,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(Re,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(Re,{className:"h-[48px] w-full rounded-lg border"})]}):null,!t&&!r&&s.length===0&&n.jsx("div",{className:"text-sm",children:"No events found"}),s.length>0&&!r?n.jsx("div",{className:"flex flex-col gap-4",children:s.map(a=>n.jsx(Hc,{event:a,onLoadEventData:o},a.eventId))}):null]})}function Pc(e){return e!==null&&typeof e=="object"&&"stepId"in e}function Bc(e){return e!==null&&typeof e=="object"&&"runId"in e}function pr(e){return e!==null&&typeof e=="object"&&"hookId"in e}function zc({run:e,hooks:t,onStreamClick:r,spanDetailData:o,spanDetailError:s,spanDetailLoading:a,onSpanSelect:i,onWakeUpSleep:l,onLoadEventData:d,onResolveHook:c,selectedSpan:u}){const[f,p]=m.useState(!1),[g,v]=m.useState(!1),[y,N]=m.useState(!1),[x,h]=m.useState(new Set),w=u==null?void 0:u.data,j=u==null?void 0:u.rawEvents,k=(j==null?void 0:j.length)??0,{resource:b,resourceId:I,runId:S}=m.useMemo(()=>{if(!u)return{resource:void 0,resourceId:void 0,runId:void 0};const M=u.resource;return M==="step"&&Pc(w)?{resource:"step",resourceId:w.stepId,runId:w.runId}:M==="run"&&Bc(w)?{resource:"run",resourceId:w.runId,runId:void 0}:M==="hook"&&pr(w)?{resource:"hook",resourceId:w.hookId,runId:void 0}:M==="sleep"?{resource:"sleep",resourceId:u.spanId,runId:void 0}:{resource:void 0,resourceId:void 0,runId:void 0}},[u,w]);m.useEffect(()=>{b&&I&&["run","step","hook","sleep"].includes(b)&&i({resource:b,resourceId:I,runId:S})},[b,I,S,i]);const C=m.useMemo(()=>b!=="sleep"||!j||["completed","failed","cancelled"].includes(e.status)||!j.some(se=>se.eventType==="wait_created")?!1:!j.some(se=>se.eventType==="wait_completed"),[b,j,k,e.status]),R=m.useMemo(()=>!(b!=="hook"||!j||!I||x.has(I)||["completed","failed","cancelled"].includes(e.status)||j.some(J=>J.eventType==="hook_disposed")),[b,I,j,k,e.status,x]),D=s??void 0,B=a??!1,E=m.useMemo(()=>{if(b!=="hook"||!I)return;if(pr(o)&&o.token)return o.token;const M=t==null?void 0:t.find(H=>H.hookId===I);if(M!=null&&M.token)return M.token;if(pr(w)&&w.token)return w.token},[b,I,o,w,t]);m.useEffect(()=>{D&&u&&b&&me.error(`Failed to load ${b} details`,{description:D.message})},[D,b,u]);const T=async()=>{if(!(f||!I)){if(!l){me.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{p(!0),(await l(e.runId,I)).stoppedCount>0?me.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):me.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(M){console.error("Failed to wake up run:",M),me.error("Failed to wake up run",{description:M instanceof Error?M.message:"An unknown error occurred"})}finally{p(!1)}}},_=m.useCallback(async M=>{if(!y){if(!c){me.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!E){me.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{N(!0);const H=o??w,J=pr(H)?H:void 0;await c(E,M,J),me.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),v(!1),I&&h(se=>new Set(se).add(I))}catch(H){console.error("Failed to resolve hook:",H),me.error("Failed to resolve hook",{description:H instanceof Error?H.message:"An unknown error occurred"})}finally{N(!1)}}},[c,E,y,o,w]);if(!u||!b||!I)return null;const O=b==="sleep"?w:o??w,$=m.useMemo(()=>{const M=O,H=M.stepName,J=M.workflowName;if(typeof H=="string")return H;if(typeof J=="string")return J;if(typeof e.workflowName=="string")return e.workflowName},[O,e.workflowName]),z=b.charAt(0).toUpperCase()+b.slice(1),V=b==="sleep"&&C||b==="hook"&&R,P=e.completedAt?"Completed":"Live";return n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx("div",{className:"border-b px-3 py-3",style:{borderColor:"var(--ds-gray-200)"},children:n.jsx("div",{className:"flex items-start justify-between gap-2",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-[13px] font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:z}),n.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:P})]}),n.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:I,children:I})]})})}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[V&&n.jsxs("div",{className:"mb-4 rounded-lg border p-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[n.jsx("p",{className:"mb-2 px-1 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Actions"}),n.jsxs("div",{className:"flex flex-col gap-2",children:[b==="sleep"&&C&&n.jsxs("button",{type:"button",onClick:T,disabled:f,className:Rt("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium","disabled:opacity-50 disabled:cursor-not-allowed transition-colors",f?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[n.jsx(Ea,{className:"h-4 w-4"}),f?"Waking up...":"Wake Up Sleep"]}),b==="hook"&&R&&n.jsxs("button",{type:"button",onClick:()=>v(!0),disabled:y,className:Rt("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium","disabled:opacity-50 disabled:cursor-not-allowed transition-colors",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-gray-1000)",color:"var(--ds-background-100)"},children:[n.jsx(Ko,{className:"h-4 w-4"}),"Resolve Hook"]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("section",{children:[n.jsx("h3",{className:"mb-2 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Details"}),n.jsx(Mc,{data:O,moduleSpecifier:$,expiredAt:e.expiredAt,isLoading:B,error:D??void 0,onStreamClick:r})]}),b!=="run"&&j&&n.jsx("section",{children:n.jsx(Fc,{events:j,onLoadEventData:d})})]})]}),n.jsx(qo,{isOpen:g,onClose:()=>v(!1),onSubmit:_,isSubmitting:y})]})}function Wc(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>{let r=0,o=0;const s=()=>{t.current(r),r=0},a=i=>{if(!i.ctrlKey&&!i.metaKey)return;i.preventDefault();let l=-i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_PAGE:l*=window.innerHeight;break;case WheelEvent.DOM_DELTA_LINE:l*=20;break}r+=l,cancelAnimationFrame(o),o=requestAnimationFrame(s)};return window.addEventListener("wheel",a,{passive:!1}),()=>{window.removeEventListener("wheel",a),cancelAnimationFrame(o)}},[])}function go(e){if(e<=0)return 1;const r=10**Math.floor(Math.log10(e)),o=e/r;return o<=1.5?r:o<=3.5?2*r:o<=7.5?5*r:10*r}function $c({scale:e,isLive:t=!1}){const{state:{root:r}}=it(),[,o]=m.useState(0);m.useEffect(()=>{if(!t)return;const p=setInterval(()=>o(g=>g+1),1e3);return()=>clearInterval(p)},[t]);const s=r.duration,a=e>0?e:s>0?1/s:1;let l=go(50/a);l=Math.max(1,l);let d=l*a;const c=1e3;s/l>c&&(l=go(s/c),d=l*a);const u=Math.ceil(s/l),f=Math.ceil(100/d)||1;return n.jsx("div",{className:ee.markersContainer,children:n.jsx("div",{"aria-hidden":!0,className:ee.markers,style:{width:Math.floor(r.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${d}px`},children:new Array(u).fill(null).map((p,g)=>{const v=g%f===0;return n.jsx("span",{className:Rt(ee.marker,!v&&ee.notch),children:v?n.jsxs("span",{className:ee.markerLabel,children:[mi(l*g),n.jsx("span",{className:ee.markerClockTime,children:pi(r.startTime+l*g)})]}):null},String(g))})})})}function Vc({events:e,root:t,scale:r}){const o=m.useMemo(()=>e.filter(s=>s.event.showVerticalLine!==!1),[e]);return n.jsx("div",{className:ee.eventMarkersContainer,children:n.jsx("div",{"aria-hidden":!0,className:ee.eventMarkers,style:{width:Math.floor(t.duration*r)},children:o.map(s=>n.jsx("span",{className:Rt(ee.eventMarker),style:{left:Math.floor((s.timestamp-t.startTime)*r),...s.event.color&&{borderLeftColor:s.event.color}}},s.key))})})}const xo=2;function Uc({memoCacheRef:e,timelineRef:t,root:r,spans:o,events:s,scale:a,dispatch:i,scrollSnapshotRef:l}){const d=m.useRef(!1),c=m.useRef(o);c.current=o;const u=m.useRef(s);u.current=s;const f=m.useRef(null),{style:p,setStyle:g}=$r(f),v=m.useRef(null),y=m.useRef(null),{style:N,setStyle:x}=$r(y),h=m.useRef(void 0),w=m.useRef(null),{style:j,setStyle:k}=$r(w),b=m.useRef(0);m.useEffect(()=>{const S=t.current;if(!S)return;let C=b.current,R=0,D=!1,B=!1,E=!1,T=!1,_=0,O=0;const $=Date.now()+500,z=()=>{h.current||(h.current=S.getBoundingClientRect())},V=Q=>h.current?(Q-Nr-We)/(Ft+vt):0,P=()=>{const Q=e.current;for(const de of c.current)de.isHovered&&(de.isHovered=!1,Q.set(de.span.spanId,{}));i({type:"forceRender"})};let M=0;const H=()=>{var Ke,q,Ie,ye,ke,fe,Le,Oe;if(!d.current)return;h.current||z();const Q=h.current;if(!Q)return;const{scrollLeft:de,scrollTop:Ne}=S,Ae=Math.max(0,Math.min(C+de-Q.left-We,r.duration*a)),je=`${Ae-de+We}px`;x("left",je),g("left",je);const we=r.startTime+Ae/a,Me=we-r.startTime;if(Me<0||Me>r.duration?(Ke=v.current)==null||Ke.removeAttribute("data-text"):(q=v.current)==null||q.setAttribute("data-text",ur(Me)),D){const Ze=C-R,qe=Math.abs(Ze);if(!E){if(qe<4)return;E=!0,k("display","flex"),P()}Ze>0?(k("left",""),k("right","0")):(k("left","0"),k("right","")),k("width",`${qe}px`);const ct=Math.max(0,Math.min(R+de-Q.left-We,r.duration*a))/a;let pt,St;ct<Me?(pt=ct,St=Me):(pt=Me,St=ct),(Ie=w.current)==null||Ie.setAttribute("data-range",`${ur(pt)} — ${ur(St)}`),(ye=w.current)==null||ye.setAttribute("data-duration",`${ur(St-pt)} selected`)}if(Date.now()<$){M=requestAnimationFrame(H);return}if(de!==_||Ne!==O){_=de,O=Ne,M=requestAnimationFrame(H);return}if(C-Q.left<128?(ke=v.current)==null||ke.setAttribute("data-align","left"):C-Q.left>Q.width-128?(fe=v.current)==null||fe.setAttribute("data-align","right"):(Le=v.current)==null||Le.removeAttribute("data-align"),!E&&!B){const Ze=e.current,qe=V(Ne)-xo,mt=V(Ne+Q.height)+xo;for(const Fe of c.current){const tt=Fe.row>=qe&&Fe.row<=mt&&we>=Fe.startTime&&we<=Fe.endTime;Fe.isHovered!==tt&&(Fe.isHovered=tt,Ze.set(Fe.span.spanId,{}))}const pt=12/a;let St=null,Pn=1/0;for(const Fe of u.current){const tt=Math.abs(Fe.timestamp-we);tt<=pt&&tt<Pn&&(Pn=tt,St=Fe)}for(const Fe of u.current){const tt=Fe===St;if(Fe.isHovered===tt)continue;Fe.isHovered=tt;const Bn=(Oe=Fe.ref)==null?void 0:Oe.current;Bn&&Bn.setAttribute("data-hovered",String(tt))}i({type:"forceRender"})}};M=requestAnimationFrame(H);const J=Q=>{Q.pointerType==="mouse"&&(d.current=!0)},se=()=>{d.current&&(d.current=!1,P())},X=({clientX:Q})=>{C=Q,b.current=C,cancelAnimationFrame(M),M=requestAnimationFrame(H)},G=Q=>{Q.preventDefault()},Z=Q=>{var de;if(Q.button===2)T=!0,Q.preventDefault();else{if(Q.button!==0)return;T=!1}(de=t.current)!=null&&de.contains(Q.target)?(R=C,D=!0):(B=!0,requestAnimationFrame(P))},A=Q=>{if(B=!1,!D||(D=!1,!E))return;if(E=!1,k("display",""),k("left",""),k("right",""),k("width",""),Q.preventDefault(),Q.stopImmediatePropagation(),T){T=!1;return}h.current||z();const de=h.current;if(!de)return;const{scrollLeft:Ne}=S,Ae=Math.max(0,Math.min((R+Ne-de.left-We)/a,r.duration)),je=Math.max(0,Math.min((C+Ne-de.left-We)/a,r.duration));i({type:"scaleToRange",t1:Ae+r.startTime,t2:je+r.startTime})},W=Q=>{D&&Q.key==="Escape"&&(T=!0,A(Q))},oe=()=>{h.current=void 0,I.current=void 0,cancelAnimationFrame(M),M=requestAnimationFrame(H)},ce=()=>{cancelAnimationFrame(M),M=requestAnimationFrame(H)},ie=new ResizeObserver(()=>{h.current=void 0});return ie.observe(S),window.addEventListener("mousemove",X),S.addEventListener("contextmenu",G),window.addEventListener("mousedown",Z),window.addEventListener("mouseup",A),window.addEventListener("blur",A),window.addEventListener("keydown",W,!0),window.addEventListener("scroll",oe),S.addEventListener("scroll",ce),S.addEventListener("pointerenter",J),S.addEventListener("pointerleave",se),()=>{ie.disconnect(),window.removeEventListener("mousemove",X),S.removeEventListener("contextmenu",G),window.removeEventListener("mousedown",Z),window.removeEventListener("mouseup",A),window.removeEventListener("blur",A),window.removeEventListener("keydown",W,!0),window.removeEventListener("scroll",oe),S.removeEventListener("scroll",ce),S.removeEventListener("pointerenter",J),S.removeEventListener("pointerleave",se),cancelAnimationFrame(M),b.current=C,P()}},[i,r,a,x,g,k,e,t,l]);const I=m.useRef(void 0);return Wc(S=>{const C=t.current;if(!C)return;h.current??(h.current=C.getBoundingClientRect());const R=h.current,D=Math.max(0,Math.min(b.current-R.left-We,R.width-2*We));let B=0,E=I.current;(E==null?void 0:E.anchorX)===D?B=E.anchorT:(B=(C.scrollLeft+D)/a,E={anchorT:B,anchorX:D},I.current=E),i({type:"trackpadScale",delta:S/64,anchorT:B,anchorX:D})}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:ee.cursorMarkerStickyParent,children:n.jsx("div",{className:ee.cursorMarkerLabelContainer,ref:f,style:p,children:n.jsx("div",{className:ee.cursorMarkerLabel,ref:v})})}),n.jsx("div",{className:ee.cursorMarkerStickyParent,children:n.jsx("div",{className:ee.cursorMarkerContainer,ref:y,style:N,children:n.jsx("div",{className:ee.cursorMarker,children:n.jsx("div",{className:ee.cursorSelection,ref:w,style:j})})})})]})}function Gc({height:e,width:t,value:r,placeholder:o,onChange:s}){return n.jsxs("label",{className:ee.searchInputLabel,children:[n.jsx("div",{className:ee.searchInputPrefix,children:n.jsx(Kc,{})}),n.jsx("input",{type:"search",value:r,placeholder:o,onChange:s,style:{height:e,width:t}})]})}function Kc(){return n.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function qc(){return n.jsx("nav",{className:ee.searchBar,children:n.jsx(Yc,{})})}function Yc(){const{dispatch:e}=it(),[t,r]=m.useState("");return m.useEffect(()=>{const o=setTimeout(()=>e({type:"setFilter",filter:t}),100);return()=>{clearTimeout(o)}},[e,t]),n.jsx("div",{className:ee.searchInput,children:n.jsx(Gc,{height:Jo,onChange:o=>r(o.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}function Xc({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Zoom In"}),n.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("path",{d:"M11 8v6M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),n.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Zc({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Zoom Out"}),n.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("path",{d:"M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),n.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Jc({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Minus"}),n.jsx("path",{d:"M6 12h12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Qc(){const{dispatch:e}=it(),t=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),r=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),o=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return n.jsxs("div",{className:ee.zoomButtonGroup,children:[n.jsx("button",{"aria-label":"Zoom Out",className:ee.zoomButton,onClick:r,type:"button",children:n.jsx(Zc,{size:18})}),n.jsx("div",{className:ee.divider}),n.jsx("button",{"aria-label":"Reset Zoom",className:ee.zoomButton,onClick:o,type:"button",children:n.jsx(Jc,{size:18})}),n.jsx("div",{className:ee.divider}),n.jsx("button",{"aria-label":"Zoom In",className:ee.zoomButton,onClick:t,type:"button",children:n.jsx(Xc,{size:18})})]})}const ed=e=>{const{spans:t}=e,r={startTime:0,endTime:0,duration:0,depth:0,children:[]},o={},s=new Map,a=f=>{const p=s.get(f);if(p)return p;const g=s.size+1;return s.set(f,g),g};let i=!1;for(const f of t){const p=Vt(f.startTime),g=Vt(f.endTime),v=Vt(f.duration);g>r.endTime&&(r.endTime=g,r.duration=g-r.startTime),(r.startTime===0||p<r.startTime)&&(r.startTime=p,r.duration=r.endTime-p);const y=f.resource.startsWith("vercel.");y||(i=!0);const N=y&&(f.resource!=="vercel.serverless-runtime"||!("http.method"in f.attributes)),x=N?0:a(f.resource);let h;N&&(h=`▲ ${f.name}`),o[f.spanId]={parent:null,startTime:p,endTime:g,duration:v,span:f,depth:0,label:h,events:td(f),isVercel:N,children:[],resourceIndex:x,activeStartTime:f.activeStartTime?Vt(f.activeStartTime):void 0}}const l=(f,p)=>{let g;p?(g=o[p],g||(g=r)):g=r,f.parent=g,g.children.push(f)},d=f=>{"parent"in f&&(f.depth=f.parent.depth+1);for(const p of f.children)d(p)};let c=1;const u=(f,p)=>{if("parent"in f&&f.span.name===p){let g=f.endTime;const v=b=>b.children.length?b.children.map(v).sort((I,S)=>I.duration-S.duration)[0]||b:b.span.name==="waitUntil"?(g=b.startTime,b.parent):b,y=v(f),N=`instrumentation-hint-${c++}`,x=f.duration*.05,h=f.startTime+x,w=Math.max(h+x,Math.min(g-f.duration*.01,f.endTime-x)),j=w-h,k={parent:y,startTime:h,endTime:w,duration:j,span:{spanId:N,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Vr(h),endTime:Vr(w),duration:Vr(j)},depth:f.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return y.children.push(k),o[N]=k,!0}for(const g of f.children)if(u(g,p))return!0;return!1};for(const f of Object.values(o))l(f,f.span.parentSpanId);if(d(r),!i){for(const f of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(u(r,f))break}return{root:r,map:o}},td=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((r,o)=>({key:`${t}${o}`,timestamp:Vt(r.timestamp),event:r})).sort((r,o)=>r.timestamp-o.timestamp)},vo=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function en(){return[]}const rd=(e,t=!1)=>{const{state:r,dispatch:o}=it(),{root:s,filter:a,scale:i,timelineRef:l,timelineWidth:d,spanMap:c,scrollSnapshotRef:u,selected:f,memoCacheRef:p}=r,g=nd(r.timelineHeight),v=m.useRef(0),[y,N]=m.useState(en),[x,h]=m.useState(en),[w,j]=m.useState(en),[k,b]=m.useState(-1),I=m.useRef(void 0);return m.useEffect(()=>{var S;return(S=I.current)==null?void 0:S.call(I,a)},[a]),m.useEffect(()=>{if(e!=null&&e.length){for(const S of y)for(const C of S){const R=e.includes(C.span.spanId);C.isHighlighted!==R&&(C.isHighlighted=R,p.current.set(C.span.spanId,{}))}o({type:"forceRender"})}},[y,e,o,p]),m.useEffect(()=>{if(!s.startTime)return;const S=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let C=++v.current;const R=B=>{var T;const E=B.data;switch(E.type){case"setRowsResult":{if((E==null?void 0:E.requestId)!==C)return;if(E.isEnd)for(const _ of E.rows)for(const O of _)O.span=((T=c[O.span.spanId])==null?void 0:T.span)??O.span;N(E.rows);break}case"updateHighlight":{if((E==null?void 0:E.requestId)!==C)return;const{matches:_}=E;N(O=>{for(const $ of O)for(const z of $){const V=_.has(z.span.spanId);z.isHighlighted!==V&&(z.isHighlighted=V,p.current.set(z.span.spanId,{}))}return O}),o({type:"forceRender"});break}}};S.addEventListener("message",R);const D={requestId:C,type:"calculateSpanPositions",root:s};return S.postMessage(D),I.current=B=>{const E=B.trim().toLocaleLowerCase();if(!E){N(_=>_.map(O=>O.map($=>($.isHighlighted=void 0,{...$}))));return}C=++v.current;const T={type:"filterSpans",requestId:C,root:s,filter:E};S.postMessage(T)},()=>{S.terminate()}},[s,c,o,p]),m.useEffect(()=>{if(!y.length)return;if(t){const X=[],G=[];for(const Z of y)for(const A of Z)vo(A)&&(X.push(A),A.events&&G.push(...A.events));h(X),j(G),b(i);return}const S=l.current;let C=u.current,R=!1,D=!1,B=0,E=0;const T=Math.max(500,d*.5),_=new Array(y.length).fill(null),O=()=>{D=!0;const X=Math.min(1+E+Math.ceil((C==null?void 0:C.endRow)??Number.POSITIVE_INFINITY),y.length);for(let G=X;G--;){if(_[G])continue;const Z=$(G);if(Math.abs(Z)>E){if(D=!1,Z>0)continue;break}const A=[],W=y[G];if(W){for(const oe of W){if(!vo(oe))continue;const ce=z(oe);B=Math.max(ce,B),A.push({d:ce,span:oe})}_[G]=A}}},$=X=>C?X<C.startRow?X-C.startRow:X>C.endRow?X-C.endRow:0:0,z=X=>{if(!C)return 0;let G=0;X.endTime<C.startTime?G=C.startTime-X.endTime:X.startTime>C.endTime&&(G=X.startTime-C.endTime);const Z=Math.abs($(X.row));return!G&&!Z?0:Math.sqrt((G/i)**2+(Z*Ft+vt)**2)},V=()=>{if(!S)return;const{scrollLeft:X,scrollTop:G}=S,Z=0,A=X/i,W=(G-Nr-We)/(Ft+vt),oe=W+Math.ceil(g/(Ft+vt));C={anchorT:A,anchorX:Z,scrollLeft:X,scrollTop:G,startTime:s.startTime+X/i,endTime:s.startTime+(X+d)/i,startRow:W,endRow:oe,scale:i},u.current=C;for(let ce=_.length;ce--;)_[ce]=null};let P=0;const M=()=>{(R||!C)&&(R=!1,V()),O();const X=[],G=[];for(const Z of _)if(Z)for(const{d:A,span:W}of Z)A>E||(X.push(W),W.events&&G.push(...W.events));E<T&&(!D||E<B)&&(E=Math.min(T,E+100),P=requestAnimationFrame(M)),h(X),j(G),b(i)};M();let H=Date.now();const J=X=>{(X.ctrlKey||X.metaKey)&&(H=Date.now())};S==null||S.addEventListener("wheel",J);const se=()=>{Date.now()-H<=50||(R=!0,cancelAnimationFrame(P),P=requestAnimationFrame(M))};return S==null||S.addEventListener("scroll",se),()=>{cancelAnimationFrame(P),S==null||S.removeEventListener("wheel",J),S==null||S.removeEventListener("scroll",se)}},[y,s,i,u,l,d,g,t]),m.useEffect(()=>{var R;if(!f)return;let S;for(const D of x)if(D.span.spanId===f.span.spanId){S=D;break}const C=(R=S==null?void 0:S.ref)==null?void 0:R.current;if(!(!S||!C))return S.isSelected=!0,C.setAttribute("data-selected",""),()=>{S.isSelected=!1,C.removeAttribute("data-selected")}},[x,f]),{rows:y,spans:x,events:w,scale:k}};function nd(e){const[t,r]=m.useState(e);return m.useEffect(()=>{if(t===e)return;let o=0,s=0;const a=()=>{if(++o<=3){s=requestAnimationFrame(a);return}r(e)};return a(),()=>{cancelAnimationFrame(s)}},[t,e]),t}const yo={traceId:"skeleton",spans:[{parentSpanId:"",spanId:"root",name:"root span",kind:1,resource:"vercel.runtime",startTime:[5e3,0],endTime:[6e3,0],duration:[1e3,0],library:{name:"vercel-site"},status:{code:1},attributes:{"vercel.ownerId":"team_abc"},traceFlags:1,events:[],links:[]}],resources:[{name:"vercel.runtime",attributes:{}}],rootSpanId:"root"};function od({trace:e=yo,className:t="",scrollLock:r=!1,height:o,withPanel:s=!1,highlightedSpans:a,eagerRender:i=!1,isLive:l=!1}){const d=e===yo,{state:c,dispatch:u}=it(),{timelineRef:f,scrollSnapshotRef:p}=c,g=c.memoCacheRef.current,v=((a==null?void 0:a.length)??0)>0,y=m.useRef(!1),N=m.useRef(""),x=m.useRef(null),h=m.useRef({}),w=m.useRef(null);m.useEffect(()=>{const{root:E,map:T}=ed(e),_=!y.current;y.current=!0;const O=Object.keys(T).sort().map($=>{const z=T[$].events,V=(z==null?void 0:z.length)??0,P=V?z==null?void 0:z[0]:void 0,M=V?z==null?void 0:z[V-1]:void 0,H=`${(P==null?void 0:P.event.name)??"none"}@${(P==null?void 0:P.timestamp)??0}|${(M==null?void 0:M.event.name)??"none"}@${(M==null?void 0:M.timestamp)??0}`;return`${$}:${V}:${H}`}).join(",");if(!_&&O===N.current&&x.current){const $=x.current,z=h.current;let V=!1;($.endTime!==E.endTime||$.duration!==E.duration)&&($.endTime=E.endTime,$.duration=E.duration,V=!0);for(const[P,M]of Object.entries(T)){const H=z[P];H&&((H.endTime!==M.endTime||H.duration!==M.duration)&&(H.endTime=M.endTime,H.duration=M.duration,V=!0),Object.assign(H.span,M.span))}if(!V)return;u({type:"forceRender"});return}N.current=O,x.current=E,h.current=T,u({type:_?"setRoot":"updateRoot",root:E,spanMap:T,resources:e.resources||[]})},[u,e]);const{rows:j,spans:k,events:b,scale:I}=rd(a,i),S=m.useRef(null);m.useLayoutEffect(()=>{const E=S.current;if(!E)return;const T=()=>{const O=2*We,$=E.getBoundingClientRect(),z=$.width-O,V=$.height,P=w.current;P&&P.width===z&&P.height===V||(w.current={width:z,height:V},u({type:"setSize",width:z,height:V}))};T();const _=new ResizeObserver(T);return _.observe(E),window.addEventListener("resize",T),()=>{_.disconnect(),window.removeEventListener("resize",T)}},[u]);const C=m.useRef({t:0,x:-1,y:-1,spanId:""}),R=m.useCallback(E=>{const T=C.current,_=Date.now(),{clientX:O,clientY:$}=E,z=Math.sqrt((O-T.x)**2+($-T.y)**2);if(_-T.t<=500&&z<=8){if(E.stopPropagation(),E.preventDefault(),!T.spanId){u({type:"resetScale"});return}u({type:"select",id:T.spanId}),u({type:"scaleToNode",id:T.spanId});return}const V=E.target;if(!V.closest(`.${String(ee.timeline)}`))return;const P=V.closest("[data-span-id]"),M=(P==null?void 0:P.dataset.spanId)||"";C.current={x:O,y:$,t:_,spanId:M},M&&(u({type:"toggleSelection",id:M}),E.stopPropagation())},[u]);m.useLayoutEffect(()=>{const E=f.current;if(!E)return;const T=p.current;T&&(E.scrollLeft=T.anchorT*I-T.anchorX,p.current=void 0)},[p,f,I]),m.useEffect(()=>{var _;const E=(_=c.selected)==null?void 0:_.span.spanId;if(!E)return;const T=setTimeout(()=>{const O=c.timelineRef.current,$=O==null?void 0:O.querySelector(`[data-span-id="${E}"]`);if(!O||!$)return;const z=O.getBoundingClientRect(),V=$.getBoundingClientRect();V.width<z.width&&(V.left<z.left||V.right>z.right||V.top<z.top||V.bottom>z.bottom)&&$.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(T)}},[c.selected,c.timelineRef]),m.useEffect(()=>{const E=T=>{T.key==="Escape"&&u({type:"escape"})};return window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}},[u]),m.useEffect(()=>{if(!r)return;const E=document.documentElement,T=document.body;E.style.overflow="clip",T.style.overflow="clip";const _=O=>{O!=null&&O.cancelable?O.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return _(),window.addEventListener("scroll",_,{passive:!1}),()=>{E.style.overflow="",T.style.overflow="",window.removeEventListener("scroll",_)}},[r]);const D=Math.max(c.timelineHeight-c.scrollbarWidth,Nr+vt+j.length*(Ft+vt)-vt+84),B=!!(c.isMobile&&c.selected);return n.jsxs("div",{className:Rt(ee.traceViewer,d&&ee.skeleton,t),onClickCapture:R,ref:S,style:{height:o,"--timeline-padding":`${We}px`,"--row-height":`${Ft}px`,"--row-padding":`${vt}px`,"--search-height":`${v?0:Jo}px`,"--search-gap":`${v?2:xi}px`,"--map-height":`${gi}px`,"--timeline-width":`${c.timelineWidth}px`,"--timeline-height":`${c.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(c.root.duration*c.scale)}px`,"--panel-width":`${c.panelWidth}px`,"--panel-height":`${c.panelHeight}px`,"--height":`${c.height}px`,"--scrollbar-width":`${c.scrollbarWidth}px`,"--marker-height":`${Nr}px`,"--marker-notch-height":`${hi}px`},children:[v?null:n.jsx(qc,{}),n.jsx(vi,{rows:j,scale:I,timelineRef:f}),n.jsxs("div",{className:Rt(ee.traceViewerContent,B&&ee.inert),children:[n.jsx("div",{className:ee.timeline,ref:f,children:n.jsx("div",{style:{position:"relative",width:c.timelineWidth,height:c.timelineHeight-We*2,padding:We,paddingBottom:0},children:n.jsxs("div",{className:ee.traceNode,style:{width:c.root.duration*I||void 0,height:D-We*2},children:[n.jsx($c,{scale:I,isLive:l}),n.jsx(Vc,{events:b,root:c.root,scale:I}),n.jsx(Uc,{dispatch:u,events:b,memoCacheRef:c.memoCacheRef,root:c.root,scale:I,scrollSnapshotRef:p,spans:k,timelineRef:f}),n.jsx(yi,{cacheKey:g.get(""),cache:g,customSpanClassNameFunc:c.customSpanClassNameFunc,customSpanEventClassNameFunc:c.customSpanEventClassNameFunc,isLive:l,root:c.root,scale:I,scrollSnapshotRef:p,spans:k})]})})}),n.jsx("div",{className:ee.zoomButtonTraceViewer,children:n.jsx(Qc,{})})]}),s?n.jsx("div",{className:Rt(ee.spanDetailPanelTraceViewer,!c.selected&&ee.hidden,c.isMobile&&ee.mobile),children:n.jsx(bi,{attached:!0})}):null]})}function bo(e,t=!1){if(t&&e==="pending")return ee.spanPendingStriped;switch(e){case"running":return ee.spanRunning;case"pending":return ee.spanPending;case"completed":return ee.spanCompleted;case"cancelled":return ee.spanCancelled;case"failed":return ee.spanFailed;default:return""}}function sd(e){return String(e).toLowerCase().endsWith("sleep")}const ad=e=>{const t=e.span.attributes,r=t==null?void 0:t.resource;if(r==="step"){const o=t.data,s=o==null?void 0:o.stepName;if(s&&sd(s))return ee.spanSleep;const a=(o==null?void 0:o.status)==="pending";return bo(o==null?void 0:o.status,a)}if(r==="run"){const o=t.data;return bo(o==null?void 0:o.status,!1)}return r==="hook"?ee.spanHook:r==="sleep"?ee.spanSleep:""},id=e=>{const t=e.event.name;return t==="step_failed"||t==="run_failed"?ee.eventFailed:t==="step_retrying"?ee.eventRetrying:t==="hook_created"||t==="hook_received"||t==="hook_disposed"?ee.eventHook:ee.eventDefault};function ld(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function Je(e){if(typeof e=="string"&&(e=new Date(e)),!e||!(e instanceof Date))return[0,0];const t=e.getTime(),r=Math.floor(t/1e3),o=t%1e3*1e6;return[r,o]}function wo(e){const t=e[0]*1e3,r=e[1]/1e6;return t+r}function Br(e,t){if(typeof e=="string"&&(e=new Date(e)),typeof t=="string"&&(t=new Date(t)),!e||!(e instanceof Date))return[0,0];const o=(t&&t instanceof Date?t:new Date).getTime()-e.getTime(),s=Math.floor(o/1e3),a=o%1e3*1e6;return[s,a]}const ir={name:"workflow-development-kit",version:"4.0.0"},cd=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function zr(e,t=!0){return e.filter(r=>t?cd.has(r.eventType):!0).map(r=>({name:r.eventType,timestamp:Je(r.createdAt),attributes:{eventId:r.eventId,correlationId:r.correlationId,eventData:"eventData"in r?r.eventData:void 0},showVerticalLine:ld(r.eventType)}))}const Fs=e=>{var o;const t=e.find(s=>s.eventType==="wait_created");if(!t)return null;const r=e.find(s=>s.eventType==="wait_completed");return{waitId:t.correlationId,runId:t.runId,createdAt:t.createdAt,resumeAt:(o=t.eventData)==null?void 0:o.resumeAt,completedAt:r==null?void 0:r.createdAt}};function dd(e,t,r){const o=Fs(e);if(!o)return null;const s=new Date(t.completedAt||r)??r,a=(o==null?void 0:o.createdAt)??r,i=(o==null?void 0:o.completedAt)??s,l=Je(a),d=Je(i),c=Br(a,i),u=zr(e,!1);return{spanId:o.waitId,name:"sleep",kind:1,resource:"sleep",library:ir,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:o},links:[],events:u,duration:c,startTime:l,endTime:d}}function ud(e,t,r,o){const s=r??new Date,a=nr(String(e.stepName)),{input:i,output:l,error:d,...c}=e,u={resource:"step",data:c},f="step",p=new Date(e.completedAt??o??s),g=zr(t,!1),v=new Date(e.createdAt);let y=e.startedAt?new Date(e.startedAt):void 0;const N=t.find(x=>x.eventType==="step_started");return N&&(y=new Date(N.createdAt)),{spanId:String(e.stepId),name:(a==null?void 0:a.shortName)??"",kind:1,resource:f,library:ir,status:{code:0},traceFlags:1,attributes:u,links:[],events:g,startTime:Je(v),endTime:Je(p),duration:Br(v,p),activeStartTime:y&&y.getTime()>v.getTime()?Je(y):void 0}}const fd=e=>{var a;const t=e.find(i=>i.eventType==="hook_created");if(!t)return null;const r=e.filter(i=>i.eventType==="hook_received"),o=e.filter(i=>i.eventType==="hook_disposed"),s=r.at(-1);return{hookId:t.correlationId,runId:t.runId,createdAt:t.createdAt,receivedCount:r.length,lastReceivedAt:(s==null?void 0:s.createdAt)||void 0,disposedAt:((a=o.at(-1))==null?void 0:a.createdAt)||void 0}};function md(e,t,r){const o=fd(e);if(!o)return null;const s=zr(e,!1),a=new Date(t.completedAt||r)??r,i=o.disposedAt||a;return{spanId:String(o.hookId),name:String(o.hookId),kind:1,resource:"hook",library:ir,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:o},links:[],events:s,startTime:Je(o.createdAt),endTime:Je(i),duration:Br(o.createdAt,i)}}function pd(e,t,r){var g;const o=r??new Date,{input:s,output:a,error:i,...l}=e,d={resource:"run",data:l},c=new Date(e.createdAt),u=e.startedAt?new Date(e.startedAt):void 0,f=e.completedAt??o,p=zr(t,!1);return{spanId:String(e.runId),name:String(((g=bt(e.workflowName))==null?void 0:g.shortName)??"?"),kind:1,resource:"run",library:ir,status:{code:0},traceFlags:1,attributes:d,links:[],events:p,startTime:Je(c),endTime:Je(f),duration:Br(c,f),activeStartTime:u&&u.getTime()>c.getTime()?Je(u):void 0}}function hd(e){const{state:t,dispatch:r}=it(),o=m.useRef(t);o.current=t,m.useEffect(()=>{if(!e)return;let s=0;const a=()=>{const{root:c}=o.current;if(c.startTime){const u=Date.now();u>c.endTime&&(c.endTime=u,c.duration=c.endTime-c.startTime)}s=requestAnimationFrame(a)};s=requestAnimationFrame(a);let i=0,l=0;const d=()=>{const c=o.current;if(c.root.duration>0){const u=(c.width-c.scrollbarWidth)/c.root.duration;(Math.abs(u-l)>l*.001||l===0)&&(l=u,r({type:"detectBaseScale"}))}i=requestAnimationFrame(d)};return i=requestAnimationFrame(d),()=>{cancelAnimationFrame(s),cancelAnimationFrame(i)}},[e,r])}const gd=450,xd=240;function vd({menu:e,items:t,onClose:r}){const o=m.useRef(null);m.useEffect(()=>{const i=u=>{o.current&&!o.current.contains(u.target)&&r()},l=u=>{u.key==="Escape"&&r()},d=()=>{r()},c=setTimeout(()=>{window.addEventListener("mousedown",i),window.addEventListener("keydown",l),window.addEventListener("scroll",d,!0)},0);return()=>{clearTimeout(c),window.removeEventListener("mousedown",i),window.removeEventListener("keydown",l),window.removeEventListener("scroll",d,!0)}},[r]);const[s,a]=m.useState({x:e.x,y:e.y});return m.useEffect(()=>{const i=o.current;if(!i)return;const l=i.getBoundingClientRect();let{x:d,y:c}=e;l.right>window.innerWidth&&(d=window.innerWidth-l.width-8),l.bottom>window.innerHeight&&(c=window.innerHeight-l.height-8),(d!==e.x||c!==e.y)&&a({x:d,y:c})},[e]),t.length===0?null:$o.createPortal(n.jsxs("div",{ref:o,style:{position:"fixed",left:s.x,top:s.y,zIndex:99999,boxShadow:"var(--ds-shadow-menu)",borderRadius:12,background:"var(--ds-background-100)",padding:"var(--geist-space-gap-quarter, 4px)",fontSize:14,minWidth:180,overflowX:"hidden",overflowY:"auto"},children:[n.jsx("div",{style:{display:"block",color:"var(--ds-gray-900)",fontSize:"0.75rem",padding:"var(--geist-gap-quarter, 4px) var(--geist-space-2x, 8px)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:240,borderBottom:"1px solid var(--ds-gray-alpha-400)",marginBottom:4},children:e.spanName}),t.map(i=>n.jsxs("button",{type:"button",style:{outline:"none",cursor:i.disabled?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:8,padding:"0 var(--geist-space-2x, 8px)",height:40,textDecoration:"none",borderRadius:6,color:i.destructive?"var(--ds-red-900)":"var(--ds-gray-1000)",width:"100%",background:"transparent",border:"none",fontSize:14,textAlign:"left",opacity:i.disabled?.4:1,transition:"background 0.15s"},disabled:i.disabled,onMouseEnter:l=>{l.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},onClick:()=>{i.action(),r()},children:[i.icon??null,i.label]},i.label))]}),document.body)}function yd({trace:e,run:t,hooks:r,isLive:o,onWakeUpSleep:s,onCancelRun:a,onResolveHook:i,onLoadMoreSpans:l,hasMoreSpans:d=!1,isLoadingMoreSpans:c=!1,children:u}){const{state:f,dispatch:p}=it();hd(o);const[g,v]=m.useState(null),[y,N]=m.useState(null),[x,h]=m.useState(!1),[w,j]=m.useState(new Set),k=m.useMemo(()=>{const E=new Map;for(const T of e.spans)E.set(T.spanId,T);return E},[e.spans]),b=m.useMemo(()=>{const E=new Map;for(const T of r)E.set(T.hookId,T);return E},[r]),I=m.useCallback(async E=>{if(!(x||!y||!i)){if(!y.token){me.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{h(!0),await i(y.token,E,y),me.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),j(T=>new Set(T).add(y.hookId)),N(null)}catch(T){console.error("Failed to resolve hook:",T),me.error("Failed to resolve hook",{description:T instanceof Error?T.message:"An unknown error occurred"})}finally{h(!1)}}},[i,y,x]),S=m.useCallback(E=>{const _=E.target.closest("[data-span-id]");if(!_)return;const O=_.dataset.spanId;if(!O)return;E.preventDefault(),E.stopPropagation();const $=k.get(O);if(!$)return;const z=$.attributes.resource??"unknown",V=$.attributes.data,P=!(V!=null&&V.completedAt)&&!(V!=null&&V.disposedAt);v({x:E.clientX,y:E.clientY,spanId:O,spanName:$.name,resourceType:z,isActive:P})},[k]),C=m.useRef(null);m.useEffect(()=>{const E=C.current;if(!E)return;const T=_=>{S(_)};return E.addEventListener("contextmenu",T),()=>{E.removeEventListener("contextmenu",T)}},[S]);const R=m.useRef(!1);m.useEffect(()=>{const E=f.timelineRef.current;if(!E||!l||!d)return;const T=200,_=()=>{R.current||c||!d||E.scrollHeight-E.scrollTop-E.clientHeight>T||(R.current=!0,Promise.resolve(l()).finally(()=>{R.current=!1}))};return E.addEventListener("scroll",_),_(),()=>{E.removeEventListener("scroll",_)}},[f.timelineRef,l,d,c]);const D=m.useCallback(()=>{v(null)},[]),B=m.useCallback(E=>{var O,$;const T=[],_=!t.completedAt;if(E.resourceType==="sleep"&&E.isActive&&_&&s&&T.push({label:"Wake Up Sleep",icon:n.jsx(Da,{className:"h-3.5 w-3.5"}),action:()=>{s(t.runId,E.spanId).then(z=>{z.stoppedCount>0?me.success("Sleep woken up",{description:`Woke up ${String(z.stoppedCount)} sleep${z.stoppedCount>1?"s":""}`}):me.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(z=>{me.error("Failed to wake up sleep",{description:z instanceof Error?z.message:"An unknown error occurred"})})}}),E.resourceType==="hook"&&_&&i){const z=b.get(E.spanId),V=k.get(E.spanId),P=(O=V==null?void 0:V.attributes)==null?void 0:O.data,M=!!(P!=null&&P.disposedAt)||!!(($=V==null?void 0:V.events)!=null&&$.some(H=>H.name==="hook_disposed"))||w.has(E.spanId);z!=null&&z.token&&!M&&T.push({label:"Resolve Hook",icon:n.jsx(Ko,{className:"h-3.5 w-3.5"}),action:()=>{N(z)}})}return E.resourceType==="run"&&_&&a&&T.push({label:"Cancel Run",icon:n.jsx(Ma,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{a(t.runId).catch(z=>{me.error("Failed to cancel run",{description:z instanceof Error?z.message:"An unknown error occurred"})})}}),T.push({label:"View Details",icon:n.jsx(Mi,{className:"h-3.5 w-3.5"}),action:()=>{p({type:"select",id:E.spanId})}}),T.push({label:"Copy Name",icon:n.jsx(Li,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(E.spanName).then(()=>{me.success("Name copied to clipboard")}).catch(()=>{me.error("Failed to copy name")})}}),T.push({label:"Copy ID",icon:n.jsx(rr,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(E.spanId).then(()=>{me.success("ID copied to clipboard")}).catch(()=>{me.error("Failed to copy ID")})}}),T},[p,s,a,i,b,k,w,t.runId,t.completedAt]);return n.jsxs("div",{className:"relative w-full h-full",ref:C,children:[u,g?n.jsx(vd,{menu:g,items:B(g),onClose:D}):null,n.jsx(qo,{isOpen:y!==null,onClose:()=>N(null),onSubmit:I,isSubmitting:x})]})}const bd=e=>e==="wait_created"||e==="wait_completed",wd=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed",hr=(e,t,r)=>{const o=e.get(t);if(o){o.push(r);return}e.set(t,[r])},Id=(e,t,r)=>{const o=new Map,s=new Map,a=[],i=new Map,l=new Map,d=new Set(t.map(u=>u.stepId)),c=new Set(r.map(u=>u.hookId));for(const u of e){const f=u.correlationId;if(!f){a.push(u);continue}if(bd(u.eventType)){hr(i,f,u);continue}if(wd(u.eventType)){hr(l,f,u);continue}if(d.has(f)){hr(o,f,u);continue}if(c.has(f)){hr(s,f,u);continue}a.push(u)}return{eventsByStepId:o,eventsByHookId:s,runLevelEvents:a,timerEvents:i,hookEvents:l}},Nd=(e,t,r,o)=>{const s=new Date(e.completedAt||o),a=t.map(d=>{const c=r.eventsByStepId.get(d.stepId)||[];return ud(d,c,o,s)}),i=Array.from(r.hookEvents.values()).map(d=>md(d,e,o)).filter(d=>d!==null),l=Array.from(r.timerEvents.values()).map(d=>dd(d,e,o)).filter(d=>d!==null);return{runSpan:pd(e,r.runLevelEvents,o),spans:[...a,...i,...l]}},jd=(e,t)=>{const r=[e,...t.slice().sort((o,s)=>{const a=wo(o.startTime),i=wo(s.startTime);return a-i})];return r.map((o,s)=>{const a=s===0?void 0:String(r[s-1].spanId);return{...o,parentSpanId:a}})},kd=(e,t,r,o,s)=>{const a=Id(o,t,r),{runSpan:i,spans:l}=Nd(e,t,a,s),d=jd(i,l);return{traceId:e.runId,rootSpanId:e.runId,spans:d,resources:[{name:"workflow",attributes:{"service.name":ir.name}}]}};function Sd({onSelectionChange:e}){const{state:t}=it(),{selected:r}=t,o=m.useRef(e);return o.current=e,m.useEffect(()=>{var s,a;r?o.current({data:(s=r.span.attributes)==null?void 0:s.data,resource:(a=r.span.attributes)==null?void 0:a.resource,spanId:r.span.spanId}):o.current(null)},[r]),null}function Cd({triggerDeselect:e}){const{dispatch:t}=it();return m.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function Td({selectRequest:e}){const{dispatch:t}=it();return m.useEffect(()=>{e!=null&&e.id&&t({type:"select",id:e.id})},[t,e]),null}function Ed({onResize:e}){const t=m.useCallback(r=>{r.preventDefault();let o=r.clientX;const s=i=>{const l=o-i.clientX;o=i.clientX,e(l)},a=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",a)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",a)},[e]);return n.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-400/50 z-10",onPointerDown:t})}const Ad=({run:e,steps:t,hooks:r,events:o,isLoading:s,error:a,spanDetailData:i,spanDetailLoading:l,spanDetailError:d,onWakeUpSleep:c,onResolveHook:u,onCancelRun:f,onStreamClick:p,onSpanSelect:g,onLoadEventData:v,onLoadMoreSpans:y,hasMoreSpans:N=!1,isLoadingMoreSpans:x=!1})=>{const[h,w]=m.useState(null),[j,k]=m.useState(gd),[b,I]=m.useState(0),[S,C]=m.useState(null),R=!!(e&&!e.completedAt),D=m.useMemo(()=>{if(e)return kd(e,t,r,o,new Date)},[e,t,r,o]);m.useEffect(()=>{a&&!s&&(console.error(a),me.error("Error loading workflow trace data",{description:a.message}))},[a,s]);const B=m.useCallback(H=>{g==null||g(H)},[g]),E=m.useCallback(H=>{if(H){const J=H.spanId,se=J?o.filter(X=>X.correlationId===J):[];w({...H,rawEvents:se})}else w(null)},[o]);m.useEffect(()=>{const H=h==null?void 0:h.spanId;if(!H)return;const J=o.filter(se=>se.correlationId===H);w(se=>{if(!se||se.spanId!==H)return se;const X=se.rawEvents??[];return X.length===J.length&&X.every((Z,A)=>{var W;return Z.eventId===((W=J[A])==null?void 0:W.eventId)})?se:{...se,rawEvents:J}})},[o,h==null?void 0:h.spanId]);const T=m.useCallback(()=>{w(null),I(H=>H+1)},[]),_=m.useCallback(H=>{k(J=>Math.max(xd,J+H))},[]),O=m.useMemo(()=>!(h!=null&&h.spanId)||!D?-1:D.spans.findIndex(H=>H.spanId===h.spanId),[h==null?void 0:h.spanId,D]),$=O>0,z=O>=0&&D!=null&&O<D.spans.length-1,V=m.useCallback(()=>{var J;if(!D||O<=0)return;const H=(J=D.spans[O-1])==null?void 0:J.spanId;H&&C({id:H,token:Date.now()})},[O,D]),P=m.useCallback(()=>{var J;if(!D||O<0)return;const H=(J=D.spans[O+1])==null?void 0:J.spanId;H&&C({id:H,token:Date.now()})},[O,D]),M=m.useMemo(()=>{var X,G;if(!(h!=null&&h.data))return;const H=h.data,J=H.stepName,se=H.workflowName;return(J?(X=nr(J))==null?void 0:X.shortName:void 0)??(se?(G=bt(se))==null?void 0:G.shortName:void 0)??J??se??H.hookId??"Details"},[h==null?void 0:h.data]);return s||!D?n.jsxs("div",{className:"relative w-full h-full",children:[n.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),n.jsx(Re,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),n.jsxs("div",{className:"p-2 relative w-full",children:[n.jsx(Re,{className:"w-full mt-6 h-[20px]"}),n.jsx(Re,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),n.jsx(Re,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),n.jsx(Re,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]}):n.jsxs("div",{className:"relative w-full h-full flex",children:[n.jsx("div",{className:"flex-1 min-w-0 relative",children:n.jsxs(wi,{customSpanClassNameFunc:ad,customSpanEventClassNameFunc:id,children:[n.jsx(Sd,{onSelectionChange:E}),n.jsx(Cd,{triggerDeselect:b}),n.jsx(Td,{selectRequest:S}),n.jsx(yd,{trace:D,run:e,hooks:r,isLive:R,onWakeUpSleep:c,onCancelRun:f,onResolveHook:u,onLoadMoreSpans:y,hasMoreSpans:N,isLoadingMoreSpans:x,children:n.jsx(od,{eagerRender:!0,height:"100%",isLive:R,trace:D})})]})}),h&&n.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:j,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx(Ed,{onResize:_}),n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-y flex-shrink-0",style:{borderColor:"var(--ds-gray-200)"},children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--ds-gray-1000)"},title:M,children:M})}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("button",{type:"button","aria-label":"Previous span",onClick:V,disabled:!$,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:$?"pointer":"not-allowed",opacity:$?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:H=>{$&&(H.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:n.jsx(Aa,{size:16})}),n.jsx("button",{type:"button","aria-label":"Next span",onClick:P,disabled:!z,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:2,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:z?"pointer":"not-allowed",opacity:z?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:H=>{z&&(H.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:n.jsx(Ra,{size:16})})]}),n.jsx("div",{className:"flex items-center",style:{borderLeft:"1px solid var(--ds-gray-300)",marginLeft:6},children:n.jsx("button",{type:"button","aria-label":"Close panel",onClick:T,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:"pointer",flexShrink:0,transition:"background 0.15s"},onMouseEnter:H=>{H.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:n.jsx(Yo,{size:16})})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(Ot,{title:"Failed to load entity details",children:n.jsx(zc,{run:e,hooks:r,onStreamClick:p,spanDetailData:i??null,spanDetailError:d,spanDetailLoading:l,onSpanSelect:B,onWakeUpSleep:c,onLoadEventData:v,onResolveHook:u,selectedSpan:h})})})]})]})};function Rd(e){if(e===""||e===".")return new ArrayBuffer(0);const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r.buffer}function Ps(){function e(t){return Rd(t)}return{...Ni,ArrayBuffer:e,BigInt:t=>BigInt(t),BigInt64Array:t=>new BigInt64Array(e(t)),BigUint64Array:t=>new BigUint64Array(e(t)),Date:t=>new Date(t),Error:t=>{const r=new Error(t.message);return r.name=t.name,r.stack=t.stack,r},Float32Array:t=>new Float32Array(e(t)),Float64Array:t=>new Float64Array(e(t)),Int8Array:t=>new Int8Array(e(t)),Int16Array:t=>new Int16Array(e(t)),Int32Array:t=>new Int32Array(e(t)),Map:t=>new Map(t),RegExp:t=>new RegExp(t.source,t.flags),Set:t=>new Set(t),Uint8Array:t=>new Uint8Array(e(t)),Uint8ClampedArray:t=>new Uint8ClampedArray(e(t)),Uint16Array:t=>new Uint16Array(e(t)),Uint32Array:t=>new Uint32Array(e(t)),Headers:t=>new Headers(t),URL:t=>new URL(t),URLSearchParams:t=>new URLSearchParams(t==="."?"":t),Class:t=>`<class:${$n(t.classId)}>`,Instance:t=>{const r=$n(t.classId),o=t.data,s=o&&typeof o=="object"?{...o}:{value:o},a={[r]:function(){}}[r],i=Object.create(a.prototype);return Object.assign(i,s),i}}}let tn=null;function Dd(){return tn||(tn=Ps()),tn}function Se(e){return Ii(e,Dd())}async function Md(e,t,r,o={}){const s=o.resolveData??"all";let a,i;if(t==="run")a=await gr(fn(e,r,s)),i=a.runId;else if(t==="step"){const{runId:l}=o;if(!l)throw new Tt("runId is required for step resource",{layer:"client"});a=await gr(ji(e,l,r,s)),i=a.stepId}else if(t==="hook")a=await gr(Qo(e,r,s)),i=a.hookId;else throw new Tt(`Unknown resource type: ${t}`,{layer:"client"});return a=Se(a),{data:a,correlationId:i}}function Bs(e,t,r,o={}){const{refreshInterval:s=0,runId:a,enabled:i=!0}=o,[l,d]=m.useState(null),[c,u]=m.useState(i),[f,p]=m.useState(null),g=m.useCallback(async()=>{if(!i){u(!1);return}if(d(null),p(null),t==="hook"){const{error:v,result:y}=await Ee(Qo(e,r,"all"));if(v){p(v);return}d(Se(y));return}if(t==="sleep"){const{error:v,result:y}=await Ee(jr(e,r,{sortOrder:"asc",limit:100,withData:!0}));if(v){p(v);return}const N=y.data.map(Se),x=Fs(N);if(x===null){p(new Error(`Failed to load ${t} details: missing required event data`));return}d(x);return}u(!0);try{const{data:v}=await Md(e,t,r,{runId:a});d(v)}catch(v){v instanceof Error?p(v):p(new Error(String(v)));return}finally{u(!1)}},[e,t,r,a,i]);return m.useEffect(()=>{g()},[g]),m.useEffect(()=>{if(!s||s<=0)return;const v=setInterval(g,s);return()=>clearInterval(v)},[s,g]),{data:l,loading:c,error:f,refresh:g}}const Ld=1e3;function Gt(e,t,r){const o=[...e,...t],s=new Map(o.map(a=>[a[r],a]));return Array.from(s.values())}async function rn(e){const{fetchFn:t,setItems:r,setCursor:o,setError:s,idKey:a,cursorStrategy:i="always",transform:l}=e,{error:d,result:c}=await t();if(d)return s(d),!1;if(c.data.length>0){const u=l?c.data.map(l):c.data;return r(p=>Gt(p,u,a)),(i==="onHasMore"?!!(c.cursor&&c.hasMore):!!c.cursor)&&o(c.cursor),!0}return!1}const nn=10,_t=50,_d=2e3,Hd=5e3;async function Od(e,t){let r=[],o;for(;;){const{error:s,result:a}=await Ee(jr(e,t,{cursor:o,sortOrder:"asc",limit:1e3}));if(s||(r=[...r,...a.data],!a.hasMore||!a.cursor||r.length>=Ld))break;o=a.cursor}return r}async function Io(e,t){return t.length===0?[]:(await Promise.all(t.map(o=>Od(e,o)))).flat()}function Fd(e,t,r={}){const{live:o=!1}=r,[s,a]=m.useState(null),[i,l]=m.useState([]),[d,c]=m.useState([]),[u,f]=m.useState([]),[p,g]=m.useState(!0),[v,y]=m.useState(!1),[N,x]=m.useState(null),[h,w]=m.useState(),[j,k]=m.useState(),[b,I]=m.useState(),[S,C]=m.useState(!1),[R,D]=m.useState(!1),[B,E]=m.useState(!1),[T,_]=m.useState(!1),O=m.useRef(!1),[$,z]=m.useState(!1),V=m.useCallback(async()=>{var je;if(O.current)return;O.current=!0,g(!0),y(!0),x(null);const[G,Z,A,W]=await Promise.all([Ee(fn(e,t)),Ee(Ur(e,t,{sortOrder:"asc",limit:_t})),Ee(Gr(e,{runId:t,sortOrder:"asc",limit:_t})),Ee(Kt(e,t,{sortOrder:"asc",limit:_t}))]);G.error?x(G.error):a(Se(G.result));const oe=Z.error?[]:Z.result.data.map(Se),ce=A.error?[]:A.result.data.map(Se),ie=W.error?[]:W.result.data.map(Se),Q=[...oe.map(we=>we.stepId),...ce.map(we=>we.hookId)],Ne=(await Io(e,Q)).map(Se);l(oe),c(ce),f(Gt([],[...ie,...Ne],"eventId")),w(Z.error||!Z.result.hasMore?void 0:Z.result.cursor),k(A.error||!A.result.hasMore?void 0:A.result.cursor),I(W.error||!W.result.hasMore?void 0:W.result.cursor),C(!!(!Z.error&&Z.result.hasMore)),D(!!(!A.error&&A.result.hasMore)),E(!!(!W.error&&W.result.hasMore));const Ae=[G,Z,A,W];if(g(!1),y(!1),z(!0),O.current=!1,!G.error){const we=(je=Ae.find(Me=>Me.error))==null?void 0:je.error;we&&x(we)}},[e,t]),P=m.useCallback(async()=>{var G,Z,A,W,oe,ce;if(!(O.current||!$||T)&&!(!S&&!R&&!B)){_(!0);try{const[ie,Q,de]=await Promise.all([S?Ee(Ur(e,t,{cursor:h,sortOrder:"asc",limit:_t})):Promise.resolve({error:null,result:null}),R?Ee(Gr(e,{runId:t,cursor:j,sortOrder:"asc",limit:_t})):Promise.resolve({error:null,result:null}),B?Ee(Kt(e,t,{cursor:b,sortOrder:"asc",limit:_t})):Promise.resolve({error:null,result:null})]);ie.error&&x(ie.error),Q.error&&x(Q.error),de.error&&x(de.error);const Ne=((G=ie.result)==null?void 0:G.data.map(Se))??[],Ae=((Z=Q.result)==null?void 0:Z.data.map(Se))??[],je=((A=de.result)==null?void 0:A.data.map(Se))??[];Ne.length>0&&l(fe=>Gt(fe,Ne,"stepId")),Ae.length>0&&c(fe=>Gt(fe,Ae,"hookId"));const we=[...Ne.map(fe=>fe.stepId),...Ae.map(fe=>fe.hookId)],Ke=(await Io(e,we)).map(Se),q=[...je,...Ke];q.length>0&&f(fe=>Gt(fe,q,"eventId"));const Ie=ie.error?S:!!(ie.result&&ie.result.hasMore),ye=Q.error?R:!!(Q.result&&Q.result.hasMore),ke=de.error?B:!!(de.result&&de.result.hasMore);C(Ie),D(ye),E(ke),ie.error||w((W=ie.result)!=null&&W.hasMore?ie.result.cursor:void 0),Q.error||k((oe=Q.result)!=null&&oe.hasMore?Q.result.cursor:void 0),de.error||I((ce=de.result)!=null&&ce.hasMore?de.result.cursor:void 0)}finally{_(!1)}}},[e,t,$,T,S,R,B,h,j,b]),M=m.useCallback(async()=>{if(s!=null&&s.completedAt)return!1;const{error:G,result:Z}=await Ee(fn(e,t));return G?(x(G),!1):(a(Se(Z)),!0)},[e,t,s==null?void 0:s.completedAt]),H=m.useCallback(()=>rn({fetchFn:()=>Ee(Ur(e,t,{cursor:h,sortOrder:"asc",limit:nn})),setItems:l,setCursor:w,setError:x,idKey:"stepId",cursorStrategy:"onHasMore",transform:Se}),[e,t,h]),J=m.useCallback(()=>rn({fetchFn:()=>Ee(Gr(e,{runId:t,cursor:j,sortOrder:"asc",limit:nn})),setItems:c,setCursor:k,setError:x,idKey:"hookId",transform:Se}),[e,t,j]),se=m.useCallback(()=>rn({fetchFn:()=>Ee(Kt(e,t,{cursor:b,sortOrder:"asc",limit:nn})),setItems:f,setCursor:I,setError:x,idKey:"eventId",transform:Se}),[e,t,b]),X=m.useCallback(async(G=!1)=>{if(O.current||!$)return{foundNewItems:!1};let Z=!1;try{const[A,W,oe,ce]=await Promise.all([G?Promise.resolve(!1):M(),H(),G?Promise.resolve(!1):J(),G?Promise.resolve(!1):se()]);Z=W||oe||ce}catch(A){console.error("Update error:",A)}return{foundNewItems:Z}},[H,J,se,$,M]);return m.useEffect(()=>{V()},[V]),m.useEffect(()=>{if(!o||!$||s!=null&&s.completedAt)return;const G=setInterval(()=>{X()},Hd),Z=setInterval(()=>{X(!0)},_d);return()=>{clearInterval(G),clearInterval(Z)}},[o,$,X,s==null?void 0:s.completedAt]),{run:s??{},steps:i,hooks:d,events:u,loading:p,auxiliaryDataLoading:v,error:N,update:X,loadMoreTraceData:P,hasMoreTraceData:S||R||B,isLoadingMoreTraceData:T}}function Pd(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function Bd(e,t,r,o){try{const s=`/api/stream/${encodeURIComponent(t)}${r!=null?`?startIndex=${r}`:""}`,a=await fetch(s,{signal:o});if(!a.ok){const i=await a.json().catch(()=>null);throw i&&Pd(i)?new Tt(i.message,{layer:"client",cause:i.cause,request:i.request}):new Tt(`Failed to read stream: ${a.status}`,{layer:"client"})}if(!a.body)throw new Tt("Failed to read stream: no body",{layer:"client"});return a.body}catch(s){throw s instanceof Tt?s:new Tt("Failed to read stream",{layer:"client",cause:s})}}async function zd(e,t){return gr(ki(e,t))}const Wd=1e4;function $d(e,t,r=Wd){const[o,s]=m.useState([]),[a,i]=m.useState(!0),[l,d]=m.useState(null),c=m.useCallback(async()=>{i(!0),d(null);try{const u=await zd(e,t);s(u)}catch(u){d(u instanceof Error?u:new Error(String(u)))}finally{i(!1)}},[e,t]);return m.useEffect(()=>{c()},[c]),m.useEffect(()=>{if(!r||r<=0)return;const u=setInterval(c,r);return()=>clearInterval(u)},[r,c]),{streams:o,loading:a,error:l,refresh:c}}var Vd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ut=Vd.reduce((e,t)=>{const r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,l=a?In:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(l,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ud(e,t){e&&$o.flushSync(()=>e.dispatchEvent(t))}var Gd="DismissableLayer",bn="dismissableLayer.update",Kd="dismissableLayer.pointerDownOutside",qd="dismissableLayer.focusOutside",No,zs=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ws=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,c=m.useContext(zs),[u,f]=m.useState(null),p=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=m.useState({}),v=It(t,I=>f(I)),y=Array.from(c.layers),[N]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=y.indexOf(N),h=u?y.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,j=h>=x,k=Zd(I=>{const S=I.target,C=[...c.branches].some(R=>R.contains(S));!j||C||(s==null||s(I),i==null||i(I),I.defaultPrevented||l==null||l())},p),b=Jd(I=>{const S=I.target;[...c.branches].some(R=>R.contains(S))||(a==null||a(I),i==null||i(I),I.defaultPrevented||l==null||l())},p);return La(I=>{h===c.layers.size-1&&(o==null||o(I),!I.defaultPrevented&&l&&(I.preventDefault(),l()))},p),m.useEffect(()=>{if(u)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(No=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),jo(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=No)}},[u,p,r,c]),m.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),jo())},[u,c]),m.useEffect(()=>{const I=()=>g({});return document.addEventListener(bn,I),()=>document.removeEventListener(bn,I)},[]),n.jsx(ut.div,{...d,ref:v,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:dt(e.onFocusCapture,b.onFocusCapture),onBlurCapture:dt(e.onBlurCapture,b.onBlurCapture),onPointerDownCapture:dt(e.onPointerDownCapture,k.onPointerDownCapture)})});Ws.displayName=Gd;var Yd="DismissableLayerBranch",Xd=m.forwardRef((e,t)=>{const r=m.useContext(zs),o=m.useRef(null),s=It(t,o);return m.useEffect(()=>{const a=o.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(ut.div,{...e,ref:s})});Xd.displayName=Yd;function Zd(e,t=globalThis==null?void 0:globalThis.document){const r=br(e),o=m.useRef(!1),s=m.useRef(()=>{});return m.useEffect(()=>{const a=l=>{if(l.target&&!o.current){let d=function(){$s(Kd,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=d,t.addEventListener("click",s.current,{once:!0})):d()}else t.removeEventListener("click",s.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function Jd(e,t=globalThis==null?void 0:globalThis.document){const r=br(e),o=m.useRef(!1);return m.useEffect(()=>{const s=a=>{a.target&&!o.current&&$s(qd,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function jo(){const e=new CustomEvent(bn);document.dispatchEvent(e)}function $s(e,t,r,{discrete:o}){const s=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),o?Ud(s,a):s.dispatchEvent(a)}var on="focusScope.autoFocusOnMount",sn="focusScope.autoFocusOnUnmount",ko={bubbles:!1,cancelable:!0},Qd="FocusScope",Vs=m.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=m.useState(null),c=br(s),u=br(a),f=m.useRef(null),p=It(t,y=>d(y)),g=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let y=function(w){if(g.paused||!l)return;const j=w.target;l.contains(j)?f.current=j:xt(f.current,{select:!0})},N=function(w){if(g.paused||!l)return;const j=w.relatedTarget;j!==null&&(l.contains(j)||xt(f.current,{select:!0}))},x=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&xt(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",N);const h=new MutationObserver(x);return l&&h.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",N),h.disconnect()}}},[o,l,g.paused]),m.useEffect(()=>{if(l){Co.add(g);const y=document.activeElement;if(!l.contains(y)){const x=new CustomEvent(on,ko);l.addEventListener(on,c),l.dispatchEvent(x),x.defaultPrevented||(eu(su(Us(l)),{select:!0}),document.activeElement===y&&xt(l))}return()=>{l.removeEventListener(on,c),setTimeout(()=>{const x=new CustomEvent(sn,ko);l.addEventListener(sn,u),l.dispatchEvent(x),x.defaultPrevented||xt(y??document.body,{select:!0}),l.removeEventListener(sn,u),Co.remove(g)},0)}}},[l,c,u,g]);const v=m.useCallback(y=>{if(!r&&!o||g.paused)return;const N=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,x=document.activeElement;if(N&&x){const h=y.currentTarget,[w,j]=tu(h);w&&j?!y.shiftKey&&x===j?(y.preventDefault(),r&&xt(w,{select:!0})):y.shiftKey&&x===w&&(y.preventDefault(),r&&xt(j,{select:!0})):x===h&&y.preventDefault()}},[r,o,g.paused]);return n.jsx(ut.div,{tabIndex:-1,...i,ref:p,onKeyDown:v})});Vs.displayName=Qd;function eu(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(xt(o,{select:t}),document.activeElement!==r)return}function tu(e){const t=Us(e),r=So(t,e),o=So(t.reverse(),e);return[r,o]}function Us(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const s=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||s?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function So(e,t){for(const r of e)if(!ru(r,{upTo:t}))return r}function ru(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function nu(e){return e instanceof HTMLInputElement&&"select"in e}function xt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&nu(e)&&t&&e.select()}}var Co=ou();function ou(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=To(e,t),e.unshift(t)},remove(t){var r;e=To(e,t),(r=e[0])==null||r.resume()}}}function To(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function su(e){return e.filter(t=>t.tagName!=="A")}var au="Portal",Gs=m.forwardRef((e,t)=>{var l;const{container:r,...o}=e,[s,a]=m.useState(!1);_a(()=>a(!0),[]);const i=r||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Wo.createPortal(n.jsx(ut.div,{...o,ref:t}),i):null});Gs.displayName=au;var _n="Dialog",[Ks,qs]=Xo(_n),[iu,et]=Ks(_n),Ys=e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=m.useRef(null),d=m.useRef(null),[c=!1,u]=Oa({prop:o,defaultProp:s,onChange:a});return n.jsx(iu,{scope:t,triggerRef:l,contentRef:d,contentId:Wr(),titleId:Wr(),descriptionId:Wr(),open:c,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(f=>!f),[u]),modal:i,children:r})};Ys.displayName=_n;var Xs="DialogTrigger",Zs=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=et(Xs,r),a=It(t,s.triggerRef);return n.jsx(ut.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Fn(s.open),...o,ref:a,onClick:dt(e.onClick,s.onOpenToggle)})});Zs.displayName=Xs;var Hn="DialogPortal",[lu,Js]=Ks(Hn,{forceMount:void 0}),Qs=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:s}=e,a=et(Hn,t);return n.jsx(lu,{scope:t,forceMount:r,children:m.Children.map(o,i=>n.jsx(wn,{present:r||a.open,children:n.jsx(Gs,{asChild:!0,container:s,children:i})}))})};Qs.displayName=Hn;var Rr="DialogOverlay",ea=m.forwardRef((e,t)=>{const r=Js(Rr,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=et(Rr,e.__scopeDialog);return a.modal?n.jsx(wn,{present:o||a.open,children:n.jsx(cu,{...s,ref:t})}):null});ea.displayName=Rr;var cu=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=et(Rr,r);return n.jsx(Pa,{as:In,allowPinchZoom:!0,shards:[s.contentRef],children:n.jsx(ut.div,{"data-state":Fn(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),Dt="DialogContent",ta=m.forwardRef((e,t)=>{const r=Js(Dt,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=et(Dt,e.__scopeDialog);return n.jsx(wn,{present:o||a.open,children:a.modal?n.jsx(du,{...s,ref:t}):n.jsx(uu,{...s,ref:t})})});ta.displayName=Dt;var du=m.forwardRef((e,t)=>{const r=et(Dt,e.__scopeDialog),o=m.useRef(null),s=It(t,r.contentRef,o);return m.useEffect(()=>{const a=o.current;if(a)return Fa(a)},[]),n.jsx(ra,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:dt(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:dt(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:dt(e.onFocusOutside,a=>a.preventDefault())})}),uu=m.forwardRef((e,t)=>{const r=et(Dt,e.__scopeDialog),o=m.useRef(!1),s=m.useRef(!1);return n.jsx(ra,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(o.current||(l=r.triggerRef.current)==null||l.focus(),a.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:a=>{var d,c;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((c=r.triggerRef.current)==null?void 0:c.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),ra=m.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=et(Dt,r),d=m.useRef(null),c=It(t,d);return Ba(),n.jsxs(n.Fragment,{children:[n.jsx(Vs,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:a,children:n.jsx(Ws,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Fn(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(mu,{titleId:l.titleId}),n.jsx(hu,{contentRef:d,descriptionId:l.descriptionId})]})]})}),On="DialogTitle",na=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=et(On,r);return n.jsx(ut.h2,{id:s.titleId,...o,ref:t})});na.displayName=On;var oa="DialogDescription",sa=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=et(oa,r);return n.jsx(ut.p,{id:s.descriptionId,...o,ref:t})});sa.displayName=oa;var aa="DialogClose",ia=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=et(aa,r);return n.jsx(ut.button,{type:"button",...o,ref:t,onClick:dt(e.onClick,()=>s.onOpenChange(!1))})});ia.displayName=aa;function Fn(e){return e?"open":"closed"}var la="DialogTitleWarning",[fu,ca]=Ha(la,{contentName:Dt,titleName:On,docsSlug:"dialog"}),mu=({titleId:e})=>{const t=ca(la),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
24
+
25
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
26
+
27
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},pu="DialogDescriptionWarning",hu=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ca(pu).contentName}}.`;return m.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},gu=Ys,xu=Zs,vu=Qs,yu=ea,bu=ta,wu=na,Iu=sa,da=ia,ua="AlertDialog",[Nu]=Xo(ua,[qs]),ft=qs(),fa=e=>{const{__scopeAlertDialog:t,...r}=e,o=ft(t);return n.jsx(gu,{...o,...r,modal:!0})};fa.displayName=ua;var ju="AlertDialogTrigger",ku=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ft(r);return n.jsx(xu,{...s,...o,ref:t})});ku.displayName=ju;var Su="AlertDialogPortal",ma=e=>{const{__scopeAlertDialog:t,...r}=e,o=ft(t);return n.jsx(vu,{...o,...r})};ma.displayName=Su;var Cu="AlertDialogOverlay",pa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ft(r);return n.jsx(yu,{...s,...o,ref:t})});pa.displayName=Cu;var Bt="AlertDialogContent",[Tu,Eu]=Nu(Bt),ha=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:o,...s}=e,a=ft(r),i=m.useRef(null),l=It(t,i),d=m.useRef(null);return n.jsx(fu,{contentName:Bt,titleName:ga,docsSlug:"alert-dialog",children:n.jsx(Tu,{scope:r,cancelRef:d,children:n.jsxs(bu,{role:"alertdialog",...a,...s,ref:l,onOpenAutoFocus:dt(s.onOpenAutoFocus,c=>{var u;c.preventDefault(),(u=d.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[n.jsx(Si,{children:o}),n.jsx(Ru,{contentRef:i})]})})})});ha.displayName=Bt;var ga="AlertDialogTitle",xa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ft(r);return n.jsx(wu,{...s,...o,ref:t})});xa.displayName=ga;var va="AlertDialogDescription",ya=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ft(r);return n.jsx(Iu,{...s,...o,ref:t})});ya.displayName=va;var Au="AlertDialogAction",ba=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ft(r);return n.jsx(da,{...s,...o,ref:t})});ba.displayName=Au;var wa="AlertDialogCancel",Ia=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,{cancelRef:s}=Eu(wa,r),a=ft(r),i=It(t,s);return n.jsx(da,{...a,...o,ref:i})});Ia.displayName=wa;var Ru=({contentRef:e})=>{const t=`\`${Bt}\` requires a description for the component to be accessible for screen reader users.
28
+
29
+ You can add a description to the \`${Bt}\` by passing a \`${va}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
30
+
31
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Bt}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
32
+
33
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return m.useEffect(()=>{var o;document.getElementById((o=e.current)==null?void 0:o.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Du=fa,Mu=ma,Lu=pa,_u=ha,Hu=ba,Ou=Ia,Fu=xa,Pu=ya;function Eo({...e}){return n.jsx(Du,{"data-slot":"alert-dialog",...e})}function Bu({...e}){return n.jsx(Mu,{"data-slot":"alert-dialog-portal",...e})}function zu({className:e,...t}){return n.jsx(Lu,{"data-slot":"alert-dialog-overlay",className:Ge("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Ao({className:e,onSubmit:t,...r}){return n.jsxs(Bu,{children:[n.jsx(zu,{}),n.jsx(_u,{"data-slot":"alert-dialog-content",className:Ge("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),onSubmit:o=>{o.preventDefault(),t==null||t(o)},...r})]})}function Ro({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-header",className:Ge("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Do({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-footer",className:Ge("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Mo({className:e,...t}){return n.jsx(Fu,{"data-slot":"alert-dialog-title",className:Ge("text-lg font-semibold",e),...t})}function Lo({className:e,...t}){return n.jsx(Pu,{"data-slot":"alert-dialog-description",className:Ge("text-muted-foreground text-sm",e),...t})}function _o({className:e,...t}){return n.jsx(Hu,{className:Ge(es(),e),...t})}function Ho({className:e,...t}){return n.jsx(Ou,{className:Ge(es({variant:"outline"}),e),...t})}function Wu({...e}){return n.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function $u({className:e,...t}){return n.jsx("ol",{"data-slot":"breadcrumb-list",className:Ge("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...t})}function Oo({className:e,...t}){return n.jsx("li",{"data-slot":"breadcrumb-item",className:Ge("inline-flex items-center gap-1.5",e),...t})}function Vu({asChild:e,className:t,...r}){const o=e?In:"a";return n.jsx(o,{"data-slot":"breadcrumb-link",className:Ge("hover:text-foreground transition-colors",t),...r})}function Uu({className:e,...t}){return n.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:Ge("text-foreground font-normal",e),...t})}function Gu({children:e,className:t,...r}){return n.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:Ge("[&>svg]:size-3.5",t),...r,children:e??n.jsx(Uo,{})})}const Ht={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function Dr(e){return e.replace(/\/\/\.\.\//g,"//")}function Ku(e,t,r,o){let s;switch(e.status){case"completed":s="completed";break;case"failed":s=r<o-1?"retrying":"failed";break;case"running":s="running";break;case"cancelled":s="cancelled";break;case"pending":default:s="pending";break}const a=e.completedAt&&e.startedAt?new Date(e.completedAt).getTime()-new Date(e.startedAt).getTime():void 0;return{nodeId:t,stepId:e.stepId,attemptNumber:e.attempt,status:s,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0,duration:a,input:e.input,output:e.output,error:e.error?{message:e.error.message,stack:e.error.stack||""}:void 0}}function Mr(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function qu(e){const t=new Map,r=new Map,o=new Map,s=[],a=new Map;for(const i of e){if(i.data.stepId){const l=Dr(i.data.stepId),d=t.get(l)||[];d.push(i),t.set(l,d);const c=Mr(l);if(c){const u=r.get(c)||[];u.push(i),r.set(c,u)}}if(i.data.nodeKind==="primitive"){const l=i.data.label,d=o.get(l)||[];d.push(i),o.set(l,d)}if(i.data.nodeKind==="agent"&&s.push(i),i.data.nodeKind==="tool"){const d=i.data.label.replace(/ \(tool\)$/,""),c=a.get(d)||[];if(c.push(i),a.set(d,c),i.data.stepId){const u=Mr(Dr(i.data.stepId));if(u){const f=a.get(u)||[];f.includes(i)||(f.push(i),a.set(u,f))}}}}return{byStepId:t,byFunctionName:r,primitivesByLabel:o,agentNodes:s,toolNodes:a}}function Yu(e,t,r){var d,c,u,f;const o=new Map,s=new Set(e),a=new Map;for(const p of t.nodes){const g=(d=p.metadata)==null?void 0:d.parallelGroupId;if(g){const v=a.get(g)||{nodes:[]};v.nodes.push(p),v.method=(c=p.metadata)==null?void 0:c.parallelMethod,a.set(g,v)}}const i=new Map;for(const[p,g]of a)if(g.method==="race"){let v,y;for(const N of g.nodes){const x=r.get(N.id);if(x){for(const h of x)if(h.status==="completed"&&h.completedAt){const w=new Date(h.completedAt);(!y||w<y)&&(y=w,v=N.id)}}}v&&i.set(p,v)}const l=p=>{const g=o.get(p.id);g?g.traversalCount++:o.set(p.id,{edgeId:p.id,traversalCount:1,timings:[]})};for(const p of t.edges){const g=t.nodes.find(w=>w.id===p.source),v=t.nodes.find(w=>w.id===p.target);if(!g||!v)continue;const y=s.has(p.source),N=s.has(p.target);if(!y&&!N)continue;if(p.type==="conditional"){y&&N&&l(p);continue}const x=(u=g.metadata)==null?void 0:u.parallelGroupId,h=(f=g.metadata)==null?void 0:f.parallelMethod;x&&h==="race"?i.get(x)===p.source&&N&&l(p):(y&&N||y&&p.type==="parallel"&&N)&&l(p)}return o}function Xu(e,t,r,o){const s=t.nodes.find(a=>a.data.nodeKind==="workflow_start");s&&(r.push(s.id),o.set(s.id,[{nodeId:s.id,attemptNumber:1,status:"completed",startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0}]))}function Zu(e,t,r,o){const s=t.nodes.find(i=>i.data.nodeKind==="workflow_end");if(!s||r.includes(s.id))return;let a;switch(e.status){case"completed":a="completed";break;case"failed":a="failed";break;case"cancelled":a="cancelled";break;case"running":a="running";break;case"pending":default:return}r.push(s.id),o.set(s.id,[{nodeId:s.id,attemptNumber:1,status:a,startedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0,completedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0}])}function Ju(e,t,r,o,s,a,i){const l=Dr(t),d=s.get(l)||0;s.set(l,d+1);let c=r.get(l)||[],u="step-id";if(c.length===0){const v=Mr(l);v&&(c=o.get(v)||[],u="function-name")}const f=c.length===1?c[0]:c[d];if(console.log("[Graph Mapper] Processing step group:",{stepName:t,normalizedStepName:l,attempts:e.length,occurrenceIndex:d,totalNodesWithStepId:c.length,selectedNode:f==null?void 0:f.id,allNodesWithStepId:c.map(v=>v.id),matchStrategy:u,strategy:c.length===1?"single-node-multiple-invocations":"occurrence-based"}),!f)return;const p=e.map((v,y)=>Ku(v,f.id,y,e.length));if(c.length===1){const v=a.get(f.id)||[];a.set(f.id,[...v,...p])}else a.set(f.id,p);return i.includes(f.id)||i.push(f.id),p[p.length-1].status==="running"?f.id:void 0}function Qu(e,t,r,o){const s=new Map,a=new Map;for(const x of e){if(!x.correlationId)continue;const h=a.get(x.correlationId)||[];h.push(x),a.set(x.correlationId,h)}let i;const l=t.get(Ht.sleep)||[],d=new Set;for(const x of e)x.eventType==="wait_created"&&x.correlationId&&d.add(x.correlationId);const c=Array.from(d).sort((x,h)=>{var I,S;const w=a.get(x)||[],j=a.get(h)||[],k=(I=w.find(C=>C.eventType==="wait_created"))==null?void 0:I.createdAt,b=(S=j.find(C=>C.eventType==="wait_created"))==null?void 0:S.createdAt;return!k||!b?0:new Date(k).getTime()-new Date(b).getTime()});for(const x of c){const h=a.get(x)||[],w=h.find(E=>E.eventType==="wait_created"),j=h.find(E=>E.eventType==="wait_completed");if(!w)continue;const k=s.get(Ht.sleep)||0;s.set(Ht.sleep,k+1);const b=l.length===1?l[0]:l[k];if(!b)continue;let I="running";j&&(I="completed");const S=new Date(w.createdAt).toISOString(),C=j?new Date(j.createdAt).toISOString():void 0,R=j?new Date(j.createdAt).getTime()-new Date(w.createdAt).getTime():void 0,D={nodeId:b.id,attemptNumber:1,status:I,startedAt:S,completedAt:C,duration:R},B=r.get(b.id)||[];r.set(b.id,[...B,D]),o.includes(b.id)||o.push(b.id),I==="running"&&(i=b.id)}const u=[...t.get(Ht.createHook)||[],...t.get(Ht.createWebhook)||[]],f=new Set;for(const x of e)x.eventType==="hook_created"&&x.correlationId&&f.add(x.correlationId);const p=Array.from(f).sort((x,h)=>{var I,S;const w=a.get(x)||[],j=a.get(h)||[],k=(I=w.find(C=>C.eventType==="hook_created"))==null?void 0:I.createdAt,b=(S=j.find(C=>C.eventType==="hook_created"))==null?void 0:S.createdAt;return!k||!b?0:new Date(k).getTime()-new Date(b).getTime()});let g=0;for(const x of p){const w=(a.get(x)||[]).find(R=>R.eventType==="hook_created");if(!w)continue;const j=u.length===1?u[0]:u[g];if(g++,!j)continue;const k="completed",b=new Date(w.createdAt).toISOString(),I=new Date(w.createdAt).toISOString(),S={nodeId:j.id,attemptNumber:1,status:k,startedAt:b,completedAt:I,duration:0},C=r.get(j.id)||[];r.set(j.id,[...C,S]),o.includes(j.id)||o.push(j.id)}const v=t.get(Ht.awaitWebhook)||[],y=new Set;for(const x of e)x.eventType==="hook_received"&&x.correlationId&&y.add(x.correlationId);let N=0;for(const x of p){const h=v.length===1?v[0]:v[N];if(N++,!h)continue;const w=a.get(x)||[],j=w.find(B=>B.eventType==="hook_created"),k=w.find(B=>B.eventType==="hook_received");let b,I,S,C=0;k?(b="completed",I=j?new Date(j.createdAt).toISOString():new Date(k.createdAt).toISOString(),S=new Date(k.createdAt).toISOString(),C=new Date(S).getTime()-new Date(I).getTime()):j?(b="running",I=new Date(j.createdAt).toISOString()):b="pending";const R={nodeId:h.id,attemptNumber:1,status:b,startedAt:I,completedAt:S,duration:C},D=r.get(h.id)||[];r.set(h.id,[...D,R]),o.includes(h.id)||o.push(h.id)}return i}function ef(e,t,r,o,s,a,i){var d;let l="pending";e.status==="completed"?l="completed":e.status==="failed"?l="failed":e.status==="running"&&(l="running");for(const c of r){const u={nodeId:c.id,attemptNumber:1,status:l,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(l==="completed"||l==="failed")?new Date(e.completedAt).toISOString():void 0};s.set(c.id,[u]),a.includes(c.id)||a.push(c.id)}for(const c of t){const u=Mr(c.stepName);if(!u)continue;const f=o.get(u);if(!f||f.length===0)continue;const p=f[0];let g;switch(c.status){case"completed":g="completed";break;case"failed":g="failed";break;case"running":g="running";break;case"cancelled":g="cancelled";break;case"pending":default:g="pending";break}const v=c.completedAt&&c.startedAt?new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime():void 0,y={nodeId:p.id,stepId:c.stepId,attemptNumber:c.attempt,status:g,startedAt:c.startedAt?new Date(c.startedAt).toISOString():void 0,completedAt:c.completedAt?new Date(c.completedAt).toISOString():void 0,duration:v,input:c.input,output:c.output,error:c.error},N=s.get(p.id)||[];s.set(p.id,[...N,y]),a.includes(p.id)||a.push(p.id)}for(const c of i){const u=((d=c.metadata)==null?void 0:d.isToolsCollection)===!0;if(c.data.nodeKind==="tool"&&u&&!s.has(c.id)){const f={nodeId:c.id,attemptNumber:1,status:l,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(l==="completed"||l==="failed")?new Date(e.completedAt).toISOString():void 0};s.set(c.id,[f]),a.includes(c.id)||a.push(c.id)}}}function tf(e,t,r,o){var i,l,d;const s=e.nodes.filter(c=>c.data.nodeKind==="conditional"),a=new Map;for(const c of e.nodes){const u=(i=c.metadata)==null?void 0:i.conditionalId;if(u){const f=a.get(u)||{thenNodes:[],elseNodes:[]};((l=c.metadata)==null?void 0:l.conditionalBranch)==="Then"?f.thenNodes.push(c):((d=c.metadata)==null?void 0:d.conditionalBranch)==="Else"&&f.elseNodes.push(c),a.set(u,f)}}for(const c of s){const u=c.id.match(/^(cond_\d+)_node$/);if(!u)continue;const f=u[1],p=a.get(f);if(!p)continue;const g=p.thenNodes.some(y=>t.has(y.id)),v=p.elseNodes.some(y=>t.has(y.id));if(g||v){const y=[...p.thenNodes,...p.elseNodes];if(!t.has(c.id)){let N;for(const w of y){const j=t.get(w.id);if(j&&j.length>0){const k=j[0];k.startedAt&&(!N||k.startedAt<N)&&(N=k.startedAt)}}const x=o.startedAt?new Date(o.startedAt).toISOString():void 0,h={nodeId:c.id,attemptNumber:1,status:"completed",startedAt:N||x,completedAt:N||x};t.set(c.id,[h])}if(!r.includes(c.id)){const N=y.map(x=>r.indexOf(x.id)).filter(x=>x>=0);if(N.length>0){const x=Math.min(...N);x>=0&&x<r.length?r.splice(x,0,c.id):r.push(c.id)}else r.push(c.id)}}}}function rf(e,t,r,o){const s=new Map,a=[];let i;console.log("[Graph Mapper] Mapping run to execution:",{runId:e.runId,workflowName:e.workflowName,graphNodes:o.nodes.length,stepsCount:t.length}),Xu(e,o,a,s);const l=[...t].sort((j,k)=>new Date(j.createdAt).getTime()-new Date(k.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",l.map(j=>({stepId:j.stepId,stepName:j.stepName,attempt:j.attempt,status:j.status,createdAt:j.createdAt})));const{byStepId:d,byFunctionName:c,primitivesByLabel:u,agentNodes:f,toolNodes:p}=qu(o.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:o.nodes.map(j=>({id:j.id,stepId:j.data.stepId,normalizedStepId:j.data.stepId?Dr(j.data.stepId):void 0,nodeKind:j.data.nodeKind})),nodesByStepId:Array.from(d.entries()).map(([j,k])=>({stepId:j,nodeIds:k.map(b=>b.id)}))});const g=new Map;let v=[],y=null,N=null;for(let j=0;j<=l.length;j++){const k=l[j];if(!k||k.stepId!==y){if(v.length>0&&N){const I=Ju(v,N,d,c,g,s,a);I&&(i=I)}k&&(v=[k],y=k.stepId,N=k.stepName)}else v.push(k)}const x=Qu(r,u,s,a);x&&(i=x),ef(e,l,f,p,s,a,o.nodes),tf(o,s,a,e),Zu(e,o,a,s);const h=Yu(a,o,s),w={runId:e.runId,status:e.status,nodeExecutions:s,edgeTraversals:h,currentNode:i,executionPath:a};return console.log("[Graph Mapper] Mapping complete:",{executionPath:a,nodeExecutionsCount:s.size,nodeExecutions:Array.from(s.entries()).map(([j,k])=>{var b;return{nodeId:j,executionCount:k.length,latestStatus:(b=k[k.length-1])==null?void 0:b.status}})}),w}function nf(e,t){const[r,o]=m.useState([]),[s,a]=m.useState(!1),[i,l]=m.useState(null),d=m.useRef(null),c=m.useRef(0);return m.useEffect(()=>{if(o([]),l(null),c.current=0,!t){a(!1);return}let u=!0;const f=new AbortController;d.current=f,a(!0);const p=Ps(),g=()=>{u&&a(!1)},v=h=>{u&&(l(h instanceof Error?h.message:String(h)),a(!1))},y=h=>{if(u&&h!==void 0&&h!==null){const w=c.current++;let j;try{j=Ti(h,p)}catch{j=h}const k=typeof j=="string"?j:JSON.stringify(j,null,2);o(b=>[...b,{id:w,text:k}])}},N=async h=>{var k;let w=new Uint8Array(0);const j=b=>{const I=new Uint8Array(w.length+b.length);I.set(w,0),I.set(b,w.length),w=I};for(;!((k=d.current)!=null&&k.signal.aborted);){const{value:b,done:I}=await h.read();if(I){g();break}for(j(b);w.length>=4;){const C=new DataView(w.buffer,w.byteOffset,w.byteLength).getUint32(0,!1);if(w.length<4+C)break;const R=w.slice(4,4+C);w=w.slice(4+C);try{const D=Ci(R);y(D)}catch(D){console.error("Failed to decode stream chunk:",D)}}}};return(async()=>{try{const w=(await Bd(e,t,void 0,f.signal)).getReader();await N(w)}catch(h){if(f.signal.aborted)return;v(h)}})(),()=>{u=!1,d.current&&d.current.abort()}},[e,t]),{chunks:r,isLive:s,error:i}}function of({hasError:e,errorMessage:t}){return n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(ts,{children:[n.jsx(rs,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${e?"bg-red-500":"bg-green-500 animate-pulse"}`}),n.jsx("span",{className:`text-xs $
34
+ hasError
35
+ ? 'text-red-600 dark:text-red-400'
36
+ : 'text-muted-foreground'`,children:e?"Error":"Live"})]})}),n.jsx(ns,{children:n.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${Ei/1e3} seconds`})})]})})}function Fo(e){return e==="retrying"?"running":e}function sf({data:e,selected:t}){var o,s,a,i;const r=e;return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((o=r.nodeStyle)==null?void 0:o.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(s=r.nodeStyle)==null?void 0:s.backgroundColor,borderColor:((a=r.nodeStyle)==null?void 0:a.borderColor)??"#9ca3af",opacity:(i=r.nodeStyle)==null?void 0:i.opacity,boxShadow:t?"0 0 0 2px rgba(168, 85, 247, 0.5)":void 0},children:[r.label,n.jsx(nt,{type:"target",position:ot.Top,className:"!bg-purple-500"}),n.jsx(nt,{type:"source",position:ot.Bottom,className:"!bg-purple-500"}),n.jsx(nt,{type:"source",position:ot.Left,id:"loop-out",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"30%"}}),n.jsx(nt,{type:"target",position:ot.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})}function af({data:e,selected:t}){var a,i,l,d;const r=e,o=r.nodeKind==="workflow_start",s=r.nodeKind==="workflow_end";return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((a=r.nodeStyle)==null?void 0:a.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(i=r.nodeStyle)==null?void 0:i.backgroundColor,borderColor:((l=r.nodeStyle)==null?void 0:l.borderColor)??"#9ca3af",opacity:(d=r.nodeStyle)==null?void 0:d.opacity,boxShadow:t?"0 0 0 2px rgba(59, 130, 246, 0.35)":void 0},children:[r.label,!o&&n.jsx(nt,{type:"target",position:ot.Top,className:"!bg-muted"}),!s&&n.jsx(nt,{type:"source",position:ot.Bottom,className:"!bg-muted"})]})}function lf({data:e,selected:t}){var s,a,i;const r=e,o=160;return n.jsxs("div",{className:`relative flex items-center justify-center ${r.className||""}`,style:{width:o,height:o},children:[n.jsx("div",{style:{width:o*.7,height:o*.7,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:(s=r.nodeStyle)==null?void 0:s.backgroundColor,borderColor:((a=r.nodeStyle)==null?void 0:a.borderColor)??"#ef4444",opacity:(i=r.nodeStyle)==null?void 0:i.opacity,boxShadow:t?"0 0 0 2px rgba(239, 68, 68, 0.5)":void 0}}),n.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{fontSize:11,fontWeight:600,padding:o*.25},title:typeof r.label=="string"?r.label:void 0,children:n.jsx("span",{className:"text-center line-clamp-3 overflow-hidden",children:r.label})}),n.jsx(nt,{type:"target",position:ot.Top,className:"!bg-red-500"}),n.jsx(nt,{type:"source",position:ot.Bottom,id:"bottom",className:"!bg-red-500"}),n.jsx(nt,{type:"source",position:ot.Left,id:"left",className:"!bg-red-500"}),n.jsx(nt,{type:"source",position:ot.Right,id:"right",className:"!bg-red-500"})]})}const cf={loopNode:sf,parallelGroup:Ua,executionNode:af,diamondNode:lf},df=Va(Ja);function uf(e,t){const r=Xa(e);if(!t||t.length===0)return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:"#9ca3af",opacity:.4};const o=t[t.length-1];let s="#9ca3af",a=2;switch(o.status){case"completed":s="#22c55e";break;case"failed":s="#ef4444",a=3;break;case"running":s="#3b82f6",a=2;break;case"retrying":s="#f97316";break;case"cancelled":s="#eab308";break;case"pending":s="#9ca3af";break}return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:s,borderWidth:a}}function Po(e,t,r){const o=n.jsxs("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[n.jsx("div",{className:"flex-shrink-0",children:Za(e.nodeKind,e.label)}),n.jsx("span",{className:"text-sm font-medium break-words whitespace-normal leading-tight flex-1 min-w-0",children:e.label})]});if(!r||r.length===0)return o;const s=r[r.length-1],a=r.length,i=a>1;return i||s.duration&&s.duration>0?n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[o,n.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[i&&n.jsxs(wr,{variant:"outline",className:"text-xs px-1.5 py-0 border-orange-500 text-orange-700 dark:text-orange-300",children:["↻ ",a,"x"]}),s.duration&&s.duration>0&&n.jsxs(wr,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",At(s.duration,!0)]})]})]}):o}const Na={...qa};function Bo(e,t){var d,c,u;const{nodes:r,groupNodes:o}=Zo(e,Na),s=new Map,a=new Map;for(const f of o)f.id.startsWith("group_")&&a.set(f.id,f.position);for(const f of r){const p=(d=f.metadata)!=null&&d.parallelGroupId?`group_${f.metadata.parallelGroupId}`:null;p&&a.has(p)&&s.set(f.id,p)}const i=[],l=o.filter(f=>f.id.startsWith("group_"));for(const f of l)i.push({id:f.id,type:"parallelGroup",position:f.position,style:{...f.style,cursor:"grab",zIndex:-1},data:f.data,selectable:!0,draggable:!0});for(const f of r){const p=t==null?void 0:t.nodeExecutions.get(f.id),g=uf(f.data.nodeKind,p),v=(t==null?void 0:t.currentNode)===f.id,y=!!((c=f.metadata)!=null&&c.loopId),N=!!((u=f.metadata)!=null&&u.loopIsAwait),x=f.data.nodeKind==="conditional",h=x?"diamondNode":y?"loopNode":"executionNode",w=s.get(f.id);let j=f.position;if(w){const b=a.get(w);b&&(j={x:f.position.x-b.x,y:f.position.y-b.y})}const k=v?"animate-pulse-subtle":"";y?i.push({id:f.id,type:h,position:j,parentId:w,extent:w?"parent":void 0,expandParent:!0,data:{...f.data,label:Po(f.data,f.metadata,p),executions:p,isLoopNode:!0,isAwaitLoop:N,nodeStyle:g,className:k}}):x?i.push({id:f.id,type:h,position:j,parentId:w,extent:w?"parent":void 0,expandParent:!0,data:{...f.data,label:f.data.label,executions:p,nodeStyle:g,className:k}}):i.push({id:f.id,type:h,position:j,parentId:w,extent:w?"parent":void 0,expandParent:!0,data:{...f.data,label:Po(f.data,f.metadata,p),executions:p,nodeStyle:g,className:k},style:{width:220}})}return i}function zo(e,t){const{additionalEdges:r}=Zo(e,Na),s=[...e.edges.map(i=>i.type==="loop"?{...i,id:`loop_back_${i.source}_${i.target}`,isOriginal:!0}:{...i,isOriginal:!0}),...r.map(i=>({...i,isOriginal:!1}))];return Ya(s,e.nodes).map(i=>{if(i.type==="selfLoop")return{id:i.id,source:i.source,target:i.target,sourceHandle:i.sourceHandle,targetHandle:i.targetHandle,type:"selfLoop",label:i.label,markerEnd:{type:Wn.ArrowClosed,width:12,height:12,color:"#a855f7"}};let l=t==null?void 0:t.edgeTraversals.get(i.id);if(!l&&i.isConsolidated&&i.originalEdgeIds)for(const I of i.originalEdgeIds){const S=t==null?void 0:t.edgeTraversals.get(I);if(S&&S.traversalCount>0){l=S;break}}const d=l&&l.traversalCount>0,c=!!t,u=l!=null&&l.timings.length?l.timings.reduce((I,S)=>I+S,0)/l.timings.length:void 0;let f="bezier",p,g=i.label,v=!1;switch(i.type){case"parallel":f="smoothstep",p="4,4",g=void 0;break;case"loop":f="step",p="8,4";break;case"conditional":f="smoothstep",p="8,4",v=!0;break;default:f="bezier"}const N=d?"#22c55e":"#6b7280",x=d?void 0:p,h=c&&!d?.35:1,w=d?2.5:1,j=v?"#ffffff":"#6b7280",k=v?"#374151":"#f3f4f6",b=v?"#4b5563":"#d1d5db";return{id:i.id,source:i.source,target:i.target,type:f,animated:d&&(t==null?void 0:t.status)==="running",label:l&&l.traversalCount>1?n.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[n.jsxs(wr,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[l.traversalCount,"×"]}),u&&u>0&&n.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["~",At(u,!0)]})]}):g,labelStyle:{fill:j,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:k,fillOpacity:.95,stroke:b,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:Wn.ArrowClosed,width:d?14:10,height:d?14:10,color:N},style:{strokeWidth:w,stroke:N,opacity:h,strokeDasharray:x}}})}function ff({selectedNode:e,env:t,onClose:r}){const{node:o,executions:s,stepId:a,runId:i}=e,l=s[s.length-1],d=s.length>1,{data:c,loading:u}=Bs(t??{},"step",a??"",{runId:i}),f=(c==null?void 0:c.input)??(l==null?void 0:l.input),p=(c==null?void 0:c.output)??(l==null?void 0:l.output),g=(c==null?void 0:c.error)??(l==null?void 0:l.error);return n.jsxs("div",{className:"h-full flex flex-col bg-background border-l",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b flex-none",children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",title:o.data.label,children:o.data.label}),n.jsxs("div",{className:"flex items-center gap-2 flex-none",children:[(l==null?void 0:l.duration)!==void 0&&l.duration>0&&n.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:At(l.duration)}),n.jsx("div",{className:"w-px h-4 bg-border"}),n.jsx("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-muted transition-colors","aria-label":"Close panel",children:n.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})})]})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:[n.jsxs("div",{className:"flex flex-col divide-y rounded-lg border overflow-hidden mb-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"type"}),n.jsx("span",{className:"text-[11px] font-mono",children:o.data.nodeKind})]}),l&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"status"}),n.jsx(an,{status:Fo(l.status)})]}),l.duration!==void 0&&l.duration>0&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"duration"}),n.jsx("span",{className:"text-[11px] font-mono",children:At(l.duration)})]}),d&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"attempts"}),n.jsx("span",{className:"text-[11px] font-mono",children:s.length})]}),l.startedAt&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"startedAt"}),n.jsx("span",{className:"text-[11px] font-mono",children:new Date(l.startedAt).toLocaleString()})]}),l.completedAt&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"completedAt"}),n.jsx("span",{className:"text-[11px] font-mono",children:new Date(l.completedAt).toLocaleString()})]})]})]}),u&&a&&n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[n.jsx(kr,{className:"h-3 w-3 animate-spin"}),n.jsx("span",{children:"Loading step data..."})]}),f!==void 0&&n.jsxs("details",{className:"group mb-3",children:[n.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[n.jsx("span",{className:"font-medium",children:"Input"}),n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Array.isArray(f)?f.length:1," args)"]})]}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:n.jsx("code",{children:JSON.stringify(f,null,2)})})]})]}),p!==void 0&&n.jsxs("details",{className:"group mb-3",children:[n.jsx("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:n.jsx("span",{className:"font-medium",children:"Output"})}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:n.jsx("code",{children:JSON.stringify(p,null,2)})})]})]}),g&&n.jsxs("details",{className:"group mb-3",open:!0,children:[n.jsx("summary",{className:"cursor-pointer rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 px-2.5 py-1.5 text-xs hover:brightness-95",children:n.jsx("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error"})}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-red-300"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-red-300"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border border-red-200 p-2.5 bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300 whitespace-pre-wrap max-h-64 overflow-y-auto",children:n.jsx("code",{children:typeof g=="object"?JSON.stringify(g,null,2):String(g)})})]})]}),d&&n.jsxs("details",{className:"group",children:[n.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[n.jsx("span",{className:"font-medium",children:"Attempt History"}),n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",s.length," attempts)"]})]}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",children:s.map(v=>n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-[11px]",children:[n.jsxs("span",{className:"text-muted-foreground",children:["Attempt ",v.attemptNumber]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(an,{status:Fo(v.status)}),v.duration!==void 0&&v.duration>0&&n.jsx("span",{className:"font-mono text-muted-foreground",children:At(v.duration)})]})]},v.attemptNumber))})]})]})]})]})}function mf({workflow:e,execution:t,env:r,onNodeClick:o}){const[s,a]=m.useState(null),i=320,l=m.useMemo(()=>Bo(e,t),[e,t]),d=m.useMemo(()=>zo(e,t),[e,t]),[c,u,f]=za(l),[p,g,v]=Wa(d);m.useEffect(()=>{u(x=>{const h=Bo(e,t),w=new Map(x.map(j=>[j.id,j.position]));return h.map(j=>({...j,position:w.get(j.id)??j.position}))}),g(zo(e,t))},[e,t,u,g]);const y=m.useCallback((x,h)=>{const w=e.nodes.find(j=>j.id===h.id);if(w){const j=h.data.executions||[],k=j[j.length-1];a({nodeId:h.id,node:w,executions:j,stepId:k==null?void 0:k.stepId,runId:t==null?void 0:t.runId}),o&&j.length>0&&o(h.id,j)}},[e.nodes,t==null?void 0:t.runId,o]),N=m.useCallback(()=>{a(null)},[]);return n.jsxs("div",{className:"h-full w-full border rounded-lg bg-background relative overflow-hidden flex",children:[n.jsx("div",{className:"h-full flex-1 min-w-0",style:{width:s?`calc(100% - ${i}px)`:"100%"},children:n.jsxs($a,{nodes:c,edges:p,onNodesChange:f,onEdgesChange:v,onNodeClick:y,nodeTypes:cf,edgeTypes:df,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[n.jsx(Ga,{}),n.jsx(Ka,{}),n.jsx(zn,{position:"top-left",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-2 text-xs",children:n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("div",{className:"font-semibold text-[10px] text-muted-foreground mb-1",children:"Status"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-green-500 bg-background"}),n.jsx("span",{children:"Completed"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-red-500 bg-background"}),n.jsx("span",{children:"Failed"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-blue-500 bg-background"}),n.jsx("span",{children:"Running"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-yellow-500 bg-background"}),n.jsx("span",{children:"Cancelled"})]}),n.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-gray-400 bg-background"}),n.jsx("span",{children:"Pending"})]})]})}),t&&n.jsxs(zn,{position:"top-right",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-3 text-xs space-y-1.5",children:[n.jsx("div",{className:"font-semibold text-sm",children:"Execution"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:"Status:"}),n.jsx(wr,{variant:t.status==="completed"?"default":t.status==="failed"?"destructive":t.status==="cancelled"?"outline":"secondary",className:"text-xs",children:t.status})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:"Progress:"}),n.jsxs("span",{className:"font-mono",children:[t.executionPath.length," / ",e.nodes.length]})]})]})]})}),s&&n.jsx("div",{className:"h-full flex-none",style:{width:i},children:n.jsx(ff,{selectedNode:s,env:r,onClose:N})})]})}function pf({run:e,allSteps:t,allEvents:r,env:o}){const{manifest:s,loading:a,error:i}=li(),l=m.useMemo(()=>{var g;if(!s||!e.workflowName)return null;const c=String(e.workflowName).trim(),u=s.workflows[c];if(u)return u;const f=(g=bt(c))==null?void 0:g.shortName;return Object.values(s.workflows).find(v=>{var y;return v.workflowId===c||v.workflowName===c?!0:f?((y=bt(v.workflowName))==null?void 0:y.shortName)===f:!1})??null},[s,e.workflowName]),d=m.useMemo(()=>!l||!e.runId?null:rf(e,t||[],r||[],l),[l,e,t,r]);return a?n.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[n.jsx(kr,{className:"h-8 w-8 animate-spin text-muted-foreground"}),n.jsx("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):i?n.jsx("div",{className:"flex items-center justify-center w-full h-full p-4",children:n.jsxs(ln,{variant:"destructive",className:"max-w-lg",children:[n.jsx(cn,{className:"h-4 w-4"}),n.jsx(dn,{children:"Error Loading Workflow Graph"}),n.jsx(un,{children:i.message})]})}):l?n.jsx(mf,{workflow:l,execution:d||void 0,env:o}):n.jsx("div",{className:"flex items-center justify-center w-full h-full",children:n.jsxs(ln,{className:"max-w-lg",children:[n.jsx(cn,{className:"h-4 w-4"}),n.jsx(dn,{children:"Workflow Graph Not Found"}),n.jsx(un,{children:"Could not find the workflow graph for this run. The workflow may have been deleted or the graph manifest may need to be regenerated."})]})})}const hf=new Set(["run_created","run_started","run_completed","run_failed","run_cancelled"]);function gf({runId:e,selectedId:t}){var Ke;const r=ja(),[o]=Vo(),{serverConfig:s}=Ai(),[a,i]=m.useState(!1),[l,d]=m.useState(!1),[c,u]=m.useState(!1),[f,p]=m.useState(!1),g=m.useMemo(()=>({}),[]),v=o.get("tab")||"trace",y=o.get("streamId"),N=m.useCallback(q=>{const Ie=new URLSearchParams(o.toString());for(const[ye,ke]of Object.entries(q))ke===null?Ie.delete(ye):Ie.set(ye,ke);r(`?${Ie.toString()}`,{preventScrollReset:!0})},[r,o]),x=m.useCallback(q=>{N(q==="trace"||q==="graph"?{tab:q,streamId:null}:{tab:q})},[N]),h=m.useCallback(q=>{N({streamId:q})},[N]),w=m.useCallback(q=>{N({tab:"streams",streamId:q})},[N]),j=m.useCallback(async(q,Ie)=>Qa(g,q,{correlationIds:[Ie]}),[g]),k=m.useCallback(async(q,Ie)=>{await ei(g,q,Ie)},[g]),b=m.useCallback(async q=>{if(!hf.has(q.eventType)&&q.correlationId){const{error:Oe,result:Ze}=await Ee(jr(g,q.correlationId,{sortOrder:"asc",limit:100,withData:!0}));if(Oe)throw Oe;const qe=Ze.data.find(ct=>ct.eventId===q.eventId),mt=qe?Se(qe):null;return mt&&"eventData"in mt?mt.eventData:null}const{error:ye,result:ke}=await Ee(Kt(g,q.runId,{sortOrder:"desc",limit:1e3,withData:!0}));if(ye)throw ye;let fe=ke.data.find(Oe=>Oe.eventId===q.eventId);if(!fe){const{error:Oe,result:Ze}=await Ee(Kt(g,q.runId,{sortOrder:"asc",limit:1e3,withData:!0}));if(Oe)throw Oe;fe=Ze.data.find(qe=>qe.eventId===q.eventId)}const Le=fe?Se(fe):null;return Le&&"eventData"in Le?Le.eventData:null},[g]),I=m.useCallback(async(q,Ie)=>{const{error:ye,result:ke}=await Ee(jr(g,q,{sortOrder:"asc",limit:100,withData:!0}));if(ye)throw ye;const fe=ke.data.find(Oe=>Oe.eventId===Ie),Le=fe?Se(fe):null;return Le&&"eventData"in Le?Le.eventData:null},[g]),S=s.backendId==="local"||s.backendId==="@workflow/world-local",{run:C,steps:R,hooks:D,events:B,loading:E,auxiliaryDataLoading:T,error:_,update:O,loadMoreTraceData:$,hasMoreTraceData:z,isLoadingMoreTraceData:V}=Fd(g,e,{live:!0}),P=C??{},[M,H]=m.useState(null),{data:J,loading:se,error:X}=Bs(g,(M==null?void 0:M.resource)??"run",(M==null?void 0:M.resourceId)??"",{runId:M==null?void 0:M.runId,enabled:!!(M!=null&&M.resource&&(M!=null&&M.resourceId)&&M.resource!=="hook")}),G=m.useCallback(q=>{H(q)},[]),{streams:Z,loading:A,error:W}=$d(g,e),{chunks:oe,isLive:ce,error:ie}=nf(g,y),Q=()=>{u(!0)},de=async()=>{if(!a)try{i(!0),u(!1),await ai(g,e),await O(),me.success("Run cancelled successfully")}catch(q){console.error("Failed to cancel run:",q),me.error("Failed to cancel run",{description:q instanceof Error?q.message:"An unknown error occurred"})}finally{i(!1)}},Ne=()=>{p(!0)},Ae=async()=>{if(!l)try{d(!0),p(!1);const q=await ii(g,P.runId);me.success("New run started successfully",{description:`Run ID: ${q}`}),r(`/run/${q}`)}catch(q){console.error("Failed to re-run workflow:",q),me.error("Failed to start new run",{description:q instanceof Error?q.message:"An unknown error occurred"})}finally{d(!1),p(!1)}};if(_&&!C)return n.jsxs(ln,{variant:"destructive",className:"m-4",children:[n.jsx(cn,{className:"h-4 w-4"}),n.jsx(dn,{children:"Error loading workflow run"}),n.jsx(un,{children:_.message})]});const je=(Ke=bt(P.workflowName))==null?void 0:Ke.shortName;return n.jsxs(n.Fragment,{children:[n.jsx(Eo,{open:c,onOpenChange:u,children:n.jsxs(Ao,{children:[n.jsxs(Ro,{children:[n.jsx(Mo,{children:"Cancel Workflow Run?"}),n.jsx(Lo,{children:"This will stop the workflow execution immediately, and no further steps will be executed. Partial workflow execution may occur. Are you sure you want to cancel the run?"})]}),n.jsxs(Do,{children:[n.jsx(Ho,{children:"Keep Running"}),n.jsx(_o,{onClick:de,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),n.jsx(Eo,{open:f,onOpenChange:p,children:n.jsxs(Ao,{children:[n.jsxs(Ro,{children:[n.jsx(Mo,{children:"Replay Run?"}),n.jsx(Lo,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),n.jsxs(Do,{children:[n.jsx(Ho,{children:"Cancel"}),n.jsx(_o,{onClick:Ae,children:"Replay Run"})]})]})}),n.jsxs("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[n.jsxs("div",{className:"flex-none space-y-4",children:[n.jsx(Wu,{children:n.jsxs($u,{children:[n.jsx(Oo,{children:n.jsx(Vu,{asChild:!0,children:n.jsx(ka,{to:"/",children:"Runs"})})}),n.jsx(Gu,{}),n.jsx(Oo,{children:n.jsx(Uu,{className:"font-mono text-xs",children:e})})]})}),n.jsxs("div",{className:"space-y-4 p-6 border rounded-lg",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsx("div",{className:"mb-4",children:n.jsx("h1",{className:"text-xl font-semibold",children:je||n.jsx(Ct,{className:"w-[260px] h-[28px]"})})}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(of,{hasError:!1,errorMessage:""}),n.jsx(ti,{env:g,runId:e,runStatus:P.status,events:B,eventsLoading:T,loading:E,onRerunClick:Ne,onCancelClick:Q,callbacks:{onSuccess:O}})]})]}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Status"}),P.status?n.jsx(an,{status:P.status,context:P}):n.jsx(Ct,{className:"w-[55px] h-[24px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Duration"}),n.jsx("div",{className:"text-xs",children:P.runId?P.startedAt?(()=>{const q=(P.completedAt?new Date(P.completedAt).getTime():Date.now())-new Date(P.startedAt).getTime(),Ie=Math.floor(q/1e3);if(Ie<60)return`${Ie}s`;const ye=Math.floor(Ie/60),ke=Ie%60;if(ye<60)return ke>0?`${ye}m ${ke}s`:`${ye}m`;const fe=Math.floor(ye/60),Le=ye%60;return Le>0?`${fe}h ${Le}m`:`${fe}h`})():"-":n.jsx(Ct,{className:"w-[60px] h-[20px]"})})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),P.runId?n.jsx(ri,{text:P.runId,children:n.jsx("div",{className:"text-xs mt-0.5 font-mono",children:P.runId})}):n.jsx(Ct,{className:"w-[280px] h-[20px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Queued"}),P.createdAt?n.jsx("div",{className:"text-xs",children:n.jsx(lr,{date:P.createdAt})}):n.jsx(Ct,{className:"w-[110px] h-[20px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Started"}),n.jsx("div",{className:"text-xs",children:P.runId?P.startedAt?n.jsx(lr,{date:P.startedAt}):"-":n.jsx(Ct,{className:"w-[110px] h-[20px]"})})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Completed"}),n.jsx("div",{className:"text-xs",children:P.runId?P.completedAt?n.jsx(lr,{date:P.completedAt}):"-":n.jsx(Ct,{className:"w-[110px] h-[20px]"})})]}),P.expiredAt!=null&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs(ts,{children:[n.jsx(rs,{asChild:!0,children:n.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",n.jsx(Di,{className:"w-3 h-3"})]})}),n.jsx(ns,{children:n.jsx("p",{children:"The storage data for this run has expired and is no longer available."})})]}),n.jsx("div",{className:"text-xs",children:n.jsx(lr,{date:P.expiredAt})})]})]})]})]}),n.jsxs("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[n.jsxs(ni,{value:v,onValueChange:q=>x(q),className:"flex-1 flex flex-col min-h-0",children:[n.jsxs(oi,{className:"mb-4 flex-none",children:[n.jsxs(cr,{value:"trace",className:"gap-2",children:[n.jsx(Kr,{className:"h-4 w-4"}),"Trace"]}),S&&n.jsxs(cr,{value:"graph",className:"gap-2",children:[n.jsx(si,{className:"h-4 w-4"}),"Graph"]}),n.jsxs(cr,{value:"events",className:"gap-2",children:[n.jsx(Kr,{className:"h-4 w-4"}),"Events"]}),n.jsxs(cr,{value:"streams",className:"gap-2",children:[n.jsx(Kr,{className:"h-4 w-4"}),"Streams"]})]}),n.jsx(dr,{value:"trace",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ot,{title:"Failed to load trace viewer",children:n.jsx("div",{className:"h-full",children:n.jsx(Ad,{error:_,steps:R,events:B,hooks:D,run:P,isLoading:E,spanDetailData:J,spanDetailLoading:se,spanDetailError:X,onSpanSelect:G,onStreamClick:w,onWakeUpSleep:j,onResolveHook:k,onLoadEventData:I,onLoadMoreSpans:$,hasMoreSpans:z,isLoadingMoreSpans:V})})})}),n.jsx(dr,{value:"events",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ot,{title:"Failed to load events list",children:n.jsx("div",{className:"h-full",children:n.jsx(xc,{events:B,steps:R,run:P,onLoadEventData:b})})})}),n.jsx(dr,{value:"streams",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ot,{title:"Failed to load stream data",children:n.jsxs("div",{className:"h-full flex gap-4",children:[n.jsxs("div",{className:"w-64 flex-shrink-0 border rounded-lg overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-background-100)"},children:[n.jsxs("div",{className:"px-3 py-2 border-b text-xs font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)"},children:["Streams (",Z.length,")"]}),n.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:A?n.jsx("div",{className:"p-4 flex items-center justify-center",children:n.jsx(kr,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):W?n.jsx("div",{className:"p-4 text-xs text-destructive",children:W.message}):Z.length===0?n.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):Z.map(q=>n.jsx("button",{type:"button",onClick:()=>h(q),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:y===q?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:q,children:q},q))})]}),n.jsx("div",{className:"flex-1 min-w-0",children:y?n.jsx(Ri,{streamId:y,chunks:oe,isLive:ce,error:ie}):n.jsx("div",{className:"h-full flex items-center justify-center rounded-lg border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:n.jsx("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:Z.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),S&&n.jsx(dr,{value:"graph",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ot,{title:"Failed to load execution graph",children:n.jsx("div",{className:"h-full min-h-[500px]",children:n.jsx(pf,{run:P,allSteps:R,allEvents:B,env:g})})})})]}),T&&n.jsxs("div",{className:"fixed flex items-center gap-2 left-8 bottom-8 bg-background border rounded-md px-4 py-2 shadow-lg",children:[n.jsx(kr,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}const If=Sa(function(){const t=Ca(),[r]=Vo(),o=t.runId,s=r.get("stepId"),a=r.get("eventId"),i=r.get("hookId"),l=s||a||i||void 0;return n.jsx(Ot,{title:"Failed to load run details",children:n.jsx(gf,{runId:o,selectedId:l})})});export{If as default};