decocms 3.31.0 → 3.31.2

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 (249) hide show
  1. package/dist/client/assets/{AlertCircle-A2M1Yk61.js → AlertCircle-B4gYnOPQ.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-CjvxrowT.js → ArrowUpRight-D0kjnBU3.js} +1 -1
  3. package/dist/client/assets/{Check-Cl07asRj.js → Check-Cy2gwr8C.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-Ck9u9W7w.js → CheckCircle-CNdjtGTh.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-Ce3UdjOo.js → ChevronDown-3x5m66Bs.js} +1 -1
  6. package/dist/client/assets/{ChevronLeft-SeayBU0G.js → ChevronLeft-2_IuBsKu.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-C8KzXj8H.js → ChevronRight-CeIr4WsE.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-zA2iz0JQ.js → ChevronUp-Bh0YaH7H.js} +1 -1
  9. package/dist/client/assets/{Container-B3y5dlGc.js → Container-CYA7KoET.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-_g_anHKb.js → DotsVertical-FCIPj2jh.js} +1 -1
  11. package/dist/client/assets/{Eye-lcuSJE4l.js → Eye-BEaX-nOW.js} +1 -1
  12. package/dist/client/assets/{FilterLines-EpjZnXUA.js → FilterLines-PIiHcomo.js} +1 -1
  13. package/dist/client/assets/{Globe01-CfZP4vCY.js → Globe01-DCcLGAPs.js} +1 -1
  14. package/dist/client/assets/{HardDrive-75MAycL-.js → HardDrive-DF3wR4Ey.js} +1 -1
  15. package/dist/client/assets/{Key01-DyeMqFvi.js → Key01-DOICf9Yf.js} +1 -1
  16. package/dist/client/assets/{LayoutLeft-DwKLO_V_.js → LayoutLeft-XvA4efJR.js} +1 -1
  17. package/dist/client/assets/{LinkExternal01-r7kaLetr.js → LinkExternal01-kEaZ-3VP.js} +1 -1
  18. package/dist/client/assets/{Monitor01-C_pzVd4h.js → Monitor01-BQ2ab3I8.js} +1 -1
  19. package/dist/client/assets/{Palette-DdA_ILd6.js → Palette-BvgmCjcf.js} +1 -1
  20. package/dist/client/assets/{Play-CnkDDouZ.js → Play-CgnBFM99.js} +1 -1
  21. package/dist/client/assets/{Plus-Dx1SIiMT.js → Plus-CZoFo8m3.js} +1 -1
  22. package/dist/client/assets/{RefreshCcw01-C3I3Y9Tu.js → RefreshCcw01-CoOu-1-t.js} +1 -1
  23. package/dist/client/assets/{SearchMd-DFhUmylG.js → SearchMd-Cd3g9OHi.js} +1 -1
  24. package/dist/client/assets/{Settings02-CWkfxXGQ.js → Settings02-h4KhooA8.js} +1 -1
  25. package/dist/client/assets/{Shield01-CbvWDrmE.js → Shield01-CxluyAom.js} +1 -1
  26. package/dist/client/assets/{Star01-DkpG4lGE.js → Star01-BQu9_hS7.js} +1 -1
  27. package/dist/client/assets/{Stars01-CJ8FecuG.js → Stars01-D3E_UsFP.js} +1 -1
  28. package/dist/client/assets/{Stars02-bH2-rrrk.js → Stars02-DQPSVMUP.js} +1 -1
  29. package/dist/client/assets/{Sun-CLmK6D64.js → Sun-CGlOqn-C.js} +1 -1
  30. package/dist/client/assets/{SwitchHorizontal01-CDVzg25U.js → SwitchHorizontal01-DruCuOB9.js} +1 -1
  31. package/dist/client/assets/{Tool01-Cm1sVqXs.js → Tool01-DXZCxrW7.js} +1 -1
  32. package/dist/client/assets/{Trash01-CA4jg9ww.js → Trash01-CdVc63JX.js} +1 -1
  33. package/dist/client/assets/{Upload01-BbVOBYlS.js → Upload01-hFtvGOKc.js} +1 -1
  34. package/dist/client/assets/{User01-CMz2xYx2.js → User01-DkghkjfJ.js} +1 -1
  35. package/dist/client/assets/{Users01-DBOuOgB6.js → Users01-DSIM6pEW.js} +1 -1
  36. package/dist/client/assets/{Users03-DIxLvYmx.js → Users03-cwi85RQL.js} +1 -1
  37. package/dist/client/assets/{X-8-D5pATw.js → X-CiRjfhfc.js} +1 -1
  38. package/dist/client/assets/{XCircle-D0Uf6feY.js → XCircle-m30sBtwe.js} +1 -1
  39. package/dist/client/assets/{XClose-Cnj8fI9u.js → XClose-DEtxBka1.js} +1 -1
  40. package/dist/client/assets/{Zap-mYMK3ZBL.js → Zap-BqoFLQhx.js} +1 -1
  41. package/dist/client/assets/{ZapSquare-qMfSZ8L9.js → ZapSquare-88gaWy0c.js} +1 -1
  42. package/dist/client/assets/{ZoomOut-aYAC7hBe.js → ZoomOut-OQ9XVMLx.js} +1 -1
  43. package/dist/client/assets/{access-gate-daLhvTar.js → access-gate-DADwk2R8.js} +1 -1
  44. package/dist/client/assets/{accordion-Cm248afD.js → accordion-67DY3M-J.js} +1 -1
  45. package/dist/client/assets/add-section-modal-CAjwD6Pd.js +1 -0
  46. package/dist/client/assets/agent-capabilities-f1C_QUMa.js +3 -0
  47. package/dist/client/assets/{agent-icon-cetEWq0Z.js → agent-icon-DRs2sxx6.js} +1 -1
  48. package/dist/client/assets/{agent-icons-CK-xDflz.js → agent-icons-4ZuoYvOM.js} +2 -2
  49. package/dist/client/assets/{agents-list-Da1iRt5l.js → agents-list-BawKTAIq.js} +1 -1
  50. package/dist/client/assets/{ai-providers-BJhgs18P.js → ai-providers-Cw6JIdBf.js} +1 -1
  51. package/dist/client/assets/{alert-BBTJrkK5.js → alert-DvSgp-Ux.js} +1 -1
  52. package/dist/client/assets/{alert-dialog-DokKbPq-.js → alert-dialog-CvpxH7Lf.js} +2 -2
  53. package/dist/client/assets/app-editor-DFjSiVlG.js +1 -0
  54. package/dist/client/assets/{auth-catchall-CVFro2W9.js → auth-catchall-DYNGMvE3.js} +1 -1
  55. package/dist/client/assets/{auth-split-layout-Bsctr1_-.js → auth-split-layout-NbrrlaWV.js} +1 -1
  56. package/dist/client/assets/{automation-list-row-D23Bvwkx.js → automation-list-row-DUFXJruv.js} +1 -1
  57. package/dist/client/assets/{automation-runs-BMMJyRtq.js → automation-runs-CAmeSsSa.js} +1 -1
  58. package/dist/client/assets/{automations-DoosX3yK.js → automations-CgeuUTLU.js} +1 -1
  59. package/dist/client/assets/{avatar-Bg8Fajzf.js → avatar-CWn5LER_.js} +1 -1
  60. package/dist/client/assets/{badge-CWyTrVve.js → badge-CIMelj9a.js} +1 -1
  61. package/dist/client/assets/{brand-context-D5dCbA6y.js → brand-context-H1clX-er.js} +1 -1
  62. package/dist/client/assets/{buckets-C3jVEHjb.js → buckets-CC7y0QTv.js} +1 -1
  63. package/dist/client/assets/{calendar-D2buY6we.js → calendar-YPBFp_E0.js} +1 -1
  64. package/dist/client/assets/{capability-load-error-Co02--jW.js → capability-load-error-mbutkBah.js} +1 -1
  65. package/dist/client/assets/{card-BVDRUeiB.js → card-CPe96wry.js} +1 -1
  66. package/dist/client/assets/{chat-context-CpxV-LEc.js → chat-context-BjxJIMHx.js} +1 -1
  67. package/dist/client/assets/{checkbox-C0OD5DTK.js → checkbox-CMfBi1P9.js} +1 -1
  68. package/dist/client/assets/{cli-auth-success-pLKti1nS.js → cli-auth-success-DYhb7-ie.js} +1 -1
  69. package/dist/client/assets/{collection-detail-Bx5cx6Tv.js → collection-detail-BxKQrABJ.js} +1 -1
  70. package/dist/client/assets/{collection-display-button-Dpa_fFcT.js → collection-display-button-CT3gbaW0.js} +1 -1
  71. package/dist/client/assets/{collection-search-DHln9QoJ.js → collection-search-CR7VmYXP.js} +1 -1
  72. package/dist/client/assets/{collection-table-wrapper-CTiIT2dF.js → collection-table-wrapper-8RUKrDnB.js} +1 -1
  73. package/dist/client/assets/{collection-tabs-BaiyS1az.js → collection-tabs-DyRPz2M0.js} +1 -1
  74. package/dist/client/assets/{collections-Deko--Yp.js → collections-D3ATOWCI.js} +1 -1
  75. package/dist/client/assets/{command-3qLn4P52.js → command-DwAn8s0z.js} +1 -1
  76. package/dist/client/assets/{connect-desktop-dialog-BoRQM4OA.js → connect-desktop-dialog-CUd_SkHU.js} +1 -1
  77. package/dist/client/assets/{connection-card-ZCt-smg_.js → connection-card-0Tyv2fap.js} +1 -1
  78. package/dist/client/assets/{connection-detail-DipDTh4H.js → connection-detail-Ci7FJpsv.js} +1 -1
  79. package/dist/client/assets/{connection-form-helpers-B6JNJh-A.js → connection-form-helpers-Csat880R.js} +1 -1
  80. package/dist/client/assets/connections-CCuMprHu.js +1 -0
  81. package/dist/client/assets/decopilot-sse-pool-Qs-1EY0r.js +1 -0
  82. package/dist/client/assets/{dialog-BnOLdErK.js → dialog-BgALXZ6h.js} +1 -1
  83. package/dist/client/assets/{domain-settings-CwC_r-qt.js → domain-settings-AaPYLR4t.js} +1 -1
  84. package/dist/client/assets/{drawer-Be_zu0QX.js → drawer-DLAFbROZ.js} +1 -1
  85. package/dist/client/assets/{dropdown-menu-mHDT-XH7.js → dropdown-menu-uYsl4z-0.js} +1 -1
  86. package/dist/client/assets/{dynamic-plugin-layout-BGkekAkH.js → dynamic-plugin-layout-OZf-s4Vh.js} +1 -1
  87. package/dist/client/assets/{empty-state-CpfaS4oL.js → empty-state-CzSsahKD.js} +1 -1
  88. package/dist/client/assets/{empty-state-CeDRg4Pp.js → empty-state-DaQUj4WW.js} +1 -1
  89. package/dist/client/assets/{extract-connection-data-bN8kltS6.js → extract-connection-data-8yLRil2N.js} +1 -1
  90. package/dist/client/assets/{features-4Hsf4UEQ.js → features-BUlOTs5u.js} +1 -1
  91. package/dist/client/assets/file-explorer-1z_jfh76.js +2 -0
  92. package/dist/client/assets/{file-type-icon-DHQvk0za.js → file-type-icon-BI-57QdR.js} +1 -1
  93. package/dist/client/assets/{files-Bp_B54JG.js → files-CXNJllw8.js} +1 -1
  94. package/dist/client/assets/{form-C_FOfVah.js → form-BSWyFOE3.js} +1 -1
  95. package/dist/client/assets/{general-Dwpcwhzc.js → general-D0FEa5ER.js} +1 -1
  96. package/dist/client/assets/{generate-id-CQZwmjfI.js → generate-id-Cx2Cl6ns.js} +1 -1
  97. package/dist/client/assets/{github-repo-picker-Cd_kXw_v.js → github-repo-picker-DFc58L4T.js} +1 -1
  98. package/dist/client/assets/{header-tab-button-yQ_OLTia.js → header-tab-button-EU-XSa1F.js} +1 -1
  99. package/dist/client/assets/{hover-card-CHj7OURi.js → hover-card-B2Xe1JoR.js} +1 -1
  100. package/dist/client/assets/{image-field-D7PJzfsZ.js → image-field-D5MmzFT-.js} +1 -1
  101. package/dist/client/assets/index-8eGpjmNk.js +8 -0
  102. package/dist/client/assets/{index-bcXz_XDV.js → index-9-_G5hYz.js} +1 -1
  103. package/dist/client/assets/{index-DhrBeRkU.js → index-BHORPjEK.js} +1 -1
  104. package/dist/client/assets/{index-CXrzfY3D.js → index-BK9zbgCs.js} +1 -1
  105. package/dist/client/assets/{index-DHxOddsj.js → index-BPnG82q8.js} +3 -3
  106. package/dist/client/assets/index-B_KbH-mb.js +1 -0
  107. package/dist/client/assets/{index-CVroQ5fV.js → index-BpKJI7Dd.js} +1 -1
  108. package/dist/client/assets/{index-Cvm5sLsh.js → index-C0KuwIPp.js} +1 -1
  109. package/dist/client/assets/{index-D0AW3RJr.js → index-CUVr6lcg.js} +1 -1
  110. package/dist/client/assets/{index-DdL0ZJ74.js → index-CUWw06mX.js} +1 -1
  111. package/dist/client/assets/{index-Dw2PpfWw.js → index-CU_dpGl4.js} +1 -1
  112. package/dist/client/assets/{index-CR5thpY0.js → index-CYt0V3AS.js} +1 -1
  113. package/dist/client/assets/{index-C93oJ98C.js → index-DMmuIje2.js} +1 -1
  114. package/dist/client/assets/index-DaOT4XJB.js +1 -0
  115. package/dist/client/assets/{index-fYs9lCK5.js → index-Nndg_EdX.js} +19 -19
  116. package/dist/client/assets/{index-redirect-CNjnlL2S.js → index-redirect--1iDHaDV.js} +1 -1
  117. package/dist/client/assets/{input-C3YblD3D.js → input-Dp561wvu.js} +1 -1
  118. package/dist/client/assets/{integration-icon-DNnbE81S.js → integration-icon-CcFsasgm.js} +1 -1
  119. package/dist/client/assets/{label-g7a72jJD.js → label-BSaEPU5n.js} +1 -1
  120. package/dist/client/assets/{layout-Bac2NmXP.js → layout-DhLz9U2X.js} +1 -1
  121. package/dist/client/assets/{login-Dy8BMo_0.js → login-KELNaPBJ.js} +1 -1
  122. package/dist/client/assets/{members-DnAomETO.js → members-W8grzhWu.js} +1 -1
  123. package/dist/client/assets/monaco-editor-BR_tbU8a.js +9 -0
  124. package/dist/client/assets/{monitoring-stats-row-BXLdNMMZ.js → monitoring-stats-row-5K-iNny9.js} +1 -1
  125. package/dist/client/assets/{oauth-callback-1VcaC9dS.js → oauth-callback-8KL4StZE.js} +1 -1
  126. package/dist/client/assets/{oauth-callback-ai-provider-MiK5yD8w.js → oauth-callback-ai-provider-N8VomC_I.js} +1 -1
  127. package/dist/client/assets/{onboarding-BGq8QKH-.js → onboarding-DtdxPB0K.js} +1 -1
  128. package/dist/client/assets/{org-install-DZd3jGKm.js → org-install-D5FbkY3j.js} +1 -1
  129. package/dist/client/assets/{org-layout-BsR_SirN.js → org-layout-KSFpSPTk.js} +1 -1
  130. package/dist/client/assets/{org-plugin-layout-DiqJAM1g.js → org-plugin-layout-DJo1Z-Pr.js} +1 -1
  131. package/dist/client/assets/{page-seo-form-D30yiy8Q.js → page-seo-form-DJY-iA3B.js} +1 -1
  132. package/dist/client/assets/page-seo-sheet-BmGMfOzX.js +1 -0
  133. package/dist/client/assets/{pair-CV7DGW5V.js → pair-B6H2XHda.js} +6 -6
  134. package/dist/client/assets/{plugin-empty-state-rraryswS.js → plugin-empty-state-APGWpnYe.js} +1 -1
  135. package/dist/client/assets/{plugin-header-B1uUxTrr.js → plugin-header-CfyEfwUD.js} +1 -1
  136. package/dist/client/assets/{plugin-layout-DmiyMdB_.js → plugin-layout-Bu5dLcrn.js} +1 -1
  137. package/dist/client/assets/{popover-8cVh6gq0.js → popover-BYJBybY_.js} +1 -1
  138. package/dist/client/assets/{post-editor-C7P1dXNH.js → post-editor-CYVdmKp6.js} +2 -2
  139. package/dist/client/assets/{primitives-BsgolKyl.js → primitives-H10wZI-E.js} +1 -1
  140. package/dist/client/assets/{profile-D4w-Z3ol.js → profile-CRrSZ5vD.js} +1 -1
  141. package/dist/client/assets/project-app-view-Dy7VlptC.js +1 -0
  142. package/dist/client/assets/record-editor-BnPSQQYA.js +1 -0
  143. package/dist/client/assets/registry-CX-ET0zi.js +2 -0
  144. package/dist/client/assets/registry-layout-B7ptEXAi.js +27 -0
  145. package/dist/client/assets/{require-capability-skg99hPH.js → require-capability-C4c85-CT.js} +1 -1
  146. package/dist/client/assets/{required-auth-layout-Cidb--Hk.js → required-auth-layout-BApuEUpI.js} +1 -1
  147. package/dist/client/assets/{reset-password-CNhRvj5g.js → reset-password-CAbJ7zW-.js} +1 -1
  148. package/dist/client/assets/{resizable-BT48Uzms.js → resizable-D7pt8dup.js} +1 -1
  149. package/dist/client/assets/roles-xJLawXZj.js +1 -0
  150. package/dist/client/assets/save-referenced-block-ShdGpmDs.js +1 -0
  151. package/dist/client/assets/{save-status-DsIS1sld.js → save-status-oczKxF1W.js} +1 -1
  152. package/dist/client/assets/{schema-form-oJE4kcAX.js → schema-form-974itnxa.js} +1 -1
  153. package/dist/client/assets/{scroll-area-D2NfEZKG.js → scroll-area-DuFY4R5d.js} +1 -1
  154. package/dist/client/assets/{search-input-wg0ktmKr.js → search-input-DACBbzIk.js} +1 -1
  155. package/dist/client/assets/{secrets-YPZEWZE9.js → secrets-DMWeEvqW.js} +1 -1
  156. package/dist/client/assets/{sections-editor-CDk8QiTt.js → sections-editor-DM97T9Hx.js} +2 -2
  157. package/dist/client/assets/{select-LvZkQCcv.js → select-gqSNOxQD.js} +1 -1
  158. package/dist/client/assets/{select-model-Bvdn_l3a.js → select-model-CbdvfMbD.js} +1 -1
  159. package/dist/client/assets/seo-editor-BNi1XNxf.js +1 -0
  160. package/dist/client/assets/{settings-layout-Cn8PAm-f.js → settings-layout-XPdklskX.js} +1 -1
  161. package/dist/client/assets/{settings-section-BiebCtcC.js → settings-section-BgPOTco2.js} +1 -1
  162. package/dist/client/assets/{sheet-4GES45T2.js → sheet-J-5zCitH.js} +1 -1
  163. package/dist/client/assets/{shell-controls-pFVNS2Vn.js → shell-controls-BB8JT3cu.js} +1 -1
  164. package/dist/client/assets/{shell-layout-DtkuyxW9.js → shell-layout-B1bpQmja.js} +1 -1
  165. package/dist/client/assets/shell-route-loading-BL818aqT.js +1 -0
  166. package/dist/client/assets/{sidebar-BY-0S2nV.js → sidebar-DpznaqAr.js} +1 -1
  167. package/dist/client/assets/{skeleton-B2rX4p4v.js → skeleton-BrZY2U4q.js} +1 -1
  168. package/dist/client/assets/{sortable.esm-C0tZpwHI.js → sortable.esm-DAdL_KCM.js} +1 -1
  169. package/dist/client/assets/{spinner-WtoCvpNX.js → spinner-DWj9d3Oy.js} +1 -1
  170. package/dist/client/assets/{sso-4MYeJHQK.js → sso-_Gw_BXbF.js} +1 -1
  171. package/dist/client/assets/{store-BTeo8TpT.js → store-C4geYRDc.js} +1 -1
  172. package/dist/client/assets/store-registry-WC9BumXE.js +2 -0
  173. package/dist/client/assets/{studio-tools-CH7dZ7HT.js → studio-tools-YbndxaJx.js} +1 -1
  174. package/dist/client/assets/{switch-BOtiDaPh.js → switch-CWe9x1dO.js} +1 -1
  175. package/dist/client/assets/{tab-id-DaQY5Du1.js → tab-id-Bc_4nZgl.js} +1 -1
  176. package/dist/client/assets/{table-kq85oeWE.js → table-MDhW4B8D.js} +1 -1
  177. package/dist/client/assets/{tabs-D_XRbq3N.js → tabs-9ZkZ5CXu.js} +1 -1
  178. package/dist/client/assets/{task-status-BlpPmTT-.js → task-status-BNkxxOv6.js} +1 -1
  179. package/dist/client/assets/{textarea-CxRmk2pV.js → textarea-CimG5sWW.js} +1 -1
  180. package/dist/client/assets/{toggle-group-B_ZhC8rH.js → toggle-group-BqOsII08.js} +1 -1
  181. package/dist/client/assets/{toolbar-BptUton3.js → toolbar-oWPvqwRC.js} +1 -1
  182. package/dist/client/assets/{tools-list-BXxC0BJ6.js → tools-list-C2in0sGo.js} +1 -1
  183. package/dist/client/assets/{tooltip-6OktDyzD.js → tooltip-BwiZr2GD.js} +1 -1
  184. package/dist/client/assets/{types-k3mlT_jb.js → types-BYtVTpDQ.js} +1 -1
  185. package/dist/client/assets/{use-ai-providers-Czs3LwMV.js → use-ai-providers-B4z2G4rP.js} +1 -1
  186. package/dist/client/assets/{use-automations-6FHnA6mT.js → use-automations-Cgz4YKs5.js} +1 -1
  187. package/dist/client/assets/{use-capability-B2GMKCxl.js → use-capability-CtdbYGMh.js} +1 -1
  188. package/dist/client/assets/{use-clock-tick-DRfafiJJ.js → use-clock-tick-CPPdyWgW.js} +1 -1
  189. package/dist/client/assets/{use-collections-3gcbdMo5.js → use-collections-D52tQdGt.js} +1 -1
  190. package/dist/client/assets/{use-connection-Cygt3JAU.js → use-connection-DyyYYs8L.js} +1 -1
  191. package/dist/client/assets/{use-copy-BzO5OLbn.js → use-copy-BEZFUgho.js} +1 -1
  192. package/dist/client/assets/{use-create-virtual-mcp-BJIgmNjf.js → use-create-virtual-mcp-w-CGYLKc.js} +1 -1
  193. package/dist/client/assets/{use-debounced-autosave-rTdfYQSA.js → use-debounced-autosave-7GLgaJXq.js} +1 -1
  194. package/dist/client/assets/{use-delete-connection-BwHDAibo.js → use-delete-connection-6bfkbwg3.js} +1 -1
  195. package/dist/client/assets/{use-file-configs-C_uUU82K.js → use-file-configs-fZ_0pNgv.js} +1 -1
  196. package/dist/client/assets/use-infinite-scroll-D2-BvjXC.js +1 -0
  197. package/dist/client/assets/{use-list-state-CAT0PD89.js → use-list-state-BiQdeo-3.js} +1 -1
  198. package/dist/client/assets/{use-mcp-client-Bbkq-Btq.js → use-mcp-client-iXdxenz3.js} +1 -1
  199. package/dist/client/assets/{use-mcp-prompts-C2IR7B-B.js → use-mcp-prompts-BZ3M88pO.js} +1 -1
  200. package/dist/client/assets/{use-mcp-tools-BiO0x3bS.js → use-mcp-tools-BFte_Z9f.js} +1 -1
  201. package/dist/client/assets/{use-members-Ct7TKvLy.js → use-members-lO5UPidt.js} +1 -1
  202. package/dist/client/assets/{use-navigate-to-agent-7jnPTeCV.js → use-navigate-to-agent-DIjWe8In.js} +1 -1
  203. package/dist/client/assets/{use-org-auth-client-DwSMx4xq.js → use-org-auth-client-CjM9gfPH.js} +1 -1
  204. package/dist/client/assets/{use-org-sso-HULZXLZY.js → use-org-sso-Sk1A6q8-.js} +1 -1
  205. package/dist/client/assets/{use-organization-roles-C24SP1RJ.js → use-organization-roles-C5mxX9Rk.js} +1 -1
  206. package/dist/client/assets/{use-organization-settings-6ykeD7wG.js → use-organization-settings-MrnwSgAR.js} +1 -1
  207. package/dist/client/assets/{use-registry-connections-Cw0Uu9HN.js → use-registry-connections-CC-YLphz.js} +1 -1
  208. package/dist/client/assets/{use-secrets-Dn7Z2olr.js → use-secrets-CajEM27b.js} +1 -1
  209. package/dist/client/assets/{use-status-sounds-BMl-h7wF.js → use-status-sounds-BwNN0Dt-.js} +1 -1
  210. package/dist/client/assets/{use-view-mode-DS8kaEq4.js → use-view-mode-B5-wFbmS.js} +1 -1
  211. package/dist/client/assets/{use-virtual-mcp-C6pMpGrR.js → use-virtual-mcp-Cw_yVFMO.js} +1 -1
  212. package/dist/client/assets/useInfiniteQuery-DHhL-q8j.js +1 -0
  213. package/dist/client/assets/{useRouterState-Dnb9kW5z.js → useRouterState-IhZ1SxRm.js} +1 -1
  214. package/dist/client/assets/useSuspenseInfiniteQuery-oHftqcSU.js +1 -0
  215. package/dist/client/assets/{user-TO91q8is.js → user-CJUwgqvV.js} +1 -1
  216. package/dist/client/assets/{view-mode-toggle-X2TTOWIg.js → view-mode-toggle-CMrO4dTZ.js} +1 -1
  217. package/dist/client/assets/{watch-sse-pool-CuN8_Ws2.js → watch-sse-pool-BZQA3Ki3.js} +1 -1
  218. package/dist/client/assets/{workflow-Bof_Hi_L.js → workflow-CrJS-2vt.js} +1 -1
  219. package/dist/client/assets/workflow-detail-CBOkNhJP.js +1 -0
  220. package/dist/client/index.html +1 -1
  221. package/dist/server/cli.js +387 -387
  222. package/dist/server/migrate.js +52 -52
  223. package/dist/server/server.js +265 -265
  224. package/package.json +1 -1
  225. package/dist/client/assets/add-section-modal-BEtlbcy-.js +0 -1
  226. package/dist/client/assets/agent-capabilities-CFuGvMed.js +0 -3
  227. package/dist/client/assets/app-editor-DqK_iwlT.js +0 -1
  228. package/dist/client/assets/connections-DzNM9iR8.js +0 -1
  229. package/dist/client/assets/decopilot-sse-pool-8baykh62.js +0 -1
  230. package/dist/client/assets/file-explorer-Bm3G3AJO.js +0 -2
  231. package/dist/client/assets/index-Bq-oI4jf.js +0 -8
  232. package/dist/client/assets/index-DeWy5Ckp.js +0 -1
  233. package/dist/client/assets/index-jA2TneF4.js +0 -1
  234. package/dist/client/assets/infiniteQueryObserver-Da-l1Mrb.js +0 -1
  235. package/dist/client/assets/monaco-editor-CVjkFUXK.js +0 -9
  236. package/dist/client/assets/page-seo-sheet-DHjVYqZY.js +0 -1
  237. package/dist/client/assets/project-app-view-MmHyDgpb.js +0 -1
  238. package/dist/client/assets/record-editor-LCb43Ehs.js +0 -1
  239. package/dist/client/assets/registry-DRQ1oW7y.js +0 -2
  240. package/dist/client/assets/registry-layout-C-3QWp3D.js +0 -27
  241. package/dist/client/assets/roles-9lGr_fMG.js +0 -1
  242. package/dist/client/assets/save-referenced-block-Uk3HPmEZ.js +0 -1
  243. package/dist/client/assets/seo-editor-CZ4NCpV7.js +0 -1
  244. package/dist/client/assets/shell-route-loading-B6fsTD_h.js +0 -1
  245. package/dist/client/assets/store-registry-B8aDVYEg.js +0 -2
  246. package/dist/client/assets/use-infinite-scroll-D7Lz32GP.js +0 -1
  247. package/dist/client/assets/useInfiniteQuery-DnxNK7B2.js +0 -1
  248. package/dist/client/assets/useSuspenseInfiniteQuery-Bdpr4GcQ.js +0 -1
  249. package/dist/client/assets/workflow-detail-xblJkXWm.js +0 -1
@@ -1,4 +1,4 @@
1
- import{e as $,j as t,q as J,b as he,G as ae,r as L,M as ke,J as Re,R as ie,n as xe,K as U,a as be,t as oe,o as D,B as se,c as V,l as Y,s as Ae,F as Oe}from"./index-DHxOddsj.js";import{b as Ge}from"./use-virtual-mcp-C6pMpGrR.js";import{k as le}from"./use-navigate-to-agent-7jnPTeCV.js";import{b as Le,u as ye}from"./use-connection-Cygt3JAU.js";import{W as Pe,u as H,a as ce}from"./use-mcp-client-Bbkq-Btq.js";import{D as we,a as Ce,b as Ie,c as Ne,d as $e}from"./dialog-BnOLdErK.js";import{i as ue}from"./RefreshCcw01-C3I3Y9Tu.js";import{C as je}from"./collection-search-DHln9QoJ.js";import{C as pe}from"./checkbox-C0OD5DTK.js";import{n as He}from"./agent-icon-cetEWq0Z.js";import{u as Me}from"./use-mcp-tools-BiO0x3bS.js";import{e as De}from"./extract-connection-data-bN8kltS6.js";const Ue=`<svg width="74" height="84" viewBox="0 0 74 84" fill="none" xmlns="http://www.w3.org/2000/svg">
1
+ import{e as $,j as t,q as J,b as he,G as ae,r as L,M as ke,J as Re,R as ie,n as xe,K as U,a as be,t as oe,o as D,B as se,c as V,l as Y,s as Ae,F as Oe}from"./index-BPnG82q8.js";import{b as Ge}from"./use-virtual-mcp-Cw_yVFMO.js";import{k as le}from"./use-navigate-to-agent-DIjWe8In.js";import{b as Le,u as ye}from"./use-connection-DyyYYs8L.js";import{W as Pe,u as H,a as ce}from"./use-mcp-client-iXdxenz3.js";import{D as we,a as Ce,b as Ie,c as Ne,d as $e}from"./dialog-BgALXZ6h.js";import{i as ue}from"./RefreshCcw01-CoOu-1-t.js";import{C as je}from"./collection-search-CR7VmYXP.js";import{C as pe}from"./checkbox-CMfBi1P9.js";import{n as He}from"./agent-icon-DRs2sxx6.js";import{u as Me}from"./use-mcp-tools-BFte_Z9f.js";import{e as De}from"./extract-connection-data-8yLRil2N.js";const Ue=`<svg width="74" height="84" viewBox="0 0 74 84" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <path d="M63.4462 15.3005C63.1414 15.2764 57.2333 15.1845 57.2333 15.1845C57.2333 15.1845 52.2906 10.3849 51.8019 9.89426C51.6127 9.71981 51.3729 9.60981 51.1172 9.58008V83.0253L73.2664 77.5175C73.2664 77.5175 64.2277 16.3953 64.1696 15.9772C64.1417 15.7997 64.055 15.6366 63.9235 15.5139C63.7919 15.3913 63.6255 15.3162 63.4462 15.3005Z" fill="#171717"/>
3
3
  <path fill-rule="evenodd" clip-rule="evenodd" d="M32.748 0.00356357C34.8334 -0.0568526 36.5759 0.651298 37.9307 2.10122C38.0276 2.20613 38.1209 2.31463 38.2109 2.42544L38.2354 2.42349C38.4434 2.40657 38.6494 2.38638 38.8574 2.38638H38.8672C41.9831 2.3913 44.5571 4.16796 46.3184 7.527C46.8023 8.4621 47.2004 9.43976 47.5068 10.4469L49.9883 9.67837C50.3609 9.56961 51.315 9.42163 51.8037 9.90981L51.9922 82.3883L51.1162 83.0387L0 74.1979C0.0195597 74.0466 6.09952 27.0238 6.3291 25.3629C6.63636 23.1661 6.70922 23.0933 9.03906 22.361L16.957 19.9079C17.4531 16.377 19.1884 11.8165 21.4746 8.18423C24.7237 3.02487 28.7273 0.119714 32.748 0.00356357ZM38.8408 26.7077C38.8133 26.694 36.5926 25.6009 32.2842 25.8747C21.032 26.5853 15.9341 34.4515 16.4229 42.2213C17.0059 51.4485 26.2283 51.1199 26.584 56.734C26.6686 58.0922 25.8271 60.0114 23.4658 60.1588C19.8562 60.3883 15.3438 56.9831 15.3438 56.9831L13.6191 64.3249C13.6191 64.3249 18.1021 69.1296 26.2432 68.6149C33.027 68.1895 37.7351 62.759 37.2344 54.8249C36.5981 44.7397 25.2729 43.7966 25.002 39.4948C24.9512 38.7038 25.0055 35.556 29.9932 35.2418C33.3786 35.0279 36.2354 36.3195 36.2666 36.3336L38.8408 26.7077ZM32.8262 2.6813C26.6181 2.86014 21.2028 12.5587 19.8213 19.0211L26.8311 16.8512C27.6101 12.7476 29.5648 8.48928 32.1221 5.74868C33.0162 4.76667 34.0719 3.94401 35.2432 3.31704H35.2451C34.5654 2.87005 33.7695 2.66203 32.8262 2.6813ZM36.9775 5.46548C35.7921 5.95366 34.7952 6.80972 34.0791 7.57583C32.1608 9.63716 30.5951 12.7807 29.7725 15.9391L38.3057 13.2956C38.3322 11.0721 38.0904 7.7854 36.9775 5.46548ZM39.7568 5.14907C40.7052 7.59721 40.9505 10.4321 40.9795 12.4694L44.9473 11.2389C44.3133 9.17981 42.8075 5.72907 39.7568 5.14907Z" fill="#393939"/>
4
4
  </svg>`,Fe=`data:image/svg+xml,${encodeURIComponent(Ue)}`,Nt={title:"New Website",description:"Website cloned from a public template",url:"https://github.com/decocms/webapp-template",owner:"decocms",name:"webapp-template"},jt={title:"Shopify Headless Store",description:"Shopify Headless Store cloned from a public template",url:"https://github.com/Shopify/hydrogen-demo-store",owner:"Shopify",name:"hydrogen-demo-store",icon:Fe};function St(){const o=$.c(6),e=Ge(),n=le();let s;o[0]!==e.create||o[1]!==n?(s=async r=>{const f=await e.create.mutateAsync({title:r.title,description:r.description,icon:r.icon??null,status:"active",pinned:!1,connections:[],metadata:{githubRepo:{url:r.url,owner:r.owner,name:r.name},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"},chatDefaultOpen:!0}}}});return f.id&&n(f.id),f},o[0]=e.create,o[1]=n,o[2]=s):s=o[2];const l=s;let i;return o[3]!==e.create.isPending||o[4]!==l?(i={createFromTemplate:l,isCreating:e.create.isPending},o[3]=e.create.isPending,o[4]=l,o[5]=i):i=o[5],i}function F(o){const e=$.c(4),{size:n,className:s}=o;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z"}),e[0]=l):l=e[0];let i;return e[1]!==s||e[2]!==n?(i=t.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:s,children:l}),e[1]=s,e[2]=n,e[3]=i):i=e[3],i}function ze(o,e){const n=$.c(12),{org:s}=J();let l;n[0]!==s.id?(l=Pe.REGISTRY(s.id),n[0]=s.id,n[1]=l):l=n[1];const i=l;let r;n[2]!==s.id||n[3]!==s.slug||n[4]!==i?(r={connectionId:i,orgId:s.id,orgSlug:s.slug},n[2]=s.id,n[3]=s.slug,n[4]=i,n[5]=r):r=n[5];const f=H(r);let b;n[6]!==o?(b={name:o},n[6]=o,n[7]=b):b=n[7];const a=e?.enabled??!0;let C;return n[8]!==f||n[9]!==b||n[10]!==a?(C={client:f,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:b,enabled:a,staleTime:3e5,select:qe},n[8]=f,n[9]=b,n[10]=a,n[11]=C):C=n[11],Me(C)}function qe(o){return o.structuredContent?.item??null}const Be="deco/mcp-github";function Se(o){const{org:e}=J(),{data:n}=he.useSession(),s=Le(),l=ae(),[i,r]=L.useState("idle"),[f,b]=L.useState(null),[a,C]=L.useState(null),{data:h,isLoading:m}=ze(Be,{enabled:o.enabled}),x=L.useRef(!1);o.enabled&&h&&!m&&!x.current&&n?.user?.id&&i==="idle"&&(x.current=!0,N());async function N(){if(!(!h||!n?.user?.id||!e))try{r("installing"),b(null);const p=De(h,e.id,n.user.id,{remoteIndex:0});if(!p.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:w}=await s.create.mutateAsync(p);r("authenticating");const j=new URL(`/api/${e.slug}/mcp/${w}`,window.location.origin),d=await ke({url:j.href,token:null,orgId:e.id});if(d.supportsOAuth&&!d.isAuthenticated){const{token:S,tokenInfo:c,error:v}=await Re({connectionId:w,orgSlug:e.slug,scope:"offline_access"});if(v||!S){try{await s.delete.mutateAsync(w)}catch{}throw new Error(v??"No token received from GitHub")}if(c)try{(await fetch(`/api/${e.slug}/connections/${w}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:c.accessToken,refreshToken:c.refreshToken,expiresIn:c.expiresIn,scope:c.scope,clientId:c.clientId,clientSecret:c.clientSecret,tokenEndpoint:c.tokenEndpoint})})).ok||await s.update.mutateAsync({id:w,data:{connection_token:S}})}catch{await s.update.mutateAsync({id:w,data:{connection_token:S}})}}ie(l,e.id),C(p),r("ready")}catch(p){b(p instanceof Error?p.message:String(p)),r("error")}}function y(){r("idle"),b(null),C(null),x.current=!1}return o.enabled&&m&&i==="idle"?{status:"installing",error:null,connection:null,retry:y}:{status:i,error:f,connection:a,retry:y}}const Ve="deco-sites";function Ke(o){if(!o||typeof o!="object")return null;const e=o.github;if(!e||typeof e!="object")return null;const n=e.owner,s=e.repo;return typeof n!="string"||typeof s!="string"||n.length===0||s.length===0?null:{owner:n,repo:s}}function Qe(o,e){const n=e?Ke(e):null,s=n?.owner??Ve,l=n?.repo??o;return{owner:s,name:l,url:`https://github.com/${s}/${l}`}}const K={contents:"write",metadata:"read",pull_requests:"write",issues:"write"};function Je(o){if(!o||typeof o!="object"||Array.isArray(o))return K;const e=o;return Object.values(e).some(n=>typeof n!="string")?K:e}function Ye(o){if(!(typeof o!="number"||!Number.isFinite(o)||!Number.isInteger(o)||o<=0))return o}function We(o){const e=o.metadata?.repoScope;if(!e||typeof e.installationId!="number"||!Number.isFinite(e.installationId)||!Number.isInteger(e.installationId)||e.installationId<=0||typeof e.owner!="string"||typeof e.repo!="string"||e.owner.length===0||e.repo.length===0)return null;const n=Ye(e.repositoryId);return{sourceConnectionId:typeof e.sourceConnectionId=="string"?e.sourceConnectionId:void 0,installationId:e.installationId,repositoryId:n,owner:e.owner,repo:e.repo,permissions:Je(e.permissions),grantProvider:e.grantProvider==="github-mcp"?"github-mcp":void 0}}function ve(o){return(o??[]).filter(e=>We(e)===null)}async function Ee(o,e){const s=(await o({name:"GITHUB_LIST_USER_ORGS",arguments:{connectionId:e}})).content?.[0]?.text;if(!s)throw new Error("No response from GITHUB_LIST_USER_ORGS");try{return JSON.parse(s)}catch{throw new Error("Invalid response from GITHUB_LIST_USER_ORGS")}}function Ze(o,e){const n=e.toLowerCase();return o.find(s=>s.login.toLowerCase()===n)}const ge="GitHub MCP did not return refreshable repo grant metadata";function q(o){if(typeof o!="string")return null;const e=o.trim();return e.length>0?e:null}function Xe(o){try{const e=new URL(o);return(e.protocol==="http:"||e.protocol==="https:")&&!e.username&&!e.password}catch{return!1}}function et(o){return typeof o=="number"&&Number.isFinite(o)&&Number.isInteger(o)&&o>0?o:void 0}async function Te(o){const{orgSlug:e,sourceConnection:n,installationId:s,owner:l,repo:i,githubCallTool:r,selfCallTool:f}=o,b=await r({name:"MINT_REPO_TOKEN",arguments:{installationId:s,owner:l,repo:i,permissions:K}}),a=b.structuredContent;if(b.isError||!a?.token){const A=b.content?.find(T=>T.type==="text")?.text;throw new Error(A?`Failed to mint a repo-scoped GitHub token: ${A}`:"Failed to mint a repo-scoped GitHub token")}const C=q(a.refreshToken),h=q(a.tokenEndpoint),m=q(a.clientId);if(!C||!h||!m)throw new Error(ge);if(!Xe(h))throw new Error(ge);const x=q(a.repository?.owner),N=q(a.repository?.name),y="GitHub MCP returned refresh metadata for a different repository";if(a.repository?.owner!==void 0&&(!x||x.toLowerCase()!==l.toLowerCase()))throw new Error(y);if(a.repository?.name!==void 0&&(!N||N.toLowerCase()!==i.toLowerCase()))throw new Error(y);const p=et(a.repository?.id),I=a.expiresAt?Date.parse(a.expiresAt):NaN,w=Number.isFinite(I)?Math.max(0,Math.floor((I-Date.now())/1e3)):null,d=(typeof a.expiresIn=="number"&&Number.isFinite(a.expiresIn)&&Number.isInteger(a.expiresIn)&&a.expiresIn>0?a.expiresIn:null)??w,S=await f({name:"COLLECTION_CONNECTIONS_CREATE",arguments:{data:{title:`GitHub: ${l}/${i}`,description:`Repo-scoped GitHub access for ${l}/${i}`,icon:n.icon,app_name:n.app_name,app_id:n.app_id,connection_type:n.connection_type,connection_url:n.connection_url,metadata:{repoScope:{installationId:s,repositoryId:p,owner:l,repo:i,permissions:K,grantProvider:"github-mcp"}}}}}),c=S.structuredContent??S,v=c.item?.id??c.id;if(!v)throw new Error("Failed to create the repo-scoped GitHub connection");if(!(await fetch(`/api/${e}/connections/${v}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:a.token,refreshToken:C,expiresIn:d,scope:a.scope??null,clientId:m,tokenEndpoint:h})})).ok)throw await f({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:v,force:!0}}).catch(()=>{}),new Error("Failed to persist the repo-scoped token");return{childConnectionId:v}}function tt(o){return o.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function nt(o){const e=await fetch(`/api/${o}/deco-sites`);if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.error??`Failed to load sites (${e.status})`)}return e.json()}function vt({open:o,onOpenChange:e,onBack:n}){const{org:s}=J(),l=le(),i=ae(),{data:r}=he.useSession(),[f,b]=L.useState(null),[a,C]=L.useState(null),[h,m]=L.useState(""),x=H({connectionId:ce,orgId:s.id,orgSlug:s.slug}),N=ye({slug:"mcp-github"}),y=ve(N),p=Se({enabled:o&&y.length===0}),I=y.length===1?y[0]??null:a,w=y.length>1&&!I,j=H({connectionId:I?.id??"",orgId:s.id,orgSlug:s.slug}),d=o&&y.length===0&&(p.status==="installing"||p.status==="authenticating"||p.status==="idle"),{data:S,isLoading:c,error:v}=xe({queryKey:U.decoSites(r?.user?.email),queryFn:()=>nt(s.slug),enabled:o&&!!r?.user?.email,staleTime:6e4,retry:!1}),O=S?.sites??[],A=u=>{u||(b(null),C(null),m("")),e(u)},T=O.filter(u=>u.name.toLowerCase().includes(h.toLowerCase())||(u.domains?.[0]?.domain?.toLowerCase().includes(h.toLowerCase())??!1)),g=!f||T.some(u=>u.name===f),k=be({mutationFn:async u=>{if(!I)throw new Error("GitHub is not connected. Complete GitHub setup and try again.");oe("deco_site_import_started",{site_name:u});const{installations:R,appSlug:_}=await Ee(P=>x.callTool(P),I.id),G=O.find(P=>P.name===u);if(!G)throw new Error("Selected site is no longer available");const E=Qe(u,G.metadata),z=Ze(R,E.owner);if(!z){const P=_?`https://github.com/apps/${_}/installations/new`:"https://github.com/settings/installations";throw new Error(`Install the GitHub App on the "${E.owner}" organization to import this site. ${P}`)}let W=null,Z=null,X=null;const _e=async()=>{X&&await x.callTool({name:"COLLECTION_VIRTUAL_MCP_DELETE",arguments:{id:X}}).catch(()=>{}),Z&&await x.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:Z,force:!0}}).catch(()=>{}),W&&await x.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:W,force:!0}}).catch(()=>{})};try{const P=await fetch(`/api/${s.slug}/deco-sites/connection`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:u})}),ee=await P.json().catch(()=>({}));if(!P.ok)throw new Error(ee.error??`Failed to create connection (${P.status})`);const M=ee.connId;if(!M)throw new Error("Server did not return a connection ID");W=M;const{childConnectionId:te}=await Te({orgSlug:s.slug,sourceConnection:I,installationId:z.installationId,owner:E.owner,repo:E.name,githubCallTool:ne=>j.callTool(ne),selfCallTool:ne=>x.callTool(ne)});Z=te;const de=ee.icon??null,me=tt(u),fe=await x.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:u,description:"Imported from deco.cx",pinned:!1,icon:de??null,subtype:"project",metadata:{instructions:null,enabled_plugins:[],githubRepo:{owner:E.owner,name:E.name,url:E.url,installationId:z.installationId,connectionId:te},ui:{banner:null,bannerColor:"#22C55E",icon:de,themeColor:"#22C55E",slug:me,pinnedViews:[{connectionId:M,toolName:"fetch_assets",label:"Assets",icon:null},{connectionId:M,toolName:"get_monitor_data",label:"Monitor",icon:null}],layout:{defaultMainView:{type:"preview"},chatDefaultOpen:!0}}},connections:[{connection_id:M},{connection_id:te}]}}}),B=fe.structuredContent??fe;if(!B.item?.id)throw new Error("Failed to create the imported agent");return X=B.item.id,{slug:me,virtualMcpId:B.item.id,connId:M,item:B.item}}catch(P){throw await _e(),P}},onSuccess:({slug:u,virtualMcpId:R,item:_})=>{oe("deco_site_import_succeeded",{site_name:_.title,virtual_mcp_id:R,slug:u}),i.setQueryData(U.collectionItem(x,s.id,"","VIRTUAL_MCP",R),{item:_}),i.invalidateQueries({predicate:G=>{const E=G.queryKey;return E[1]===s.id&&E[3]==="collection"&&E[4]==="VIRTUAL_MCP"}}),i.invalidateQueries({queryKey:U.projects(s.id)}),D.success(`Imported ${u} from deco.cx`),A(!1),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),l(R)},onError:u=>{oe("deco_site_import_failed",{error:u instanceof Error?u.message:"Unknown error"}),D.error("Import failed: "+(u instanceof Error?u.message:"Unknown error"))}});return t.jsx(we,{open:o,onOpenChange:A,children:t.jsxs(Ce,{className:"sm:max-w-[900px] p-0 gap-0 overflow-hidden",children:[t.jsx(Ie,{className:"sr-only",children:t.jsx(Ne,{children:"Import from deco.cx"})}),t.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3",children:[n&&t.jsx("button",{type:"button",onClick:n,className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors","aria-label":"Go back",children:t.jsx(ue,{size:18})}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Import from deco.cx"})]}),t.jsx("div",{children:t.jsx(je,{value:h,onChange:m,placeholder:"Search sites...",onKeyDown:u=>{u.key==="Escape"&&m("")}})}),t.jsxs("div",{className:"pb-0 min-h-[300px]",children:[p.status==="error"&&t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-48 px-8 text-center",children:[t.jsx("p",{className:"text-sm text-destructive",children:p.error??"Failed to connect GitHub"}),t.jsx(se,{variant:"outline",size:"sm",onClick:p.retry,children:"Retry GitHub setup"})]}),d&&p.status!=="error"&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"Setting up GitHub connection..."}),w&&!d&&p.status!=="error"&&t.jsxs("div",{className:"flex flex-col py-2",children:[t.jsx("div",{className:"px-8 py-2",children:t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Select a GitHub connection"})}),y.map(u=>t.jsxs("button",{type:"button",onClick:()=>C(u),className:"flex items-center gap-3 px-8 py-3 hover:bg-accent transition-colors text-left",children:[u.icon?t.jsx("img",{src:u.icon,alt:u.title,className:"size-7 rounded-full shrink-0"}):t.jsx("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center shrink-0",children:t.jsx(F,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:u.title})]},u.id))]}),c&&!d&&p.status!=="error"&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"Loading sites..."}),!c&&!d&&!w&&p.status!=="error"&&!v&&O.length===0&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"No sites found for this account."}),!c&&!d&&!w&&p.status!=="error"&&O.length>0&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 max-h-[420px] overflow-y-auto py-4 px-8 [scrollbar-gutter:stable]",children:[T.length===0&&t.jsxs("p",{className:"col-span-3 text-sm text-muted-foreground text-center py-8",children:["No sites match “",h,"”"]}),T.map(u=>{const R=u.domains?.find(G=>G.production)?.domain??u.domains?.[0]?.domain,_=f===u.name;return t.jsxs("button",{type:"button",onClick:()=>b(u.name),className:V("flex flex-col rounded-xl border overflow-hidden text-left transition-all cursor-pointer",_?"border-primary ring-1 ring-primary":"border-border hover:border-muted-foreground/40"),children:[t.jsx("div",{className:"w-full aspect-video bg-muted overflow-hidden",children:u.thumb_url?t.jsx("img",{src:u.thumb_url,alt:u.name,className:"w-full h-full object-cover",loading:"lazy"}):t.jsx("div",{className:"w-full h-full bg-muted"})}),t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:u.name}),R&&t.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:R})]})]},u.name)})]})]}),t.jsxs($e,{className:"px-8 py-5 border-t border-border",children:[t.jsx(se,{variant:"outline",onClick:()=>A(!1),disabled:k.isPending,children:"Cancel"}),t.jsx(se,{disabled:!f||!g||k.isPending||c||d||w||!I||p.status==="error",onClick:()=>f&&k.mutate(f),children:k.isPending?"Importing...":"Import"})]})]})})}function ot(o,e){const n=$.c(4),[s,l]=L.useState(o);let i,r;return n[0]!==e||n[1]!==o?(i=()=>{const f=setTimeout(()=>l(o),e);return()=>clearTimeout(f)},r=[o,e],n[0]=e,n[1]=o,n[2]=i,n[3]=r):(i=n[2],r=n[3]),L.useEffect(i,r),s}const Q=[{key:"auto-respond-to-issues",triggerType:"github.issues.opened",nameSuffix:"auto-respond to issues",label:"Auto-respond to new issues",defaultEnabled:!0,instructions:({owner:o,name:e})=>`A new GitHub issue has been opened in ${o}/${e}. Read the issue, explore relevant code, create a branch, implement the fix, and open a PR referencing the issue number.`},{key:"review-incoming-prs",triggerType:"github.pull_request.opened",nameSuffix:"review incoming PRs",label:"Review incoming pull requests",defaultEnabled:!0,instructions:({owner:o,name:e})=>`A pull request was opened in ${o}/${e}. Read the diff, summarize what changed, flag risks (security, perf, breaking changes), and leave a review comment.`},{key:"note-merged-prs",triggerType:"github.pull_request.closed",nameSuffix:"note merged/closed PRs",label:"Note merged or closed PRs",defaultEnabled:!1,instructions:({owner:o,name:e})=>`A pull request was closed in ${o}/${e}. If it was merged, update changelog/release notes as appropriate.`}];function st(o,e){const n=new Set;if(o.paramsSchema)for(const l of Object.keys(o.paramsSchema))n.add(l);if(Array.isArray(o.params))for(const l of o.params)n.add(l.name);else if(o.params&&typeof o.params=="object")for(const l of Object.keys(o.params))n.add(l);if(n.has("repo"))return{repo:`${e.owner}/${e.name}`};const s={};return n.has("owner")&&(s.owner=e.owner),n.has("name")&&(s.name=e.name),n.has("repository")&&(s.repository=`${e.owner}/${e.name}`),s}async function rt({githubCallTool:o,selfCallTool:e,virtualMcpId:n,repo:s,connectionId:l,selectedKeys:i}){const r=await o({name:"TRIGGER_LIST",arguments:{}}),f=r.structuredContent??r,b=new Map((f.triggers??[]).map(m=>[m.type,m])),a=Q.filter(m=>i.has(m.key)),C=await Promise.allSettled(a.map(async m=>{const x=b.get(m.triggerType);if(!x)throw new Error(`Trigger ${m.triggerType} not exposed`);const N=await e({name:"AUTOMATION_CREATE",arguments:{name:`${s.name}: ${m.nameSuffix}`,virtual_mcp_id:n,messages:m.instructions(s),active:!0}}),y=(N.structuredContent??N).id;if(!y)throw new Error(`AUTOMATION_CREATE returned no id for ${m.key}`);await e({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:y,type:"event",connection_id:l,event_type:m.triggerType,params:st(x,s)}})})),h=C.filter(m=>m.status==="rejected").length;return h>0&&console.error("Some GitHub automations failed to set up:",C.filter(m=>m.status==="rejected")),{total:C.length,failed:h}}function Et(o){const e=$.c(22),{open:n,onOpenChange:s,title:l,hideAutoRespondCheckbox:i,onImportComplete:r}=o,f=l===void 0?"Import from GitHub":l,b=i===void 0?!1:i,[a,C]=L.useState(null);let h;e[0]!==f?(h=t.jsx(Ie,{className:"sr-only",children:t.jsx(Ne,{children:f})}),e[0]=f,e[1]=h):h=e[1];let m;e[2]!==a||e[3]!==f?(m=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:a?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>C(null),className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors shrink-0","aria-label":"Back to accounts",children:t.jsx(ue,{size:16})}),t.jsx("img",{src:a.avatarUrl,alt:a.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:a.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:f})]})}),e[2]=a,e[3]=f,e[4]=m):m=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Y,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=x):x=e[5];let N;e[6]!==s?(N=()=>s(!1),e[6]=s,e[7]=N):N=e[7];let y;e[8]!==b||e[9]!==r||e[10]!==n||e[11]!==a||e[12]!==N?(y=t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:t.jsx(L.Suspense,{fallback:x,children:t.jsx(it,{open:n,onComplete:N,selectedInstallation:a,onSelectInstallation:C,hideAutoRespondCheckbox:b,onImportComplete:r})})}),e[8]=b,e[9]=r,e[10]=n,e[11]=a,e[12]=N,e[13]=y):y=e[13];let p;e[14]!==h||e[15]!==m||e[16]!==y?(p=t.jsxs(Ce,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[h,m,y]}),e[14]=h,e[15]=m,e[16]=y,e[17]=p):p=e[17];let I;return e[18]!==s||e[19]!==n||e[20]!==p?(I=t.jsx(we,{open:n,onOpenChange:s,children:p}),e[18]=s,e[19]=n,e[20]=p,e[21]=I):I=e[21],I}function it({open:o,onComplete:e,selectedInstallation:n,onSelectInstallation:s,hideAutoRespondCheckbox:l,onImportComplete:i}){const{org:r}=J(),f=ae(),b=le(),[a,C]=L.useState(null),[h,m]=L.useState(!0),[x,N]=L.useState(()=>new Set(Q.filter(g=>g.defaultEnabled).map(g=>g.key))),y=Q.filter(g=>g.defaultEnabled).map(g=>g.key),p=l?new Set(y):h?x:new Set,I=ye({slug:"mcp-github"}),w=ve(I),j=Se({enabled:o&&w.length===0}),d=w.length===1?w[0]??null:a,S=H({connectionId:d?.id??"",orgId:r.id,orgSlug:r.slug}),c=H({connectionId:ce,orgId:r.id,orgSlug:r.slug}),v=async(g,k)=>{try{const R=await S.callTool({name:"get_file_contents",arguments:{owner:g.owner,repo:g.name,path:k}});if(R.isError)return null;const G=R.content?.find(E=>E.type==="resource")?.resource?.text;if(!G)return null;try{const E=JSON.parse(G);return typeof E=="string"?E:JSON.stringify(E)}catch{return G}}catch{return null}},O=(g,k)=>{Promise.all([v(k,"AGENTS.md"),v(k,"CLAUDE.md")]).then(async([u,R])=>{const _=u??R??null;_&&(await c.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:g,data:{metadata:{instructions:_}}}}),ie(f,r.id))}).catch(u=>{console.error("GitHub instructions fetch failed:",u)})},A=async({virtualMcpId:g,repo:k,connectionId:u,selectedKeys:R})=>{const{total:_,failed:G}=await rt({githubCallTool:E=>S.callTool(E),selfCallTool:E=>c.callTool(E),virtualMcpId:g,repo:k,connectionId:u,selectedKeys:R});G>0&&D.warning(`Set up ${_-G}/${_} GitHub automations. Add the rest from the automations view.`)},T=be({mutationFn:async g=>{if(!d||!n)throw new Error("No GitHub connection or installation");const k=n.installationId,{childConnectionId:u}=await Te({orgSlug:r.slug,sourceConnection:d,installationId:k,owner:g.owner,repo:g.name,githubCallTool:_=>S.callTool(_),selfCallTool:_=>c.callTool(_)});let R=null;try{const _=await c.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:g.name,description:g.description||"Imported from GitHub",pinned:!1,icon:null,metadata:{githubRepo:{owner:g.owner,name:g.name,url:g.url,installationId:k,connectionId:u},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"},chatDefaultOpen:!0}}},connections:[{connection_id:u}]}}}),G=_.structuredContent??_,E=G.item?.id;if(!G.item||!E)throw new Error("Failed to create the imported agent");return R=E,p.size>0&&await A({virtualMcpId:E,repo:g,connectionId:u,selectedKeys:p}).catch(z=>{console.error("Failed to set up GitHub automations:",z),D.warning("Imported repo, but failed to set up GitHub automations. You can add triggers manually from the automations view.")}),{virtualMcpId:E,repo:g,connectionId:u,item:G.item}}catch(_){throw R&&await c.callTool({name:"COLLECTION_VIRTUAL_MCP_DELETE",arguments:{id:R}}).catch(()=>{}),await c.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:u,force:!0}}).catch(()=>{}),_}},onSuccess:({virtualMcpId:g,repo:k,connectionId:u,item:R})=>{if(f.setQueryData(U.collectionItem(c,r.id,"","VIRTUAL_MCP",g),{item:R}),ie(f,r.id),O(g,k),i){i({virtualMcpId:g,repo:k,connectionId:u});return}D.success(`Imported ${k.name} from GitHub`),e(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),b(g)},onError:g=>{D.error("Failed to import repo: "+(g instanceof Error?g.message:"Unknown error"))}});return j.status==="installing"||j.status==="authenticating"?t.jsx(re,{status:j.status,error:null,retry:j.retry}):j.status==="error"?t.jsx(re,{status:"error",error:j.error,retry:j.retry}):w.length===0&&j.status==="idle"?t.jsx(re,{status:"installing",error:null,retry:j.retry}):w.length>1&&!d?t.jsxs("div",{className:"flex flex-col py-2",children:[t.jsx("div",{className:"px-4 py-2",children:t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Select a connection"})}),w.map(g=>t.jsxs("button",{type:"button",onClick:()=>C(g),className:"flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left",children:[g.icon?t.jsx("img",{src:g.icon,alt:g.title,className:"size-7 rounded-full shrink-0"}):t.jsx("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center shrink-0",children:t.jsx(F,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:g.title})]},g.id))]}):d?n?t.jsx(lt,{connectionId:d.id,orgId:r.id,orgSlug:r.slug,installation:n,onSelectRepo:g=>T.mutate(g),isSaving:T.isPending,autoRespondEnabled:h,onAutoRespondChange:m,selectedAutomationKeys:x,onAutomationKeysChange:N,hideAutoRespondCheckbox:l}):t.jsx(at,{connectionId:d.id,orgId:r.id,orgSlug:r.slug,onSelect:s,showBackButton:w.length>1,onBack:()=>C(null)}):null}function at(o){const e=$.c(31),{connectionId:n,orgId:s,orgSlug:l,onSelect:i,showBackButton:r,onBack:f}=o;let b;e[0]!==s||e[1]!==l?(b={connectionId:ce,orgId:s,orgSlug:l},e[0]=s,e[1]=l,e[2]=b):b=e[2];const a=H(b);let C;e[3]!==n||e[4]!==s?(C=U.githubUserOrgs(s,n),e[3]=n,e[4]=s,e[5]=C):C=e[5];let h;e[6]!==n||e[7]!==a?(h=()=>Ee(c=>a.callTool(c),n),e[6]=n,e[7]=a,e[8]=h):h=e[8];let m;e[9]!==C||e[10]!==h?(m={queryKey:C,queryFn:h},e[9]=C,e[10]=h,e[11]=m):m=e[11];const x=xe(m);if(x.isLoading){let c;return e[12]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Y,{size:18,className:"animate-spin text-muted-foreground"})}),e[12]=c):c=e[12],c}if(x.isError){let c;return e[13]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("p",{className:"text-sm text-destructive",children:"Failed to load GitHub accounts"})}),e[13]=c):c=e[13],c}const N=x.data;if(!N)return null;let y;e[14]!==f||e[15]!==r?(y=r&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:f,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(ue,{size:12}),"Change connection"]})}),e[14]=f,e[15]=r,e[16]=y):y=e[16];let p;if(e[17]!==N.installations||e[18]!==i){let c;e[20]!==i?(c=v=>t.jsxs("button",{type:"button",onClick:()=>i(v),className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left group",children:[t.jsx("img",{src:v.avatarUrl,alt:v.login,className:"size-7 rounded-full shrink-0 ring-1 ring-border"}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium leading-none",children:v.login}),v.type==="User"&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Personal account"})]}),t.jsx("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:"Select →"})]},v.installationId),e[20]=i,e[21]=c):c=e[21],p=N.installations.map(c),e[17]=N.installations,e[18]=i,e[19]=p}else p=e[19];let I;e[22]!==p?(I=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:p}),e[22]=p,e[23]=I):I=e[23];const w=N.appSlug?`https://github.com/apps/${N.appSlug}/installations/new`:"https://github.com/settings/installations";let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("span",{className:"underline underline-offset-2",children:"Install the GitHub App"}),e[24]=j):j=e[24];let d;e[25]!==w?(d=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:["Account not listed?"," ",j]})}),e[25]=w,e[26]=d):d=e[26];let S;return e[27]!==d||e[28]!==y||e[29]!==I?(S=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[y,I,d]}),e[27]=d,e[28]=y,e[29]=I,e[30]=S):S=e[30],S}function lt(o){const e=$.c(27),{connectionId:n,orgId:s,orgSlug:l,installation:i,onSelectRepo:r,isSaving:f,autoRespondEnabled:b,onAutoRespondChange:a,selectedAutomationKeys:C,onAutomationKeysChange:h,hideAutoRespondCheckbox:m}=o,[x,N]=L.useState(""),y=ot(x,300),p=L.useDeferredValue(y),I=x!==p;let w;e[0]!==I||e[1]!==x?(w=t.jsx(je,{placeholder:"Search repositories...",value:x,onChange:N,isSearching:I}),e[0]=I,e[1]=x,e[2]=w):w=e[2];const j=I?"opacity-40":"opacity-100";let d;e[3]!==j?(d=V("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",j),e[3]=j,e[4]=d):d=e[4];let S;e[5]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Y,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=S):S=e[5];let c;e[6]!==n||e[7]!==p||e[8]!==i||e[9]!==f||e[10]!==r||e[11]!==s||e[12]!==l?(c=t.jsx(L.Suspense,{fallback:S,children:t.jsx(ct,{connectionId:n,orgId:s,orgSlug:l,installation:i,query:p,onSelectRepo:r,isSaving:f})}),e[6]=n,e[7]=p,e[8]=i,e[9]=f,e[10]=r,e[11]=s,e[12]=l,e[13]=c):c=e[13];let v;e[14]!==d||e[15]!==c?(v=t.jsx("div",{className:d,children:c}),e[14]=d,e[15]=c,e[16]=v):v=e[16];let O;e[17]!==b||e[18]!==m||e[19]!==a||e[20]!==h||e[21]!==C?(O=!m&&t.jsxs("div",{className:"border-t border-border shrink-0",children:[t.jsxs("label",{className:"flex items-center gap-2 px-4 py-3 cursor-pointer select-none",children:[t.jsx(pe,{checked:b,onCheckedChange:T=>a(T===!0)}),t.jsx("span",{className:"text-xs text-foreground",children:"Set up GitHub automations for this repo"})]}),b&&t.jsx("div",{className:"px-4 pb-3 pl-9 flex flex-col gap-1.5",children:Q.map(T=>t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[t.jsx(pe,{checked:C.has(T.key),onCheckedChange:g=>{const k=new Set(C);g===!0?k.add(T.key):k.delete(T.key),h(k)}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:T.label})]},T.key))})]}),e[17]=b,e[18]=m,e[19]=a,e[20]=h,e[21]=C,e[22]=O):O=e[22];let A;return e[23]!==w||e[24]!==v||e[25]!==O?(A=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[w,v,O]}),e[23]=w,e[24]=v,e[25]=O,e[26]=A):A=e[26],A}function ct(o){const e=$.c(29),{connectionId:n,orgId:s,orgSlug:l,installation:i,query:r,onSelectRepo:f,isSaving:b}=o;let a;e[0]!==n||e[1]!==s||e[2]!==l?(a={connectionId:n,orgId:s,orgSlug:l},e[0]=n,e[1]=s,e[2]=l,e[3]=a):a=e[3];const C=H(a),h=i.type==="User"?"user":"org",m=r?`${h}:${i.login} ${r} in:name`:`${h}:${i.login}`;let x;e[4]!==n||e[5]!==i.login||e[6]!==s||e[7]!==r?(x=U.githubOrgRepos(s,n,i.login,r),e[4]=n,e[5]=i.login,e[6]=s,e[7]=r,e[8]=x):x=e[8];let N;e[9]!==C||e[10]!==m?(N=async j=>{const{signal:d}=j,c=(await C.callTool({name:"search_repositories",arguments:{query:m,page:1,perPage:30}},void 0,{signal:d})).content?.[0]?.text;if(!c)throw new Error("No response from search_repositories");return(JSON.parse(c).items??[]).map(ut)},e[9]=C,e[10]=m,e[11]=N):N=e[11];let y;e[12]!==x||e[13]!==N?(y={queryKey:x,queryFn:N},e[12]=x,e[13]=N,e[14]=y):y=e[14];const{data:p}=Ae(y);if(p.length===0){let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("p",{className:"text-sm text-muted-foreground",children:"No repositories found"}),e[15]=j):j=e[15];let d;e[16]!==r?(d=r&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Try a different search term"}),e[16]=r,e[17]=d):d=e[17];let S;return e[18]!==d?(S=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[j,d]}),e[18]=d,e[19]=S):S=e[19],S}let I;if(e[20]!==b||e[21]!==f||e[22]!==p){let j;e[24]!==b||e[25]!==f?(j=d=>t.jsxs("button",{type:"button",onClick:()=>f(d),disabled:b,className:"flex items-start gap-3 px-4 py-3 hover:bg-accent transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(F,{className:"size-4 text-muted-foreground mt-0.5 shrink-0"}),t.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:t.jsx("span",{className:"text-sm font-medium truncate",children:d.name})}),t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:[d.private?t.jsx(Oe,{size:10}):t.jsx(He,{size:10}),d.private?"Private":"Public"]})]},d.fullName),e[24]=b,e[25]=f,e[26]=j):j=e[26],I=p.map(j),e[20]=b,e[21]=f,e[22]=p,e[23]=I}else I=e[23];let w;return e[27]!==I?(w=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:I}),e[27]=I,e[28]=w):w=e[28],w}function ut(o){return{name:o.name,fullName:o.full_name,owner:o.full_name.split("/")[0]??"",url:o.html_url,private:o.private,description:o.description,updatedAt:o.updated_at}}function re(o){const e=$.c(33),{status:n,error:s,retry:l}=o;if(n==="error"){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("div",{className:"size-10 rounded-full bg-destructive/10 flex items-center justify-center",children:t.jsx(F,{className:"size-5 text-destructive"})}),e[0]=c):c=e[0];let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx("p",{className:"text-sm font-medium",children:"Connection failed"}),e[1]=v):v=e[1];const O=s??"Something went wrong while connecting to GitHub.";let A;e[2]!==O?(A=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[v,t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:O})]}),e[2]=O,e[3]=A):A=e[3];let T;e[4]!==l?(T=t.jsx("button",{type:"button",onClick:l,className:"text-xs font-medium text-foreground border border-border rounded-md px-3 py-1.5 hover:bg-accent transition-colors",children:"Try again"}),e[4]=l,e[5]=T):T=e[5];let g;return e[6]!==A||e[7]!==T?(g=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[c,A,T]}),e[6]=A,e[7]=T,e[8]=g):g=e[8],g}const i=n==="authenticating";let r;e[9]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(F,{className:"size-5 text-foreground"})}),e[9]=r):r=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsxs("div",{className:"relative size-10",children:[r,t.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-background flex items-center justify-center",children:t.jsx(Y,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[10]=f):f=e[10];const b=i?"Authenticating with GitHub":"Setting up GitHub";let a;e[11]!==b?(a=t.jsx("p",{className:"text-sm font-medium",children:b}),e[11]=b,e[12]=a):a=e[12];const C=i?"Complete the OAuth flow in your browser":"Installing the GitHub connection...";let h;e[13]!==C?(h=t.jsx("p",{className:"text-xs text-muted-foreground",children:C}),e[13]=C,e[14]=h):h=e[14];let m;e[15]!==a||e[16]!==h?(m=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[a,h]}),e[15]=a,e[16]=h,e[17]=m):m=e[17];const x=i?"bg-muted-foreground/30":"bg-foreground animate-pulse";let N;e[18]!==x?(N=V("size-1.5 rounded-full",x),e[18]=x,e[19]=N):N=e[19];let y;e[20]!==N?(y=t.jsx("span",{className:N}),e[20]=N,e[21]=y):y=e[21];const p=i?"bg-foreground animate-pulse":"bg-muted-foreground/30";let I;e[22]!==p?(I=V("size-1.5 rounded-full",p),e[22]=p,e[23]=I):I=e[23];let w;e[24]!==I?(w=t.jsx("span",{className:I}),e[24]=I,e[25]=w):w=e[25];let j;e[26]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[26]=j):j=e[26];let d;e[27]!==y||e[28]!==w?(d=t.jsxs("div",{className:"flex items-center gap-1.5",children:[y,w,j]}),e[27]=y,e[28]=w,e[29]=d):d=e[29];let S;return e[30]!==d||e[31]!==m?(S=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[f,m,d]}),e[30]=d,e[31]=m,e[32]=S):S=e[32],S}export{F as G,jt as H,vt as I,Fe as S,Nt as W,Et as a,St as u};
@@ -1,4 +1,4 @@
1
- import{e as y,q as C,G as ce,a as Q,K as E,n as B,b6 as we,a0 as xe,j as o,l as ge,B as q,r as v,C as ye,c as ee,o as re}from"./index-DHxOddsj.js";import{S as G}from"./skeleton-B2rX4p4v.js";import{n as Z}from"./Globe01-CfZP4vCY.js";import{l as je,F as ke}from"./index-DhrBeRkU.js";import{F as be,M as ve}from"./file-type-icon-DHQvk0za.js";import{D as Se,a as $e,b as Te,c as ie}from"./dropdown-menu-mHDT-XH7.js";import{b as A,T as K,a as H}from"./tooltip-6OktDyzD.js";import{i as Ee}from"./Check-Cl07asRj.js";import{a as Ce}from"./Eye-lcuSJE4l.js";import{e as Me,f as Fe,a as Ne,b as De}from"./ZoomOut-aYAC7hBe.js";import{i as Pe}from"./LayoutLeft-DwKLO_V_.js";import{n as Ue}from"./LinkExternal01-r7kaLetr.js";function Oe(s){return s.contentHash??`${s.size}-${s.updatedAt}`}function F(s,e,t,n){const r=new URLSearchParams(n).toString();return`/api/${encodeURIComponent(s)}/fs/${encodeURIComponent(e)}/${t}${r?`?${r}`:""}`}async function N(s,e){const t=await fetch(s,e);if(!t.ok){let n="";try{n=(await t.json()).error??""}catch{}throw new Error(n||`HTTP ${t.status}`)}return t}function vt(s,e){const t=y.c(11),{org:n}=C();let r;t[0]!==n.id||t[1]!==e||t[2]!==s?(r=E.orgFsList(n.id,s,e),t[0]=n.id,t[1]=e,t[2]=s,t[3]=r):r=t[3];let i;t[4]!==n.slug||t[5]!==e||t[6]!==s?(i=async()=>(await(await N(F(n.slug,s,"list",{path:e}))).json()).entries.toSorted(ze),t[4]=n.slug,t[5]=e,t[6]=s,t[7]=i):i=t[7];let a;return t[8]!==r||t[9]!==i?(a={queryKey:r,placeholderData:we,queryFn:i},t[8]=r,t[9]=i,t[10]=a):a=t[10],B(a)}function ze(s,e){return s.kind!==e.kind?s.kind==="dir"?-1:1:s.path.localeCompare(e.path)}function St(s,e,t){const n=y.c(15),{org:r}=C();let i;n[0]!==r.id||n[1]!==e||n[2]!==s?(i=E.orgFsStat(r.id,s??"",e),n[0]=r.id,n[1]=e,n[2]=s,n[3]=i):i=n[3];const a=s!==null;let d;n[4]!==t?(d=t?.refetchIntervalWhenAbsent?f=>f.state.data?!1:t.refetchIntervalWhenAbsent??!1:void 0,n[4]=t,n[5]=d):d=n[5];let c;n[6]!==r.slug||n[7]!==e||n[8]!==s?(c=async()=>{const f=await fetch(F(r.slug,s??"","stat",{path:e}));if(f.status===404)return null;if(!f.ok)throw new Error(`HTTP ${f.status}`);return(await f.json()).entry},n[6]=r.slug,n[7]=e,n[8]=s,n[9]=c):c=n[9];let l;return n[10]!==i||n[11]!==a||n[12]!==d||n[13]!==c?(l={queryKey:i,enabled:a,refetchInterval:d,queryFn:c},n[10]=i,n[11]=a,n[12]=d,n[13]=c,n[14]=l):l=n[14],B(l)}function $t(s){const e=y.c(9),{org:t}=C();let n;e[0]!==t.id||e[1]!==s?(n=E.orgFsUsage(t.id,s),e[0]=t.id,e[1]=s,e[2]=n):n=e[2];let r;e[3]!==t.slug||e[4]!==s?(r=async()=>await(await N(F(t.slug,s,"usage"))).json(),e[3]=t.slug,e[4]=s,e[5]=r):r=e[5];let i;return e[6]!==n||e[7]!==r?(i={queryKey:n,queryFn:r},e[6]=n,e[7]=r,e[8]=i):i=e[8],B(i)}function Tt(s,e){const t=y.c(9),n=s===void 0?60:s,{org:r}=C();let i;t[0]!==r.id?(i=E.orgFsRecent(r.id),t[0]=r.id,t[1]=i):i=t[1];const a=e?.enabled;let d;t[2]!==n||t[3]!==r.slug?(d=async()=>(await(await N(`/api/${encodeURIComponent(r.slug)}/fs/recent?limit=${n}`)).json()).entries,t[2]=n,t[3]=r.slug,t[4]=d):d=t[4];let c;return t[5]!==i||t[6]!==a||t[7]!==d?(c={queryKey:i,enabled:a,queryFn:d},t[5]=i,t[6]=a,t[7]=d,t[8]=c):c=t[8],B(c)}function Et(s){const e=y.c(8),{org:t}=C();let n;e[0]!==t.id?(n=E.orgFsSkills(t.id),e[0]=t.id,e[1]=n):n=e[1];const r=s?.enabled;let i;e[2]!==t.slug?(i=async()=>{const d=await N(`/api/${encodeURIComponent(t.slug)}/fs/public-sets`),{sets:c}=await d.json(),l=["home",...c.map(_e)];return(await Promise.all(l.map(async u=>{const m=await N(F(t.slug,u,"list",{path:""})),{entries:w}=await m.json();return w.filter(Re).map(j=>({volume:u,path:j.path}))}))).flat()},e[2]=t.slug,e[3]=i):i=e[3];let a;return e[4]!==n||e[5]!==r||e[6]!==i?(a={queryKey:n,enabled:r,queryFn:i},e[4]=n,e[5]=r,e[6]=i,e[7]=a):a=e[7],B(a)}function Re(s){return s.kind==="dir"&&s.hasSkill}function _e(s){return`public-${s}`}function Ct(){const s=y.c(7),{org:e}=C();let t;s[0]!==e.id?(t=E.orgFsPublicSets(e.id),s[0]=e.id,s[1]=t):t=s[1];let n;s[2]!==e.slug?(n=async()=>(await(await N(`/api/${encodeURIComponent(e.slug)}/fs/public-sets`)).json()).sets,s[2]=e.slug,s[3]=n):n=s[3];let r;return s[4]!==t||s[5]!==n?(r={queryKey:t,staleTime:3e5,queryFn:n},s[4]=t,s[5]=n,s[6]=r):r=s[6],B(r)}function Mt(s){const e=y.c(3),{org:t}=C();let n;return e[0]!==t.slug||e[1]!==s?(n=r=>F(t.slug,s,"read",{path:r}),e[0]=t.slug,e[1]=s,e[2]=n):n=e[2],n}function Ft(){const s=y.c(2),{org:e}=C();let t;return s[0]!==e.slug?(t=(n,r)=>F(e.slug,n,"read",{path:r}),s[0]=e.slug,s[1]=t):t=s[1],t}function We(s){const e=y.c(3),{org:t}=C();let n;return e[0]!==t||e[1]!==s?(n={mutationFn:async r=>(await(await N(F(t.slug,s,"file",{path:r.path}),{method:"PUT",headers:{"content-type":r.contentType??"text/html; charset=utf-8"},body:r.body})).json()).entry},e[0]=t,e[1]=s,e[2]=n):n=e[2],Q(n)}function Nt(s){const e=y.c(26),{org:t}=C(),n=ce();let r;e[0]!==t||e[1]!==n||e[2]!==s?(r=()=>{n.invalidateQueries({queryKey:E.orgFsVolume(t.id,s)}),n.invalidateQueries({queryKey:E.orgFsRecent(t.id)})},e[0]=t,e[1]=n,e[2]=s,e[3]=r):r=e[3];const i=r;let a;e[4]!==t||e[5]!==s?(a=async g=>{for(const k of g.files){const S=g.dir?`${g.dir}/${k.name}`:k.name;await N(F(t.slug,s,"file",{path:S}),{method:"PUT",headers:{"content-type":k.type||"application/octet-stream"},body:k})}},e[4]=t,e[5]=s,e[6]=a):a=e[6];let d;e[7]!==i||e[8]!==a?(d={mutationFn:a,onSettled:i},e[7]=i,e[8]=a,e[9]=d):d=e[9];const c=Q(d);let l;e[10]!==t||e[11]!==s?(l=async g=>{await N(F(t.slug,s,"dir",{path:g}),{method:"POST"})},e[10]=t,e[11]=s,e[12]=l):l=e[12];let f;e[13]!==i||e[14]!==l?(f={mutationFn:l,onSuccess:i},e[13]=i,e[14]=l,e[15]=f):f=e[15];const u=Q(f);let m;e[16]!==t||e[17]!==s?(m=async g=>{await N(F(t.slug,s,"file",{path:g}),{method:"DELETE"})},e[16]=t,e[17]=s,e[18]=m):m=e[18];let w;e[19]!==i||e[20]!==m?(w={mutationFn:m,onSuccess:i},e[19]=i,e[20]=m,e[21]=w):w=e[21];const j=Q(w);let b;return e[22]!==u||e[23]!==j||e[24]!==c?(b={upload:c,mkdir:u,remove:j},e[22]=u,e[23]=j,e[24]=c,e[25]=b):b=e[25],b}function qe(s){if(!s||s.includes("/")||s.includes("\\")||s.includes("..")||s.includes("\0"))return!0;try{const e=decodeURIComponent(s);return e.includes("/")||e.includes("\\")||e.includes("..")||e.includes("\0")}catch{return!0}}function Le(s){if(qe(s))throw new Error(`Invalid block key: ${s||"(empty)"}`)}function Ie(s){try{return decodeURIComponent(s)}catch{return s}}function Be(s){return Le(s),encodeURIComponent(s)}function Ae(s){return`.deco/blocks/${Be(s)}.json`}function Dt(s){return`/${Ae(s)}`}const Pt=1e4,Ke=3;function J(s){return s.trim()?(s.startsWith("/")?s:`/${s}`).replace(/\/+/g,"/"):"/"}function te(s){return s.startsWith("/")?s.slice(1):s}function Y(s){return s.trim()?s.startsWith("/")?s:`/${s}`:"/"}function He(s){const e=Y(s);if(e==="/")return"/";const t=e.split("/").filter(Boolean);return t.pop(),t.length===0?"/":`/${t.join("/")}`}function Ut(s,e){const t=e.replace(/^\/+|\/+$/g,"");return Y(t?`${s==="/"?"":s}/${t}`:s)}function Ot(s,e){return e==="directory"?s:He(s)}function zt(s){const e=s.trim();return e?e.includes("/")||e.includes("\\")||e.includes("..")||e.includes("\0")?"Name cannot contain /, \\, or ..":e.startsWith(".")?"Name cannot start with a dot":null:"Name is required"}function Ve(s){const e=te(s);return e?e.split("/").filter(Boolean).length:0}function Rt(s,e,t,n=!1){return{files:[...new Set([...s,...t.files])],directories:[...new Set([...e,...t.directories??[]])],truncated:n||!!t.truncated}}function _t(s,e){return Ve(s)>Ke&&!e.has(s)}function Wt(s,e,t=[]){const n=te(s);if(e.includes(n)||t.includes(n))return!0;if(!n)return!1;const r=`${n}/`;return e.some(i=>i.startsWith(r))||t.some(i=>i.startsWith(r))}function qt(s){const e=te(s),t=".deco/blocks/";if(!e.startsWith(t)||!e.endsWith(".json"))return null;const n=e.slice(t.length,-5);return Ie(n)}function Xe(s){if(!s)return"plaintext";const e=s.toLowerCase();return e.endsWith(".tsx")||e.endsWith(".ts")?"typescript":e.endsWith(".jsx")||e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")?"javascript":e.endsWith(".json")?"json":e.endsWith(".md")||e.endsWith(".mdx")?"markdown":e.endsWith(".css")?"css":e.endsWith(".scss")?"scss":e.endsWith(".html")?"html":e.endsWith(".yaml")||e.endsWith(".yml")?"yaml":e.endsWith(".xml")||e.endsWith(".svg")?"xml":e.endsWith(".py")?"python":e.endsWith(".sql")?"sql":e.endsWith(".sh")?"shell":"plaintext"}function Lt(s){const e=J(s).split("/").filter(Boolean),t=["/"];let n="";for(const r of e.slice(0,-1))n+=`/${r}`,t.push(n);return t}function It(s,e=[]){const t={children:[]},n=i=>{const d=J(i).split("/").filter(Boolean);let c=t,l="";for(const f of d){l+=`/${f}`;let u=c.children.find(m=>m.name===f);u?u.kind==="file"&&(u.kind="directory"):(u={name:f,path:l,kind:"directory",children:[]},c.children.push(u)),c=u}};for(const i of s){const d=J(i).split("/").filter(Boolean);let c=t,l="";d.forEach((f,u)=>{l+=`/${f}`;const m=u===d.length-1;let w=c.children.find(j=>j.name===f);w||(w={name:f,path:l,kind:m?"file":"directory",children:[]},c.children.push(w)),c=w})}for(const i of e)n(Y(i));const r=i=>{i.sort((a,d)=>a.kind!==d.kind?a.kind==="directory"?-1:1:a.name.localeCompare(d.name));for(const a of i)a.children.length>0&&r(a.children)};return r(t.children),t.children}function Ge(s,e,t=0){const n=[];for(const r of s)r.name!==".gitkeep"&&(n.push({node:r,depth:t}),r.kind==="directory"&&r.children.length>0&&e.has(r.path)&&n.push(...Ge(r.children,e,t+1)));return n}function Bt(s){return s.split(`
1
+ import{e as y,q as C,G as ce,a as Q,K as E,n as B,b6 as we,a0 as xe,j as o,l as ge,B as q,r as v,C as ye,c as ee,o as re}from"./index-BPnG82q8.js";import{S as G}from"./skeleton-BrZY2U4q.js";import{n as Z}from"./Globe01-DCcLGAPs.js";import{l as je,F as ke}from"./index-BHORPjEK.js";import{F as be,M as ve}from"./file-type-icon-BI-57QdR.js";import{D as Se,a as $e,b as Te,c as ie}from"./dropdown-menu-uYsl4z-0.js";import{b as A,T as K,a as H}from"./tooltip-BwiZr2GD.js";import{i as Ee}from"./Check-Cy2gwr8C.js";import{a as Ce}from"./Eye-BEaX-nOW.js";import{e as Me,f as Fe,a as Ne,b as De}from"./ZoomOut-OQ9XVMLx.js";import{i as Pe}from"./LayoutLeft-XvA4efJR.js";import{n as Ue}from"./LinkExternal01-kEaZ-3VP.js";function Oe(s){return s.contentHash??`${s.size}-${s.updatedAt}`}function F(s,e,t,n){const r=new URLSearchParams(n).toString();return`/api/${encodeURIComponent(s)}/fs/${encodeURIComponent(e)}/${t}${r?`?${r}`:""}`}async function N(s,e){const t=await fetch(s,e);if(!t.ok){let n="";try{n=(await t.json()).error??""}catch{}throw new Error(n||`HTTP ${t.status}`)}return t}function vt(s,e){const t=y.c(11),{org:n}=C();let r;t[0]!==n.id||t[1]!==e||t[2]!==s?(r=E.orgFsList(n.id,s,e),t[0]=n.id,t[1]=e,t[2]=s,t[3]=r):r=t[3];let i;t[4]!==n.slug||t[5]!==e||t[6]!==s?(i=async()=>(await(await N(F(n.slug,s,"list",{path:e}))).json()).entries.toSorted(ze),t[4]=n.slug,t[5]=e,t[6]=s,t[7]=i):i=t[7];let a;return t[8]!==r||t[9]!==i?(a={queryKey:r,placeholderData:we,queryFn:i},t[8]=r,t[9]=i,t[10]=a):a=t[10],B(a)}function ze(s,e){return s.kind!==e.kind?s.kind==="dir"?-1:1:s.path.localeCompare(e.path)}function St(s,e,t){const n=y.c(15),{org:r}=C();let i;n[0]!==r.id||n[1]!==e||n[2]!==s?(i=E.orgFsStat(r.id,s??"",e),n[0]=r.id,n[1]=e,n[2]=s,n[3]=i):i=n[3];const a=s!==null;let d;n[4]!==t?(d=t?.refetchIntervalWhenAbsent?f=>f.state.data?!1:t.refetchIntervalWhenAbsent??!1:void 0,n[4]=t,n[5]=d):d=n[5];let c;n[6]!==r.slug||n[7]!==e||n[8]!==s?(c=async()=>{const f=await fetch(F(r.slug,s??"","stat",{path:e}));if(f.status===404)return null;if(!f.ok)throw new Error(`HTTP ${f.status}`);return(await f.json()).entry},n[6]=r.slug,n[7]=e,n[8]=s,n[9]=c):c=n[9];let l;return n[10]!==i||n[11]!==a||n[12]!==d||n[13]!==c?(l={queryKey:i,enabled:a,refetchInterval:d,queryFn:c},n[10]=i,n[11]=a,n[12]=d,n[13]=c,n[14]=l):l=n[14],B(l)}function $t(s){const e=y.c(9),{org:t}=C();let n;e[0]!==t.id||e[1]!==s?(n=E.orgFsUsage(t.id,s),e[0]=t.id,e[1]=s,e[2]=n):n=e[2];let r;e[3]!==t.slug||e[4]!==s?(r=async()=>await(await N(F(t.slug,s,"usage"))).json(),e[3]=t.slug,e[4]=s,e[5]=r):r=e[5];let i;return e[6]!==n||e[7]!==r?(i={queryKey:n,queryFn:r},e[6]=n,e[7]=r,e[8]=i):i=e[8],B(i)}function Tt(s,e){const t=y.c(9),n=s===void 0?60:s,{org:r}=C();let i;t[0]!==r.id?(i=E.orgFsRecent(r.id),t[0]=r.id,t[1]=i):i=t[1];const a=e?.enabled;let d;t[2]!==n||t[3]!==r.slug?(d=async()=>(await(await N(`/api/${encodeURIComponent(r.slug)}/fs/recent?limit=${n}`)).json()).entries,t[2]=n,t[3]=r.slug,t[4]=d):d=t[4];let c;return t[5]!==i||t[6]!==a||t[7]!==d?(c={queryKey:i,enabled:a,queryFn:d},t[5]=i,t[6]=a,t[7]=d,t[8]=c):c=t[8],B(c)}function Et(s){const e=y.c(8),{org:t}=C();let n;e[0]!==t.id?(n=E.orgFsSkills(t.id),e[0]=t.id,e[1]=n):n=e[1];const r=s?.enabled;let i;e[2]!==t.slug?(i=async()=>{const d=await N(`/api/${encodeURIComponent(t.slug)}/fs/public-sets`),{sets:c}=await d.json(),l=["home",...c.map(_e)];return(await Promise.all(l.map(async u=>{const m=await N(F(t.slug,u,"list",{path:""})),{entries:w}=await m.json();return w.filter(Re).map(j=>({volume:u,path:j.path}))}))).flat()},e[2]=t.slug,e[3]=i):i=e[3];let a;return e[4]!==n||e[5]!==r||e[6]!==i?(a={queryKey:n,enabled:r,queryFn:i},e[4]=n,e[5]=r,e[6]=i,e[7]=a):a=e[7],B(a)}function Re(s){return s.kind==="dir"&&s.hasSkill}function _e(s){return`public-${s}`}function Ct(){const s=y.c(7),{org:e}=C();let t;s[0]!==e.id?(t=E.orgFsPublicSets(e.id),s[0]=e.id,s[1]=t):t=s[1];let n;s[2]!==e.slug?(n=async()=>(await(await N(`/api/${encodeURIComponent(e.slug)}/fs/public-sets`)).json()).sets,s[2]=e.slug,s[3]=n):n=s[3];let r;return s[4]!==t||s[5]!==n?(r={queryKey:t,staleTime:3e5,queryFn:n},s[4]=t,s[5]=n,s[6]=r):r=s[6],B(r)}function Mt(s){const e=y.c(3),{org:t}=C();let n;return e[0]!==t.slug||e[1]!==s?(n=r=>F(t.slug,s,"read",{path:r}),e[0]=t.slug,e[1]=s,e[2]=n):n=e[2],n}function Ft(){const s=y.c(2),{org:e}=C();let t;return s[0]!==e.slug?(t=(n,r)=>F(e.slug,n,"read",{path:r}),s[0]=e.slug,s[1]=t):t=s[1],t}function We(s){const e=y.c(3),{org:t}=C();let n;return e[0]!==t||e[1]!==s?(n={mutationFn:async r=>(await(await N(F(t.slug,s,"file",{path:r.path}),{method:"PUT",headers:{"content-type":r.contentType??"text/html; charset=utf-8"},body:r.body})).json()).entry},e[0]=t,e[1]=s,e[2]=n):n=e[2],Q(n)}function Nt(s){const e=y.c(26),{org:t}=C(),n=ce();let r;e[0]!==t||e[1]!==n||e[2]!==s?(r=()=>{n.invalidateQueries({queryKey:E.orgFsVolume(t.id,s)}),n.invalidateQueries({queryKey:E.orgFsRecent(t.id)})},e[0]=t,e[1]=n,e[2]=s,e[3]=r):r=e[3];const i=r;let a;e[4]!==t||e[5]!==s?(a=async g=>{for(const k of g.files){const S=g.dir?`${g.dir}/${k.name}`:k.name;await N(F(t.slug,s,"file",{path:S}),{method:"PUT",headers:{"content-type":k.type||"application/octet-stream"},body:k})}},e[4]=t,e[5]=s,e[6]=a):a=e[6];let d;e[7]!==i||e[8]!==a?(d={mutationFn:a,onSettled:i},e[7]=i,e[8]=a,e[9]=d):d=e[9];const c=Q(d);let l;e[10]!==t||e[11]!==s?(l=async g=>{await N(F(t.slug,s,"dir",{path:g}),{method:"POST"})},e[10]=t,e[11]=s,e[12]=l):l=e[12];let f;e[13]!==i||e[14]!==l?(f={mutationFn:l,onSuccess:i},e[13]=i,e[14]=l,e[15]=f):f=e[15];const u=Q(f);let m;e[16]!==t||e[17]!==s?(m=async g=>{await N(F(t.slug,s,"file",{path:g}),{method:"DELETE"})},e[16]=t,e[17]=s,e[18]=m):m=e[18];let w;e[19]!==i||e[20]!==m?(w={mutationFn:m,onSuccess:i},e[19]=i,e[20]=m,e[21]=w):w=e[21];const j=Q(w);let b;return e[22]!==u||e[23]!==j||e[24]!==c?(b={upload:c,mkdir:u,remove:j},e[22]=u,e[23]=j,e[24]=c,e[25]=b):b=e[25],b}function qe(s){if(!s||s.includes("/")||s.includes("\\")||s.includes("..")||s.includes("\0"))return!0;try{const e=decodeURIComponent(s);return e.includes("/")||e.includes("\\")||e.includes("..")||e.includes("\0")}catch{return!0}}function Le(s){if(qe(s))throw new Error(`Invalid block key: ${s||"(empty)"}`)}function Ie(s){try{return decodeURIComponent(s)}catch{return s}}function Be(s){return Le(s),encodeURIComponent(s)}function Ae(s){return`.deco/blocks/${Be(s)}.json`}function Dt(s){return`/${Ae(s)}`}const Pt=1e4,Ke=3;function J(s){return s.trim()?(s.startsWith("/")?s:`/${s}`).replace(/\/+/g,"/"):"/"}function te(s){return s.startsWith("/")?s.slice(1):s}function Y(s){return s.trim()?s.startsWith("/")?s:`/${s}`:"/"}function He(s){const e=Y(s);if(e==="/")return"/";const t=e.split("/").filter(Boolean);return t.pop(),t.length===0?"/":`/${t.join("/")}`}function Ut(s,e){const t=e.replace(/^\/+|\/+$/g,"");return Y(t?`${s==="/"?"":s}/${t}`:s)}function Ot(s,e){return e==="directory"?s:He(s)}function zt(s){const e=s.trim();return e?e.includes("/")||e.includes("\\")||e.includes("..")||e.includes("\0")?"Name cannot contain /, \\, or ..":e.startsWith(".")?"Name cannot start with a dot":null:"Name is required"}function Ve(s){const e=te(s);return e?e.split("/").filter(Boolean).length:0}function Rt(s,e,t,n=!1){return{files:[...new Set([...s,...t.files])],directories:[...new Set([...e,...t.directories??[]])],truncated:n||!!t.truncated}}function _t(s,e){return Ve(s)>Ke&&!e.has(s)}function Wt(s,e,t=[]){const n=te(s);if(e.includes(n)||t.includes(n))return!0;if(!n)return!1;const r=`${n}/`;return e.some(i=>i.startsWith(r))||t.some(i=>i.startsWith(r))}function qt(s){const e=te(s),t=".deco/blocks/";if(!e.startsWith(t)||!e.endsWith(".json"))return null;const n=e.slice(t.length,-5);return Ie(n)}function Xe(s){if(!s)return"plaintext";const e=s.toLowerCase();return e.endsWith(".tsx")||e.endsWith(".ts")?"typescript":e.endsWith(".jsx")||e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")?"javascript":e.endsWith(".json")?"json":e.endsWith(".md")||e.endsWith(".mdx")?"markdown":e.endsWith(".css")?"css":e.endsWith(".scss")?"scss":e.endsWith(".html")?"html":e.endsWith(".yaml")||e.endsWith(".yml")?"yaml":e.endsWith(".xml")||e.endsWith(".svg")?"xml":e.endsWith(".py")?"python":e.endsWith(".sql")?"sql":e.endsWith(".sh")?"shell":"plaintext"}function Lt(s){const e=J(s).split("/").filter(Boolean),t=["/"];let n="";for(const r of e.slice(0,-1))n+=`/${r}`,t.push(n);return t}function It(s,e=[]){const t={children:[]},n=i=>{const d=J(i).split("/").filter(Boolean);let c=t,l="";for(const f of d){l+=`/${f}`;let u=c.children.find(m=>m.name===f);u?u.kind==="file"&&(u.kind="directory"):(u={name:f,path:l,kind:"directory",children:[]},c.children.push(u)),c=u}};for(const i of s){const d=J(i).split("/").filter(Boolean);let c=t,l="";d.forEach((f,u)=>{l+=`/${f}`;const m=u===d.length-1;let w=c.children.find(j=>j.name===f);w||(w={name:f,path:l,kind:m?"file":"directory",children:[]},c.children.push(w)),c=w})}for(const i of e)n(Y(i));const r=i=>{i.sort((a,d)=>a.kind!==d.kind?a.kind==="directory"?-1:1:a.name.localeCompare(d.name));for(const a of i)a.children.length>0&&r(a.children)};return r(t.children),t.children}function Ge(s,e,t=0){const n=[];for(const r of s)r.name!==".gitkeep"&&(n.push({node:r,depth:t}),r.kind==="directory"&&r.children.length>0&&e.has(r.path)&&n.push(...Ge(r.children,e,t+1)));return n}function Bt(s){return s.split(`
2
2
  `).map(e=>{const t=e.match(/^\d+\t(.*)/);return t?t[1]:e}).join(`
3
3
  `)}je.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function Qe(s){const e=y.c(11),{value:t,filename:n}=s,[r]=xe(),i=r.theme==="dark"||r.theme==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;let a;e[0]!==n?(a=Xe(n),e[0]=n,e[1]=a):a=e[1];const d=i?"vs-dark":"light";let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex h-full w-full items-center justify-center",children:o.jsx(ge,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2];let l,f;e[3]===Symbol.for("react.memo_cache_sentinel")?(l={enabled:!1},f={top:12,bottom:12},e[3]=l,e[4]=f):(l=e[3],f=e[4]);let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u={readOnly:!0,domReadOnly:!0,fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbersMinChars:3,wordWrap:"on",minimap:l,padding:f,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"auto",verticalScrollbarSize:8,horizontalScrollbarSize:8}},e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==a||e[8]!==d||e[9]!==t?(m=o.jsx(ke,{path:n,language:a,value:t,theme:d,loading:c,options:u},n),e[6]=n,e[7]=a,e[8]=d,e[9]=t,e[10]=m):m=e[10],m}function Ye(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}const Ze=new Set(["png","jpg","jpeg","gif","webp","svg","avif"]),Je=new Set(["txt","json","csv","tsv","log","yaml","yml","xml","toml","ts","tsx","js","jsx","py","rb","go","rs","java","sh","sql"]),oe=2*1024*1024;function et(s,e){const t=s.split(".").pop()?.toLowerCase()??"";return Ze.has(t)?"image":t==="pdf"?"pdf":t==="html"||t==="htm"?"html":t==="md"||t==="markdown"?e<=oe?"markdown":"download":Je.has(t)&&e<=oe?"text":"download"}function tt(){const s=y.c(2);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(G,{className:"h-6 w-2/3"}),s[0]=e):e=s[0];let t;return s[1]===Symbol.for("react.memo_cache_sentinel")?(t=o.jsx("div",{className:"flex h-full w-full items-center justify-center",children:o.jsxs("div",{className:"flex w-3/4 max-w-md flex-col gap-3 p-6",children:[e,o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx(G,{className:"h-3 w-full"}),o.jsx(G,{className:"h-3 w-5/6"}),o.jsx(G,{className:"h-3 w-2/3"})]})]})}),s[1]=t):t=s[1],t}function de(s){const e=y.c(20),{file:t,note:n}=s;let r;e[0]!==t.filename?(r=o.jsx(be,{filename:t.filename,className:"h-12 w-10"}),e[0]=t.filename,e[1]=r):r=e[1];let i;e[2]!==t.filename?(i=o.jsx("span",{className:"text-sm font-medium text-foreground",children:t.filename}),e[2]=t.filename,e[3]=i):i=e[3];let a;e[4]!==t.size?(a=Ye(t.size),e[4]=t.size,e[5]=a):a=e[5];const d=n?` · ${n}`:"";let c;e[6]!==a||e[7]!==d?(c=o.jsxs("span",{className:"text-xs text-muted-foreground",children:[a,d]}),e[6]=a,e[7]=d,e[8]=c):c=e[8];let l;e[9]!==i||e[10]!==c?(l=o.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[i,c]}),e[9]=i,e[10]=c,e[11]=l):l=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx(Z,{size:14}),e[12]=f):f=e[12];let u;e[13]!==t.downloadUrl||e[14]!==t.filename?(u=o.jsx(q,{asChild:!0,variant:"outline",size:"sm",children:o.jsxs("a",{href:t.downloadUrl,download:t.filename,children:[f,"Download"]})}),e[13]=t.downloadUrl,e[14]=t.filename,e[15]=u):u=e[15];let m;return e[16]!==r||e[17]!==l||e[18]!==u?(m=o.jsx("div",{className:"flex h-full w-full items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-border bg-muted/30 px-10 py-8",children:[r,l,u]})}),e[16]=r,e[17]=l,e[18]=u,e[19]=m):m=e[19],m}function le(s){const e=y.c(16),{file:t,markdown:n}=s;let r;e[0]!==t.downloadUrl?(r=E.fileText(t.downloadUrl),e[0]=t.downloadUrl,e[1]=r):r=e[1];let i;e[2]!==t.downloadUrl?(i=async()=>{const u=await fetch(t.downloadUrl,{credentials:"include"});if(!u.ok)throw new Error(`fetch failed: ${u.status}`);return u.text()},e[2]=t.downloadUrl,e[3]=i):i=e[3];let a;e[4]!==r||e[5]!==i?(a={queryKey:r,queryFn:i,staleTime:6e4,retry:!1},e[4]=r,e[5]=i,e[6]=a):a=e[6];const{data:d,isPending:c,isError:l}=B(a);if(c){let u;return e[7]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(tt,{}),e[7]=u):u=e[7],u}if(l||d===void 0){let u;return e[8]!==t?(u=o.jsx(de,{file:t,note:"preview unavailable"}),e[8]=t,e[9]=u):u=e[9],u}if(n){const u=`file-preview-${t.key}`;let m;return e[10]!==d||e[11]!==u?(m=o.jsx("div",{className:"h-full overflow-y-auto",children:o.jsx("div",{className:"prose prose-sm dark:prose-invert mx-auto max-w-3xl px-6 py-6",children:o.jsx(ve,{id:u,text:d})})}),e[10]=d,e[11]=u,e[12]=m):m=e[12],m}let f;return e[13]!==d||e[14]!==t.filename?(f=o.jsx(Qe,{value:d,filename:t.filename}),e[13]=d,e[14]=t.filename,e[15]=f):f=e[15],f}function At(s){const e=y.c(15),{file:t}=s;switch(et(t.filename,t.size)){case"image":{let r;return e[0]!==t.downloadUrl||e[1]!==t.filename?(r=o.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-auto bg-muted/30 p-4",children:o.jsx("img",{src:t.downloadUrl,alt:t.filename,className:"max-h-full max-w-full rounded-lg object-contain"})}),e[0]=t.downloadUrl,e[1]=t.filename,e[2]=r):r=e[2],r}case"pdf":{let r;return e[3]!==t.downloadUrl||e[4]!==t.filename?(r=o.jsx("iframe",{src:t.downloadUrl,title:t.filename,className:"block h-full w-full bg-white"}),e[3]=t.downloadUrl,e[4]=t.filename,e[5]=r):r=e[5],r}case"html":{let r;return e[6]!==t.downloadUrl||e[7]!==t.filename?(r=o.jsx("iframe",{src:t.downloadUrl,title:t.filename,sandbox:"allow-scripts",className:"block h-full w-full bg-white"}),e[6]=t.downloadUrl,e[7]=t.filename,e[8]=r):r=e[8],r}case"markdown":{let r;return e[9]!==t?(r=o.jsx(le,{file:t,markdown:!0}),e[9]=t,e[10]=r):r=e[10],r}case"text":{let r;return e[11]!==t?(r=o.jsx(le,{file:t,markdown:!1}),e[11]=t,e[12]=r):r=e[12],r}default:{let r;return e[13]!==t?(r=o.jsx(de,{file:t}),e[13]=t,e[14]=r):r=e[14],r}}}function st(s){const e=y.c(53),{readUrl:t,editor:n,downloadName:r,trailing:i}=s,[a,d]=v.useState(!1);let c;e[0]!==t?(c=new URL(t,window.location.origin).toString(),e[0]=t,e[1]=c):c=e[1];const l=c;let f;e[2]!==l?(f=()=>{navigator.clipboard.writeText(l),d(!0),window.setTimeout(()=>d(!1),1500)},e[2]=l,e[3]=f):f=e[3];const u=f;let m;e[4]!==n?(m=n.deckDetected&&o.jsxs(A,{children:[o.jsx(K,{asChild:!0,children:o.jsx(q,{variant:n.railOpen?"secondary":"ghost",size:"icon","aria-label":n.railOpen?"Hide slide list":"Show slide list",onClick:()=>n.setRailOpen(!n.railOpen),children:o.jsx(Pe,{size:14})})}),o.jsx(H,{side:"bottom",children:n.railOpen?"Hide slide list":"Show slide list"})]}),e[4]=n,e[5]=m):m=e[5];let w;e[6]!==l?(w=()=>window.open(l,"_blank","noopener"),e[6]=l,e[7]=w):w=e[7];let j;e[8]!==l?(j=o.jsx("span",{className:"truncate",children:l}),e[8]=l,e[9]=j):j=e[9];let b;e[10]!==l||e[11]!==w||e[12]!==j?(b=o.jsx("button",{type:"button",onClick:w,className:"flex min-w-0 flex-1 items-center rounded-md px-2 py-1 text-left text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",title:l,children:j}),e[10]=l,e[11]=w,e[12]=j,e[13]=b):b=e[13];let g;e[14]!==n.agentUpdated||e[15]!==n.reload?(g=n.agentUpdated&&o.jsxs(A,{children:[o.jsx(K,{asChild:!0,children:o.jsxs(q,{variant:"outline",size:"sm",className:"h-7 gap-1 text-xs",onClick:n.reload,children:[o.jsx(ye,{size:12}),"Agent updated — reload"]})}),o.jsx(H,{side:"bottom",children:"The agent rewrote this deck while you were editing. Reloading discards unsaved differences."})]}),e[14]=n.agentUpdated,e[15]=n.reload,e[16]=g):g=e[16];let k;e[17]!==n.saving?(k=n.saving&&o.jsx("span",{className:"px-1 text-xs text-muted-foreground",children:"Saving…"}),e[17]=n.saving,e[18]=k):k=e[18];let S;e[19]!==n?(S=n.deckDetected&&n.writable&&o.jsxs(A,{children:[o.jsx(K,{asChild:!0,children:o.jsx(q,{variant:n.editMode?"secondary":"ghost",size:"icon","aria-label":n.editMode?"Done editing":"Edit inline",className:ee(n.editMode&&"text-primary"),onClick:()=>n.setEditMode(!n.editMode),children:o.jsx(Me,{size:14})})}),o.jsx(H,{side:"bottom",children:n.editMode?"Done editing":"Edit inline (text, reorder, delete)"})]}),e[19]=n,e[20]=S):S=e[20];let M;e[21]!==l||e[22]!==r||e[23]!==n.deckDetected?(M=n.deckDetected?o.jsxs(Se,{children:[o.jsx($e,{asChild:!0,children:o.jsx(q,{variant:"ghost",size:"icon","aria-label":"Download",children:o.jsx(Z,{size:14})})}),o.jsxs(Te,{align:"end",children:[o.jsxs(ie,{onClick:()=>window.open(`${l}#print`,"_blank","noopener"),children:[o.jsx(Fe,{size:14}),"Export as PDF"]}),o.jsx(ie,{asChild:!0,children:o.jsxs("a",{href:l,download:r,children:[o.jsx(Ne,{size:14}),"Download HTML"]})})]})]}):o.jsxs(A,{children:[o.jsx(K,{asChild:!0,children:o.jsx(q,{variant:"ghost",size:"icon","aria-label":"Download",asChild:!0,children:o.jsx("a",{href:l,download:r,children:o.jsx(Z,{size:14})})})}),o.jsx(H,{side:"bottom",children:"Download"})]}),e[21]=l,e[22]=r,e[23]=n.deckDetected,e[24]=M):M=e[24];let P;e[25]!==a?(P=a?o.jsx(Ee,{size:14}):o.jsx(Ce,{size:14}),e[25]=a,e[26]=P):P=e[26];let U;e[27]!==u||e[28]!==P?(U=o.jsx(K,{asChild:!0,children:o.jsx(q,{variant:"ghost",size:"icon","aria-label":"Copy URL",onClick:u,children:P})}),e[27]=u,e[28]=P,e[29]=U):U=e[29];const X=a?"Copied":"Copy URL";let p;e[30]!==X?(p=o.jsx(H,{side:"bottom",children:X}),e[30]=X,e[31]=p):p=e[31];let O;e[32]!==U||e[33]!==p?(O=o.jsxs(A,{children:[U,p]}),e[32]=U,e[33]=p,e[34]=O):O=e[34];let D;e[35]!==l?(D=()=>window.open(l,"_blank","noopener"),e[35]=l,e[36]=D):D=e[36];let $;e[37]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx(Ue,{size:14}),e[37]=$):$=e[37];let T;e[38]!==D?(T=o.jsx(K,{asChild:!0,children:o.jsx(q,{variant:"ghost",size:"icon","aria-label":"Open in new tab",onClick:D,children:$})}),e[38]=D,e[39]=T):T=e[39];let I;e[40]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(H,{side:"bottom",children:"Open in new tab"}),e[40]=I):I=e[40];let z;e[41]!==T?(z=o.jsxs(A,{children:[T,I]}),e[41]=T,e[42]=z):z=e[42];let R;return e[43]!==M||e[44]!==O||e[45]!==z||e[46]!==m||e[47]!==b||e[48]!==g||e[49]!==k||e[50]!==S||e[51]!==i?(R=o.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[m,b,g,k,S,M,O,z,i]}),e[43]=M,e[44]=O,e[45]=z,e[46]=m,e[47]=b,e[48]=g,e[49]=k,e[50]=S,e[51]=i,e[52]=R):R=e[52],R}const V=1;function nt(s){if(typeof s!="object"||s===null||s.v!==V||s.source!=="deck-viewer")return null;const e=s;return e.type==="ready"||e.type==="state"||e.type==="op"&&typeof e.opId=="string"&&e.op?e:null}class L extends Error{constructor(e,t){super(e),this.code=t,this.name="DeckOpError"}code}function ue(s){return[...s.children].filter(e=>!/^(TEMPLATE|SCRIPT|STYLE)$/.test(e.tagName))}function rt(s){const t=new DOMParser().parseFromString(s,"text/html").querySelector("deck-viewer");return t?ue(t).length:null}function it(s,e){const t=new DOMParser().parseFromString(s,"text/html"),n=t.querySelector("deck-viewer");if(!n)throw new L("no <deck-viewer> element in source","no-viewer");const r=ue(n),i=e.kind==="move"?e.from:e.at,a=r[i];if(!a)throw new L(`slide index ${i} out of range (${r.length})`,"stale-index");switch(e.kind){case"remove":{if(r.length<=1)throw new L("cannot remove the last slide","bad-op");a.remove();break}case"duplicate":{const c=a.cloneNode(!0);c.removeAttribute("id");for(const l of c.querySelectorAll("[id]"))l.removeAttribute("id");a.after(c);break}case"move":{if(e.to<0||e.to>=r.length)throw new L(`move target ${e.to} out of range`,"stale-index");if(e.to!==e.from){const c=e.to<e.from?r[e.to]:r[e.to].nextSibling;n.insertBefore(a,c)}break}case"set-attr":{if(!/^[a-zA-Z][\w-]*$/.test(e.name))throw new L(`invalid attribute name: ${e.name}`,"bad-op");a.setAttribute(e.name,e.value);break}case"remove-attr":{a.removeAttribute(e.name);break}case"replace":{const l=new DOMParser().parseFromString(e.html,"text/html").body.firstElementChild;if(!l)throw new L("replace html has no root element","bad-op");a.replaceWith(t.importNode(l,!0));break}default:throw new L(`unknown op kind: ${e.kind}`,"bad-op")}return`${s.trimStart().toLowerCase().startsWith("<!doctype")?`<!DOCTYPE html>
4
4
  `:""}${t.documentElement.outerHTML}
@@ -1 +1 @@
1
- import{r as c,j as d,dm as M,a7 as F,a8 as f,dp as T,ag as $,bk as O,bx as I,dq as U,dr as W,dt as z,dn as B,bh as G,dl as K,e as E,c as q}from"./index-DHxOddsj.js";var w,b="HoverCard",[N]=$(b,[T]),R=T(),[V,S]=N(b),_=o=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:a,onOpenChange:s,openDelay:l=700,closeDelay:u=300}=o,i=R(e),p=c.useRef(0),v=c.useRef(0),C=c.useRef(!1),h=c.useRef(!1),[m,n]=G({prop:r,defaultProp:a??!1,onChange:s,caller:b}),x=c.useCallback(()=>{clearTimeout(v.current),p.current=window.setTimeout(()=>n(!0),l)},[l,n]),L=c.useCallback(()=>{clearTimeout(p.current),!C.current&&!h.current&&(v.current=window.setTimeout(()=>n(!1),u))},[u,n]),k=c.useCallback(()=>n(!1),[n]);return c.useEffect(()=>()=>{clearTimeout(p.current),clearTimeout(v.current)},[]),d.jsx(V,{scope:e,open:m,onOpenChange:n,onOpen:x,onClose:L,onDismiss:k,hasSelectionRef:C,isPointerDownOnContentRef:h,children:d.jsx(K,{...i,children:t})})};_.displayName=b;var y="HoverCardTrigger",D=c.forwardRef((o,e)=>{const{__scopeHoverCard:t,...r}=o,a=S(y,t),s=R(t);return d.jsx(M,{asChild:!0,...s,children:d.jsx(F.a,{"data-state":a.open?"open":"closed",...r,ref:e,onPointerEnter:f(o.onPointerEnter,P(a.onOpen)),onPointerLeave:f(o.onPointerLeave,P(a.onClose)),onFocus:f(o.onFocus,a.onOpen),onBlur:f(o.onBlur,a.onClose),onTouchStart:f(o.onTouchStart,l=>l.preventDefault())})})});D.displayName=y;var H="HoverCardPortal",[J,Q]=N(H,{forceMount:void 0}),j=o=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:a}=o,s=S(H,e);return d.jsx(J,{scope:e,forceMount:t,children:d.jsx(O,{present:t||s.open,children:d.jsx(B,{asChild:!0,container:a,children:r})})})};j.displayName=H;var g="HoverCardContent",A=c.forwardRef((o,e)=>{const t=Q(g,o.__scopeHoverCard),{forceMount:r=t.forceMount,...a}=o,s=S(g,o.__scopeHoverCard);return d.jsx(O,{present:r||s.open,children:d.jsx(X,{"data-state":s.open?"open":"closed",...a,onPointerEnter:f(o.onPointerEnter,P(s.onOpen)),onPointerLeave:f(o.onPointerLeave,P(s.onClose)),ref:e})})});A.displayName=g;var X=c.forwardRef((o,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:s,onInteractOutside:l,...u}=o,i=S(g,t),p=R(t),v=c.useRef(null),C=I(e,v),[h,m]=c.useState(!1);return c.useEffect(()=>{if(h){const n=document.body;return w=n.style.userSelect||n.style.webkitUserSelect,n.style.userSelect="none",n.style.webkitUserSelect="none",()=>{n.style.userSelect=w,n.style.webkitUserSelect=w}}},[h]),c.useEffect(()=>{if(v.current){const n=()=>{m(!1),i.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(i.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",n),()=>{document.removeEventListener("pointerup",n),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!1}}},[i.isPointerDownOnContentRef,i.hasSelectionRef]),c.useEffect(()=>{v.current&&ee(v.current).forEach(x=>x.setAttribute("tabindex","-1"))}),d.jsx(U,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:f(s,n=>{n.preventDefault()}),onDismiss:i.onDismiss,children:d.jsx(W,{...p,...u,onPointerDown:f(u.onPointerDown,n=>{n.currentTarget.contains(n.target)&&m(!0),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!0}),ref:C,style:{...u.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Y="HoverCardArrow",Z=c.forwardRef((o,e)=>{const{__scopeHoverCard:t,...r}=o,a=R(t);return d.jsx(z,{...a,...r,ref:e})});Z.displayName=Y;function P(o){return e=>e.pointerType==="touch"?void 0:o()}function ee(o){const e=[],t=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var te=_,oe=D,re=j,ne=A;function se(o){const e=E.c(4);let t;e[0]!==o?({...t}=o,e[0]=o,e[1]=t):t=e[1];let r;return e[2]!==t?(r=d.jsx(te,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function ie(o){const e=E.c(4);let t;e[0]!==o?({...t}=o,e[0]=o,e[1]=t):t=e[1];let r;return e[2]!==t?(r=d.jsx(oe,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function ce(o){const e=E.c(12);let t,r,a,s;e[0]!==o?({className:t,align:a,sideOffset:s,...r}=o,e[0]=o,e[1]=t,e[2]=r,e[3]=a,e[4]=s):(t=e[1],r=e[2],a=e[3],s=e[4]);const l=a===void 0?"center":a,u=s===void 0?4:s;let i;e[5]!==t?(i=q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=i):i=e[6];let p;return e[7]!==l||e[8]!==r||e[9]!==u||e[10]!==i?(p=d.jsx(re,{"data-slot":"hover-card-portal",children:d.jsx(ne,{"data-slot":"hover-card-content",align:l,sideOffset:u,className:i,...r})}),e[7]=l,e[8]=r,e[9]=u,e[10]=i,e[11]=p):p=e[11],p}export{ie as H,ce as a,se as b};
1
+ import{r as c,j as d,dm as M,a7 as F,a8 as f,dp as T,ag as $,bk as O,bx as I,dq as U,dr as W,dt as z,dn as B,bh as G,dl as K,e as E,c as q}from"./index-BPnG82q8.js";var w,b="HoverCard",[N]=$(b,[T]),R=T(),[V,S]=N(b),_=o=>{const{__scopeHoverCard:e,children:t,open:r,defaultOpen:a,onOpenChange:s,openDelay:l=700,closeDelay:u=300}=o,i=R(e),p=c.useRef(0),v=c.useRef(0),C=c.useRef(!1),h=c.useRef(!1),[m,n]=G({prop:r,defaultProp:a??!1,onChange:s,caller:b}),x=c.useCallback(()=>{clearTimeout(v.current),p.current=window.setTimeout(()=>n(!0),l)},[l,n]),L=c.useCallback(()=>{clearTimeout(p.current),!C.current&&!h.current&&(v.current=window.setTimeout(()=>n(!1),u))},[u,n]),k=c.useCallback(()=>n(!1),[n]);return c.useEffect(()=>()=>{clearTimeout(p.current),clearTimeout(v.current)},[]),d.jsx(V,{scope:e,open:m,onOpenChange:n,onOpen:x,onClose:L,onDismiss:k,hasSelectionRef:C,isPointerDownOnContentRef:h,children:d.jsx(K,{...i,children:t})})};_.displayName=b;var y="HoverCardTrigger",D=c.forwardRef((o,e)=>{const{__scopeHoverCard:t,...r}=o,a=S(y,t),s=R(t);return d.jsx(M,{asChild:!0,...s,children:d.jsx(F.a,{"data-state":a.open?"open":"closed",...r,ref:e,onPointerEnter:f(o.onPointerEnter,P(a.onOpen)),onPointerLeave:f(o.onPointerLeave,P(a.onClose)),onFocus:f(o.onFocus,a.onOpen),onBlur:f(o.onBlur,a.onClose),onTouchStart:f(o.onTouchStart,l=>l.preventDefault())})})});D.displayName=y;var H="HoverCardPortal",[J,Q]=N(H,{forceMount:void 0}),j=o=>{const{__scopeHoverCard:e,forceMount:t,children:r,container:a}=o,s=S(H,e);return d.jsx(J,{scope:e,forceMount:t,children:d.jsx(O,{present:t||s.open,children:d.jsx(B,{asChild:!0,container:a,children:r})})})};j.displayName=H;var g="HoverCardContent",A=c.forwardRef((o,e)=>{const t=Q(g,o.__scopeHoverCard),{forceMount:r=t.forceMount,...a}=o,s=S(g,o.__scopeHoverCard);return d.jsx(O,{present:r||s.open,children:d.jsx(X,{"data-state":s.open?"open":"closed",...a,onPointerEnter:f(o.onPointerEnter,P(s.onOpen)),onPointerLeave:f(o.onPointerLeave,P(s.onClose)),ref:e})})});A.displayName=g;var X=c.forwardRef((o,e)=>{const{__scopeHoverCard:t,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:s,onInteractOutside:l,...u}=o,i=S(g,t),p=R(t),v=c.useRef(null),C=I(e,v),[h,m]=c.useState(!1);return c.useEffect(()=>{if(h){const n=document.body;return w=n.style.userSelect||n.style.webkitUserSelect,n.style.userSelect="none",n.style.webkitUserSelect="none",()=>{n.style.userSelect=w,n.style.webkitUserSelect=w}}},[h]),c.useEffect(()=>{if(v.current){const n=()=>{m(!1),i.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(i.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",n),()=>{document.removeEventListener("pointerup",n),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!1}}},[i.isPointerDownOnContentRef,i.hasSelectionRef]),c.useEffect(()=>{v.current&&ee(v.current).forEach(x=>x.setAttribute("tabindex","-1"))}),d.jsx(U,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:f(s,n=>{n.preventDefault()}),onDismiss:i.onDismiss,children:d.jsx(W,{...p,...u,onPointerDown:f(u.onPointerDown,n=>{n.currentTarget.contains(n.target)&&m(!0),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!0}),ref:C,style:{...u.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Y="HoverCardArrow",Z=c.forwardRef((o,e)=>{const{__scopeHoverCard:t,...r}=o,a=R(t);return d.jsx(z,{...a,...r,ref:e})});Z.displayName=Y;function P(o){return e=>e.pointerType==="touch"?void 0:o()}function ee(o){const e=[],t=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;t.nextNode();)e.push(t.currentNode);return e}var te=_,oe=D,re=j,ne=A;function se(o){const e=E.c(4);let t;e[0]!==o?({...t}=o,e[0]=o,e[1]=t):t=e[1];let r;return e[2]!==t?(r=d.jsx(te,{"data-slot":"hover-card",...t}),e[2]=t,e[3]=r):r=e[3],r}function ie(o){const e=E.c(4);let t;e[0]!==o?({...t}=o,e[0]=o,e[1]=t):t=e[1];let r;return e[2]!==t?(r=d.jsx(oe,{"data-slot":"hover-card-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function ce(o){const e=E.c(12);let t,r,a,s;e[0]!==o?({className:t,align:a,sideOffset:s,...r}=o,e[0]=o,e[1]=t,e[2]=r,e[3]=a,e[4]=s):(t=e[1],r=e[2],a=e[3],s=e[4]);const l=a===void 0?"center":a,u=s===void 0?4:s;let i;e[5]!==t?(i=q("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),e[5]=t,e[6]=i):i=e[6];let p;return e[7]!==l||e[8]!==r||e[9]!==u||e[10]!==i?(p=d.jsx(re,{"data-slot":"hover-card-portal",children:d.jsx(ne,{"data-slot":"hover-card-content",align:l,sideOffset:u,className:i,...r})}),e[7]=l,e[8]=r,e[9]=u,e[10]=i,e[11]=p):p=e[11],p}export{ie as H,ce as a,se as b};
@@ -1 +1 @@
1
- import{e as w,q as be,a as Ne,K as ke,j as t,E as we,r as $,c as de,B as Y,l as Ce,P as Se,o as Q}from"./index-DHxOddsj.js";import{a as H}from"./Tool01-Cm1sVqXs.js";import{s as _e}from"./Trash01-CA4jg9ww.js";import{i as fe}from"./Upload01-BbVOBYlS.js";import{I as Ie}from"./input-C3YblD3D.js";import{L as Pe}from"./label-g7a72jJD.js";import{i as Ue}from"./AlertCircle-A2M1Yk61.js";import{i as ge}from"./Check-Cl07asRj.js";import{a as $e}from"./Eye-lcuSJE4l.js";import{i as De}from"./DotsVertical-_g_anHKb.js";import{H as ze}from"./agent-icon-cetEWq0Z.js";import{n as Fe}from"./LinkExternal01-r7kaLetr.js";import{D as Te,c as Ee,e as Le,b as Oe,a as Ae}from"./dialog-BnOLdErK.js";import{c as ce,a as Re,D as Be,b as Ge}from"./dropdown-menu-mHDT-XH7.js";import{S as Me}from"./skeleton-B2rX4p4v.js";import{T as Ve,a as Ke,b as qe,c as Je}from"./tabs-D_XRbq3N.js";import{u as Qe,c as Ye}from"./use-file-configs-C_uUU82K.js";import{u as He}from"./useInfiniteQuery-DnxNK7B2.js";import{u as We}from"./studio-tools-CH7dZ7HT.js";function Xe(s){if(typeof s=="string")return s;if(!s||typeof s!="object")return"";const e=s;if(Array.isArray(e.variants)){const n=e.variants,l=n.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof l?.value=="string")return l.value;const i=n.find(o=>typeof o.value=="string");if(i)return i.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function Ze(s){const e=w.c(10),{org:n}=be(),l=We();let i;e[0]!==n.id||e[1]!==s.configId?(i=ke.filePickerObjects(n.id,s.configId),e[0]=n.id,e[1]=s.configId,e[2]=i):i=e[2];const o=s.enabled!==!1&&!!s.configId;let a;e[3]!==s.configId||e[4]!==l?(a=async m=>{const{pageParam:c}=m;return await l.call("FILE_OBJECTS_LIST",{configId:s.configId,cursor:c??void 0})},e[3]=s.configId,e[4]=l,e[5]=a):a=e[5];let r;return e[6]!==i||e[7]!==o||e[8]!==a?(r={queryKey:i,enabled:o,staleTime:3e4,initialPageParam:null,queryFn:a,getNextPageParam:et},e[6]=i,e[7]=o,e[8]=a,e[9]=r):r=e[9],He(r)}function et(s){return s.nextCursor??void 0}function je(){const s=w.c(2),{org:e}=be();let n;return s[0]!==e?(n={mutationFn:async l=>{const i=l.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(l.configId)}/upload?filename=${encodeURIComponent(l.file.name)}`,{method:"POST",headers:{"Content-Type":i},body:l.file});if(!o.ok){const a=await o.text().catch(tt);let r=`${o.status} ${o.statusText}`;try{const m=JSON.parse(a);m.message&&(r=m.message)}catch{a&&(r=a.slice(0,200))}throw new Error(`Upload failed: ${r}`)}return await o.json()}},s[0]=e,s[1]=n):n=s[1],Ne(n)}function tt(){return""}const ue="file-picker:last-config-id";function st(s){const e=w.c(18),n=s.mode==="image"?"Pick an image":"Pick a file";let l;e[0]!==n?(l=t.jsx(Ee,{children:n}),e[0]=n,e[1]=l):l=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Le,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=i):i=e[2];let o;e[3]!==l?(o=t.jsxs(Oe,{children:[l,i]}),e[3]=l,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Me,{className:"h-64 w-full"}),e[5]=a):a=e[5];let r;e[6]!==s?(r=d=>{s.onSelect(d),s.onOpenChange(!1)},e[6]=s,e[7]=r):r=e[7];let m;e[8]!==s.mode||e[9]!==r?(m=t.jsx(we,{fallback:nt,children:t.jsx($.Suspense,{fallback:a,children:t.jsx(lt,{mode:s.mode,onSelect:r})})}),e[8]=s.mode,e[9]=r,e[10]=m):m=e[10];let c;e[11]!==o||e[12]!==m?(c=t.jsxs(Ae,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,m]}),e[11]=o,e[12]=m,e[13]=c):c=e[13];let p;return e[14]!==s.onOpenChange||e[15]!==s.open||e[16]!==c?(p=t.jsx(Te,{open:s.open,onOpenChange:s.onOpenChange,children:c}),e[14]=s.onOpenChange,e[15]=s.open,e[16]=c,e[17]=p):p=e[17],p}function nt(s){const{error:e}=s;return t.jsx(it,{error:e??new Error("Failed to load buckets")})}function it(s){const e=w.c(3),{error:n}=s;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Ue,{size:16}),e[0]=l):l=e[0];let i;return e[1]!==n.message?(i=t.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[l,t.jsx("span",{className:"text-sm font-medium",children:n.message})]}),e[1]=n.message,e[2]=i):i=e[2],i}function lt(s){const e=w.c(23),{mode:n,onSelect:l}=s,i=Qe();if(i.length===0){let f;return e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(at,{}),e[0]=f):f=e[0],f}if(i.length===1){const f=i[0];let g;return e[1]!==f||e[2]!==n||e[3]!==l?(g=t.jsx(pe,{config:f,mode:n,onSelect:l}),e[1]=f,e[2]=n,e[3]=l,e[4]=g):g=e[4],g}let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=typeof window<"u"?window.localStorage.getItem(ue):null,e[5]=o):o=e[5];const a=o;let r;e[6]!==i?(r=i.find(f=>f.id===a)?.id??i[0].id,e[6]=i,e[7]=r):r=e[7];const m=r;let c;e[8]!==i?(c=i.map(rt),e[8]=i,e[9]=c):c=e[9];let p;e[10]!==c?(p=t.jsx(Ke,{className:"self-start",children:c}),e[10]=c,e[11]=p):p=e[11];let d;if(e[12]!==i||e[13]!==n||e[14]!==l){let f;e[16]!==n||e[17]!==l?(f=g=>t.jsx(qe,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(pe,{config:g,mode:n,onSelect:l})},g.id),e[16]=n,e[17]=l,e[18]=f):f=e[18],d=i.map(f),e[12]=i,e[13]=n,e[14]=l,e[15]=d}else d=e[15];let x;return e[19]!==m||e[20]!==p||e[21]!==d?(x=t.jsxs(Je,{defaultValue:m,onValueChange:ot,className:"min-h-0 flex-1 flex flex-col",children:[p,d]}),e[19]=m,e[20]=p,e[21]=d,e[22]=x):x=e[22],x}function rt(s){return t.jsx(Ve,{value:s.id,children:s.name},s.id)}function ot(s){typeof window<"u"&&window.localStorage.setItem(ue,s)}function at(){const s=w.c(3);let e,n;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:t.jsx(fe,{size:20,className:"text-muted-foreground"})}),n=t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),s[0]=e,s[1]=n):(e=s[0],n=s[1]);let l;return s[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[e,n,t.jsx(Y,{asChild:!0,size:"sm",className:"mt-2",children:t.jsx(Se,{to:"/settings/files",children:"Configure a bucket"})})]}),s[2]=l):l=s[2],l}function pe({config:s,mode:e,onSelect:n}){const l=Ze({configId:s.id}),i=je(),[o,a]=$.useState(!1),r=$.useRef(null),m=e==="image"?"image/*":void 0;async function c(u){if(!u)return;const y=Array.from(u);if(y.length===0)return;let k=null;const b=[];for(const N of y)try{const h=await i.mutateAsync({configId:s.id,file:N});k??=h.publicUrl}catch(h){b.push(`${N.name} (${h instanceof Error?h.message:"upload failed"})`)}await l.refetch(),b.length>0&&Q.error(b.length===y.length?`Upload failed: ${b.join("; ")}`:`Some files failed: ${b.join("; ")}`),k&&n(k)}function p(u){u.preventDefault(),a(!0)}function d(){a(!1)}function x(u){u.preventDefault(),a(!1),c(u.dataTransfer.files)}const g=(l.data?.pages??[]).flatMap(u=>u.items),j=g.filter(u=>e==="image"?ye(u.key):!0);return t.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[t.jsxs("button",{type:"button",onClick:()=>r.current?.click(),onDragOver:p,onDragLeave:d,onDrop:x,className:de("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",o&&"border-primary bg-primary/5",i.isPending&&"opacity-60 pointer-events-none"),children:[t.jsx(fe,{size:18,className:"text-muted-foreground"}),t.jsx("p",{className:"text-sm font-medium",children:i.isPending?"Uploading…":"Drop files here or click to upload"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),t.jsx("input",{ref:r,type:"file",accept:m,multiple:!0,className:"hidden",onChange:u=>{const y=u.target.files;u.target.value="",c(y)}})]}),l.isFetching&&!l.isFetchingNextPage?t.jsx("div",{className:"flex justify-end",children:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading…"})}):null,t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[j.length===0?e==="image"&&g.length>0?t.jsx(dt,{}):t.jsx(ct,{}):e==="image"?t.jsx(ut,{items:j,onSelect:n}):t.jsx(mt,{items:j,onSelect:n}),l.hasNextPage&&t.jsx("div",{className:"flex justify-center py-4",children:t.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>l.fetchNextPage(),children:l.isFetchingNextPage?t.jsxs(t.Fragment,{children:[t.jsx(Ce,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function ct(){const s=w.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[t.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:t.jsx(H,{size:18,className:"text-muted-foreground"})}),t.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),s[0]=e):e=s[0],e}function dt(){const s=w.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[t.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:t.jsx(H,{size:18,className:"text-muted-foreground"})}),t.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),s[0]=e):e=s[0],e}function ye(s){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(s)}function ft(s){const e=s.lastIndexOf(".");return e<0||e===s.length-1?"file":s.slice(e+1).toLowerCase()}function ut(s){const e=w.c(7),{items:n,onSelect:l}=s;let i;if(e[0]!==n||e[1]!==l){let a;e[3]!==l?(a=r=>t.jsx(ve,{item:r,variant:"image",onSelect:l},r.key),e[3]=l,e[4]=a):a=e[4],i=n.map(a),e[0]=n,e[1]=l,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:i}),e[5]=i,e[6]=o):o=e[6],o}function mt(s){const e=w.c(7),{items:n,onSelect:l}=s;let i;if(e[0]!==n||e[1]!==l){let a;e[3]!==l?(a=r=>t.jsx("li",{children:t.jsx(ve,{item:r,variant:"row",onSelect:l})},r.key),e[3]=l,e[4]=a):a=e[4],i=n.map(a),e[0]=n,e[1]=l,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=t.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:i}),e[5]=i,e[6]=o):o=e[6],o}function ve(s){const e=w.c(58),{item:n,variant:l,onSelect:i}=s;let o;e[0]!==n.key?(o=ft(n.key),e[0]=n.key,e[1]=o):o=e[1];const a=o;if(l==="image"){let b;e[2]!==n.publicUrl||e[3]!==i?(b=()=>i(n.publicUrl),e[2]=n.publicUrl,e[3]=i,e[4]=b):b=e[4];let N;e[5]!==n.key||e[6]!==n.publicUrl?(N=t.jsx("img",{src:n.publicUrl,alt:n.key,loading:"lazy",className:"h-full w-full object-cover",onError:gt}),e[5]=n.key,e[6]=n.publicUrl,e[7]=N):N=e[7];let h;e[8]!==n.key||e[9]!==b||e[10]!==N?(h=t.jsx("button",{type:"button",onClick:b,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:n.key,children:N}),e[8]=n.key,e[9]=b,e[10]=N,e[11]=h):h=e[11];let C;e[12]!==a?(C=t.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=C):C=e[13];let _;e[14]!==n||e[15]!==i?(_=t.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(xe,{item:n,onSelect:i})}),e[14]=n,e[15]=i,e[16]=_):_=e[16];let S;e[17]!==n.key?(S=he(n.key),e[17]=n.key,e[18]=S):S=e[18];let I;e[19]!==S?(I=t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx("p",{className:"truncate text-xs text-white",children:S})}),e[19]=S,e[20]=I):I=e[20];let P;return e[21]!==h||e[22]!==C||e[23]!==_||e[24]!==I?(P=t.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[h,C,_,I]}),e[21]=h,e[22]=C,e[23]=_,e[24]=I,e[25]=P):P=e[25],P}let r;e[26]!==n.publicUrl||e[27]!==i?(r=()=>i(n.publicUrl),e[26]=n.publicUrl,e[27]=i,e[28]=r):r=e[28];let m;e[29]!==n.key?(m=t.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:ye(n.key)?t.jsx(H,{size:16,className:"text-muted-foreground"}):t.jsx(ze,{size:16,className:"text-muted-foreground"})}),e[29]=n.key,e[30]=m):m=e[30];let c;e[31]!==n.key?(c=he(n.key),e[31]=n.key,e[32]=c):c=e[32];let p;e[33]!==c?(p=t.jsx("p",{className:"truncate text-sm font-medium",children:c}),e[33]=c,e[34]=p):p=e[34];let d;e[35]!==n.key?(d=t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:n.key}),e[35]=n.key,e[36]=d):d=e[36];let x;e[37]!==p||e[38]!==d?(x=t.jsxs("div",{className:"min-w-0 flex-1",children:[p,d]}),e[37]=p,e[38]=d,e[39]=x):x=e[39];let f;e[40]!==a?(f=t.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=f):f=e[41];let g;e[42]!==n.size?(g=bt(n.size),e[42]=n.size,e[43]=g):g=e[43];let j;e[44]!==g?(j=t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:g}),e[44]=g,e[45]=j):j=e[45];let u;e[46]!==j||e[47]!==r||e[48]!==m||e[49]!==x||e[50]!==f?(u=t.jsxs("button",{type:"button",onClick:r,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[m,x,f,j]}),e[46]=j,e[47]=r,e[48]=m,e[49]=x,e[50]=f,e[51]=u):u=e[51];let y;e[52]!==n||e[53]!==i?(y=t.jsx(xe,{item:n,onSelect:i}),e[52]=n,e[53]=i,e[54]=y):y=e[54];let k;return e[55]!==u||e[56]!==y?(k=t.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[u,y]}),e[55]=u,e[56]=y,e[57]=k):k=e[57],k}function gt(s){s.target.style.display="none"}function xe(s){const e=w.c(22),{item:n,onSelect:l}=s,[i,o]=$.useState(!1);let a;e[0]!==n.publicUrl?(a=async function(b){b.preventDefault(),b.stopPropagation();try{await navigator.clipboard.writeText(n.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{Q.error("Failed to copy URL")}},e[0]=n.publicUrl,e[1]=a):a=e[1];const r=a;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Re,{asChild:!0,children:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:ht,"aria-label":"Asset actions",children:t.jsx(De,{size:14})})}),e[2]=m):m=e[2];let c;e[3]!==n.publicUrl||e[4]!==l?(c=()=>l(n.publicUrl),e[3]=n.publicUrl,e[4]=l,e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(ge,{size:14}),e[6]=p):p=e[6];let d;e[7]!==c?(d=t.jsxs(ce,{onClick:c,children:[p,"Use this"]}),e[7]=c,e[8]=d):d=e[8];let x;e[9]!==i?(x=i?t.jsx(ge,{size:14}):t.jsx($e,{size:14}),e[9]=i,e[10]=x):x=e[10];const f=i?"Copied":"Copy URL";let g;e[11]!==r||e[12]!==x||e[13]!==f?(g=t.jsxs(ce,{onClick:r,children:[x,f]}),e[11]=r,e[12]=x,e[13]=f,e[14]=g):g=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(Fe,{size:14}),e[15]=j):j=e[15];let u;e[16]!==n.publicUrl?(u=t.jsx(ce,{asChild:!0,children:t.jsxs("a",{href:n.publicUrl,target:"_blank",rel:"noreferrer",onClick:pt,children:[j,"Open in new tab"]})}),e[16]=n.publicUrl,e[17]=u):u=e[17];let y;return e[18]!==u||e[19]!==d||e[20]!==g?(y=t.jsxs(Be,{children:[m,t.jsxs(Ge,{align:"end",onClick:xt,children:[d,g,u]})]}),e[18]=u,e[19]=d,e[20]=g,e[21]=y):y=e[21],y}function pt(s){return s.stopPropagation()}function xt(s){return s.stopPropagation()}function ht(s){return s.stopPropagation()}function he(s){const e=s.split("/");return e[e.length-1]??s}function bt(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function jt(s){try{const e=new URL(s).pathname;return decodeURIComponent(e.split("/").pop()??s)}catch{return s.split("/").pop()??s}}function yt(s){const e=s.lastIndexOf(".");return e<0||e===s.length-1?"":s.slice(e+1).toLowerCase()}const vt=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function Gt(s){const e=w.c(79),{schema:n,value:l,onChange:i,path:o,label:a}=s,r=Xe(l),[m,c]=$.useState(!1),[p,d]=$.useState(!1),[x,f]=$.useState(!1),[g,j]=$.useState(!1),u=r?jt(r):"",y=u?yt(u):"",k=Ye(),b=je();let N;e[0]!==i||e[1]!==j||e[2]!==f?(N=function(v){f(!1),j(!1),i(v)},e[0]=i,e[1]=j,e[2]=f,e[3]=N):N=e[3];const h=N;let C;e[4]!==k.data?.configs?(C=function(){const v=k.data?.configs??[];if(v.length===1)return v[0].id;if(v.length===0)return null;const D=typeof window<"u"?window.localStorage.getItem(ue):null;return v.some(te=>te.id===D)?D:null},e[4]=k.data?.configs,e[5]=C):C=e[5];const _=C;let S;e[6]!==_||e[7]!==c||e[8]!==h||e[9]!==b?(S=async function(v){if(!v)return;const D=Array.from(v).filter(Nt);if(D.length===0){Q.error("Only image files are accepted here.");return}const te=_();if(!te){c(!0);return}try{const ae=await b.mutateAsync({configId:te,file:D[0]});h(ae.publicUrl),D.length>1&&Q.info(`Uploaded ${D[0].name}; extra files were ignored (single-select field).`)}catch(ae){const me=ae;Q.error(me instanceof Error?me.message:"Upload failed")}},e[6]=_,e[7]=c,e[8]=h,e[9]=b,e[10]=S):S=e[10];const I=S;let P;e[11]!==d?(P=function(v){v.preventDefault(),v.dataTransfer.types.includes("Files")&&d(!0)},e[11]=d,e[12]=P):P=e[12];const se=P;let W;e[13]!==d?(W=function(v){v.currentTarget===v.target&&d(!1)},e[13]=d,e[14]=W):W=e[14];const ne=W;let X;e[15]!==I||e[16]!==d?(X=function(v){v.preventDefault(),d(!1),I(v.dataTransfer.files)},e[15]=I,e[16]=d,e[17]=X):X=e[17];const ie=X;let z;e[18]!==a||e[19]!==o?(z=t.jsx(Pe,{htmlFor:o,className:"text-muted-foreground",children:a}),e[18]=a,e[19]=o,e[20]=z):z=e[20];let F;e[21]!==n.description?(F=n.description&&t.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:n.description}),e[21]=n.description,e[22]=F):F=e[22];let T;e[23]!==z||e[24]!==F?(T=t.jsxs("div",{className:"min-w-0 space-y-0.5",children:[z,F]}),e[23]=z,e[24]=F,e[25]=T):T=e[25];const le=p&&"border-primary ring-2 ring-primary/30",re=b.isPending&&"pointer-events-none opacity-60";let E;e[26]!==le||e[27]!==re?(E=de("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",le,re),e[26]=le,e[27]=re,e[28]=E):E=e[28];let L;e[29]!==y||e[30]!==u||e[31]!==g||e[32]!==x||e[33]!==a||e[34]!==j||e[35]!==f||e[36]!==c||e[37]!==r||e[38]!==b.isPending?(L=r?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative h-40 w-full bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&t.jsx("img",{src:r,alt:a,className:de("h-full w-full object-contain transition-opacity",!x&&"opacity-0"),onLoad:()=>f(!0),onError:()=>j(!0)},r),g&&t.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[t.jsx(H,{size:20}),t.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!x&&!g&&t.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"})]}),t.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:u}),y&&t.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:y})]})]}):t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[t.jsx(H,{size:20}),t.jsx("span",{className:"text-sm font-medium",children:b.isPending?"Uploading…":"Drop an image or click to browse"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[29]=y,e[30]=u,e[31]=g,e[32]=x,e[33]=a,e[34]=j,e[35]=f,e[36]=c,e[37]=r,e[38]=b.isPending,e[39]=L):L=e[39];let O;e[40]!==p?(O=p&&t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:t.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[40]=p,e[41]=O):O=e[41];let A;e[42]!==ne||e[43]!==se||e[44]!==ie||e[45]!==E||e[46]!==L||e[47]!==O?(A=t.jsxs("div",{onDragOver:se,onDragLeave:ne,onDrop:ie,className:E,children:[L,O]}),e[42]=ne,e[43]=se,e[44]=ie,e[45]=E,e[46]=L,e[47]=O,e[48]=A):A=e[48];let R;e[49]!==h?(R=U=>h(U.target.value),e[49]=h,e[50]=R):R=e[50];let B;e[51]!==o||e[52]!==r||e[53]!==R?(B=t.jsx(Ie,{id:o,type:"url",value:r,onChange:R,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[51]=o,e[52]=r,e[53]=R,e[54]=B):B=e[54];let G;e[55]!==c?(G=()=>c(!0),e[55]=c,e[56]=G):G=e[56];let Z;e[57]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(fe,{size:14}),e[57]=Z):Z=e[57];const oe=r?"Replace":"Browse";let M;e[58]!==G||e[59]!==oe?(M=t.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:G,className:"h-9 shrink-0",children:[Z,oe]}),e[58]=G,e[59]=oe,e[60]=M):M=e[60];let V;e[61]!==h||e[62]!==r?(V=r&&t.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(""),className:"h-9 shrink-0","aria-label":"Remove image",children:t.jsx(_e,{size:14})}),e[61]=h,e[62]=r,e[63]=V):V=e[63];let K;e[64]!==B||e[65]!==M||e[66]!==V?(K=t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[B,M,V]}),e[64]=B,e[65]=M,e[66]=V,e[67]=K):K=e[67];let q;e[68]!==h?(q=U=>h(U),e[68]=h,e[69]=q):q=e[69];let J;e[70]!==m||e[71]!==c||e[72]!==q?(J=t.jsx(st,{open:m,onOpenChange:c,mode:"image",onSelect:q}),e[70]=m,e[71]=c,e[72]=q,e[73]=J):J=e[73];let ee;return e[74]!==A||e[75]!==K||e[76]!==J||e[77]!==T?(ee=t.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[T,A,K,J]}),e[74]=A,e[75]=K,e[76]=J,e[77]=T,e[78]=ee):ee=e[78],ee}function Nt(s){return vt.has(s.type||"")}export{st as F,Gt as I,ue as L,Xe as e,je as u};
1
+ import{e as w,q as be,a as Ne,K as ke,j as t,E as we,r as $,c as de,B as Y,l as Ce,P as Se,o as Q}from"./index-BPnG82q8.js";import{a as H}from"./Tool01-DXZCxrW7.js";import{s as _e}from"./Trash01-CdVc63JX.js";import{i as fe}from"./Upload01-hFtvGOKc.js";import{I as Ie}from"./input-Dp561wvu.js";import{L as Pe}from"./label-BSaEPU5n.js";import{i as Ue}from"./AlertCircle-B4gYnOPQ.js";import{i as ge}from"./Check-Cy2gwr8C.js";import{a as $e}from"./Eye-BEaX-nOW.js";import{i as De}from"./DotsVertical-FCIPj2jh.js";import{H as ze}from"./agent-icon-DRs2sxx6.js";import{n as Fe}from"./LinkExternal01-kEaZ-3VP.js";import{D as Te,c as Ee,e as Le,b as Oe,a as Ae}from"./dialog-BgALXZ6h.js";import{c as ce,a as Re,D as Be,b as Ge}from"./dropdown-menu-uYsl4z-0.js";import{S as Me}from"./skeleton-BrZY2U4q.js";import{T as Ve,a as Ke,b as qe,c as Je}from"./tabs-9ZkZ5CXu.js";import{u as Qe,c as Ye}from"./use-file-configs-fZ_0pNgv.js";import{u as He}from"./useInfiniteQuery-DHhL-q8j.js";import{u as We}from"./studio-tools-YbndxaJx.js";function Xe(s){if(typeof s=="string")return s;if(!s||typeof s!="object")return"";const e=s;if(Array.isArray(e.variants)){const n=e.variants,l=n.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof l?.value=="string")return l.value;const i=n.find(o=>typeof o.value=="string");if(i)return i.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function Ze(s){const e=w.c(10),{org:n}=be(),l=We();let i;e[0]!==n.id||e[1]!==s.configId?(i=ke.filePickerObjects(n.id,s.configId),e[0]=n.id,e[1]=s.configId,e[2]=i):i=e[2];const o=s.enabled!==!1&&!!s.configId;let a;e[3]!==s.configId||e[4]!==l?(a=async m=>{const{pageParam:c}=m;return await l.call("FILE_OBJECTS_LIST",{configId:s.configId,cursor:c??void 0})},e[3]=s.configId,e[4]=l,e[5]=a):a=e[5];let r;return e[6]!==i||e[7]!==o||e[8]!==a?(r={queryKey:i,enabled:o,staleTime:3e4,initialPageParam:null,queryFn:a,getNextPageParam:et},e[6]=i,e[7]=o,e[8]=a,e[9]=r):r=e[9],He(r)}function et(s){return s.nextCursor??void 0}function je(){const s=w.c(2),{org:e}=be();let n;return s[0]!==e?(n={mutationFn:async l=>{const i=l.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(l.configId)}/upload?filename=${encodeURIComponent(l.file.name)}`,{method:"POST",headers:{"Content-Type":i},body:l.file});if(!o.ok){const a=await o.text().catch(tt);let r=`${o.status} ${o.statusText}`;try{const m=JSON.parse(a);m.message&&(r=m.message)}catch{a&&(r=a.slice(0,200))}throw new Error(`Upload failed: ${r}`)}return await o.json()}},s[0]=e,s[1]=n):n=s[1],Ne(n)}function tt(){return""}const ue="file-picker:last-config-id";function st(s){const e=w.c(18),n=s.mode==="image"?"Pick an image":"Pick a file";let l;e[0]!==n?(l=t.jsx(Ee,{children:n}),e[0]=n,e[1]=l):l=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Le,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=i):i=e[2];let o;e[3]!==l?(o=t.jsxs(Oe,{children:[l,i]}),e[3]=l,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Me,{className:"h-64 w-full"}),e[5]=a):a=e[5];let r;e[6]!==s?(r=d=>{s.onSelect(d),s.onOpenChange(!1)},e[6]=s,e[7]=r):r=e[7];let m;e[8]!==s.mode||e[9]!==r?(m=t.jsx(we,{fallback:nt,children:t.jsx($.Suspense,{fallback:a,children:t.jsx(lt,{mode:s.mode,onSelect:r})})}),e[8]=s.mode,e[9]=r,e[10]=m):m=e[10];let c;e[11]!==o||e[12]!==m?(c=t.jsxs(Ae,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,m]}),e[11]=o,e[12]=m,e[13]=c):c=e[13];let p;return e[14]!==s.onOpenChange||e[15]!==s.open||e[16]!==c?(p=t.jsx(Te,{open:s.open,onOpenChange:s.onOpenChange,children:c}),e[14]=s.onOpenChange,e[15]=s.open,e[16]=c,e[17]=p):p=e[17],p}function nt(s){const{error:e}=s;return t.jsx(it,{error:e??new Error("Failed to load buckets")})}function it(s){const e=w.c(3),{error:n}=s;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Ue,{size:16}),e[0]=l):l=e[0];let i;return e[1]!==n.message?(i=t.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[l,t.jsx("span",{className:"text-sm font-medium",children:n.message})]}),e[1]=n.message,e[2]=i):i=e[2],i}function lt(s){const e=w.c(23),{mode:n,onSelect:l}=s,i=Qe();if(i.length===0){let f;return e[0]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(at,{}),e[0]=f):f=e[0],f}if(i.length===1){const f=i[0];let g;return e[1]!==f||e[2]!==n||e[3]!==l?(g=t.jsx(pe,{config:f,mode:n,onSelect:l}),e[1]=f,e[2]=n,e[3]=l,e[4]=g):g=e[4],g}let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=typeof window<"u"?window.localStorage.getItem(ue):null,e[5]=o):o=e[5];const a=o;let r;e[6]!==i?(r=i.find(f=>f.id===a)?.id??i[0].id,e[6]=i,e[7]=r):r=e[7];const m=r;let c;e[8]!==i?(c=i.map(rt),e[8]=i,e[9]=c):c=e[9];let p;e[10]!==c?(p=t.jsx(Ke,{className:"self-start",children:c}),e[10]=c,e[11]=p):p=e[11];let d;if(e[12]!==i||e[13]!==n||e[14]!==l){let f;e[16]!==n||e[17]!==l?(f=g=>t.jsx(qe,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(pe,{config:g,mode:n,onSelect:l})},g.id),e[16]=n,e[17]=l,e[18]=f):f=e[18],d=i.map(f),e[12]=i,e[13]=n,e[14]=l,e[15]=d}else d=e[15];let x;return e[19]!==m||e[20]!==p||e[21]!==d?(x=t.jsxs(Je,{defaultValue:m,onValueChange:ot,className:"min-h-0 flex-1 flex flex-col",children:[p,d]}),e[19]=m,e[20]=p,e[21]=d,e[22]=x):x=e[22],x}function rt(s){return t.jsx(Ve,{value:s.id,children:s.name},s.id)}function ot(s){typeof window<"u"&&window.localStorage.setItem(ue,s)}function at(){const s=w.c(3);let e,n;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:t.jsx(fe,{size:20,className:"text-muted-foreground"})}),n=t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),s[0]=e,s[1]=n):(e=s[0],n=s[1]);let l;return s[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[e,n,t.jsx(Y,{asChild:!0,size:"sm",className:"mt-2",children:t.jsx(Se,{to:"/settings/files",children:"Configure a bucket"})})]}),s[2]=l):l=s[2],l}function pe({config:s,mode:e,onSelect:n}){const l=Ze({configId:s.id}),i=je(),[o,a]=$.useState(!1),r=$.useRef(null),m=e==="image"?"image/*":void 0;async function c(u){if(!u)return;const y=Array.from(u);if(y.length===0)return;let k=null;const b=[];for(const N of y)try{const h=await i.mutateAsync({configId:s.id,file:N});k??=h.publicUrl}catch(h){b.push(`${N.name} (${h instanceof Error?h.message:"upload failed"})`)}await l.refetch(),b.length>0&&Q.error(b.length===y.length?`Upload failed: ${b.join("; ")}`:`Some files failed: ${b.join("; ")}`),k&&n(k)}function p(u){u.preventDefault(),a(!0)}function d(){a(!1)}function x(u){u.preventDefault(),a(!1),c(u.dataTransfer.files)}const g=(l.data?.pages??[]).flatMap(u=>u.items),j=g.filter(u=>e==="image"?ye(u.key):!0);return t.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[t.jsxs("button",{type:"button",onClick:()=>r.current?.click(),onDragOver:p,onDragLeave:d,onDrop:x,className:de("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",o&&"border-primary bg-primary/5",i.isPending&&"opacity-60 pointer-events-none"),children:[t.jsx(fe,{size:18,className:"text-muted-foreground"}),t.jsx("p",{className:"text-sm font-medium",children:i.isPending?"Uploading…":"Drop files here or click to upload"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),t.jsx("input",{ref:r,type:"file",accept:m,multiple:!0,className:"hidden",onChange:u=>{const y=u.target.files;u.target.value="",c(y)}})]}),l.isFetching&&!l.isFetchingNextPage?t.jsx("div",{className:"flex justify-end",children:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading…"})}):null,t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[j.length===0?e==="image"&&g.length>0?t.jsx(dt,{}):t.jsx(ct,{}):e==="image"?t.jsx(ut,{items:j,onSelect:n}):t.jsx(mt,{items:j,onSelect:n}),l.hasNextPage&&t.jsx("div",{className:"flex justify-center py-4",children:t.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:l.isFetchingNextPage,onClick:()=>l.fetchNextPage(),children:l.isFetchingNextPage?t.jsxs(t.Fragment,{children:[t.jsx(Ce,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function ct(){const s=w.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[t.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:t.jsx(H,{size:18,className:"text-muted-foreground"})}),t.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),s[0]=e):e=s[0],e}function dt(){const s=w.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[t.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:t.jsx(H,{size:18,className:"text-muted-foreground"})}),t.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),s[0]=e):e=s[0],e}function ye(s){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(s)}function ft(s){const e=s.lastIndexOf(".");return e<0||e===s.length-1?"file":s.slice(e+1).toLowerCase()}function ut(s){const e=w.c(7),{items:n,onSelect:l}=s;let i;if(e[0]!==n||e[1]!==l){let a;e[3]!==l?(a=r=>t.jsx(ve,{item:r,variant:"image",onSelect:l},r.key),e[3]=l,e[4]=a):a=e[4],i=n.map(a),e[0]=n,e[1]=l,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:i}),e[5]=i,e[6]=o):o=e[6],o}function mt(s){const e=w.c(7),{items:n,onSelect:l}=s;let i;if(e[0]!==n||e[1]!==l){let a;e[3]!==l?(a=r=>t.jsx("li",{children:t.jsx(ve,{item:r,variant:"row",onSelect:l})},r.key),e[3]=l,e[4]=a):a=e[4],i=n.map(a),e[0]=n,e[1]=l,e[2]=i}else i=e[2];let o;return e[5]!==i?(o=t.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:i}),e[5]=i,e[6]=o):o=e[6],o}function ve(s){const e=w.c(58),{item:n,variant:l,onSelect:i}=s;let o;e[0]!==n.key?(o=ft(n.key),e[0]=n.key,e[1]=o):o=e[1];const a=o;if(l==="image"){let b;e[2]!==n.publicUrl||e[3]!==i?(b=()=>i(n.publicUrl),e[2]=n.publicUrl,e[3]=i,e[4]=b):b=e[4];let N;e[5]!==n.key||e[6]!==n.publicUrl?(N=t.jsx("img",{src:n.publicUrl,alt:n.key,loading:"lazy",className:"h-full w-full object-cover",onError:gt}),e[5]=n.key,e[6]=n.publicUrl,e[7]=N):N=e[7];let h;e[8]!==n.key||e[9]!==b||e[10]!==N?(h=t.jsx("button",{type:"button",onClick:b,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:n.key,children:N}),e[8]=n.key,e[9]=b,e[10]=N,e[11]=h):h=e[11];let C;e[12]!==a?(C=t.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=C):C=e[13];let _;e[14]!==n||e[15]!==i?(_=t.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx(xe,{item:n,onSelect:i})}),e[14]=n,e[15]=i,e[16]=_):_=e[16];let S;e[17]!==n.key?(S=he(n.key),e[17]=n.key,e[18]=S):S=e[18];let I;e[19]!==S?(I=t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:t.jsx("p",{className:"truncate text-xs text-white",children:S})}),e[19]=S,e[20]=I):I=e[20];let P;return e[21]!==h||e[22]!==C||e[23]!==_||e[24]!==I?(P=t.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[h,C,_,I]}),e[21]=h,e[22]=C,e[23]=_,e[24]=I,e[25]=P):P=e[25],P}let r;e[26]!==n.publicUrl||e[27]!==i?(r=()=>i(n.publicUrl),e[26]=n.publicUrl,e[27]=i,e[28]=r):r=e[28];let m;e[29]!==n.key?(m=t.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:ye(n.key)?t.jsx(H,{size:16,className:"text-muted-foreground"}):t.jsx(ze,{size:16,className:"text-muted-foreground"})}),e[29]=n.key,e[30]=m):m=e[30];let c;e[31]!==n.key?(c=he(n.key),e[31]=n.key,e[32]=c):c=e[32];let p;e[33]!==c?(p=t.jsx("p",{className:"truncate text-sm font-medium",children:c}),e[33]=c,e[34]=p):p=e[34];let d;e[35]!==n.key?(d=t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:n.key}),e[35]=n.key,e[36]=d):d=e[36];let x;e[37]!==p||e[38]!==d?(x=t.jsxs("div",{className:"min-w-0 flex-1",children:[p,d]}),e[37]=p,e[38]=d,e[39]=x):x=e[39];let f;e[40]!==a?(f=t.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=f):f=e[41];let g;e[42]!==n.size?(g=bt(n.size),e[42]=n.size,e[43]=g):g=e[43];let j;e[44]!==g?(j=t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:g}),e[44]=g,e[45]=j):j=e[45];let u;e[46]!==j||e[47]!==r||e[48]!==m||e[49]!==x||e[50]!==f?(u=t.jsxs("button",{type:"button",onClick:r,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[m,x,f,j]}),e[46]=j,e[47]=r,e[48]=m,e[49]=x,e[50]=f,e[51]=u):u=e[51];let y;e[52]!==n||e[53]!==i?(y=t.jsx(xe,{item:n,onSelect:i}),e[52]=n,e[53]=i,e[54]=y):y=e[54];let k;return e[55]!==u||e[56]!==y?(k=t.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[u,y]}),e[55]=u,e[56]=y,e[57]=k):k=e[57],k}function gt(s){s.target.style.display="none"}function xe(s){const e=w.c(22),{item:n,onSelect:l}=s,[i,o]=$.useState(!1);let a;e[0]!==n.publicUrl?(a=async function(b){b.preventDefault(),b.stopPropagation();try{await navigator.clipboard.writeText(n.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{Q.error("Failed to copy URL")}},e[0]=n.publicUrl,e[1]=a):a=e[1];const r=a;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Re,{asChild:!0,children:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:ht,"aria-label":"Asset actions",children:t.jsx(De,{size:14})})}),e[2]=m):m=e[2];let c;e[3]!==n.publicUrl||e[4]!==l?(c=()=>l(n.publicUrl),e[3]=n.publicUrl,e[4]=l,e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(ge,{size:14}),e[6]=p):p=e[6];let d;e[7]!==c?(d=t.jsxs(ce,{onClick:c,children:[p,"Use this"]}),e[7]=c,e[8]=d):d=e[8];let x;e[9]!==i?(x=i?t.jsx(ge,{size:14}):t.jsx($e,{size:14}),e[9]=i,e[10]=x):x=e[10];const f=i?"Copied":"Copy URL";let g;e[11]!==r||e[12]!==x||e[13]!==f?(g=t.jsxs(ce,{onClick:r,children:[x,f]}),e[11]=r,e[12]=x,e[13]=f,e[14]=g):g=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(Fe,{size:14}),e[15]=j):j=e[15];let u;e[16]!==n.publicUrl?(u=t.jsx(ce,{asChild:!0,children:t.jsxs("a",{href:n.publicUrl,target:"_blank",rel:"noreferrer",onClick:pt,children:[j,"Open in new tab"]})}),e[16]=n.publicUrl,e[17]=u):u=e[17];let y;return e[18]!==u||e[19]!==d||e[20]!==g?(y=t.jsxs(Be,{children:[m,t.jsxs(Ge,{align:"end",onClick:xt,children:[d,g,u]})]}),e[18]=u,e[19]=d,e[20]=g,e[21]=y):y=e[21],y}function pt(s){return s.stopPropagation()}function xt(s){return s.stopPropagation()}function ht(s){return s.stopPropagation()}function he(s){const e=s.split("/");return e[e.length-1]??s}function bt(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function jt(s){try{const e=new URL(s).pathname;return decodeURIComponent(e.split("/").pop()??s)}catch{return s.split("/").pop()??s}}function yt(s){const e=s.lastIndexOf(".");return e<0||e===s.length-1?"":s.slice(e+1).toLowerCase()}const vt=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function Gt(s){const e=w.c(79),{schema:n,value:l,onChange:i,path:o,label:a}=s,r=Xe(l),[m,c]=$.useState(!1),[p,d]=$.useState(!1),[x,f]=$.useState(!1),[g,j]=$.useState(!1),u=r?jt(r):"",y=u?yt(u):"",k=Ye(),b=je();let N;e[0]!==i||e[1]!==j||e[2]!==f?(N=function(v){f(!1),j(!1),i(v)},e[0]=i,e[1]=j,e[2]=f,e[3]=N):N=e[3];const h=N;let C;e[4]!==k.data?.configs?(C=function(){const v=k.data?.configs??[];if(v.length===1)return v[0].id;if(v.length===0)return null;const D=typeof window<"u"?window.localStorage.getItem(ue):null;return v.some(te=>te.id===D)?D:null},e[4]=k.data?.configs,e[5]=C):C=e[5];const _=C;let S;e[6]!==_||e[7]!==c||e[8]!==h||e[9]!==b?(S=async function(v){if(!v)return;const D=Array.from(v).filter(Nt);if(D.length===0){Q.error("Only image files are accepted here.");return}const te=_();if(!te){c(!0);return}try{const ae=await b.mutateAsync({configId:te,file:D[0]});h(ae.publicUrl),D.length>1&&Q.info(`Uploaded ${D[0].name}; extra files were ignored (single-select field).`)}catch(ae){const me=ae;Q.error(me instanceof Error?me.message:"Upload failed")}},e[6]=_,e[7]=c,e[8]=h,e[9]=b,e[10]=S):S=e[10];const I=S;let P;e[11]!==d?(P=function(v){v.preventDefault(),v.dataTransfer.types.includes("Files")&&d(!0)},e[11]=d,e[12]=P):P=e[12];const se=P;let W;e[13]!==d?(W=function(v){v.currentTarget===v.target&&d(!1)},e[13]=d,e[14]=W):W=e[14];const ne=W;let X;e[15]!==I||e[16]!==d?(X=function(v){v.preventDefault(),d(!1),I(v.dataTransfer.files)},e[15]=I,e[16]=d,e[17]=X):X=e[17];const ie=X;let z;e[18]!==a||e[19]!==o?(z=t.jsx(Pe,{htmlFor:o,className:"text-muted-foreground",children:a}),e[18]=a,e[19]=o,e[20]=z):z=e[20];let F;e[21]!==n.description?(F=n.description&&t.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:n.description}),e[21]=n.description,e[22]=F):F=e[22];let T;e[23]!==z||e[24]!==F?(T=t.jsxs("div",{className:"min-w-0 space-y-0.5",children:[z,F]}),e[23]=z,e[24]=F,e[25]=T):T=e[25];const le=p&&"border-primary ring-2 ring-primary/30",re=b.isPending&&"pointer-events-none opacity-60";let E;e[26]!==le||e[27]!==re?(E=de("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",le,re),e[26]=le,e[27]=re,e[28]=E):E=e[28];let L;e[29]!==y||e[30]!==u||e[31]!==g||e[32]!==x||e[33]!==a||e[34]!==j||e[35]!==f||e[36]!==c||e[37]!==r||e[38]!==b.isPending?(L=r?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative h-40 w-full bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&t.jsx("img",{src:r,alt:a,className:de("h-full w-full object-contain transition-opacity",!x&&"opacity-0"),onLoad:()=>f(!0),onError:()=>j(!0)},r),g&&t.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[t.jsx(H,{size:20}),t.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!x&&!g&&t.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"})]}),t.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:u}),y&&t.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:y})]})]}):t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[t.jsx(H,{size:20}),t.jsx("span",{className:"text-sm font-medium",children:b.isPending?"Uploading…":"Drop an image or click to browse"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[29]=y,e[30]=u,e[31]=g,e[32]=x,e[33]=a,e[34]=j,e[35]=f,e[36]=c,e[37]=r,e[38]=b.isPending,e[39]=L):L=e[39];let O;e[40]!==p?(O=p&&t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:t.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[40]=p,e[41]=O):O=e[41];let A;e[42]!==ne||e[43]!==se||e[44]!==ie||e[45]!==E||e[46]!==L||e[47]!==O?(A=t.jsxs("div",{onDragOver:se,onDragLeave:ne,onDrop:ie,className:E,children:[L,O]}),e[42]=ne,e[43]=se,e[44]=ie,e[45]=E,e[46]=L,e[47]=O,e[48]=A):A=e[48];let R;e[49]!==h?(R=U=>h(U.target.value),e[49]=h,e[50]=R):R=e[50];let B;e[51]!==o||e[52]!==r||e[53]!==R?(B=t.jsx(Ie,{id:o,type:"url",value:r,onChange:R,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[51]=o,e[52]=r,e[53]=R,e[54]=B):B=e[54];let G;e[55]!==c?(G=()=>c(!0),e[55]=c,e[56]=G):G=e[56];let Z;e[57]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(fe,{size:14}),e[57]=Z):Z=e[57];const oe=r?"Replace":"Browse";let M;e[58]!==G||e[59]!==oe?(M=t.jsxs(Y,{type:"button",variant:"outline",size:"sm",onClick:G,className:"h-9 shrink-0",children:[Z,oe]}),e[58]=G,e[59]=oe,e[60]=M):M=e[60];let V;e[61]!==h||e[62]!==r?(V=r&&t.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(""),className:"h-9 shrink-0","aria-label":"Remove image",children:t.jsx(_e,{size:14})}),e[61]=h,e[62]=r,e[63]=V):V=e[63];let K;e[64]!==B||e[65]!==M||e[66]!==V?(K=t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[B,M,V]}),e[64]=B,e[65]=M,e[66]=V,e[67]=K):K=e[67];let q;e[68]!==h?(q=U=>h(U),e[68]=h,e[69]=q):q=e[69];let J;e[70]!==m||e[71]!==c||e[72]!==q?(J=t.jsx(st,{open:m,onOpenChange:c,mode:"image",onSelect:q}),e[70]=m,e[71]=c,e[72]=q,e[73]=J):J=e[73];let ee;return e[74]!==A||e[75]!==K||e[76]!==J||e[77]!==T?(ee=t.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[T,A,K,J]}),e[74]=A,e[75]=K,e[76]=J,e[77]=T,e[78]=ee):ee=e[78],ee}function Nt(s){return vt.has(s.type||"")}export{st as F,Gt as I,ue as L,Xe as e,je as u};
@@ -0,0 +1,8 @@
1
+ import{e as le,r as K,f as bt,q as Be,j as t,B as Z,o as Ce,c as ce,K as it,n as yt,v as ss,d as rs,t as xt,E as ls}from"./index-BPnG82q8.js";import{S as os}from"./search-input-DACBbzIk.js";import{P as Me}from"./index-BpKJI7Dd.js";import{E as wt}from"./empty-state-CzSsahKD.js";import{R as as}from"./require-capability-C4c85-CT.js";import{o as kt}from"./pair-B6H2XHda.js";import{B as rt}from"./badge-CIMelj9a.js";import{P as ct,a as dt,b as mt}from"./popover-BYJBybY_.js";import{b as Ze,T as et,a as tt}from"./tooltip-BwiZr2GD.js";import{i as ft}from"./Check-Cy2gwr8C.js";import{a as Xe}from"./Eye-BEaX-nOW.js";import{n as Tt}from"./Globe01-DCcLGAPs.js";import{i as Pt}from"./FilterLines-PIiHcomo.js";import{i as ns}from"./Key01-DOICf9Yf.js";import{i as is}from"./Play-CgnBFM99.js";import{a9 as cs,aa as ds,R as ms,G as us}from"./agent-icon-DRs2sxx6.js";import{M as Mt}from"./monaco-editor-BR_tbU8a.js";import{u as xs}from"./use-members-lO5UPidt.js";import{u as _t}from"./use-connection-DyyYYs8L.js";import{a as fs,u as ps,W as hs}from"./use-mcp-client-iXdxenz3.js";import{a as gs}from"./use-virtual-mcp-Cw_yVFMO.js";import{n as Qe}from"./Container-CYA7KoET.js";import{c as js}from"./SwitchHorizontal01-DruCuOB9.js";import{s as vs}from"./Plus-CZoFo8m3.js";import{s as Ns}from"./Trash01-CdVc63JX.js";import{I as Ge}from"./input-Dp561wvu.js";import{g as bs,b as Dt,f as st,a as At,c as pt,d as ys,e as Lt,h as Vt,A as ws,T as Ss,i as Is,M as ht}from"./automation-runs-CAmeSsSa.js";import{S as lt,a as ot,b as at,c as Re,d as nt}from"./select-gqSNOxQD.js";import{S as Cs}from"./scroll-area-DuFY4R5d.js";import{t as Ut}from"./ChevronDown-3x5m66Bs.js";import{C as ks}from"./calendar-YPBFp_E0.js";import{T as Ts}from"./textarea-CimG5sWW.js";import{C as Kt}from"./collection-tabs-DyRPz2M0.js";import{S as Ms}from"./switch-CWe9x1dO.js";import{L as _s}from"./label-BSaEPU5n.js";import{I as qe}from"./integration-icon-CcFsasgm.js";import{A as qt}from"./avatar-CWn5LER_.js";import{A as Ds,a as Ls,b as Rs}from"./alert-DvSgp-Ux.js";import{C as Bt}from"./card-CPe96wry.js";import{K as ke}from"./monitoring-stats-row-5K-iNny9.js";import{u as Ht}from"./studio-tools-YbndxaJx.js";import{g as Fs}from"./connection-slug-eyAPH6o3.js";import{u as $s}from"./useSuspenseInfiniteQuery-oHftqcSU.js";import{d as zs,S as Os,a as Es,b as Ps}from"./sheet-J-5zCitH.js";import{T as De,a as ut,b as Jt,c as Gt,d as Qt,e as oe}from"./table-MDhW4B8D.js";import{n as As}from"./ChevronUp-Bh0YaH7H.js";import{u as Vs}from"./use-infinite-scroll-D2-BvjXC.js";import{c as Us,b as Ks}from"./use-automations-Cgz4YKs5.js";import"./SearchMd-Cd3g9OHi.js";import"./sidebar-DpznaqAr.js";import"./LayoutLeft-XvA4efJR.js";import"./use-capability-CtdbYGMh.js";import"./access-gate-DADwk2R8.js";import"./capability-load-error-mbutkBah.js";import"./Stars01-D3E_UsFP.js";import"./XCircle-m30sBtwe.js";import"./ChevronRight-CeIr4WsE.js";import"./use-clock-tick-CPPdyWgW.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./use-copy-BEZFUgho.js";import"./file-type-icon-BI-57QdR.js";import"./dialog-BgALXZ6h.js";import"./X-CiRjfhfc.js";import"./ZoomOut-OQ9XVMLx.js";import"./content-blocks-o63cs2vh.js";import"./types-BYtVTpDQ.js";import"./chat-context-BjxJIMHx.js";import"./tab-id-Bc_4nZgl.js";import"./watch-sse-pool-BZQA3Ki3.js";import"./decopilot-sse-pool-Qs-1EY0r.js";import"./use-ai-providers-B4z2G4rP.js";import"./use-organization-settings-MrnwSgAR.js";import"./AlertCircle-B4gYnOPQ.js";import"./Star01-BQu9_hS7.js";import"./XClose-DEtxBka1.js";import"./ZapSquare-88gaWy0c.js";import"./Tool01-DXZCxrW7.js";import"./Monitor01-BQ2ab3I8.js";import"./Upload01-hFtvGOKc.js";import"./shell-layout-B1bpQmja.js";import"./Users03-cwi85RQL.js";import"./Stars02-DQPSVMUP.js";import"./CheckCircle-CNdjtGTh.js";import"./Zap-BqoFLQhx.js";import"./required-auth-layout-BApuEUpI.js";import"./useRouterState-IhZ1SxRm.js";import"./use-org-sso-Sk1A6q8-.js";import"./LinkExternal01-kEaZ-3VP.js";import"./Palette-BvgmCjcf.js";import"./use-navigate-to-agent-DIjWe8In.js";import"./use-mcp-prompts-BZ3M88pO.js";import"./form-BSWyFOE3.js";import"./spinner-DWj9d3Oy.js";import"./RefreshCcw01-CoOu-1-t.js";import"./ArrowUpRight-D0kjnBU3.js";import"./ChevronLeft-2_IuBsKu.js";import"./DotsVertical-FCIPj2jh.js";import"./HardDrive-DF3wR4Ey.js";import"./Sun-CGlOqn-C.js";import"./Settings02-h4KhooA8.js";import"./Shield01-CxluyAom.js";import"./User01-DkghkjfJ.js";import"./Users01-DSIM6pEW.js";import"./index-BHORPjEK.js";import"./use-org-auth-client-CjM9gfPH.js";import"./use-collections-D52tQdGt.js";import"./useInfiniteQuery-DHhL-q8j.js";import"./task-status-BNkxxOv6.js";import"./checkbox-CMfBi1P9.js";import"./command-DwAn8s0z.js";import"./index-9-_G5hYz.js";import"./index-CYt0V3AS.js";const vt={maxJsonRenderSize:5e4,pageSize:50,streamingRefetchInterval:3e3};function Le(s){return s.filter(e=>e.key.trim()).map(e=>{const r=encodeURIComponent(e.key.trim()),l=encodeURIComponent(e.value||"");return`${r}:${e.operator}:${l}`}).join(",")}function qs(s){return s?s.split(",").map(e=>{const[r,l,...a]=e.split(":");return{key:decodeURIComponent(r||""),operator:l||"eq",value:decodeURIComponent(a.join(":")||"")}}):[]}function Ye(s){return s.filter(e=>e.key.trim()).map(e=>{switch(e.operator){case"eq":return`${e.key}=${e.value}`;case"contains":return`${e.key}~${e.value}`;case"exists":return`${e.key}?`;case"in":return`${e.key}@${e.value}`}}).join(`
2
+ `)}function Rt(s){return s.trim()?s.split(`
3
+ `).map(e=>e.trim()).filter(e=>e.length>0).map(e=>{if(e.endsWith("?"))return{key:e.slice(0,-1),operator:"exists",value:""};if(e.includes("=")){const[r,...l]=e.split("=");return{key:r||"",operator:"eq",value:l.join("=")}}if(e.includes("~")){const[r,...l]=e.split("~");return{key:r||"",operator:"contains",value:l.join("~")}}if(e.includes("@")){const[r,...l]=e.split("@");return{key:r||"",operator:"in",value:l.join("@")}}return{key:e,operator:"exists",value:""}}):[]}function Bs(s){const e={},r={},l=[],a={};for(const o of s)if(o.key.trim())switch(o.operator){case"eq":o.value&&(e[o.key]=o.value);break;case"contains":o.value&&(r[o.key]=`%${o.value}%`);break;case"exists":l.push(o.key);break;case"in":o.value&&(a[o.key]=o.value);break}return{properties:Object.keys(e).length>0?e:void 0,propertyPatterns:Object.keys(r).length>0?r:void 0,propertyKeys:l.length>0?l:void 0,propertyInValues:Object.keys(a).length>0?a:void 0}}function Ft(s){if(!s)return{content:"null",isTruncated:!1,originalSize:4};if(typeof s._decocms_truncated=="string")return{content:s._decocms_truncated,isTruncated:!0,originalSize:s._decocms_truncated.length};const e=JSON.stringify(s,null,2),r=e.length;return r<=vt.maxJsonRenderSize?{content:e,isTruncated:!1,originalSize:r}:{content:e.slice(0,vt.maxJsonRenderSize)+`
4
+
5
+ ... [TRUNCATED - content too large to display]`,isTruncated:!0,originalSize:r}}function Hs(s){const e=le.c(116),{log:r}=s,[l,a]=K.useState(!1),[o,d]=K.useState(!1),i=bt(),{org:n}=Be(),c=Ft(r.input),u=Ft(r.output),j=Js;let v;e[0]!==r.input||e[1]!==r.output?(v=async se=>{const re=j(se==="input"?r.input:r.output);try{await navigator.clipboard.writeText(re),se==="input"?(a(!0),setTimeout(()=>a(!1),2e3)):(d(!0),setTimeout(()=>d(!1),2e3))}catch{Ce.error("Failed to copy to clipboard")}},e[0]=r.input,e[1]=r.output,e[2]=v):v=e[2];const b=v;let x;e[3]!==r.id||e[4]!==r.input||e[5]!==r.output||e[6]!==r.toolName?(x=se=>{const re=j(se==="input"?r.input:r.output),ie=new Blob([re],{type:"application/json"}),pe=URL.createObjectURL(ie),ye=document.createElement("a");ye.href=pe,ye.download=`${r.toolName}-${se}-${r.id}.json`,ye.click(),URL.revokeObjectURL(pe)},e[3]=r.id,e[4]=r.input,e[5]=r.output,e[6]=r.toolName,e[7]=x):x=e[7];const L=x;let p;e[8]!==r.connectionId||e[9]!==r.input||e[10]!==r.toolName||e[11]!==i||e[12]!==n.slug?(p=()=>{const se=crypto.randomUUID();sessionStorage.setItem(`replay-${se}`,JSON.stringify(r.input)),i({to:"/$org/settings/connections/$connectionId/$collectionName/$itemId",params:{org:n.slug,connectionId:r.connectionId,collectionName:"tools",itemId:encodeURIComponent(r.toolName)},search:{replayId:se}})},e[8]=r.connectionId,e[9]=r.input,e[10]=r.toolName,e[11]=i,e[12]=n.slug,e[13]=p):p=e[13];const g=p,[m,k]=K.useState(!1);let S;e[14]!==r.requestId?(S=async()=>{try{await navigator.clipboard.writeText(r.requestId),k(!0),setTimeout(()=>k(!1),2e3)}catch{Ce.error("Failed to copy to clipboard")}},e[14]=r.requestId,e[15]=S):S=e[15];const h=S;let T;e[16]!==r.timestamp?(T=new Date(r.timestamp).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e[16]=r.timestamp,e[17]=T):T=e[17];const I=T,f="text-sm px-5 md:px-6 py-5 space-y-5";let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Timestamp"}),e[18]=M):M=e[18];let y;e[19]!==I?(y=t.jsxs("div",{children:[M,t.jsx("div",{className:"text-sm text-foreground",children:I})]}),e[19]=I,e[20]=y):y=e[20];let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Duration"}),e[21]=$):$=e[21];let C;e[22]!==r.durationMs?(C=t.jsxs("div",{children:[$,t.jsxs("div",{className:"text-sm font-mono text-foreground",children:[r.durationMs,"ms"]})]}),e[22]=r.durationMs,e[23]=C):C=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"User"}),e[24]=E):E=e[24];let R;e[25]!==r.userName?(R=t.jsxs("div",{children:[E,t.jsx("div",{className:"text-sm text-foreground",children:r.userName})]}),e[25]=r.userName,e[26]=R):R=e[26];let H;e[27]!==r.virtualMcpName?(H=r.virtualMcpName&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Agent"}),t.jsx("div",{className:"text-sm text-foreground",children:r.virtualMcpName})]}),e[27]=r.virtualMcpName,e[28]=H):H=e[28];let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Request ID"}),e[29]=A):A=e[29];let W;e[30]!==r.requestId?(W=t.jsx("code",{className:"font-mono text-foreground text-[11px]",children:r.requestId}),e[30]=r.requestId,e[31]=W):W=e[31];let w;e[32]!==m?(w=m?t.jsx(ft,{size:12}):t.jsx(Xe,{size:12}),e[32]=m,e[33]=w):w=e[33];let _;e[34]!==h||e[35]!==w?(_=t.jsx(Z,{size:"icon",variant:"ghost",onClick:h,"aria-label":"Copy request ID",className:"h-5 w-5 text-muted-foreground hover:text-foreground",children:w}),e[34]=h,e[35]=w,e[36]=_):_=e[36];let F;e[37]!==W||e[38]!==_?(F=t.jsxs("div",{children:[A,t.jsxs("div",{className:"flex items-center gap-1",children:[W,_]})]}),e[37]=W,e[38]=_,e[39]=F):F=e[39];let z;e[40]!==r.userAgent?(z=r.userAgent&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Client"}),t.jsx("div",{className:"text-sm font-mono text-foreground",children:r.userAgent})]}),e[40]=r.userAgent,e[41]=z):z=e[41];let O;e[42]!==r.properties||e[43]!==i||e[44]!==n.slug?(O=r.properties&&Object.keys(r.properties).length>0&&t.jsxs("div",{className:"md:col-span-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1.5",children:"Properties"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:Object.entries(r.properties).map(se=>{const[re,ie]=se;return t.jsxs(ct,{children:[t.jsx(dt,{asChild:!0,children:t.jsxs(rt,{variant:"secondary",className:"font-mono text-xs px-2 py-0.5 cursor-pointer hover:bg-secondary/80 transition-colors",children:[re,"=",ie]})}),t.jsx(mt,{className:"w-auto p-1",align:"end",children:t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs(Z,{variant:"ghost",size:"sm",className:"justify-start h-8 px-2 text-xs font-normal focus-visible:ring-0 focus-visible:ring-offset-0",onClick:()=>{const pe={key:re,operator:"eq",value:ie};i({to:"/$org/settings/monitor",params:{org:n.slug},search:{propertyFilters:Le([pe])}})},children:[t.jsx(Pt,{size:14,className:"mr-2"}),"Filter by this property"]}),t.jsxs(Z,{variant:"ghost",size:"sm",className:"justify-start h-8 px-2 text-xs font-normal focus-visible:ring-0 focus-visible:ring-offset-0",onClick:async()=>{try{await navigator.clipboard.writeText(`${re}=${ie}`),Ce.success("Copied filter to clipboard")}catch{Ce.error("Failed to copy to clipboard")}},children:[t.jsx(Xe,{size:14,className:"mr-2"}),"Copy filter"]}),t.jsxs(Z,{variant:"ghost",size:"sm",className:"justify-start h-8 px-2 text-xs font-normal focus-visible:ring-0 focus-visible:ring-offset-0",onClick:async()=>{try{await navigator.clipboard.writeText(re),Ce.success("Copied key to clipboard")}catch{Ce.error("Failed to copy to clipboard")}},children:[t.jsx(ns,{size:14,className:"mr-2"}),"Copy key"]}),t.jsxs(Z,{variant:"ghost",size:"sm",className:"justify-start h-8 px-2 text-xs font-normal focus-visible:ring-0 focus-visible:ring-offset-0",onClick:async()=>{try{await navigator.clipboard.writeText(ie),Ce.success("Copied value to clipboard")}catch{Ce.error("Failed to copy to clipboard")}},children:[t.jsx(cs,{size:14,className:"mr-2"}),"Copy value"]})]})})]},re)})})]}),e[42]=r.properties,e[43]=i,e[44]=n.slug,e[45]=O):O=e[45];let V;e[46]!==C||e[47]!==R||e[48]!==H||e[49]!==F||e[50]!==z||e[51]!==O||e[52]!==y?(V=t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4",children:[y,C,R,H,F,z,O]}),e[46]=C,e[47]=R,e[48]=H,e[49]=F,e[50]=z,e[51]=O,e[52]=y,e[53]=V):V=e[53];let q;e[54]!==r.errorMessage?(q=r.errorMessage&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs text-destructive mb-1",children:"Error"}),t.jsx("div",{className:"text-destructive font-mono text-xs bg-destructive/10 p-2 rounded break-all",children:r.errorMessage})]}),e[54]=r.errorMessage,e[55]=q):q=e[55];const J="space-y-4";let G;e[56]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsx("span",{className:"text-xs text-muted-foreground select-none",children:"Input"}),e[56]=G):G=e[56];const Q=c.isTruncated&&t.jsxs("span",{className:"text-xs text-amber-600 dark:text-amber-400",children:["(",kt(c.originalSize)," - truncated)"]});let U;e[57]!==Q?(U=t.jsxs("div",{className:"flex items-center gap-2",children:[G,Q]}),e[57]=Q,e[58]=U):U=e[58];let P;e[59]!==g||e[60]!==r.input?(P=r.input&&t.jsxs(Ze,{children:[t.jsx(et,{asChild:!0,children:t.jsx(Z,{size:"icon",variant:"ghost",onClick:g,"aria-label":"Replay tool call",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:t.jsx(is,{size:14})})}),t.jsx(tt,{children:"Replay tool call"})]}),e[59]=g,e[60]=r.input,e[61]=P):P=e[61];let N;e[62]!==L||e[63]!==c?(N=c.isTruncated&&t.jsxs(Ze,{children:[t.jsx(et,{asChild:!0,children:t.jsx(Z,{size:"icon",variant:"ghost",onClick:()=>L("input"),"aria-label":"Download full input",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:t.jsx(Tt,{size:14})})}),t.jsx(tt,{children:"Download full input"})]}),e[62]=L,e[63]=c,e[64]=N):N=e[64];let D;e[65]!==b?(D=()=>b("input"),e[65]=b,e[66]=D):D=e[66];let B;e[67]!==l?(B=l?t.jsx(ft,{size:14}):t.jsx(Xe,{size:14}),e[67]=l,e[68]=B):B=e[68];let ee;e[69]!==D||e[70]!==B?(ee=t.jsx(Z,{size:"icon",variant:"ghost",onClick:D,"aria-label":"Copy input",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:B}),e[69]=D,e[70]=B,e[71]=ee):ee=e[71];let X;e[72]!==P||e[73]!==N||e[74]!==ee?(X=t.jsxs("div",{className:"flex items-center gap-1",children:[P,N,ee]}),e[72]=P,e[73]=N,e[74]=ee,e[75]=X):X=e[75];let te;e[76]!==U||e[77]!==X?(te=t.jsxs("div",{className:"flex items-center justify-between p-1 pl-4 border-b border-border",children:[U,X]}),e[76]=U,e[77]=X,e[78]=te):te=e[78];let Y;e[79]!==c?(Y=t.jsx("div",{className:"h-[200px] md:h-[280px] overflow-auto",children:t.jsx(Mt,{code:c.content,language:"json",height:"100%",readOnly:!0})}),e[79]=c,e[80]=Y):Y=e[80];let ae;e[81]!==te||e[82]!==Y?(ae=t.jsx("div",{children:t.jsxs("div",{className:"rounded-lg overflow-hidden border border-border",children:[te,Y]})}),e[81]=te,e[82]=Y,e[83]=ae):ae=e[83];const _e="rounded-lg overflow-hidden border border-border",Fe="flex items-center justify-between p-1 pl-4 border-b border-border",Se="flex items-center gap-2";let ne;e[84]===Symbol.for("react.memo_cache_sentinel")?(ne=t.jsx("span",{className:"text-xs text-muted-foreground select-none",children:"Output"}),e[84]=ne):ne=e[84];const he=u.isTruncated&&t.jsxs("span",{className:"text-xs text-amber-600 dark:text-amber-400",children:["(",kt(u.originalSize)," - truncated)"]});let ge;e[85]!==ne||e[86]!==he?(ge=t.jsxs("div",{className:Se,children:[ne,he]}),e[85]=ne,e[86]=he,e[87]=ge):ge=e[87];let je;e[88]!==L||e[89]!==u.isTruncated?(je=u.isTruncated&&t.jsxs(Ze,{children:[t.jsx(et,{asChild:!0,children:t.jsx(Z,{size:"icon",variant:"ghost",onClick:()=>L("output"),"aria-label":"Download full output",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:t.jsx(Tt,{size:14})})}),t.jsx(tt,{children:"Download full output"})]}),e[88]=L,e[89]=u.isTruncated,e[90]=je):je=e[90];let ve;e[91]!==b?(ve=()=>b("output"),e[91]=b,e[92]=ve):ve=e[92];let Ne;e[93]!==o?(Ne=o?t.jsx(ft,{size:14}):t.jsx(Xe,{size:14}),e[93]=o,e[94]=Ne):Ne=e[94];let de;e[95]!==ve||e[96]!==Ne?(de=t.jsx(Z,{size:"icon",variant:"ghost",onClick:ve,"aria-label":"Copy output",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:Ne}),e[95]=ve,e[96]=Ne,e[97]=de):de=e[97];let be;e[98]!==je||e[99]!==de?(be=t.jsxs("div",{className:"flex items-center gap-1",children:[je,de]}),e[98]=je,e[99]=de,e[100]=be):be=e[100];let me;e[101]!==ge||e[102]!==be?(me=t.jsxs("div",{className:Fe,children:[ge,be]}),e[101]=ge,e[102]=be,e[103]=me):me=e[103];let ue;e[104]!==u.content?(ue=t.jsx("div",{className:"h-[200px] md:h-[280px] overflow-auto",children:t.jsx(Mt,{code:u.content,language:"json",height:"100%",readOnly:!0})}),e[104]=u.content,e[105]=ue):ue=e[105];let xe;e[106]!==me||e[107]!==ue?(xe=t.jsx("div",{children:t.jsxs("div",{className:_e,children:[me,ue]})}),e[106]=me,e[107]=ue,e[108]=xe):xe=e[108];let fe;e[109]!==ae||e[110]!==xe?(fe=t.jsxs("div",{className:J,children:[ae,xe]}),e[109]=ae,e[110]=xe,e[111]=fe):fe=e[111];let $e;return e[112]!==V||e[113]!==q||e[114]!==fe?($e=t.jsxs("div",{className:f,children:[V,q,fe]}),e[112]=V,e[113]=q,e[114]=fe,e[115]=$e):$e=e[115],$e}function Js(s){return JSON.stringify(s,null,2)}const Wt=/^now(?:-(\d+)([mhdwM]))?$/,Gs={m:"minute",h:"hour",d:"day",w:"week",M:"month"};function Xt(s){const e=s.trim();if(e==="now")return{isNow:!0,offset:0,unit:null};const r=e.match(Wt);if(!r)return null;const l=r[1]?Number.parseInt(r[1],10):0,a=r[2]||null;return{isNow:!0,offset:l,unit:a}}function we(s){const e=s.trim(),r=new Date(e);if(!Number.isNaN(r.getTime())&&e.includes("-"))return{valid:!0,date:r};const l=Xt(e);if(!l)return{valid:!1,date:null,error:'Invalid expression. Use "now" or "now-Xu" (e.g., now-2d, now-3h)'};const a=new Date,o=new Date(a);if(l.offset===0||!l.unit)return{valid:!0,date:o};switch(l.unit){case"m":o.setMinutes(o.getMinutes()-l.offset);break;case"h":o.setHours(o.getHours()-l.offset);break;case"d":o.setDate(o.getDate()-l.offset);break;case"w":o.setDate(o.getDate()-l.offset*7);break;case"M":o.setMonth(o.getMonth()-l.offset);break}return{valid:!0,date:o}}function Qs(s){return s.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Yt(s){const e=s.trim();return Wt.test(e)}function $t(s){const e=s.trim();if(e==="now")return"Now";const r=Xt(e);if(!r||!r.unit){const o=we(e);return o.valid&&o.date?Qs(o.date):e}const l=Gs[r.unit],a=r.offset!==1?"s":"";return`${r.offset} ${l}${a} ago`}const Zt=[{label:"Last 5 minutes",from:"now-5m",to:"now",value:"5m"},{label:"Last 15 minutes",from:"now-15m",to:"now",value:"15m"},{label:"Last 30 minutes",from:"now-30m",to:"now",value:"30m"},{label:"Last 1 hour",from:"now-1h",to:"now",value:"1h"},{label:"Last 3 hours",from:"now-3h",to:"now",value:"3h"},{label:"Last 6 hours",from:"now-6h",to:"now",value:"6h"},{label:"Last 12 hours",from:"now-12h",to:"now",value:"12h"},{label:"Last 24 hours",from:"now-24h",to:"now",value:"24h"},{label:"Last 2 days",from:"now-2d",to:"now",value:"2d"},{label:"Last 7 days",from:"now-7d",to:"now",value:"7d"},{label:"Last 30 days",from:"now-30d",to:"now",value:"30d"}];function Ws(s,e){const r=Zt.find(l=>l.from===s&&l.to===e);return r?r.label:`${$t(s)} to ${$t(e)}`}function Je(s){const e=s.getFullYear(),r=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),a=String(s.getHours()).padStart(2,"0"),o=String(s.getMinutes()).padStart(2,"0"),d=String(s.getSeconds()).padStart(2,"0");return`${e}-${r}-${l} ${a}:${o}:${d}`}function Xs(s){const e=s.match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/);if(!e)return null;const[,r,l,a,o,d,i]=e,n=new Date(Number(r),Number(l)-1,Number(a),Number(o),Number(d),Number(i));return Number.isNaN(n.getTime())?null:n}function gt(s){if(Yt(s))return s;const e=we(s);return e.valid&&e.date?Je(e.date):s}function zt({value:s,onChange:e,placeholder:r="now or now-2d",className:l,disabled:a,error:o}){const[d,i]=K.useState(!1),[n,c]=K.useState(()=>gt(s)),[u,j]=K.useState(),[v,b]=K.useState(!1),x=K.useRef(s);x.current!==s&&(x.current=s,v||c(gt(s)));const L=f=>{const M=f.target.value;c(M),j(void 0)},p=()=>{b(!0)},g=()=>{b(!1);const f=n.trim();if(Yt(f)){j(void 0),e(f);return}const M=Xs(f);if(M){j(void 0),e(M.toISOString()),c(Je(M));return}const y=we(f);if(y.valid&&y.date){j(void 0),e(f),c(Je(y.date));return}c(gt(s)),j(void 0)},m=f=>{if(f){const y=we(s).date||new Date;f.setHours(y.getHours()),f.setMinutes(y.getMinutes()),f.setSeconds(0),f.setMilliseconds(0);const $=f.toISOString();c(Je(f)),e($),j(void 0)}i(!1)},k=f=>{const[M,y]=f.target.value.split(":").map(Number),C=we(s).date||new Date;C.setHours(M||0),C.setMinutes(y||0),C.setSeconds(0),C.setMilliseconds(0);const E=C.toISOString();c(Je(C)),e(E)},S=we(s),h=S.valid?S.date:new Date,T=h?`${String(h.getHours()).padStart(2,"0")}:${String(h.getMinutes()).padStart(2,"0")}`:"",I=o||u;return t.jsxs("div",{className:ce("flex gap-1",l),children:[t.jsxs("div",{className:"flex-1 relative",children:[t.jsx(Ge,{value:n,onChange:L,onFocus:p,onBlur:g,placeholder:r,disabled:a,className:ce("text-sm h-8",I&&"border-destructive focus-visible:ring-destructive")}),I&&t.jsx("p",{className:"text-xs text-destructive mt-1",children:I})]}),t.jsxs(ct,{open:d,onOpenChange:i,children:[t.jsx(dt,{asChild:!0,children:t.jsx(Z,{variant:"outline",size:"icon",className:"h-8 w-8 shrink-0",disabled:a,children:t.jsx(ds,{className:"h-4 w-4"})})}),t.jsxs(mt,{className:"w-auto p-0",align:"end",children:[t.jsx(ks,{mode:"single",selected:h||void 0,onSelect:m,initialFocus:!0}),t.jsxs("div",{className:"border-t p-3",children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1.5 block",children:"Time"}),t.jsx(Ge,{type:"time",value:T,onChange:k,className:"text-sm h-8"})]})]})]})]})}function Ys({value:s,onChange:e,className:r,disabled:l,quickRanges:a=Zt}){const[o,d]=K.useState(!1),[i,n]=K.useState(s.from),[c,u]=K.useState(s.to),[j,v]=K.useState(null),b=K.useRef({from:s.from,to:s.to});(b.current.from!==s.from||b.current.to!==s.to)&&(b.current={from:s.from,to:s.to},n(s.from),u(s.to));const x=m=>{b.current={from:m.from,to:m.to},n(m.from),u(m.to),d(!1),e({from:m.from,to:m.to})},L=()=>{const m=we(i),k=we(c);if(!m.valid||!m.date){v("Invalid 'From' date");return}if(!k.valid||!k.date){v("Invalid 'To' date");return}if(m.date>=k.date){v("'From' must be before 'To'");return}v(null),e({from:i,to:c}),d(!1)},p=m=>s.from===m.from&&s.to===m.to,g=Ws(s.from,s.to);return t.jsxs(ct,{open:o,onOpenChange:d,children:[t.jsx(dt,{asChild:!0,children:t.jsxs(Z,{variant:"outline",className:ce("gap-1.5 min-w-[160px] justify-between",r),disabled:l,children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(ms,{className:"size-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm",children:g})]}),t.jsx(Ut,{className:"size-4 text-muted-foreground"})]})}),t.jsx(mt,{className:"w-[540px] p-0",align:"end",sideOffset:4,onCloseAutoFocus:m=>m.preventDefault(),style:o?void 0:{animationDuration:"0s"},children:t.jsxs("div",{className:"flex",children:[t.jsxs("div",{className:"flex-1 p-4 border-r",children:[t.jsx("h4",{className:"text-sm font-medium mb-4",children:"Absolute time range"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1.5 block",children:"From"}),t.jsx(zt,{value:i,onChange:n,placeholder:"now-24h"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1.5 block",children:"To"}),t.jsx(zt,{value:c,onChange:u,placeholder:"now"})]}),j&&t.jsx("p",{className:"text-xs text-destructive",children:j}),t.jsx(Z,{onClick:L,className:"w-full",size:"sm",children:"Apply time range"})]})]}),t.jsx("div",{className:"w-[200px]",children:t.jsx(Cs,{className:"h-[280px]",children:t.jsx("div",{className:"p-2",children:a.map(m=>{const k=p(m);return t.jsx("button",{type:"button",onClick:()=>x(m),className:ce("w-full text-left px-3 py-2 text-sm rounded-md transition-colors","hover:bg-accent hover:text-accent-foreground",k&&"bg-accent text-accent-foreground font-medium"),children:m.label},m.value)})})})})]})})]})}const es="decopilot";async function ts(s,e){return await s.call("MONITORING_STATS",e)}function Zs(s,e){const r=le.c(12),{org:l}=Be(),a=Ht();let o,d,i;r[0]!==l.id||r[1]!==s?(i={...s,excludeConnectionIds:[es,...s.excludeConnectionIds??[]]},d=yt,o=it.monitoringStatsToolCalls(l.id,JSON.stringify(i)),r[0]=l.id,r[1]=s,r[2]=o,r[3]=d,r[4]=i):(o=r[2],d=r[3],i=r[4]);let n;r[5]!==a||r[6]!==i?(n=()=>ts(a,i),r[5]=a,r[6]=i,r[7]=n):n=r[7];let c;return r[8]!==e||r[9]!==o||r[10]!==n?(c={queryKey:o,queryFn:n,staleTime:3e4,retry:!1,...e},r[8]=e,r[9]=o,r[10]=n,r[11]=c):c=r[11],d(c)}function er(s,e){const r=le.c(12),{org:l}=Be(),a=Ht();let o,d,i;r[0]!==l.id||r[1]!==s?(i={...s,connectionIds:[es],topN:5,llmUsage:!0,userIds:s.userIds?.length?s.userIds:void 0},d=yt,o=it.monitoringStatsLlm(l.id,JSON.stringify(i)),r[0]=l.id,r[1]=s,r[2]=o,r[3]=d,r[4]=i):(o=r[2],d=r[3],i=r[4]);let n;r[5]!==a||r[6]!==i?(n=()=>ts(a,i),r[5]=a,r[6]=i,r[7]=n):n=r[7];let c;return r[8]!==e||r[9]!==o||r[10]!==n?(c={queryKey:o,queryFn:n,staleTime:3e4,retry:!1,...e},r[8]=e,r[9]=o,r[10]=n,r[11]=c):c=r[11],d(c)}function Te(s){const e=le.c(20),{title:r,value:l,action:a,children:o,className:d}=s;let i;e[0]!==d?(i=ce("pt-4 px-4 pb-6 gap-8",d),e[0]=d,e[1]=i):i=e[1];let n;e[2]!==r?(n=t.jsx("span",{className:"text-sm text-foreground/70",children:r}),e[2]=r,e[3]=n):n=e[3];let c;e[4]!==l?(c=t.jsx("span",{className:"text-4xl font-normal",children:l}),e[4]=l,e[5]=c):c=e[5];let u;e[6]!==n||e[7]!==c?(u=t.jsxs("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[n,c]}),e[6]=n,e[7]=c,e[8]=u):u=e[8];let j;e[9]!==a?(j=a&&t.jsx("div",{className:"shrink-0",children:a}),e[9]=a,e[10]=j):j=e[10];let v;e[11]!==u||e[12]!==j?(v=t.jsxs("div",{className:"flex items-start justify-between",children:[u,j]}),e[11]=u,e[12]=j,e[13]=v):v=e[13];let b;e[14]!==o?(b=o&&t.jsx("div",{className:"flex flex-col gap-6",children:o}),e[14]=o,e[15]=b):b=e[15];let x;return e[16]!==i||e[17]!==v||e[18]!==b?(x=t.jsxs(Bt,{className:i,children:[v,b]}),e[16]=i,e[17]=v,e[18]=b,e[19]=x):x=e[19],x}function jt(s){const e=le.c(14),{metrics:r,connections:l,mode:a,total:o}=s,{org:d}=Be(),i=bt();let n,c,u;if(e[0]!==l||e[1]!==r||e[2]!==a||e[3]!==i||e[4]!==d||e[5]!==o){u=Symbol.for("react.early_return_sentinel");e:{const v=l??[],b=new Map(r.map(sr));let x;e[9]!==a?(x=(p,g)=>{const m=Lt(p.metric,a);return Lt(g.metric,a)-m},e[9]=a,e[10]=x):x=e[10];const L=v.map(p=>({connection:p,metric:b.get(p.id)})).filter(tr).sort(x).slice(0,4);if(L.length===0){u=null;break e}n="flex flex-col",c=L.map((p,g)=>{const{connection:m,metric:k}=p,S=o>0?(k.calls/o*100).toFixed(1):"0.0",h=a==="errors"?`${k.errorRate.toFixed(1)}%`:`${S}%`,T=g===L.length-1;return t.jsxs("div",{className:ce("flex items-center h-10 px-3 cursor-pointer hover:bg-accent/50 transition-colors",!T&&"border-b border-border/50"),onClick:()=>i({to:"/$org/settings/connections/$appSlug",params:{org:d.slug,appSlug:Fs(m)}}),children:[t.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0",children:[t.jsx(qe,{icon:m.icon,name:m.title,size:"xs",fallbackIcon:t.jsx(Qe,{}),className:"shrink-0 size-6! min-w-6! rounded-md"}),t.jsx("span",{className:"text-sm text-muted-foreground flex-1 truncate",children:m.title})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 px-3",children:[t.jsx("span",{className:"text-sm text-foreground/30 tabular-nums",children:h}),t.jsx("span",{className:"text-sm text-foreground tabular-nums",children:ys(k,a)})]})]},m.id)})}e[0]=l,e[1]=r,e[2]=a,e[3]=i,e[4]=d,e[5]=o,e[6]=n,e[7]=c,e[8]=u}else n=e[6],c=e[7],u=e[8];if(u!==Symbol.for("react.early_return_sentinel"))return u;let j;return e[11]!==n||e[12]!==c?(j=t.jsx("div",{className:n,children:c}),e[11]=n,e[12]=c,e[13]=j):j=e[13],j}function tr(s){return s.metric}function sr(s){return[s.connectionId,s]}const Ot=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"];function Et(s){let e=0;for(let r=0;r<s.length;r++)e=e*31+s.charCodeAt(r)>>>0;return Ot[e%Ot.length]}function He(s){const e=le.c(21),{models:r,mode:l}=s,a=l===void 0?"calls":l;if(r.length===0)return null;let o;e[0]!==a?(o=x=>a==="tokens"?(x.inputTokens??0)+(x.outputTokens??0):a==="cost"?x.costUsd??0:x.calls,e[0]=a,e[1]=o):o=e[1];const d=o;let i;e[2]!==a?(i=x=>a==="cost"?At(x):a==="tokens"?st(x):x.toLocaleString(),e[2]=a,e[3]=i):i=e[3];const n=i;let c;e[4]!==d?(c=(x,L)=>x+d(L),e[4]=d,e[5]=c):c=e[5];const u=r.reduce(c,0);let j,v;if(e[6]!==n||e[7]!==r||e[8]!==u||e[9]!==d){let x;e[12]!==d?(x=(g,m)=>d(m)-d(g),e[12]=d,e[13]=x):x=e[13];const L=[...r].sort(x).slice(0,4);j="flex flex-col";let p;e[14]!==n||e[15]!==u||e[16]!==d?(p=(g,m,k)=>{const S=d(g),h=u>0?(S/u*100).toFixed(1):"0.0",T=m===k.length-1;return t.jsxs("div",{className:ce("flex items-center h-10 px-3",!T&&"border-b border-border/50"),children:[t.jsxs("div",{className:"flex flex-1 items-center gap-2 min-w-0",children:[t.jsx("div",{className:"size-6 rounded-md border border-border/10 shadow-sm flex items-center justify-center shrink-0",style:{backgroundColor:`color-mix(in oklch, ${Et(g.toolName)} 18%, transparent)`},children:t.jsx(Qe,{size:14,style:{color:Et(g.toolName)}})}),t.jsx("span",{className:"text-sm text-muted-foreground flex-1 truncate",children:g.toolName})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 px-3",children:[t.jsxs("span",{className:"text-sm text-foreground/30 tabular-nums",children:[h,"%"]}),t.jsx("span",{className:"text-sm text-foreground tabular-nums",children:n(S)})]})]},g.toolName)},e[14]=n,e[15]=u,e[16]=d,e[17]=p):p=e[17],v=L.map(p),e[6]=n,e[7]=r,e[8]=u,e[9]=d,e[10]=j,e[11]=v}else j=e[10],v=e[11];let b;return e[18]!==j||e[19]!==v?(b=t.jsx("div",{className:j,children:v}),e[18]=j,e[19]=v,e[20]=b):b=e[20],b}function rr(s){const e=le.c(48),{displayDateRange:r,connectionIds:l,excludeConnectionIds:a,toolName:o,status:d,connections:i,isStreaming:n,streamingRefetchInterval:c,llmUserIds:u}=s,j=bs(r),v=n?c:!1;let b;e[0]!==v?(b={refetchInterval:v},e[0]=v,e[1]=b):b=e[1];const{data:x,isError:L}=Zs({interval:j,startDate:r.startDate.toISOString(),endDate:r.endDate.toISOString(),connectionIds:l.length>0?l:void 0,excludeConnectionIds:a,toolNames:o?[o]:void 0,status:d},b);let p;e[2]!==v?(p={refetchInterval:v},e[2]=v,e[3]=p):p=e[3];const{data:g,isError:m}=er({interval:j,startDate:r.startDate.toISOString(),endDate:r.endDate.toISOString(),userIds:u?.length?u:void 0},p),k=L||m,S=x?{totalCalls:x.totalCalls,totalErrors:x.totalErrors,avgDurationMs:x.avgDurationMs,p95DurationMs:x.p95DurationMs,data:Dt(x.timeseries,r,j)}:{totalCalls:0,totalErrors:0,avgDurationMs:0,p95DurationMs:0,data:[]},h=g?{totalCalls:g.totalCalls,totalErrors:g.totalErrors,avgDurationMs:g.avgDurationMs,p95DurationMs:g.p95DurationMs,data:Dt(g.timeseries,r,j)}:{totalCalls:0,totalErrors:0,avgDurationMs:0,p95DurationMs:0,data:[]};let T;e[4]!==g?.topTools?(T=g?.topTools??[],e[4]=g?.topTools,e[5]=T):T=e[5];const I=T,f=g?.totalInputTokens??0,M=g?.totalOutputTokens??0,y=g?.totalTokens??0,$=g?.totalCostUsd??0;let C;e[6]!==x?.connectionBreakdown?(C=x?.connectionBreakdown??[],e[6]=x?.connectionBreakdown,e[7]=C):C=e[7];const E=C,[R,H]=K.useState("avg");let A;e[8]!==k?(A=k&&t.jsxs(Ds,{variant:"destructive",children:[t.jsx(ss,{}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(Ls,{children:"Failed to load monitoring data"}),t.jsx(Rs,{children:"We couldn't fetch your monitoring stats right now. Please try again later."})]})]}),e[8]=k,e[9]=A):A=e[9];let W;e[10]===Symbol.for("react.memo_cache_sentinel")?(W=_e=>H(_e),e[10]=W):W=e[10];let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(lt,{className:"w-[120px]",children:t.jsx(ot,{})}),e[11]=w):w=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsxs(at,{children:[t.jsx(Re,{value:"avg",children:"Avg"}),t.jsx(Re,{value:"p95",children:"P95"})]}),e[12]=_):_=e[12];let F;e[13]!==R?(F=t.jsxs(nt,{value:R,onValueChange:W,children:[w,_]}),e[13]=R,e[14]=F):F=e[14];let z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsxs("div",{className:"flex items-center gap-3 pt-4",children:[t.jsx("div",{className:"h-px flex-1 bg-border"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"AI Usage"}),t.jsx("div",{className:"h-px flex-1 bg-border"})]}),e[15]=z):z=e[15];let O;e[16]!==I?(O=t.jsx(He,{models:I,mode:"calls"}),e[16]=I,e[17]=O):O=e[17];let V;e[18]!==y?(V=st(y),e[18]=y,e[19]=V):V=e[19];let q;e[20]!==f?(q=st(f),e[20]=f,e[21]=q):q=e[21];let J;e[22]!==M?(J=st(M),e[22]=M,e[23]=J):J=e[23];let G;e[24]!==q||e[25]!==J?(G=t.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[q," in ·"," ",J," out"]}),e[24]=q,e[25]=J,e[26]=G):G=e[26];let Q;e[27]!==I?(Q=t.jsx(He,{models:I,mode:"tokens"}),e[27]=I,e[28]=Q):Q=e[28];let U;e[29]!==$?(U=$>0?At($):"—",e[29]=$,e[30]=U):U=e[30];let P;e[31]!==$?(P=$===0?t.jsx("span",{className:"text-xs text-muted-foreground",children:"No provider cost data"}):void 0,e[31]=$,e[32]=P):P=e[32];let N;e[33]!==I||e[34]!==$?(N=$>0?t.jsx(He,{models:I,mode:"cost"}):t.jsx("div",{className:"flex items-center justify-center h-20 text-center text-xs text-muted-foreground px-4",children:"Cost is reported only for the deco AI Gateway and OpenRouter providers."}),e[33]=I,e[34]=$,e[35]=N):N=e[35];let D;e[36]!==I?(D=t.jsx(He,{models:I,mode:"calls"}),e[36]=I,e[37]=D):D=e[37];const B=Te,ee="AI Errors",X=h.totalErrors.toLocaleString();let te;e[38]!==h.data?(te=t.jsx(ke,{data:h.data,dataKey:"errors",colorNum:3,chartHeight:"h-[80px] md:h-[120px]"}),e[38]=h.data,e[39]=te):te=e[39];let Y;e[40]!==I||e[41]!==h.totalErrors?(Y=h.totalErrors===0?t.jsx("div",{className:"flex items-center justify-center h-20 text-sm text-muted-foreground",children:"No AI errors in this period"}):t.jsx(He,{models:I,mode:"calls"}),e[40]=I,e[41]=h.totalErrors,e[42]=Y):Y=e[42];let ae;return e[43]!==B||e[44]!==X||e[45]!==te||e[46]!==Y?(ae=t.jsxs(B,{title:ee,value:X,children:[te,Y]}),e[43]=B,e[44]=X,e[45]=te,e[46]=Y,e[47]=ae):ae=e[47],t.jsxs("div",{className:"flex flex-col gap-4 px-4 md:px-10 pt-2 pb-6 max-w-[1200px] mx-auto w-full overflow-auto",children:[A,t.jsxs(Te,{title:"Tool Calls",value:S.totalCalls.toLocaleString(),children:[t.jsx(ke,{data:S.data,dataKey:"calls",colorNum:1,chartHeight:"h-[120px] md:h-[180px]",variant:"area"}),t.jsx(jt,{metrics:E,connections:i,mode:"requests",total:S.totalCalls})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs(Te,{title:"Latency",value:pt(R==="avg"?S.avgDurationMs:S.p95DurationMs),action:F,children:[t.jsx(ke,{data:S.data,dataKey:R,colorNum:4,chartHeight:"h-[120px] md:h-[180px]"}),t.jsx(jt,{metrics:E,connections:i,mode:"latency",total:S.totalCalls})]}),t.jsxs(Te,{title:"Errors",value:S.totalErrors.toLocaleString(),children:[t.jsx(ke,{data:S.data,dataKey:"errors",colorNum:3,chartHeight:"h-[120px] md:h-[180px]"}),S.totalErrors===0?t.jsx("div",{className:"flex items-center justify-center h-20 text-sm text-muted-foreground",children:"No errors in this period"}):t.jsx(jt,{metrics:E,connections:i,mode:"errors",total:S.totalErrors})]})]}),z,t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(Te,{title:"AI Calls",value:h.totalCalls.toLocaleString(),children:[t.jsx(ke,{data:h.data,dataKey:"calls",colorNum:1,chartHeight:"h-[80px] md:h-[120px]"}),O]}),t.jsxs(Te,{title:"Tokens",value:V,action:G,children:[t.jsx(ke,{data:h.data,dataKey:"totalTokens",colorNum:2,chartHeight:"h-[80px] md:h-[120px]"}),Q]}),t.jsxs(Te,{title:"Cost",value:U,action:P,children:[t.jsx(ke,{data:h.data,dataKey:"costUsd",colorNum:5,chartHeight:"h-[80px] md:h-[120px]"}),N]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs(Te,{title:"AI Latency",value:pt(h.avgDurationMs),action:t.jsxs("span",{className:"text-xs text-muted-foreground",children:["p95: ",pt(h.p95DurationMs)]}),children:[t.jsx(ke,{data:h.data,dataKey:"avg",colorNum:4,chartHeight:"h-[80px] md:h-[120px]"}),D]}),ae]})]})}function Ke(s){const e=le.c(8),{className:r}=s;let l;e[0]!==r?(l=ce("pt-4 px-4 pb-6 gap-8",r),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"}),t.jsx("div",{className:"h-10 w-14 rounded bg-muted animate-pulse"})]}),t.jsx("div",{className:"h-8 w-[120px] rounded-md bg-muted animate-pulse"})]}),e[2]=a):a=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"h-[180px] w-full rounded bg-muted/60 animate-pulse"}),e[3]=o):o=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=Array.from({length:4}).map(lr),e[4]=d):d=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex flex-col gap-6",children:[o,t.jsxs("div",{className:"flex flex-col",children:[d,t.jsx("div",{className:"flex items-center h-10 px-4 gap-2",children:t.jsx("div",{className:"h-4 w-14 rounded bg-muted animate-pulse"})})]})]}),e[5]=i):i=e[5];let n;return e[6]!==l?(n=t.jsxs(Bt,{className:l,children:[a,i]}),e[6]=l,e[7]=n):n=e[7],n}function lr(s,e){return t.jsxs("div",{className:ce("flex items-center h-10 px-3",e<3&&"border-b border-border/50"),children:[t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"size-6 rounded-md bg-muted animate-pulse shrink-0"}),t.jsx("div",{className:"h-4 w-24 rounded bg-muted animate-pulse"})]}),t.jsxs("div",{className:"flex items-center gap-2 px-3",children:[t.jsx("div",{className:"h-4 w-10 rounded bg-muted animate-pulse"}),t.jsx("div",{className:"h-4 w-10 rounded bg-muted animate-pulse"})]})]},e)}function or(){const s=le.c(4);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ke,{}),s[0]=e):e=s[0];let r,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsx(Ke,{}),t.jsx(Ke,{})]}),l=t.jsx("div",{className:"border-t border-border"}),s[1]=r,s[2]=l):(r=s[1],l=s[2]);let a;return s[3]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsxs("div",{className:"flex flex-col gap-4 px-4 md:px-10 pt-8 md:pt-12 pb-6 max-w-[1200px] mx-auto w-full",children:[e,r,l,t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsx(Ke,{}),t.jsx(Ke,{}),t.jsx(Ke,{})]})]}),s[3]=a):a=s[3],a}function ar(s){const e=le.c(46),{log:r,connection:l,virtualMcpName:a,virtualMcpIcon:o,onClick:d,lastLogRef:i}=s;let n,c;if(e[0]!==r.timestamp){const R=new Date(r.timestamp);n=R.toLocaleDateString("en-US",{month:"short",day:"numeric"}),c=R.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit"}),e[0]=r.timestamp,e[1]=n,e[2]=c}else n=e[1],c=e[2];const u=c,j=l?.icon||null,v=l?.title??r.connectionId;let b;e[3]!==j||e[4]!==v?(b=t.jsx(De,{className:"w-12 md:w-16 px-2 md:px-4",children:t.jsx("div",{className:"flex items-center justify-center",children:t.jsx(qe,{icon:j,name:v,size:"xs",className:"shadow-sm"})})}),e[3]=j,e[4]=v,e[5]=b):b=e[5];let x;e[6]!==r.toolName?(x=t.jsx("div",{className:"font-medium text-foreground truncate block",children:r.toolName}),e[6]=r.toolName,e[7]=x):x=e[7];const L=l?.title??r.connectionId;let p;e[8]!==L?(p=t.jsx("div",{className:"text-muted-foreground truncate block text-xs",children:L}),e[8]=L,e[9]=p):p=e[9];let g;e[10]!==x||e[11]!==p?(g=t.jsxs(De,{className:"min-w-0 pr-2 md:pr-4",children:[x,p]}),e[10]=x,e[11]=p,e[12]=g):g=e[12];let m;e[13]!==o||e[14]!==a?(m=t.jsx(De,{className:"w-36 md:w-44 px-2 md:px-3 text-muted-foreground",children:a?t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(qe,{icon:o,name:a,size:"xs",fallbackIcon:t.jsx(Qe,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),t.jsx("span",{className:"truncate",children:a})]}):t.jsx("span",{className:"text-muted-foreground/40",children:"—"})}),e[13]=o,e[14]=a,e[15]=m):m=e[15];let k;e[16]!==r.userImage||e[17]!==r.userName?(k=t.jsx(qt,{url:r.userImage,fallback:r.userName,shape:"circle",size:"2xs",className:"shrink-0"}),e[16]=r.userImage,e[17]=r.userName,e[18]=k):k=e[18];let S;e[19]!==r.userName?(S=t.jsx("span",{className:"truncate",children:r.userName}),e[19]=r.userName,e[20]=S):S=e[20];let h;e[21]!==k||e[22]!==S?(h=t.jsx(De,{className:"w-28 md:w-36 px-2 md:px-3 text-muted-foreground",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[k,S]})}),e[21]=k,e[22]=S,e[23]=h):h=e[23];let T;e[24]!==n?(T=t.jsx("div",{children:n}),e[24]=n,e[25]=T):T=e[25];let I;e[26]!==u?(I=t.jsx("div",{className:"text-xs text-muted-foreground/60",children:u}),e[26]=u,e[27]=I):I=e[27];let f;e[28]!==T||e[29]!==I?(f=t.jsxs(De,{className:"w-32 md:w-40 px-2 md:px-3 text-muted-foreground",children:[T,I]}),e[28]=T,e[29]=I,e[30]=f):f=e[30];let M;e[31]!==r.durationMs?(M=t.jsxs(De,{className:"w-16 md:w-20 px-2 md:px-3 text-muted-foreground font-mono",children:[r.durationMs,"ms"]}),e[31]=r.durationMs,e[32]=M):M=e[32];const y=r.isError?"destructive":"success",$=r.isError?"Error":"OK";let C;e[33]!==y||e[34]!==$?(C=t.jsx(De,{className:"w-16 md:w-24 px-2 md:px-3 pr-3 md:pr-5",children:t.jsx("div",{className:"flex items-center justify-end",children:t.jsx(rt,{variant:y,className:"px-1.5 md:px-2 py-0.5 md:py-1",children:$})})}),e[33]=y,e[34]=$,e[35]=C):C=e[35];let E;return e[36]!==i||e[37]!==d||e[38]!==h||e[39]!==f||e[40]!==M||e[41]!==C||e[42]!==b||e[43]!==g||e[44]!==m?(E=t.jsxs(ut,{ref:i,className:"h-14 md:h-16 transition-colors cursor-pointer hover:bg-muted/40 border-b-0",onClick:d,children:[b,g,m,h,f,M,C]}),e[36]=i,e[37]=d,e[38]=h,e[39]=f,e[40]=M,e[41]=C,e[42]=b,e[43]=g,e[44]=m,e[45]=E):E=e[45],E}function nr(s){const e=le.c(26),{connectionIds:r,virtualMcpIds:l,tool:a,status:o,search:d,logs:i,hasMore:n,onLoadMore:c,isLoadingMore:u,connections:j,virtualMcps:v,membersData:b,client:x}=s,L=j??[],p=v??[],[g,m]=K.useState(null),k=Vs(c,n,u),S=Vt(b),h=new Map(S.map(mr)),T=new Map(p.map(dr));let f=i.map(N=>{const D=h.get(N.userId??""),B=N.virtualMcpId?T.get(N.virtualMcpId):null;return{...N,userName:D?.name??N.userId??"Unknown",userImage:D?.image??void 0,virtualMcpName:B?.title??null,virtualMcpIcon:B?.icon??null}});if(r.length>1){let N;e[0]!==r?(N=D=>r.includes(D.connectionId),e[0]=r,e[1]=N):N=e[1],f=f.filter(N)}if(l.length>1){let N;e[2]!==l?(N=D=>D.virtualMcpId&&l.includes(D.virtualMcpId),e[2]=l,e[3]=N):N=e[3],f=f.filter(N)}const M=new Map(L.map(cr));if(d){const N=d.toLowerCase();f=f.filter(D=>D.toolName.toLowerCase().includes(N)||(M.get(D.connectionId)?.title??D.connectionId).toLowerCase().includes(N)||D.errorMessage?.toLowerCase().includes(N))}const y=g!==null?f[g]??null:null,$=yt({queryKey:it.monitoringLogDetail(y?.id??""),queryFn:async()=>{if(!x)throw new Error("MCP client is not available");const N=await x.callTool({name:"MONITORING_LOG_GET",arguments:{id:y.id}});return N.structuredContent??N},enabled:y!==null}),C=$.data?.log,E=y&&C?{...y,input:C.input,output:C.output}:y;if(f.length===0){let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("img",{src:"/empty-state-logs.svg",alt:"",width:336,height:320,"aria-hidden":"true"}),e[4]=N):N=e[4];const D=d||r.length>0||l.length>0||a||o!=="all"?"No logs match your filters":"No logs found in this time range";let B;return e[5]!==D?(B=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(wt,{image:N,title:"No logs found",description:D})}),e[5]=D,e[6]=B):B=e[6],B}const R="flex-1 flex flex-col min-w-0",H="flex-1 min-w-0 pt-1",A="min-w-[600px] md:min-w-0",W=Gt,w="w-full border-collapse";let _;e[7]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx(Qt,{className:"border-b-0 z-20",children:t.jsxs(ut,{className:"h-9 hover:bg-transparent border-b border-border",children:[t.jsx(oe,{className:"w-5"}),t.jsx(oe,{className:"pr-2 md:pr-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Tool / Connection"}),t.jsx(oe,{className:"w-36 md:w-44 px-2 md:px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Agent"}),t.jsx(oe,{className:"w-28 md:w-36 px-2 md:px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"User"}),t.jsx(oe,{className:"w-32 md:w-40 px-2 md:px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Date"}),t.jsx(oe,{className:"w-16 md:w-20 px-2 md:px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Latency"}),t.jsx(oe,{className:"w-16 md:w-24 px-2 md:px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right pr-3 md:pr-5",children:"Status"})]})}),e[7]=_):_=e[7];const F=Jt,z=f.map((N,D)=>t.jsx(ar,{log:N,connection:M.get(N.connectionId),virtualMcpName:N.virtualMcpName??"",virtualMcpIcon:N.virtualMcpIcon,onClick:()=>m(D),lastLogRef:D===f.length-1?k:void 0},N.id));let O;e[8]!==F||e[9]!==z?(O=t.jsx(F,{children:z}),e[8]=F,e[9]=z,e[10]=O):O=e[10];let V;e[11]!==W||e[12]!==_||e[13]!==O?(V=t.jsx("div",{className:H,children:t.jsx("div",{className:A,children:t.jsxs(W,{className:w,children:[_,O]})})}),e[11]=W,e[12]=_,e[13]=O,e[14]=V):V=e[14];const q=g!==null;let J;e[15]!==m?(J=N=>{N||m(null)},e[15]=m,e[16]=J):J=e[16];const G=y&&g!==null&&t.jsxs(t.Fragment,{children:[t.jsx(zs,{className:"px-5 md:px-6 pt-6 pb-5 border-b border-border shrink-0",children:t.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(qe,{icon:M.get(y.connectionId)?.icon||null,name:M.get(y.connectionId)?.title??y.connectionId,size:"sm",className:"shadow-sm shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(Os,{className:"text-sm leading-snug truncate",children:y.toolName}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:M.get(y.connectionId)?.title??y.connectionId})]})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[t.jsx(Z,{size:"icon",variant:"ghost",onClick:()=>m(ir),disabled:g===0,className:"h-7 w-7 text-muted-foreground","aria-label":"Previous entry",children:t.jsx(As,{size:14})}),t.jsx(Z,{size:"icon",variant:"ghost",onClick:()=>m(N=>N!==null&&N<f.length-1?N+1:N),disabled:g===f.length-1,className:"h-7 w-7 text-muted-foreground","aria-label":"Next entry",children:t.jsx(Ut,{size:14})})]})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:$.isLoading?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"size-5 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"})}):$.isError?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground",children:[t.jsx("p",{children:"Failed to load log details"}),t.jsx(Z,{variant:"outline",size:"sm",onClick:()=>$.refetch(),children:"Retry"})]}):t.jsx(Hs,{log:E})})]});let Q;e[17]!==G?(Q=t.jsx(Es,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:G}),e[17]=G,e[18]=Q):Q=e[18];let U;e[19]!==J||e[20]!==Q||e[21]!==q?(U=t.jsx(Ps,{open:q,onOpenChange:J,children:Q}),e[19]=J,e[20]=Q,e[21]=q,e[22]=U):U=e[22];let P;return e[23]!==U||e[24]!==V?(P=t.jsxs("div",{className:R,children:[V,U]}),e[23]=U,e[24]=V,e[25]=P):P=e[25],P}function ir(s){return s!==null&&s>0?s-1:s}function cr(s){return[s.id,s]}function dr(s){return[s.id,s]}function mr(s){return[s.userId,s.user]}function ur(){const s=le.c(8);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(oe,{className:"w-12 md:w-16 px-2 md:px-4"}),s[0]=e):e=s[0];let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(oe,{className:"pr-2 md:pr-4",children:t.jsx("div",{className:"h-3 w-24 rounded bg-muted animate-pulse"})}),s[1]=r):r=s[1];let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(oe,{className:"w-24 md:w-32 px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-12 rounded bg-muted animate-pulse"})}),s[2]=l):l=s[2];let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(oe,{className:"w-20 md:w-24 px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-16 rounded bg-muted animate-pulse"})}),s[3]=a):a=s[3];let o;s[4]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(oe,{className:"w-32 md:w-40 px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-10 rounded bg-muted animate-pulse"})}),s[4]=o):o=s[4];let d;s[5]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(oe,{className:"w-16 md:w-20 px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-10 rounded bg-muted animate-pulse ml-auto"})}),s[5]=d):d=s[5];let i;s[6]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Qt,{className:"border-b-0 z-20",children:t.jsxs(ut,{className:"h-9 hover:bg-transparent border-b border-border",children:[e,r,l,a,o,d,t.jsx(oe,{className:"w-16 md:w-24 px-2 md:px-3 pr-3 md:pr-5",children:t.jsx("div",{className:"h-3 w-12 rounded bg-muted animate-pulse ml-auto"})})]})}),s[6]=i):i=s[6];let n;return s[7]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("div",{className:"flex-1 flex flex-col overflow-auto min-w-0",children:t.jsx("div",{className:"mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",children:t.jsxs(Gt,{className:"w-full border-collapse",children:[i,t.jsx(Jt,{children:Array.from({length:8}).map(xr)})]})})}),s[7]=n):n=s[7],n}function xr(s,e){return t.jsxs(ut,{className:"h-14 border-b border-border hover:bg-transparent",children:[t.jsx("td",{className:"px-2 md:px-4",children:t.jsx("div",{className:"size-5 rounded bg-muted animate-pulse"})}),t.jsx("td",{className:"pr-2 md:pr-4",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"h-3.5 w-32 rounded bg-muted animate-pulse"}),t.jsx("div",{className:"h-2.5 w-20 rounded bg-muted animate-pulse"})]})}),t.jsx("td",{className:"px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-16 rounded bg-muted animate-pulse"})}),t.jsx("td",{className:"px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-14 rounded bg-muted animate-pulse"})}),t.jsx("td",{className:"px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-16 rounded bg-muted animate-pulse"})}),t.jsx("td",{className:"px-2 md:px-3",children:t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"h-3 w-14 rounded bg-muted animate-pulse"}),t.jsx("div",{className:"h-2.5 w-20 rounded bg-muted animate-pulse"})]})}),t.jsx("td",{className:"px-2 md:px-3",children:t.jsx("div",{className:"h-3 w-10 rounded bg-muted animate-pulse ml-auto"})}),t.jsx("td",{className:"px-2 md:px-3 pr-3 md:pr-5",children:t.jsx("div",{className:"h-5 w-14 rounded-full bg-muted animate-pulse ml-auto"})})]},e)}const Nt=Object.assign(nr,{Skeleton:ur});function fr(s){const e=le.c(34),{client:r,locator:l,baseParams:a,pageSize:o,isStreaming:d,streamingRefetchInterval:i,connectionIds:n,virtualMcpIds:c,tool:u,status:j,searchQuery:v,allConnections:b,allVirtualMcps:x,membersData:L}=s;let p;e[0]!==a||e[1]!==l?(p=it.monitoringLogsInfinite(l,JSON.stringify(a)),e[0]=a,e[1]=l,e[2]=p):p=e[2];let g;e[3]!==a||e[4]!==r||e[5]!==o?(g=async H=>{const{pageParam:A}=H,W=A===void 0?0:A;if(!r)throw new Error("MCP client is not available");const w=await r.callTool({name:"MONITORING_LOGS_LIST",arguments:{...a,limit:o,offset:W}});return w.structuredContent??w},e[3]=a,e[4]=r,e[5]=o,e[6]=g):g=e[6];let m;e[7]!==o?(m=(H,A)=>{if(!((H?.logs?.length??0)<o))return A.length*o},e[7]=o,e[8]=m):m=e[8];const k=d?i:!1;let S;e[9]!==p||e[10]!==g||e[11]!==m||e[12]!==k?(S={queryKey:p,queryFn:g,initialPageParam:0,getNextPageParam:m,staleTime:0,refetchInterval:k},e[9]=p,e[10]=g,e[11]=m,e[12]=k,e[13]=S):S=e[13];const{data:h,fetchNextPage:T,hasNextPage:I,isFetchingNextPage:f}=$s(S);let M;e[14]!==h.pages?(M=h.pages.flatMap(pr),e[14]=h.pages,e[15]=M):M=e[15];const y=M;let $;e[16]!==T||e[17]!==I||e[18]!==f?($=()=>{I&&!f&&T()},e[16]=T,e[17]=I,e[18]=f,e[19]=$):$=e[19];const C=$,E=I??!1;let R;return e[20]!==b||e[21]!==x||e[22]!==r||e[23]!==n||e[24]!==C||e[25]!==f||e[26]!==L||e[27]!==y||e[28]!==v||e[29]!==j||e[30]!==E||e[31]!==u||e[32]!==c?(R=t.jsx("div",{className:"flex-1 flex flex-col overflow-auto min-w-0",children:t.jsx("div",{className:"mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",children:t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:t.jsx(Nt,{connectionIds:n,virtualMcpIds:c,tool:u,status:j,search:v,logs:y,hasMore:E,onLoadMore:C,isLoadingMore:f,connections:b,virtualMcps:x,membersData:L,client:r})})})}),e[20]=b,e[21]=x,e[22]=r,e[23]=n,e[24]=C,e[25]=f,e[26]=L,e[27]=y,e[28]=v,e[29]=j,e[30]=E,e[31]=u,e[32]=c,e[33]=R):R=e[33],R}function pr(s){return s.logs??[]}function hr(s){const e=le.c(15),{dateRange:r}=s,{data:l,isLoading:a}=Us(void 0);let o;e[0]!==l?(o=l===void 0?[]:l,e[0]=l,e[1]=o):o=e[1];const d=o,[i,n]=K.useState(null),c=i??d[0]?.id??null,{data:u}=Ks(c??"");let j;e[2]!==r.startDate?(j=r.startDate.toISOString(),e[2]=r.startDate,e[3]=j):j=e[3];let v;e[4]!==r.endDate?(v=r.endDate.toISOString(),e[4]=r.endDate,e[5]=v):v=e[5];let b;e[6]!==j||e[7]!==v?(b={startDate:j,endDate:v},e[6]=j,e[7]=v,e[8]=b):b=e[8];const x=b;let L;return e[9]!==u||e[10]!==d||e[11]!==c||e[12]!==a||e[13]!==x?(L=t.jsx("div",{className:"flex-1 flex flex-col overflow-auto min-w-0",children:t.jsx("div",{className:"mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0 gap-5 pt-1",children:a?t.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Loading…"}):d.length===0?t.jsx("div",{className:"py-16",children:t.jsx(wt,{title:"No automations",description:"Create an automation to see its runs and usage here."})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(nt,{value:c??"",onValueChange:p=>n(p),children:[t.jsx(lt,{className:"w-72",children:t.jsx(ot,{placeholder:"Select an automation…"})}),t.jsx(at,{children:d.map(jr)})]})}),u?t.jsx(ws,{automationId:u.id,triggerIds:u.triggers.map(gr),range:x}):t.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Loading…"})]})})}),e[9]=u,e[10]=d,e[11]=c,e[12]=a,e[13]=x,e[14]=L):L=e[14],L}function gr(s){return s.id}function jr(s){return t.jsx(Re,{value:s.id,children:s.name},s.id)}const vr=[{value:"eq",label:"equals"},{value:"contains",label:"contains"},{value:"in",label:"in (list)"},{value:"exists",label:"exists"}];function Nr({connectionIds:s,virtualMcpIds:e,tool:r,status:l,hideSystem:a,propertyFilters:o,connectionOptions:d,virtualMcpOptions:i,activeFiltersCount:n,onUpdateFilters:c,onConnectionSearchChange:u,memberOptions:j,llmUserIds:v=[],onLlmUserIdsChange:b,showMemberFilter:x}){const[L,p]=K.useState(!1),[g,m]=K.useState("form"),[k,S]=K.useState(r),[h,T]=K.useState(o),[I,f]=K.useState(Ye(o)),M=K.useRef(r),y=K.useRef(Le(o));M.current!==r&&(M.current=r,k!==r&&S(r));const $=Le(o);y.current!==$&&(y.current=$,T(o),f(Ye(o)));const C=(w,_)=>{const F=[...h],z=F[w];z&&(F[w]={key:_.key??z.key,operator:_.operator??z.operator,value:_.value??z.value},T(F))},E=()=>{T([...h,{key:"",operator:"eq",value:""}])},R=w=>{const _=h.filter((F,z)=>z!==w);T(_),f(Ye(_)),c({propertyFilters:Le(_)})},H=()=>{c({propertyFilters:Le(h)})},A=()=>{const w=Rt(I);T(w),c({propertyFilters:Le(w)})},W=()=>{if(g==="raw"){const w=Rt(I);T(w),m("form")}else f(Ye(h)),m("raw")};return t.jsxs(ct,{open:L,onOpenChange:p,children:[t.jsx(dt,{asChild:!0,children:t.jsxs(Z,{variant:"outline",className:"relative",children:[t.jsx(Pt,{size:16}),t.jsx("span",{className:"hidden sm:inline",children:"Filters"}),n>0&&t.jsxs(t.Fragment,{children:[t.jsx(rt,{variant:"default",className:"sm:hidden absolute -top-1.5 -right-1.5 h-4 min-w-4 px-1 text-[10px] leading-none",children:n}),t.jsx(rt,{variant:"default",className:"hidden sm:flex ml-1 h-5 w-5 rounded-full p-0 items-center justify-center text-xs",children:n})]})]})}),t.jsx(mt,{align:"end",className:"w-[320px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{children:t.jsx("h4",{className:"font-medium text-sm mb-3",children:"Filter Logs"})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(_s,{htmlFor:"hide-system-calls",className:"text-xs font-medium text-muted-foreground cursor-pointer",children:"Hide system calls"}),t.jsx(Ms,{id:"hide-system-calls",checked:a,onCheckedChange:w=>c({hideSystem:!!w})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Connections"}),t.jsx(ht,{options:d,defaultValue:s,onValueChange:w=>c({connectionId:w}),onSearchChange:u,placeholder:"All servers",variant:"secondary",className:"w-full",maxCount:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Agents"}),t.jsx(ht,{options:i,defaultValue:e,onValueChange:w=>c({virtualMcpId:w}),placeholder:"All Agents",variant:"secondary",className:"w-full",maxCount:2})]}),x&&t.jsxs("div",{children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Members"}),t.jsx(ht,{options:j??[],defaultValue:v,onValueChange:w=>b?.(w),placeholder:"All members",variant:"secondary",className:"w-full",maxCount:2}),t.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Filters AI usage (calls, tokens, cost) only."})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Tool Name"}),t.jsx(Ge,{id:"filter-tool",placeholder:"Filter by tool...",value:k,onChange:w=>S(w.target.value),onBlur:()=>{k!==r&&c({tool:k})},onKeyDown:w=>{w.key==="Enter"&&k!==r&&c({tool:k})},className:"w-full"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Status"}),t.jsxs(nt,{value:l,onValueChange:w=>c({status:w}),children:[t.jsx(lt,{className:"w-full",children:t.jsx(ot,{})}),t.jsxs(at,{children:[t.jsx(Re,{value:"all",children:"All Status"}),t.jsx(Re,{value:"success",children:"Success Only"}),t.jsx(Re,{value:"errors",children:"Errors Only"})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"Property Filters"}),t.jsxs(Ze,{children:[t.jsx(et,{asChild:!0,children:t.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:W,children:g==="raw"?t.jsx(js,{size:14}):t.jsx(us,{size:14})})}),t.jsx(tt,{children:g==="raw"?"Switch to form view":"Switch to raw text"})]})]}),g==="raw"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Ts,{placeholder:`Paste property filters here:
6
+ thread_id=abc123
7
+ user~test
8
+ debug?`,value:I,onChange:w=>f(w.target.value),onBlur:A,onKeyDown:w=>{w.key==="Enter"&&w.metaKey&&A()},className:"font-mono text-sm min-h-[80px] resize-none"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["One per line:"," ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"key=value"})," ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"key~contains"})," ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"key@in_list"})," ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"key?"})]})]}):t.jsxs("div",{className:"space-y-3",children:[h.map((w,_)=>t.jsxs("div",{className:"p-2.5 rounded-md border border-border bg-muted/30 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-xs text-muted-foreground",children:["Filter ",_+1]}),t.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>R(_),children:t.jsx(Ns,{size:12})})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ge,{placeholder:"Key (e.g., thread_id)",value:w.key,onChange:F=>C(_,{key:F.target.value}),onBlur:H,onKeyDown:F=>{F.key==="Enter"&&H()},className:"flex-1 font-mono text-sm"}),t.jsxs(nt,{value:w.operator,onValueChange:F=>{const z=[...h],O=z[_];O&&(z[_]={...O,operator:F,value:F==="exists"?"":O.value},T(z),c({propertyFilters:Le(z)}))},children:[t.jsx(lt,{className:"w-28",children:t.jsx(ot,{})}),t.jsx(at,{children:vr.map(F=>t.jsx(Re,{value:F.value,children:F.label},F.value))})]})]}),w.operator!=="exists"&&t.jsx(Ge,{placeholder:"Value",value:w.value,onChange:F=>C(_,{value:F.target.value}),onBlur:H,onKeyDown:F=>{F.key==="Enter"&&H()},className:"w-full font-mono text-sm"})]},_)),t.jsxs(Z,{variant:"outline",size:"sm",className:"w-full",onClick:E,children:[t.jsx(vs,{size:14,className:"mr-1.5"}),"Add filter"]})]})]})]}),n>0&&t.jsx(Z,{variant:"ghost",size:"sm",className:"w-full",onClick:()=>{S(""),T([]),f(""),c({connectionId:[],virtualMcpId:[],tool:"",status:"all",propertyFilters:""}),p(!1)},children:"Clear all filters"})]})})]})}function br(s){const e=le.c(113),{tab:r,dateRange:l,displayDateRange:a,connectionIds:o,virtualMcpIds:d,tool:i,status:n,search:c,streaming:u,hideSystem:j,activeFiltersCount:v,from:b,to:x,propertyFilters:L,onUpdateFilters:p,onTimeRangeChange:g,onStreamingToggle:m,onTabChange:k}=s,S=_t(),h=gs(),{data:T}=xs(),[I,f]=K.useState(""),M=I||void 0;let y;e[0]!==M?(y={searchTerm:M},e[0]=M,e[1]=y):y=e[1];const $=_t(y);let C;e[2]!==$?(C=$??[],e[2]=$,e[3]=C):C=e[3];let E;e[4]!==C?(E=C.map(Sr),e[4]=C,e[5]=E):E=e[5];const R=E;let H;e[6]!==h?(H=h.map(wr),e[6]=h,e[7]=H):H=e[7];const A=H,{pageSize:W,streamingRefetchInterval:w}=vt,{org:_,locator:F}=Be();let z;e[8]!==_.id||e[9]!==_.slug?(z={connectionId:fs,orgId:_.id,orgSlug:_.slug},e[8]=_.id,e[9]=_.slug,e[10]=z):z=e[10];const O=ps(z);let V;e[11]!==L?(V=Bs(L),e[11]=L,e[12]=V):V=e[12];const q=V;let J;e[13]!==j||e[14]!==_.id?(J=j?[hs.SELF(_.id)]:void 0,e[13]=j,e[14]=_.id,e[15]=J):J=e[15];const G=J;let Q;e[16]===Symbol.for("react.memo_cache_sentinel")?(Q=[],e[16]=Q):Q=e[16];const[U,P]=K.useState(Q);let N;e[17]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[17]=N):N=e[17];const[D,B]=K.useState(N);let ee;e[18]===Symbol.for("react.memo_cache_sentinel")?(ee=[],e[18]=ee):ee=e[18];const[X,te]=K.useState(ee),[Y,ae]=K.useState("all"),_e=(D.length>0?1:0)+(X.length>0?1:0)+(Y!=="all"?1:0);let Fe;e[19]!==T?(Fe=Vt(T).map(yr),e[19]=T,e[20]=Fe):Fe=e[20];const Se=Fe;let ne;e[21]!==l.startDate?(ne=l.startDate.toISOString(),e[21]=l.startDate,e[22]=ne):ne=e[22];let he;e[23]!==l.endDate?(he=l.endDate.toISOString(),e[23]=l.endDate,e[24]=he):he=e[24];const ge=o.length===1?o[0]:void 0,je=d.length===1?d[0]:void 0,ve=i||void 0,Ne=n==="errors"?!0:n==="success"?!1:void 0;let de;e[25]!==G||e[26]!==q||e[27]!==ne||e[28]!==he||e[29]!==ge||e[30]!==je||e[31]!==ve||e[32]!==Ne?(de={startDate:ne,endDate:he,connectionId:ge,excludeConnectionIds:G,virtualMcpId:je,toolName:ve,isError:Ne,...q},e[25]=G,e[26]=q,e[27]=ne,e[28]=he,e[29]=ge,e[30]=je,e[31]=ve,e[32]=Ne,e[33]=de):de=e[33];const be=de;let me;e[34]===Symbol.for("react.memo_cache_sentinel")?(me={id:"overview",label:"Overview"},e[34]=me):me=e[34];let ue;e[35]===Symbol.for("react.memo_cache_sentinel")?(ue={id:"audit",label:"Audit"},e[35]=ue):ue=e[35];let xe;e[36]===Symbol.for("react.memo_cache_sentinel")?(xe={id:"threads",label:"Threads"},e[36]=xe):xe=e[36];let fe;e[37]===Symbol.for("react.memo_cache_sentinel")?(fe=[me,ue,xe,{id:"automations",label:"Automations"}],e[37]=fe):fe=e[37];const $e=fe;let se;e[38]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsx(Me.Title,{children:"Monitoring"}),e[38]=se):se=e[38];let re;e[39]!==k?(re=Ie=>k(Ie),e[39]=k,e[40]=re):re=e[40];let ie;e[41]!==re||e[42]!==r?(ie=t.jsx(Kt,{tabs:$e,activeTab:r,onTabChange:re}),e[41]=re,e[42]=r,e[43]=ie):ie=e[43];let pe;e[44]!==v||e[45]!==o||e[46]!==R||e[47]!==I||e[48]!==j||e[49]!==u||e[50]!==U||e[51]!==Se||e[52]!==m||e[53]!==p||e[54]!==L||e[55]!==n||e[56]!==r||e[57]!==i||e[58]!==d||e[59]!==A?(pe=(r==="overview"||r==="audit")&&t.jsxs(t.Fragment,{children:[t.jsxs(Z,{variant:u?"secondary":"outline",className:"gap-1.5",onClick:m,children:[u&&t.jsx("span",{className:"size-2 rounded-full bg-emerald-500 animate-pulse"}),t.jsx("span",{children:"Live"}),u&&t.jsx("span",{className:"text-muted-foreground text-xs",children:"3s"})]}),t.jsx(Nr,{connectionIds:o,virtualMcpIds:d,tool:i,status:n,hideSystem:j,propertyFilters:L,connectionOptions:R,virtualMcpOptions:A,activeFiltersCount:v,onUpdateFilters:p,connectionSearchTerm:I,onConnectionSearchChange:f,memberOptions:Se,llmUserIds:U,onLlmUserIdsChange:P,showMemberFilter:r==="overview"})]}),e[44]=v,e[45]=o,e[46]=R,e[47]=I,e[48]=j,e[49]=u,e[50]=U,e[51]=Se,e[52]=m,e[53]=p,e[54]=L,e[55]=n,e[56]=r,e[57]=i,e[58]=d,e[59]=A,e[60]=pe):pe=e[60];let ye;e[61]!==Se||e[62]!==r||e[63]!==_e||e[64]!==D||e[65]!==Y||e[66]!==X||e[67]!==A?(ye=r==="threads"&&t.jsx(Ss,{filterAgentIds:D,filterUserIds:X,filterStatus:Y,virtualMcpOptions:A,memberOptions:Se,activeFiltersCount:_e,onUpdateFilters:Ie=>{const{filterAgentIds:St,filterUserIds:It,filterStatus:Ct}=Ie;St!==void 0&&B(St),It!==void 0&&te(It),Ct!==void 0&&ae(Ct)}}),e[61]=Se,e[62]=r,e[63]=_e,e[64]=D,e[65]=Y,e[66]=X,e[67]=A,e[68]=ye):ye=e[68];let ze;e[69]!==b||e[70]!==x?(ze={from:b,to:x},e[69]=b,e[70]=x,e[71]=ze):ze=e[71];let Oe;e[72]!==g||e[73]!==ze?(Oe=t.jsx(Ys,{value:ze,onChange:g}),e[72]=g,e[73]=ze,e[74]=Oe):Oe=e[74];let Ee;e[75]!==pe||e[76]!==ye||e[77]!==Oe?(Ee=t.jsxs("div",{className:"flex items-center gap-2",children:[pe,ye,Oe]}),e[75]=pe,e[76]=ye,e[77]=Oe,e[78]=Ee):Ee=e[78];let Pe;e[79]!==ie||e[80]!==Ee?(Pe=t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[ie,Ee]}),e[79]=ie,e[80]=Ee,e[81]=Pe):Pe=e[81];let Ae;e[82]!==p||e[83]!==c||e[84]!==r?(Ae=(r==="audit"||r==="threads")&&t.jsx(os,{value:c,onChange:Ie=>p({search:Ie}),placeholder:r==="threads"?"Search by title…":"Search by tool name, connection, or error...",onKeyDown:Ie=>{Ie.key==="Escape"&&(p({search:""}),Ie.target.blur())},className:"w-full md:w-[375px]"}),e[82]=p,e[83]=c,e[84]=r,e[85]=Ae):Ae=e[85];let Ve;e[86]!==Pe||e[87]!==Ae?(Ve=t.jsx(Me.Body,{className:"!pb-4",children:t.jsxs("div",{className:"flex flex-col gap-5",children:[se,Pe,Ae]})}),e[86]=Pe,e[87]=Ae,e[88]=Ve):Ve=e[88];let Ue;e[89]!==S||e[90]!==h||e[91]!==be||e[92]!==O||e[93]!==o||e[94]!==l||e[95]!==a||e[96]!==G||e[97]!==u||e[98]!==U||e[99]!==F||e[100]!==T||e[101]!==c||e[102]!==n||e[103]!==r||e[104]!==D||e[105]!==Y||e[106]!==X||e[107]!==i||e[108]!==d?(Ue=r==="automations"?t.jsx(hr,{dateRange:l}):r==="threads"?t.jsx(Is,{client:O,locator:F,membersData:T,allConnections:S,allVirtualMcps:h,dateRange:l,searchQuery:c,filterAgentIds:D,filterUserIds:X,filterStatus:Y}):r==="audit"?t.jsx(fr,{client:O,locator:F,baseParams:be,pageSize:W,isStreaming:u,streamingRefetchInterval:w,connectionIds:o,virtualMcpIds:d,tool:i,status:n,searchQuery:c,allConnections:S,allVirtualMcps:h,membersData:T}):t.jsx("div",{className:"flex-1 flex flex-col overflow-auto min-w-0",children:t.jsx(rr,{displayDateRange:a,connectionIds:o,excludeConnectionIds:G,toolName:i||void 0,status:n==="errors"?"error":n==="success"?"success":void 0,connections:S,isStreaming:u,streamingRefetchInterval:w,llmUserIds:U})}),e[89]=S,e[90]=h,e[91]=be,e[92]=O,e[93]=o,e[94]=l,e[95]=a,e[96]=G,e[97]=u,e[98]=U,e[99]=F,e[100]=T,e[101]=c,e[102]=n,e[103]=r,e[104]=D,e[105]=Y,e[106]=X,e[107]=i,e[108]=d,e[109]=Ue):Ue=e[109];let We;return e[110]!==Ve||e[111]!==Ue?(We=t.jsxs(t.Fragment,{children:[Ve,Ue]}),e[110]=Ve,e[111]=Ue,e[112]=We):We=e[112],We}function yr(s){const e=s.user.name??s.user.email??s.userId,r=s.user.image??void 0;return{value:s.userId,label:e,icon:l=>{const{className:a}=l;return t.jsx(qt,{url:r,fallback:e,shape:"circle",size:"2xs",className:ce("shrink-0",a)})}}}function wr(s){const e=s.icon,r=s.title??"Decopilot";return{value:s.id??"",label:r,icon:l=>{const{className:a}=l;return t.jsx(qe,{icon:e,name:r,size:"xs",fallbackIcon:t.jsx(Qe,{}),className:ce("size-4! min-w-4! rounded-sm shrink-0",a)})}}}function Sr(s){const e=s.icon,r=s.title||s.id;return{value:s.id,label:r,icon:l=>{const{className:a}=l;return t.jsx(qe,{icon:e,name:r,size:"xs",fallbackIcon:t.jsx(Qe,{}),className:ce("size-4! min-w-4! rounded-sm shrink-0",a)})}}}function Do(){const s=le.c(83),{org:e}=Be(),r=bt();let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l={from:"/shell/$org/settings/monitor"},s[0]=l):l=s[0];const a=rs(l),{tab:o,from:d,to:i,connectionId:n,virtualMcpId:c,tool:u,search:j,status:v,streaming:b,propertyFilters:x,hideSystem:L}=a,p=o===void 0?"overview":o;let g;s[1]!==n?(g=n===void 0?[]:n,s[1]=n,s[2]=g):g=s[2];const m=g;let k;s[3]!==c?(k=c===void 0?[]:c,s[3]=c,s[4]=k):k=s[4];const S=k,h=b===void 0?!0:b,T=x===void 0?"":x,I=L===void 0?!1:L;let f,M,y,$,C,E,R;if(s[5]!==m.length||s[6]!==d||s[7]!==I||s[8]!==r||s[9]!==e.slug||s[10]!==T||s[11]!==a||s[12]!==v||s[13]!==h||s[14]!==i||s[15]!==u||s[16]!==S.length){C=qs(T);let P;s[24]!==r||s[25]!==e.slug||s[26]!==a?(P=X=>{r({to:"/$org/settings/monitor",params:{org:e.slug},search:{...a,...X}})},s[24]=r,s[25]=e.slug,s[26]=a,s[27]=P):P=s[27],R=P;let N;s[28]!==R?(N=X=>{R({from:X.from,to:X.to})},s[28]=R,s[29]=N):N=s[29],$=N;let D,B;if(s[30]!==d||s[31]!==h||s[32]!==i){const X=we(d),te=we(i);B=X.date||new Date(Date.now()-18e5);const Y=te.date||new Date;y={startDate:B,endDate:Y},D=Y,h&&i==="now"&&(D=new Date(Y),D.setHours(D.getHours()+1)),s[30]=d,s[31]=h,s[32]=i,s[33]=y,s[34]=D,s[35]=B}else y=s[33],D=s[34],B=s[35];let ee;s[36]!==D||s[37]!==B?(ee={startDate:B,endDate:D},s[36]=D,s[37]=B,s[38]=ee):ee=s[38],M=ee,f=0,m.length>0&&f++,S.length>0&&f++,u&&f++,v!=="all"&&f++,I&&f++,E=C.filter(Ir),s[5]=m.length,s[6]=d,s[7]=I,s[8]=r,s[9]=e.slug,s[10]=T,s[11]=a,s[12]=v,s[13]=h,s[14]=i,s[15]=u,s[16]=S.length,s[17]=f,s[18]=M,s[19]=y,s[20]=$,s[21]=C,s[22]=E,s[23]=R}else f=s[17],M=s[18],y=s[19],$=s[20],C=s[21],E=s[22],R=s[23];const H=E;H.length>0&&(f=f+H.length);let A;s[39]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Me.Body,{className:"!pb-3",children:t.jsx(Me.Title,{children:"Monitoring"})}),s[39]=A):A=s[39];let W;s[40]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsxs(t.Fragment,{children:[A,t.jsx(Me.Content,{children:t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsx(wt,{title:"Failed to load monitoring data",description:"There was an error loading the monitoring data. Please try again."})})})]}),s[40]=W):W=s[40];let w;s[41]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(Me.Title,{children:"Monitoring"}),s[41]=w):w=s[41];let _;s[42]===Symbol.for("react.memo_cache_sentinel")?(_=[{id:"overview",label:"Overview"},{id:"audit",label:"Audit"},{id:"threads",label:"Threads"},{id:"automations",label:"Automations"}],s[42]=_):_=s[42];let F;s[43]!==R?(F=P=>R({tab:P}),s[43]=R,s[44]=F):F=s[44];let z;s[45]!==F||s[46]!==p?(z=t.jsx(Me.Body,{className:"!pb-3",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[w,t.jsx(Kt,{tabs:_,activeTab:p,onTabChange:F})]})}),s[45]=F,s[46]=p,s[47]=z):z=s[47];let O;s[48]!==p?(O=p==="threads"?t.jsx("div",{className:"flex-1 flex flex-col overflow-auto md:overflow-hidden",children:t.jsx(Nt.Skeleton,{})}):p==="audit"?t.jsx("div",{className:"flex-1 flex flex-col overflow-auto md:overflow-hidden",children:t.jsx(Nt.Skeleton,{})}):t.jsx("div",{className:"flex-1 flex flex-col overflow-auto",children:t.jsx(or,{})}),s[48]=p,s[49]=O):O=s[49];let V;s[50]!==z||s[51]!==O?(V=t.jsxs(t.Fragment,{children:[z,O]}),s[50]=z,s[51]=O,s[52]=V):V=s[52];let q;s[53]!==$?(q=P=>{xt("monitoring_time_range_changed",{from:P.from,to:P.to}),$(P)},s[53]=$,s[54]=q):q=s[54];let J;s[55]!==h||s[56]!==R?(J=()=>{xt("monitoring_live_toggled",{enabled:!h}),R({streaming:!h})},s[55]=h,s[56]=R,s[57]=J):J=s[57];let G;s[58]!==p||s[59]!==R?(G=P=>{P!==p&&xt("monitoring_tab_changed",{from_tab:p,to_tab:P}),R({tab:P})},s[58]=p,s[59]=R,s[60]=G):G=s[60];let Q;s[61]!==f||s[62]!==m||s[63]!==M||s[64]!==y||s[65]!==d||s[66]!==I||s[67]!==C||s[68]!==j||s[69]!==v||s[70]!==h||s[71]!==q||s[72]!==J||s[73]!==G||s[74]!==p||s[75]!==i||s[76]!==u||s[77]!==R||s[78]!==S?(Q=t.jsx(br,{tab:p,dateRange:M,displayDateRange:y,connectionIds:m,virtualMcpIds:S,tool:u,status:v,search:j,streaming:h,hideSystem:I,activeFiltersCount:f,from:d,to:i,propertyFilters:C,onUpdateFilters:R,onTimeRangeChange:q,onStreamingToggle:J,onTabChange:G}),s[61]=f,s[62]=m,s[63]=M,s[64]=y,s[65]=d,s[66]=I,s[67]=C,s[68]=j,s[69]=v,s[70]=h,s[71]=q,s[72]=J,s[73]=G,s[74]=p,s[75]=i,s[76]=u,s[77]=R,s[78]=S,s[79]=Q):Q=s[79];let U;return s[80]!==V||s[81]!==Q?(U=t.jsx(as,{capability:"monitoring:view",area:"monitoring",children:t.jsx(Me,{children:t.jsx(ls,{fallback:W,children:t.jsx(K.Suspense,{fallback:V,children:Q})})})}),s[80]=V,s[81]=Q,s[82]=U):U=s[82],U}function Ir(s){return s.key.trim()}export{Do as default};