decocms 4.76.71 → 4.76.72

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 (254) hide show
  1. package/dist/client/assets/{AlertCircle-Cvu85Sr0.js → AlertCircle-DEC9MSli.js} +1 -1
  2. package/dist/client/assets/{AreaChart-BSihuL6I.js → AreaChart-DTG-5b5r.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-fbYe80_F.js → ArrowUp-Bv0D2eRZ.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-Bl5xGmHO.js → ArrowUpRight-CYh_XgMl.js} +1 -1
  5. package/dist/client/assets/{Check-wimNrbhN.js → Check-e0NpaqDI.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-Bl4aW-nn.js → CheckCircle-Dx8PlP_2.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-C5CvsmcD.js → ChevronDown-_14-4vSC.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-Bno5_0xg.js → ChevronRight-DbSu3dHh.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-DrDSr-mi.js → ChevronUp-B37nF1fQ.js} +1 -1
  10. package/dist/client/assets/{Circle-g57xQlUQ.js → Circle-BRedzDGU.js} +1 -1
  11. package/dist/client/assets/{Copy01-1_zUjHG9.js → Copy01-By6PMNLM.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-SPVqsXfZ.js → DotsVertical-BnGH5h2q.js} +1 -1
  13. package/dist/client/assets/{Eye-BMAxGnGK.js → Eye-SeG_sslr.js} +1 -1
  14. package/dist/client/assets/{FilterLines-BnL8BlYf.js → FilterLines-DgL56yQR.js} +1 -1
  15. package/dist/client/assets/{Flag01-BFVNOegT.js → Flag01-D30atYPD.js} +1 -1
  16. package/dist/client/assets/{Globe01-DJ_zs5G_.js → Globe01-CGrBb2vX.js} +1 -1
  17. package/dist/client/assets/{Globe04-DkaJlCI4.js → Globe04-CfZZGfkA.js} +1 -1
  18. package/dist/client/assets/{HardDrive-yPFtg6_w.js → HardDrive-But4kF8X.js} +1 -1
  19. package/dist/client/assets/Image01-DmnY7rUZ.js +1 -0
  20. package/dist/client/assets/{Key01-BdmJ-1sf.js → Key01-CTvn2ZzI.js} +1 -1
  21. package/dist/client/assets/{LayoutLeft-DXtD65nH.js → LayoutLeft-BgPQbC33.js} +1 -1
  22. package/dist/client/assets/{LinkExternal01-26v779uD.js → LinkExternal01-P3P-mbSS.js} +1 -1
  23. package/dist/client/assets/{List-Degct3aY.js → List-BSS9biwy.js} +1 -1
  24. package/dist/client/assets/{Monitor01-B52VT9DG.js → Monitor01-CJoylRhB.js} +1 -1
  25. package/dist/client/assets/{Package-CKW2xi_w.js → Package-CZ8HIJPE.js} +1 -1
  26. package/dist/client/assets/{Palette-Bv_JYMYM.js → Palette-BqxIzEcM.js} +1 -1
  27. package/dist/client/assets/{Play-Dw4gmx5C.js → Play-BjvHD3Bw.js} +1 -1
  28. package/dist/client/assets/{Plus-CeRRdRrw.js → Plus-CODnQ6Q6.js} +1 -1
  29. package/dist/client/assets/{SearchLg-EpoU8TwV.js → SearchLg-BaxA63pq.js} +1 -1
  30. package/dist/client/assets/{SearchMd-DAd-Bkgu.js → SearchMd-D40sWBRu.js} +1 -1
  31. package/dist/client/assets/{Settings02-BYgyRjAD.js → Settings02-DQJFAffZ.js} +1 -1
  32. package/dist/client/assets/{Shield01-CMDd26KY.js → Shield01-CjRpjR_E.js} +1 -1
  33. package/dist/client/assets/{Star01-B4wdnyjY.js → Star01-_3pK6eyk.js} +1 -1
  34. package/dist/client/assets/{Stars01-aA8DbwLH.js → Stars01-DdwQA6ep.js} +1 -1
  35. package/dist/client/assets/{Stars02-CmYTwRcx.js → Stars02-D4MIgE30.js} +1 -1
  36. package/dist/client/assets/{Sun-MykPXdqN.js → Sun-BPUPfxdb.js} +1 -1
  37. package/dist/client/assets/{SwitchHorizontal01-DJnrgsIK.js → SwitchHorizontal01-KFFv0SYH.js} +1 -1
  38. package/dist/client/assets/Tool01-YMJ1AQ7b.js +1 -0
  39. package/dist/client/assets/{Tool02-Bt1NLhl1.js → Tool02-CQKaIo5U.js} +1 -1
  40. package/dist/client/assets/{Trash01-kZy-N3Xo.js → Trash01-YzxIFPEh.js} +1 -1
  41. package/dist/client/assets/{TrendUp01-CwpvhxrP.js → TrendUp01-e6qVgaWu.js} +1 -1
  42. package/dist/client/assets/{Upload01-Bpbyu6sv.js → Upload01-CjzKM9B1.js} +1 -1
  43. package/dist/client/assets/{User01-DQn1mAZF.js → User01-DKdTYNBE.js} +1 -1
  44. package/dist/client/assets/{UserPlus01-DjC11OT1.js → UserPlus01-C6rHXPgw.js} +1 -1
  45. package/dist/client/assets/{Users01-CY0-Vc-O.js → Users01-B1f-a-8q.js} +1 -1
  46. package/dist/client/assets/{Users03-CLvfcW6v.js → Users03-JOazr1ri.js} +1 -1
  47. package/dist/client/assets/{X-BZ_UKD_O.js → X-DOYte4FY.js} +1 -1
  48. package/dist/client/assets/{XCircle-BgTed_Co.js → XCircle-BujJTW-u.js} +1 -1
  49. package/dist/client/assets/{XClose-CcOoHUUk.js → XClose-D2J197LD.js} +1 -1
  50. package/dist/client/assets/{Zap-D3VZuva8.js → Zap-5x1m3kYf.js} +1 -1
  51. package/dist/client/assets/{ZapSquare-95HyzbKN.js → ZapSquare-CzB0XDWh.js} +1 -1
  52. package/dist/client/assets/ZoomOut-BpXvy-WE.js +1 -0
  53. package/dist/client/assets/{access-gate-DKOiEABa.js → access-gate-DXPMLlBG.js} +1 -1
  54. package/dist/client/assets/{add-section-modal-DS-jmwsV.js → add-section-modal-DXtJ-8Vn.js} +1 -1
  55. package/dist/client/assets/agent-icon-gJGKPGRw.js +1 -0
  56. package/dist/client/assets/agents-list-O3_wFc4B.js +1 -0
  57. package/dist/client/assets/ai-providers-G88BQka1.js +1 -0
  58. package/dist/client/assets/{alert-CpO8hjmN.js → alert-Dc_gaUf6.js} +1 -1
  59. package/dist/client/assets/{alert-dialog-nxq3-B6t.js → alert-dialog-aBhDZKiu.js} +1 -1
  60. package/dist/client/assets/app-editor-1x_hThf7.js +1 -0
  61. package/dist/client/assets/{auth-4uk65Jwa.js → auth-D0u-sXdR.js} +1 -1
  62. package/dist/client/assets/{auth-catchall-StGshhx2.js → auth-catchall-Ho9vBgJg.js} +1 -1
  63. package/dist/client/assets/{auth-entry-BBVTjEcb.js → auth-entry-CeMJZPYU.js} +1 -1
  64. package/dist/client/assets/{auth-split-layout-5rHPK2FX.js → auth-split-layout-CXbU0Pxf.js} +1 -1
  65. package/dist/client/assets/{authenticate-and-persist-oauth-DSvl_dtV.js → authenticate-and-persist-oauth-C1F-Ib2x.js} +1 -1
  66. package/dist/client/assets/{automation-list-row-BbQKDFDI.js → automation-list-row-RVZQ1tzS.js} +1 -1
  67. package/dist/client/assets/{automation-runs-J5VVC0pP.js → automation-runs-BAUPpPsN.js} +6 -6
  68. package/dist/client/assets/automations-DdvI7mpY.js +1 -0
  69. package/dist/client/assets/{autosend-C3_RSy-l.js → autosend-BA5B1p8b.js} +1 -1
  70. package/dist/client/assets/{avatar-DJ2MPOjW.js → avatar-DhzJ7Zvn.js} +1 -1
  71. package/dist/client/assets/{badge-tPEV-RxK.js → badge-CU7Ybb4s.js} +1 -1
  72. package/dist/client/assets/{block-document-BGBDt9He.js → block-document-CDGFLVI9.js} +1 -1
  73. package/dist/client/assets/{brand-context-XU5oj6VV.js → brand-context-CtoaVJwL.js} +1 -1
  74. package/dist/client/assets/{buckets-BpEMloCg.js → buckets-KILbd-nI.js} +1 -1
  75. package/dist/client/assets/bulk-category-panel-DtWIgxRZ.js +1 -0
  76. package/dist/client/assets/{calendar-Csl0UCmv.js → calendar-BKUPgHWb.js} +1 -1
  77. package/dist/client/assets/{capability-load-error-BVM1o44K.js → capability-load-error-1uM7cYTS.js} +1 -1
  78. package/dist/client/assets/{card-BiR2GL-H.js → card-Cx6wrdfw.js} +1 -1
  79. package/dist/client/assets/category-editor-C739ZvBd.js +1 -0
  80. package/dist/client/assets/{chat-context-CXmj1wzI.js → chat-context-B5ZQ1YfK.js} +1 -1
  81. package/dist/client/assets/{checkbox-BnAeGRmY.js → checkbox-B7TbfwYP.js} +1 -1
  82. package/dist/client/assets/{cli-auth-success-DpSY8KYL.js → cli-auth-success-CBSRlsxB.js} +1 -1
  83. package/dist/client/assets/collection-detail-B4w3rR_M.js +1 -0
  84. package/dist/client/assets/{collection-display-button-ClhtIWW8.js → collection-display-button-0-Hst3O8.js} +1 -1
  85. package/dist/client/assets/{collection-search-CIVfwIbs.js → collection-search-AKNFTM-D.js} +1 -1
  86. package/dist/client/assets/{collection-table-wrapper-BLGcEcmX.js → collection-table-wrapper-CEqEmtDG.js} +1 -1
  87. package/dist/client/assets/{collection-tabs-C-nwiHu-.js → collection-tabs--bEwcm53.js} +1 -1
  88. package/dist/client/assets/{command-CZ7egaGh.js → command-B7XTl9tP.js} +1 -1
  89. package/dist/client/assets/commerce-onboarding-m8aal-Ok.js +1 -0
  90. package/dist/client/assets/{companions-core-DVErIwai.js → companions-core-kxCoM-si.js} +1 -1
  91. package/dist/client/assets/{connect-desktop-dialog-B4yVc_7M.js → connect-desktop-dialog-DxF0k8Db.js} +1 -1
  92. package/dist/client/assets/{connection-card-DAmJM9w3.js → connection-card-d5eTvTiU.js} +1 -1
  93. package/dist/client/assets/connection-detail-WDGkMUzt.js +1 -0
  94. package/dist/client/assets/{connection-form-helpers-CmZoSIwh.js → connection-form-helpers-DbDFNXLq.js} +1 -1
  95. package/dist/client/assets/connections-D1N1XzHS.js +1 -0
  96. package/dist/client/assets/{decopilot-sse-pool-COulQsQu.js → decopilot-sse-pool-Dsaw7oxy.js} +1 -1
  97. package/dist/client/assets/{dialog-gLpw4bfG.js → dialog-BPAdfoaH.js} +1 -1
  98. package/dist/client/assets/{domain-settings-BdAEu5gj.js → domain-settings-L_qtUFf4.js} +1 -1
  99. package/dist/client/assets/{drawer-ZJqvF-A5.js → drawer-BiJB3f_K.js} +1 -1
  100. package/dist/client/assets/{dropdown-menu-Bbpx10wk.js → dropdown-menu-BgVBdzgn.js} +1 -1
  101. package/dist/client/assets/{empty-state-n5t0v7uI.js → empty-state-BD2XpatK.js} +1 -1
  102. package/dist/client/assets/{extract-connection-data-DQ2KFguj.js → extract-connection-data-Bb4ouwkr.js} +1 -1
  103. package/dist/client/assets/file-explorer-xlajTm22.js +2 -0
  104. package/dist/client/assets/{file-type-icon-BZvnDuN0.js → file-type-icon-BSIaVdXl.js} +1 -1
  105. package/dist/client/assets/{files-Y9_h0NXa.js → files-VX1EwHro.js} +1 -1
  106. package/dist/client/assets/{form-CEJ7NLQz.js → form-CH35sWOt.js} +1 -1
  107. package/dist/client/assets/{general-Dz0_FpL5.js → general-CuQ7F01F.js} +1 -1
  108. package/dist/client/assets/{github-repo-picker-BXgmr-ZU.js → github-repo-picker-C8uMgVuF.js} +1 -1
  109. package/dist/client/assets/{hooks-qsHMC7Ia.js → hooks-BYwJXzbJ.js} +1 -1
  110. package/dist/client/assets/{index-Bq8gS4_7.js → index--6OJQKLs.js} +1 -1
  111. package/dist/client/assets/{index-BGNS1OgZ.js → index-BDbyCous.js} +1 -1
  112. package/dist/client/assets/index-BWbNoA4-.js +173 -0
  113. package/dist/client/assets/{index-LRYSqCUf.js → index-C02FCcQV.js} +1 -1
  114. package/dist/client/assets/{index-DKZ2zjKb.js → index-CUBg3a-0.js} +1 -1
  115. package/dist/client/assets/{index-Dh4GqdsZ.js → index-CbmZLGvf.js} +1 -1
  116. package/dist/client/assets/{index-DejlCbgi.js → index-CkseNUY3.js} +1 -1
  117. package/dist/client/assets/{index-kW87eoYl.js → index-DE9bsiH9.js} +3 -3
  118. package/dist/client/assets/{index-B6gIYSAi.js → index-DR3_Zkfu.js} +2 -2
  119. package/dist/client/assets/index-DtS6J0cK.js +1 -0
  120. package/dist/client/assets/{index-CczqpYmb.js → index-DuqgHh6W.js} +1 -1
  121. package/dist/client/assets/{index-BDELOfSs.js → index-SFE6Rfyj.js} +16 -16
  122. package/dist/client/assets/{index-G899Mwwz.js → index-pk1nt4x0.js} +1 -1
  123. package/dist/client/assets/{index-redirect-QoYcGrYH.js → index-redirect-BL5XXZtW.js} +1 -1
  124. package/dist/client/assets/{index-DvtTPSSz.js → index-y0cucw2j.js} +2 -2
  125. package/dist/client/assets/{input-BUVWi6ji.js → input-DovBF_6H.js} +1 -1
  126. package/dist/client/assets/{integration-icon-RxSgmsqJ.js → integration-icon-NCY_y5rt.js} +1 -1
  127. package/dist/client/assets/{invite-member-dialog-Cg5P2m_Y.js → invite-member-dialog-aUdxLnOl.js} +1 -1
  128. package/dist/client/assets/{label-DoX8QwZg.js → label-BWlR6vAl.js} +1 -1
  129. package/dist/client/assets/{layout-C46sf1QP.js → layout-yrkPETvd.js} +1 -1
  130. package/dist/client/assets/{login-C5rPpeku.js → login-BHVoN3Dl.js} +1 -1
  131. package/dist/client/assets/{mcp-oauth-DayJEOBQ.js → mcp-oauth-Ok6tUSLD.js} +1 -1
  132. package/dist/client/assets/{members-BGQwgaxl.js → members-MMn0cVOt.js} +1 -1
  133. package/dist/client/assets/{monaco-editor-BQzusA3f.js → monaco-editor-BDgsF20v.js} +1 -1
  134. package/dist/client/assets/{monitoring-stats-row-cCie6bHV.js → monitoring-stats-row-CSFFT8zk.js} +1 -1
  135. package/dist/client/assets/{multi-select-C7UKUlA7.js → multi-select-BReKMl3F.js} +1 -1
  136. package/dist/client/assets/{oauth-callback-BfQDJq5F.js → oauth-callback-M90Y0nJQ.js} +1 -1
  137. package/dist/client/assets/{oauth-callback-ai-provider-CCEPN7ut.js → oauth-callback-ai-provider-CLeRWyoD.js} +1 -1
  138. package/dist/client/assets/{onboarding-fd5CG08c.js → onboarding-BHH0YB9S.js} +1 -1
  139. package/dist/client/assets/{org-install-Dl_4sb8U.js → org-install-Dx44ltxQ.js} +1 -1
  140. package/dist/client/assets/{org-layout-Cn6g2hBG.js → org-layout-fi4AQOsf.js} +1 -1
  141. package/dist/client/assets/{organization-choice-D7thp0nF.js → organization-choice-DGLh4y7b.js} +1 -1
  142. package/dist/client/assets/{orgs-BWXnjR-G.js → orgs-BI6oXNnp.js} +1 -1
  143. package/dist/client/assets/{page-seo-form-low418oG.js → page-seo-form-BL8Xxslp.js} +1 -1
  144. package/dist/client/assets/page-seo-sheet-CmyMK4Jf.js +1 -0
  145. package/dist/client/assets/{popover-1iWni6pj.js → popover-DbmxDQo8.js} +1 -1
  146. package/dist/client/assets/post-editor-CBMYgfKM.js +1 -0
  147. package/dist/client/assets/{primitives-BV45qvF6.js → primitives-DQp5QZlZ.js} +1 -1
  148. package/dist/client/assets/{profile-C09oJ7nj.js → profile-MZin5Sq8.js} +1 -1
  149. package/dist/client/assets/project-app-view-Cd-BIsC7.js +1 -0
  150. package/dist/client/assets/record-editor-CDKws8al.js +1 -0
  151. package/dist/client/assets/redirect-editor-iPcJvy11.js +1 -0
  152. package/dist/client/assets/registry-DoKzGyyE.js +2 -0
  153. package/dist/client/assets/{registry-layout-C4z50gL3.js → registry-layout-70W_rTpj.js} +1 -1
  154. package/dist/client/assets/{reports-BHGC1TMn.js → reports-BW3jotlV.js} +1 -1
  155. package/dist/client/assets/{require-capability-NMkQ7p2n.js → require-capability-q2k4vgrL.js} +1 -1
  156. package/dist/client/assets/{required-auth-layout-BdTGAOVV.js → required-auth-layout-EGqwZ6se.js} +1 -1
  157. package/dist/client/assets/{reset-password-WfkYhHBu.js → reset-password-C9cKsUOP.js} +1 -1
  158. package/dist/client/assets/roles-D7FYoVgP.js +1 -0
  159. package/dist/client/assets/{search-input-DvuYITM0.js → search-input-DNBSW_V4.js} +1 -1
  160. package/dist/client/assets/{secrets-C2UBhfFr.js → secrets-CLdgv5Bt.js} +1 -1
  161. package/dist/client/assets/{sections-editor-Blzdp0oy.js → sections-editor-kh_mdITm.js} +2 -2
  162. package/dist/client/assets/{select-gkpsAlUm.js → select-aBCLkiqI.js} +1 -1
  163. package/dist/client/assets/{select-model-DE9e2e1e.js → select-model-muHB6mNx.js} +2 -2
  164. package/dist/client/assets/{self-tool-result-2G6-rtik.js → self-tool-result-59x0oxLl.js} +1 -1
  165. package/dist/client/assets/seo-editor-DNKNpBlP.js +1 -0
  166. package/dist/client/assets/{settings-layout-CwsTbQU0.js → settings-layout-BeRwpMiS.js} +1 -1
  167. package/dist/client/assets/{settings-section-BhliH2-8.js → settings-section-5TQzN23l.js} +1 -1
  168. package/dist/client/assets/{shell-controls-HysOBF2a.js → shell-controls-obTHmMmn.js} +1 -1
  169. package/dist/client/assets/{shell-layout-F-ok_nx8.js → shell-layout-DUOq8-Mi.js} +1 -1
  170. package/dist/client/assets/{sidebar-DjP0hlIN.js → sidebar-KfZUHaZ3.js} +1 -1
  171. package/dist/client/assets/{skeleton-1fz4b835.js → skeleton-oM88nII8.js} +1 -1
  172. package/dist/client/assets/{sso-BA16hQgw.js → sso-Bkfs_4Hf.js} +1 -1
  173. package/dist/client/assets/{store-DvmwXBiB.js → store-CKHAhHTW.js} +1 -1
  174. package/dist/client/assets/store-registry-lt8F8AQy.js +2 -0
  175. package/dist/client/assets/{studio-tools-hO5SJ9L1.js → studio-tools-CLlC8XC0.js} +1 -1
  176. package/dist/client/assets/{switch-BSb1YfEU.js → switch-wc-JMrJW.js} +1 -1
  177. package/dist/client/assets/{table-BO-Pqce3.js → table-DnmayFDg.js} +1 -1
  178. package/dist/client/assets/{tabs-BaUdekDU.js → tabs-p5oGER-3.js} +1 -1
  179. package/dist/client/assets/{textarea-CJ9nnedq.js → textarea-CKVUE152.js} +1 -1
  180. package/dist/client/assets/{toggle-group-BLEtqopd.js → toggle-group-Bq_kOy1h.js} +1 -1
  181. package/dist/client/assets/{toolbar-mHxlKpgC.js → toolbar-BSiYnqoL.js} +1 -1
  182. package/dist/client/assets/{toolbar-icon-button-tX4cl55G.js → toolbar-icon-button-Lw9n0_WR.js} +1 -1
  183. package/dist/client/assets/{tooltip-MpF93QwW.js → tooltip-gbjR2jqB.js} +1 -1
  184. package/dist/client/assets/{use-ai-providers-DOWHTDqA.js → use-ai-providers-_qS2qx6u.js} +1 -1
  185. package/dist/client/assets/{use-automations-D9Z5baDr.js → use-automations-Cg19EnMj.js} +1 -1
  186. package/dist/client/assets/{use-autosave-DWH_u4bp.js → use-autosave-C0k8vm8D.js} +1 -1
  187. package/dist/client/assets/{use-capability-D9_H5dnX.js → use-capability-B-IX_soF.js} +1 -1
  188. package/dist/client/assets/{use-clock-tick-BL0-k7e9.js → use-clock-tick-BkGGOkbb.js} +1 -1
  189. package/dist/client/assets/{use-collections-BwkNh9s8.js → use-collections-DKaN9Van.js} +1 -1
  190. package/dist/client/assets/{use-connection-Dyi0y--H.js → use-connection-3hoAyxR0.js} +1 -1
  191. package/dist/client/assets/{use-copy-DD-AY19W.js → use-copy-Bj5N25Og.js} +1 -1
  192. package/dist/client/assets/{use-create-virtual-mcp-NhUMTYbb.js → use-create-virtual-mcp-BPw8BNDm.js} +1 -1
  193. package/dist/client/assets/{use-debounced-autosave-CWt391ns.js → use-debounced-autosave-BR6AvYxX.js} +1 -1
  194. package/dist/client/assets/{use-debounced-value-Bb7tMvOa.js → use-debounced-value-DFX3-h9r.js} +1 -1
  195. package/dist/client/assets/{use-deco-credits-DRClHKlt.js → use-deco-credits-DYBJ8MJK.js} +1 -1
  196. package/dist/client/assets/{use-decopilot-events-BXDhFIv7.js → use-decopilot-events-DoOrs7Jp.js} +1 -1
  197. package/dist/client/assets/{use-delete-connection-6W9qWG0y.js → use-delete-connection-BtsfohMK.js} +1 -1
  198. package/dist/client/assets/{use-deployment-admin-BYh8bdhB.js → use-deployment-admin-w2nqdf2W.js} +1 -1
  199. package/dist/client/assets/{use-file-configs-DjyD5Omy.js → use-file-configs-BU6poq2e.js} +1 -1
  200. package/dist/client/assets/{use-infinite-scroll-AWTzpLPw.js → use-infinite-scroll-D7ow0UWK.js} +1 -1
  201. package/dist/client/assets/{use-join-requests-CGldJY9N.js → use-join-requests-C_WcbOxJ.js} +1 -1
  202. package/dist/client/assets/{use-mcp-auth-status-CSloTF4V.js → use-mcp-auth-status-Cc5P5YPy.js} +1 -1
  203. package/dist/client/assets/{use-mcp-client-t1Lq9dtN.js → use-mcp-client-BtzK1kSd.js} +1 -1
  204. package/dist/client/assets/{use-mcp-tools-CCr3WLAZ.js → use-mcp-tools-CfMvkYlJ.js} +1 -1
  205. package/dist/client/assets/{use-members-B0yMwrOg.js → use-members-CbyW23vN.js} +1 -1
  206. package/dist/client/assets/{use-mobile-DKQP_Jss.js → use-mobile-CQnz-qO9.js} +1 -1
  207. package/dist/client/assets/{use-navigate-to-agent-Cwegpci4.js → use-navigate-to-agent-CB5dVqMu.js} +1 -1
  208. package/dist/client/assets/{use-org-auth-client-Cj6dUtY9.js → use-org-auth-client-C9_EVR6o.js} +1 -1
  209. package/dist/client/assets/{use-org-sso-z04b3p1a.js → use-org-sso-Cq6_NWho.js} +1 -1
  210. package/dist/client/assets/{use-organization-roles-CGng68qz.js → use-organization-roles-gQwIKDF6.js} +1 -1
  211. package/dist/client/assets/{use-organization-settings-Bs5bz6s7.js → use-organization-settings-De7_zsu2.js} +1 -1
  212. package/dist/client/assets/{use-registry-connections-izs-KLy2.js → use-registry-connections-EA7l6B_t.js} +1 -1
  213. package/dist/client/assets/{use-secrets-BRyksvJu.js → use-secrets-2R9rPimZ.js} +1 -1
  214. package/dist/client/assets/{use-status-sounds-CCDNWlCZ.js → use-status-sounds-D5DSSwdi.js} +1 -1
  215. package/dist/client/assets/{use-view-mode-CUhUbUhu.js → use-view-mode-Dfn6ZzsY.js} +1 -1
  216. package/dist/client/assets/{use-virtual-mcp-CFX-alhS.js → use-virtual-mcp-BtoQe4jO.js} +1 -1
  217. package/dist/client/assets/useInfiniteQuery-BYBonOR0.js +1 -0
  218. package/dist/client/assets/{useRouterState-seAdVQEm.js → useRouterState-oXjMqXoY.js} +1 -1
  219. package/dist/client/assets/useSuspenseInfiniteQuery-FBzK59jx.js +1 -0
  220. package/dist/client/assets/{users-DuOSsUUl.js → users-BNdsP3mj.js} +1 -1
  221. package/dist/client/assets/variant-calendar-BkGz0Z87.js +1 -0
  222. package/dist/client/assets/{view-mode-toggle-xB0T4AsL.js → view-mode-toggle-C22jBG_O.js} +1 -1
  223. package/dist/client/index.html +1 -1
  224. package/dist/server/cli.js +1 -1
  225. package/dist/server/server.js +1 -1
  226. package/package.json +1 -1
  227. package/dist/client/assets/Tool01-BcPlknT9.js +0 -1
  228. package/dist/client/assets/ZoomOut-Mbjnh50O.js +0 -1
  229. package/dist/client/assets/agent-icon-wm2eb0Nq.js +0 -1
  230. package/dist/client/assets/agents-list-Dz15AE-1.js +0 -1
  231. package/dist/client/assets/ai-providers-BKooAHnA.js +0 -1
  232. package/dist/client/assets/app-editor-Baj_Q_pt.js +0 -1
  233. package/dist/client/assets/automations-c5wcHSrJ.js +0 -1
  234. package/dist/client/assets/bulk-category-panel-kbn3uWhA.js +0 -1
  235. package/dist/client/assets/category-editor-CIv3YUMC.js +0 -1
  236. package/dist/client/assets/collection-detail-xpBis_7_.js +0 -1
  237. package/dist/client/assets/commerce-onboarding-BaXxbYVf.js +0 -1
  238. package/dist/client/assets/connection-detail-Dve5jUgE.js +0 -1
  239. package/dist/client/assets/connections-JiFN616P.js +0 -1
  240. package/dist/client/assets/file-explorer-DVcP3tZ1.js +0 -2
  241. package/dist/client/assets/index-BU2GOVdy.js +0 -1
  242. package/dist/client/assets/index-DyfzQj5m.js +0 -173
  243. package/dist/client/assets/page-seo-sheet-CSYYJs4Y.js +0 -1
  244. package/dist/client/assets/post-editor-mwSGk_ht.js +0 -1
  245. package/dist/client/assets/project-app-view-HOewAoV4.js +0 -1
  246. package/dist/client/assets/record-editor-CGSKkbo3.js +0 -1
  247. package/dist/client/assets/redirect-editor-C6ONqY6R.js +0 -1
  248. package/dist/client/assets/registry-XVj5joIQ.js +0 -2
  249. package/dist/client/assets/roles-BYjp-Ajk.js +0 -1
  250. package/dist/client/assets/seo-editor-Do4mbKfF.js +0 -1
  251. package/dist/client/assets/store-registry-DYJLdhuX.js +0 -2
  252. package/dist/client/assets/useInfiniteQuery-C3eTHgjV.js +0 -1
  253. package/dist/client/assets/useSuspenseInfiniteQuery-BcApL0b0.js +0 -1
  254. package/dist/client/assets/variant-calendar-YBO9nK_z.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as E,c as _,J as Kh,j as p,B as un,I as ra,H as Jh,M as Gh,bJ as Kc,bK as Xh,at as Yh,aM as dn,bL as Qh,l as ee,p as Zh,aR as ep,aO as Ut,aV as tp,aU as _t,ba as Nr,aS as kn,bM as Jc,aQ as Gc,C as Ct,n as np,d as rp,K as Qe,t as Xo,m as Mr,b as Vn,E as Xc,aL as Yc,bN as Bi,aT as sp,bO as Qt}from"./index-kW87eoYl.js";import{e as op}from"./select-gkpsAlUm.js";import{u as Qc}from"./useInfiniteQuery-C3eTHgjV.js";import{a as Zc,u as ip}from"./use-connection-Dyi0y--H.js";import{c as lp,u as Fi}from"./use-mcp-client-t1Lq9dtN.js";import{u as ap}from"./use-virtual-mcp-CFX-alhS.js";import{b as cp,i as up,a as dp,S as fp}from"./constants-D_FQAPnt.js";import{C as hp}from"./card-BiR2GL-H.js";import{o as eu,m as tu,p as Hi,q as Vi}from"./sidebar-DjP0hlIN.js";import{c as nu,d as ru,a as Ks,e as Je,b as su,T as Ge}from"./table-BO-Pqce3.js";import{E as Yo}from"./empty-state-n5t0v7uI.js";import{u as Wi}from"./use-infinite-scroll-AWTzpLPw.js";import{u as pp}from"./use-members-B0yMwrOg.js";import{u as ou,S as Rn}from"./use-clock-tick-BL0-k7e9.js";import{e as mp}from"./use-automations-D9Z5baDr.js";import{u as iu}from"./studio-tools-hO5SJ9L1.js";import{u as gp}from"./useSuspenseInfiniteQuery-BcApL0b0.js";import{A as lu}from"./avatar-DJ2MPOjW.js";import{t as Zr}from"./ChevronDown-C5CvsmcD.js";import{n as Qo}from"./ChevronUp-DrDSr-mi.js";import{t as xp,a as au,n as Ui}from"./Tool02-Bt1NLhl1.js";import{e as yp,ap as bp,aq as kp,U as Sp,u as vp,ar as wp,$ as Cp,af as Tp,j as Np,an as cu,as as Mp,at as Ep,A as uu,au as ut,av as Ap}from"./agent-icon-wm2eb0Nq.js";import{t as Js}from"./Stars01-aA8DbwLH.js";import{i as du,b as Or}from"./XCircle-BgTed_Co.js";import{i as qi}from"./Check-wimNrbhN.js";import{i as sa}from"./ChevronRight-Bno5_0xg.js";import{a as fu}from"./Copy01-1_zUjHG9.js";import{b as Ht,t as Ki,c as oa}from"./format-time-BnbuEtat.js";import{u as hu}from"./use-copy-DD-AY19W.js";import{T as fn,a as hn,b as pn}from"./tooltip-MpF93QwW.js";import{M as Ji,I as pu,F as jp}from"./file-type-icon-BZvnDuN0.js";import{R as Ip,c as Op,r as Rp,g as Dp}from"./hooks-qsHMC7Ia.js";import{S as Pp,h as Wn,m as Lp,c as Gi,d as _p,b as $p}from"./chat-context-CXmj1wzI.js";import{c as zp}from"./monaco-editor-BQzusA3f.js";import{g as mu,M as Bp}from"./index-CczqpYmb.js";import{f as Fp,n as Hp,o as Vp}from"./tab-id-BijBBRwE.js";import{i as gu}from"./AlertCircle-Cvu85Sr0.js";import{s as Wp}from"./Eye-BMAxGnGK.js";import{s as es,t as xu}from"./Star01-B4wdnyjY.js";import{s as Up}from"./XClose-CcOoHUUk.js";import{n as Zo}from"./ZapSquare-95HyzbKN.js";import{n as yu,i as qp}from"./Globe01-DJ_zs5G_.js";import{d as Kp,c as Jp,a as Rr}from"./Tool01-BcPlknT9.js";import{i as ia,a as Gp}from"./ZoomOut-Mbjnh50O.js";import{i as nr}from"./Monitor01-B52VT9DG.js";import{i as Xp}from"./SearchMd-DAd-Bkgu.js";import{i as Yp}from"./Upload01-Bpbyu6sv.js";import{u as Qp,a as Zp}from"./shell-layout-F-ok_nx8.js";import{n as bu}from"./LinkExternal01-26v779uD.js";import{I as qt}from"./integration-icon-RxSgmsqJ.js";import{i as em}from"./ArrowUpRight-Bl5xGmHO.js";import{a as Xi}from"./Users03-CLvfcW6v.js";import{a as dt}from"./Palette-Bv_JYMYM.js";import{c as ku}from"./use-navigate-to-agent-Cwegpci4.js";import{a as tm}from"./Stars02-CmYTwRcx.js";import{g as nm}from"./AreaChart-BSihuL6I.js";import{a as rm,D as sm,c as om,d as im,e as lm}from"./dialog-gLpw4bfG.js";import{a as am,F as cm,b as um,c as dm,d as fm,f as hm}from"./form-CEJ7NLQz.js";import{I as pm}from"./input-BUVWi6ji.js";import{i as mm}from"./UserPlus01-DjC11OT1.js";const gm={openrouter:n=>{const e=n?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Su(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(gm)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function vu(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function wu(n,e){if(!e)return n;const t=e.inputTokenDetails?.cacheReadTokens??e.cachedInputTokens??0,r=e.inputTokenDetails?.cacheWriteTokens??0;return{inputTokens:n.inputTokens+(e.inputTokens??0),outputTokens:n.outputTokens+(e.outputTokens??0),reasoningTokens:n.reasoningTokens+(e.reasoningTokens??0),totalTokens:n.totalTokens+(e.totalTokens??0),cost:n.cost+Su(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function qC(n){return n.reduce((e,t)=>wu(e,t.metadata?.usage),vu())}const xm={damping:.7,stiffness:.05,mass:1.25},ym=70,bm=1e3/60,km=350;let Gs=!1;globalThis.document?.addEventListener("mousedown",()=>{Gs=!0});globalThis.document?.addEventListener("mouseup",()=>{Gs=!1});globalThis.document?.addEventListener("click",()=>{Gs=!1});const Sm=(n={})=>{const[e,t]=E.useState(!1),[r,s]=E.useState(n.initial!==!1),[o,i]=E.useState(!1),l=E.useRef(null);l.current=n;const a=E.useCallback(()=>{if(!Gs)return!1;const b=window.getSelection();if(!b||!b.rangeCount)return!1;const k=b.getRangeAt(0);return k.commonAncestorContainer.contains(x.current)||x.current?.contains(k.commonAncestorContainer)},[]),c=E.useCallback(b=>{d.isAtBottom=b,s(b)},[]),u=E.useCallback(b=>{d.escapedFromLock=b,t(b)},[]),d=E.useMemo(()=>{let b;return{escapedFromLock:e,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(k){if(x.current){const{scrollBehavior:S}=getComputedStyle(x.current);S!=="auto"&&(x.current.style.scrollBehavior="auto"),x.current.scrollTop=k,d.ignoreScrollToTop=x.current.scrollTop,S!=="auto"&&(x.current.style.scrollBehavior=S)}},get targetScrollTop(){return!x.current||!y.current?0:x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!y.current)return 0;const{targetScrollTop:k}=this;if(!n.targetScrollTop)return k;if(b?.targetScrollTop===k)return b.calculatedScrollTop;const S=Math.max(Math.min(n.targetScrollTop(k,{scrollElement:x.current,contentElement:y.current}),k),0);return b={targetScrollTop:k,calculatedScrollTop:S},requestAnimationFrame(()=>{b=void 0}),S},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ym}}},[]),f=E.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),S=bo(l.current,b.animation),{ignoreEscapes:v=!1}=b;let w,C=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{w=Date.now()}):w=k+(b.duration??0);const T=async()=>{const N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;const{scrollTop:M}=d,j=performance.now(),R=(j-(d.lastTick??j))/bm;if(d.animation||(d.animation={behavior:S,promise:N,ignoreEscapes:v}),d.animation.behavior===S&&(d.lastTick=j),a()||k>Date.now())return T();if(M<Math.min(C,d.calculatedTargetScrollTop)){if(d.animation?.behavior===S){if(S==="instant")return d.scrollTop=d.calculatedTargetScrollTop,T();d.velocity=(S.damping*d.velocity+S.stiffness*d.scrollDifference)/S.mass,d.accumulated+=d.velocity*R,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return T()}return w>Date.now()?(C=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:bo(l.current,l.current.resize),ignoreEscapes:v,duration:Math.max(0,w-Date.now())||void 0}):d.isAtBottom)});return N.then(M=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),M))};return b.wait!==!0&&(d.animation=void 0),d.animation?.behavior===S?d.animation.promise:T()},[c,a,d]),h=E.useCallback(()=>{u(!0),c(!1)},[u,c]),m=E.useCallback(({target:b})=>{if(b!==x.current)return;const{scrollTop:k,ignoreScrollToTop:S}=d;let{lastScrollTop:v=k}=d;d.lastScrollTop=k,d.ignoreScrollToTop=void 0,S&&S>k&&(v=S),i(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===S)return;if(a()){u(!0),c(!1);return}const w=k>v,C=k<v;if(d.animation?.ignoreEscapes){d.scrollTop=v;return}C&&(u(!0),c(!1)),w&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,a,d]),g=E.useCallback(({target:b,deltaY:k})=>{let S=b;for(;!["scroll","auto"].includes(getComputedStyle(S).overflow);){if(!S.parentElement)return;S=S.parentElement}S===x.current&&k<0&&x.current.scrollHeight>x.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),x=la(b=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),y=la(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([S])=>{const{height:v}=S.contentRect,w=v-(k??v);if(d.resizeDifference=w,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),i(d.isNearBottom),w>=0){const C=bo(l.current,k?l.current.resize:l.current.initial);f({animation:C,wait:!0,preserveScrollPosition:!0,duration:C==="instant"?void 0:km})}else d.isNearBottom&&(u(!1),c(!0));k=v,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===w&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:y,scrollRef:x,scrollToBottom:f,stopScroll:h,isAtBottom:r||o,isNearBottom:o,escapedFromLock:e,state:d}};function la(n,e){const t=E.useCallback(r=>(t.current=r,n(r)),e);return t}const yo=new Map;function bo(...n){const e={...xm};let t=!1;for(const s of n){if(s==="instant"){t=!0;continue}typeof s=="object"&&(t=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const r=JSON.stringify(e);return yo.has(r)||yo.set(r,Object.freeze(e)),t?"instant":yo.get(r)}function vm(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Yi(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function Qi(n,e){if(!e)return n;const t=`${vm(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function wm(n,e){return Qi(n,e).replace(/[_-]/g," ").toLowerCase()}function Cm(n){const e={};for(const t of n?.arguments??[])e[t.name]=t.required?ra().min(1,"Required"):ra();return Jh(e)}function Tm(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Nm(n){const e=_.c(67),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:o}=n,i=E.useId();let l,a;if(e[0]!==t){const L=Cm(t);a=Gh,l=Kh(L),e[0]=t,e[1]=l,e[2]=a}else l=e[1],a=e[2];let c;e[3]!==o||e[4]!==t?(c=t?Tm(t,o):{},e[3]=o,e[4]=t,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==c?(u={resolver:l,defaultValues:c,mode:"onChange"},e[6]=l,e[7]=c,e[8]=u):u=e[8];const d=a(u);let f;e[9]!==t?.arguments?(f=t?.arguments??[],e[9]=t?.arguments,e[10]=f):f=e[10];const h=f;let m;e[11]!==d||e[12]!==s||e[13]!==r?(m=async L=>{await s(L),r(null),d.reset()},e[11]=d,e[12]=s,e[13]=r,e[14]=m):m=e[14];const g=m;let x;e[15]!==d||e[16]!==r?(x=L=>{L||(d.reset(),r(null))},e[15]=d,e[16]=r,e[17]=x):x=e[17];const y=x;if(!t)return null;let b;e[18]!==t._meta||e[19]!==t.name||e[20]!==t.title?(b=t.title||wm(t.name,Yi(t._meta)),e[18]=t._meta,e[19]=t.name,e[20]=t.title,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(rm,{children:p.jsx("span",{className:"capitalize",children:b})}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==t.description?(S=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[24]=t.description,e[25]=S):S=e[25];let v;e[26]!==S||e[27]!==k?(v=p.jsxs(sm,{children:[k,S]}),e[26]=S,e[27]=k,e[28]=v):v=e[28];let w;e[29]!==d||e[30]!==g?(w=L=>{L.stopPropagation(),d.handleSubmit(g)(L)},e[29]=d,e[30]=g,e[31]=w):w=e[31];let C;if(e[32]!==h||e[33]!==d.control||e[34]!==d.formState.isSubmitting){let L;e[36]!==d.control||e[37]!==d.formState.isSubmitting?(L=z=>p.jsx(cm,{control:d.control,name:z.name,render:F=>{const{field:U}=F;return p.jsxs(um,{children:[p.jsxs(dm,{className:"text-xs",children:[z.name,z.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(fm,{children:p.jsx(pm,{...U,value:U.value??"",required:z.required,placeholder:z.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),p.jsx(hm,{})]})}},z.name),e[36]=d.control,e[37]=d.formState.isSubmitting,e[38]=L):L=e[38],C=h.map(L),e[32]=h,e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=C}else C=e[35];let T;e[39]!==y?(T=()=>y(!1),e[39]=y,e[40]=T):T=e[40];let N;e[41]!==d.formState.isSubmitting||e[42]!==T?(N=p.jsx(un,{type:"button",variant:"ghost",onClick:T,disabled:d.formState.isSubmitting,children:"Cancel"}),e[41]=d.formState.isSubmitting,e[42]=T,e[43]=N):N=e[43];let M;e[44]!==d.formState.isSubmitting?(M=d.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(Pp,{size:"xs"}),"Loading..."]}):"Use prompt",e[44]=d.formState.isSubmitting,e[45]=M):M=e[45];let j;e[46]!==d.formState.isSubmitting||e[47]!==i||e[48]!==M?(j=p.jsx(un,{type:"submit",form:i,disabled:d.formState.isSubmitting,children:M}),e[46]=d.formState.isSubmitting,e[47]=i,e[48]=M,e[49]=j):j=e[49];let R;e[50]!==N||e[51]!==j?(R=p.jsxs(om,{children:[N,j]}),e[50]=N,e[51]=j,e[52]=R):R=e[52];let A;e[53]!==i||e[54]!==w||e[55]!==C||e[56]!==R?(A=p.jsxs("form",{id:i,className:"space-y-4 py-4",autoComplete:"off",onSubmit:w,children:[C,R]}),e[53]=i,e[54]=w,e[55]=C,e[56]=R,e[57]=A):A=e[57];let D;e[58]!==d||e[59]!==A?(D=p.jsx(am,{...d,children:A}),e[58]=d,e[59]=A,e[60]=D):D=e[60];let I;e[61]!==v||e[62]!==D?(I=p.jsxs(im,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[v,D]}),e[61]=v,e[62]=D,e[63]=I):I=e[63];let $;return e[64]!==y||e[65]!==I?($=p.jsx(lm,{open:!0,onOpenChange:y,children:I}),e[64]=y,e[65]=I,e[66]=$):$=e[66],$}function Cu(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function ot(n,e){return n==="output-error"||n==="output-denied"?"error":n==="approval-requested"?"approval":n==="input-streaming"||n==="input-available"||n==="output-available"&&e===!0?"loading":"idle"}function Un(n){if(n==null||typeof n!="object")return;const e=n;if(e.structuredContent&&typeof e.structuredContent=="object")return e.structuredContent;if(Array.isArray(e.content)){const t=e.content[0];if(t?.type==="text"&&typeof t.text=="string")try{return JSON.parse(t.text)}catch{return}return}return n}function Ne(n){this.content=n}Ne.prototype={constructor:Ne,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new Ne(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ne(t)},addToStart:function(n,e){return new Ne([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ne(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new Ne(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ne.from(n),n.size?new Ne(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ne.from(n),n.size?new Ne(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ne.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Ne.from=function(n){if(n instanceof Ne)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ne(e)};function Tu(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Tu(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Nu(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=Nu(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class O{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new O(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new O(r,s)}cutByIndex(e,t){return e==t?O.empty:e==0&&t==this.content.length?this:new O(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new O(s,o)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Tu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Nu(this,e,t,r)}findIndex(e){if(e==0)return Dr(0,e);if(e==this.size)return Dr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Dr(t+1,o):Dr(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return O.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new O(t||e,r)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const ko={index:0,offset:0};function Dr(n,e){return ko.index=n,ko.offset=e,ko}function ts(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ts(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ts(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let le=class ei{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ts(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ei.none;if(e instanceof ei)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};le.none=[];class ns extends Error{}class B{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Eu(this.content,e+this.openStart,t);return r&&new B(r,this.openStart,this.openEnd)}removeBetween(e,t){return new B(Mu(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return B.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new B(O.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new B(e,r,s)}}B.empty=new B(O.empty,0,0);function Mu(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Mu(o.content,e-s-1,t-s-1)))}function Eu(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Eu(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function Mm(n,e,t){if(t.openStart>n.depth)throw new ns("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ns("Inconsistent open depths");return Au(n,e,t,0)}function Au(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=Au(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return on(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Em(t,n);return on(o,Iu(n,i,l,e,r))}else return on(o,rs(n,e,r))}function ju(n,e){if(!e.type.compatibleContent(n.type))throw new ns("Cannot join "+e.type.name+" onto "+n.type.name)}function ti(n,e,t){let r=n.node(t);return ju(r,e.node(t)),r}function sn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function rr(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(sn(n.nodeAfter,r),o++));for(let l=o;l<i;l++)sn(s.child(l),r);e&&e.depth==t&&e.textOffset&&sn(e.nodeBefore,r)}function on(n,e){return n.type.checkContent(e),n.copy(e)}function Iu(n,e,t,r,s){let o=n.depth>s&&ti(n,e,s+1),i=r.depth>s&&ti(t,r,s+1),l=[];return rr(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(ju(o,i),sn(on(o,Iu(n,e,t,r,s+1)),l)):(o&&sn(on(o,rs(n,e,s+1)),l),rr(e,t,s,l),i&&sn(on(i,rs(t,r,s+1)),l)),rr(r,null,s,l),new O(l)}function rs(n,e,t){let r=[];if(rr(null,n,t,r),n.depth>t){let s=ti(n,e,t+1);sn(on(s,rs(n,e,t+1)),r)}return rr(e,null,t,r),new O(r)}function Em(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(O.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class pr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return le.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new ss(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new pr(t,r,o)}static resolveCached(e,t){let r=aa.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else aa.set(e,r=new Am);let s=r.elts[r.i]=pr.resolve(e,t);return r.i=(r.i+1)%jm,s}}class Am{constructor(){this.elts=[],this.i=0}}const jm=12,aa=new WeakMap;class ss{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Im=Object.create(null);class st{constructor(e,t,r,s=le.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ts(this.attrs,t||e.defaultAttrs||Im)&&le.sameSet(this.marks,r||le.none)}copy(e=null){return e==this.content?this:new st(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new st(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return B.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new B(c,s.depth-i,o.depth-i)}replace(e,t,r){return Mm(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return pr.resolveCached(this,e)}resolveNoCache(e){return pr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ou(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=O.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=le.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=O.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}st.prototype.text=void 0;class is extends st{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ou(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new is(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new is(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ou(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class mn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Om(e,t);if(r.next==null)return mn.empty;let s=Ru(r);r.next&&r.err("Unexpected trailing text");let o=zm($m(s));return Bm(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return O.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
1
+ import{r as E,c as _,J as Kh,j as p,B as un,I as ra,H as Jh,M as Gh,bJ as Kc,bK as Xh,at as Yh,aM as dn,bL as Qh,l as ee,p as Zh,aR as ep,aO as Ut,aV as tp,aU as _t,ba as Nr,aS as kn,bM as Jc,aQ as Gc,C as Ct,n as np,d as rp,K as Qe,t as Xo,m as Mr,b as Vn,E as Xc,aL as Yc,bN as Bi,aT as sp,bO as Qt}from"./index-DE9bsiH9.js";import{e as op}from"./select-aBCLkiqI.js";import{u as Qc}from"./useInfiniteQuery-BYBonOR0.js";import{a as Zc,u as ip}from"./use-connection-3hoAyxR0.js";import{c as lp,u as Fi}from"./use-mcp-client-BtzK1kSd.js";import{u as ap}from"./use-virtual-mcp-BtoQe4jO.js";import{b as cp,i as up,a as dp,S as fp}from"./constants-D_FQAPnt.js";import{C as hp}from"./card-Cx6wrdfw.js";import{o as eu,m as tu,p as Hi,q as Vi}from"./sidebar-KfZUHaZ3.js";import{c as nu,d as ru,a as Ks,e as Je,b as su,T as Ge}from"./table-DnmayFDg.js";import{E as Yo}from"./empty-state-BD2XpatK.js";import{u as Wi}from"./use-infinite-scroll-D7ow0UWK.js";import{u as pp}from"./use-members-CbyW23vN.js";import{u as ou,S as Rn}from"./use-clock-tick-BkGGOkbb.js";import{e as mp}from"./use-automations-Cg19EnMj.js";import{u as iu}from"./studio-tools-CLlC8XC0.js";import{u as gp}from"./useSuspenseInfiniteQuery-FBzK59jx.js";import{A as lu}from"./avatar-DhzJ7Zvn.js";import{t as Zr}from"./ChevronDown-_14-4vSC.js";import{n as Qo}from"./ChevronUp-B37nF1fQ.js";import{t as xp,a as au,n as Ui}from"./Tool02-CQKaIo5U.js";import{e as yp,ao as bp,ap as kp,U as Sp,u as vp,aq as wp,$ as Cp,ae as Tp,j as Np,am as cu,ar as Mp,as as Ep,A as uu,at as ut,au as Ap}from"./agent-icon-gJGKPGRw.js";import{t as Js}from"./Stars01-DdwQA6ep.js";import{i as du,b as Or}from"./XCircle-BujJTW-u.js";import{i as qi}from"./Check-e0NpaqDI.js";import{i as sa}from"./ChevronRight-DbSu3dHh.js";import{a as fu}from"./Copy01-By6PMNLM.js";import{b as Ht,t as Ki,c as oa}from"./format-time-BnbuEtat.js";import{u as hu}from"./use-copy-Bj5N25Og.js";import{T as fn,a as hn,b as pn}from"./tooltip-gbjR2jqB.js";import{M as Ji,I as pu,F as jp}from"./file-type-icon-BSIaVdXl.js";import{R as Ip,c as Op,r as Rp,g as Dp}from"./hooks-BYwJXzbJ.js";import{S as Pp,h as Wn,m as Lp,c as Gi,d as _p,b as $p}from"./chat-context-B5ZQ1YfK.js";import{c as zp}from"./monaco-editor-BDgsF20v.js";import{g as mu,M as Bp}from"./index-DuqgHh6W.js";import{f as Fp,n as Hp,o as Vp}from"./tab-id-BijBBRwE.js";import{i as gu}from"./AlertCircle-DEC9MSli.js";import{s as Wp}from"./Eye-SeG_sslr.js";import{s as es,t as xu}from"./Star01-_3pK6eyk.js";import{s as Up}from"./XClose-D2J197LD.js";import{n as Zo}from"./ZapSquare-CzB0XDWh.js";import{n as yu,i as qp}from"./Globe01-CGrBb2vX.js";import{c as Kp,b as Jp}from"./Tool01-YMJ1AQ7b.js";import{i as ia,a as Gp}from"./ZoomOut-BpXvy-WE.js";import{i as nr}from"./Monitor01-CJoylRhB.js";import{i as Xp}from"./SearchMd-D40sWBRu.js";import{i as Yp}from"./Upload01-CjzKM9B1.js";import{u as Qp,a as Zp}from"./shell-layout-DUOq8-Mi.js";import{a as Rr}from"./Image01-DmnY7rUZ.js";import{n as bu}from"./LinkExternal01-P3P-mbSS.js";import{I as qt}from"./integration-icon-NCY_y5rt.js";import{i as em}from"./ArrowUpRight-CYh_XgMl.js";import{a as Xi}from"./Users03-JOazr1ri.js";import{a as dt}from"./Palette-BqxIzEcM.js";import{c as ku}from"./use-navigate-to-agent-CB5dVqMu.js";import{a as tm}from"./Stars02-D4MIgE30.js";import{g as nm}from"./AreaChart-DTG-5b5r.js";import{a as rm,D as sm,c as om,d as im,e as lm}from"./dialog-BPAdfoaH.js";import{a as am,F as cm,b as um,c as dm,d as fm,f as hm}from"./form-CH35sWOt.js";import{I as pm}from"./input-DovBF_6H.js";import{i as mm}from"./UserPlus01-C6rHXPgw.js";const gm={openrouter:n=>{const e=n?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Su(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(gm)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function vu(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function wu(n,e){if(!e)return n;const t=e.inputTokenDetails?.cacheReadTokens??e.cachedInputTokens??0,r=e.inputTokenDetails?.cacheWriteTokens??0;return{inputTokens:n.inputTokens+(e.inputTokens??0),outputTokens:n.outputTokens+(e.outputTokens??0),reasoningTokens:n.reasoningTokens+(e.reasoningTokens??0),totalTokens:n.totalTokens+(e.totalTokens??0),cost:n.cost+Su(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function KC(n){return n.reduce((e,t)=>wu(e,t.metadata?.usage),vu())}const xm={damping:.7,stiffness:.05,mass:1.25},ym=70,bm=1e3/60,km=350;let Gs=!1;globalThis.document?.addEventListener("mousedown",()=>{Gs=!0});globalThis.document?.addEventListener("mouseup",()=>{Gs=!1});globalThis.document?.addEventListener("click",()=>{Gs=!1});const Sm=(n={})=>{const[e,t]=E.useState(!1),[r,s]=E.useState(n.initial!==!1),[o,i]=E.useState(!1),l=E.useRef(null);l.current=n;const a=E.useCallback(()=>{if(!Gs)return!1;const b=window.getSelection();if(!b||!b.rangeCount)return!1;const k=b.getRangeAt(0);return k.commonAncestorContainer.contains(x.current)||x.current?.contains(k.commonAncestorContainer)},[]),c=E.useCallback(b=>{d.isAtBottom=b,s(b)},[]),u=E.useCallback(b=>{d.escapedFromLock=b,t(b)},[]),d=E.useMemo(()=>{let b;return{escapedFromLock:e,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(k){if(x.current){const{scrollBehavior:S}=getComputedStyle(x.current);S!=="auto"&&(x.current.style.scrollBehavior="auto"),x.current.scrollTop=k,d.ignoreScrollToTop=x.current.scrollTop,S!=="auto"&&(x.current.style.scrollBehavior=S)}},get targetScrollTop(){return!x.current||!y.current?0:x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!y.current)return 0;const{targetScrollTop:k}=this;if(!n.targetScrollTop)return k;if(b?.targetScrollTop===k)return b.calculatedScrollTop;const S=Math.max(Math.min(n.targetScrollTop(k,{scrollElement:x.current,contentElement:y.current}),k),0);return b={targetScrollTop:k,calculatedScrollTop:S},requestAnimationFrame(()=>{b=void 0}),S},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=ym}}},[]),f=E.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),S=bo(l.current,b.animation),{ignoreEscapes:v=!1}=b;let w,C=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{w=Date.now()}):w=k+(b.duration??0);const T=async()=>{const N=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;const{scrollTop:M}=d,j=performance.now(),R=(j-(d.lastTick??j))/bm;if(d.animation||(d.animation={behavior:S,promise:N,ignoreEscapes:v}),d.animation.behavior===S&&(d.lastTick=j),a()||k>Date.now())return T();if(M<Math.min(C,d.calculatedTargetScrollTop)){if(d.animation?.behavior===S){if(S==="instant")return d.scrollTop=d.calculatedTargetScrollTop,T();d.velocity=(S.damping*d.velocity+S.stiffness*d.scrollDifference)/S.mass,d.accumulated+=d.velocity*R,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return T()}return w>Date.now()?(C=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:bo(l.current,l.current.resize),ignoreEscapes:v,duration:Math.max(0,w-Date.now())||void 0}):d.isAtBottom)});return N.then(M=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),M))};return b.wait!==!0&&(d.animation=void 0),d.animation?.behavior===S?d.animation.promise:T()},[c,a,d]),h=E.useCallback(()=>{u(!0),c(!1)},[u,c]),m=E.useCallback(({target:b})=>{if(b!==x.current)return;const{scrollTop:k,ignoreScrollToTop:S}=d;let{lastScrollTop:v=k}=d;d.lastScrollTop=k,d.ignoreScrollToTop=void 0,S&&S>k&&(v=S),i(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===S)return;if(a()){u(!0),c(!1);return}const w=k>v,C=k<v;if(d.animation?.ignoreEscapes){d.scrollTop=v;return}C&&(u(!0),c(!1)),w&&u(!1),!d.escapedFromLock&&d.isNearBottom&&c(!0)},1)},[u,c,a,d]),g=E.useCallback(({target:b,deltaY:k})=>{let S=b;for(;!["scroll","auto"].includes(getComputedStyle(S).overflow);){if(!S.parentElement)return;S=S.parentElement}S===x.current&&k<0&&x.current.scrollHeight>x.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),c(!1))},[u,c,d]),x=la(b=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),y=la(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([S])=>{const{height:v}=S.contentRect,w=v-(k??v);if(d.resizeDifference=w,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),i(d.isNearBottom),w>=0){const C=bo(l.current,k?l.current.resize:l.current.initial);f({animation:C,wait:!0,preserveScrollPosition:!0,duration:C==="instant"?void 0:km})}else d.isNearBottom&&(u(!1),c(!0));k=v,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===w&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:y,scrollRef:x,scrollToBottom:f,stopScroll:h,isAtBottom:r||o,isNearBottom:o,escapedFromLock:e,state:d}};function la(n,e){const t=E.useCallback(r=>(t.current=r,n(r)),e);return t}const yo=new Map;function bo(...n){const e={...xm};let t=!1;for(const s of n){if(s==="instant"){t=!0;continue}typeof s=="object"&&(t=!1,e.damping=s.damping??e.damping,e.stiffness=s.stiffness??e.stiffness,e.mass=s.mass??e.mass)}const r=JSON.stringify(e);return yo.has(r)||yo.set(r,Object.freeze(e)),t?"instant":yo.get(r)}function vm(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Yi(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function Qi(n,e){if(!e)return n;const t=`${vm(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function wm(n,e){return Qi(n,e).replace(/[_-]/g," ").toLowerCase()}function Cm(n){const e={};for(const t of n?.arguments??[])e[t.name]=t.required?ra().min(1,"Required"):ra();return Jh(e)}function Tm(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Nm(n){const e=_.c(67),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:o}=n,i=E.useId();let l,a;if(e[0]!==t){const L=Cm(t);a=Gh,l=Kh(L),e[0]=t,e[1]=l,e[2]=a}else l=e[1],a=e[2];let c;e[3]!==o||e[4]!==t?(c=t?Tm(t,o):{},e[3]=o,e[4]=t,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==c?(u={resolver:l,defaultValues:c,mode:"onChange"},e[6]=l,e[7]=c,e[8]=u):u=e[8];const d=a(u);let f;e[9]!==t?.arguments?(f=t?.arguments??[],e[9]=t?.arguments,e[10]=f):f=e[10];const h=f;let m;e[11]!==d||e[12]!==s||e[13]!==r?(m=async L=>{await s(L),r(null),d.reset()},e[11]=d,e[12]=s,e[13]=r,e[14]=m):m=e[14];const g=m;let x;e[15]!==d||e[16]!==r?(x=L=>{L||(d.reset(),r(null))},e[15]=d,e[16]=r,e[17]=x):x=e[17];const y=x;if(!t)return null;let b;e[18]!==t._meta||e[19]!==t.name||e[20]!==t.title?(b=t.title||wm(t.name,Yi(t._meta)),e[18]=t._meta,e[19]=t.name,e[20]=t.title,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(rm,{children:p.jsx("span",{className:"capitalize",children:b})}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==t.description?(S=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[24]=t.description,e[25]=S):S=e[25];let v;e[26]!==S||e[27]!==k?(v=p.jsxs(sm,{children:[k,S]}),e[26]=S,e[27]=k,e[28]=v):v=e[28];let w;e[29]!==d||e[30]!==g?(w=L=>{L.stopPropagation(),d.handleSubmit(g)(L)},e[29]=d,e[30]=g,e[31]=w):w=e[31];let C;if(e[32]!==h||e[33]!==d.control||e[34]!==d.formState.isSubmitting){let L;e[36]!==d.control||e[37]!==d.formState.isSubmitting?(L=z=>p.jsx(cm,{control:d.control,name:z.name,render:F=>{const{field:U}=F;return p.jsxs(um,{children:[p.jsxs(dm,{className:"text-xs",children:[z.name,z.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(fm,{children:p.jsx(pm,{...U,value:U.value??"",required:z.required,placeholder:z.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),p.jsx(hm,{})]})}},z.name),e[36]=d.control,e[37]=d.formState.isSubmitting,e[38]=L):L=e[38],C=h.map(L),e[32]=h,e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=C}else C=e[35];let T;e[39]!==y?(T=()=>y(!1),e[39]=y,e[40]=T):T=e[40];let N;e[41]!==d.formState.isSubmitting||e[42]!==T?(N=p.jsx(un,{type:"button",variant:"ghost",onClick:T,disabled:d.formState.isSubmitting,children:"Cancel"}),e[41]=d.formState.isSubmitting,e[42]=T,e[43]=N):N=e[43];let M;e[44]!==d.formState.isSubmitting?(M=d.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(Pp,{size:"xs"}),"Loading..."]}):"Use prompt",e[44]=d.formState.isSubmitting,e[45]=M):M=e[45];let j;e[46]!==d.formState.isSubmitting||e[47]!==i||e[48]!==M?(j=p.jsx(un,{type:"submit",form:i,disabled:d.formState.isSubmitting,children:M}),e[46]=d.formState.isSubmitting,e[47]=i,e[48]=M,e[49]=j):j=e[49];let R;e[50]!==N||e[51]!==j?(R=p.jsxs(om,{children:[N,j]}),e[50]=N,e[51]=j,e[52]=R):R=e[52];let A;e[53]!==i||e[54]!==w||e[55]!==C||e[56]!==R?(A=p.jsxs("form",{id:i,className:"space-y-4 py-4",autoComplete:"off",onSubmit:w,children:[C,R]}),e[53]=i,e[54]=w,e[55]=C,e[56]=R,e[57]=A):A=e[57];let D;e[58]!==d||e[59]!==A?(D=p.jsx(am,{...d,children:A}),e[58]=d,e[59]=A,e[60]=D):D=e[60];let I;e[61]!==v||e[62]!==D?(I=p.jsxs(im,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[v,D]}),e[61]=v,e[62]=D,e[63]=I):I=e[63];let $;return e[64]!==y||e[65]!==I?($=p.jsx(lm,{open:!0,onOpenChange:y,children:I}),e[64]=y,e[65]=I,e[66]=$):$=e[66],$}function Cu(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function ot(n,e){return n==="output-error"||n==="output-denied"?"error":n==="approval-requested"?"approval":n==="input-streaming"||n==="input-available"||n==="output-available"&&e===!0?"loading":"idle"}function Un(n){if(n==null||typeof n!="object")return;const e=n;if(e.structuredContent&&typeof e.structuredContent=="object")return e.structuredContent;if(Array.isArray(e.content)){const t=e.content[0];if(t?.type==="text"&&typeof t.text=="string")try{return JSON.parse(t.text)}catch{return}return}return n}function Ne(n){this.content=n}Ne.prototype={constructor:Ne,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),o=r.content.slice();return s==-1?o.push(t||n,e):(o[s+1]=e,t&&(o[s]=t)),new Ne(o)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ne(t)},addToStart:function(n,e){return new Ne([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ne(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),o=r.find(n);return s.splice(o==-1?s.length:o,0,e,t),new Ne(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ne.from(n),n.size?new Ne(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ne.from(n),n.size?new Ne(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ne.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Ne.from=function(n){if(n instanceof Ne)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ne(e)};function Tu(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),o=e.child(r);if(s==o){t+=s.nodeSize;continue}if(!s.sameMarkup(o))return t;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)t++;return t}if(s.content.size||o.content.size){let i=Tu(s.content,o.content,t+1);if(i!=null)return i}t+=s.nodeSize}}function Nu(n,e,t,r){for(let s=n.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:t,b:r};let i=n.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=Nu(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class O{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,o){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let o="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new O(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let o=0,i=0;i<t;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),s+=l.nodeSize),i=a}return new O(r,s)}cutByIndex(e,t){return e==t?O.empty:e==0&&t==this.content.length?this:new O(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new O(s,o)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Tu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Nu(this,e,t,r)}findIndex(e){if(e==0)return Dr(0,e);if(e==this.size)return Dr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),o=r+s.nodeSize;if(o>=e)return o==e?Dr(t+1,o):Dr(t,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return O.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let t,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(t||(t=e.slice(0,s)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new O(t||e,r)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const ko={index:0,offset:0};function Dr(n,e){return ko.index=n,ko.offset=e,ko}function ts(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ts(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ts(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let le=class ei{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ts(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ei.none;if(e instanceof ei)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};le.none=[];class ns extends Error{}class B{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Eu(this.content,e+this.openStart,t);return r&&new B(r,this.openStart,this.openEnd)}removeBetween(e,t){return new B(Mu(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return B.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new B(O.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)s++;return new B(e,r,s)}}B.empty=new B(O.empty,0,0);function Mu(n,e,t){let{index:r,offset:s}=n.findIndex(e),o=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(s==e||o.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Mu(o.content,e-s-1,t-s-1)))}function Eu(n,e,t,r){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Eu(i.content,e-o-1,t,i);return l&&n.replaceChild(s,i.copy(l))}function Mm(n,e,t){if(t.openStart>n.depth)throw new ns("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ns("Inconsistent open depths");return Au(n,e,t,0)}function Au(n,e,t,r){let s=n.index(r),o=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let i=Au(n,e,t,r+1);return o.copy(o.content.replaceChild(s,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return on(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Em(t,n);return on(o,Iu(n,i,l,e,r))}else return on(o,rs(n,e,r))}function ju(n,e){if(!e.type.compatibleContent(n.type))throw new ns("Cannot join "+e.type.name+" onto "+n.type.name)}function ti(n,e,t){let r=n.node(t);return ju(r,e.node(t)),r}function sn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function rr(n,e,t,r){let s=(e||n).node(t),o=0,i=e?e.index(t):s.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(sn(n.nodeAfter,r),o++));for(let l=o;l<i;l++)sn(s.child(l),r);e&&e.depth==t&&e.textOffset&&sn(e.nodeBefore,r)}function on(n,e){return n.type.checkContent(e),n.copy(e)}function Iu(n,e,t,r,s){let o=n.depth>s&&ti(n,e,s+1),i=r.depth>s&&ti(t,r,s+1),l=[];return rr(null,n,s,l),o&&i&&e.index(s)==t.index(s)?(ju(o,i),sn(on(o,Iu(n,e,t,r,s+1)),l)):(o&&sn(on(o,rs(n,e,s+1)),l),rr(e,t,s,l),i&&sn(on(i,rs(t,r,s+1)),l)),rr(r,null,s,l),new O(l)}function rs(n,e,t){let r=[];if(rr(null,n,t,r),n.depth>t){let s=ti(n,e,t+1);sn(on(s,rs(n,e,t+1)),r)}return rr(e,null,t,r),new O(r)}function Em(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)s=e.node(o).copy(O.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class pr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return le.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new ss(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,o=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new pr(t,r,o)}static resolveCached(e,t){let r=aa.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==t)return i}else aa.set(e,r=new Am);let s=r.elts[r.i]=pr.resolve(e,t);return r.i=(r.i+1)%jm,s}}class Am{constructor(){this.elts=[],this.i=0}}const jm=12,aa=new WeakMap;class ss{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Im=Object.create(null);class st{constructor(e,t,r,s=le.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ts(this.attrs,t||e.defaultAttrs||Im)&&le.sameSet(this.marks,r||le.none)}copy(e=null){return e==this.content?this:new st(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new st(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return B.empty;let s=this.resolve(e),o=this.resolve(t),i=r?0:s.sharedDepth(t),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new B(c,s.depth-i,o.depth-i)}replace(e,t,r){return Mm(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return pr.resolveCached(this,e)}resolveNoCache(e){return pr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ou(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=O.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=le.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!le.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=O.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}st.prototype.text=void 0;class is extends st{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ou(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new is(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new is(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ou(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class mn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Om(e,t);if(r.next==null)return mn.empty;let s=Ru(r);r.next&&r.err("Unexpected trailing text");let o=zm($m(s));return Bm(o,r),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let o=t;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return O.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));if(f)return f}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
2
2
  `)}}mn.empty=new mn(!0);class Om{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ru(n){let e=[];do e.push(Rm(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Rm(n){let e=[];do e.push(Dm(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Dm(n){let e=_m(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Pm(n,e);else break;return e}function ca(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Pm(n,e){let t=ca(n),r=t;return n.eat(",")&&(n.next!="}"?r=ca(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Lm(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let o in t){let i=t[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function _m(n){if(n.eat("(")){let e=Ru(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Lm(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function $m(n){let e=[[]];return s(o(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),s(o(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Du(n,e){return e-n}function ua(n,e){let t=[];return r(e),t.sort(Du);function r(s){let o=n[s];if(o.length==1&&!o[0].term)return r(o[0].to);t.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&t.indexOf(a)==-1&&r(a)}}}function zm(n){let e=Object.create(null);return t(ua(n,0));function t(r){let s=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);ua(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new mn(r.indexOf(n.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(Du);o.next.push({type:s[i][0],next:e[l.join(",")]||t(l)})}return o}}function Bm(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Pu(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Lu(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let o=n[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function _u(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let o=n[s];o.validate&&o.validate(e[s])}}function $u(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Hm(n,r,e[r]);return t}let da=class zu{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=$u(e,r.attrs),this.defaultAttrs=Pu(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==mn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Lu(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new st(this,this.computeAttrs(e),O.from(t),le.setFrom(r))}createChecked(e=null,t,r){return t=O.from(t),this.checkContent(t),new st(this,this.computeAttrs(e),t,le.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=O.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let s=this.contentMatch.matchFragment(t),o=s&&s.fillBefore(O.empty,!0);return o?new st(this,e,t.append(o),le.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){_u(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:le.none:e}static compile(e,t){let r=Object.create(null);e.forEach((o,i)=>r[o]=new zu(o,t,i));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Fm(n,e,t){let r=t.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}class Hm{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Fm(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Xs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=$u(e,s.attrs),this.excluded=null;let o=Pu(this.attrs);this.instance=o?new le(this,o):null}create(e=null){return!e&&this.instance?this.instance:new le(this,Lu(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Xs(o,s++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){_u(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Bu{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Ne.from(e.nodes),t.marks=Ne.from(e.marks||{}),this.nodes=da.compile(this.spec.nodes,this),this.marks=Xs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=mn.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?fa(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:fa(this,i.split(" "))}this.nodeFromJSON=s=>st.fromJSON(this,s),this.markFromJSON=s=>le.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof da){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new is(r,r.defaultAttrs,e,le.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function fa(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],o=n.marks[s],i=o;if(o)t.push(o);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Vm(n){return n.tag!=null}function Wm(n){return n.style!=null}class $t{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(Vm(s))this.tags.push(s);else if(Wm(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new pa(this,t,!1);return r.addAll(e,le.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new pa(this,t,!0);return r.addAll(e,le.none,t.from,t.to),B.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(Km(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,t,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<o)break}t.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ma(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=ma(i)),i.node||i.ignore||i.mark||(i.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $t(e,$t.schemaRules(e)))}}const Fu={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Um={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Hu={ol:!0,ul:!0},mr=1,ni=2,sr=4;function ha(n,e,t){return e!=null?(e?mr:0)|(e==="full"?ni:0):n&&n.whitespace=="pre"?mr|ni:t&~sr}class Pr{constructor(e,t,r,s,o,i){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=le.none,this.match=o||(i&sr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(O.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&mr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let t=O.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Fu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pa{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,o,i=ha(null,t.preserveWhitespace,0)|(r?sr:0);s?o=new Pr(s.type,s.attrs,le.none,!0,t.topMatch||s.type.contentMatch,i):r?o=new Pr(null,null,le.none,!0,null,i):o=new Pr(e.schema.topNodeType,null,le.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,o=s.options&ni?"full":this.localPreserveWS||(s.options&mr)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)if(o==="full")r=r.replace(/\r\n?/g,`
3
3
  `);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(i.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(i.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Hu.hasOwnProperty(i)&&this.parser.normalizeLists&&qm(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Um.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Fu.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=le.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):ga(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let o=this.findPlace(e.create(t),r,!1);return o&&(o=this.enterInner(e,t,r,!0,s)),o}enterInner(e,t,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=ha(e,o,i.options);i.options&sr&&i.content.length==0&&(l|=sr);let a=le.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):ga(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Pr(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=mr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function qm(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Hu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Km(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ma(n){let e={};for(let t in n)e[t]=n[t];return e}function ga(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class Sn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=So(t).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Jr(So(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Jr(So(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Jr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Sn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=xa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return xa(e.marks)}}function xa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function So(n){return n.document||window.document}const ya=new WeakMap;function Jm(n){let e=ya.get(n);return e===void 0&&ya.set(n,e=Gm(n)),e}function Gm(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Jr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Jm(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(t=s.slice(0,i),s=s.slice(i+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:m}=Jr(n,f,t,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const Vu=65535,Wu=Math.pow(2,16);function Xm(n,e){return n+e*Wu}function ba(n){return n&Vu}function Ym(n){return(n-(n&Vu))/Wu}const Uu=1,qu=2,Gr=4,Ku=8;class ri{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Ku)>0}get deletedBefore(){return(this.delInfo&(Uu|Gr))>0}get deletedAfter(){return(this.delInfo&(qu|Gr))>0}get deletedAcross(){return(this.delInfo&Gr)>0}}class We{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&We.empty)return We.empty}recover(e){let t=0,r=ba(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Ym(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(r)return h;let m=e==(t<0?a:d)?null:Xm(l/3,e-a),g=e==a?qu:e==d?Uu:Gr;return(t<0?e!=a:e!=d)&&(g|=Ku),new ri(h,g,m)}s+=u-c}return r?e+s:new ri(e+s,0,null)}touches(e,t){let r=0,s=ba(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new We(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?We.empty:new We(e<0?[0,-e,0]:[0,0,e])}}We.empty=new We([]);class gr{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new gr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new gr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new ri(e,s,null)}}const vo=Object.create(null);class Re{getMap(){return We.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=vo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in vo)throw new RangeError("Duplicate use of step JSON ID "+e);return vo[e]=t,t.prototype.jsonID=e,t}}class be{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new be(e,null)}static fail(e){return new be(null,e)}static fromReplace(e,t,r,s){try{return be.ok(e.replace(t,r,s))}catch(o){if(o instanceof ns)return be.fail(o.message);throw o}}}function Zi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let o=n.child(s);o.content.size&&(o=o.copy(Zi(o.content,e,o))),o.isInline&&(o=e(o,t,s)),r.push(o)}return O.fromArray(r)}class Dt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new B(Zi(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),t.openStart,t.openEnd);return be.fromReplace(e,this.from,this.to,o)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Dt(t.pos,r.pos,this.mark)}merge(e){return e instanceof Dt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Dt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("addMark",Dt);class rt extends Re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new B(Zi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return be.fromReplace(e,this.from,this.to,r)}invert(){return new Dt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new rt(t.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(t.from,t.to,e.markFromJSON(t.mark))}}Re.jsonID("removeMark",rt);class Pt extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return be.fromReplace(e,this.pos,this.pos+1,new B(O.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new Pt(this.pos,t.marks[s]);return new Pt(this.pos,this.mark)}}return new gn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Pt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Pt(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("addNodeMark",Pt);class gn extends Re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return be.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return be.fromReplace(e,this.pos,this.pos+1,new B(O.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Pt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new gn(t.pos,e.markFromJSON(t.mark))}}Re.jsonID("removeNodeMark",gn);class ye extends Re{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&si(e,this.from,this.to)?be.fail("Structure replace would overwrite content"):be.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new We([this.from,this.to-this.from,this.slice.size])}invert(e){return new ye(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&ye.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new ye(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ye)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?B.empty:new B(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ye(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?B.empty:new B(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ye(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ye(t.from,t.to,B.fromJSON(e,t.slice),!!t.structure)}}ye.MAP_BIAS=1;Re.jsonID("replace",ye);class we extends Re{constructor(e,t,r,s,o,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(si(e,this.from,this.gapFrom)||si(e,this.gapTo,this.to)))return be.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return be.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?be.fromReplace(e,this.from,this.to,r):be.fail("Content does not fit in gap")}getMap(){return new We([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new we(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||o>r.pos?null:new we(t.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new we(t.from,t.to,t.gapFrom,t.gapTo,B.fromJSON(e,t.slice),t.insert,!!t.structure)}}Re.jsonID("replaceAround",we);function si(n,e,t){let r=n.resolve(e),s=t-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function Qm(n,e,t,r){let s=[],o=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=h:s.push(i=new rt(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new Dt(f,h,r))}}),s.forEach(a=>n.step(a)),o.forEach(a=>n.step(a))}function Zm(n,e,t,r){let s=[],o=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof Xs){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==o-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>n.step(new rt(i.from,i.to,i.style)))}function el(n,e,t,r=t.contentMatch,s=!0){let o=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new ye(l,u,B.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new rt(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new B(O.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new ye(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);n.replace(l,l,new B(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function eg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function qn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,o=0;;--r){let i=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-o;if(r<n.depth&&i.canReplace(l,a,t))return r;if(r==0||i.type.spec.isolating||!eg(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function tg(n,e,t){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,u=O.empty,d=0;for(let m=o,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=O.from(r.node(m).copy(u)),d++):a--;let f=O.empty,h=0;for(let m=o,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=O.from(s.node(m).copy(f)),h++):c++;n.step(new we(a,c,i,l,new B(u.append(f),d,h),u.size-d,!0))}function tl(n,e,t=null,r=n){let s=ng(n,e),o=s&&rg(r,e);return o?s.map(ka).concat({type:e,attrs:t}).concat(o.map(ka)):null}function ka(n){return{type:n,attrs:null}}function ng(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return t.canReplaceWith(r,s,i)?o:null}function rg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,o=t.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function sg(n,e,t){let r=O.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(t[i].type.create(t[i].attrs,r))}let s=e.start,o=e.end;n.step(new we(s,o,s,o,new B(r,0,0),t.length,!0))}function og(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&ig(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&Gu(n,i,l,o),el(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return n.step(new we(d,f,d+1,f-1,new B(O.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ju(n,i,l,o),!1}})}function Ju(n,e,t,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+o+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Gu(n,e,t,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+o);n.replaceWith(i,i+1,e.type.schema.text(`
@@ -82,7 +82,7 @@ img.ProseMirror-separator {
82
82
  display: block;
83
83
  }`;function vy(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}var wy=class extends cy{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:B0,createMappablePosition:F0},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:o})=>this.options.onDrop(r,s,o)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=nf(e,this.options.autofocus);this.editorState=jn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(n){console.warn("Failed to remove CSS element:",n)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=vy(Sy,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=af(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;t=t.filter(i=>!i.key.startsWith(o))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const r=[...this.options.enableCoreExtensions?[Tf,Sf.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),vf,Mf,Ef,jf,Cf,Af,wf,If.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s?.type));this.extensionManager=new co(r,this)}createCommandManager(){this.commandManager=new so({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=gi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=gi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=t?this.extensionManager.dispatchTransaction(r):r,o=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(o);this.editorView=new Yd(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),s=t.includes(n),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=i?.getMeta("focus"),a=i?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:i}),a&&this.emit("blur",{editor:this,event:a.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return hf(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return _0(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Sl(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
84
84
 
85
- `,textSerializers:t={}}=n||{};return I0(this.state.doc,{blockSeparator:e,textSerializers:{...ff(this.schema),...t}})}get isEmpty(){return lo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new ky(e,this)}get $doc(){return this.$pos(0)}};function Bn(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=oe(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(vl(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&o.delete(u,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Cy(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=oe(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function yi(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=oe(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function Fn(n){return new ao({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=oe(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&tl(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(x=>h.includes(x.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Kt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)},undoable:n.undoable})}function Ty(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof V){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function KC(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ny={};xl(Ny,{createAtomBlockMarkdownSpec:()=>My,createBlockMarkdownSpec:()=>Ey,createInlineMarkdownSpec:()=>Iy,parseAttributes:()=>Cl,parseIndentedBlocks:()=>bi,renderNestedMarkdownContent:()=>Nl,serializeAttributes:()=>Tl});function Cl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Tl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function My(n){const{nodeName:e,name:t,parseAttributes:r=Cl,serializeAttributes:s=Tl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...o,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",x=r(g);if(!i.find(b=>!(b in x)))return{type:e,raw:m[0],attributes:x}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Ey(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Cl,serializeAttributes:o=Tl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,u=d=>{if(!a)return d;const f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const g=r(d);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const m={...i,...d.attributes};return f.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),m=(f=d.match(h))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,h){var m;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=d.match(g);if(!x)return;const[y,b=""]=x,k=s(b);let S=1;const v=y.length;let w="";const C=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(v);for(C.lastIndex=0;;){const N=C.exec(T);if(N===null)break;const M=N.index,j=N[1];if(!((m=N[2])!=null&&m.endsWith(":::"))){if(j)S+=1;else if(S-=1,S===0){const R=T.slice(0,M);w=R.trim();const A=d.slice(0,v+M+N[0].length);let D=[];if(w)if(l==="block")for(D=h.blockTokens(R),D.forEach(I=>{I.text&&(!I.tokens||I.tokens.length===0)&&(I.tokens=h.inlineTokens(I.text))});D.length>0;){const I=D[D.length-1];if(I.type==="paragraph"&&(!I.text||I.text.trim()===""))D.pop();else break}else D=h.inlineTokens(w);return{type:e,raw:A,attributes:k,content:w,tokens:D}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=o(h),g=m?` {${m}}`:"",x=f.renderChildren(d.content||[],`
85
+ `,textSerializers:t={}}=n||{};return I0(this.state.doc,{blockSeparator:e,textSerializers:{...ff(this.schema),...t}})}get isEmpty(){return lo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new ky(e,this)}get $doc(){return this.$pos(0)}};function Bn(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=oe(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(vl(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&o.delete(u,t.to),c>t.from&&o.delete(t.from+a,c);const f=t.from+a+i.length;o.addMark(t.from+a,f,n.type.create(s||{})),o.removeStoredMark(n.type)}},undoable:n.undoable})}function Cy(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=oe(n.getAttributes,void 0,r)||{},{tr:o}=e,i=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;o.insert(c,n.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:n.undoable})}function yi(n){return new ao({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),o=oe(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)},undoable:n.undoable})}function Fn(n){return new ao({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const o=oe(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&tl(a,n.type,o);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(x=>h.includes(x.type.name));i.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Kt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)},undoable:n.undoable})}function Ty(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof V){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function JC(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ny={};xl(Ny,{createAtomBlockMarkdownSpec:()=>My,createBlockMarkdownSpec:()=>Ey,createInlineMarkdownSpec:()=>Iy,parseAttributes:()=>Cl,parseIndentedBlocks:()=>bi,renderNestedMarkdownContent:()=>Nl,serializeAttributes:()=>Tl});function Cl(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(e.id=o[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Tl(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function My(n){const{nodeName:e,name:t,parseAttributes:r=Cl,serializeAttributes:s=Tl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...o,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",x=r(g);if(!i.find(b=>!(b in x)))return{type:e,raw:m[0],attributes:x}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Ey(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Cl,serializeAttributes:o=Tl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=n,c=t||e,u=d=>{if(!a)return d;const f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const g=r(d);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const m={...i,...d.attributes};return f.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),m=(f=d.match(h))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,h){var m;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=d.match(g);if(!x)return;const[y,b=""]=x,k=s(b);let S=1;const v=y.length;let w="";const C=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(v);for(C.lastIndex=0;;){const N=C.exec(T);if(N===null)break;const M=N.index,j=N[1];if(!((m=N[2])!=null&&m.endsWith(":::"))){if(j)S+=1;else if(S-=1,S===0){const R=T.slice(0,M);w=R.trim();const A=d.slice(0,v+M+N[0].length);let D=[];if(w)if(l==="block")for(D=h.blockTokens(R),D.forEach(I=>{I.text&&(!I.tokens||I.tokens.length===0)&&(I.tokens=h.inlineTokens(I.text))});D.length>0;){const I=D[D.length-1];if(I.type==="paragraph"&&(!I.text||I.text.trim()===""))D.pop();else break}else D=h.inlineTokens(w);return{type:e,raw:A,attributes:k,content:w,tokens:D}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=o(h),g=m?` {${m}}`:"",x=f.renderChildren(d.content||[],`
86
86
 
87
87
  `);return`:::${c}${g}
88
88
 
@@ -99,7 +99,7 @@ ${x}
99
99
  `);a+=c.type==="paragraph"?`
100
100
 
101
101
  ${m}`:`
102
- ${m}`}}),a}function Oy(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,u,n.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var _e=class Of extends wl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Of(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Ry=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),S=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,v=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+S,f=k.y-b.y+v}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const x=V.create(a.state.doc,g),y=a.state.tr.setSelection(x);a.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=V.isSelectable(this.node),d=n.type==="copy",f=n.type==="paste",h=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(Sr()||mi())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function bn(n){return new py({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=oe(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(vl(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===n.type&&x!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Dy,getOwnPropertySymbols:Py}=Object,{hasOwnProperty:Ly}=Object.prototype;function _o(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function Fr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function _y(n){return n?.[Symbol.toStringTag]}function gc(n){return Dy(n).concat(Py(n))}const $y=Object.hasOwn||((n,e)=>Ly.call(n,e));function wn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const zy="__v",By="__o",Fy="_owner",{getOwnPropertyDescriptor:xc,keys:yc}=Object;function Hy(n,e){return n.byteLength===e.byteLength&&ps(new Uint8Array(n),new Uint8Array(e))}function Vy(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Wy(n,e){return n.byteLength===e.byteLength&&ps(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Uy(n,e){return wn(n.getTime(),e.getTime())}function qy(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Ky(n,e){return n===e}function bc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,d,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const Jy=wn;function Gy(n,e,t){const r=yc(n);let s=r.length;if(yc(e).length!==s)return!1;for(;s-- >0;)if(!Rf(n,e,t,r[s]))return!1;return!0}function Gn(n,e,t){const r=gc(n);let s=r.length;if(gc(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Rf(n,e,t,o)||(i=xc(n,o),l=xc(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Xy(n,e){return wn(n.valueOf(),e.valueOf())}function Yy(n,e){return n.source===e.source&&n.flags===e.flags}function kc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ps(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Qy(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function Rf(n,e,t,r){return(r===Fy||r===By||r===zy)&&(n.$$typeof||e.$$typeof)?!0:$y(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Zy="[object ArrayBuffer]",eb="[object Arguments]",tb="[object Boolean]",nb="[object DataView]",rb="[object Date]",sb="[object Error]",ob="[object Map]",ib="[object Number]",lb="[object Object]",ab="[object RegExp]",cb="[object Set]",ub="[object String]",db={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},fb="[object URL]",hb=Object.prototype.toString;function pb({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(x,y,b){if(x===y)return!0;if(x==null||y==null)return!1;const k=typeof x;if(k!==typeof y)return!1;if(k!=="object")return k==="number"?l(x,y,b):k==="function"?o(x,y,b):!1;const S=x.constructor;if(S!==y.constructor)return!1;if(S===Object)return a(x,y,b);if(Array.isArray(x))return e(x,y,b);if(S===Date)return r(x,y,b);if(S===RegExp)return u(x,y,b);if(S===Map)return i(x,y,b);if(S===Set)return d(x,y,b);const v=hb.call(x);if(v===rb)return r(x,y,b);if(v===ab)return u(x,y,b);if(v===ob)return i(x,y,b);if(v===cb)return d(x,y,b);if(v===lb)return typeof x.then!="function"&&typeof y.then!="function"&&a(x,y,b);if(v===fb)return h(x,y,b);if(v===sb)return s(x,y,b);if(v===eb)return a(x,y,b);if(db[v])return f(x,y,b);if(v===Zy)return n(x,y,b);if(v===nb)return t(x,y,b);if(v===tb||v===ib||v===ub)return c(x,y,b);if(m){let w=m[v];if(!w){const C=_y(x);C&&(w=m[C])}if(w)return w(x,y,b)}return!1}}function mb({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Hy,areArraysEqual:t?Gn:Vy,areDataViewsEqual:Wy,areDatesEqual:Uy,areErrorsEqual:qy,areFunctionsEqual:Ky,areMapsEqual:t?_o(bc,Gn):bc,areNumbersEqual:Jy,areObjectsEqual:t?Gn:Gy,arePrimitiveWrappersEqual:Xy,areRegExpsEqual:Yy,areSetsEqual:t?_o(kc,Gn):kc,areTypedArraysEqual:t?_o(ps,Gn):ps,areUrlsEqual:Qy,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Fr(r.areArraysEqual),o=Fr(r.areMapsEqual),i=Fr(r.areObjectsEqual),l=Fr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function gb(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function xb({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:u}=t();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const yb=Gt();Gt({strict:!0});Gt({circular:!0});Gt({circular:!0,strict:!0});Gt({createInternalComparator:()=>wn});Gt({strict:!0,createInternalComparator:()=>wn});Gt({circular:!0,createInternalComparator:()=>wn});Gt({circular:!0,createInternalComparator:()=>wn,strict:!0});function Gt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=mb(n),i=pb(o),l=t?t(i):gb(i);return xb({circular:e,comparator:i,createState:r,equals:l,strict:s})}var bb=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},kb=({contentComponent:n})=>{const e=Kc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Sb(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Qh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var vb=class extends dn.Component{constructor(n){var e;super(n),this.editorContentRef=dn.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Sb(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:bb(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(kb,{contentComponent:n.contentComponent})]})}},wb=E.forwardRef((n,e)=>{const t=dn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return dn.createElement(vb,{key:t,innerRef:e,...n})}),Df=dn.memo(wb),Cb=typeof window<"u"?E.useLayoutEffect:E.useEffect,Tb=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Nb(n){var e;const[t]=E.useState(()=>new Tb(n.editor)),r=Xh.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:yb);return Cb(()=>t.watch(n.editor),[n.editor,t]),E.useDebugValue(r),r}var Mb=!1,ki=typeof window>"u",Eb=ki||!!(typeof window<"u"&&window.next),Ab=class Pf{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?ki||Eb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new wy(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Pf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function jb(n={},e=[]){const t=E.useRef(n);t.current=n;const[r]=E.useState(()=>new Ab(t)),s=Kc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),Nb({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var Ml=E.createContext({editor:null});Ml.Consumer;var JC=()=>E.useContext(Ml),Lf=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Ib=()=>E.useContext(Lf),_f=dn.forwardRef((n,e)=>{const{onDragStart:t}=Ib(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Sc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function vc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Ob(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Rb(n){if(Sc(n)||vc(n))return!0;if(Ob(n)){const e=n.type;if(e)return Sc(e)||vc(e)}return!1}function Db(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var Pb=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?Yh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=Db(),o=Rb(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};dn.createContext({markViewContentRef:()=>{}});var Lb=class extends Ry{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const n=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(t,r,s){var o;return r==="storage"?(o=n.storage[e.name])!=null?o:{}:Reflect.get(t,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:E.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=E.memo(a=>p.jsx(Lf.Provider,{value:r,children:E.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Pb(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=zn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function $f(n,e){return t=>t.editor.contentComponent?new Lb(n,t,e):{}}var El=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});El.displayName="TiptapContext";var _b=()=>E.useContext(El);function zf({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=E.useMemo(()=>({editor:r}),[r]),o=E.useMemo(()=>({editor:r}),[r]);return p.jsx(Ml.Provider,{value:o,children:p.jsx(El.Provider,{value:s,children:t})})}zf.displayName="Tiptap";function Bf({...n}){const{editor:e}=_b();return p.jsx(Df,{editor:e,...n})}Bf.displayName="Tiptap.Content";Object.assign(zf,{Content:Bf});function $b(n){return n.storage.mention}function GC(n,e,t){n.chain().focus().insertContentAt(e,[Ff(t),{type:"text",text:" "}]).run()}function Ff(n){return{type:"mention",attrs:n}}function zb(n){const e=_.c(19),{node:t,selected:r,view:s,editor:o,getPos:i}=n,{name:l,char:a,kind:c,id:u,args:d}=t.attrs,f=r&&s.editable,h=a==="@",m=s.editable&&a==="/"&&(c==="prompt"||c==null);let g;e[0]!==d||e[1]!==o||e[2]!==i||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const M=$b(o)?.onEditChip;if(!M||typeof i!="function")return;const j=i();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),M({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=o,e[2]=i,e[3]=u,e[4]=m,e[5]=l,e[6]=g):g=e[6];const x=g,y=m?"cursor-pointer":"cursor-default",b=h?"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",k=f&&"outline-2 outline-blue-300 outline-offset-0",S=m&&"hover:brightness-95";let v;e[7]!==y||e[8]!==b||e[9]!==k||e[10]!==S?(v=ee("px-1 py-1 rounded","inline-flex items-center gap-1",y,"select-none","text-xs font-light",b,k,S,"capitalize"),e[7]=y,e[8]=b,e[9]=k,e[10]=S,e[11]=v):v=e[11];let w;e[12]!==l?(w=l?Cu(l):"",e[12]=l,e[13]=w):w=e[13];let C;return e[14]!==a||e[15]!==x||e[16]!==v||e[17]!==w?(C=p.jsxs(_f,{onClick:x,className:v,children:[a,w]}),e[14]=a,e[15]=x,e[16]=v,e[17]=w,e[18]=C):C=e[18],C}const Bb=_e.create({name:"mention",group:"inline",inline:!0,atom:!0,addStorage(){return{onEditChip:null}},addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},char:{default:"/",parseHTML:n=>n.getAttribute("data-char")||"/",renderHTML:n=>n.char?{"data-char":n.char}:{}},metadata:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:n=>n.metadata?{"data-metadata":JSON.stringify(n.metadata)}:{}},kind:{default:null,parseHTML:n=>n.getAttribute("data-kind")||null,renderHTML:n=>n.kind?{"data-kind":n.kind}:{}},args:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-args")||"null")}catch{return null}},renderHTML:n=>n.args?{"data-args":JSON.stringify(n.args)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"mention"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.char&&(t["data-char"]=n.attrs.char),n.attrs.metadata&&(t["data-metadata"]=JSON.stringify(n.attrs.metadata)),n.attrs.kind&&(t["data-kind"]=n.attrs.kind),n.attrs.args&&(t["data-args"]=JSON.stringify(n.attrs.args)),["span",{...e,...t}]},renderText({node:n}){const e=n.attrs.char??"@",t=n.attrs.name??"";return`${e}${t}`},addNodeView(){return $f(zb)}}),Fb=/^mcp__[a-zA-Z0-9_-]+__/;function Hf(n){return n.replace(Fb,"")}function uo(n){const e=_.c(18),{id:t,part:r,copyable:s,extraActions:o,alwaysShowActions:i,animate:l}=n,a=s===void 0?!1:s,c=i===void 0?!1:i,u=l===void 0?!1:l,{handleCopy:d}=hu(),[f,h]=E.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{Zh("chat_message_copied",{message_id:t,chars:r.text.length}),await d(r.text),h(!0),setTimeout(()=>h(!1),2e3)},e[0]=d,e[1]=t,e[2]=r.text,e[3]=m):m=e[3];const g=m,x=a&&o,y=x||o;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Ji,{id:t,text:r.text,animate:u}),e[4]=u,e[5]=t,e[6]=r.text,e[7]=b):b=e[7];let k;e[8]!==c||e[9]!==o||e[10]!==g||e[11]!==f||e[12]!==y||e[13]!==x?(k=y&&p.jsxs("div",{className:ee("flex w-full items-center gap-2 text-sm text-muted-foreground transition-all duration-200 mt-1 py-1",c?"opacity-100":"opacity-0 pointer-events-none group-hover/part:opacity-100 group-hover/part:pointer-events-auto"),children:[o,x&&o&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),x&&p.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground [@media(hover:hover)]:hover:text-foreground transition-colors active:scale-[0.97]","aria-label":"Copy message",children:f?p.jsx(qi,{className:"size-4"}):p.jsx(fu,{className:"size-4"})})]}),e[8]=c,e[9]=o,e[10]=g,e[11]=f,e[12]=y,e[13]=x,e[14]=k):k=e[14];let S;return e[15]!==b||e[16]!==k?(S=p.jsxs("div",{className:"group/part relative",children:[b,k]}),e[15]=b,e[16]=k,e[17]=S):S=e[17],S}function XC(n,e,t){n.chain().focus().insertContentAt(e,[Hb(t),{type:"text",text:" "}]).run()}function Hb(n){return{type:"file",attrs:n}}function Vb(n){const e=_.c(17),{node:t,selected:r,view:s}=n,{name:o,mimeType:i,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==i?(c=i.startsWith("image/"),e[0]=i,e[1]=c):c=e[1];const u=c,d=a&&"outline-2 outline-blue-300 outline-offset-0";let f;e[2]!==d?(f=ee("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-muted text-muted-foreground",d),e[2]=d,e[3]=f):f=e[3];let h;e[4]!==o?(h=p.jsx(fn,{asChild:!0,children:p.jsx("span",{children:o})}),e[4]=o,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==i||e[9]!==o?(m=p.jsx(hn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${i};base64,${l}`,alt:o,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:o}),p.jsx("div",{className:"text-muted-foreground mt-1",children:i})]})}),e[6]=l,e[7]=u,e[8]=i,e[9]=o,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(pn,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13];let x;return e[14]!==f||e[15]!==g?(x=p.jsx(_f,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=x):x=e[16],x}const Wb=_e.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},mimeType:{default:null,parseHTML:n=>n.getAttribute("data-mime-type")||null,renderHTML:n=>n.mimeType?{"data-mime-type":n.mimeType}:{}},size:{default:0,parseHTML:n=>{const e=n.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:n=>n.size?{"data-size":String(n.size)}:{}},data:{default:null,parseHTML:n=>n.getAttribute("data-data")||null,renderHTML:n=>n.data?{"data-data":n.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"file"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.mimeType&&(t["data-mime-type"]=n.attrs.mimeType),n.attrs.size&&(t["data-size"]=String(n.attrs.size)),n.attrs.data&&(t["data-data"]=n.attrs.data),["span",{...e,...t}]},renderText({node:n}){return`[${n.attrs.name??""}]`},addNodeView(){return $f(Vb)}});function Ub(n={}){return new fe({view(e){return new qb(e,n)}})}class qb{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Yu(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class me extends X{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return me.valid(r)?new me(r):X.near(r)}content(){return B.empty}eq(e){return e instanceof me&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new me(e.resolve(t.pos))}getBookmark(){return new Al(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Kb(e)||!Jb(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&me.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(me.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(me.valid(l))return l}return null}}}me.prototype.visible=!1;me.findFrom=me.findGapCursorFrom;X.jsonID("gapcursor",me);class Al{constructor(e){this.pos=e}map(e){return new Al(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return me.valid(t)?new me(t):X.near(t)}}function Vf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Kb(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Vf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Jb(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Vf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Gb(){return new fe({props:{decorations:Zb,createSelectionBetween(n,e,t){return e.pos==t.pos&&me.valid(t)?new me(t):null},handleClick:Yb,handleKeyDown:Xb,handleDOMEvents:{beforeinput:Qb}}})}const Xb=Qd({ArrowLeft:Hr("horiz",-1),ArrowRight:Hr("horiz",1),ArrowUp:Hr("vert",-1),ArrowDown:Hr("vert",1)});function Hr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof q){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=me.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new me(c))),!0):!1}}function Yb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!me.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&V.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new me(r))),!0)}function Qb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof me))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let i=r.length-1;i>=0;i--)s=O.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new B(s,0,0));return o.setSelection(q.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Zb(n){if(!(n.selection instanceof me))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",de.create(n.doc,[De.widget(n.selection.head,e,{key:"gapcursor"})])}var ms=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<ms&&this.leafAppend(e)||this.length<ms&&e.leafPrepend(this)||this.appendInner(e)):this};Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this};Ce.prototype.appendInner=function(e){return new ek(this,e)};Ce.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ce.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};Ce.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new Wf(e):Ce.empty};var Wf=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=ms)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=ms)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Ce);Ce.empty=new Wf([]);var ek=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ce);const tk=500;class nt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new lt(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new lt(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new lt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>rk&&(l=nk(l,c),i-=c),new nt(l.append(o),i)}remapping(e,t){let r=new gr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(t=>new lt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),x=f.selection&&f.selection.map(o.slice(a+1,h));x&&l++,r.push(new lt(m,g,x))}else r.push(new lt(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new lt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>tk&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new lt(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new nt(Ce.from(s.reverse()),o)}}nt.empty=new nt(Ce.empty,0);function nk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class lt{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new lt(t.getMap().invert(),t,this.selection)}}}class jt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const rk=20;function sk(n,e,t,r){let s=t.getMeta(cn),o;if(s)return s.historyState;t.getMeta(lk)&&(n=new jt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(cn))return i.getMeta(cn).redo?new jt(n.done.addTransform(t,void 0,r,Yr(e)),n.undone,wc(t.mapping.maps),n.prevTime,n.prevComposition):new jt(n.done,n.undone.addTransform(t,void 0,r,Yr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ok(t,n.prevRanges)),c=i?$o(n.prevRanges,t.mapping):wc(t.mapping.maps);return new jt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Yr(e)),nt.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new jt(n.done.rebased(t,o),n.undone.rebased(t,o),$o(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new jt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),$o(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ok(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function wc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function $o(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function ik(n,e,t){let r=Yr(e),s=cn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new jt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(cn,{redo:t,historyState:a})}let zo=!1,Cc=null;function Yr(n){let e=n.plugins;if(Cc!=e){zo=!1,Cc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zo=!0;break}}return zo}const cn=new ve("history"),lk=new ve("closeHistory");function ak(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new fe({key:cn,state:{init(){return new jt(nt.empty,nt.empty,null,0,-1)},apply(e,t,r){return sk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?qf:r=="historyRedo"?Kf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Uf(n,e){return(t,r)=>{let s=cn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=ik(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const qf=Uf(!1,!0),Kf=Uf(!0,!0);xe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new fe({key:new ve("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var ck=xe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ub(this.options)]}});xe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fe({key:new ve("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return de.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(De.node(c,c+a.nodeSize,{class:this.options.className}))}),de.create(n,o)}}})]}});var uk=xe.create({name:"gapCursor",addProseMirrorPlugins(){return[Gb()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=oe(H(n,"allowGapCursor",t)))!=null?e:null}}}),Tc="placeholder";function dk(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var YC=xe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Tc,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${dk(this.options.dataAttribute)}`:`data-${Tc}`;return[new fe({key:new ve("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,o=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&lo(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const f=De.node(a,a+l.nodeSize,{class:d.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});o.push(f)}return this.options.includeChildren}),de.create(e,o)}}})]}});xe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new fe({key:new ve("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||mf(t.selection)||n.view.dragging?null:de.create(t.doc,[De.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Nc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var fk=xe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ve(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new fe({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!Nc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Nc({node:i,types:r})}}})]}}),hk=xe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>qf(n,e),redo:()=>({state:n,dispatch:e})=>Kf(n,e)}},addProseMirrorPlugins(){return[ak(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),gs=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},pk=/^\s*>\s$/,mk=_e.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return gs("blockquote",{...Se(this.options.HTMLAttributes,n),children:gs("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((s,o)=>{var i,l;const u=((l=(i=e.renderChild)==null?void 0:i.call(e,s,o))!=null?l:e.renderChildren([s])).split(`
102
+ ${m}`}}),a}function Oy(n,e,t={}){const{state:r}=e,{doc:s,tr:o}=r,i=n;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==d.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});o.removeMark(c,u,n.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var _e=class Of extends wl{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Of(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Ry=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,s,o,i,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),S=(s=n.offsetX)!=null?s:(r=n.nativeEvent)==null?void 0:r.offsetX,v=(i=n.offsetY)!=null?i:(o=n.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+S,f=k.y-b.y+v}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const x=V.create(a.state.doc,g),y=a.state.tr.setSelection(x);a.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const s=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=V.isSelectable(this.node),d=n.type==="copy",f=n.type==="paste",h=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&s&&n.target===this.dom&&n.preventDefault(),c&&s&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const g=t.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(Sr()||mi())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function bn(n){return new py({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const o=oe(n.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(vl(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(x=>x===n.type&&x!==m.mark.type)).filter(m=>m.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Dy,getOwnPropertySymbols:Py}=Object,{hasOwnProperty:Ly}=Object.prototype;function _o(n,e){return function(r,s,o){return n(r,s,o)&&e(r,s,o)}}function Fr(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:o}=s,i=o.get(t),l=o.get(r);if(i&&l)return i===r&&l===t;o.set(t,r),o.set(r,t);const a=n(t,r,s);return o.delete(t),o.delete(r),a}}function _y(n){return n?.[Symbol.toStringTag]}function gc(n){return Dy(n).concat(Py(n))}const $y=Object.hasOwn||((n,e)=>Ly.call(n,e));function wn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const zy="__v",By="__o",Fy="_owner",{getOwnPropertyDescriptor:xc,keys:yc}=Object;function Hy(n,e){return n.byteLength===e.byteLength&&ps(new Uint8Array(n),new Uint8Array(e))}function Vy(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Wy(n,e){return n.byteLength===e.byteLength&&ps(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Uy(n,e){return wn(n.getTime(),e.getTime())}function qy(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Ky(n,e){return n===e}function bc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(t.equals(f[0],h[0],a,d,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const Jy=wn;function Gy(n,e,t){const r=yc(n);let s=r.length;if(yc(e).length!==s)return!1;for(;s-- >0;)if(!Rf(n,e,t,r[s]))return!1;return!0}function Gn(n,e,t){const r=gc(n);let s=r.length;if(gc(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Rf(n,e,t,o)||(i=xc(n,o),l=xc(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function Xy(n,e){return wn(n.valueOf(),e.valueOf())}function Yy(n,e){return n.source===e.source&&n.flags===e.flags}function kc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=n.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(i.value,l.value,i.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ps(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Qy(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function Rf(n,e,t,r){return(r===Fy||r===By||r===zy)&&(n.$$typeof||e.$$typeof)?!0:$y(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Zy="[object ArrayBuffer]",eb="[object Arguments]",tb="[object Boolean]",nb="[object DataView]",rb="[object Date]",sb="[object Error]",ob="[object Map]",ib="[object Number]",lb="[object Object]",ab="[object RegExp]",cb="[object Set]",ub="[object String]",db={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},fb="[object URL]",hb=Object.prototype.toString;function pb({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(x,y,b){if(x===y)return!0;if(x==null||y==null)return!1;const k=typeof x;if(k!==typeof y)return!1;if(k!=="object")return k==="number"?l(x,y,b):k==="function"?o(x,y,b):!1;const S=x.constructor;if(S!==y.constructor)return!1;if(S===Object)return a(x,y,b);if(Array.isArray(x))return e(x,y,b);if(S===Date)return r(x,y,b);if(S===RegExp)return u(x,y,b);if(S===Map)return i(x,y,b);if(S===Set)return d(x,y,b);const v=hb.call(x);if(v===rb)return r(x,y,b);if(v===ab)return u(x,y,b);if(v===ob)return i(x,y,b);if(v===cb)return d(x,y,b);if(v===lb)return typeof x.then!="function"&&typeof y.then!="function"&&a(x,y,b);if(v===fb)return h(x,y,b);if(v===sb)return s(x,y,b);if(v===eb)return a(x,y,b);if(db[v])return f(x,y,b);if(v===Zy)return n(x,y,b);if(v===nb)return t(x,y,b);if(v===tb||v===ib||v===ub)return c(x,y,b);if(m){let w=m[v];if(!w){const C=_y(x);C&&(w=m[C])}if(w)return w(x,y,b)}return!1}}function mb({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:Hy,areArraysEqual:t?Gn:Vy,areDataViewsEqual:Wy,areDatesEqual:Uy,areErrorsEqual:qy,areFunctionsEqual:Ky,areMapsEqual:t?_o(bc,Gn):bc,areNumbersEqual:Jy,areObjectsEqual:t?Gn:Gy,arePrimitiveWrappersEqual:Xy,areRegExpsEqual:Yy,areSetsEqual:t?_o(kc,Gn):kc,areTypedArraysEqual:t?_o(ps,Gn):ps,areUrlsEqual:Qy,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Fr(r.areArraysEqual),o=Fr(r.areMapsEqual),i=Fr(r.areObjectsEqual),l=Fr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function gb(n){return function(e,t,r,s,o,i,l){return n(e,t,l)}}function xb({circular:n,comparator:e,createState:t,equals:r,strict:s}){if(t)return function(l,a){const{cache:c=n?new WeakMap:void 0,meta:u}=t();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(n)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,o)}}const yb=Gt();Gt({strict:!0});Gt({circular:!0});Gt({circular:!0,strict:!0});Gt({createInternalComparator:()=>wn});Gt({strict:!0,createInternalComparator:()=>wn});Gt({circular:!0,createInternalComparator:()=>wn});Gt({circular:!0,createInternalComparator:()=>wn,strict:!0});function Gt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,o=mb(n),i=pb(o),l=t?t(i):gb(i);return xb({circular:e,comparator:i,createState:r,equals:l,strict:s})}var bb=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},kb=({contentComponent:n})=>{const e=Kc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Sb(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Qh.createPortal(r.reactElement,r.element,t)},n.forEach(s=>s())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(s=>s())}}}var vb=class extends dn.Component{constructor(n){var e;super(n),this.editorContentRef=dn.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Sb(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:bb(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(kb,{contentComponent:n.contentComponent})]})}},wb=E.forwardRef((n,e)=>{const t=dn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return dn.createElement(vb,{key:t,innerRef:e,...n})}),Df=dn.memo(wb),Cb=typeof window<"u"?E.useLayoutEffect:E.useEffect,Tb=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Nb(n){var e;const[t]=E.useState(()=>new Tb(n.editor)),r=Xh.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:yb);return Cb(()=>t.watch(n.editor),[n.editor,t]),E.useDebugValue(r),r}var Mb=!1,ki=typeof window>"u",Eb=ki||!!(typeof window<"u"&&window.next),Ab=class Pf{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(t=>t())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?ki||Eb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new wy(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=t.extensions)==null?void 0:i[o])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Pf.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function jb(n={},e=[]){const t=E.useRef(n);t.current=n;const[r]=E.useState(()=>new Ab(t)),s=Kc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),Nb({editor:s,selector:({transactionNumber:o})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&o===0?0:o+1}),s}var Ml=E.createContext({editor:null});Ml.Consumer;var GC=()=>E.useContext(Ml),Lf=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Ib=()=>E.useContext(Lf),_f=dn.forwardRef((n,e)=>{const{onDragStart:t}=Ib(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Sc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function vc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Ob(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Rb(n){if(Sc(n)||vc(n))return!0;if(Ob(n)){const e=n.type;if(e)return Sc(e)||vc(e)}return!1}function Db(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var Pb=class{constructor(n,{editor:e,props:t={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?Yh.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var n;if(this.destroyed)return;const e=this.component,t=this.props,r=this.editor,s=Db(),o=Rb(e),i={...t};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.destroyed||(this.props={...this.props,...n},this.render())}destroy(){var n;this.destroyed=!0;const e=this.editor;(n=e?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};dn.createContext({markViewContentRef:()=>{}});var Lb=class extends Ry{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const n=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(t,r,s){var o;return r==="storage"?(o=n.storage[e.name])!=null?o:{}:Reflect.get(t,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:E.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=E.memo(a=>p.jsx(Lf.Provider,{value:r,children:E.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Pb(o,{editor:this.editor,props:n,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:o,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=zn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function $f(n,e){return t=>t.editor.contentComponent?new Lb(n,t,e):{}}var El=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});El.displayName="TiptapContext";var _b=()=>E.useContext(El);function zf({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=E.useMemo(()=>({editor:r}),[r]),o=E.useMemo(()=>({editor:r}),[r]);return p.jsx(Ml.Provider,{value:o,children:p.jsx(El.Provider,{value:s,children:t})})}zf.displayName="Tiptap";function Bf({...n}){const{editor:e}=_b();return p.jsx(Df,{editor:e,...n})}Bf.displayName="Tiptap.Content";Object.assign(zf,{Content:Bf});function $b(n){return n.storage.mention}function XC(n,e,t){n.chain().focus().insertContentAt(e,[Ff(t),{type:"text",text:" "}]).run()}function Ff(n){return{type:"mention",attrs:n}}function zb(n){const e=_.c(19),{node:t,selected:r,view:s,editor:o,getPos:i}=n,{name:l,char:a,kind:c,id:u,args:d}=t.attrs,f=r&&s.editable,h=a==="@",m=s.editable&&a==="/"&&(c==="prompt"||c==null);let g;e[0]!==d||e[1]!==o||e[2]!==i||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const M=$b(o)?.onEditChip;if(!M||typeof i!="function")return;const j=i();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),M({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=o,e[2]=i,e[3]=u,e[4]=m,e[5]=l,e[6]=g):g=e[6];const x=g,y=m?"cursor-pointer":"cursor-default",b=h?"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",k=f&&"outline-2 outline-blue-300 outline-offset-0",S=m&&"hover:brightness-95";let v;e[7]!==y||e[8]!==b||e[9]!==k||e[10]!==S?(v=ee("px-1 py-1 rounded","inline-flex items-center gap-1",y,"select-none","text-xs font-light",b,k,S,"capitalize"),e[7]=y,e[8]=b,e[9]=k,e[10]=S,e[11]=v):v=e[11];let w;e[12]!==l?(w=l?Cu(l):"",e[12]=l,e[13]=w):w=e[13];let C;return e[14]!==a||e[15]!==x||e[16]!==v||e[17]!==w?(C=p.jsxs(_f,{onClick:x,className:v,children:[a,w]}),e[14]=a,e[15]=x,e[16]=v,e[17]=w,e[18]=C):C=e[18],C}const Bb=_e.create({name:"mention",group:"inline",inline:!0,atom:!0,addStorage(){return{onEditChip:null}},addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},char:{default:"/",parseHTML:n=>n.getAttribute("data-char")||"/",renderHTML:n=>n.char?{"data-char":n.char}:{}},metadata:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-metadata")||"null")}catch{return null}},renderHTML:n=>n.metadata?{"data-metadata":JSON.stringify(n.metadata)}:{}},kind:{default:null,parseHTML:n=>n.getAttribute("data-kind")||null,renderHTML:n=>n.kind?{"data-kind":n.kind}:{}},args:{default:null,parseHTML:n=>{try{return JSON.parse(n.getAttribute("data-args")||"null")}catch{return null}},renderHTML:n=>n.args?{"data-args":JSON.stringify(n.args)}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"mention"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.char&&(t["data-char"]=n.attrs.char),n.attrs.metadata&&(t["data-metadata"]=JSON.stringify(n.attrs.metadata)),n.attrs.kind&&(t["data-kind"]=n.attrs.kind),n.attrs.args&&(t["data-args"]=JSON.stringify(n.attrs.args)),["span",{...e,...t}]},renderText({node:n}){const e=n.attrs.char??"@",t=n.attrs.name??"";return`${e}${t}`},addNodeView(){return $f(zb)}}),Fb=/^mcp__[a-zA-Z0-9_-]+__/;function Hf(n){return n.replace(Fb,"")}function uo(n){const e=_.c(18),{id:t,part:r,copyable:s,extraActions:o,alwaysShowActions:i,animate:l}=n,a=s===void 0?!1:s,c=i===void 0?!1:i,u=l===void 0?!1:l,{handleCopy:d}=hu(),[f,h]=E.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{Zh("chat_message_copied",{message_id:t,chars:r.text.length}),await d(r.text),h(!0),setTimeout(()=>h(!1),2e3)},e[0]=d,e[1]=t,e[2]=r.text,e[3]=m):m=e[3];const g=m,x=a&&o,y=x||o;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Ji,{id:t,text:r.text,animate:u}),e[4]=u,e[5]=t,e[6]=r.text,e[7]=b):b=e[7];let k;e[8]!==c||e[9]!==o||e[10]!==g||e[11]!==f||e[12]!==y||e[13]!==x?(k=y&&p.jsxs("div",{className:ee("flex w-full items-center gap-2 text-sm text-muted-foreground transition-all duration-200 mt-1 py-1",c?"opacity-100":"opacity-0 pointer-events-none group-hover/part:opacity-100 group-hover/part:pointer-events-auto"),children:[o,x&&o&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),x&&p.jsx("button",{type:"button",onClick:g,className:"text-muted-foreground [@media(hover:hover)]:hover:text-foreground transition-colors active:scale-[0.97]","aria-label":"Copy message",children:f?p.jsx(qi,{className:"size-4"}):p.jsx(fu,{className:"size-4"})})]}),e[8]=c,e[9]=o,e[10]=g,e[11]=f,e[12]=y,e[13]=x,e[14]=k):k=e[14];let S;return e[15]!==b||e[16]!==k?(S=p.jsxs("div",{className:"group/part relative",children:[b,k]}),e[15]=b,e[16]=k,e[17]=S):S=e[17],S}function YC(n,e,t){n.chain().focus().insertContentAt(e,[Hb(t),{type:"text",text:" "}]).run()}function Hb(n){return{type:"file",attrs:n}}function Vb(n){const e=_.c(17),{node:t,selected:r,view:s}=n,{name:o,mimeType:i,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==i?(c=i.startsWith("image/"),e[0]=i,e[1]=c):c=e[1];const u=c,d=a&&"outline-2 outline-blue-300 outline-offset-0";let f;e[2]!==d?(f=ee("px-1 py-1 rounded","inline-flex items-center gap-1","cursor-default select-none","text-xs font-light","bg-muted text-muted-foreground",d),e[2]=d,e[3]=f):f=e[3];let h;e[4]!==o?(h=p.jsx(fn,{asChild:!0,children:p.jsx("span",{children:o})}),e[4]=o,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==i||e[9]!==o?(m=p.jsx(hn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${i};base64,${l}`,alt:o,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:o}),p.jsx("div",{className:"text-muted-foreground mt-1",children:i})]})}),e[6]=l,e[7]=u,e[8]=i,e[9]=o,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(pn,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=g):g=e[13];let x;return e[14]!==f||e[15]!==g?(x=p.jsx(_f,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=x):x=e[16],x}const Wb=_e.create({name:"file",group:"inline",inline:!0,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id")||null,renderHTML:n=>n.id?{"data-id":n.id}:{}},name:{default:null,parseHTML:n=>n.getAttribute("data-name")||null,renderHTML:n=>n.name?{"data-name":n.name}:{}},mimeType:{default:null,parseHTML:n=>n.getAttribute("data-mime-type")||null,renderHTML:n=>n.mimeType?{"data-mime-type":n.mimeType}:{}},size:{default:0,parseHTML:n=>{const e=n.getAttribute("data-size");return e?Number.parseInt(e,10):0},renderHTML:n=>n.size?{"data-size":String(n.size)}:{}},data:{default:null,parseHTML:n=>n.getAttribute("data-data")||null,renderHTML:n=>n.data?{"data-data":n.data}:{}}}},parseHTML(){return[{tag:'span[data-type="file"]'}]},renderHTML({node:n,HTMLAttributes:e}){const t={"data-type":"file"};return n.attrs.id&&(t["data-id"]=n.attrs.id),n.attrs.name&&(t["data-name"]=n.attrs.name),n.attrs.mimeType&&(t["data-mime-type"]=n.attrs.mimeType),n.attrs.size&&(t["data-size"]=String(n.attrs.size)),n.attrs.data&&(t["data-data"]=n.attrs.data),["span",{...e,...t}]},renderText({node:n}){return`[${n.attrs.name??""}]`},addNodeView(){return $f(Vb)}});function Ub(n={}){return new fe({view(e){return new qb(e,n)}})}class qb{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!o){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Yu(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class me extends X{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return me.valid(r)?new me(r):X.near(r)}content(){return B.empty}eq(e){return e instanceof me&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new me(e.resolve(t.pos))}getBookmark(){return new Al(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Kb(e)||!Jb(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&me.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=t;let a=e.doc.resolve(s);if(me.valid(a))return a}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*t),r=!1;continue e}break}o=i,s+=t;let l=e.doc.resolve(s);if(me.valid(l))return l}return null}}}me.prototype.visible=!1;me.findFrom=me.findGapCursorFrom;X.jsonID("gapcursor",me);class Al{constructor(e){this.pos=e}map(e){return new Al(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return me.valid(t)?new me(t):X.near(t)}}function Vf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Kb(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Vf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Jb(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Vf(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Gb(){return new fe({props:{decorations:Zb,createSelectionBetween(n,e,t){return e.pos==t.pos&&me.valid(t)?new me(t):null},handleClick:Yb,handleKeyDown:Xb,handleDOMEvents:{beforeinput:Qb}}})}const Xb=Qd({ArrowLeft:Hr("horiz",-1),ArrowRight:Hr("horiz",1),ArrowUp:Hr("vert",-1),ArrowDown:Hr("vert",1)});function Hr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof q){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=me.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new me(c))),!0):!1}}function Yb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!me.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&V.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new me(r))),!0)}function Qb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof me))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let i=r.length-1;i>=0;i--)s=O.from(r[i].createAndFill(null,s));let o=n.state.tr.replace(t.pos,t.pos,new B(s,0,0));return o.setSelection(q.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Zb(n){if(!(n.selection instanceof me))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",de.create(n.doc,[De.widget(n.selection.head,e,{key:"gapcursor"})])}var ms=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<ms&&this.leafAppend(e)||this.length<ms&&e.leafPrepend(this)||this.appendInner(e)):this};Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this};Ce.prototype.appendInner=function(e){return new ek(this,e)};Ce.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ce.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};Ce.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},t,r),s};Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new Wf(e):Ce.empty};var Wf=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=ms)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=ms)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(Ce);Ce.empty=new Wf([]);var ek=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ce);const tk=500;class nt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;t&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new lt(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new lt(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new lt(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(i++,t=void 0),s||(a=f)}let c=i-r.depth;return c>rk&&(l=nk(l,c),i-=c),new nt(l.append(o),i)}remapping(e,t){let r=new gr;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(t=>new lt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),x=f.selection&&f.selection.map(o.slice(a+1,h));x&&l++,r.push(new lt(m,g,x))}else r.push(new lt(m))},s);let c=[];for(let f=t;f<i;f++)c.push(new lt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>tk&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&o++;let d=new lt(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new nt(Ce.from(s.reverse()),o)}}nt.empty=new nt(Ce.empty,0);function nk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class lt{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new lt(t.getMap().invert(),t,this.selection)}}}class jt{constructor(e,t,r,s,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const rk=20;function sk(n,e,t,r){let s=t.getMeta(cn),o;if(s)return s.historyState;t.getMeta(lk)&&(n=new jt(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(cn))return i.getMeta(cn).redo?new jt(n.done.addTransform(t,void 0,r,Yr(e)),n.undone,wc(t.mapping.maps),n.prevTime,n.prevComposition):new jt(n.done,n.undone.addTransform(t,void 0,r,Yr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ok(t,n.prevRanges)),c=i?$o(n.prevRanges,t.mapping):wc(t.mapping.maps);return new jt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Yr(e)),nt.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new jt(n.done.rebased(t,o),n.undone.rebased(t,o),$o(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new jt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),$o(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ok(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(t=!0)}),t}function wc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,o,i)=>e.push(o,i));return e}function $o(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),o=e.map(n[r+1],-1);s<=o&&t.push(s,o)}return t}function ik(n,e,t){let r=Yr(e),s=cn.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new jt(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(cn,{redo:t,historyState:a})}let zo=!1,Cc=null;function Yr(n){let e=n.plugins;if(Cc!=e){zo=!1,Cc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zo=!0;break}}return zo}const cn=new ve("history"),lk=new ve("closeHistory");function ak(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new fe({key:cn,state:{init(){return new jt(nt.empty,nt.empty,null,0,-1)},apply(e,t,r){return sk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?qf:r=="historyRedo"?Kf:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function Uf(n,e){return(t,r)=>{let s=cn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let o=ik(s,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const qf=Uf(!1,!0),Kf=Uf(!0,!0);xe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new fe({key:new ve("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var ck=xe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ub(this.options)]}});xe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fe({key:new ve("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!t||!r)return de.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return n.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(De.node(c,c+a.nodeSize,{class:this.options.className}))}),de.create(n,o)}}})]}});var uk=xe.create({name:"gapCursor",addProseMirrorPlugins(){return[Gb()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=oe(H(n,"allowGapCursor",t)))!=null?e:null}}}),Tc="placeholder";function dk(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var QC=xe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Tc,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${dk(this.options.dataAttribute)}`:`data-${Tc}`;return[new fe({key:new ve("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,o=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&lo(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const f=De.node(a,a+l.nodeSize,{class:d.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});o.push(f)}return this.options.includeChildren}),de.create(e,o)}}})]}});xe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new fe({key:new ve("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||mf(t.selection)||n.view.dragging?null:de.create(t.doc,[De.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Nc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var fk=xe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new ve(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(t).includes(s.name));return[new fe({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!Nc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Nc({node:i,types:r})}}})]}}),hk=xe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>qf(n,e),redo:()=>({state:n,dispatch:e})=>Kf(n,e)}},addProseMirrorPlugins(){return[ak(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),gs=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},pk=/^\s*>\s$/,mk=_e.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return gs("blockquote",{...Se(this.options.HTMLAttributes,n),children:gs("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((s,o)=>{var i,l;const u=((l=(i=e.renderChild)==null?void 0:i.call(e,s,o))!=null?l:e.renderChildren([s])).split(`
103
103
  `).map(d=>d.trim()===""?t:`${t} ${d}`);r.push(u.join(`
104
104
  `))}),r.join(`
105
105
  ${t}
@@ -139,7 +139,7 @@ ${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:
139
139
  `):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const s=n.split(`
140
140
  `),[o,i]=hS(s);if(o.length===0)return;const l=dh(o,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=o[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,i).join(`
141
141
  `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(mS,this.editor.getAttributes(_c)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Fn({find:$c,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Fn({find:$c,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(_c)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),gS=/^\s*(\[([( |x])?\])\s$/,xS=_e.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",Se(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const s=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return Nl(n,e,s)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(n),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const m=t();if(typeof m!="number")return!1;const g=h.doc.nodeAt(m);return h.setNodeMarkup(m,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=n.attrs.checked,l.checked=n.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,h=zn(d,f),m=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(x=>{m.has(x)||(x in g?s.setAttribute(x,g[x]):s.removeAttribute(x))}),Object.entries(h).forEach(([x,y])=>{y==null?x in g?s.setAttribute(x,g[x]):s.removeAttribute(x):s.setAttribute(x,y)}),u=m,!0}}}},addInputRules(){return[Fn({find:gS,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),yS=_e.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",Se(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
142
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=bi(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=bi(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});xe.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(rh.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(sh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(uh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(fh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(xS.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(yS.configure(this.options.taskList)),n}});var zc="&nbsp;",bS=" ",kS=_e.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Se(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return r.length===1&&r[0].type==="text"&&(r[0].text===zc||r[0].text===bS)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const o=Array.isArray(n.content)?n.content:[];if(o.length===0){const i=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&i.length===0?zc:""}return e.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),SS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,vS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,wS=vn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Bn({find:SS,type:this.type})]},addPasteRules(){return[bn({find:vS,type:this.type})]}}),CS=_e.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),TS=vn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Se(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),NS=xe.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(kk.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(mk.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(rh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(wk.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Nk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Mk.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(ck.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(uk.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Ek.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Ak.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(hk.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(jk.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Pk.configure(this.options.italic)),this.options.listItem!==!1&&s.push(sh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(uh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(iS.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(fh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(kS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(wS.configure(this.options.strike)),this.options.text!==!1&&s.push(CS.configure(this.options.text)),this.options.underline!==!1&&s.push(TS.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(fk.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),MS=NS;const Yt=16,Ii=2.5,Oi=(Yt-Ii)/2,Ko=2*Math.PI*Oi;function hh(n){const e=_.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:o,cost:i}=t;if(!r&&!s&&!o)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(yp,{size:12}),e[0]=l):l=e[0];let a;e[1]!==i||e[2]!==r?(a=i>0?`$${i.toFixed(4)}`:r.toLocaleString(),e[1]=i,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(fn,{asChild:!0,children:p.jsxs("span",{className:"inline-flex items-center text-muted-foreground [@media(hover:hover)]:hover:text-foreground pl-1 h-6 gap-1 whitespace-nowrap shrink-0 cursor-default",children:[l,p.jsx("span",{className:"text-sm font-mono tabular-nums",children:a})]})}),e[4]=a,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("p",{className:"text-muted text-[10px] mb-1",children:"tokens"}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("span",{className:"text-muted",children:"in"}),e[7]=d):d=e[7];let f;e[8]!==s?(f=s.toLocaleString(),e[8]=s,e[9]=f):f=e[9];let h;e[10]!==f?(h=p.jsx("span",{className:"text-right tabular-nums",children:f}),e[10]=f,e[11]=h):h=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("span",{className:"text-muted",children:"out"}),e[12]=m):m=e[12];const g=o-(t.reasoningTokens??0);let x;e[13]!==g?(x=g.toLocaleString(),e[13]=g,e[14]=x):x=e[14];let y;e[15]!==x?(y=p.jsx("span",{className:"text-right tabular-nums",children:x}),e[15]=x,e[16]=y):y=e[16];let b;e[17]!==s||e[18]!==t.cacheReadTokens||e[19]!==t.cacheWriteTokens?(b=(t.cacheReadTokens>0||t.cacheWriteTokens>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:s>0?`${(t.cacheReadTokens/s*100).toFixed(0)}%`:"0%"})]}),e[17]=s,e[18]=t.cacheReadTokens,e[19]=t.cacheWriteTokens,e[20]=b):b=e[20];let k;e[21]!==i?(k=i>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",i.toFixed(4)]})]}),e[21]=i,e[22]=k):k=e[22];let S;e[23]!==y||e[24]!==b||e[25]!==k||e[26]!==h?(S=p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[u,p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[d,h,m,y,b,k]})]}),e[23]=y,e[24]=b,e[25]=k,e[26]=h,e[27]=S):S=e[27];let v;return e[28]!==S||e[29]!==c?(v=p.jsxs(pn,{children:[c,S]}),e[28]=S,e[29]=c,e[30]=v):v=e[30],v}function ES(n){const e=_.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,o=t!=null&&(t.cost??0)>0,i=t!=null&&(t.totalTokens??0)>0;if(!s&&!o&&!i)return null;let l;e[0]!==r||e[1]!==s?(l=s?Ht(r/1e3):null,e[0]=r,e[1]=s,e[2]=l):l=e[2];const a=l;let c;e[3]!==r||e[4]!==a||e[5]!==t?(c=a&&p.jsxs(pn,{children:[p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:a})}),p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"thinking"}),p.jsx("span",{className:"tabular-nums",children:Ht(r/1e3)}),(t?.reasoningTokens??0)>0&&p.jsxs("span",{className:"ml-2 opacity-50",children:[t.reasoningTokens.toLocaleString()," tok"]})]})]}),e[3]=r,e[4]=a,e[5]=t,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==s||e[9]!==i?(u=s&&(o||i)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=o,e[8]=s,e[9]=i,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==i||e[13]!==t?(d=(o||i)&&p.jsxs(pn,{children:[p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:o?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"tokens"}),p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[p.jsx("span",{className:"opacity-60",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:(t.inputTokens??0).toLocaleString()}),p.jsx("span",{className:"opacity-60",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:((t.outputTokens??0)-(t?.reasoningTokens??0)).toLocaleString()}),(t?.reasoningTokens??0)>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"think"}),p.jsx("span",{className:"text-right tabular-nums",children:t.reasoningTokens.toLocaleString()})]}),((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:(t?.inputTokens??0)>0?`${((t?.cacheReadTokens??0)/t.inputTokens*100).toFixed(0)}%`:"0%"})]})]})]})]}),e[11]=o,e[12]=i,e[13]=t,e[14]=d):d=e[14];let f;return e[15]!==c||e[16]!==u||e[17]!==d?(f=p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c,u,d]}),e[15]=c,e[16]=u,e[17]=d,e[18]=f):f=e[18],f}function QC(n){const e=_.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:o}=n,i=Math.min(r/s*100,100),l=Ko-i/100*Ko,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==i?(d=i.toFixed(0),e[0]=i,e[1]=d):d=e[1];let f;e[2]!==a?(f=a>0?`, $${a.toFixed(2)}`:"",e[2]=a,e[3]=f):f=e[3];const h=`Context usage: ${d}%${f}`,m=o?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=ee("flex items-center gap-1.5 text-muted-foreground hover:text-foreground h-6 px-1 shrink-0",m),e[4]=m,e[5]=g):g=e[5];let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("circle",{cx:Yt/2,cy:Yt/2,r:Oi,fill:"none",stroke:"currentColor",strokeWidth:Ii,className:"opacity-15"}),e[6]=x):x=e[6];const y=i>90?"text-destructive":i>70?"text-warning":"text-muted-foreground";let b;e[7]!==y?(b=ee(y),e[7]=y,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:Yt,height:Yt,className:"-rotate-90",children:[x,p.jsx("circle",{cx:Yt/2,cy:Yt/2,r:Oi,fill:"none",stroke:"currentColor",strokeWidth:Ii,strokeDasharray:Ko,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let S;e[12]!==i?(S=i.toFixed(0),e[12]=i,e[13]=S):S=e[13];let v;e[14]!==a?(v=a>0?` · $${a.toFixed(2)}`:"",e[14]=a,e[15]=v):v=e[15];let w;e[16]!==S||e[17]!==v?(w=p.jsxs("span",{className:"inline-block overflow-hidden whitespace-nowrap max-w-0 opacity-0 transition-[max-width,opacity] duration-200 ease-out @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100 text-[11px] font-mono tabular-nums",children:[S,"%",v]}),e[16]=S,e[17]=v,e[18]=w):w=e[18];let C;e[19]!==o||e[20]!==w||e[21]!==h||e[22]!==g||e[23]!==k?(C=p.jsx(fn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:o,"aria-label":h,className:g,children:[k,w]})}),e[19]=o,e[20]=w,e[21]=h,e[22]=g,e[23]=k,e[24]=C):C=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx("span",{className:"text-muted",children:"context"}),e[25]=T):T=e[25];let N;e[26]!==r?(N=r.toLocaleString(),e[26]=r,e[27]=N):N=e[27];let M;e[28]!==s?(M=s.toLocaleString(),e[28]=s,e[29]=M):M=e[29];let j;e[30]!==i?(j=i.toFixed(1),e[30]=i,e[31]=j):j=e[31];let R;e[32]!==N||e[33]!==M||e[34]!==j?(R=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",M," (",j,"%)"]}),e[32]=N,e[33]=M,e[34]=j,e[35]=R):R=e[35];let A;e[36]!==a||e[37]!==c||e[38]!==u?(A=a>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",a.toFixed(4)]}),p.jsx("span",{className:"text-muted",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:c.toLocaleString()}),p.jsx("span",{className:"text-muted",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:u.toLocaleString()})]}),e[36]=a,e[37]=c,e[38]=u,e[39]=A):A=e[39];let D;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(D=((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:c>0?`${((t?.cacheReadTokens??0)/c*100).toFixed(0)}%`:"0%"})]}),e[40]=c,e[41]=t?.cacheReadTokens,e[42]=t?.cacheWriteTokens,e[43]=D):D=e[43];let I;e[44]!==R||e[45]!==A||e[46]!==D?(I=p.jsx(hn,{side:"top",className:"font-mono text-[11px]",children:p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[T,R,A,D]})}),e[44]=R,e[45]=A,e[46]=D,e[47]=I):I=e[47];let $;return e[48]!==C||e[49]!==I?($=p.jsxs(pn,{children:[C,I]}),e[48]=C,e[49]=I,e[50]=$):$=e[50],$}var ho="Collapsible",[AS,ZC]=Gc(ho),[jS,Bl]=AS(ho),ph=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=ep({prop:r,defaultProp:s??!1,onChange:i,caller:ho});return p.jsx(jS,{scope:t,disabled:o,contentId:tp(),open:a,onOpenToggle:E.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Ut.div,{"data-state":Wl(a),"data-disabled":o?"":void 0,...l,ref:e})})});ph.displayName=ho;var mh="CollapsibleTrigger",Fl=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=Bl(mh,t);return p.jsx(Ut.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Wl(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:_t(n.onClick,s.onOpenToggle)})});Fl.displayName=mh;var Hl="CollapsibleContent",Vl=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Bl(Hl,n.__scopeCollapsible);return p.jsx(Nr,{present:t||s.open,children:({present:o})=>p.jsx(IS,{...r,ref:e,present:o})})});Vl.displayName=Hl;var IS=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=Bl(Hl,t),[l,a]=E.useState(r),c=E.useRef(null),u=kn(e,c),d=E.useRef(0),f=d.current,h=E.useRef(0),m=h.current,g=i.open||l,x=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),Jc(()=>{const b=c.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,x.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),a(r)}},[i.open,r]),p.jsx(Ut.div,{"data-state":Wl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:g&&s})});function Wl(n){return n?"open":"closed"}var OS=ph,eT=Fl,tT=Vl;function RS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(OS,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function DS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Fl,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function PS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Vl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function Z({icon:n,title:e,usage:t,latency:r,summary:s,state:o,detail:i,detailVariant:l="code",forceOpen:a,variant:c="default",trailing:u,iconDestructive:d,alwaysChevron:f,defaultOpen:h,children:m}){const[g,x]=E.useState(h??!1),{handleCopy:y,copied:b}=hu(),k=o==="loading",S=o==="error",w=!!(i&&i.trim())||!!m,C=c==="subtask",T=(a??!1)||g,N=Sm({initial:k?"instant":!1}),M=p.jsxs(RS,{open:T,onOpenChange:a?void 0:x,className:"min-w-0",children:[p.jsxs(DS,{disabled:!w,className:ee("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",w&&"[@media(hover:hover)]:hover:bg-accent/30",!w&&"cursor-default",k&&"shimmer"),"aria-disabled":!w,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(sa,{className:ee("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:ee("absolute inset-0 flex items-center justify-center [&>svg]:size-4 transition-opacity duration-150",d?"[&>svg]:text-destructive/70":S?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75",w&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),w&&p.jsx("div",{className:ee("absolute inset-0 flex items-center justify-center transition-opacity duration-150",T?"opacity-100":"opacity-0 [@media(hover:hover)]:group-hover/tool:opacity-100"),children:p.jsx(sa,{className:ee("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:ee("shrink-0 text-[14px] font-normal",S?"text-warning/80":"text-foreground"),children:e}),s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),u&&p.jsx("div",{className:"shrink-0 flex items-center gap-1 [&_svg]:size-3.5 [&_svg]:text-muted-foreground/50",children:u}),p.jsx(hh,{usage:t})]}),w&&p.jsx(PS,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:m||(l==="prose"?p.jsx("div",{className:"mt-1 mb-1",children:p.jsx("div",{ref:N.scrollRef,className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:p.jsx("p",{ref:N.contentRef,className:"text-xs text-muted-foreground/70 whitespace-pre-wrap leading-relaxed wrap-break-word",children:i})})}):p.jsx("div",{className:"ml-[20px] pl-3 border-l border-border/30 mt-0.5 pb-1",children:p.jsx("div",{ref:N.scrollRef,className:"flex flex-col max-h-48 overflow-y-auto",children:p.jsxs("div",{ref:N.contentRef,className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:i})}),p.jsx("button",{type:"button",onClick:()=>y(i),className:"shrink-0 p-1.5 rounded-md text-muted-foreground/50 [@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/50 transition-colors active:scale-[0.97]","aria-label":"Copy",children:b?p.jsx(qi,{className:"size-3.5"}):p.jsx(fu,{className:"size-3.5"})})]})})}))})]});return C?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:M}):M}function Ie(n){const e=_.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Ht(t),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r?(s=p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground",children:r}),e[2]=r,e[3]=s):s=e[3],s}const gh=4;function xh(n){const e=_.c(5),{count:t,noun:r,onClick:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(du,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==r||e[3]!==s?(i=p.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:["See all ",t," ",r,o]}),e[1]=t,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function yh(n){const e=_.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let o,i,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Ki(s);if(u===null){a=null;break e}const d=new Date(u);o=d.toLocaleString(),e[6]!==r?(i=ee("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=i):i=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=l,e[5]=a}else o=e[2],i=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==o||e[9]!==i||e[10]!==l?(c=p.jsx("span",{title:o,className:i,children:l}),e[8]=o,e[9]=i,e[10]=l,e[11]=c):c=e[11],c}function Ri(n){const e=_.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>oa(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,o]=E.useState(r);let i,l;e[2]!==t?(i=()=>{const d=setInterval(()=>o(oa(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=i,e[4]=l):(i=e[3],l=e[4]),E.useEffect(i,l);const a=s/1e3;let c;e[5]!==a?(c=Ht(a),e[5]=a,e[6]=c):c=e[6];let u;return e[7]!==c?(u=p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground/50",children:c}),e[7]=c,e[8]=u):u=e[8],u}const bh=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function LS(){const n=_.c(5),[e]=E.useState(_S);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={gridTemplateColumns:"repeat(3, 3px)",gap:"1.5px",width:"fit-content"},n[0]=t):t=n[0];let r;n[1]!==e?(r=bh.map((o,i)=>{const{delay:l}=o;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[i],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},i)}),n[1]=e,n[2]=r):r=n[2];let s;return n[3]!==r?(s=p.jsx("div",{className:"grid",style:t,children:r}),n[3]=r,n[4]=s):s=n[4],s}function _S(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return bh.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const $S={planning:{icon:p.jsx(kp,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves",detail:"Deciding how to approach the request"},thinking:{icon:p.jsx(Js,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},zS=1200;function Di(n){const e=_.c(9),{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==o||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(Z,{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:u,latency:a,trailing:c}),e[0]=o,e[1]=u,e[2]=t,e[3]=a,e[4]=i,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function BS(n){const e=_.c(17),{startedAt:t}=n,r=Wn()?.runStatusStage??null,[s,o]=E.useState("planning");let i,l;if(e[0]!==r?(i=()=>{if(r!==null)return;const f=setTimeout(()=>{o("thinking")},zS);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=i,e[2]=l):(i=e[1],l=e[2]),E.useEffect(i,l),r!==null){const f=Ip[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Js,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(Ri,{since:t}),e[4]=t,e[5]=g):g=e[5];let x;return e[6]!==f.detail||e[7]!==m||e[8]!==g?(x=p.jsx(Di,{icon:h,title:m,summary:f.detail,state:"loading",trailing:g}),e[6]=f.detail,e[7]=m,e[8]=g,e[9]=x):x=e[9],x}const a=$S[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(Ri,{since:t}),e[10]=t,e[11]=u):u=e[11];let d;return e[12]!==a.detail||e[13]!==a.icon||e[14]!==c||e[15]!==u?(d=p.jsx(Di,{icon:a.icon,title:c,summary:a.detail,state:"loading",trailing:u}),e[12]=a.detail,e[13]=a.icon,e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function FS(n){const e=_.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(LS,{}),e[0]=r):r=e[0];let s;return e[1]!==t?(s=p.jsxs("div",{className:"flex items-center gap-2.5 mt-1 pb-1 text-muted-foreground/40 select-none",children:[r,p.jsx(Ri,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const HS=2e4;function VS(n){const e=_.c(8),{startedAt:t}=n;ou(1e3);const r=Wn(),o=(t!==null?Date.now()-t:0)>=HS;let i;e[0]!==t?(i=p.jsx(BS,{startedAt:t}),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==o||e[3]!==r?(l=o&&r?.stop&&p.jsxs("div",{className:"flex items-center gap-2 pb-1 text-[13px] text-muted-foreground/60",children:[p.jsx("span",{children:"This is taking longer than usual."}),p.jsx("button",{type:"button",onClick:()=>r.stop(),className:"text-muted-foreground hover:text-foreground underline underline-offset-2",children:"Cancel"})]}),e[2]=o,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==i||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[i,l]}),e[5]=i,e[6]=l,e[7]=a):a=e[7],a}function WS(n){const e=_.c(20),{duration:t,parts:r,isStreaming:s}=n;let o;e[0]!==r?(o=r.every(KS),e[0]=r,e[1]=o):o=e[1];const i=o;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Ht(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==i||e[5]!==s||e[6]!==r){const k=r.map(qS).join(`
142
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=o=>{const i=bi(o,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:t.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(o)},s=bi(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,i)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:t.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},t);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});xe.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(rh.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(sh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(uh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(fh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(xS.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(yS.configure(this.options.taskList)),n}});var zc="&nbsp;",bS=" ",kS=_e.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Se(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return r.length===1&&r[0].type==="text"&&(r[0].text===zc||r[0].text===bS)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const o=Array.isArray(n.content)?n.content:[];if(o.length===0){const i=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&i.length===0?zc:""}return e.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),SS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,vS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,wS=vn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Se(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Bn({find:SS,type:this.type})]},addPasteRules(){return[bn({find:vS,type:this.type})]}}),CS=_e.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),TS=vn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Se(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),NS=xe.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(kk.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(mk.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(rh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(wk.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Nk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Mk.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(ck.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(uk.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Ek.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Ak.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(hk.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(jk.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Pk.configure(this.options.italic)),this.options.listItem!==!1&&s.push(sh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(uh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(iS.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(fh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(kS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(wS.configure(this.options.strike)),this.options.text!==!1&&s.push(CS.configure(this.options.text)),this.options.underline!==!1&&s.push(TS.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(fk.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),MS=NS;const Yt=16,Ii=2.5,Oi=(Yt-Ii)/2,Ko=2*Math.PI*Oi;function hh(n){const e=_.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:o,cost:i}=t;if(!r&&!s&&!o)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(yp,{size:12}),e[0]=l):l=e[0];let a;e[1]!==i||e[2]!==r?(a=i>0?`$${i.toFixed(4)}`:r.toLocaleString(),e[1]=i,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(fn,{asChild:!0,children:p.jsxs("span",{className:"inline-flex items-center text-muted-foreground [@media(hover:hover)]:hover:text-foreground pl-1 h-6 gap-1 whitespace-nowrap shrink-0 cursor-default",children:[l,p.jsx("span",{className:"text-sm font-mono tabular-nums",children:a})]})}),e[4]=a,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("p",{className:"text-muted text-[10px] mb-1",children:"tokens"}),e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("span",{className:"text-muted",children:"in"}),e[7]=d):d=e[7];let f;e[8]!==s?(f=s.toLocaleString(),e[8]=s,e[9]=f):f=e[9];let h;e[10]!==f?(h=p.jsx("span",{className:"text-right tabular-nums",children:f}),e[10]=f,e[11]=h):h=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("span",{className:"text-muted",children:"out"}),e[12]=m):m=e[12];const g=o-(t.reasoningTokens??0);let x;e[13]!==g?(x=g.toLocaleString(),e[13]=g,e[14]=x):x=e[14];let y;e[15]!==x?(y=p.jsx("span",{className:"text-right tabular-nums",children:x}),e[15]=x,e[16]=y):y=e[16];let b;e[17]!==s||e[18]!==t.cacheReadTokens||e[19]!==t.cacheWriteTokens?(b=(t.cacheReadTokens>0||t.cacheWriteTokens>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:s>0?`${(t.cacheReadTokens/s*100).toFixed(0)}%`:"0%"})]}),e[17]=s,e[18]=t.cacheReadTokens,e[19]=t.cacheWriteTokens,e[20]=b):b=e[20];let k;e[21]!==i?(k=i>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",i.toFixed(4)]})]}),e[21]=i,e[22]=k):k=e[22];let S;e[23]!==y||e[24]!==b||e[25]!==k||e[26]!==h?(S=p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[u,p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[d,h,m,y,b,k]})]}),e[23]=y,e[24]=b,e[25]=k,e[26]=h,e[27]=S):S=e[27];let v;return e[28]!==S||e[29]!==c?(v=p.jsxs(pn,{children:[c,S]}),e[28]=S,e[29]=c,e[30]=v):v=e[30],v}function ES(n){const e=_.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,o=t!=null&&(t.cost??0)>0,i=t!=null&&(t.totalTokens??0)>0;if(!s&&!o&&!i)return null;let l;e[0]!==r||e[1]!==s?(l=s?Ht(r/1e3):null,e[0]=r,e[1]=s,e[2]=l):l=e[2];const a=l;let c;e[3]!==r||e[4]!==a||e[5]!==t?(c=a&&p.jsxs(pn,{children:[p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:a})}),p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"thinking"}),p.jsx("span",{className:"tabular-nums",children:Ht(r/1e3)}),(t?.reasoningTokens??0)>0&&p.jsxs("span",{className:"ml-2 opacity-50",children:[t.reasoningTokens.toLocaleString()," tok"]})]})]}),e[3]=r,e[4]=a,e[5]=t,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==s||e[9]!==i?(u=s&&(o||i)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=o,e[8]=s,e[9]=i,e[10]=u):u=e[10];let d;e[11]!==o||e[12]!==i||e[13]!==t?(d=(o||i)&&p.jsxs(pn,{children:[p.jsx(fn,{asChild:!0,children:p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground cursor-default [@media(hover:hover)]:hover:text-foreground transition-colors select-none",children:o?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(hn,{side:"top",className:"font-mono text-[11px]",children:[p.jsx("p",{className:"opacity-60 text-[10px] mb-1",children:"tokens"}),p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[p.jsx("span",{className:"opacity-60",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:(t.inputTokens??0).toLocaleString()}),p.jsx("span",{className:"opacity-60",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:((t.outputTokens??0)-(t?.reasoningTokens??0)).toLocaleString()}),(t?.reasoningTokens??0)>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"think"}),p.jsx("span",{className:"text-right tabular-nums",children:t.reasoningTokens.toLocaleString()})]}),((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"opacity-60",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:(t?.inputTokens??0)>0?`${((t?.cacheReadTokens??0)/t.inputTokens*100).toFixed(0)}%`:"0%"})]})]})]})]}),e[11]=o,e[12]=i,e[13]=t,e[14]=d):d=e[14];let f;return e[15]!==c||e[16]!==u||e[17]!==d?(f=p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c,u,d]}),e[15]=c,e[16]=u,e[17]=d,e[18]=f):f=e[18],f}function ZC(n){const e=_.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:o}=n,i=Math.min(r/s*100,100),l=Ko-i/100*Ko,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==i?(d=i.toFixed(0),e[0]=i,e[1]=d):d=e[1];let f;e[2]!==a?(f=a>0?`, $${a.toFixed(2)}`:"",e[2]=a,e[3]=f):f=e[3];const h=`Context usage: ${d}%${f}`,m=o?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=ee("flex items-center gap-1.5 text-muted-foreground hover:text-foreground h-6 px-1 shrink-0",m),e[4]=m,e[5]=g):g=e[5];let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("circle",{cx:Yt/2,cy:Yt/2,r:Oi,fill:"none",stroke:"currentColor",strokeWidth:Ii,className:"opacity-15"}),e[6]=x):x=e[6];const y=i>90?"text-destructive":i>70?"text-warning":"text-muted-foreground";let b;e[7]!==y?(b=ee(y),e[7]=y,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:Yt,height:Yt,className:"-rotate-90",children:[x,p.jsx("circle",{cx:Yt/2,cy:Yt/2,r:Oi,fill:"none",stroke:"currentColor",strokeWidth:Ii,strokeDasharray:Ko,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let S;e[12]!==i?(S=i.toFixed(0),e[12]=i,e[13]=S):S=e[13];let v;e[14]!==a?(v=a>0?` · $${a.toFixed(2)}`:"",e[14]=a,e[15]=v):v=e[15];let w;e[16]!==S||e[17]!==v?(w=p.jsxs("span",{className:"inline-block overflow-hidden whitespace-nowrap max-w-0 opacity-0 transition-[max-width,opacity] duration-200 ease-out @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100 text-[11px] font-mono tabular-nums",children:[S,"%",v]}),e[16]=S,e[17]=v,e[18]=w):w=e[18];let C;e[19]!==o||e[20]!==w||e[21]!==h||e[22]!==g||e[23]!==k?(C=p.jsx(fn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:o,"aria-label":h,className:g,children:[k,w]})}),e[19]=o,e[20]=w,e[21]=h,e[22]=g,e[23]=k,e[24]=C):C=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx("span",{className:"text-muted",children:"context"}),e[25]=T):T=e[25];let N;e[26]!==r?(N=r.toLocaleString(),e[26]=r,e[27]=N):N=e[27];let M;e[28]!==s?(M=s.toLocaleString(),e[28]=s,e[29]=M):M=e[29];let j;e[30]!==i?(j=i.toFixed(1),e[30]=i,e[31]=j):j=e[31];let R;e[32]!==N||e[33]!==M||e[34]!==j?(R=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",M," (",j,"%)"]}),e[32]=N,e[33]=M,e[34]=j,e[35]=R):R=e[35];let A;e[36]!==a||e[37]!==c||e[38]!==u?(A=a>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",a.toFixed(4)]}),p.jsx("span",{className:"text-muted",children:"in"}),p.jsx("span",{className:"text-right tabular-nums",children:c.toLocaleString()}),p.jsx("span",{className:"text-muted",children:"out"}),p.jsx("span",{className:"text-right tabular-nums",children:u.toLocaleString()})]}),e[36]=a,e[37]=c,e[38]=u,e[39]=A):A=e[39];let D;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(D=((t?.cacheReadTokens??0)>0||(t?.cacheWriteTokens??0)>0)&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cache hit"}),p.jsx("span",{className:"text-right tabular-nums",children:c>0?`${((t?.cacheReadTokens??0)/c*100).toFixed(0)}%`:"0%"})]}),e[40]=c,e[41]=t?.cacheReadTokens,e[42]=t?.cacheWriteTokens,e[43]=D):D=e[43];let I;e[44]!==R||e[45]!==A||e[46]!==D?(I=p.jsx(hn,{side:"top",className:"font-mono text-[11px]",children:p.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[T,R,A,D]})}),e[44]=R,e[45]=A,e[46]=D,e[47]=I):I=e[47];let $;return e[48]!==C||e[49]!==I?($=p.jsxs(pn,{children:[C,I]}),e[48]=C,e[49]=I,e[50]=$):$=e[50],$}var ho="Collapsible",[AS,eT]=Gc(ho),[jS,Bl]=AS(ho),ph=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=n,[a,c]=ep({prop:r,defaultProp:s??!1,onChange:i,caller:ho});return p.jsx(jS,{scope:t,disabled:o,contentId:tp(),open:a,onOpenToggle:E.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Ut.div,{"data-state":Wl(a),"data-disabled":o?"":void 0,...l,ref:e})})});ph.displayName=ho;var mh="CollapsibleTrigger",Fl=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=Bl(mh,t);return p.jsx(Ut.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Wl(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:_t(n.onClick,s.onOpenToggle)})});Fl.displayName=mh;var Hl="CollapsibleContent",Vl=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Bl(Hl,n.__scopeCollapsible);return p.jsx(Nr,{present:t||s.open,children:({present:o})=>p.jsx(IS,{...r,ref:e,present:o})})});Vl.displayName=Hl;var IS=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...o}=n,i=Bl(Hl,t),[l,a]=E.useState(r),c=E.useRef(null),u=kn(e,c),d=E.useRef(0),f=d.current,h=E.useRef(0),m=h.current,g=i.open||l,x=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),Jc(()=>{const b=c.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,x.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),a(r)}},[i.open,r]),p.jsx(Ut.div,{"data-state":Wl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...n.style},children:g&&s})});function Wl(n){return n?"open":"closed"}var OS=ph,tT=Fl,nT=Vl;function RS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(OS,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function DS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Fl,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function PS(n){const e=_.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let r;return e[2]!==t?(r=p.jsx(Vl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function Z({icon:n,title:e,usage:t,latency:r,summary:s,state:o,detail:i,detailVariant:l="code",forceOpen:a,variant:c="default",trailing:u,iconDestructive:d,alwaysChevron:f,defaultOpen:h,children:m}){const[g,x]=E.useState(h??!1),{handleCopy:y,copied:b}=hu(),k=o==="loading",S=o==="error",w=!!(i&&i.trim())||!!m,C=c==="subtask",T=(a??!1)||g,N=Sm({initial:k?"instant":!1}),M=p.jsxs(RS,{open:T,onOpenChange:a?void 0:x,className:"min-w-0",children:[p.jsxs(DS,{disabled:!w,className:ee("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",w&&"[@media(hover:hover)]:hover:bg-accent/30",!w&&"cursor-default",k&&"shimmer"),"aria-disabled":!w,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(sa,{className:ee("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:ee("absolute inset-0 flex items-center justify-center [&>svg]:size-4 transition-opacity duration-150",d?"[&>svg]:text-destructive/70":S?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75",w&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),w&&p.jsx("div",{className:ee("absolute inset-0 flex items-center justify-center transition-opacity duration-150",T?"opacity-100":"opacity-0 [@media(hover:hover)]:group-hover/tool:opacity-100"),children:p.jsx(sa,{className:ee("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:ee("shrink-0 text-[14px] font-normal",S?"text-warning/80":"text-foreground"),children:e}),s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),u&&p.jsx("div",{className:"shrink-0 flex items-center gap-1 [&_svg]:size-3.5 [&_svg]:text-muted-foreground/50",children:u}),p.jsx(hh,{usage:t})]}),w&&p.jsx(PS,{className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden",children:m||(l==="prose"?p.jsx("div",{className:"mt-1 mb-1",children:p.jsx("div",{ref:N.scrollRef,className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:p.jsx("p",{ref:N.contentRef,className:"text-xs text-muted-foreground/70 whitespace-pre-wrap leading-relaxed wrap-break-word",children:i})})}):p.jsx("div",{className:"ml-[20px] pl-3 border-l border-border/30 mt-0.5 pb-1",children:p.jsx("div",{ref:N.scrollRef,className:"flex flex-col max-h-48 overflow-y-auto",children:p.jsxs("div",{ref:N.contentRef,className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:p.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:i})}),p.jsx("button",{type:"button",onClick:()=>y(i),className:"shrink-0 p-1.5 rounded-md text-muted-foreground/50 [@media(hover:hover)]:hover:text-foreground [@media(hover:hover)]:hover:bg-accent/50 transition-colors active:scale-[0.97]","aria-label":"Copy",children:b?p.jsx(qi,{className:"size-3.5"}):p.jsx(fu,{className:"size-3.5"})})]})})}))})]});return C?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:M}):M}function Ie(n){const e=_.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Ht(t),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r?(s=p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground",children:r}),e[2]=r,e[3]=s):s=e[3],s}const gh=4;function xh(n){const e=_.c(5),{count:t,noun:r,onClick:s}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(du,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=o):o=e[0];let i;return e[1]!==t||e[2]!==r||e[3]!==s?(i=p.jsxs("button",{type:"button",onClick:s,className:"group flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-card px-3 py-2.5 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:["See all ",t," ",r,o]}),e[1]=t,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function yh(n){const e=_.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let o,i,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Ki(s);if(u===null){a=null;break e}const d=new Date(u);o=d.toLocaleString(),e[6]!==r?(i=ee("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=i):i=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=o,e[3]=i,e[4]=l,e[5]=a}else o=e[2],i=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==o||e[9]!==i||e[10]!==l?(c=p.jsx("span",{title:o,className:i,children:l}),e[8]=o,e[9]=i,e[10]=l,e[11]=c):c=e[11],c}function Ri(n){const e=_.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>oa(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,o]=E.useState(r);let i,l;e[2]!==t?(i=()=>{const d=setInterval(()=>o(oa(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=i,e[4]=l):(i=e[3],l=e[4]),E.useEffect(i,l);const a=s/1e3;let c;e[5]!==a?(c=Ht(a),e[5]=a,e[6]=c):c=e[6];let u;return e[7]!==c?(u=p.jsx("span",{className:"tabular-nums text-sm font-mono text-muted-foreground/50",children:c}),e[7]=c,e[8]=u):u=e[8],u}const bh=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function LS(){const n=_.c(5),[e]=E.useState(_S);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t={gridTemplateColumns:"repeat(3, 3px)",gap:"1.5px",width:"fit-content"},n[0]=t):t=n[0];let r;n[1]!==e?(r=bh.map((o,i)=>{const{delay:l}=o;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[i],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},i)}),n[1]=e,n[2]=r):r=n[2];let s;return n[3]!==r?(s=p.jsx("div",{className:"grid",style:t,children:r}),n[3]=r,n[4]=s):s=n[4],s}function _S(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return bh.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const $S={planning:{icon:p.jsx(kp,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves",detail:"Deciding how to approach the request"},thinking:{icon:p.jsx(Js,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},zS=1200;function Di(n){const e=_.c(9),{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==o||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==i||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(Z,{icon:t,title:r,summary:s,detail:o,state:i,detailVariant:u,latency:a,trailing:c}),e[0]=o,e[1]=u,e[2]=t,e[3]=a,e[4]=i,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function BS(n){const e=_.c(17),{startedAt:t}=n,r=Wn()?.runStatusStage??null,[s,o]=E.useState("planning");let i,l;if(e[0]!==r?(i=()=>{if(r!==null)return;const f=setTimeout(()=>{o("thinking")},zS);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=i,e[2]=l):(i=e[1],l=e[2]),E.useEffect(i,l),r!==null){const f=Ip[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Js,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(Ri,{since:t}),e[4]=t,e[5]=g):g=e[5];let x;return e[6]!==f.detail||e[7]!==m||e[8]!==g?(x=p.jsx(Di,{icon:h,title:m,summary:f.detail,state:"loading",trailing:g}),e[6]=f.detail,e[7]=m,e[8]=g,e[9]=x):x=e[9],x}const a=$S[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(Ri,{since:t}),e[10]=t,e[11]=u):u=e[11];let d;return e[12]!==a.detail||e[13]!==a.icon||e[14]!==c||e[15]!==u?(d=p.jsx(Di,{icon:a.icon,title:c,summary:a.detail,state:"loading",trailing:u}),e[12]=a.detail,e[13]=a.icon,e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function FS(n){const e=_.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(LS,{}),e[0]=r):r=e[0];let s;return e[1]!==t?(s=p.jsxs("div",{className:"flex items-center gap-2.5 mt-1 pb-1 text-muted-foreground/40 select-none",children:[r,p.jsx(Ri,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const HS=2e4;function VS(n){const e=_.c(8),{startedAt:t}=n;ou(1e3);const r=Wn(),o=(t!==null?Date.now()-t:0)>=HS;let i;e[0]!==t?(i=p.jsx(BS,{startedAt:t}),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==o||e[3]!==r?(l=o&&r?.stop&&p.jsxs("div",{className:"flex items-center gap-2 pb-1 text-[13px] text-muted-foreground/60",children:[p.jsx("span",{children:"This is taking longer than usual."}),p.jsx("button",{type:"button",onClick:()=>r.stop(),className:"text-muted-foreground hover:text-foreground underline underline-offset-2",children:"Cancel"})]}),e[2]=o,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==i||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[i,l]}),e[5]=i,e[6]=l,e[7]=a):a=e[7],a}function WS(n){const e=_.c(20),{duration:t,parts:r,isStreaming:s}=n;let o;e[0]!==r?(o=r.every(KS),e[0]=r,e[1]=o):o=e[1];const i=o;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Ht(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==i||e[5]!==s||e[6]!==r){const k=r.map(qS).join(`
143
143
  `).trim().split(`
144
144
  `).filter(Boolean),S=s?k[k.length-1]??"":k[0]??"";c=!i&&S?S.length>100?S.slice(0,100)+"…":S:void 0,e[4]=i,e[5]=s,e[6]=r,e[7]=c}else c=e[7];const u=c;let d;if(e[8]!==i||e[9]!==r){const b=r.map(US).join(`
145
145
 
@@ -178,11 +178,11 @@ Output: Tool execution was denied`)}}}return t.length>0?t.join(`
178
178
  `+z)):a!==void 0&&(F&&(F=F+`
179
179
 
180
180
  `),F=F+(`# Output
181
- `+Ws(a)));let U;e[40]===Symbol.for("react.memo_cache_sentinel")?(U=p.jsx(Rr,{size:14}),e[40]=U):U=e[40];const Y=i==="error"?"Failed":"No images generated",K=i==="error"?"error":"idle",Q=F||null;let ne;e[41]!==$||e[42]!==Y||e[43]!==K||e[44]!==Q||e[45]!==d?(ne=p.jsx(Z,{icon:U,title:"Image generation",summary:Y,state:K,usage:d,trailing:$,detail:Q}),e[41]=$,e[42]=Y,e[43]=K,e[44]=Q,e[45]=d,e[46]=ne):ne=e[46],y=ne;break e}x="flex flex-col gap-2",h=Z,e[47]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(Rr,{size:14,className:"text-pink-500"}),e[47]=v):v=e[47],w="Generated image",C=f,T="idle",m=d,g=$,b="flex flex-col gap-1 pb-2 pl-6",e[48]!==l?(k=l?.prompt&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:l.prompt}),e[48]=l,e[49]=k):k=e[49],S=D&&D.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"references:"}),D.map((L,z)=>{const F=L.uri??L.url;return p.jsx(x2,{uri:F,orgSlug:s.slug},z)})]})}e[4]=c,e[5]=l,e[6]=r,e[7]=f,e[8]=s,e[9]=t,e[10]=a,e[11]=i,e[12]=d,e[13]=h,e[14]=m,e[15]=g,e[16]=x,e[17]=y,e[18]=b,e[19]=k,e[20]=S,e[21]=v,e[22]=w,e[23]=C,e[24]=T}else h=e[13],m=e[14],g=e[15],x=e[16],y=e[17],b=e[18],k=e[19],S=e[20],v=e[21],w=e[22],C=e[23],T=e[24];if(y!==Symbol.for("react.early_return_sentinel"))return y;let N;e[50]!==b||e[51]!==k||e[52]!==S?(N=p.jsxs("div",{className:b,children:[k,S]}),e[50]=b,e[51]=k,e[52]=S,e[53]=N):N=e[53];let M;e[54]!==h||e[55]!==m||e[56]!==g||e[57]!==N||e[58]!==v||e[59]!==w||e[60]!==C||e[61]!==T?(M=p.jsx(h,{icon:v,title:w,summary:C,state:T,usage:m,trailing:g,children:N}),e[54]=h,e[55]=m,e[56]=g,e[57]=N,e[58]=v,e[59]=w,e[60]=C,e[61]=T,e[62]=M):M=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let D;e[67]!==l?.prompt||e[68]!==s?(D=(I,$)=>{const L=I.uri??I.url;if(!L)return null;const z=Sh(L,s.slug);return p.jsx(pu,{src:z,alt:l?.prompt??"Generated image",children:p.jsx("img",{src:z,alt:l?.prompt??"Generated image",className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"})},$)},e[67]=l?.prompt,e[68]=s,e[69]=D):D=e[69],j=c.map(D),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let R;e[70]!==j?(R=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=R):R=e[71];let A;return e[72]!==x||e[73]!==M||e[74]!==R?(A=p.jsxs("div",{className:x,children:[M,R]}),e[72]=x,e[73]=M,e[74]=R,e[75]=A):A=e[75],A}function b2(n){return n.uri??n.url}function k2(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function S2(n){const e=_.c(26),{part:t,latency:r}=n,s=Bi(),o=ot(t.state),i=t.input,l=t.output,a=l?.image?.uri,c=l?.url??i?.url;let u;e[0]!==r?(u=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(o==="loading"){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(nr,{size:14}),e[2]=v):v=e[2];let w;return e[3]!==c?(w=p.jsx(Z,{icon:v,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=w):w=e[4],w}if(o==="error"||l?.success===!1||!a){let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(nr,{size:14}),e[5]=v):v=e[5];const w=l?.error??"Failed";let C;return e[6]!==d||e[7]!==w?(C=p.jsx(Z,{icon:v,title:"Take screenshot",summary:w,state:"error",trailing:d}),e[6]=d,e[7]=w,e[8]=C):C=e[8],C}let f;e[9]!==s.slug||e[10]!==a?(f=k2(a,s.slug),e[9]=s.slug,e[10]=a,e[11]=f):f=e[11];const h=f;let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(nr,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(Z,{icon:m,title:"Screenshot",summary:c,state:"idle",trailing:d}),e[13]=d,e[14]=c,e[15]=g):g=e[15];const x=c??"Screenshot",y=c??"Screenshot";let b;e[16]!==h||e[17]!==y?(b=p.jsx("img",{src:h,alt:y,className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"}),e[16]=h,e[17]=y,e[18]=b):b=e[18];let k;e[19]!==h||e[20]!==x||e[21]!==b?(k=p.jsx("div",{className:"flex flex-wrap gap-2",children:p.jsx(pu,{src:h,alt:x,children:b})}),e[19]=h,e[20]=x,e[21]=b,e[22]=k):k=e[22];let S;return e[23]!==g||e[24]!==k?(S=p.jsxs("div",{className:"flex flex-col gap-2",children:[g,k]}),e[23]=g,e[24]=k,e[25]=S):S=e[25],S}function v2(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function w2(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;if(!r)return null;const s={providerMetadata:n.usage.providerMetadata};return{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:Su(s),cacheReadTokens:0,cacheWriteTokens:0}}function C2(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function T2(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function N2(n){const e=_.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=C2(t.url),e[0]=t.url,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.url?(i=T2(t.url),e[2]=t.url,e[3]=i):i=e[3];const l=i,a=t.title||o;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:M2}),e[4]=l,e[5]=c):c=e[5];let u;e[6]!==a?(u=p.jsx("span",{className:"truncate max-w-[180px]",children:a}),e[6]=a,e[7]=u):u=e[7];const d=r+1;let f;e[8]!==d?(f=p.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0",children:["[",d,"]"]}),e[8]=d,e[9]=f):f=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(bu,{size:10,className:"shrink-0 opacity-0 group-hover/src:opacity-100 transition-opacity"}),e[10]=h):h=e[10];let m;return e[11]!==t.url||e[12]!==c||e[13]!==u||e[14]!==f?(m=p.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"group/src inline-flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:[c,u,f,h]}),e[11]=t.url,e[12]=c,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function M2(n){n.target.style.display="none"}function E2(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,o=e[s];return o?`[\\[${r}\\]](${o.url})`:t})}const Jo=5;function A2(n){const e=_.c(12),{citations:t}=n,[r,s]=E.useState(!1),o=t.length>Jo;let i;e[0]!==t||e[1]!==r?(i=r?t:t.slice(0,Jo),e[0]=t,e[1]=r,e[2]=i):i=e[2];const l=i;let a;e[3]!==l?(a=l.map(I2),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==o?(c=o&&p.jsx("button",{type:"button",onClick:()=>s(j2),className:"inline-flex items-center rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:r?"show less":`+${t.length-Jo} more`}),e[5]=t.length,e[6]=r,e[7]=o,e[8]=c):c=e[8];let u;return e[9]!==a||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a,c]}),e[9]=a,e[10]=c,e[11]=u):u=e[11],u}function j2(n){return!n}function I2(n,e){return p.jsx(N2,{citation:n,index:e},n.url)}function O2(n){const e=_.c(51),{part:t,latency:r,streamingText:s}=n,o=Bi();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i,a=t.input,c=t.output;let u,d,f;e[2]!==o||e[3]!==c?(u=c?.uri?v2(c.uri,o.slug):void 0,f=Mr,d=Qe.webSearchBlob(u??""),e[2]=o,e[3]=c,e[4]=u,e[5]=d,e[6]=f):(u=e[4],d=e[5],f=e[6]);let h;e[7]!==u?(h=async()=>{const K=await fetch(u);if(!K.ok)throw new Error(`Failed to fetch: ${K.status}`);return K.text()},e[7]=u,e[8]=h):h=e[8];const m=!!u;let g;e[9]!==d||e[10]!==h||e[11]!==m?(g={queryKey:d,queryFn:h,enabled:m,staleTime:1/0},e[9]=d,e[10]=h,e[11]=m,e[12]=g):g=e[12];const{data:x}=f(g),y=l==="loading",b=l!=="loading"&&l!=="error",k=c?.citations;let S;e[13]!==c?(S=w2(c),e[13]=c,e[14]=S):S=e[14];const v=S,w=c?.content??x??s;let C;e[15]!==k||e[16]!==w?(C=w&&k?.length?E2(w,k):w,e[15]=k,e[16]=w,e[17]=C):C=e[17];const T=C;let N;e[18]!==r?(N=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[18]=r,e[19]=N):N=e[19];const M=N;if(l==="error"){let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(es,{size:14}),e[20]=K):K=e[20];let Q;return e[21]!==M||e[22]!==v?(Q=p.jsx(Z,{icon:K,title:"Web search",summary:"Failed",state:"error",usage:v,trailing:M}),e[21]=M,e[22]=v,e[23]=Q):Q=e[23],Q}const j=y?"animate-pulse":"text-blue-500";let R;e[24]!==j?(R=ee(j),e[24]=j,e[25]=R):R=e[25];let A;e[26]!==R?(A=p.jsx(es,{size:14,className:R}),e[26]=R,e[27]=A):A=e[27];const D=y?"Researching...":"Web search";let I;e[28]!==a||e[29]!==b||e[30]!==c?.model?(I=b?c?.model??a?.query?.slice(0,60):a?.query?`"${a.query.slice(0,80)}"`:void 0,e[28]=a,e[29]=b,e[30]=c?.model,e[31]=I):I=e[31];const $=y?"loading":"idle";let L;e[32]!==a?(L=a?.query&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:a.query}),e[32]=a,e[33]=L):L=e[33];let z;e[34]!==T||e[35]!==t.toolCallId?(z=T?p.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-hidden rounded-lg border border-border/40 bg-muted/20 px-4 py-3 min-w-0",children:p.jsx("div",{className:"prose prose-sm prose-neutral dark:prose-invert max-w-none text-[13px] leading-relaxed break-words",children:p.jsx(Ji,{id:t.toolCallId,text:T})})}):p.jsx("div",{className:"rounded-lg border border-border/40 bg-muted/20 px-4 py-3",children:p.jsxs("div",{className:"space-y-2 animate-pulse",children:[p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-3/4"}),p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-1/2"})]})}),e[34]=T,e[35]=t.toolCallId,e[36]=z):z=e[36];let F;e[37]!==k?(F=k&&k.length>0&&p.jsx(A2,{citations:k}),e[37]=k,e[38]=F):F=e[38];let U;e[39]!==L||e[40]!==z||e[41]!==F?(U=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[L,z,F]}),e[39]=L,e[40]=z,e[41]=F,e[42]=U):U=e[42];let Y;return e[43]!==M||e[44]!==A||e[45]!==D||e[46]!==I||e[47]!==$||e[48]!==U||e[49]!==v?(Y=p.jsx(Z,{icon:A,title:D,summary:I,state:$,usage:v,trailing:M,defaultOpen:!0,children:U}),e[43]=M,e[44]=A,e[45]=D,e[46]=I,e[47]=$,e[48]=U,e[49]=v,e[50]=Y):Y=e[50],Y}function R2(n){const e=_.c(14),{part:t}=n;if(!t.state.startsWith("output-"))return null;let r;e[0]!==t.input?.prompt?(r=t.input?.prompt?.trim()||"Question",e[0]=t.input?.prompt,e[1]=r):r=e[1];const s=r,o=t.state==="output-error"||t.state==="output-denied",i=t.state==="output-denied";let l;e[2]!==i||e[3]!==t?(l=i?"Skipped":t.state==="output-error"?po(t)??"Error":t.output?.response??"",e[2]=i,e[3]=t,e[4]=l):l=e[4];const a=l;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(xp,{className:"size-4 text-muted-foreground/50 shrink-0 mt-0.5"}),e[5]=c):c=e[5];let u;e[6]!==s?(u=p.jsxs("div",{className:"flex items-start gap-2",children:[c,p.jsx("span",{className:"text-[14px] text-muted-foreground leading-snug",children:s})]}),e[6]=s,e[7]=u):u=e[7];let d;e[8]!==a||e[9]!==o?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:ee("text-[14px] leading-snug",o?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13],f}const vh=E.createContext(new Map);function nT(n){const e=_.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const i of t){const l=i.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(i):s.set(l,[i])}e[0]=t,e[1]=s}else s=e[1];let o;return e[2]!==s||e[3]!==r?(o=p.jsx(vh.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function D2(n){const e=_.c(3),t=E.useContext(vh);let r;return e[0]!==n||e[1]!==t?(r=n?t.get(n)??[]:[],e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function P2(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:o,value:i}=await t.read();if(o)break;s+=r.decode(i,{stream:!0});let l;for(;(l=s.indexOf(`
181
+ `+Ws(a)));let U;e[40]===Symbol.for("react.memo_cache_sentinel")?(U=p.jsx(Rr,{size:14}),e[40]=U):U=e[40];const Y=i==="error"?"Failed":"No images generated",K=i==="error"?"error":"idle",Q=F||null;let ne;e[41]!==$||e[42]!==Y||e[43]!==K||e[44]!==Q||e[45]!==d?(ne=p.jsx(Z,{icon:U,title:"Image generation",summary:Y,state:K,usage:d,trailing:$,detail:Q}),e[41]=$,e[42]=Y,e[43]=K,e[44]=Q,e[45]=d,e[46]=ne):ne=e[46],y=ne;break e}x="flex flex-col gap-2",h=Z,e[47]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(Rr,{size:14,className:"text-pink-500"}),e[47]=v):v=e[47],w="Generated image",C=f,T="idle",m=d,g=$,b="flex flex-col gap-1 pb-2 pl-6",e[48]!==l?(k=l?.prompt&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:l.prompt}),e[48]=l,e[49]=k):k=e[49],S=D&&D.length>0&&p.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[p.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"references:"}),D.map((L,z)=>{const F=L.uri??L.url;return p.jsx(x2,{uri:F,orgSlug:s.slug},z)})]})}e[4]=c,e[5]=l,e[6]=r,e[7]=f,e[8]=s,e[9]=t,e[10]=a,e[11]=i,e[12]=d,e[13]=h,e[14]=m,e[15]=g,e[16]=x,e[17]=y,e[18]=b,e[19]=k,e[20]=S,e[21]=v,e[22]=w,e[23]=C,e[24]=T}else h=e[13],m=e[14],g=e[15],x=e[16],y=e[17],b=e[18],k=e[19],S=e[20],v=e[21],w=e[22],C=e[23],T=e[24];if(y!==Symbol.for("react.early_return_sentinel"))return y;let N;e[50]!==b||e[51]!==k||e[52]!==S?(N=p.jsxs("div",{className:b,children:[k,S]}),e[50]=b,e[51]=k,e[52]=S,e[53]=N):N=e[53];let M;e[54]!==h||e[55]!==m||e[56]!==g||e[57]!==N||e[58]!==v||e[59]!==w||e[60]!==C||e[61]!==T?(M=p.jsx(h,{icon:v,title:w,summary:C,state:T,usage:m,trailing:g,children:N}),e[54]=h,e[55]=m,e[56]=g,e[57]=N,e[58]=v,e[59]=w,e[60]=C,e[61]=T,e[62]=M):M=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let D;e[67]!==l?.prompt||e[68]!==s?(D=(I,$)=>{const L=I.uri??I.url;if(!L)return null;const z=Sh(L,s.slug);return p.jsx(pu,{src:z,alt:l?.prompt??"Generated image",children:p.jsx("img",{src:z,alt:l?.prompt??"Generated image",className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"})},$)},e[67]=l?.prompt,e[68]=s,e[69]=D):D=e[69],j=c.map(D),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let R;e[70]!==j?(R=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=R):R=e[71];let A;return e[72]!==x||e[73]!==M||e[74]!==R?(A=p.jsxs("div",{className:x,children:[M,R]}),e[72]=x,e[73]=M,e[74]=R,e[75]=A):A=e[75],A}function b2(n){return n.uri??n.url}function k2(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function S2(n){const e=_.c(26),{part:t,latency:r}=n,s=Bi(),o=ot(t.state),i=t.input,l=t.output,a=l?.image?.uri,c=l?.url??i?.url;let u;e[0]!==r?(u=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(o==="loading"){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(nr,{size:14}),e[2]=v):v=e[2];let w;return e[3]!==c?(w=p.jsx(Z,{icon:v,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=w):w=e[4],w}if(o==="error"||l?.success===!1||!a){let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(nr,{size:14}),e[5]=v):v=e[5];const w=l?.error??"Failed";let C;return e[6]!==d||e[7]!==w?(C=p.jsx(Z,{icon:v,title:"Take screenshot",summary:w,state:"error",trailing:d}),e[6]=d,e[7]=w,e[8]=C):C=e[8],C}let f;e[9]!==s.slug||e[10]!==a?(f=k2(a,s.slug),e[9]=s.slug,e[10]=a,e[11]=f):f=e[11];const h=f;let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(nr,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(Z,{icon:m,title:"Screenshot",summary:c,state:"idle",trailing:d}),e[13]=d,e[14]=c,e[15]=g):g=e[15];const x=c??"Screenshot",y=c??"Screenshot";let b;e[16]!==h||e[17]!==y?(b=p.jsx("img",{src:h,alt:y,className:"max-w-sm max-h-80 object-contain rounded-lg border border-border hover:border-foreground/20 transition-colors"}),e[16]=h,e[17]=y,e[18]=b):b=e[18];let k;e[19]!==h||e[20]!==x||e[21]!==b?(k=p.jsx("div",{className:"flex flex-wrap gap-2",children:p.jsx(pu,{src:h,alt:x,children:b})}),e[19]=h,e[20]=x,e[21]=b,e[22]=k):k=e[22];let S;return e[23]!==g||e[24]!==k?(S=p.jsxs("div",{className:"flex flex-col gap-2",children:[g,k]}),e[23]=g,e[24]=k,e[25]=S):S=e[25],S}function v2(n,e){const t=mo(n);return t!==null?`/api/${e}/files/${t}`:n}function w2(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;if(!r)return null;const s={providerMetadata:n.usage.providerMetadata};return{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:Su(s),cacheReadTokens:0,cacheWriteTokens:0}}function C2(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function T2(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function N2(n){const e=_.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=C2(t.url),e[0]=t.url,e[1]=s):s=e[1];const o=s;let i;e[2]!==t.url?(i=T2(t.url),e[2]=t.url,e[3]=i):i=e[3];const l=i,a=t.title||o;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:M2}),e[4]=l,e[5]=c):c=e[5];let u;e[6]!==a?(u=p.jsx("span",{className:"truncate max-w-[180px]",children:a}),e[6]=a,e[7]=u):u=e[7];const d=r+1;let f;e[8]!==d?(f=p.jsxs("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0",children:["[",d,"]"]}),e[8]=d,e[9]=f):f=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(bu,{size:10,className:"shrink-0 opacity-0 group-hover/src:opacity-100 transition-opacity"}),e[10]=h):h=e[10];let m;return e[11]!==t.url||e[12]!==c||e[13]!==u||e[14]!==f?(m=p.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"group/src inline-flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:[c,u,f,h]}),e[11]=t.url,e[12]=c,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function M2(n){n.target.style.display="none"}function E2(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,o=e[s];return o?`[\\[${r}\\]](${o.url})`:t})}const Jo=5;function A2(n){const e=_.c(12),{citations:t}=n,[r,s]=E.useState(!1),o=t.length>Jo;let i;e[0]!==t||e[1]!==r?(i=r?t:t.slice(0,Jo),e[0]=t,e[1]=r,e[2]=i):i=e[2];const l=i;let a;e[3]!==l?(a=l.map(I2),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==o?(c=o&&p.jsx("button",{type:"button",onClick:()=>s(j2),className:"inline-flex items-center rounded-md border border-border/50 bg-muted/30 px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:border-border hover:text-foreground",children:r?"show less":`+${t.length-Jo} more`}),e[5]=t.length,e[6]=r,e[7]=o,e[8]=c):c=e[8];let u;return e[9]!==a||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[a,c]}),e[9]=a,e[10]=c,e[11]=u):u=e[11],u}function j2(n){return!n}function I2(n,e){return p.jsx(N2,{citation:n,index:e},n.url)}function O2(n){const e=_.c(51),{part:t,latency:r,streamingText:s}=n,o=Bi();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i,a=t.input,c=t.output;let u,d,f;e[2]!==o||e[3]!==c?(u=c?.uri?v2(c.uri,o.slug):void 0,f=Mr,d=Qe.webSearchBlob(u??""),e[2]=o,e[3]=c,e[4]=u,e[5]=d,e[6]=f):(u=e[4],d=e[5],f=e[6]);let h;e[7]!==u?(h=async()=>{const K=await fetch(u);if(!K.ok)throw new Error(`Failed to fetch: ${K.status}`);return K.text()},e[7]=u,e[8]=h):h=e[8];const m=!!u;let g;e[9]!==d||e[10]!==h||e[11]!==m?(g={queryKey:d,queryFn:h,enabled:m,staleTime:1/0},e[9]=d,e[10]=h,e[11]=m,e[12]=g):g=e[12];const{data:x}=f(g),y=l==="loading",b=l!=="loading"&&l!=="error",k=c?.citations;let S;e[13]!==c?(S=w2(c),e[13]=c,e[14]=S):S=e[14];const v=S,w=c?.content??x??s;let C;e[15]!==k||e[16]!==w?(C=w&&k?.length?E2(w,k):w,e[15]=k,e[16]=w,e[17]=C):C=e[17];const T=C;let N;e[18]!==r?(N=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ht(r)}):null,e[18]=r,e[19]=N):N=e[19];const M=N;if(l==="error"){let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx(es,{size:14}),e[20]=K):K=e[20];let Q;return e[21]!==M||e[22]!==v?(Q=p.jsx(Z,{icon:K,title:"Web search",summary:"Failed",state:"error",usage:v,trailing:M}),e[21]=M,e[22]=v,e[23]=Q):Q=e[23],Q}const j=y?"animate-pulse":"text-blue-500";let R;e[24]!==j?(R=ee(j),e[24]=j,e[25]=R):R=e[25];let A;e[26]!==R?(A=p.jsx(es,{size:14,className:R}),e[26]=R,e[27]=A):A=e[27];const D=y?"Researching...":"Web search";let I;e[28]!==a||e[29]!==b||e[30]!==c?.model?(I=b?c?.model??a?.query?.slice(0,60):a?.query?`"${a.query.slice(0,80)}"`:void 0,e[28]=a,e[29]=b,e[30]=c?.model,e[31]=I):I=e[31];const $=y?"loading":"idle";let L;e[32]!==a?(L=a?.query&&p.jsx("p",{className:"text-xs text-muted-foreground/70 whitespace-pre-wrap wrap-break-word",children:a.query}),e[32]=a,e[33]=L):L=e[33];let z;e[34]!==T||e[35]!==t.toolCallId?(z=T?p.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-hidden rounded-lg border border-border/40 bg-muted/20 px-4 py-3 min-w-0",children:p.jsx("div",{className:"prose prose-sm prose-neutral dark:prose-invert max-w-none text-[13px] leading-relaxed break-words",children:p.jsx(Ji,{id:t.toolCallId,text:T})})}):p.jsx("div",{className:"rounded-lg border border-border/40 bg-muted/20 px-4 py-3",children:p.jsxs("div",{className:"space-y-2 animate-pulse",children:[p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-3/4"}),p.jsx("div",{className:"h-3 rounded bg-muted-foreground/10 w-1/2"})]})}),e[34]=T,e[35]=t.toolCallId,e[36]=z):z=e[36];let F;e[37]!==k?(F=k&&k.length>0&&p.jsx(A2,{citations:k}),e[37]=k,e[38]=F):F=e[38];let U;e[39]!==L||e[40]!==z||e[41]!==F?(U=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[L,z,F]}),e[39]=L,e[40]=z,e[41]=F,e[42]=U):U=e[42];let Y;return e[43]!==M||e[44]!==A||e[45]!==D||e[46]!==I||e[47]!==$||e[48]!==U||e[49]!==v?(Y=p.jsx(Z,{icon:A,title:D,summary:I,state:$,usage:v,trailing:M,defaultOpen:!0,children:U}),e[43]=M,e[44]=A,e[45]=D,e[46]=I,e[47]=$,e[48]=U,e[49]=v,e[50]=Y):Y=e[50],Y}function R2(n){const e=_.c(14),{part:t}=n;if(!t.state.startsWith("output-"))return null;let r;e[0]!==t.input?.prompt?(r=t.input?.prompt?.trim()||"Question",e[0]=t.input?.prompt,e[1]=r):r=e[1];const s=r,o=t.state==="output-error"||t.state==="output-denied",i=t.state==="output-denied";let l;e[2]!==i||e[3]!==t?(l=i?"Skipped":t.state==="output-error"?po(t)??"Error":t.output?.response??"",e[2]=i,e[3]=t,e[4]=l):l=e[4];const a=l;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(xp,{className:"size-4 text-muted-foreground/50 shrink-0 mt-0.5"}),e[5]=c):c=e[5];let u;e[6]!==s?(u=p.jsxs("div",{className:"flex items-start gap-2",children:[c,p.jsx("span",{className:"text-[14px] text-muted-foreground leading-snug",children:s})]}),e[6]=s,e[7]=u):u=e[7];let d;e[8]!==a||e[9]!==o?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:ee("text-[14px] leading-snug",o?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13],f}const vh=E.createContext(new Map);function rT(n){const e=_.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const i of t){const l=i.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(i):s.set(l,[i])}e[0]=t,e[1]=s}else s=e[1];let o;return e[2]!==s||e[3]!==r?(o=p.jsx(vh.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function D2(n){const e=_.c(3),t=E.useContext(vh);let r;return e[0]!==n||e[1]!==t?(r=n?t.get(n)??[]:[],e[0]=n,e[1]=t,e[2]=r):r=e[2],r}function P2(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:o,value:i}=await t.read();if(o)break;s+=r.decode(i,{stream:!0});let l;for(;(l=s.indexOf(`
182
182
 
183
183
  `))!==-1;){const a=s.slice(0,l);s=s.slice(l+2);const c=a.split(`
184
184
  `).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trim()).join(`
185
185
  `);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{t.releaseLock(),e.close()}}})}function L2(n){const{orgSlug:e,threadId:t,jobId:r,enabled:s}=n,[o,i]=E.useState([]),[l,a]=E.useState(!1);return E.useEffect(()=>{if(!s||!r)return;const c=new AbortController;return i([]),a(!0),(async()=>{try{const u=await fetch(`/api/${encodeURIComponent(e)}/decopilot/threads/${encodeURIComponent(t)}/jobs/${encodeURIComponent(r)}/stream`,{headers:{accept:"text/event-stream"},credentials:"include",signal:c.signal});if(!u.ok||!u.body)return;for await(const d of Rp({stream:Dp(P2(u.body),void 0)})){if(c.signal.aborted)return;i([d])}}catch{}finally{c.signal.aborted||a(!1)}})(),()=>c.abort()},[s,r,t,e]),{messages:o,streaming:l}}function _2(n){if(n&&typeof n=="object"&&!Array.isArray(n)){const e=n;if(typeof e.text=="string"||typeof e.error=="string"||typeof e.finishReason=="string"){if(typeof e.error=="string"&&e.error.length>0)return`Subtask failed: ${e.error}`;const r=typeof e.text=="string"?e.text.trim():"",s=e.finishReason==="length";return r?(s?`[Subtask hit step limit — partial result below; consider narrowing the task.]
186
186
 
187
187
  `:"")+r:s?"[Subtask hit step limit before producing a final report. The subagent did work but ran out of steps. Narrow the task or increase the budget.]":"Subtask completed (no output)."}}return i2(n)}function wh(n){return!!n&&typeof n=="object"&&n.background===!0}function Ch({part:n,subtaskMeta:e}){const t=n.state==="input-streaming"||n.state==="input-available",r=n.state==="output-available"&&n.preliminary===!0,s=n.state==="output-available"&&!n.preliminary,o=n.state==="output-error",i=ot(n.state,"preliminary"in n?n.preliminary:!1),l=i==="approval"?"idle":i,a=t?"Starting subtask...":r?"Subtask running...":s?"Subtask completed":o?"Subtask failed":"Subtask",c=n.input?.prompt??"",u=n.state==="approval-requested"?"Awaiting approval...":c.length>120?c.slice(0,120)+"…":c;return{fallbackTitle:a,summary:u,usage:e?.usage,state:l}}function Ul(n){const e=_.c(45),{icon:t,title:r,summary:s,state:o,usage:i,onOpenChange:l,children:a}=n,[c,u]=E.useState(!1);let d;e[0]!==l?(d=z=>{u(z),l?.(z)},e[0]=l,e[1]=d):d=e[1];const f=d,h=o==="loading",m=o==="error";let g;e[2]!==f?(g=()=>f(!0),e[2]=f,e[3]=g):g=e[3];const x=h&&"shimmer";let y;e[4]!==x?(y=ee("group/tool flex items-center gap-2 w-full py-2.5 text-left rounded-md transition-colors","[@media(hover:hover)]:hover:bg-accent/30",x),e[4]=x,e[5]=y):y=e[5];const b=m?"[&>svg]:text-warning/70":"[&>svg]:text-muted-foreground/75";let k;e[6]!==b?(k=ee("relative shrink-0 size-4 flex items-center justify-center [&>svg]:size-4",b),e[6]=b,e[7]=k):k=e[7];let S;e[8]!==t||e[9]!==k?(S=p.jsx("div",{className:k,children:t}),e[8]=t,e[9]=k,e[10]=S):S=e[10];const v=m?"text-warning/80":"text-foreground";let w;e[11]!==v?(w=ee("shrink-0 text-[14px] font-normal",v),e[11]=v,e[12]=w):w=e[12];let C;e[13]!==w||e[14]!==r?(C=p.jsx("span",{className:w,children:r}),e[13]=w,e[14]=r,e[15]=C):C=e[15];let T;e[16]!==s?(T=s?p.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.jsx("span",{className:"text-[12px] text-muted-foreground/60 bg-muted/50 rounded-[3px] px-1 py-px leading-none",children:s})}):p.jsx("div",{className:"flex-1"}),e[16]=s,e[17]=T):T=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx(em,{className:"size-3.5 shrink-0 text-muted-foreground/40 opacity-0 transition-opacity [@media(hover:hover)]:group-hover/tool:opacity-100"}),e[18]=N):N=e[18];let M;e[19]!==i?(M=p.jsx(hh,{usage:i}),e[19]=i,e[20]=M):M=e[20];let j;e[21]!==C||e[22]!==T||e[23]!==M||e[24]!==g||e[25]!==y||e[26]!==S?(j=p.jsxs("button",{type:"button",onClick:g,className:y,children:[S,C,T,N,M]}),e[21]=C,e[22]=T,e[23]=M,e[24]=g,e[25]=y,e[26]=S,e[27]=j):j=e[27];let R;e[28]!==t?(R=p.jsx("span",{className:"flex items-center [&>svg]:size-4 [&>svg]:text-muted-foreground/75",children:t}),e[28]=t,e[29]=R):R=e[29];let A;e[30]!==R||e[31]!==r?(A=p.jsx(eu,{className:"px-4 py-3 border-b border-border shrink-0",children:p.jsxs(tu,{className:"flex items-center gap-2 text-sm font-medium",children:[R,r]})}),e[30]=R,e[31]=r,e[32]=A):A=e[32];let D;e[33]!==a?(D=p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4",children:a}),e[33]=a,e[34]=D):D=e[34];let I;e[35]!==A||e[36]!==D?(I=p.jsxs(Hi,{side:"right",className:"w-full sm:max-w-2xl flex flex-col p-0 gap-0",children:[A,D]}),e[35]=A,e[36]=D,e[37]=I):I=e[37];let $;e[38]!==c||e[39]!==f||e[40]!==I?($=p.jsx(Vi,{open:c,onOpenChange:f,children:I}),e[38]=c,e[39]=f,e[40]=I,e[41]=$):$=e[41];let L;return e[42]!==j||e[43]!==$?(L=p.jsxs(p.Fragment,{children:[j,$]}),e[42]=j,e[43]=$,e[44]=L):L=e[44],L}function Th(n){const e=_.c(9),{part:t}=n,r=t.state==="output-error",s=t.input?.prompt??"No prompt provided";let o;if(e[0]!==r||e[1]!==t||e[2]!==s){const i=r?po(t):_2(t.output)??"";let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[4]=l):l=e[4];let a;e[5]!==s?(a=p.jsxs("section",{children:[l,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:s})]}),e[5]=s,e[6]=a):a=e[6];const c=r?"Error":"Result";let u;e[7]!==c?(u=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:c}),e[7]=c,e[8]=u):u=e[8],o=p.jsxs("div",{className:"flex flex-col gap-4",children:[a,p.jsxs("section",{children:[u,i.trim()?p.jsx(Ji,{id:`${t.toolCallId}-result`,text:i}):p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic",children:"Running…"})]})]}),e[0]=r,e[1]=t,e[2]=s,e[3]=o}else o=e[3];return o}const Go=600;function $2(n){const e=_.c(12),{part:t}=n,r=t.type??"";let s;e[0]!==t.toolName||e[1]!==r?(s=r==="dynamic-tool"?t.toolName??"tool":r.slice(5),e[0]=t.toolName,e[1]=r,e[2]=s):s=e[2];const o=s;let i;if(e[3]!==t.input){const f=t.input!=null?JSON.stringify(t.input):"";i=f.length>80?`${f.slice(0,80)}…`:f||void 0,e[3]=t.input,e[4]=i}else i=e[4];const l=i;let a;if(e[5]!==t.input){const f=t.input!=null?JSON.stringify(t.input,null,2):null;a=f&&f.length>Go?`${f.slice(0,Go)}
188
- … (${f.length-Go} more characters)`:f,e[5]=t.input,e[6]=a}else a=e[6];const c=a;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(au,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==o||e[10]!==l?(d=p.jsx(Z,{icon:u,title:o,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=o,e[10]=l,e[11]=d):d=e[11],d}function z2(n){const e=_.c(12),{jobId:t,prompt:r,items:s,streaming:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=i):i=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[i,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:r})]}),e[1]=r,e[2]=l):l=e[2];let a;e[3]!==s||e[4]!==t||e[5]!==o?(a=s.length===0?p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic py-1",children:"Running in the background…"}):s.map((d,f)=>{const h=d,m=h.type??"";return m==="text"?h.text?.trim()?p.jsx(uo,{id:`${t}-sub-${f}`,part:d,animate:o},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx($2,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=o,e[6]=a):a=e[6];let c;e[7]!==a?(c=p.jsx("section",{className:"flex flex-col gap-3 sm:gap-2",children:a}),e[7]=a,e[8]=c):c=e[8];let u;return e[9]!==l||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-col gap-4",children:[l,c]}),e[9]=l,e[10]=c,e[11]=u):u=e[11],u}function Nh(n){const e=_.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=_p(),{org:o}=Ct(),[i,l]=E.useState(!1),a=D2(r);let c;e[0]!==r||e[1]!==i||e[2]!==o.slug||e[3]!==s?(c={orgSlug:o.slug,threadId:s,jobId:r,enabled:i},e[0]=r,e[1]=i,e[2]=o.slug,e[3]=s,e[4]=c):c=e[4];const u=L2(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(F2),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(B2),e[7]=a,e[8]=h):h=e[8];const m=h,g=f.length>0?f:m,x=t.input?.prompt??"No prompt provided";let y;e[9]!==x?(y=x.length>120?`${x.slice(0,120)}…`:x,e[9]=x,e[10]=y):y=e[10];const b=y,k=a.length===0;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(qt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(Xi,{})}),e[11]=S):S=e[11];const v=k?"loading":"idle",w=u.streaming||k;let C;e[12]!==g||e[13]!==r||e[14]!==x||e[15]!==w?(C=p.jsx(z2,{jobId:r,prompt:x,items:g,streaming:w}),e[12]=g,e[13]=r,e[14]=x,e[15]=w,e[16]=C):C=e[16];let T;return e[17]!==b||e[18]!==v||e[19]!==C?(T=p.jsx(Ul,{icon:S,title:"Subtask",summary:b,state:v,onOpenChange:l,children:C}),e[17]=b,e[18]=v,e[19]=C,e[20]=T):T=e[20],T}function B2(n){return n.parts??[]}function F2(n){return n.parts??[]}function H2(n){const e=_.c(13);if(wh(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Nh,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=Ch(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:o,state:i}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(qt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(Xi,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(Th,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==i||e[9]!==s||e[10]!==a||e[11]!==o?(c=p.jsx(Ul,{icon:l,title:r,summary:s,state:i,usage:o,children:a}),e[7]=r,e[8]=i,e[9]=s,e[10]=a,e[11]=o,e[12]=c):c=e[12],c}function V2(n){const e=_.c(17),t=Zc(n.part.input?.agent_id);if(wh(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Nh,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=Ch(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:o,usage:i,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Xi,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(qt,{icon:a,name:c,size:"2xs",className:"rounded-xs",fallbackIcon:u}),e[5]=a,e[6]=c,e[7]=d):d=e[7];const f=t?.title??s;let h;e[8]!==n.part?(h=p.jsx(Th,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==o||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==i?(m=p.jsx(Ul,{icon:d,title:f,summary:o,state:l,usage:i,children:h}),e[10]=l,e[11]=o,e[12]=d,e[13]=f,e[14]=h,e[15]=i,e[16]=m):m=e[16],m}function W2(n){const e=_.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",o=t.output?.approved===!0;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(Zo,{className:"size-4 text-purple-500 shrink-0"}),l=p.jsx("span",{className:"text-[14px] font-medium text-foreground/80",children:"Implementation Plan"}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let a;e[2]!==o?(a=o&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-success bg-success/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(qi,{size:12}),"Approved"]}),e[2]=o,e[3]=a):a=e[3];let c;e[4]!==o||e[5]!==t.state?(c=!o&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=o,e[5]=t.state,e[6]=c):c=e[6];let u;e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[i,l,a,c]}),e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"View plan"}),e[10]=d):d=e[10];let f;e[11]!==r?(f=p.jsxs("details",{className:"ml-6",children:[d,p.jsx("div",{className:"mt-1 pl-2 border-l-2 border-purple-500/30 prose prose-sm max-w-none text-sm",children:p.jsx(uo,{id:"plan-content",part:{type:"text",text:r}})})]}),e[11]=r,e[12]=f):f=e[12];let h;return e[13]!==u||e[14]!==f?(h=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,f]}),e[13]=u,e[14]=f,e[15]=h):h=e[15],h}const ql={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function U2(n){return n.startsWith("http")?n:`https://${n}`}function Hc(n){const e=_.c(2),{children:t}=n;let r;return e[0]!==t?(r=p.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[0]=t,e[1]=r):r=e[1],r}function q2(n){const e=_.c(12),{name:t,value:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"size-7 shrink-0 rounded-md border border-border",style:{backgroundColor:r},"aria-hidden":!0}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==o||e[7]!==i?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8];let a;return e[9]!==s||e[10]!==l?(a=p.jsxs("div",{className:"flex items-center gap-2.5",children:[s,l]}),e[9]=s,e[10]=l,e[11]=a):a=e[11],a}function K2(n){const e=_.c(15),{role:t,family:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"text-2xl font-medium leading-none text-foreground shrink-0",style:{fontFamily:r},"aria-hidden":!0,children:"Aa"}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i={fontFamily:r},e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r||e[7]!==i?(l=p.jsx("span",{className:"text-sm text-foreground",style:i,children:r}),e[6]=r,e[7]=i,e[8]=l):l=e[8];let a;e[9]!==o||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[o,l]}),e[9]=o,e[10]=l,e[11]=a):a=e[11];let c;return e[12]!==s||e[13]!==a?(c=p.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted px-4 py-3",children:[s,a]}),e[12]=s,e[13]=a,e[14]=c):c=e[14],c}function J2(n){const e=_.c(3),{logo:t,favicon:r,name:s}=n,o=t??r;if(!o)return null;const i=s?`${s} logo`:"";let l;return e[0]!==o||e[1]!==i?(l=p.jsx("img",{src:o,alt:i,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:G2}),e[0]=o,e[1]=i,e[2]=l):l=e[2],l}function G2(n){n.target.style.display="none"}function Mh(n){const e=_.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(Y2),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let o;return e[2]!==s?(o=p.jsx("div",{className:"flex h-1.5",children:s.map(X2)}),e[2]=s,e[3]=o):o=e[3],o}function X2(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${ql[e]}: ${t}`,"aria-hidden":!0},e)}function Y2(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Eh(n){const e=_.c(36),{logo:t,favicon:r,name:s,domain:o,overview:i,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(tv):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(ev):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(Mh,{colors:l}),e[4]=l,e[5]=g):g=e[5];let x;e[6]!==r||e[7]!==t||e[8]!==s?(x=p.jsx(J2,{logo:t,favicon:r,name:s}),e[6]=r,e[7]=t,e[8]=s,e[9]=x):x=e[9];let y;e[10]!==u||e[11]!==s||e[12]!==c?(y=s&&p.jsxs("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-foreground truncate",children:[s,c&&u&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[p.jsx(xu,{className:"size-3 text-amber-500"}),"default"]})]}),e[10]=u,e[11]=s,e[12]=c,e[13]=y):y=e[13];let b;e[14]!==o?(b=o&&p.jsxs("a",{href:U2(o),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[o,p.jsx(bu,{className:"size-3 shrink-0"})]}),e[14]=o,e[15]=b):b=e[15];let k;e[16]!==y||e[17]!==b?(k=p.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[y,b]}),e[16]=y,e[17]=b,e[18]=k):k=e[18];let S;e[19]!==x||e[20]!==k?(S=p.jsxs("div",{className:"flex items-center gap-4",children:[x,k]}),e[19]=x,e[20]=k,e[21]=S):S=e[21];let v;e[22]!==i?(v=i&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:i}),e[22]=i,e[23]=v):v=e[23];let w;e[24]!==f?(w=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Hc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(Z2)})]}),e[24]=f,e[25]=w):w=e[25];let C;e[26]!==m?(C=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Hc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(Q2)})]}),e[26]=m,e[27]=C):C=e[27];let T;e[28]!==w||e[29]!==C||e[30]!==S||e[31]!==v?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[S,v,w,C]}),e[28]=w,e[29]=C,e[30]=S,e[31]=v,e[32]=T):T=e[32];let N;return e[33]!==T||e[34]!==g?(N=p.jsxs("div",{className:"mt-2 rounded-lg overflow-hidden border border-border",children:[g,T]}),e[33]=T,e[34]=g,e[35]=N):N=e[35],N}function Q2(n){const[e,t]=n;return p.jsx(K2,{role:e,family:t},e)}function Z2(n){const[e,t]=n;return p.jsx(q2,{name:ql[e],value:t},e)}function ev(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function tv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function nv(n){const e=_.c(29),{part:t,latency:r}=n,s=ot(t.state);let o;e[0]!==t.output?(o=Un(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){const C=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(dt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=C?.domain?`from ${C.domain}`:void 0;let M;return e[3]!==N?(M=p.jsx(Z,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=M):M=e[4],M}if(a){let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(dt,{}),e[5]=C):C=e[5];const T=i?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[6]=r,e[7]=N):N=e[7];let M;return e[8]!==T||e[9]!==N?(M=p.jsx(Z,{icon:C,title:"Brand extraction failed",summary:T,state:"error",trailing:N}),e[8]=T,e[9]=N,e[10]=M):M=e[10],M}let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(dt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=i?.name?`Brand set: ${i.name}`:"Brand context set",d=i?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[12]=r,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==d||e[16]!==f?(h=p.jsx(Z,{icon:c,title:u,summary:d,state:"idle",trailing:f}),e[14]=u,e[15]=d,e[16]=f,e[17]=h):h=e[17];const m=i?.logo,g=i?.favicon,x=i?.name,y=i?.domain,b=i?.overview,k=i?.colors,S=i?.fonts;let v;e[18]!==y||e[19]!==b||e[20]!==k||e[21]!==S||e[22]!==m||e[23]!==g||e[24]!==x?(v=p.jsx(Eh,{logo:m,favicon:g,name:x,domain:y,overview:b,colors:k,fonts:S}),e[18]=y,e[19]=b,e[20]=k,e[21]=S,e[22]=m,e[23]=g,e[24]=x,e[25]=v):v=e[25];let w;return e[26]!==v||e[27]!==h?(w=p.jsxs(p.Fragment,{children:[h,v]}),e[26]=v,e[27]=h,e[28]=w):w=e[28],w}function rv(n){const e=_.c(27),{part:t,latency:r}=n,s=ot(t.state);let o;e[0]!==t.output?(o=Un(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(Z,{icon:p.jsx(dt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!i){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(dt,{}),e[3]=g):g=e[3];let x;e[4]!==r?(x=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[4]=r,e[5]=x):x=e[5];let y;return e[6]!==x?(y=p.jsx(Z,{icon:g,title:"Couldn't load brand",state:"error",trailing:x}),e[6]=x,e[7]=y):y=e[7],y}let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(dt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=i.name?`Brand · ${i.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==i.domain||e[12]!==u||e[13]!==d?(f=p.jsx(Z,{icon:c,title:u,summary:i.domain,state:"idle",trailing:d}),e[11]=i.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==i.colors||e[16]!==i.domain||e[17]!==i.favicon||e[18]!==i.fonts||e[19]!==i.isDefault||e[20]!==i.logo||e[21]!==i.name||e[22]!==i.overview?(h=p.jsx(Eh,{logo:i.logo,favicon:i.favicon,name:i.name,domain:i.domain,overview:i.overview,colors:i.colors,fonts:i.fonts,showDefaultBadge:!0,isDefault:i.isDefault}),e[15]=i.colors,e[16]=i.domain,e[17]=i.favicon,e[18]=i.fonts,e[19]=i.isDefault,e[20]=i.logo,e[21]=i.name,e[22]=i.overview,e[23]=h):h=e[23];let m;return e[24]!==f||e[25]!==h?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[24]=f,e[25]=h,e[26]=m):m=e[26],m}function sv(n){const e=_.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=ot(t.state),e[0]=t.state,e[1]=s):s=e[1];const o=s;let i,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==o){c=Symbol.for("react.early_return_sentinel");e:{const f=Un(t.output),h=Array.isArray(f?.items)?f.items:[],m=o==="loading",g=o==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Z,{icon:p.jsx(dt,{className:"animate-pulse"}),title:"Loading brands",state:"loading"}),e[9]=k):k=e[9],c=k;break e}if(g){let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(dt,{}),e[10]=k):k=e[10];let S;e[11]!==r?(S=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[11]=r,e[12]=S):S=e[12];let v;e[13]!==S?(v=p.jsx(Z,{icon:k,title:"Couldn't load brands",state:"error",trailing:S}),e[13]=S,e[14]=v):v=e[14],c=v;break e}if(h.length===0){let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(dt,{}),e[15]=k):k=e[15];let S;e[16]!==r?(S=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[16]=r,e[17]=S):S=e[17];let v;e[18]!==S?(v=p.jsx(Z,{icon:k,title:"No brands yet",summary:"The organization hasn't set up any brand context.",state:"idle",trailing:S}),e[18]=S,e[19]=v):v=e[19],c=v;break e}let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx(dt,{className:"text-fuchsia-500"}),e[20]=x):x=e[20];const y=h.length===1?"1 brand":`${h.length} brands`;let b;e[21]!==r?(b=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==y||e[24]!==b?(a=p.jsx(Z,{icon:x,title:y,state:"idle",trailing:b}),e[23]=y,e[24]=b,e[25]=a):a=e[25],i="mt-2 flex flex-col gap-1.5",l=h.map(ov)}e[2]=r,e[3]=t.output,e[4]=o,e[5]=i,e[6]=l,e[7]=a,e[8]=c}else i=e[5],l=e[6],a=e[7],c=e[8];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;e[26]!==i||e[27]!==l?(u=p.jsx("div",{className:i,children:l}),e[26]=i,e[27]=l,e[28]=u):u=e[28];let d;return e[29]!==a||e[30]!==u?(d=p.jsxs(p.Fragment,{children:[a,u]}),e[29]=a,e[30]=u,e[31]=d):d=e[31],d}function ov(n){const e=n.colors?Object.entries(n.colors).filter(av):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(Mh,{colors:n.colors}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(n.logo||n.favicon)&&p.jsx("img",{src:n.logo??n.favicon??void 0,alt:"",className:"size-8 shrink-0 rounded-md border border-border bg-background object-contain p-0.5",onError:lv}),p.jsxs("div",{className:"flex flex-col leading-tight min-w-0 flex-1",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-foreground truncate",children:[n.name??"Untitled",n.isDefault&&p.jsx(xu,{className:"size-3 text-amber-500 shrink-0"})]}),n.domain&&p.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:n.domain})]}),e.length>0&&p.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:e.slice(0,5).map(iv)})]})]},n.id??`${n.name}-${n.domain}`)}function iv(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${ql[e]}: ${t}`,"aria-hidden":!0},e)}function lv(n){n.target.style.display="none"}function av(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Pi(n){const e=_.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,o=Zc(t);if(!o)return null;let i;return e[0]!==o.icon||e[1]!==o.title||e[2]!==s?(i=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(qt,{icon:o.icon,name:o.title,size:s})}),e[0]=o.icon,e[1]=o.title,e[2]=s,e[3]=i):i=e[3],i}Pi.Fallback=function({iconSize:e="xs"}){const t=e==="sm"?"size-6":"size-5";return p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:ee(t,"rounded bg-muted animate-pulse")})})};function Tr(n){const e=_.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:o}=n,i=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==o||e[1]!==t||e[2]!==l||e[3]!==i){const h=t.slice(0,i);a=t.length-i,e[7]!==o?(c=ee("flex items-center justify-end -space-x-2",o),e[7]=o,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(E.Suspense,{fallback:p.jsx(Pi.Fallback,{iconSize:l}),children:p.jsx(Pi,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=o,e[1]=t,e[2]=l,e[3]=i,e[4]=a,e[5]=c,e[6]=u}else a=e[4],c=e[5],u=e[6];let d;e[11]!==l||e[12]!==a?(d=a>0&&p.jsx("div",{className:ee("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",l==="sm"?"size-8":"size-6"),children:p.jsxs("span",{className:ee(l==="sm"?"text-sm":"text-xs","font-medium text-muted-foreground"),"aria-label":`and ${a} more`,children:["+",a]})}),e[11]=l,e[12]=a,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==u||e[16]!==d?(f=p.jsxs("div",{className:c,children:[u,d]}),e[14]=c,e[15]=u,e[16]=d,e[17]=f):f=e[17],f}Tr.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",o=r==="sm"?"size-8":"size-6",i=t!==void 0&&t>e;return p.jsxs("div",{className:"flex items-center -space-x-2",children:[Array.from({length:e}).map((l,a)=>p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:ee(s,"rounded bg-muted animate-pulse")})},a)),i&&p.jsx("div",{className:ee("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",o),children:p.jsx("div",{className:ee(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const cv="This document certifies that the bearer agent has been granted authorized access to the tools and capabilities described herein. The agent is permitted to operate within the scope defined by its instructions and shall act in accordance with the constraints set forth by the issuing organization. This credential remains valid for the duration of the agent's active status. Unauthorized modification of this agent's permissions or scope is prohibited. The issuing authority reserves the right to revoke access at any time. All actions performed by this agent are subject to audit and review by the organization administrator. ",Vc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function uv(n){const e=_.c(64),{part:t,latency:r}=n,s=ku(),o=ot(t.state),i=E.useRef(null),l=E.useRef(null),a=E.useRef(null),c=E.useRef(null),u=E.useRef(null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{Vc?.matches||(u.current=i.current?.getBoundingClientRect()??null,i.current&&(i.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=W=>{if(Vc?.matches)return;const te=u.current,he=i.current;if(!te||!he)return;const ge=(W.clientX-te.left)/te.width*100,Be=(W.clientY-te.top)/te.height*100;he.style.transform=`perspective(800px) rotateY(${(ge-50)*.05}deg) rotateX(${(Be-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(ge-50)*.15}px, ${(Be-50)*.15}px)`),a.current&&(a.current.style.opacity="0.45"),c.current&&(c.current.style.opacity="0.45")},e[1]=h):h=e[1];const m=h;let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const W=i.current;W&&(W.style.transform="none",W.style.willChange="auto"),l.current&&(l.current.style.opacity="0.4",l.current.style.transform="translate(0, 0)"),a.current&&(a.current.style.opacity="0.3"),c.current&&(c.current.style.opacity="0.3"),u.current=null},e[2]=g):g=e[2];const x=g;if(o==="loading"){let W;return e[3]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(Z,{icon:p.jsx(ut,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=W):W=e[3],W}if(o==="approval"){let W;return e[4]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(Z,{icon:p.jsx(ut,{}),title:"Create agent",state:"idle"}),e[4]=W):W=e[4],W}if(o==="error"){let W;e[5]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(ut,{}),e[5]=W):W=e[5];const te=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let he;e[6]!==r?(he=p.jsx(Ie,{latency:r}),e[6]=r,e[7]=he):he=e[7];let ge;return e[8]!==te||e[9]!==he?(ge=p.jsx(Z,{icon:W,title:te,state:"error",trailing:he}),e[8]=te,e[9]=he,e[10]=ge):ge=e[10],ge}let y,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(y=Un(t.output)?.item,!y?.id||!y?.title){let W;e[16]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(ut,{}),e[16]=W):W=e[16];let te;e[17]!==r?(te=p.jsx(Z,{icon:W,title:"Agent created",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[17]=r,e[18]=te):te=e[18],k=te;break e}b=(y.connections??[]).map(dv)}e[11]=r,e[12]=t.output,e[13]=y,e[14]=b,e[15]=k}else y=e[13],b=e[14],k=e[15];if(k!==Symbol.for("react.early_return_sentinel"))return k;const S=b;let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ut,{className:"text-success"}),e[19]=v):v=e[19];const w=`Agent created: ${y.title}`;let C;e[20]!==r?(C=p.jsx(Ie,{latency:r}),e[20]=r,e[21]=C):C=e[21];let T;e[22]!==w||e[23]!==C?(T=p.jsx(Z,{icon:v,title:w,state:"idle",trailing:C}),e[22]=w,e[23]=C,e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N={transition:"transform 0.3s ease-out"},e[25]=N):N=e[25];let M;e[26]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsx("div",{ref:l,className:"pointer-events-none absolute inset-[-20%] z-[1] select-none rounded-lg",style:{background:"linear-gradient(135deg, hsla(280, 60%, 80%, 0.35) 0%, transparent 35%), linear-gradient(315deg, hsla(190, 70%, 80%, 0.35) 0%, transparent 35%), linear-gradient(225deg, hsla(140, 55%, 80%, 0.3) 0%, transparent 30%), linear-gradient(45deg, hsla(320, 55%, 82%, 0.3) 0%, transparent 30%)",opacity:.4,transition:"opacity 0.3s ease, transform 0.3s ease-out"},"aria-hidden":"true"}),e[26]=M):M=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j={textAlign:"justify",wordBreak:"break-all"},e[27]=j):j=e[27];let R,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx("p",{className:"pointer-events-none absolute inset-0 z-[1] select-none overflow-hidden text-[6px] font-light leading-[1.5] tracking-[0.06px] text-background opacity-50 mix-blend-overlay",style:j,"aria-hidden":"true",children:cv.repeat(6)}),A=p.jsx("img",{src:"/stamp.svg",alt:"",className:"pointer-events-none absolute -right-10 -top-10 size-[140px] opacity-50 select-none","aria-hidden":"true"}),e[28]=R,e[29]=A):(R=e[28],A=e[29]);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx("img",{ref:a,src:"/left-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 left-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[30]=D):D=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=p.jsx("img",{ref:c,src:"/right-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 right-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[31]=I):I=e[31];let $;e[32]!==y.icon||e[33]!==y.title?($=p.jsx(uu,{icon:y.icon,name:y.title,size:"md"}),e[32]=y.icon,e[33]=y.title,e[34]=$):$=e[34];let L;e[35]!==y.title?(L=p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:y.title})}),e[35]=y.title,e[36]=L):L=e[36];let z;e[37]!==$||e[38]!==L?(z=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[$,L]}),e[37]=$,e[38]=L,e[39]=z):z=e[39];let F;e[40]!==y.description?(F=y.description&&p.jsx("div",{className:"px-2 pt-1 pr-16",children:p.jsx("p",{className:"text-sm leading-snug text-muted-foreground line-clamp-2",children:y.description})}),e[40]=y.description,e[41]=F):F=e[41];let U;e[42]!==z||e[43]!==F?(U=p.jsxs("div",{className:"relative",children:[z,F]}),e[42]=z,e[43]=F,e[44]=U):U=e[44];let Y;e[45]!==S?(Y=S.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Tr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:S.length}),children:p.jsx(Tr,{connectionIds:S,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=S,e[46]=Y):Y=e[46];let K;e[47]!==Y?(K=p.jsx("div",{className:"flex-1 min-w-0",children:Y}),e[47]=Y,e[48]=K):K=e[48];let Q;e[49]!==y.id||e[50]!==s?(Q=()=>s(y.id),e[49]=y.id,e[50]=s,e[51]=Q):Q=e[51];const ne=`See agent: ${y.title}`;let re;e[52]!==Q||e[53]!==ne?(re=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(un,{size:"sm",className:"h-7",onClick:Q,"aria-label":ne,children:"See agent"})}),e[52]=Q,e[53]=ne,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==re?(se=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[K,re]}),e[55]=K,e[56]=re,e[57]=se):se=e[57];let ae;e[58]!==U||e[59]!==se?(ae=p.jsx("div",{className:"mt-2 overflow-hidden rounded-xl border-[0.5px] border-border bg-card p-2.5",children:p.jsxs("div",{ref:i,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:x,children:[M,R,A,D,I,U,se]})}),e[58]=U,e[59]=se,e[60]=ae):ae=e[60];let Te;return e[61]!==ae||e[62]!==T?(Te=p.jsxs(p.Fragment,{children:[T,ae]}),e[61]=ae,e[62]=T,e[63]=Te):Te=e[63],Te}function dv(n){return n.connection_id}function fv(n){const e=_.c(24),{agent:t}=n,r=ku();if(!t.id)return null;let s;e[0]!==t.connections?(s=t.connections??[],e[0]=t.connections,e[1]=s):s=e[1];let o;e[2]!==s?(o=s.map(hv),e[2]=s,e[3]=o):o=e[3];const i=o;let l;e[4]!==t.id||e[5]!==r?(l=()=>r(t.id),e[4]=t.id,e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t.icon||e[8]!==t.title?(a=p.jsx(uu,{icon:t.icon,name:t.title,size:"sm"}),e[7]=t.icon,e[8]=t.title,e[9]=a):a=e[9];let c;e[10]!==t.title?(c=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[10]=t.title,e[11]=c):c=e[11];let u;e[12]!==t.description?(u=t.description&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.description}),e[12]=t.description,e[13]=u):u=e[13];let d;e[14]!==c||e[15]!==u?(d=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16];let f;e[17]!==i?(f=i.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Tr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:i.length}),children:p.jsx(Tr,{connectionIds:i,iconSize:"xs",maxVisibleIcons:3})}),e[17]=i,e[18]=f):f=e[18];let h;return e[19]!==l||e[20]!==a||e[21]!==d||e[22]!==f?(h=p.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[a,d,f]}),e[19]=l,e[20]=a,e[21]=d,e[22]=f,e[23]=h):h=e[23],h}function hv(n){return n.connection_id}function pv(n){const e=_.c(41),{part:t,latency:r}=n,s=Vn(),{org:o}=Ct();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const y=Un(t.output);if(c=Array.isArray(y?.items)?y.items:[],l==="loading"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(ut,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="approval"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(ut,{}),title:"List agents",state:"idle"}),e[13]=w):w=e[13],h=w;break e}if(l==="error"){let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(ut,{}),e[14]=w):w=e[14];const C=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx(Ie,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==C||e[18]!==T?(N=p.jsx(Z,{icon:w,title:C,state:"error",trailing:T}),e[17]=C,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(ut,{}),e[20]=w):w=e[20];let C;e[21]!==r?(C=p.jsx(Z,{icon:w,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[21]=r,e[22]=C):C=e[22],h=C;break e}const b=c.slice(0,gh);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ut,{className:"text-success"}),e[23]=k):k=e[23];const S=c.length===1?"1 agent":`${c.length} agents`;let v;e[24]!==r?(v=p.jsx(Ie,{latency:r}),e[24]=r,e[25]=v):v=e[25],e[26]!==S||e[27]!==v?(f=p.jsx(Z,{icon:k,title:S,state:"idle",trailing:v}),e[26]=S,e[27]=v,e[28]=f):f=e[28],u="mt-2 flex flex-col gap-1.5",d=b.map(mv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[29]!==a||e[30]!==c||e[31]!==s||e[32]!==o?(m=a>0&&p.jsx(xh,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:o.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=o,e[33]=m):m=e[33];let g;e[34]!==u||e[35]!==d||e[36]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[34]=u,e[35]=d,e[36]=m,e[37]=g):g=e[37];let x;return e[38]!==f||e[39]!==g?(x=p.jsxs(p.Fragment,{children:[f,g]}),e[38]=f,e[39]=g,e[40]=x):x=e[40],x}function mv(n){return p.jsx(fv,{agent:n},n.id)}const gv={active:"bg-success",inactive:"bg-muted-foreground",error:"bg-destructive"};function xv(n){const e=_.c(27),{connection:t}=n,r=Vn(),{org:s}=Ct(),o=t.slug,i=t.description||t.app_name,l=!o||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==o?(a=()=>o&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:o}}),e[0]=r,e[1]=s,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(qt,{icon:t.icon,name:t.title,size:"sm"}),e[4]=t.icon,e[5]=t.title,e[6]=c):c=e[6];let u;e[7]!==t.title?(u=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[7]=t.title,e[8]=u):u=e[8];let d;e[9]!==i?(d=i&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=d):d=e[10];let f;e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13];const h=gv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=ee("size-2 shrink-0 rounded-full",h),e[14]=h,e[15]=m):m=e[15];let g;e[16]!==m?(g=p.jsx("span",{className:m,"aria-hidden":"true"}),e[16]=m,e[17]=g):g=e[17];let x;e[18]!==t.status?(x=p.jsx("span",{className:"sr-only",children:t.status}),e[18]=t.status,e[19]=x):x=e[19];let y;return e[20]!==l||e[21]!==x||e[22]!==a||e[23]!==c||e[24]!==f||e[25]!==g?(y=p.jsxs("button",{type:"button","aria-disabled":l,onClick:a,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer aria-disabled:cursor-default aria-disabled:hover:bg-card",children:[c,f,g,x]}),e[20]=l,e[21]=x,e[22]=a,e[23]=c,e[24]=f,e[25]=g,e[26]=y):y=e[26],y}function yv(n){const e=_.c(40),{part:t,latency:r}=n,s=Vn(),{org:o}=Ct();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const y=Un(t.output);if(c=(Array.isArray(y?.items)?y.items:[]).filter(kv),l==="loading"||l==="approval"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(Or,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="error"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Or,{}),e[13]=w):w=e[13];const C=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx(Ie,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==C||e[17]!==T?(N=p.jsx(Z,{icon:w,title:C,state:"error",trailing:T}),e[16]=C,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Or,{}),e[19]=w):w=e[19];let C;e[20]!==r?(C=p.jsx(Z,{icon:w,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[20]=r,e[21]=C):C=e[21],h=C;break e}const b=c.slice(0,gh);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Or,{className:"text-success"}),e[22]=k):k=e[22];const S=c.length===1?"1 connection":`${c.length} connections`;let v;e[23]!==r?(v=p.jsx(Ie,{latency:r}),e[23]=r,e[24]=v):v=e[24],e[25]!==S||e[26]!==v?(f=p.jsx(Z,{icon:k,title:S,state:"idle",trailing:v}),e[25]=S,e[26]=v,e[27]=f):f=e[27],u="mt-2 flex flex-col gap-1.5",d=b.map(bv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[28]!==a||e[29]!==c||e[30]!==s||e[31]!==o?(m=a>0&&p.jsx(xh,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:o.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=o,e[32]=m):m=e[32];let g;e[33]!==u||e[34]!==d||e[35]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[33]=u,e[34]=d,e[35]=m,e[36]=g):g=e[36];let x;return e[37]!==f||e[38]!==g?(x=p.jsxs(p.Fragment,{children:[f,g]}),e[37]=f,e[38]=g,e[39]=x):x=e[39],x}function bv(n){return p.jsx(xv,{connection:n},n.id)}function kv(n){return n.connection_type!=="VIRTUAL"}function Sv(){const n=_.c(37),e=Gi(),{sendMessage:t,isStreaming:r,messages:s}=$p(),{org:o}=Ct(),i=e?.virtualMcpId,{prompts:l}=Zp(o.slug),a=i??null;let c;n[0]!==o.id||n[1]!==o.slug||n[2]!==a?(c={connectionId:a,orgId:o.id,orgSlug:o.slug},n[0]=o.id,n[1]=o.slug,n[2]=a,n[3]=c):c=n[3];const u=Fi(c),[d,f]=E.useState(null);if(!i||r||!cp(i)||!s.some(vv))return null;let m;if(n[4]!==l||n[5]!==i){let A;n[7]!==i?(A=D=>D.agentId===i&&D.promptName,n[7]=i,n[8]=A):A=n[8],m=l.find(A),n[4]=l,n[5]=i,n[6]=m}else m=n[6];const g=m;if(!g)return null;let x;n[9]!==u||n[10]!==t?(x=async(A,D)=>{if(!u){Xo.error("MCP client not available");return}try{const I=await nm(u,A.name,D);await t({type:"doc",content:[{type:"paragraph",content:[Ff({id:A.name,name:Qi(A.name,Yi(A._meta)),metadata:I.messages,char:"/",kind:"prompt",args:D}),{type:"text",text:" "}]}]})}catch(I){console.error("[next-action-chip] failed",I),Xo.error("Failed to load prompt. Please try again.")}},n[9]=u,n[10]=t,n[11]=x):x=n[11];const y=x;let b;n[12]!==g._meta||n[13]!==g.arguments||n[14]!==g.description||n[15]!==g.promptName||n[16]!==g.title||n[17]!==y?(b=()=>{const A={name:g.promptName,title:g.title,description:g.description,arguments:g.arguments,_meta:g._meta};if(A.arguments&&A.arguments.length>0){f(A);return}y(A)},n[12]=g._meta,n[13]=g.arguments,n[14]=g.description,n[15]=g.promptName,n[16]=g.title,n[17]=y,n[18]=b):b=n[18];const k=b;let S,v;n[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(tm,{size:12,className:"shrink-0 text-purple-500"}),v=p.jsx("span",{className:"font-medium text-foreground/80",children:"Next:"}),n[19]=S,n[20]=v):(S=n[19],v=n[20]);let w;n[21]!==g.title?(w=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=w):w=n[22];let C;n[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(du,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=C):C=n[23];let T;n[24]!==k||n[25]!==w?(T=p.jsxs("button",{type:"button",onClick:k,className:"group mt-3 flex items-center gap-2 self-start rounded-full border border-border bg-background px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-border hover:bg-accent/40 hover:text-foreground",children:[S,v,w,C]}),n[24]=k,n[25]=w,n[26]=T):T=n[26];let N;n[27]===Symbol.for("react.memo_cache_sentinel")?(N=A=>f(A),n[27]=N):N=n[27];let M;n[28]!==d||n[29]!==y?(M=async A=>{const D=d;f(null),D&&await y(D,A)},n[28]=d,n[29]=y,n[30]=M):M=n[30];let j;n[31]!==d||n[32]!==M?(j=p.jsx(Nm,{prompt:d,setPrompt:N,onSubmit:M}),n[31]=d,n[32]=M,n[33]=j):j=n[33];let R;return n[34]!==j||n[35]!==T?(R=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=R):R=n[36],R}function vv(n){return n.role==="user"||n.parts.some(wv)}function wv(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function Cv(n){const e=new Map;for(let t=n.length-1;t>=0;t--){const r=n[t]?.parts;if(r)for(const s of r){const o=s;if(o.type!=="data-deck-updated")continue;const i=o.data;if(!i?.path)continue;const l=`deck:${i.path}`;e.has(l)||e.set(l,{tabId:Hp(i.path),label:i.name||i.path,kind:i.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function Tv(){const n=_.c(9),e=Vn(),t=Wn()?.messages??[],r=Cv(t);if(r.length===0)return null;const s=r.some(Mv),o=r.some(Nv),i=s?o?"Slides & pages in this chat":"Slides in this chat":"Pages in this chat",l="flex flex-col gap-1.5 py-2";let a;n[0]!==i?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:i}),n[0]=i,n[1]=a):a=n[1];const c="flex flex-wrap gap-2";let u;n[2]!==e?(u=m=>p.jsxs("button",{type:"button",onClick:()=>e({to:".",search:g=>({...g,main:m.tabId}),replace:!0}),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/30 hover:bg-muted/60 text-[13px] transition-colors",children:[m.kind==="deck"?p.jsx(nr,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(qp,{className:"size-3.5 shrink-0 text-muted-foreground"}),p.jsx("span",{className:"font-medium text-foreground",children:m.label})]},m.tabId),n[2]=e,n[3]=u):u=n[3];const d=r.map(u);let f;n[4]!==d?(f=p.jsx("div",{className:c,children:d}),n[4]=d,n[5]=f):f=n[5];let h;return n[6]!==a||n[7]!==f?(h=p.jsxs("div",{className:l,children:[a,f]}),n[6]=a,n[7]=f,n[8]=h):h=n[8],h}function Nv(n){return n.kind==="page"}function Mv(n){return n.kind==="deck"}async function Ev(n,e){const t=await fetch(`/api/${e}/threads/${encodeURIComponent(n)}/outputs`,{credentials:"include"});if(!t.ok)throw new Error(`Failed to fetch thread outputs: ${t.status}`);return(await t.json()).objects??[]}function rT(){const n=_.c(2),e=Wn()?.messages??[];let t;return n[0]!==e?(t=e.some(Av),n[0]=e,n[1]=t):t=n[1],t}function Av(n){return n.parts?.some(jv)}function jv(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function Iv(n,e){const t=_.c(9),{org:r}=Ct();let s;t[0]!==n?(s=Qe.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let o;t[2]!==r||t[3]!==n?(o=()=>Ev(n??"",r.slug),t[2]=r,t[3]=n,t[4]=o):o=t[4];const i=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==o||t[7]!==i?(l={queryKey:s,queryFn:o,enabled:i,staleTime:0},t[5]=s,t[6]=o,t[7]=i,t[8]=l):l=t[8],Mr(l)}function Ov(n){const e=_.c(20),{file:t}=n,r=Vn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:Vp(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const o=s;let i;e[3]!==t.filename?(i=p.jsx(jp,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=i):i=e[4];let l;e[5]!==t.filename||e[6]!==o?(l=p.jsx("button",{type:"button",onClick:o,className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-foreground hover:underline",title:t.filename,children:t.filename}),e[5]=t.filename,e[6]=o,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(yu,{className:"size-3.5"}),e[8]=c):c=e[8];let u;e[9]!==t.downloadUrl||e[10]!==t.filename||e[11]!==a?(u=p.jsx("a",{href:t.downloadUrl,download:t.filename,className:"hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:block",title:"Download","aria-label":a,children:c}),e[9]=t.downloadUrl,e[10]=t.filename,e[11]=a,e[12]=u):u=e[12];let d;e[13]!==o?(d=p.jsx(un,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:o,children:"Open"}),e[13]=o,e[14]=d):d=e[14];let f;return e[15]!==i||e[16]!==l||e[17]!==u||e[18]!==d?(f=p.jsxs("div",{className:"group flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[i,l,u,d]}),e[15]=i,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Wc(n){return n.split("/").pop()??n}const Rv=/(^|\/)output\//;function Dv(n){const e=new Set;for(const t of n.parts??[]){const r=t;if(r.state==="output-available"){if(r.type==="tool-share_with_user"){const s=r.output?.filename??r.input?.name??(r.input?.source?Wc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&Rv.test(s)&&e.add(Wc(s))}}}return e}function Pv(n){const e=_.c(4),{threadId:t,message:r}=n,s=Dv(r),o=s.size>0;let i;e[0]!==o?(i={enabled:o},e[0]=o,e[1]=i):i=e[1];const{data:l}=Iv(t,i);if(s.size===0)return null;const a=(l??[]).filter(f=>s.has(f.filename));if(a.length===0)return null;const c="flex flex-col gap-1.5 py-2",u=a.map(Lv);let d;return e[2]!==u?(d=p.jsx("div",{className:c,children:u}),e[2]=u,e[3]=d):d=e[3],d}function Lv(n){return p.jsx(Ov,{file:n},n.key)}function _v(n){return n.type==="reasoning"}function $v(n){const e=[],t=new Set,r=new Map,s=new Map,o=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(_v(c)){l||(l={parts:[],startIndex:a},e.push(l)),l.parts.push(c),t.add(a);continue}if(l=null,c.type==="data-tool-metadata"&&"id"in c&&"data"in c){const u=c.data,d={};u.annotations&&(d.annotations=u.annotations),typeof u.latencyMs=="number"&&Number.isFinite(u.latencyMs)&&(d.latencySeconds=u.latencyMs/1e3),typeof u.outputBytes=="number"&&Number.isFinite(u.outputBytes)&&u.outputBytes>=0&&(d.outputBytes=u.outputBytes),u._meta&&typeof u._meta=="object"&&(d._meta=u._meta),r.set(c.id,d);continue}if(c.type==="data-tool-subtask-metadata"&&"id"in c){s.set(c.id,c.data);continue}if(c.type==="data-web-search"&&"id"in c&&"data"in c){const u=c.id,d=c.data;o.set(u,d.text??"");continue}}}const i=[];if(n)for(let l=0;l<n.parts.length;l++){const a=n.parts[l];if(a.type!=="step-start"){if(t.has(l)){const c=e.find(u=>u.startIndex===l);c&&i.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||i.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:i,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:o}}}const zv=3;function Bv(n,e){let t=-1;for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.kind==="part"&&e[s.index]?.type==="text"){t=r;break}}return t===-1?{collapsed:[],tail:n}:{collapsed:n.slice(0,t),tail:n.slice(t)}}function Fv(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const o=e[s.index]?.type;o==="text"?r++:(o==="dynamic-tool"||o?.startsWith("tool-"))&&o!=="tool-todo_write"&&o!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function Hv(n){const e=_.c(8),{toolCalls:t,messages:r}=n;let s;e[0]!==r||e[1]!==t?(s=t>0&&p.jsxs(p.Fragment,{children:[p.jsx(au,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[t," tool call",t===1?"":"s",r>0?",":""]})]}),e[0]=r,e[1]=t,e[2]=s):s=e[2];let o;e[3]!==r?(o=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ap,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,o]}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vv(n){const e=_.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=Fv(t,r.parts),e[0]=t,e[1]=r.parts,e[2]=u):u=e[2];const{toolCalls:d,messages:f}=u;if(d===0&&f===0)return null;let h;e[3]!==f||e[4]!==d?(h=p.jsx(Hv,{toolCalls:d,messages:f}),e[3]=f,e[4]=d,e[5]=h):h=e[5];let m;if(e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==i){let y;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==r||e[20]!==s||e[21]!==i?(y=(b,k)=>Ah({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=o,e[19]=r,e[20]=s,e[21]=i,e[22]=y):y=e[22],m=t.map(y),e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=t,e[11]=r,e[12]=s,e[13]=i,e[14]=m}else m=e[14];let g;e[23]!==m?(g=p.jsx("div",{className:"flex flex-col gap-3 sm:gap-2 pt-1",children:m}),e[23]=m,e[24]=g):g=e[24];let x;return e[25]!==h||e[26]!==g?(x=p.jsx(Z,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=x):x=e[27],x}function Ah({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:o,dataParts:i,isLoading:l,isLast:a,isLastVisiblePart:c,renderOrder:u}){if(n.kind==="reasoning-group"){const{group:m}=n,g=m===r[r.length-1],x=s&&g;if(!m.parts.some(k=>k.text?.trim())&&!x)return null;const b=r.length===1?o:null;return p.jsx(WS,{duration:b,parts:m.parts,isStreaming:x},`${t.id}-reasoning-${m.startIndex}`)}const d=t.parts[n.index],f=c||(u?u.findLastIndex(m=>m.kind==="part")===e:!1),h=f?wu(vu(),t.metadata?.usage):null;return p.jsx(Wv,{part:d,id:t.id,usageStats:f&&p.jsx(ES,{usage:h,duration:o}),dataParts:i,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function Wv(n){const e=_.c(121),{part:t,id:r,usageStats:s,dataParts:o,isLoading:i,isLastMessage:l}=n;let a;e[0]!==o.toolMetadata?(a=f=>o.toolMetadata.get(f),e[0]=o.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==o.toolSubtaskMetadata?(u=f=>o.toolSubtaskMetadata.get(f),e[2]=o.toolSubtaskMetadata,e[3]=u):u=e[3];const d=u;switch(t.type){case"dynamic-tool":{let f;e[4]!==c||e[5]!==t.toolCallId?(f=c(t.toolCallId)?.annotations,e[4]=c,e[5]=t.toolCallId,e[6]=f):f=e[6];let h;e[7]!==c||e[8]!==t.toolCallId?(h=c(t.toolCallId)?.latencySeconds,e[7]=c,e[8]=t.toolCallId,e[9]=h):h=e[9];let m;e[10]!==c||e[11]!==t.toolCallId?(m=c(t.toolCallId)?.outputBytes,e[10]=c,e[11]=t.toolCallId,e[12]=m):m=e[12];let g;e[13]!==c||e[14]!==t.toolCallId?(g=c(t.toolCallId)?._meta,e[13]=c,e[14]=t.toolCallId,e[15]=g):g=e[15];let x;return e[16]!==l||e[17]!==t||e[18]!==f||e[19]!==h||e[20]!==m||e[21]!==g?(x=p.jsx(Bc,{part:t,annotations:f,latency:h,outputBytes:m,isLastMessage:l,toolMeta:g}),e[16]=l,e[17]=t,e[18]=f,e[19]=h,e[20]=m,e[21]=g,e[22]=x):x=e[22],x}case"tool-todo_write":return null;case"tool-update_interests":return null;case"tool-user_ask":{let f;e[23]!==c||e[24]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[23]=c,e[24]=t.toolCallId,e[25]=f):f=e[25];let h;return e[26]!==t||e[27]!==f?(h=p.jsx(R2,{part:t,latency:f}),e[26]=t,e[27]=f,e[28]=h):h=e[28],h}case"tool-propose_plan":{let f;return e[29]!==t?(f=p.jsx(W2,{part:t}),e[29]=t,e[30]=f):f=e[30],f}case"tool-generate_image":{let f;e[31]!==c||e[32]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[31]=c,e[32]=t.toolCallId,e[33]=f):f=e[33];let h;return e[34]!==t||e[35]!==f?(h=p.jsx(y2,{part:t,latency:f}),e[34]=t,e[35]=f,e[36]=h):h=e[36],h}case"tool-take_screenshot":{let f;e[37]!==c||e[38]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[37]=c,e[38]=t.toolCallId,e[39]=f):f=e[39];let h;return e[40]!==t||e[41]!==f?(h=p.jsx(S2,{part:t,latency:f}),e[40]=t,e[41]=f,e[42]=h):h=e[42],h}case"tool-web_search":case"tool-deep_research":{let f;e[43]!==c||e[44]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[43]=c,e[44]=t.toolCallId,e[45]=f):f=e[45];let h;e[46]!==o.webSearchStreaming||e[47]!==t.toolCallId?(h=o.webSearchStreaming.get(t.toolCallId),e[46]=o.webSearchStreaming,e[47]=t.toolCallId,e[48]=h):h=e[48];let m;return e[49]!==t||e[50]!==f||e[51]!==h?(m=p.jsx(O2,{part:t,latency:f,streamingText:h}),e[49]=t,e[50]=f,e[51]=h,e[52]=m):m=e[52],m}case"tool-subtask":{let f;e[53]!==d||e[54]!==t.toolCallId?(f=d(t.toolCallId),e[53]=d,e[54]=t.toolCallId,e[55]=f):f=e[55];let h;e[56]!==c||e[57]!==t.toolCallId?(h=c(t.toolCallId)?.annotations,e[56]=c,e[57]=t.toolCallId,e[58]=h):h=e[58];let m;e[59]!==c||e[60]!==t.toolCallId?(m=c(t.toolCallId)?.latencySeconds,e[59]=c,e[60]=t.toolCallId,e[61]=m):m=e[61];let g;e[62]!==t||e[63]!==f||e[64]!==h||e[65]!==m?(g={part:t,subtaskMeta:f,annotations:h,latency:m},e[62]=t,e[63]=f,e[64]=h,e[65]=m,e[66]=g):g=e[66];const x=g;let y;return e[67]!==x?(y=p.jsx(E.Suspense,{fallback:p.jsx(H2,{...x}),children:p.jsx(V2,{...x})}),e[67]=x,e[68]=y):y=e[68],y}case"text":{const f=!!s&&!i,h=i&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(uo,{id:r,part:t,extraActions:s,copyable:!0,alwaysShowActions:f,animate:h}),e[69]=r,e[70]=t,e[71]=f,e[72]=h,e[73]=s,e[74]=m):m=e[74],m}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;case"data-tool-metadata":case"data-tool-subtask-metadata":case"data-generate-image":case"data-web-search":return null;default:{const f=t;if(f.type==="tool-brand_context_setup"||f.type==="tool-BRAND_CONTEXT_EXTRACT"){let h;e[75]!==f.toolCallId||e[76]!==c?(h=c(f.toolCallId)?.latencySeconds,e[75]=f.toolCallId,e[76]=c,e[77]=h):h=e[77];let m;return e[78]!==f||e[79]!==h?(m=p.jsx(nv,{part:f,latency:h}),e[78]=f,e[79]=h,e[80]=m):m=e[80],m}if(f.type==="tool-BRAND_CONTEXT_GET"){let h;e[81]!==f.toolCallId||e[82]!==c?(h=c(f.toolCallId)?.latencySeconds,e[81]=f.toolCallId,e[82]=c,e[83]=h):h=e[83];let m;return e[84]!==f||e[85]!==h?(m=p.jsx(rv,{part:f,latency:h}),e[84]=f,e[85]=h,e[86]=m):m=e[86],m}if(f.type==="tool-BRAND_CONTEXT_LIST"){let h;e[87]!==f.toolCallId||e[88]!==c?(h=c(f.toolCallId)?.latencySeconds,e[87]=f.toolCallId,e[88]=c,e[89]=h):h=e[89];let m;return e[90]!==f||e[91]!==h?(m=p.jsx(sv,{part:f,latency:h}),e[90]=f,e[91]=h,e[92]=m):m=e[92],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_CREATE"){let h;e[93]!==f.toolCallId||e[94]!==c?(h=c(f.toolCallId)?.latencySeconds,e[93]=f.toolCallId,e[94]=c,e[95]=h):h=e[95];let m;return e[96]!==f||e[97]!==h?(m=p.jsx(uv,{part:f,latency:h}),e[96]=f,e[97]=h,e[98]=m):m=e[98],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_LIST"){let h;e[99]!==f.toolCallId||e[100]!==c?(h=c(f.toolCallId)?.latencySeconds,e[99]=f.toolCallId,e[100]=c,e[101]=h):h=e[101];let m;return e[102]!==f||e[103]!==h?(m=p.jsx(pv,{part:f,latency:h}),e[102]=f,e[103]=h,e[104]=m):m=e[104],m}if(f.type==="tool-COLLECTION_CONNECTIONS_LIST"){let h;e[105]!==f.toolCallId||e[106]!==c?(h=c(f.toolCallId)?.latencySeconds,e[105]=f.toolCallId,e[106]=c,e[107]=h):h=e[107];let m;return e[108]!==f||e[109]!==h?(m=p.jsx(yv,{part:f,latency:h}),e[108]=f,e[109]=h,e[110]=m):m=e[110],m}if(f.type.startsWith("tool-")){const h=f.toolCallId;let m;e[111]!==o.toolMetadata||e[112]!==h?(m=o.toolMetadata.get(h),e[111]=o.toolMetadata,e[112]=h,e[113]=m):m=e[113];const g=m,x=g?.annotations,y=g?.latencySeconds,b=g?.outputBytes,k=g?._meta;let S;return e[114]!==f||e[115]!==l||e[116]!==x||e[117]!==y||e[118]!==b||e[119]!==k?(S=p.jsx(Bc,{part:f,annotations:x,latency:y,outputBytes:b,isLastMessage:l,toolMeta:k}),e[114]=f,e[115]=l,e[116]=x,e[117]=y,e[118]=b,e[119]=k,e[120]=S):S=e[120],S}if(f.type.startsWith("data-"))return null;throw new Error(`Unknown part type: ${f.type}`)}}}function Uv(n){const e=_.c(2),{isRunInProgress:t}=n;if(t){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Js,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),p.jsx("span",{className:"text-[14px] text-muted-foreground shimmer",children:"Resuming task..."})]})}),e[0]=s):s=e[0],s}let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-[14px] text-muted-foreground/60 py-2",children:"No response was generated"}),e[1]=r):r=e[1],r}function qv(n){const e=_.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=ee("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",t),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:p.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[14px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function Kv(n){const e=_.c(31),{message:t,turnStartedAt:r,status:s,className:o,isLast:i}=n,l=i===void 0?!1:i,{isRunInProgress:a}=Wn()??{},c=a===void 0?!1:a,u=Gi()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Ki(r),e[0]=r,e[1]=m):m=e[1];const g=m;let x;e[2]!==h?(x=()=>h?Date.now():null,e[2]=h,e[3]=x):x=e[3];const[y,b]=E.useState(x),[k,S]=E.useState(h);k!==h&&(S(h),b(h?Date.now():null));const v=g??y,{reasoningGroups:w,renderOrder:C,dataParts:T}=$v(t),N=t!==null&&C.length>0,M=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&M?.type==="reasoning";let R;if(e[4]!==t){const F=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,U=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;R=F!==null?U.getTime()-F.getTime():null,e[4]=t,e[5]=R}else R=e[5];const A=R;let D;e[6]!==l||e[7]!==t?(D=!l||!t||!t.parts.some(Gv),e[6]=l,e[7]=t,e[8]=D):D=e[8];const I=D;let $;e[9]!==N||e[10]!==h||e[11]!==I||e[12]!==t||e[13]!==C?($=!h&&N&&I&&(()=>{let F=0;for(const U of C)if(U.kind==="part"){const Y=t.parts[U.index]?.type;(Y==="dynamic-tool"||Y?.startsWith("tool-"))&&F++}return F>=zv})(),e[9]=N,e[10]=h,e[11]=I,e[12]=t,e[13]=C,e[14]=$):$=e[14];const L=$;let z;if(e[15]!==o||e[16]!==T||e[17]!==N||e[18]!==l||e[19]!==h||e[20]!==j||e[21]!==c||e[22]!==I||e[23]!==t||e[24]!==w||e[25]!==C||e[26]!==L||e[27]!==v||e[28]!==u||e[29]!==A){const{collapsed:F,tail:U}=L?Bv(C,t.parts):{collapsed:[],tail:C};z=p.jsx(qv,{className:o,children:N?p.jsxs("div",{className:"flex flex-col gap-3 sm:gap-2",children:[t.metadata?.resumedFromBackground&&p.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground/60 select-none",children:[p.jsx(Yc,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),F.length>0&&p.jsx(Vv,{items:F,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l}),U.map((Y,K)=>{const Q=F.length+K,ne=U.findLastIndex(Jv)===K;return Ah({item:Y,renderIndex:Q,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:ne,renderOrder:C})}),u&&p.jsx(Pv,{threadId:u,message:t}),l&&h&&v!==null&&p.jsx(FS,{startedAt:v}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(Tv,{}),I&&p.jsx(Sv,{})]}),!h&&p.jsx(yh,{message:t})]}):h?p.jsx(VS,{startedAt:v}):p.jsx(Uv,{isRunInProgress:l&&c})}),e[15]=o,e[16]=T,e[17]=N,e[18]=l,e[19]=h,e[20]=j,e[21]=c,e[22]=I,e[23]=t,e[24]=w,e[25]=C,e[26]=L,e[27]=v,e[28]=u,e[29]=A,e[30]=z}else z=e[30];return z}function Jv(n){return n.kind==="part"}function Gv(n){const e=n.type;if(e!=="dynamic-tool"&&!e?.startsWith("tool-"))return!1;const t=n.state;return t==="input-streaming"||t==="input-available"||t==="approval-requested"}function Xv(n){const e=_.c(21),{event:t}=n,[r,s]=E.useState(!1);let o;e[0]!==t.data?(o=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(Yv),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(mm,{className:"size-4 shrink-0 text-muted-foreground"}),c=p.jsx("span",{className:"font-medium",children:"Triggered by event"}),e[3]=a,e[4]=c):(a=e[3],c=e[4]);let u;e[5]!==t.type?(u=p.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t.type}),e[5]=t.type,e[6]=u):u=e[6];const d=r&&"rotate-180";let f;e[7]!==d?(f=ee("ml-auto size-4 shrink-0 text-muted-foreground transition-transform",d),e[7]=d,e[8]=f):f=e[8];let h;e[9]!==f?(h=p.jsx(Zr,{className:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=p.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 px-3 py-2 text-sm cursor-pointer",children:[a,c,u,h]}),e[11]=u,e[12]=h,e[13]=m):m=e[13];let g;e[14]!==t.source||e[15]!==r||e[16]!==i?(g=r&&p.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[p.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:t.source}),p.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words text-xs text-foreground",children:i})]}),e[14]=t.source,e[15]=r,e[16]=i,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==m?(x=p.jsxs("div",{className:"rounded-lg border border-border/60 bg-background overflow-hidden text-left",children:[m,g]}),e[18]=g,e[19]=m,e[20]=x):x=e[20],x}function Yv(n){return!n}const Qv=[MS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),Bb,Wb];function Zv(n){const e=_.c(5),{tiptapDoc:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let s;e[1]!==t?(s={extensions:Qv,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const o=jb(s);if(!o)return null;let i;return e[3]!==o?(i=p.jsx(Df,{editor:o,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=o,e[4]=i):i=e[4],i}function ew(n){const e=_.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:o,parts:i,metadata:l}=t,[a,c]=E.useState(!1),[u,d]=E.useState(!1),f=E.useRef(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=I=>{I&&!f.current&&(f.current=!0,d(I.scrollHeight>I.clientHeight))},e[0]=h):h=e[0];const m=h;if(!i||i.length===0)return null;let g;e[1]!==s?(g=()=>{c(!0),s?.()},e[1]=s,e[2]=g):g=e[2];const x=g,y=l?.tiptapDoc;let b;e[3]!==r?(b=ee("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=b):b=e[4];let k,S;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=()=>c(!0),S=()=>c(!1),e[5]=k,e[6]=S):(k=e[5],S=e[6]);let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx("div",{className:"absolute inset-0 bg-muted/75 rounded-lg pointer-events-none"}),e[7]=v):v=e[7];let w;e[8]!==a||e[9]!==u?(w=ee("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":ee("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=w):w=e[10];let C;if(e[11]!==o||e[12]!==i){let I;e[14]!==o?(I=($,L)=>$.type==="data-trigger-event"?p.jsx(Xv,{event:$.data},`${o}-${L}`):null,e[14]=o,e[15]=I):I=e[15],C=i.map(I),e[11]=o,e[12]=i,e[13]=C}else C=e[13];let T;e[16]!==y||e[17]!==o||e[18]!==l||e[19]!==i?(T=y?p.jsx(Zv,{tiptapDoc:l.tiptapDoc}):i.map((I,$)=>I.type==="text"?i[$-1]?.type==="data-trigger-event"?null:p.jsx(uo,{id:o,part:I},`${o}-${$}`):null),e[16]=y,e[17]=o,e[18]=l,e[19]=i,e[20]=T):T=e[20];let N;e[21]!==C||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[C,T]}),e[21]=C,e[22]=T,e[23]=N):N=e[23];let M;e[24]!==N||e[25]!==w?(M=p.jsx("div",{ref:m,className:w,children:N}),e[24]=N,e[25]=w,e[26]=M):M=e[26];let j;e[27]!==x||e[28]!==M?(j=p.jsxs("div",{tabIndex:0,onClick:x,onFocus:k,onBlur:S,className:"w-full border border-border/60 min-w-0 shadow-xs rounded-lg text-[14px] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[v,M]}),e[27]=x,e[28]=M,e[29]=j):j=e[29];let R;e[30]!==t?(R=p.jsx(yh,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=R):R=e[31];let A;e[32]!==j||e[33]!==R?(A=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,R]}),e[32]=j,e[33]=R,e[34]=A):A=e[34];let D;return e[35]!==A||e[36]!==b?(D=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:A})}),e[35]=A,e[36]=b,e[37]=D):D=e[37],D}function tw(n){const e=[],t=n.filter(r=>r.role!=="system"&&!r.metadata?.internal&&!r.metadata?.subtaskJobId);for(let r=0;r<t.length;r++){const s=t[r];if(s)if(s.role==="user"){const o=t[r+1];o&&o.role==="assistant"?(e.push({user:s,assistant:o}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function nw(n){const e=_.c(19),{pair:t,isLastPair:r,status:s}=n,o=E.useRef(null),i=E.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o.current&&o.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=l):l=e[0];const a=l;let c;e[1]!==r||e[2]!==t.assistant?.metadata?.resumedFromBackground||e[3]!==s?(c=y=>{if(o.current=y,!r||!y||i.current||(i.current=!0,t.assistant?.metadata?.resumedFromBackground))return;if(s==="submitted"||s==="streaming"){y.scrollIntoView({behavior:"smooth",block:"start"});return}const b=y.closest("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:y.scrollIntoView({behavior:"instant",block:"start"})},e[1]=r,e[2]=t.assistant?.metadata?.resumedFromBackground,e[3]=s,e[4]=c):c=e[4];const u=c,d=!t.user&&"pt-8 sm:pt-6";let f;e[5]!==d?(f=ee("flex flex-col pb-2 sm:pb-2",d),e[5]=d,e[6]=f):f=e[6];let h;e[7]!==t.user?(h=t.user&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"sticky top-0 z-50 w-full h-4 bg-background"}),p.jsx("div",{className:"sticky mb-8 sm:mb-6 top-4 z-50",children:p.jsx(ew,{message:t.user,onScrollToPair:a})})]}),e[7]=t.user,e[8]=h):h=e[8];const m=t.user?.created_at??null;let g;e[9]!==r||e[10]!==t.assistant||e[11]!==s||e[12]!==m?(g=p.jsx(Kv,{message:t.assistant,turnStartedAt:m,status:s,isLast:r}),e[9]=r,e[10]=t.assistant,e[11]=s,e[12]=m,e[13]=g):g=e[13];let x;return e[14]!==u||e[15]!==f||e[16]!==h||e[17]!==g?(x=p.jsxs("div",{ref:u,className:f,children:[h,g]}),e[14]=u,e[15]=f,e[16]=h,e[17]=g,e[18]=x):x=e[18],x}function rw(n,e){return E.useReducer((t,r)=>e[t][r]??t,n)}var Kl="ScrollArea",[jh]=Gc(Kl),[sw,tt]=jh(Kl),Ih=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:o=600,...i}=n,[l,a]=E.useState(null),[c,u]=E.useState(null),[d,f]=E.useState(null),[h,m]=E.useState(null),[g,x]=E.useState(null),[y,b]=E.useState(0),[k,S]=E.useState(0),[v,w]=E.useState(!1),[C,T]=E.useState(!1),N=kn(e,j=>a(j)),M=sp(s);return p.jsx(sw,{scope:t,type:r,dir:M,scrollHideDelay:o,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:v,onScrollbarXEnabledChange:w,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:S,children:p.jsx(Ut.div,{dir:M,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Ih.displayName=Kl;var Oh="ScrollAreaViewport",Rh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...o}=n,i=tt(Oh,t),l=E.useRef(null),a=kn(e,l,i.onViewportChange);return p.jsxs(p.Fragment,{children:[p.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),p.jsx(Ut.div,{"data-radix-scroll-area-viewport":"",...o,ref:a,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Rh.displayName=Oh;var pt="ScrollAreaScrollbar",Dh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,l=n.orientation==="horizontal";return E.useEffect(()=>(l?o(!0):i(!0),()=>{l?o(!1):i(!1)}),[l,o,i]),s.type==="hover"?p.jsx(ow,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(iw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(Ph,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Jl,{...r,ref:e}):null});Dh.displayName=pt;var ow=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),[o,i]=E.useState(!1);return E.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),i(!0)},u=()=>{a=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",c),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(a),l.removeEventListener("pointerenter",c),l.removeEventListener("pointerleave",u)}}},[s.scrollArea,s.scrollHideDelay]),p.jsx(Nr,{present:t||o,children:p.jsx(Ph,{"data-state":o?"visible":"hidden",...r,ref:e})})}),iw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),o=n.orientation==="horizontal",i=xo(()=>a("SCROLL_END"),100),[l,a]=rw("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(l==="idle"){const c=window.setTimeout(()=>a("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(c)}},[l,s.scrollHideDelay,a]),E.useEffect(()=>{const c=s.viewport,u=o?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),i()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,o,a,i]),p.jsx(Nr,{present:t||l!=="hidden",children:p.jsx(Jl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:_t(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:_t(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),Ph=E.forwardRef((n,e)=>{const t=tt(pt,n.__scopeScrollArea),{forceMount:r,...s}=n,[o,i]=E.useState(!1),l=n.orientation==="horizontal",a=xo(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;i(l?c:u)}},10);return Hn(t.viewport,a),Hn(t.content,a),p.jsx(Nr,{present:r||o,children:p.jsx(Jl,{"data-state":o?"visible":"hidden",...s,ref:e})})}),Jl=E.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=tt(pt,n.__scopeScrollArea),o=E.useRef(null),i=E.useRef(0),[l,a]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Bh(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function d(f,h){return fw(f,i.current,l,h)}return t==="horizontal"?p.jsx(lw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,h=Uc(f,l,s.dir);o.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=d(f,s.dir))}}):t==="vertical"?p.jsx(aw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,h=Uc(f,l);o.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=d(f))}}):null}),lw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=tt(pt,n.__scopeScrollArea),[i,l]=E.useState(),a=E.useRef(null),c=kn(e,a,o.onScrollbarXChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(_h,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":go(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),Hh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:qs(i.paddingLeft),paddingEnd:qs(i.paddingRight)}})}})}),aw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=tt(pt,n.__scopeScrollArea),[i,l]=E.useState(),a=E.useRef(null),c=kn(e,a,o.onScrollbarYChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(_h,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":go(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),Hh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:qs(i.paddingTop),paddingEnd:qs(i.paddingBottom)}})}})}),[cw,Lh]=jh(pt),_h=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=tt(pt,t),[m,g]=E.useState(null),x=kn(e,N=>g(N)),y=E.useRef(null),b=E.useRef(""),k=h.viewport,S=r.content-r.viewport,v=Qt(u),w=Qt(a),C=xo(d,10);function T(N){if(y.current){const M=N.clientX-y.current.left,j=N.clientY-y.current.top;c({x:M,y:j})}}return E.useEffect(()=>{const N=M=>{const j=M.target;m?.contains(j)&&v(M,S)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[k,m,S,v]),E.useEffect(w,[r,w]),Hn(m,C),Hn(h.content,C),p.jsx(cw,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:Qt(o),onThumbPointerUp:Qt(i),onThumbPositionChange:w,onThumbPointerDown:Qt(l),children:p.jsx(Ut.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:_t(n.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),y.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),T(N))}),onPointerMove:_t(n.onPointerMove,T),onPointerUp:_t(n.onPointerUp,N=>{const M=N.target;M.hasPointerCapture(N.pointerId)&&M.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),Us="ScrollAreaThumb",$h=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Lh(Us,n.__scopeScrollArea);return p.jsx(Nr,{present:t||s.hasThumb,children:p.jsx(uw,{ref:e,...r})})}),uw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,o=tt(Us,t),i=Lh(Us,t),{onThumbPositionChange:l}=i,a=kn(e,d=>i.onThumbChange(d)),c=E.useRef(void 0),u=xo(()=>{c.current&&(c.current(),c.current=void 0)},100);return E.useEffect(()=>{const d=o.viewport;if(d){const f=()=>{if(u(),!c.current){const h=hw(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[o.viewport,u,l]),p.jsx(Ut.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:_t(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:_t(n.onPointerUp,i.onThumbPointerUp)})});$h.displayName=Us;var Gl="ScrollAreaCorner",zh=E.forwardRef((n,e)=>{const t=tt(Gl,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(dw,{...n,ref:e}):null});zh.displayName=Gl;var dw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=tt(Gl,t),[o,i]=E.useState(0),[l,a]=E.useState(0),c=!!(o&&l);return Hn(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Hn(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),i(u)}),c?p.jsx(Ut.div,{...r,ref:e,style:{width:o,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function qs(n){return n?parseInt(n,10):0}function Bh(n,e){const t=n/e;return isNaN(t)?0:t}function go(n){const e=Bh(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function fw(n,e,t,r="ltr"){const s=go(t),o=s/2,i=e||o,l=s-i,a=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return Fh([a,c],d)(n)}function Uc(n,e,t="ltr"){const r=go(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,l=o-r,a=t==="ltr"?[0,i]:[i*-1,0],c=op(n,a);return Fh([0,i],[0,l])(c)}function Fh(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function Hh(n,e){return n>0&&n<e}var hw=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const o={left:n.scrollLeft,top:n.scrollTop},i=t.left!==o.left,l=t.top!==o.top;(i||l)&&e(),t=o,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function xo(n,e){const t=Qt(n),r=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),E.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(t,e)},[t,e])}function Hn(n,e){const t=Qt(e);Jc(()=>{let r=0;if(n){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return s.observe(n),()=>{window.cancelAnimationFrame(r),s.unobserve(n)}}},[n,t])}var pw=Ih,mw=Rh,gw=zh;function sT(n){const e=_.c(17);let t,r,s,o;e[0]!==n?({className:r,children:t,hideScrollbar:o,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=o===void 0?!1:o;let l;e[5]!==r?(l=ee("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(mw,{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-auto rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-[2px] focus-visible:ring-ring/20",children:p.jsx("div",{className:"flex min-w-0 flex-col",children:t})}),e[7]=t,e[8]=a):a=e[8];let c;e[9]!==i?(c=p.jsx(xw,{hideScrollbar:i}),e[9]=i,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(gw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(pw,{"data-slot":"scroll-area",className:l,...s,children:[a,c,u]}),e[12]=s,e[13]=l,e[14]=a,e[15]=c,e[16]=d):d=e[16],d}function xw(n){const e=_.c(15);let t,r,s,o;e[0]!==n?({className:t,orientation:s,hideScrollbar:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"vertical":s,l=o===void 0?!1:o,a=i==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",u=l&&"hidden";let d;e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==u?(d=ee("select-none touch-none p-px transition-colors",a,c,u,t),e[5]=t,e[6]=a,e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx($h,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==i||e[12]!==r||e[13]!==d?(h=p.jsx(Dh,{"data-slot":"scroll-area-scrollbar",orientation:i,className:d,...r,children:f}),e[11]=i,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}const Vh=[{ms:6e4,label:"1m"},{ms:12e4,label:"2m"},{ms:3e5,label:"5m"},{ms:6e5,label:"10m"},{ms:9e5,label:"15m"},{ms:18e5,label:"30m"},{ms:36e5,label:"1h"},{ms:72e5,label:"2h"},{ms:216e5,label:"6h"},{ms:432e5,label:"12h"},{ms:864e5,label:"1d"},{ms:6048e5,label:"7d"}],yw=40;function oT(n){const t=(n.endDate.getTime()-n.startDate.getTime())/yw;return Vh.find(s=>s.ms>=t)?.label??"1d"}function Xl(n){const e=Vh.find(o=>o.label===n);if(e)return e.ms;const t=/^(\d+)([mhd])$/.exec(n);if(!t)return 6e4;const r=parseInt(t[1],10),s=t[2];return s==="h"?r*36e5:s==="d"?r*864e5:r*6e4}function bw(n,e){const t=new Date(n);return Xl(e)>=864e5?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qc(n,e){const t=Xl(e);return new Date(Math.floor(n.getTime()/t)*t)}function kw(n){return n>=1e4?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}function Yl(n){return Number.isFinite(n)?n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:Math.round(n).toLocaleString():"0"}function Ql(n){return Number.isFinite(n)?`$${n.toFixed(n<1?4:2)}`:"$0.00"}function iT(n,e,t){const r=Xl(t),s=qc(e.startDate,t).getTime(),o=e.endDate.getTime(),i=new Map(n.map(a=>[qc(new Date(a.timestamp),t).getTime(),a])),l=[];for(let a=s;a<=o;a+=r){const c=i.get(a),u=new Date(a).toISOString();l.push({t:u,ts:a,label:bw(u,t),calls:c?.calls??0,errors:c?.errors??0,errorRate:c?.errorRate??0,avg:c?.avg??0,p50:c?.p50??0,p95:c?.p95??0,inputTokens:c?.inputTokens??0,outputTokens:c?.outputTokens??0,totalTokens:c?.totalTokens??0,costUsd:c?.costUsd??0})}return l}function lT(n,e){return e==="requests"?n.calls:e==="errors"?n.errorRate:n.avgDurationMs}function aT(n,e){return e==="requests"?n.calls.toLocaleString():e==="errors"?`${n.errorRate.toFixed(1)}%`:kw(n.avgDurationMs)}function Zl(n){return(n.run_config??{}).agent?.id??(n.virtual_mcp_id||null)}function ea(n,e,t,r){if(!n)return r;const s=e.find(i=>i.id===n)??t?.find(i=>i.id===n);if(s?.title)return s.title;const o=up(n);return o?dp(o).title??r:n}function ta(n,e,t){return n?(e.find(s=>s.id===n)??t?.find(s=>s.id===n))?.icon??null:null}function Wh(n){return n?.data?.members??[]}function Li(n){const e=_.c(33),{thread:t,connections:r,virtualMcps:s,selectedIndex:o,total:i,onPrev:l,onNext:a}=n;let c,u;if(e[0]!==r||e[1]!==t||e[2]!==s){const j=Zl(t);c=ea(j,s,r,""),u=ta(j,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=c,e[4]=u}else c=e[3],u=e[4];const d=u,f=c||t.title;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Ui,{}),e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==f?(m=p.jsx(qt,{icon:d,name:f,size:"sm",fallbackIcon:h,className:"shadow-sm shrink-0 rounded-md"}),e[6]=d,e[7]=f,e[8]=m):m=e[8];let g;e[9]!==t.title?(g=p.jsx(tu,{className:"text-sm leading-snug truncate",children:t.title}),e[9]=t.title,e[10]=g):g=e[10];let x;e[11]!==c?(x=c&&p.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:c}),e[11]=c,e[12]=x):x=e[12];let y;e[13]!==g||e[14]!==x?(y=p.jsxs("div",{className:"min-w-0",children:[g,x]}),e[13]=g,e[14]=x,e[15]=y):y=e[15];let b;e[16]!==m||e[17]!==y?(b=p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m,y]}),e[16]=m,e[17]=y,e[18]=b):b=e[18];const k=o===0;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Qo,{size:14}),e[19]=S):S=e[19];let v;e[20]!==l||e[21]!==k?(v=p.jsx(un,{size:"icon",variant:"ghost",onClick:l,disabled:k,className:"h-7 w-7 text-muted-foreground","aria-label":"Previous chat",children:S}),e[20]=l,e[21]=k,e[22]=v):v=e[22];const w=o===i-1;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Zr,{size:14}),e[23]=C):C=e[23];let T;e[24]!==a||e[25]!==w?(T=p.jsx(un,{size:"icon",variant:"ghost",onClick:a,disabled:w,className:"h-7 w-7 text-muted-foreground","aria-label":"Next chat",children:C}),e[24]=a,e[25]=w,e[26]=T):T=e[26];let N;e[27]!==v||e[28]!==T?(N=p.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[v,T]}),e[27]=v,e[28]=T,e[29]=N):N=e[29];let M;return e[30]!==N||e[31]!==b?(M=p.jsx(eu,{className:"px-5 md:px-6 pt-6 pb-5 border-b border-border shrink-0",children:p.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[b,N]})}),e[30]=N,e[31]=b,e[32]=M):M=e[32],M}function Sw(n){const e=_.c(48),{thread:t,connections:r,virtualMcps:s,members:o}=n;let i,l;if(e[0]!==r||e[1]!==t||e[2]!==s){const I=Zl(t);i=ea(I,s,r,""),l=ta(I,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=i,e[4]=l}else i=e[3],l=e[4];const a=l;let c;if(e[5]!==o||e[6]!==t.created_by){const I=Wh(o);let $;e[8]!==t.created_by?($=L=>L.userId===t.created_by,e[8]=t.created_by,e[9]=$):$=e[9],c=I.find($),e[5]=o,e[6]=t.created_by,e[7]=c}else c=e[7];const u=c;let d;e[10]!==u?.user.email||e[11]!==u?.user.name||e[12]!==t.created_by?(d=u?.user.name??u?.user.email??t.created_by?.substring(0,8)??"—",e[10]=u?.user.email,e[11]=u?.user.name,e[12]=t.created_by,e[13]=d):d=e[13];const f=d,h=u?.user.image??void 0;let m;e[14]!==t.created_at?(m=new Date(t.created_at).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e[14]=t.created_at,e[15]=m):m=e[15];const g=m,x=Rn[t.status]??Rn.completed,y=x.icon;let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Status"}),e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x.iconClassName?(k=p.jsx(y,{size:13,className:x.iconClassName}),e[17]=y,e[18]=x.iconClassName,e[19]=k):k=e[19];let S;e[20]!==x.labelColor?(S=ee("text-sm",x.labelColor),e[20]=x.labelColor,e[21]=S):S=e[21];let v;e[22]!==x.label||e[23]!==S?(v=p.jsx("span",{className:S,children:x.label}),e[22]=x.label,e[23]=S,e[24]=v):v=e[24];let w;e[25]!==k||e[26]!==v?(w=p.jsxs("div",{children:[b,p.jsxs("div",{className:"flex items-center gap-1.5",children:[k,v]})]}),e[25]=k,e[26]=v,e[27]=w):w=e[27];let C;e[28]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Date"}),e[28]=C):C=e[28];let T;e[29]!==g?(T=p.jsxs("div",{children:[C,p.jsx("div",{className:"text-sm text-foreground",children:g})]}),e[29]=g,e[30]=T):T=e[30];let N;e[31]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"User"}),e[31]=N):N=e[31];let M;e[32]!==h||e[33]!==f?(M=p.jsx(lu,{url:h,fallback:f,shape:"circle",size:"2xs",className:"shrink-0"}),e[32]=h,e[33]=f,e[34]=M):M=e[34];let j;e[35]!==f?(j=p.jsx("span",{className:"text-sm text-foreground",children:f}),e[35]=f,e[36]=j):j=e[36];let R;e[37]!==M||e[38]!==j?(R=p.jsxs("div",{children:[N,p.jsxs("div",{className:"flex items-center gap-2",children:[M,j]})]}),e[37]=M,e[38]=j,e[39]=R):R=e[39];let A;e[40]!==a||e[41]!==i?(A=i&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Agent"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(qt,{icon:a,name:i,size:"xs",fallbackIcon:p.jsx(Ui,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),p.jsx("span",{className:"text-sm text-foreground",children:i})]})]}),e[40]=a,e[41]=i,e[42]=A):A=e[42];let D;return e[43]!==T||e[44]!==R||e[45]!==A||e[46]!==w?(D=p.jsxs("div",{className:"px-5 md:px-6 py-5 border-b border-border grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4 text-sm",children:[w,T,R,A]}),e[43]=T,e[44]=R,e[45]=A,e[46]=w,e[47]=D):D=e[47],D}function vw(n){const e=_.c(72),{thread:t,usage:r,members:s,connections:o,virtualMcps:i,onClick:l,lastRowRef:a}=n;let c,u;if(e[0]!==o||e[1]!==t||e[2]!==i){const se=Zl(t);c=ea(se,i,o,"—"),u=ta(se,i,o),e[0]=o,e[1]=t,e[2]=i,e[3]=c,e[4]=u}else c=e[3],u=e[4];const d=u;let f;if(e[5]!==s||e[6]!==t.created_by){const se=Wh(s);let ae;e[8]!==t.created_by?(ae=Te=>Te.userId===t.created_by,e[8]=t.created_by,e[9]=ae):ae=e[9],f=se.find(ae),e[5]=s,e[6]=t.created_by,e[7]=f}else f=e[7];const h=f;let m;e[10]!==h?.user.email||e[11]!==h?.user.name||e[12]!==t.created_by?(m=h?.user.name??h?.user.email??t.created_by?.substring(0,8)??"—",e[10]=h?.user.email,e[11]=h?.user.name,e[12]=t.created_by,e[13]=m):m=e[13];const g=m,x=h?.user.image??void 0;let y,b;if(e[14]!==t.created_at){const se=new Date(t.created_at);y=se.toLocaleDateString("en-US",{month:"short",day:"numeric"}),b=se.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[14]=t.created_at,e[15]=y,e[16]=b}else y=e[15],b=e[16];const k=b,S=Rn[t.status]??Rn.completed,v=S.icon;let w;e[17]!==t.title?(w=p.jsx(Ge,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:t.title})}),e[17]=t.title,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Ui,{}),e[19]=C):C=e[19];let T;e[20]!==d||e[21]!==c?(T=p.jsx(qt,{icon:d,name:c,size:"xs",fallbackIcon:C,className:"shrink-0 size-5! min-w-5! rounded-md"}),e[20]=d,e[21]=c,e[22]=T):T=e[22];let N;e[23]!==c?(N=p.jsx("span",{className:"truncate",children:c}),e[23]=c,e[24]=N):N=e[24];let M;e[25]!==T||e[26]!==N?(M=p.jsx(Ge,{className:"w-36 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[T,N]})}),e[25]=T,e[26]=N,e[27]=M):M=e[27];let j;e[28]!==x||e[29]!==g?(j=p.jsx(lu,{url:x,fallback:g,shape:"circle",size:"2xs",className:"shrink-0"}),e[28]=x,e[29]=g,e[30]=j):j=e[30];let R;e[31]!==g?(R=p.jsx("span",{className:"truncate",children:g}),e[31]=g,e[32]=R):R=e[32];let A;e[33]!==j||e[34]!==R?(A=p.jsx(Ge,{className:"w-28 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[j,R]})}),e[33]=j,e[34]=R,e[35]=A):A=e[35];let D;e[36]!==v||e[37]!==S.iconClassName?(D=p.jsx(v,{size:14,className:S.iconClassName}),e[36]=v,e[37]=S.iconClassName,e[38]=D):D=e[38];let I;e[39]!==S.labelColor?(I=ee("text-sm",S.labelColor),e[39]=S.labelColor,e[40]=I):I=e[40];let $;e[41]!==S.label||e[42]!==I?($=p.jsx("span",{className:I,children:S.label}),e[41]=S.label,e[42]=I,e[43]=$):$=e[43];let L;e[44]!==D||e[45]!==$?(L=p.jsx(Ge,{className:"w-24 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[D,$]})}),e[44]=D,e[45]=$,e[46]=L):L=e[46];let z;e[47]!==r?(z=r?Yl(r.totalTokens):"—",e[47]=r,e[48]=z):z=e[48];let F;e[49]!==z?(F=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:z}),e[49]=z,e[50]=F):F=e[50];let U;e[51]!==r?(U=r&&r.costUsd>0?Ql(r.costUsd):"—",e[51]=r,e[52]=U):U=e[52];let Y;e[53]!==U?(Y=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:U}),e[53]=U,e[54]=Y):Y=e[54];let K;e[55]!==y?(K=p.jsx("div",{children:y}),e[55]=y,e[56]=K):K=e[56];let Q;e[57]!==k?(Q=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:k}),e[57]=k,e[58]=Q):Q=e[58];let ne;e[59]!==K||e[60]!==Q?(ne=p.jsxs(Ge,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[K,Q]}),e[59]=K,e[60]=Q,e[61]=ne):ne=e[61];let re;return e[62]!==a||e[63]!==l||e[64]!==A||e[65]!==L||e[66]!==F||e[67]!==Y||e[68]!==ne||e[69]!==w||e[70]!==M?(re=p.jsxs(Ks,{ref:a,className:"h-14 md:h-16 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:l,children:[w,M,A,L,F,Y,ne]}),e[62]=a,e[63]=l,e[64]=A,e[65]=L,e[66]=F,e[67]=Y,e[68]=ne,e[69]=w,e[70]=M,e[71]=re):re=e[71],re}const _i=100;function ww(n){const e=_.c(37),{client:t,locator:r,thread:s,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==r||e[1]!==s.id?(f=Qe.threadMessages(r,s.id),e[0]=r,e[1]=s.id,e[2]=f):f=e[2];let h;e[3]!==t||e[4]!==s.id?(h=async R=>{const{pageParam:A}=R,D=A===void 0?0:A;if(!t)throw new Error("MCP client is not available");const I=await t.callTool({name:"COLLECTION_THREAD_MESSAGES_LIST",arguments:{thread_id:s.id,limit:_i,offset:D}});return I.structuredContent??I},e[3]=t,e[4]=s.id,e[5]=h):h=e[5];let m;e[6]!==f||e[7]!==h?(m={queryKey:f,queryFn:h,initialPageParam:0,getNextPageParam:Nw,staleTime:6e4},e[6]=f,e[7]=h,e[8]=m):m=e[8];const{data:g,fetchNextPage:x,hasNextPage:y,isFetchingNextPage:b}=gp(m);let k;e[9]!==g.pages?(k=g.pages.flatMap(Tw).filter(Cw),e[9]=g.pages,e[10]=k):k=e[10];const S=k,v=tw(S);let w;e[11]!==x||e[12]!==y||e[13]!==b?(w=()=>{y&&!b&&x()},e[11]=x,e[12]=y,e[13]=b,e[14]=w):w=e[14];const C=Wi(w,y??!1,b);let T;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==s||e[20]!==c||e[21]!==i?(T=p.jsx(Li,{thread:s,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[15]=o,e[16]=d,e[17]=u,e[18]=a,e[19]=s,e[20]=c,e[21]=i,e[22]=T):T=e[22];let N;e[23]!==o||e[24]!==l||e[25]!==s||e[26]!==i?(N=p.jsx(Sw,{thread:s,connections:o,virtualMcps:i,members:l}),e[23]=o,e[24]=l,e[25]=s,e[26]=i,e[27]=N):N=e[27];let M;e[28]!==b||e[29]!==C||e[30]!==v||e[31]!==S.length?(M=S.length===0?p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No messages in this chat"}):p.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:p.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[v.map((R,A)=>p.jsx("div",{ref:A===v.length-1?C:void 0,children:p.jsx(nw,{pair:R,isLastPair:A===v.length-1,status:"ready"})},`pair-${R.user?.id??R.assistant?.id}`)),b&&p.jsx("div",{className:"py-4 text-center text-xs text-muted-foreground",children:"Loading more\\u2026"})]})}),e[28]=b,e[29]=C,e[30]=v,e[31]=S.length,e[32]=M):M=e[32];let j;return e[33]!==T||e[34]!==N||e[35]!==M?(j=p.jsxs(p.Fragment,{children:[T,N,M]}),e[33]=T,e[34]=N,e[35]=M,e[36]=j):j=e[36],j}function Cw(n){return n.role==="user"||n.role==="assistant"}function Tw(n){return n.items??[]}function Nw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<_i))return r.length*_i}function Uh(n){const e=_.c(39),{thread:t,client:r,locator:s,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==o||e[1]!==d||e[2]!==u||e[3]!==a||e[4]!==t||e[5]!==c||e[6]!==i?(f=p.jsx(Li,{thread:t,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[0]=o,e[1]=d,e[2]=u,e[3]=a,e[4]=t,e[5]=c,e[6]=i,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Failed to load messages"}),e[8]=h):h=e[8];let m;e[9]!==f?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[9]=f,e[10]=m):m=e[10];let g;e[11]!==o||e[12]!==d||e[13]!==u||e[14]!==a||e[15]!==t||e[16]!==c||e[17]!==i?(g=p.jsx(Li,{thread:t,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[11]=o,e[12]=d,e[13]=u,e[14]=a,e[15]=t,e[16]=c,e[17]=i,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Loading conversation\\u2026"}),e[19]=x):x=e[19];let y;e[20]!==g?(y=p.jsxs(p.Fragment,{children:[g,x]}),e[20]=g,e[21]=y):y=e[21];let b;e[22]!==r||e[23]!==o||e[24]!==s||e[25]!==l||e[26]!==d||e[27]!==u||e[28]!==a||e[29]!==t||e[30]!==c||e[31]!==i?(b=p.jsx(ww,{client:r,locator:s,thread:t,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[22]=r,e[23]=o,e[24]=s,e[25]=l,e[26]=d,e[27]=u,e[28]=a,e[29]=t,e[30]=c,e[31]=i,e[32]=b):b=e[32];let k;e[33]!==y||e[34]!==b?(k=p.jsx(E.Suspense,{fallback:y,children:b}),e[33]=y,e[34]=b,e[35]=k):k=e[35];let S;return e[36]!==m||e[37]!==k?(S=p.jsx(Xc,{fallback:m,children:k}),e[36]=m,e[37]=k,e[38]=S):S=e[38],S}const $i=50;function cT(n){const e=_.c(29),{client:t,locator:r,membersData:s,allConnections:o,allVirtualMcps:i,dateRange:l,searchQuery:a,filterAgentIds:c,filterUserIds:u,filterStatus:d}=n,[f,h]=E.useState(null),m=l.startDate.toISOString(),g=l.endDate.toISOString(),x=JSON.stringify({startDate:m,endDate:g,search:a,agentIds:c,userIds:u,status:d}),{data:y,fetchNextPage:b,hasNextPage:k,isFetchingNextPage:S,isLoading:v}=Qc({queryKey:Qe.threadsInfinite(r,x),queryFn:async J=>{const{pageParam:ie}=J,ue=ie===void 0?0:ie;if(!t)throw new Error("MCP client is not available");const it=await t.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:$i,offset:ue,startDate:m,endDate:g,...a?{search:a}:{},...c&&c.length>0?{agentId:c[0]}:{},...u&&u.length>0?{userId:u[0]}:{},...d&&d!=="all"?{status:d}:{}}});return it.structuredContent??it},initialPageParam:0,getNextPageParam:Ow,staleTime:3e4}),w=(y?.pages??[]).flatMap(Iw),C=w.map(jw),{data:T}=Mr({queryKey:Qe.monitoringThreadUsage(r,JSON.stringify({ids:C,startDate:m,endDate:g})),queryFn:async()=>{if(!t)throw new Error("MCP client is not available");const J=await t.callTool({name:"MONITORING_THREAD_USAGE",arguments:{threadIds:C,startDate:m,endDate:g}});return J.structuredContent??J},enabled:!!t&&C.length>0,staleTime:3e4}),N=new Map((T?.items??[]).map(Aw)),[M,j]=E.useState(null),[R,A]=E.useState("desc");let D;e[0]!==M?(D=J=>{M===J?A(Ew):(j(J),A("desc"))},e[0]=M,e[1]=D):D=e[1];const I=D,$=J=>{const ie=N.get(J);return ie?M==="cost"?ie.costUsd:ie.totalTokens:0},L=M?[...w].sort((J,ie)=>{const ue=$(J.id),it=$(ie.id);return R==="desc"?it-ue:ue-it}):w,z=f!==null?L[f]??null:null;let F;e[2]!==b||e[3]!==k||e[4]!==S?(F=()=>{k&&!S&&b()},e[2]=b,e[3]=k,e[4]=S,e[5]=F):F=e[5];const Y=Wi(F,k??!1,S),K=!!a||(c?.length??0)>0||(u?.length??0)>0||d&&d!=="all";let Q;e[6]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>h(Mw),e[6]=Q):Q=e[6];const ne=Q,re=()=>h(J=>J!==null&&J<L.length-1?J+1:J),se="flex-1 flex flex-col overflow-auto min-w-0",ae="mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",Te="flex-1 flex flex-col min-w-0",W="flex-1 min-w-0 pt-1",te="min-w-0",he=v?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading\\u2026"})}):w.length===0?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx(Yo,{title:K?"No matching chats":"No chats in this time range",description:K?"Try adjusting your filters or search query.":"Try expanding the time range to see older chats."})}):p.jsxs(p.Fragment,{children:[p.jsxs(nu,{className:"w-full border-collapse",children:[p.jsx(ru,{className:"border-b-0 z-20",children:p.jsxs(Ks,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Je,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Title"}),p.jsx(Je,{className:"w-36 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Agent"}),p.jsx(Je,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"User"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:p.jsxs("button",{type:"button",onClick:()=>I("tokens"),className:"inline-flex items-center gap-1 ml-auto hover:text-foreground transition-colors uppercase",children:["Tokens",M==="tokens"&&(R==="desc"?p.jsx(Zr,{size:12}):p.jsx(Qo,{size:12}))]})}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:p.jsxs("button",{type:"button",onClick:()=>I("cost"),className:"inline-flex items-center gap-1 ml-auto hover:text-foreground transition-colors uppercase",children:["Cost",M==="cost"&&(R==="desc"?p.jsx(Zr,{size:12}):p.jsx(Qo,{size:12}))]})}),p.jsx(Je,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Date"})]})}),p.jsx(su,{children:L.map((J,ie)=>p.jsx(vw,{thread:J,usage:N.get(J.id),members:s,connections:o,virtualMcps:i,onClick:()=>h(ie),lastRowRef:ie===L.length-1?Y:void 0},J.id))})]}),S&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more..."})]});let ge;e[7]!==he?(ge=p.jsx("div",{className:ae,children:p.jsx("div",{className:Te,children:p.jsx("div",{className:W,children:p.jsx("div",{className:te,children:he})})})}),e[7]=he,e[8]=ge):ge=e[8];const Be=f!==null;let Nt;e[9]===Symbol.for("react.memo_cache_sentinel")?(Nt=J=>{J||h(null)},e[9]=Nt):Nt=e[9];let Fe;e[10]!==o||e[11]!==i||e[12]!==t||e[13]!==L||e[14]!==re||e[15]!==ne||e[16]!==r||e[17]!==s||e[18]!==z||e[19]!==f?(Fe=z&&f!==null&&p.jsx(Uh,{thread:z,client:t,locator:r,connections:o,virtualMcps:i,members:s,selectedIndex:f,total:L.length,onPrev:ne,onNext:re}),e[10]=o,e[11]=i,e[12]=t,e[13]=L,e[14]=re,e[15]=ne,e[16]=r,e[17]=s,e[18]=z,e[19]=f,e[20]=Fe):Fe=e[20];let He;e[21]!==Fe?(He=p.jsx(Hi,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:Fe}),e[21]=Fe,e[22]=He):He=e[22];let Ve;e[23]!==Be||e[24]!==He?(Ve=p.jsx(Vi,{open:Be,onOpenChange:Nt,children:He}),e[23]=Be,e[24]=He,e[25]=Ve):Ve=e[25];let mt;return e[26]!==ge||e[27]!==Ve?(mt=p.jsxs("div",{className:se,children:[ge,Ve]}),e[26]=ge,e[27]=Ve,e[28]=mt):mt=e[28],mt}function Mw(n){return n!==null&&n>0?n-1:n}function Ew(n){return n==="desc"?"asc":"desc"}function Aw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function jw(n){return n.id}function Iw(n){return n.items??[]}function Ow(n,e){const t=n,r=e;if(!((t?.items?.length??0)<$i))return r.length*$i}const zi=50;function Kr(n){const e=_.c(10),{title:t,value:r,subtitle:s}=n;let o;e[0]!==t?(o=p.jsx("span",{className:"text-sm text-foreground/70",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==r?(i=p.jsx("span",{className:"text-3xl font-normal tabular-nums",children:r}),e[2]=r,e[3]=i):i=e[3];let l;e[4]!==s?(l=s&&p.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let a;return e[6]!==o||e[7]!==i||e[8]!==l?(a=p.jsxs(hp,{className:"pt-4 px-4 pb-5 gap-1",children:[o,i,l]}),e[6]=o,e[7]=i,e[8]=l,e[9]=a):a=e[9],a}function Rw(n){const e=_.c(27),{automationId:t,range:r}=n,{data:s,isLoading:o}=mp(t,r),i=s?.runs,l=s?.usage;let a;e[0]!==i?(a=i&&i.total>0?`${Math.round(i.completed/i.total*100)}%`:"—",e[0]=i,e[1]=a):a=e[1];const c=a,u=l&&l.truncated?`last ${l.sampledRuns} runs`:void 0;let d;e[2]!==o||e[3]!==i?.total?(d=o?"…":i?.total.toLocaleString()??"0",e[2]=o,e[3]=i?.total,e[4]=d):d=e[4];const f=i?`${i.completed} ok · ${i.failed} failed${i.inProgress>0?` · ${i.inProgress} running`:""}`:void 0;let h;e[5]!==d||e[6]!==f?(h=p.jsx(Kr,{title:"Runs",value:d,subtitle:f}),e[5]=d,e[6]=f,e[7]=h):h=e[7];const m=o?"…":c;let g;e[8]!==m?(g=p.jsx(Kr,{title:"Success rate",value:m}),e[8]=m,e[9]=g):g=e[9];let x;e[10]!==o||e[11]!==l?.totalTokens?(x=o?"…":Yl(l?.totalTokens??0),e[10]=o,e[11]=l?.totalTokens,e[12]=x):x=e[12];let y;e[13]!==x||e[14]!==u?(y=p.jsx(Kr,{title:"Tokens",value:x,subtitle:u}),e[13]=x,e[14]=u,e[15]=y):y=e[15];let b;e[16]!==o||e[17]!==l?(b=o?"…":l&&l.costUsd>0?Ql(l.costUsd):"—",e[16]=o,e[17]=l,e[18]=b):b=e[18];let k;e[19]!==b||e[20]!==u?(k=p.jsx(Kr,{title:"Cost",value:b,subtitle:u}),e[19]=b,e[20]=u,e[21]=k):k=e[21];let S;return e[22]!==k||e[23]!==h||e[24]!==g||e[25]!==y?(S=p.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[h,g,y,k]}),e[22]=k,e[23]=h,e[24]=g,e[25]=y,e[26]=S):S=e[26],S}function Dw(n){const e=_.c(39),{run:t,usage:r,onClick:s,lastRowRef:o}=n;let i,l;if(e[0]!==t.created_at){const T=new Date(t.created_at);i=T.toLocaleDateString("en-US",{month:"short",day:"numeric"}),l=T.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[0]=t.created_at,e[1]=i,e[2]=l}else i=e[1],l=e[2];const a=l,c=Rn[t.status]??Rn.completed,u=c.icon;let d;e[3]!==t.title?(d=p.jsx(Ge,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:t.title})}),e[3]=t.title,e[4]=d):d=e[4];let f;e[5]!==u||e[6]!==c.iconClassName?(f=p.jsx(u,{size:14,className:c.iconClassName}),e[5]=u,e[6]=c.iconClassName,e[7]=f):f=e[7];let h;e[8]!==c.labelColor?(h=ee("text-sm",c.labelColor),e[8]=c.labelColor,e[9]=h):h=e[9];let m;e[10]!==c.label||e[11]!==h?(m=p.jsx("span",{className:h,children:c.label}),e[10]=c.label,e[11]=h,e[12]=m):m=e[12];let g;e[13]!==f||e[14]!==m?(g=p.jsx(Ge,{className:"w-28 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[f,m]})}),e[13]=f,e[14]=m,e[15]=g):g=e[15];let x;e[16]!==r?(x=r?Yl(r.totalTokens):"—",e[16]=r,e[17]=x):x=e[17];let y;e[18]!==x?(y=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:x}),e[18]=x,e[19]=y):y=e[19];let b;e[20]!==r?(b=r&&r.costUsd>0?Ql(r.costUsd):"—",e[20]=r,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==i?(S=p.jsx("div",{children:i}),e[24]=i,e[25]=S):S=e[25];let v;e[26]!==a?(v=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:a}),e[26]=a,e[27]=v):v=e[27];let w;e[28]!==S||e[29]!==v?(w=p.jsxs(Ge,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[S,v]}),e[28]=S,e[29]=v,e[30]=w):w=e[30];let C;return e[31]!==o||e[32]!==s||e[33]!==k||e[34]!==w||e[35]!==d||e[36]!==g||e[37]!==y?(C=p.jsxs(Ks,{ref:o,className:"h-14 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:s,children:[d,g,y,k,w]}),e[31]=o,e[32]=s,e[33]=k,e[34]=w,e[35]=d,e[36]=g,e[37]=y,e[38]=C):C=e[38],C}function uT(n){const e=_.c(48),{automationId:t,triggerIds:r,range:s}=n,{org:o,locator:i}=Ct();let l;e[0]!==o.id||e[1]!==o.slug?(l={connectionId:fp,orgId:o.id,orgSlug:o.slug},e[0]=o.id,e[1]=o.slug,e[2]=l):l=e[2];const a=Fi(l),c=iu(),u=ip(),d=ap(),{data:f}=pp(),[h,m]=E.useState(null),g=r.length>0;let x;e[3]!==t||e[4]!==o.id||e[5]!==r?(x=Qe.automationRuns(o.id,t,r),e[3]=t,e[4]=o.id,e[5]=r,e[6]=x):x=e[6];let y;e[7]!==c||e[8]!==r?(y=async W=>{const{pageParam:te}=W,he=te===void 0?0:te;return await c.call("COLLECTION_THREADS_LIST",{limit:zi,offset:he,where:{trigger_ids:r}})},e[7]=c,e[8]=r,e[9]=y):y=e[9];let b;e[10]!==g||e[11]!==x||e[12]!==y?(b={queryKey:x,queryFn:y,initialPageParam:0,getNextPageParam:zw,enabled:g,staleTime:3e4},e[10]=g,e[11]=x,e[12]=y,e[13]=b):b=e[13];const{data:k,fetchNextPage:S,hasNextPage:v,isFetchingNextPage:w,isLoading:C}=Qc(b),T=(k?.pages??[]).flatMap($w),N=T.map(_w),{data:M}=Mr({queryKey:Qe.monitoringThreadUsage(i,JSON.stringify({ids:N,...s})),queryFn:async()=>await c.call("MONITORING_THREAD_USAGE",{threadIds:N,...s.startDate?{startDate:s.startDate}:{},...s.endDate?{endDate:s.endDate}:{}}),enabled:N.length>0,staleTime:3e4});let j;e[14]!==M?.items?(j=new Map((M?.items??[]).map(Lw)),e[14]=M?.items,e[15]=j):j=e[15];const R=j;let A;e[16]!==S||e[17]!==v||e[18]!==w?(A=()=>{v&&!w&&S()},e[16]=S,e[17]=v,e[18]=w,e[19]=A):A=e[19];const D=Wi(A,v??!1,w),I=h!==null?T[h]??null:null;let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=()=>m(Pw),e[20]=$):$=e[20];const L=$,z=()=>m(W=>W!==null&&W<T.length-1?W+1:W),F="flex flex-col gap-5";let U;e[21]!==t||e[22]!==s?(U=p.jsx(Rw,{automationId:t,range:s}),e[21]=t,e[22]=s,e[23]=U):U=e[23];const Y=g?C?p.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Loading runs…"}):T.length===0?p.jsx("div",{className:"py-16",children:p.jsx(Yo,{title:"No runs yet",description:"This automation hasn't run yet. Trigger it or wait for a starter to fire."})}):p.jsxs(nu,{className:"w-full border-collapse",children:[p.jsx(ru,{className:"border-b-0",children:p.jsxs(Ks,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Je,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Run"}),p.jsx(Je,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Tokens"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Cost"}),p.jsx(Je,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Started"})]})}),p.jsx(su,{children:T.map((W,te)=>p.jsx(Dw,{run:W,usage:R.get(W.id),onClick:()=>m(te),lastRowRef:te===T.length-1?D:void 0},W.id))})]}):p.jsx("div",{className:"py-16",children:p.jsx(Yo,{title:"No starters yet",description:"Add a starter (cron, event, or webhook) to start collecting runs."})});let K;e[24]!==w?(K=w&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more…"}),e[24]=w,e[25]=K):K=e[25];const Q=h!==null;let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=W=>{W||m(null)},e[26]=ne):ne=e[26];let re;e[27]!==u||e[28]!==d||e[29]!==a||e[30]!==z||e[31]!==L||e[32]!==i||e[33]!==f||e[34]!==T||e[35]!==I||e[36]!==h?(re=I&&h!==null&&p.jsx(Uh,{thread:I,client:a,locator:i,connections:u,virtualMcps:d,members:f,selectedIndex:h,total:T.length,onPrev:L,onNext:z}),e[27]=u,e[28]=d,e[29]=a,e[30]=z,e[31]=L,e[32]=i,e[33]=f,e[34]=T,e[35]=I,e[36]=h,e[37]=re):re=e[37];let se;e[38]!==re?(se=p.jsx(Hi,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:re}),e[38]=re,e[39]=se):se=e[39];let ae;e[40]!==Q||e[41]!==se?(ae=p.jsx(Vi,{open:Q,onOpenChange:ne,children:se}),e[40]=Q,e[41]=se,e[42]=ae):ae=e[42];let Te;return e[43]!==Y||e[44]!==K||e[45]!==ae||e[46]!==U?(Te=p.jsxs("div",{className:F,children:[U,Y,K,ae]}),e[43]=Y,e[44]=K,e[45]=ae,e[46]=U,e[47]=Te):Te=e[47],Te}function Pw(n){return n!==null&&n>0?n-1:n}function Lw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function _w(n){return n.id}function $w(n){return n.items??[]}function zw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<zi))return r.length*zi}export{cT as $,sT as A,ZC as B,tT as C,de as D,Ml as E,Wb as F,LS as G,xe as H,RS as I,DS as J,PS as K,uT as L,uo as M,GS as N,Ov as O,Nm as P,oT as Q,OS as R,QC as S,eT as T,iT as U,Yl as V,Ql as W,kw as X,aT as Y,lT as Z,Wh as _,Hf as a,ve as b,Ff as c,wm as d,fe as e,YC as f,Yi as g,De as h,XC as i,KC as j,GC as k,$b as l,JC as m,Bb as n,MS as o,Df as p,qC as q,tw as r,Qi as s,Cu as t,jb as u,Sm as v,nT as w,nw as x,rT as y,Iv as z};
188
+ … (${f.length-Go} more characters)`:f,e[5]=t.input,e[6]=a}else a=e[6];const c=a;let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(au,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==o||e[10]!==l?(d=p.jsx(Z,{icon:u,title:o,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=o,e[10]=l,e[11]=d):d=e[11],d}function z2(n){const e=_.c(12),{jobId:t,prompt:r,items:s,streaming:o}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=i):i=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[i,p.jsx("p",{className:"text-[13px] text-foreground/90 whitespace-pre-wrap wrap-break-word",children:r})]}),e[1]=r,e[2]=l):l=e[2];let a;e[3]!==s||e[4]!==t||e[5]!==o?(a=s.length===0?p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic py-1",children:"Running in the background…"}):s.map((d,f)=>{const h=d,m=h.type??"";return m==="text"?h.text?.trim()?p.jsx(uo,{id:`${t}-sub-${f}`,part:d,animate:o},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx($2,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=o,e[6]=a):a=e[6];let c;e[7]!==a?(c=p.jsx("section",{className:"flex flex-col gap-3 sm:gap-2",children:a}),e[7]=a,e[8]=c):c=e[8];let u;return e[9]!==l||e[10]!==c?(u=p.jsxs("div",{className:"flex flex-col gap-4",children:[l,c]}),e[9]=l,e[10]=c,e[11]=u):u=e[11],u}function Nh(n){const e=_.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=_p(),{org:o}=Ct(),[i,l]=E.useState(!1),a=D2(r);let c;e[0]!==r||e[1]!==i||e[2]!==o.slug||e[3]!==s?(c={orgSlug:o.slug,threadId:s,jobId:r,enabled:i},e[0]=r,e[1]=i,e[2]=o.slug,e[3]=s,e[4]=c):c=e[4];const u=L2(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(F2),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(B2),e[7]=a,e[8]=h):h=e[8];const m=h,g=f.length>0?f:m,x=t.input?.prompt??"No prompt provided";let y;e[9]!==x?(y=x.length>120?`${x.slice(0,120)}…`:x,e[9]=x,e[10]=y):y=e[10];const b=y,k=a.length===0;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(qt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(Xi,{})}),e[11]=S):S=e[11];const v=k?"loading":"idle",w=u.streaming||k;let C;e[12]!==g||e[13]!==r||e[14]!==x||e[15]!==w?(C=p.jsx(z2,{jobId:r,prompt:x,items:g,streaming:w}),e[12]=g,e[13]=r,e[14]=x,e[15]=w,e[16]=C):C=e[16];let T;return e[17]!==b||e[18]!==v||e[19]!==C?(T=p.jsx(Ul,{icon:S,title:"Subtask",summary:b,state:v,onOpenChange:l,children:C}),e[17]=b,e[18]=v,e[19]=C,e[20]=T):T=e[20],T}function B2(n){return n.parts??[]}function F2(n){return n.parts??[]}function H2(n){const e=_.c(13);if(wh(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Nh,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=Ch(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:o,state:i}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(qt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(Xi,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(Th,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==i||e[9]!==s||e[10]!==a||e[11]!==o?(c=p.jsx(Ul,{icon:l,title:r,summary:s,state:i,usage:o,children:a}),e[7]=r,e[8]=i,e[9]=s,e[10]=a,e[11]=o,e[12]=c):c=e[12],c}function V2(n){const e=_.c(17),t=Zc(n.part.input?.agent_id);if(wh(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Nh,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=Ch(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:o,usage:i,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Xi,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(qt,{icon:a,name:c,size:"2xs",className:"rounded-xs",fallbackIcon:u}),e[5]=a,e[6]=c,e[7]=d):d=e[7];const f=t?.title??s;let h;e[8]!==n.part?(h=p.jsx(Th,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==o||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==i?(m=p.jsx(Ul,{icon:d,title:f,summary:o,state:l,usage:i,children:h}),e[10]=l,e[11]=o,e[12]=d,e[13]=f,e[14]=h,e[15]=i,e[16]=m):m=e[16],m}function W2(n){const e=_.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",o=t.output?.approved===!0;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(Zo,{className:"size-4 text-purple-500 shrink-0"}),l=p.jsx("span",{className:"text-[14px] font-medium text-foreground/80",children:"Implementation Plan"}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let a;e[2]!==o?(a=o&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-success bg-success/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(qi,{size:12}),"Approved"]}),e[2]=o,e[3]=a):a=e[3];let c;e[4]!==o||e[5]!==t.state?(c=!o&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=o,e[5]=t.state,e[6]=c):c=e[6];let u;e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[i,l,a,c]}),e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground transition-colors",children:"View plan"}),e[10]=d):d=e[10];let f;e[11]!==r?(f=p.jsxs("details",{className:"ml-6",children:[d,p.jsx("div",{className:"mt-1 pl-2 border-l-2 border-purple-500/30 prose prose-sm max-w-none text-sm",children:p.jsx(uo,{id:"plan-content",part:{type:"text",text:r}})})]}),e[11]=r,e[12]=f):f=e[12];let h;return e[13]!==u||e[14]!==f?(h=p.jsxs("div",{className:"my-1.5 flex flex-col gap-1",children:[u,f]}),e[13]=u,e[14]=f,e[15]=h):h=e[15],h}const ql={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function U2(n){return n.startsWith("http")?n:`https://${n}`}function Hc(n){const e=_.c(2),{children:t}=n;let r;return e[0]!==t?(r=p.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),e[0]=t,e[1]=r):r=e[1],r}function q2(n){const e=_.c(12),{name:t,value:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"size-7 shrink-0 rounded-md border border-border",style:{backgroundColor:r},"aria-hidden":!0}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=i):i=e[5];let l;e[6]!==o||e[7]!==i?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[o,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8];let a;return e[9]!==s||e[10]!==l?(a=p.jsxs("div",{className:"flex items-center gap-2.5",children:[s,l]}),e[9]=s,e[10]=l,e[11]=a):a=e[11],a}function K2(n){const e=_.c(15),{role:t,family:r}=n;let s;e[0]!==r?(s=p.jsx("span",{className:"text-2xl font-medium leading-none text-foreground shrink-0",style:{fontFamily:r},"aria-hidden":!0,children:"Aa"}),e[0]=r,e[1]=s):s=e[1];let o;e[2]!==t?(o=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=o):o=e[3];let i;e[4]!==r?(i={fontFamily:r},e[4]=r,e[5]=i):i=e[5];let l;e[6]!==r||e[7]!==i?(l=p.jsx("span",{className:"text-sm text-foreground",style:i,children:r}),e[6]=r,e[7]=i,e[8]=l):l=e[8];let a;e[9]!==o||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[o,l]}),e[9]=o,e[10]=l,e[11]=a):a=e[11];let c;return e[12]!==s||e[13]!==a?(c=p.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted px-4 py-3",children:[s,a]}),e[12]=s,e[13]=a,e[14]=c):c=e[14],c}function J2(n){const e=_.c(3),{logo:t,favicon:r,name:s}=n,o=t??r;if(!o)return null;const i=s?`${s} logo`:"";let l;return e[0]!==o||e[1]!==i?(l=p.jsx("img",{src:o,alt:i,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:G2}),e[0]=o,e[1]=i,e[2]=l):l=e[2],l}function G2(n){n.target.style.display="none"}function Mh(n){const e=_.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(Y2),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let o;return e[2]!==s?(o=p.jsx("div",{className:"flex h-1.5",children:s.map(X2)}),e[2]=s,e[3]=o):o=e[3],o}function X2(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${ql[e]}: ${t}`,"aria-hidden":!0},e)}function Y2(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Eh(n){const e=_.c(36),{logo:t,favicon:r,name:s,domain:o,overview:i,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(tv):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(ev):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(Mh,{colors:l}),e[4]=l,e[5]=g):g=e[5];let x;e[6]!==r||e[7]!==t||e[8]!==s?(x=p.jsx(J2,{logo:t,favicon:r,name:s}),e[6]=r,e[7]=t,e[8]=s,e[9]=x):x=e[9];let y;e[10]!==u||e[11]!==s||e[12]!==c?(y=s&&p.jsxs("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-foreground truncate",children:[s,c&&u&&p.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[p.jsx(xu,{className:"size-3 text-amber-500"}),"default"]})]}),e[10]=u,e[11]=s,e[12]=c,e[13]=y):y=e[13];let b;e[14]!==o?(b=o&&p.jsxs("a",{href:U2(o),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[o,p.jsx(bu,{className:"size-3 shrink-0"})]}),e[14]=o,e[15]=b):b=e[15];let k;e[16]!==y||e[17]!==b?(k=p.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[y,b]}),e[16]=y,e[17]=b,e[18]=k):k=e[18];let S;e[19]!==x||e[20]!==k?(S=p.jsxs("div",{className:"flex items-center gap-4",children:[x,k]}),e[19]=x,e[20]=k,e[21]=S):S=e[21];let v;e[22]!==i?(v=i&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:i}),e[22]=i,e[23]=v):v=e[23];let w;e[24]!==f?(w=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Hc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(Z2)})]}),e[24]=f,e[25]=w):w=e[25];let C;e[26]!==m?(C=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Hc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(Q2)})]}),e[26]=m,e[27]=C):C=e[27];let T;e[28]!==w||e[29]!==C||e[30]!==S||e[31]!==v?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[S,v,w,C]}),e[28]=w,e[29]=C,e[30]=S,e[31]=v,e[32]=T):T=e[32];let N;return e[33]!==T||e[34]!==g?(N=p.jsxs("div",{className:"mt-2 rounded-lg overflow-hidden border border-border",children:[g,T]}),e[33]=T,e[34]=g,e[35]=N):N=e[35],N}function Q2(n){const[e,t]=n;return p.jsx(K2,{role:e,family:t},e)}function Z2(n){const[e,t]=n;return p.jsx(q2,{name:ql[e],value:t},e)}function ev(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function tv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function nv(n){const e=_.c(29),{part:t,latency:r}=n,s=ot(t.state);let o;e[0]!==t.output?(o=Un(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){const C=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(dt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=C?.domain?`from ${C.domain}`:void 0;let M;return e[3]!==N?(M=p.jsx(Z,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=M):M=e[4],M}if(a){let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(dt,{}),e[5]=C):C=e[5];const T=i?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[6]=r,e[7]=N):N=e[7];let M;return e[8]!==T||e[9]!==N?(M=p.jsx(Z,{icon:C,title:"Brand extraction failed",summary:T,state:"error",trailing:N}),e[8]=T,e[9]=N,e[10]=M):M=e[10],M}let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(dt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=i?.name?`Brand set: ${i.name}`:"Brand context set",d=i?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[12]=r,e[13]=f):f=e[13];let h;e[14]!==u||e[15]!==d||e[16]!==f?(h=p.jsx(Z,{icon:c,title:u,summary:d,state:"idle",trailing:f}),e[14]=u,e[15]=d,e[16]=f,e[17]=h):h=e[17];const m=i?.logo,g=i?.favicon,x=i?.name,y=i?.domain,b=i?.overview,k=i?.colors,S=i?.fonts;let v;e[18]!==y||e[19]!==b||e[20]!==k||e[21]!==S||e[22]!==m||e[23]!==g||e[24]!==x?(v=p.jsx(Eh,{logo:m,favicon:g,name:x,domain:y,overview:b,colors:k,fonts:S}),e[18]=y,e[19]=b,e[20]=k,e[21]=S,e[22]=m,e[23]=g,e[24]=x,e[25]=v):v=e[25];let w;return e[26]!==v||e[27]!==h?(w=p.jsxs(p.Fragment,{children:[h,v]}),e[26]=v,e[27]=h,e[28]=w):w=e[28],w}function rv(n){const e=_.c(27),{part:t,latency:r}=n,s=ot(t.state);let o;e[0]!==t.output?(o=Un(t.output),e[0]=t.output,e[1]=o):o=e[1];const i=o,l=s==="loading",a=s==="error"||i&&i.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(Z,{icon:p.jsx(dt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!i){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(dt,{}),e[3]=g):g=e[3];let x;e[4]!==r?(x=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[4]=r,e[5]=x):x=e[5];let y;return e[6]!==x?(y=p.jsx(Z,{icon:g,title:"Couldn't load brand",state:"error",trailing:x}),e[6]=x,e[7]=y):y=e[7],y}let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(dt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=i.name?`Brand · ${i.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==i.domain||e[12]!==u||e[13]!==d?(f=p.jsx(Z,{icon:c,title:u,summary:i.domain,state:"idle",trailing:d}),e[11]=i.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==i.colors||e[16]!==i.domain||e[17]!==i.favicon||e[18]!==i.fonts||e[19]!==i.isDefault||e[20]!==i.logo||e[21]!==i.name||e[22]!==i.overview?(h=p.jsx(Eh,{logo:i.logo,favicon:i.favicon,name:i.name,domain:i.domain,overview:i.overview,colors:i.colors,fonts:i.fonts,showDefaultBadge:!0,isDefault:i.isDefault}),e[15]=i.colors,e[16]=i.domain,e[17]=i.favicon,e[18]=i.fonts,e[19]=i.isDefault,e[20]=i.logo,e[21]=i.name,e[22]=i.overview,e[23]=h):h=e[23];let m;return e[24]!==f||e[25]!==h?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[24]=f,e[25]=h,e[26]=m):m=e[26],m}function sv(n){const e=_.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=ot(t.state),e[0]=t.state,e[1]=s):s=e[1];const o=s;let i,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==o){c=Symbol.for("react.early_return_sentinel");e:{const f=Un(t.output),h=Array.isArray(f?.items)?f.items:[],m=o==="loading",g=o==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Z,{icon:p.jsx(dt,{className:"animate-pulse"}),title:"Loading brands",state:"loading"}),e[9]=k):k=e[9],c=k;break e}if(g){let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(dt,{}),e[10]=k):k=e[10];let S;e[11]!==r?(S=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[11]=r,e[12]=S):S=e[12];let v;e[13]!==S?(v=p.jsx(Z,{icon:k,title:"Couldn't load brands",state:"error",trailing:S}),e[13]=S,e[14]=v):v=e[14],c=v;break e}if(h.length===0){let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(dt,{}),e[15]=k):k=e[15];let S;e[16]!==r?(S=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[16]=r,e[17]=S):S=e[17];let v;e[18]!==S?(v=p.jsx(Z,{icon:k,title:"No brands yet",summary:"The organization hasn't set up any brand context.",state:"idle",trailing:S}),e[18]=S,e[19]=v):v=e[19],c=v;break e}let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx(dt,{className:"text-fuchsia-500"}),e[20]=x):x=e[20];const y=h.length===1?"1 brand":`${h.length} brands`;let b;e[21]!==r?(b=r!=null&&r>0?p.jsx(Ie,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==y||e[24]!==b?(a=p.jsx(Z,{icon:x,title:y,state:"idle",trailing:b}),e[23]=y,e[24]=b,e[25]=a):a=e[25],i="mt-2 flex flex-col gap-1.5",l=h.map(ov)}e[2]=r,e[3]=t.output,e[4]=o,e[5]=i,e[6]=l,e[7]=a,e[8]=c}else i=e[5],l=e[6],a=e[7],c=e[8];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;e[26]!==i||e[27]!==l?(u=p.jsx("div",{className:i,children:l}),e[26]=i,e[27]=l,e[28]=u):u=e[28];let d;return e[29]!==a||e[30]!==u?(d=p.jsxs(p.Fragment,{children:[a,u]}),e[29]=a,e[30]=u,e[31]=d):d=e[31],d}function ov(n){const e=n.colors?Object.entries(n.colors).filter(av):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(Mh,{colors:n.colors}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[(n.logo||n.favicon)&&p.jsx("img",{src:n.logo??n.favicon??void 0,alt:"",className:"size-8 shrink-0 rounded-md border border-border bg-background object-contain p-0.5",onError:lv}),p.jsxs("div",{className:"flex flex-col leading-tight min-w-0 flex-1",children:[p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-foreground truncate",children:[n.name??"Untitled",n.isDefault&&p.jsx(xu,{className:"size-3 text-amber-500 shrink-0"})]}),n.domain&&p.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:n.domain})]}),e.length>0&&p.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:e.slice(0,5).map(iv)})]})]},n.id??`${n.name}-${n.domain}`)}function iv(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${ql[e]}: ${t}`,"aria-hidden":!0},e)}function lv(n){n.target.style.display="none"}function av(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function Pi(n){const e=_.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,o=Zc(t);if(!o)return null;let i;return e[0]!==o.icon||e[1]!==o.title||e[2]!==s?(i=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(qt,{icon:o.icon,name:o.title,size:s})}),e[0]=o.icon,e[1]=o.title,e[2]=s,e[3]=i):i=e[3],i}Pi.Fallback=function({iconSize:e="xs"}){const t=e==="sm"?"size-6":"size-5";return p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:ee(t,"rounded bg-muted animate-pulse")})})};function Tr(n){const e=_.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:o}=n,i=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==o||e[1]!==t||e[2]!==l||e[3]!==i){const h=t.slice(0,i);a=t.length-i,e[7]!==o?(c=ee("flex items-center justify-end -space-x-2",o),e[7]=o,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(E.Suspense,{fallback:p.jsx(Pi.Fallback,{iconSize:l}),children:p.jsx(Pi,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=o,e[1]=t,e[2]=l,e[3]=i,e[4]=a,e[5]=c,e[6]=u}else a=e[4],c=e[5],u=e[6];let d;e[11]!==l||e[12]!==a?(d=a>0&&p.jsx("div",{className:ee("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",l==="sm"?"size-8":"size-6"),children:p.jsxs("span",{className:ee(l==="sm"?"text-sm":"text-xs","font-medium text-muted-foreground"),"aria-label":`and ${a} more`,children:["+",a]})}),e[11]=l,e[12]=a,e[13]=d):d=e[13];let f;return e[14]!==c||e[15]!==u||e[16]!==d?(f=p.jsxs("div",{className:c,children:[u,d]}),e[14]=c,e[15]=u,e[16]=d,e[17]=f):f=e[17],f}Tr.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",o=r==="sm"?"size-8":"size-6",i=t!==void 0&&t>e;return p.jsxs("div",{className:"flex items-center -space-x-2",children:[Array.from({length:e}).map((l,a)=>p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx("div",{className:ee(s,"rounded bg-muted animate-pulse")})},a)),i&&p.jsx("div",{className:ee("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",o),children:p.jsx("div",{className:ee(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const cv="This document certifies that the bearer agent has been granted authorized access to the tools and capabilities described herein. The agent is permitted to operate within the scope defined by its instructions and shall act in accordance with the constraints set forth by the issuing organization. This credential remains valid for the duration of the agent's active status. Unauthorized modification of this agent's permissions or scope is prohibited. The issuing authority reserves the right to revoke access at any time. All actions performed by this agent are subject to audit and review by the organization administrator. ",Vc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function uv(n){const e=_.c(64),{part:t,latency:r}=n,s=ku(),o=ot(t.state),i=E.useRef(null),l=E.useRef(null),a=E.useRef(null),c=E.useRef(null),u=E.useRef(null);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{Vc?.matches||(u.current=i.current?.getBoundingClientRect()??null,i.current&&(i.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=W=>{if(Vc?.matches)return;const te=u.current,he=i.current;if(!te||!he)return;const ge=(W.clientX-te.left)/te.width*100,Be=(W.clientY-te.top)/te.height*100;he.style.transform=`perspective(800px) rotateY(${(ge-50)*.05}deg) rotateX(${(Be-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(ge-50)*.15}px, ${(Be-50)*.15}px)`),a.current&&(a.current.style.opacity="0.45"),c.current&&(c.current.style.opacity="0.45")},e[1]=h):h=e[1];const m=h;let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const W=i.current;W&&(W.style.transform="none",W.style.willChange="auto"),l.current&&(l.current.style.opacity="0.4",l.current.style.transform="translate(0, 0)"),a.current&&(a.current.style.opacity="0.3"),c.current&&(c.current.style.opacity="0.3"),u.current=null},e[2]=g):g=e[2];const x=g;if(o==="loading"){let W;return e[3]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(Z,{icon:p.jsx(ut,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=W):W=e[3],W}if(o==="approval"){let W;return e[4]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(Z,{icon:p.jsx(ut,{}),title:"Create agent",state:"idle"}),e[4]=W):W=e[4],W}if(o==="error"){let W;e[5]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(ut,{}),e[5]=W):W=e[5];const te=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let he;e[6]!==r?(he=p.jsx(Ie,{latency:r}),e[6]=r,e[7]=he):he=e[7];let ge;return e[8]!==te||e[9]!==he?(ge=p.jsx(Z,{icon:W,title:te,state:"error",trailing:he}),e[8]=te,e[9]=he,e[10]=ge):ge=e[10],ge}let y,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(y=Un(t.output)?.item,!y?.id||!y?.title){let W;e[16]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx(ut,{}),e[16]=W):W=e[16];let te;e[17]!==r?(te=p.jsx(Z,{icon:W,title:"Agent created",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[17]=r,e[18]=te):te=e[18],k=te;break e}b=(y.connections??[]).map(dv)}e[11]=r,e[12]=t.output,e[13]=y,e[14]=b,e[15]=k}else y=e[13],b=e[14],k=e[15];if(k!==Symbol.for("react.early_return_sentinel"))return k;const S=b;let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ut,{className:"text-success"}),e[19]=v):v=e[19];const w=`Agent created: ${y.title}`;let C;e[20]!==r?(C=p.jsx(Ie,{latency:r}),e[20]=r,e[21]=C):C=e[21];let T;e[22]!==w||e[23]!==C?(T=p.jsx(Z,{icon:v,title:w,state:"idle",trailing:C}),e[22]=w,e[23]=C,e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N={transition:"transform 0.3s ease-out"},e[25]=N):N=e[25];let M;e[26]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsx("div",{ref:l,className:"pointer-events-none absolute inset-[-20%] z-[1] select-none rounded-lg",style:{background:"linear-gradient(135deg, hsla(280, 60%, 80%, 0.35) 0%, transparent 35%), linear-gradient(315deg, hsla(190, 70%, 80%, 0.35) 0%, transparent 35%), linear-gradient(225deg, hsla(140, 55%, 80%, 0.3) 0%, transparent 30%), linear-gradient(45deg, hsla(320, 55%, 82%, 0.3) 0%, transparent 30%)",opacity:.4,transition:"opacity 0.3s ease, transform 0.3s ease-out"},"aria-hidden":"true"}),e[26]=M):M=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j={textAlign:"justify",wordBreak:"break-all"},e[27]=j):j=e[27];let R,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx("p",{className:"pointer-events-none absolute inset-0 z-[1] select-none overflow-hidden text-[6px] font-light leading-[1.5] tracking-[0.06px] text-background opacity-50 mix-blend-overlay",style:j,"aria-hidden":"true",children:cv.repeat(6)}),A=p.jsx("img",{src:"/stamp.svg",alt:"",className:"pointer-events-none absolute -right-10 -top-10 size-[140px] opacity-50 select-none","aria-hidden":"true"}),e[28]=R,e[29]=A):(R=e[28],A=e[29]);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx("img",{ref:a,src:"/left-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 left-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[30]=D):D=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=p.jsx("img",{ref:c,src:"/right-guilloche.png",alt:"",className:"pointer-events-none absolute inset-y-0 right-0 h-full w-auto select-none z-[1] mix-blend-overlay",style:{opacity:.3,transition:"opacity 0.3s ease"},"aria-hidden":"true"}),e[31]=I):I=e[31];let $;e[32]!==y.icon||e[33]!==y.title?($=p.jsx(uu,{icon:y.icon,name:y.title,size:"md"}),e[32]=y.icon,e[33]=y.title,e[34]=$):$=e[34];let L;e[35]!==y.title?(L=p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:y.title})}),e[35]=y.title,e[36]=L):L=e[36];let z;e[37]!==$||e[38]!==L?(z=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[$,L]}),e[37]=$,e[38]=L,e[39]=z):z=e[39];let F;e[40]!==y.description?(F=y.description&&p.jsx("div",{className:"px-2 pt-1 pr-16",children:p.jsx("p",{className:"text-sm leading-snug text-muted-foreground line-clamp-2",children:y.description})}),e[40]=y.description,e[41]=F):F=e[41];let U;e[42]!==z||e[43]!==F?(U=p.jsxs("div",{className:"relative",children:[z,F]}),e[42]=z,e[43]=F,e[44]=U):U=e[44];let Y;e[45]!==S?(Y=S.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Tr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:S.length}),children:p.jsx(Tr,{connectionIds:S,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=S,e[46]=Y):Y=e[46];let K;e[47]!==Y?(K=p.jsx("div",{className:"flex-1 min-w-0",children:Y}),e[47]=Y,e[48]=K):K=e[48];let Q;e[49]!==y.id||e[50]!==s?(Q=()=>s(y.id),e[49]=y.id,e[50]=s,e[51]=Q):Q=e[51];const ne=`See agent: ${y.title}`;let re;e[52]!==Q||e[53]!==ne?(re=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(un,{size:"sm",className:"h-7",onClick:Q,"aria-label":ne,children:"See agent"})}),e[52]=Q,e[53]=ne,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==re?(se=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[K,re]}),e[55]=K,e[56]=re,e[57]=se):se=e[57];let ae;e[58]!==U||e[59]!==se?(ae=p.jsx("div",{className:"mt-2 overflow-hidden rounded-xl border-[0.5px] border-border bg-card p-2.5",children:p.jsxs("div",{ref:i,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:x,children:[M,R,A,D,I,U,se]})}),e[58]=U,e[59]=se,e[60]=ae):ae=e[60];let Te;return e[61]!==ae||e[62]!==T?(Te=p.jsxs(p.Fragment,{children:[T,ae]}),e[61]=ae,e[62]=T,e[63]=Te):Te=e[63],Te}function dv(n){return n.connection_id}function fv(n){const e=_.c(24),{agent:t}=n,r=ku();if(!t.id)return null;let s;e[0]!==t.connections?(s=t.connections??[],e[0]=t.connections,e[1]=s):s=e[1];let o;e[2]!==s?(o=s.map(hv),e[2]=s,e[3]=o):o=e[3];const i=o;let l;e[4]!==t.id||e[5]!==r?(l=()=>r(t.id),e[4]=t.id,e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t.icon||e[8]!==t.title?(a=p.jsx(uu,{icon:t.icon,name:t.title,size:"sm"}),e[7]=t.icon,e[8]=t.title,e[9]=a):a=e[9];let c;e[10]!==t.title?(c=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[10]=t.title,e[11]=c):c=e[11];let u;e[12]!==t.description?(u=t.description&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.description}),e[12]=t.description,e[13]=u):u=e[13];let d;e[14]!==c||e[15]!==u?(d=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16];let f;e[17]!==i?(f=i.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Tr.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:i.length}),children:p.jsx(Tr,{connectionIds:i,iconSize:"xs",maxVisibleIcons:3})}),e[17]=i,e[18]=f):f=e[18];let h;return e[19]!==l||e[20]!==a||e[21]!==d||e[22]!==f?(h=p.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[a,d,f]}),e[19]=l,e[20]=a,e[21]=d,e[22]=f,e[23]=h):h=e[23],h}function hv(n){return n.connection_id}function pv(n){const e=_.c(41),{part:t,latency:r}=n,s=Vn(),{org:o}=Ct();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const y=Un(t.output);if(c=Array.isArray(y?.items)?y.items:[],l==="loading"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(ut,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="approval"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(ut,{}),title:"List agents",state:"idle"}),e[13]=w):w=e[13],h=w;break e}if(l==="error"){let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(ut,{}),e[14]=w):w=e[14];const C=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx(Ie,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==C||e[18]!==T?(N=p.jsx(Z,{icon:w,title:C,state:"error",trailing:T}),e[17]=C,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(ut,{}),e[20]=w):w=e[20];let C;e[21]!==r?(C=p.jsx(Z,{icon:w,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[21]=r,e[22]=C):C=e[22],h=C;break e}const b=c.slice(0,gh);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ut,{className:"text-success"}),e[23]=k):k=e[23];const S=c.length===1?"1 agent":`${c.length} agents`;let v;e[24]!==r?(v=p.jsx(Ie,{latency:r}),e[24]=r,e[25]=v):v=e[25],e[26]!==S||e[27]!==v?(f=p.jsx(Z,{icon:k,title:S,state:"idle",trailing:v}),e[26]=S,e[27]=v,e[28]=f):f=e[28],u="mt-2 flex flex-col gap-1.5",d=b.map(mv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[29]!==a||e[30]!==c||e[31]!==s||e[32]!==o?(m=a>0&&p.jsx(xh,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:o.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=o,e[33]=m):m=e[33];let g;e[34]!==u||e[35]!==d||e[36]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[34]=u,e[35]=d,e[36]=m,e[37]=g):g=e[37];let x;return e[38]!==f||e[39]!==g?(x=p.jsxs(p.Fragment,{children:[f,g]}),e[38]=f,e[39]=g,e[40]=x):x=e[40],x}function mv(n){return p.jsx(fv,{agent:n},n.id)}const gv={active:"bg-success",inactive:"bg-muted-foreground",error:"bg-destructive"};function xv(n){const e=_.c(27),{connection:t}=n,r=Vn(),{org:s}=Ct(),o=t.slug,i=t.description||t.app_name,l=!o||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==o?(a=()=>o&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:o}}),e[0]=r,e[1]=s,e[2]=o,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(qt,{icon:t.icon,name:t.title,size:"sm"}),e[4]=t.icon,e[5]=t.title,e[6]=c):c=e[6];let u;e[7]!==t.title?(u=p.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e[7]=t.title,e[8]=u):u=e[8];let d;e[9]!==i?(d=i&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=d):d=e[10];let f;e[11]!==u||e[12]!==d?(f=p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[u,d]}),e[11]=u,e[12]=d,e[13]=f):f=e[13];const h=gv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=ee("size-2 shrink-0 rounded-full",h),e[14]=h,e[15]=m):m=e[15];let g;e[16]!==m?(g=p.jsx("span",{className:m,"aria-hidden":"true"}),e[16]=m,e[17]=g):g=e[17];let x;e[18]!==t.status?(x=p.jsx("span",{className:"sr-only",children:t.status}),e[18]=t.status,e[19]=x):x=e[19];let y;return e[20]!==l||e[21]!==x||e[22]!==a||e[23]!==c||e[24]!==f||e[25]!==g?(y=p.jsxs("button",{type:"button","aria-disabled":l,onClick:a,className:"group flex w-full items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer aria-disabled:cursor-default aria-disabled:hover:bg-card",children:[c,f,g,x]}),e[20]=l,e[21]=x,e[22]=a,e[23]=c,e[24]=f,e[25]=g,e[26]=y):y=e[26],y}function yv(n){const e=_.c(40),{part:t,latency:r}=n,s=Vn(),{org:o}=Ct();let i;e[0]!==t.state?(i=ot(t.state),e[0]=t.state,e[1]=i):i=e[1];const l=i;let a,c,u,d,f,h;if(e[2]!==r||e[3]!==t.output||e[4]!==t.state||e[5]!==l){h=Symbol.for("react.early_return_sentinel");e:{const y=Un(t.output);if(c=(Array.isArray(y?.items)?y.items:[]).filter(kv),l==="loading"||l==="approval"){let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Z,{icon:p.jsx(Or,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=w):w=e[12],h=w;break e}if(l==="error"){let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Or,{}),e[13]=w):w=e[13];const C=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx(Ie,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==C||e[17]!==T?(N=p.jsx(Z,{icon:w,title:C,state:"error",trailing:T}),e[16]=C,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Or,{}),e[19]=w):w=e[19];let C;e[20]!==r?(C=p.jsx(Z,{icon:w,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx(Ie,{latency:r})}),e[20]=r,e[21]=C):C=e[21],h=C;break e}const b=c.slice(0,gh);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Or,{className:"text-success"}),e[22]=k):k=e[22];const S=c.length===1?"1 connection":`${c.length} connections`;let v;e[23]!==r?(v=p.jsx(Ie,{latency:r}),e[23]=r,e[24]=v):v=e[24],e[25]!==S||e[26]!==v?(f=p.jsx(Z,{icon:k,title:S,state:"idle",trailing:v}),e[25]=S,e[26]=v,e[27]=f):f=e[27],u="mt-2 flex flex-col gap-1.5",d=b.map(bv)}e[2]=r,e[3]=t.output,e[4]=t.state,e[5]=l,e[6]=a,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h}else a=e[6],c=e[7],u=e[8],d=e[9],f=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let m;e[28]!==a||e[29]!==c||e[30]!==s||e[31]!==o?(m=a>0&&p.jsx(xh,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:o.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=o,e[32]=m):m=e[32];let g;e[33]!==u||e[34]!==d||e[35]!==m?(g=p.jsxs("div",{className:u,children:[d,m]}),e[33]=u,e[34]=d,e[35]=m,e[36]=g):g=e[36];let x;return e[37]!==f||e[38]!==g?(x=p.jsxs(p.Fragment,{children:[f,g]}),e[37]=f,e[38]=g,e[39]=x):x=e[39],x}function bv(n){return p.jsx(xv,{connection:n},n.id)}function kv(n){return n.connection_type!=="VIRTUAL"}function Sv(){const n=_.c(37),e=Gi(),{sendMessage:t,isStreaming:r,messages:s}=$p(),{org:o}=Ct(),i=e?.virtualMcpId,{prompts:l}=Zp(o.slug),a=i??null;let c;n[0]!==o.id||n[1]!==o.slug||n[2]!==a?(c={connectionId:a,orgId:o.id,orgSlug:o.slug},n[0]=o.id,n[1]=o.slug,n[2]=a,n[3]=c):c=n[3];const u=Fi(c),[d,f]=E.useState(null);if(!i||r||!cp(i)||!s.some(vv))return null;let m;if(n[4]!==l||n[5]!==i){let A;n[7]!==i?(A=D=>D.agentId===i&&D.promptName,n[7]=i,n[8]=A):A=n[8],m=l.find(A),n[4]=l,n[5]=i,n[6]=m}else m=n[6];const g=m;if(!g)return null;let x;n[9]!==u||n[10]!==t?(x=async(A,D)=>{if(!u){Xo.error("MCP client not available");return}try{const I=await nm(u,A.name,D);await t({type:"doc",content:[{type:"paragraph",content:[Ff({id:A.name,name:Qi(A.name,Yi(A._meta)),metadata:I.messages,char:"/",kind:"prompt",args:D}),{type:"text",text:" "}]}]})}catch(I){console.error("[next-action-chip] failed",I),Xo.error("Failed to load prompt. Please try again.")}},n[9]=u,n[10]=t,n[11]=x):x=n[11];const y=x;let b;n[12]!==g._meta||n[13]!==g.arguments||n[14]!==g.description||n[15]!==g.promptName||n[16]!==g.title||n[17]!==y?(b=()=>{const A={name:g.promptName,title:g.title,description:g.description,arguments:g.arguments,_meta:g._meta};if(A.arguments&&A.arguments.length>0){f(A);return}y(A)},n[12]=g._meta,n[13]=g.arguments,n[14]=g.description,n[15]=g.promptName,n[16]=g.title,n[17]=y,n[18]=b):b=n[18];const k=b;let S,v;n[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(tm,{size:12,className:"shrink-0 text-purple-500"}),v=p.jsx("span",{className:"font-medium text-foreground/80",children:"Next:"}),n[19]=S,n[20]=v):(S=n[19],v=n[20]);let w;n[21]!==g.title?(w=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=w):w=n[22];let C;n[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(du,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=C):C=n[23];let T;n[24]!==k||n[25]!==w?(T=p.jsxs("button",{type:"button",onClick:k,className:"group mt-3 flex items-center gap-2 self-start rounded-full border border-border bg-background px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-border hover:bg-accent/40 hover:text-foreground",children:[S,v,w,C]}),n[24]=k,n[25]=w,n[26]=T):T=n[26];let N;n[27]===Symbol.for("react.memo_cache_sentinel")?(N=A=>f(A),n[27]=N):N=n[27];let M;n[28]!==d||n[29]!==y?(M=async A=>{const D=d;f(null),D&&await y(D,A)},n[28]=d,n[29]=y,n[30]=M):M=n[30];let j;n[31]!==d||n[32]!==M?(j=p.jsx(Nm,{prompt:d,setPrompt:N,onSubmit:M}),n[31]=d,n[32]=M,n[33]=j):j=n[33];let R;return n[34]!==j||n[35]!==T?(R=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=R):R=n[36],R}function vv(n){return n.role==="user"||n.parts.some(wv)}function wv(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function Cv(n){const e=new Map;for(let t=n.length-1;t>=0;t--){const r=n[t]?.parts;if(r)for(const s of r){const o=s;if(o.type!=="data-deck-updated")continue;const i=o.data;if(!i?.path)continue;const l=`deck:${i.path}`;e.has(l)||e.set(l,{tabId:Hp(i.path),label:i.name||i.path,kind:i.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function Tv(){const n=_.c(9),e=Vn(),t=Wn()?.messages??[],r=Cv(t);if(r.length===0)return null;const s=r.some(Mv),o=r.some(Nv),i=s?o?"Slides & pages in this chat":"Slides in this chat":"Pages in this chat",l="flex flex-col gap-1.5 py-2";let a;n[0]!==i?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:i}),n[0]=i,n[1]=a):a=n[1];const c="flex flex-wrap gap-2";let u;n[2]!==e?(u=m=>p.jsxs("button",{type:"button",onClick:()=>e({to:".",search:g=>({...g,main:m.tabId}),replace:!0}),className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-muted/30 hover:bg-muted/60 text-[13px] transition-colors",children:[m.kind==="deck"?p.jsx(nr,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(qp,{className:"size-3.5 shrink-0 text-muted-foreground"}),p.jsx("span",{className:"font-medium text-foreground",children:m.label})]},m.tabId),n[2]=e,n[3]=u):u=n[3];const d=r.map(u);let f;n[4]!==d?(f=p.jsx("div",{className:c,children:d}),n[4]=d,n[5]=f):f=n[5];let h;return n[6]!==a||n[7]!==f?(h=p.jsxs("div",{className:l,children:[a,f]}),n[6]=a,n[7]=f,n[8]=h):h=n[8],h}function Nv(n){return n.kind==="page"}function Mv(n){return n.kind==="deck"}async function Ev(n,e){const t=await fetch(`/api/${e}/threads/${encodeURIComponent(n)}/outputs`,{credentials:"include"});if(!t.ok)throw new Error(`Failed to fetch thread outputs: ${t.status}`);return(await t.json()).objects??[]}function sT(){const n=_.c(2),e=Wn()?.messages??[];let t;return n[0]!==e?(t=e.some(Av),n[0]=e,n[1]=t):t=n[1],t}function Av(n){return n.parts?.some(jv)}function jv(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function Iv(n,e){const t=_.c(9),{org:r}=Ct();let s;t[0]!==n?(s=Qe.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let o;t[2]!==r||t[3]!==n?(o=()=>Ev(n??"",r.slug),t[2]=r,t[3]=n,t[4]=o):o=t[4];const i=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==o||t[7]!==i?(l={queryKey:s,queryFn:o,enabled:i,staleTime:0},t[5]=s,t[6]=o,t[7]=i,t[8]=l):l=t[8],Mr(l)}function Ov(n){const e=_.c(20),{file:t}=n,r=Vn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:Vp(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const o=s;let i;e[3]!==t.filename?(i=p.jsx(jp,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=i):i=e[4];let l;e[5]!==t.filename||e[6]!==o?(l=p.jsx("button",{type:"button",onClick:o,className:"min-w-0 flex-1 truncate text-left text-[13px] font-medium text-foreground hover:underline",title:t.filename,children:t.filename}),e[5]=t.filename,e[6]=o,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(yu,{className:"size-3.5"}),e[8]=c):c=e[8];let u;e[9]!==t.downloadUrl||e[10]!==t.filename||e[11]!==a?(u=p.jsx("a",{href:t.downloadUrl,download:t.filename,className:"hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:block",title:"Download","aria-label":a,children:c}),e[9]=t.downloadUrl,e[10]=t.filename,e[11]=a,e[12]=u):u=e[12];let d;e[13]!==o?(d=p.jsx(un,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:o,children:"Open"}),e[13]=o,e[14]=d):d=e[14];let f;return e[15]!==i||e[16]!==l||e[17]!==u||e[18]!==d?(f=p.jsxs("div",{className:"group flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[i,l,u,d]}),e[15]=i,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Wc(n){return n.split("/").pop()??n}const Rv=/(^|\/)output\//;function Dv(n){const e=new Set;for(const t of n.parts??[]){const r=t;if(r.state==="output-available"){if(r.type==="tool-share_with_user"){const s=r.output?.filename??r.input?.name??(r.input?.source?Wc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&Rv.test(s)&&e.add(Wc(s))}}}return e}function Pv(n){const e=_.c(4),{threadId:t,message:r}=n,s=Dv(r),o=s.size>0;let i;e[0]!==o?(i={enabled:o},e[0]=o,e[1]=i):i=e[1];const{data:l}=Iv(t,i);if(s.size===0)return null;const a=(l??[]).filter(f=>s.has(f.filename));if(a.length===0)return null;const c="flex flex-col gap-1.5 py-2",u=a.map(Lv);let d;return e[2]!==u?(d=p.jsx("div",{className:c,children:u}),e[2]=u,e[3]=d):d=e[3],d}function Lv(n){return p.jsx(Ov,{file:n},n.key)}function _v(n){return n.type==="reasoning"}function $v(n){const e=[],t=new Set,r=new Map,s=new Map,o=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(_v(c)){l||(l={parts:[],startIndex:a},e.push(l)),l.parts.push(c),t.add(a);continue}if(l=null,c.type==="data-tool-metadata"&&"id"in c&&"data"in c){const u=c.data,d={};u.annotations&&(d.annotations=u.annotations),typeof u.latencyMs=="number"&&Number.isFinite(u.latencyMs)&&(d.latencySeconds=u.latencyMs/1e3),typeof u.outputBytes=="number"&&Number.isFinite(u.outputBytes)&&u.outputBytes>=0&&(d.outputBytes=u.outputBytes),u._meta&&typeof u._meta=="object"&&(d._meta=u._meta),r.set(c.id,d);continue}if(c.type==="data-tool-subtask-metadata"&&"id"in c){s.set(c.id,c.data);continue}if(c.type==="data-web-search"&&"id"in c&&"data"in c){const u=c.id,d=c.data;o.set(u,d.text??"");continue}}}const i=[];if(n)for(let l=0;l<n.parts.length;l++){const a=n.parts[l];if(a.type!=="step-start"){if(t.has(l)){const c=e.find(u=>u.startIndex===l);c&&i.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||i.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:i,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:o}}}const zv=3;function Bv(n,e){let t=-1;for(let r=n.length-1;r>=0;r--){const s=n[r];if(s.kind==="part"&&e[s.index]?.type==="text"){t=r;break}}return t===-1?{collapsed:[],tail:n}:{collapsed:n.slice(0,t),tail:n.slice(t)}}function Fv(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const o=e[s.index]?.type;o==="text"?r++:(o==="dynamic-tool"||o?.startsWith("tool-"))&&o!=="tool-todo_write"&&o!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function Hv(n){const e=_.c(8),{toolCalls:t,messages:r}=n;let s;e[0]!==r||e[1]!==t?(s=t>0&&p.jsxs(p.Fragment,{children:[p.jsx(au,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[t," tool call",t===1?"":"s",r>0?",":""]})]}),e[0]=r,e[1]=t,e[2]=s):s=e[2];let o;e[3]!==r?(o=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Ap,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=o):o=e[4];let i;return e[5]!==s||e[6]!==o?(i=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,o]}),e[5]=s,e[6]=o,e[7]=i):i=e[7],i}function Vv(n){const e=_.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=Fv(t,r.parts),e[0]=t,e[1]=r.parts,e[2]=u):u=e[2];const{toolCalls:d,messages:f}=u;if(d===0&&f===0)return null;let h;e[3]!==f||e[4]!==d?(h=p.jsx(Hv,{toolCalls:d,messages:f}),e[3]=f,e[4]=d,e[5]=h):h=e[5];let m;if(e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==i){let y;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==r||e[20]!==s||e[21]!==i?(y=(b,k)=>Ah({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:o,totalDuration:i,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=o,e[19]=r,e[20]=s,e[21]=i,e[22]=y):y=e[22],m=t.map(y),e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=t,e[11]=r,e[12]=s,e[13]=i,e[14]=m}else m=e[14];let g;e[23]!==m?(g=p.jsx("div",{className:"flex flex-col gap-3 sm:gap-2 pt-1",children:m}),e[23]=m,e[24]=g):g=e[24];let x;return e[25]!==h||e[26]!==g?(x=p.jsx(Z,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=x):x=e[27],x}function Ah({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:o,dataParts:i,isLoading:l,isLast:a,isLastVisiblePart:c,renderOrder:u}){if(n.kind==="reasoning-group"){const{group:m}=n,g=m===r[r.length-1],x=s&&g;if(!m.parts.some(k=>k.text?.trim())&&!x)return null;const b=r.length===1?o:null;return p.jsx(WS,{duration:b,parts:m.parts,isStreaming:x},`${t.id}-reasoning-${m.startIndex}`)}const d=t.parts[n.index],f=c||(u?u.findLastIndex(m=>m.kind==="part")===e:!1),h=f?wu(vu(),t.metadata?.usage):null;return p.jsx(Wv,{part:d,id:t.id,usageStats:f&&p.jsx(ES,{usage:h,duration:o}),dataParts:i,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function Wv(n){const e=_.c(121),{part:t,id:r,usageStats:s,dataParts:o,isLoading:i,isLastMessage:l}=n;let a;e[0]!==o.toolMetadata?(a=f=>o.toolMetadata.get(f),e[0]=o.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==o.toolSubtaskMetadata?(u=f=>o.toolSubtaskMetadata.get(f),e[2]=o.toolSubtaskMetadata,e[3]=u):u=e[3];const d=u;switch(t.type){case"dynamic-tool":{let f;e[4]!==c||e[5]!==t.toolCallId?(f=c(t.toolCallId)?.annotations,e[4]=c,e[5]=t.toolCallId,e[6]=f):f=e[6];let h;e[7]!==c||e[8]!==t.toolCallId?(h=c(t.toolCallId)?.latencySeconds,e[7]=c,e[8]=t.toolCallId,e[9]=h):h=e[9];let m;e[10]!==c||e[11]!==t.toolCallId?(m=c(t.toolCallId)?.outputBytes,e[10]=c,e[11]=t.toolCallId,e[12]=m):m=e[12];let g;e[13]!==c||e[14]!==t.toolCallId?(g=c(t.toolCallId)?._meta,e[13]=c,e[14]=t.toolCallId,e[15]=g):g=e[15];let x;return e[16]!==l||e[17]!==t||e[18]!==f||e[19]!==h||e[20]!==m||e[21]!==g?(x=p.jsx(Bc,{part:t,annotations:f,latency:h,outputBytes:m,isLastMessage:l,toolMeta:g}),e[16]=l,e[17]=t,e[18]=f,e[19]=h,e[20]=m,e[21]=g,e[22]=x):x=e[22],x}case"tool-todo_write":return null;case"tool-update_interests":return null;case"tool-user_ask":{let f;e[23]!==c||e[24]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[23]=c,e[24]=t.toolCallId,e[25]=f):f=e[25];let h;return e[26]!==t||e[27]!==f?(h=p.jsx(R2,{part:t,latency:f}),e[26]=t,e[27]=f,e[28]=h):h=e[28],h}case"tool-propose_plan":{let f;return e[29]!==t?(f=p.jsx(W2,{part:t}),e[29]=t,e[30]=f):f=e[30],f}case"tool-generate_image":{let f;e[31]!==c||e[32]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[31]=c,e[32]=t.toolCallId,e[33]=f):f=e[33];let h;return e[34]!==t||e[35]!==f?(h=p.jsx(y2,{part:t,latency:f}),e[34]=t,e[35]=f,e[36]=h):h=e[36],h}case"tool-take_screenshot":{let f;e[37]!==c||e[38]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[37]=c,e[38]=t.toolCallId,e[39]=f):f=e[39];let h;return e[40]!==t||e[41]!==f?(h=p.jsx(S2,{part:t,latency:f}),e[40]=t,e[41]=f,e[42]=h):h=e[42],h}case"tool-web_search":case"tool-deep_research":{let f;e[43]!==c||e[44]!==t.toolCallId?(f=c(t.toolCallId)?.latencySeconds,e[43]=c,e[44]=t.toolCallId,e[45]=f):f=e[45];let h;e[46]!==o.webSearchStreaming||e[47]!==t.toolCallId?(h=o.webSearchStreaming.get(t.toolCallId),e[46]=o.webSearchStreaming,e[47]=t.toolCallId,e[48]=h):h=e[48];let m;return e[49]!==t||e[50]!==f||e[51]!==h?(m=p.jsx(O2,{part:t,latency:f,streamingText:h}),e[49]=t,e[50]=f,e[51]=h,e[52]=m):m=e[52],m}case"tool-subtask":{let f;e[53]!==d||e[54]!==t.toolCallId?(f=d(t.toolCallId),e[53]=d,e[54]=t.toolCallId,e[55]=f):f=e[55];let h;e[56]!==c||e[57]!==t.toolCallId?(h=c(t.toolCallId)?.annotations,e[56]=c,e[57]=t.toolCallId,e[58]=h):h=e[58];let m;e[59]!==c||e[60]!==t.toolCallId?(m=c(t.toolCallId)?.latencySeconds,e[59]=c,e[60]=t.toolCallId,e[61]=m):m=e[61];let g;e[62]!==t||e[63]!==f||e[64]!==h||e[65]!==m?(g={part:t,subtaskMeta:f,annotations:h,latency:m},e[62]=t,e[63]=f,e[64]=h,e[65]=m,e[66]=g):g=e[66];const x=g;let y;return e[67]!==x?(y=p.jsx(E.Suspense,{fallback:p.jsx(H2,{...x}),children:p.jsx(V2,{...x})}),e[67]=x,e[68]=y):y=e[68],y}case"text":{const f=!!s&&!i,h=i&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(uo,{id:r,part:t,extraActions:s,copyable:!0,alwaysShowActions:f,animate:h}),e[69]=r,e[70]=t,e[71]=f,e[72]=h,e[73]=s,e[74]=m):m=e[74],m}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;case"data-tool-metadata":case"data-tool-subtask-metadata":case"data-generate-image":case"data-web-search":return null;default:{const f=t;if(f.type==="tool-brand_context_setup"||f.type==="tool-BRAND_CONTEXT_EXTRACT"){let h;e[75]!==f.toolCallId||e[76]!==c?(h=c(f.toolCallId)?.latencySeconds,e[75]=f.toolCallId,e[76]=c,e[77]=h):h=e[77];let m;return e[78]!==f||e[79]!==h?(m=p.jsx(nv,{part:f,latency:h}),e[78]=f,e[79]=h,e[80]=m):m=e[80],m}if(f.type==="tool-BRAND_CONTEXT_GET"){let h;e[81]!==f.toolCallId||e[82]!==c?(h=c(f.toolCallId)?.latencySeconds,e[81]=f.toolCallId,e[82]=c,e[83]=h):h=e[83];let m;return e[84]!==f||e[85]!==h?(m=p.jsx(rv,{part:f,latency:h}),e[84]=f,e[85]=h,e[86]=m):m=e[86],m}if(f.type==="tool-BRAND_CONTEXT_LIST"){let h;e[87]!==f.toolCallId||e[88]!==c?(h=c(f.toolCallId)?.latencySeconds,e[87]=f.toolCallId,e[88]=c,e[89]=h):h=e[89];let m;return e[90]!==f||e[91]!==h?(m=p.jsx(sv,{part:f,latency:h}),e[90]=f,e[91]=h,e[92]=m):m=e[92],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_CREATE"){let h;e[93]!==f.toolCallId||e[94]!==c?(h=c(f.toolCallId)?.latencySeconds,e[93]=f.toolCallId,e[94]=c,e[95]=h):h=e[95];let m;return e[96]!==f||e[97]!==h?(m=p.jsx(uv,{part:f,latency:h}),e[96]=f,e[97]=h,e[98]=m):m=e[98],m}if(f.type==="tool-COLLECTION_VIRTUAL_MCP_LIST"){let h;e[99]!==f.toolCallId||e[100]!==c?(h=c(f.toolCallId)?.latencySeconds,e[99]=f.toolCallId,e[100]=c,e[101]=h):h=e[101];let m;return e[102]!==f||e[103]!==h?(m=p.jsx(pv,{part:f,latency:h}),e[102]=f,e[103]=h,e[104]=m):m=e[104],m}if(f.type==="tool-COLLECTION_CONNECTIONS_LIST"){let h;e[105]!==f.toolCallId||e[106]!==c?(h=c(f.toolCallId)?.latencySeconds,e[105]=f.toolCallId,e[106]=c,e[107]=h):h=e[107];let m;return e[108]!==f||e[109]!==h?(m=p.jsx(yv,{part:f,latency:h}),e[108]=f,e[109]=h,e[110]=m):m=e[110],m}if(f.type.startsWith("tool-")){const h=f.toolCallId;let m;e[111]!==o.toolMetadata||e[112]!==h?(m=o.toolMetadata.get(h),e[111]=o.toolMetadata,e[112]=h,e[113]=m):m=e[113];const g=m,x=g?.annotations,y=g?.latencySeconds,b=g?.outputBytes,k=g?._meta;let S;return e[114]!==f||e[115]!==l||e[116]!==x||e[117]!==y||e[118]!==b||e[119]!==k?(S=p.jsx(Bc,{part:f,annotations:x,latency:y,outputBytes:b,isLastMessage:l,toolMeta:k}),e[114]=f,e[115]=l,e[116]=x,e[117]=y,e[118]=b,e[119]=k,e[120]=S):S=e[120],S}if(f.type.startsWith("data-"))return null;throw new Error(`Unknown part type: ${f.type}`)}}}function Uv(n){const e=_.c(2),{isRunInProgress:t}=n;if(t){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Js,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),p.jsx("span",{className:"text-[14px] text-muted-foreground shimmer",children:"Resuming task..."})]})}),e[0]=s):s=e[0],s}let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-[14px] text-muted-foreground/60 py-2",children:"No response was generated"}),e[1]=r):r=e[1],r}function qv(n){const e=_.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=ee("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",t),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==r?(o=p.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:p.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-[14px] wrap-break-word overflow-wrap-anywhere bg-transparent",children:r})}),e[2]=r,e[3]=o):o=e[3];let i;return e[4]!==s||e[5]!==o?(i=p.jsx("div",{className:s,children:o}),e[4]=s,e[5]=o,e[6]=i):i=e[6],i}function Kv(n){const e=_.c(31),{message:t,turnStartedAt:r,status:s,className:o,isLast:i}=n,l=i===void 0?!1:i,{isRunInProgress:a}=Wn()??{},c=a===void 0?!1:a,u=Gi()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Ki(r),e[0]=r,e[1]=m):m=e[1];const g=m;let x;e[2]!==h?(x=()=>h?Date.now():null,e[2]=h,e[3]=x):x=e[3];const[y,b]=E.useState(x),[k,S]=E.useState(h);k!==h&&(S(h),b(h?Date.now():null));const v=g??y,{reasoningGroups:w,renderOrder:C,dataParts:T}=$v(t),N=t!==null&&C.length>0,M=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&M?.type==="reasoning";let R;if(e[4]!==t){const F=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,U=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;R=F!==null?U.getTime()-F.getTime():null,e[4]=t,e[5]=R}else R=e[5];const A=R;let D;e[6]!==l||e[7]!==t?(D=!l||!t||!t.parts.some(Gv),e[6]=l,e[7]=t,e[8]=D):D=e[8];const I=D;let $;e[9]!==N||e[10]!==h||e[11]!==I||e[12]!==t||e[13]!==C?($=!h&&N&&I&&(()=>{let F=0;for(const U of C)if(U.kind==="part"){const Y=t.parts[U.index]?.type;(Y==="dynamic-tool"||Y?.startsWith("tool-"))&&F++}return F>=zv})(),e[9]=N,e[10]=h,e[11]=I,e[12]=t,e[13]=C,e[14]=$):$=e[14];const L=$;let z;if(e[15]!==o||e[16]!==T||e[17]!==N||e[18]!==l||e[19]!==h||e[20]!==j||e[21]!==c||e[22]!==I||e[23]!==t||e[24]!==w||e[25]!==C||e[26]!==L||e[27]!==v||e[28]!==u||e[29]!==A){const{collapsed:F,tail:U}=L?Bv(C,t.parts):{collapsed:[],tail:C};z=p.jsx(qv,{className:o,children:N?p.jsxs("div",{className:"flex flex-col gap-3 sm:gap-2",children:[t.metadata?.resumedFromBackground&&p.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground/60 select-none",children:[p.jsx(Yc,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),F.length>0&&p.jsx(Vv,{items:F,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l}),U.map((Y,K)=>{const Q=F.length+K,ne=U.findLastIndex(Jv)===K;return Ah({item:Y,renderIndex:Q,message:t,reasoningGroups:w,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:ne,renderOrder:C})}),u&&p.jsx(Pv,{threadId:u,message:t}),l&&h&&v!==null&&p.jsx(FS,{startedAt:v}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(Tv,{}),I&&p.jsx(Sv,{})]}),!h&&p.jsx(yh,{message:t})]}):h?p.jsx(VS,{startedAt:v}):p.jsx(Uv,{isRunInProgress:l&&c})}),e[15]=o,e[16]=T,e[17]=N,e[18]=l,e[19]=h,e[20]=j,e[21]=c,e[22]=I,e[23]=t,e[24]=w,e[25]=C,e[26]=L,e[27]=v,e[28]=u,e[29]=A,e[30]=z}else z=e[30];return z}function Jv(n){return n.kind==="part"}function Gv(n){const e=n.type;if(e!=="dynamic-tool"&&!e?.startsWith("tool-"))return!1;const t=n.state;return t==="input-streaming"||t==="input-available"||t==="approval-requested"}function Xv(n){const e=_.c(21),{event:t}=n,[r,s]=E.useState(!1);let o;e[0]!==t.data?(o=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(Yv),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(mm,{className:"size-4 shrink-0 text-muted-foreground"}),c=p.jsx("span",{className:"font-medium",children:"Triggered by event"}),e[3]=a,e[4]=c):(a=e[3],c=e[4]);let u;e[5]!==t.type?(u=p.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:t.type}),e[5]=t.type,e[6]=u):u=e[6];const d=r&&"rotate-180";let f;e[7]!==d?(f=ee("ml-auto size-4 shrink-0 text-muted-foreground transition-transform",d),e[7]=d,e[8]=f):f=e[8];let h;e[9]!==f?(h=p.jsx(Zr,{className:f}),e[9]=f,e[10]=h):h=e[10];let m;e[11]!==u||e[12]!==h?(m=p.jsxs("button",{type:"button",onClick:l,className:"flex w-full items-center gap-2 px-3 py-2 text-sm cursor-pointer",children:[a,c,u,h]}),e[11]=u,e[12]=h,e[13]=m):m=e[13];let g;e[14]!==t.source||e[15]!==r||e[16]!==i?(g=r&&p.jsxs("div",{className:"border-t border-border/60 px-3 py-2",children:[p.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:t.source}),p.jsx("pre",{className:"overflow-auto whitespace-pre-wrap break-words text-xs text-foreground",children:i})]}),e[14]=t.source,e[15]=r,e[16]=i,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==m?(x=p.jsxs("div",{className:"rounded-lg border border-border/60 bg-background overflow-hidden text-left",children:[m,g]}),e[18]=g,e[19]=m,e[20]=x):x=e[20],x}function Yv(n){return!n}const Qv=[MS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),Bb,Wb];function Zv(n){const e=_.c(5),{tiptapDoc:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={attributes:{class:"prose prose-sm max-w-none focus:outline-none"}},e[0]=r):r=e[0];let s;e[1]!==t?(s={extensions:Qv,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const o=jb(s);if(!o)return null;let i;return e[3]!==o?(i=p.jsx(Df,{editor:o,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=o,e[4]=i):i=e[4],i}function ew(n){const e=_.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:o,parts:i,metadata:l}=t,[a,c]=E.useState(!1),[u,d]=E.useState(!1),f=E.useRef(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=I=>{I&&!f.current&&(f.current=!0,d(I.scrollHeight>I.clientHeight))},e[0]=h):h=e[0];const m=h;if(!i||i.length===0)return null;let g;e[1]!==s?(g=()=>{c(!0),s?.()},e[1]=s,e[2]=g):g=e[2];const x=g,y=l?.tiptapDoc;let b;e[3]!==r?(b=ee("message-block w-full min-w-0 relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=b):b=e[4];let k,S;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=()=>c(!0),S=()=>c(!1),e[5]=k,e[6]=S):(k=e[5],S=e[6]);let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx("div",{className:"absolute inset-0 bg-muted/75 rounded-lg pointer-events-none"}),e[7]=v):v=e[7];let w;e[8]!==a||e[9]!==u?(w=ee("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":ee("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=w):w=e[10];let C;if(e[11]!==o||e[12]!==i){let I;e[14]!==o?(I=($,L)=>$.type==="data-trigger-event"?p.jsx(Xv,{event:$.data},`${o}-${L}`):null,e[14]=o,e[15]=I):I=e[15],C=i.map(I),e[11]=o,e[12]=i,e[13]=C}else C=e[13];let T;e[16]!==y||e[17]!==o||e[18]!==l||e[19]!==i?(T=y?p.jsx(Zv,{tiptapDoc:l.tiptapDoc}):i.map((I,$)=>I.type==="text"?i[$-1]?.type==="data-trigger-event"?null:p.jsx(uo,{id:o,part:I},`${o}-${$}`):null),e[16]=y,e[17]=o,e[18]=l,e[19]=i,e[20]=T):T=e[20];let N;e[21]!==C||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[C,T]}),e[21]=C,e[22]=T,e[23]=N):N=e[23];let M;e[24]!==N||e[25]!==w?(M=p.jsx("div",{ref:m,className:w,children:N}),e[24]=N,e[25]=w,e[26]=M):M=e[26];let j;e[27]!==x||e[28]!==M?(j=p.jsxs("div",{tabIndex:0,onClick:x,onFocus:k,onBlur:S,className:"w-full border border-border/60 min-w-0 shadow-xs rounded-lg text-[14px] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[v,M]}),e[27]=x,e[28]=M,e[29]=j):j=e[29];let R;e[30]!==t?(R=p.jsx(yh,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=R):R=e[31];let A;e[32]!==j||e[33]!==R?(A=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,R]}),e[32]=j,e[33]=R,e[34]=A):A=e[34];let D;return e[35]!==A||e[36]!==b?(D=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:A})}),e[35]=A,e[36]=b,e[37]=D):D=e[37],D}function tw(n){const e=[],t=n.filter(r=>r.role!=="system"&&!r.metadata?.internal&&!r.metadata?.subtaskJobId);for(let r=0;r<t.length;r++){const s=t[r];if(s)if(s.role==="user"){const o=t[r+1];o&&o.role==="assistant"?(e.push({user:s,assistant:o}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function nw(n){const e=_.c(19),{pair:t,isLastPair:r,status:s}=n,o=E.useRef(null),i=E.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o.current&&o.current.scrollIntoView({behavior:"smooth",block:"start"})},e[0]=l):l=e[0];const a=l;let c;e[1]!==r||e[2]!==t.assistant?.metadata?.resumedFromBackground||e[3]!==s?(c=y=>{if(o.current=y,!r||!y||i.current||(i.current=!0,t.assistant?.metadata?.resumedFromBackground))return;if(s==="submitted"||s==="streaming"){y.scrollIntoView({behavior:"smooth",block:"start"});return}const b=y.closest("[data-chat-scroller]");b?b.scrollTop=b.scrollHeight:y.scrollIntoView({behavior:"instant",block:"start"})},e[1]=r,e[2]=t.assistant?.metadata?.resumedFromBackground,e[3]=s,e[4]=c):c=e[4];const u=c,d=!t.user&&"pt-8 sm:pt-6";let f;e[5]!==d?(f=ee("flex flex-col pb-2 sm:pb-2",d),e[5]=d,e[6]=f):f=e[6];let h;e[7]!==t.user?(h=t.user&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"sticky top-0 z-50 w-full h-4 bg-background"}),p.jsx("div",{className:"sticky mb-8 sm:mb-6 top-4 z-50",children:p.jsx(ew,{message:t.user,onScrollToPair:a})})]}),e[7]=t.user,e[8]=h):h=e[8];const m=t.user?.created_at??null;let g;e[9]!==r||e[10]!==t.assistant||e[11]!==s||e[12]!==m?(g=p.jsx(Kv,{message:t.assistant,turnStartedAt:m,status:s,isLast:r}),e[9]=r,e[10]=t.assistant,e[11]=s,e[12]=m,e[13]=g):g=e[13];let x;return e[14]!==u||e[15]!==f||e[16]!==h||e[17]!==g?(x=p.jsxs("div",{ref:u,className:f,children:[h,g]}),e[14]=u,e[15]=f,e[16]=h,e[17]=g,e[18]=x):x=e[18],x}function rw(n,e){return E.useReducer((t,r)=>e[t][r]??t,n)}var Kl="ScrollArea",[jh]=Gc(Kl),[sw,tt]=jh(Kl),Ih=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:o=600,...i}=n,[l,a]=E.useState(null),[c,u]=E.useState(null),[d,f]=E.useState(null),[h,m]=E.useState(null),[g,x]=E.useState(null),[y,b]=E.useState(0),[k,S]=E.useState(0),[v,w]=E.useState(!1),[C,T]=E.useState(!1),N=kn(e,j=>a(j)),M=sp(s);return p.jsx(sw,{scope:t,type:r,dir:M,scrollHideDelay:o,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:v,onScrollbarXEnabledChange:w,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:C,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:S,children:p.jsx(Ut.div,{dir:M,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Ih.displayName=Kl;var Oh="ScrollAreaViewport",Rh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...o}=n,i=tt(Oh,t),l=E.useRef(null),a=kn(e,l,i.onViewportChange);return p.jsxs(p.Fragment,{children:[p.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),p.jsx(Ut.div,{"data-radix-scroll-area-viewport":"",...o,ref:a,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Rh.displayName=Oh;var pt="ScrollAreaScrollbar",Dh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,l=n.orientation==="horizontal";return E.useEffect(()=>(l?o(!0):i(!0),()=>{l?o(!1):i(!1)}),[l,o,i]),s.type==="hover"?p.jsx(ow,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(iw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(Ph,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Jl,{...r,ref:e}):null});Dh.displayName=pt;var ow=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),[o,i]=E.useState(!1);return E.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),i(!0)},u=()=>{a=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",c),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(a),l.removeEventListener("pointerenter",c),l.removeEventListener("pointerleave",u)}}},[s.scrollArea,s.scrollHideDelay]),p.jsx(Nr,{present:t||o,children:p.jsx(Ph,{"data-state":o?"visible":"hidden",...r,ref:e})})}),iw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=tt(pt,n.__scopeScrollArea),o=n.orientation==="horizontal",i=xo(()=>a("SCROLL_END"),100),[l,a]=rw("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(l==="idle"){const c=window.setTimeout(()=>a("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(c)}},[l,s.scrollHideDelay,a]),E.useEffect(()=>{const c=s.viewport,u=o?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),i()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,o,a,i]),p.jsx(Nr,{present:t||l!=="hidden",children:p.jsx(Jl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:_t(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:_t(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),Ph=E.forwardRef((n,e)=>{const t=tt(pt,n.__scopeScrollArea),{forceMount:r,...s}=n,[o,i]=E.useState(!1),l=n.orientation==="horizontal",a=xo(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;i(l?c:u)}},10);return Hn(t.viewport,a),Hn(t.content,a),p.jsx(Nr,{present:r||o,children:p.jsx(Jl,{"data-state":o?"visible":"hidden",...s,ref:e})})}),Jl=E.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=tt(pt,n.__scopeScrollArea),o=E.useRef(null),i=E.useRef(0),[l,a]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Bh(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function d(f,h){return fw(f,i.current,l,h)}return t==="horizontal"?p.jsx(lw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,h=Uc(f,l,s.dir);o.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=d(f,s.dir))}}):t==="vertical"?p.jsx(aw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,h=Uc(f,l);o.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=d(f))}}):null}),lw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=tt(pt,n.__scopeScrollArea),[i,l]=E.useState(),a=E.useRef(null),c=kn(e,a,o.onScrollbarXChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(_h,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":go(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),Hh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:qs(i.paddingLeft),paddingEnd:qs(i.paddingRight)}})}})}),aw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=tt(pt,n.__scopeScrollArea),[i,l]=E.useState(),a=E.useRef(null),c=kn(e,a,o.onScrollbarYChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(_h,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":go(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(o.viewport){const f=o.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),Hh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&o.viewport&&i&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:qs(i.paddingTop),paddingEnd:qs(i.paddingBottom)}})}})}),[cw,Lh]=jh(pt),_h=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=tt(pt,t),[m,g]=E.useState(null),x=kn(e,N=>g(N)),y=E.useRef(null),b=E.useRef(""),k=h.viewport,S=r.content-r.viewport,v=Qt(u),w=Qt(a),C=xo(d,10);function T(N){if(y.current){const M=N.clientX-y.current.left,j=N.clientY-y.current.top;c({x:M,y:j})}}return E.useEffect(()=>{const N=M=>{const j=M.target;m?.contains(j)&&v(M,S)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[k,m,S,v]),E.useEffect(w,[r,w]),Hn(m,C),Hn(h.content,C),p.jsx(cw,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:Qt(o),onThumbPointerUp:Qt(i),onThumbPositionChange:w,onThumbPointerDown:Qt(l),children:p.jsx(Ut.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:_t(n.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),y.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),T(N))}),onPointerMove:_t(n.onPointerMove,T),onPointerUp:_t(n.onPointerUp,N=>{const M=N.target;M.hasPointerCapture(N.pointerId)&&M.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),Us="ScrollAreaThumb",$h=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Lh(Us,n.__scopeScrollArea);return p.jsx(Nr,{present:t||s.hasThumb,children:p.jsx(uw,{ref:e,...r})})}),uw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,o=tt(Us,t),i=Lh(Us,t),{onThumbPositionChange:l}=i,a=kn(e,d=>i.onThumbChange(d)),c=E.useRef(void 0),u=xo(()=>{c.current&&(c.current(),c.current=void 0)},100);return E.useEffect(()=>{const d=o.viewport;if(d){const f=()=>{if(u(),!c.current){const h=hw(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[o.viewport,u,l]),p.jsx(Ut.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:_t(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:_t(n.onPointerUp,i.onThumbPointerUp)})});$h.displayName=Us;var Gl="ScrollAreaCorner",zh=E.forwardRef((n,e)=>{const t=tt(Gl,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(dw,{...n,ref:e}):null});zh.displayName=Gl;var dw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=tt(Gl,t),[o,i]=E.useState(0),[l,a]=E.useState(0),c=!!(o&&l);return Hn(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Hn(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),i(u)}),c?p.jsx(Ut.div,{...r,ref:e,style:{width:o,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function qs(n){return n?parseInt(n,10):0}function Bh(n,e){const t=n/e;return isNaN(t)?0:t}function go(n){const e=Bh(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function fw(n,e,t,r="ltr"){const s=go(t),o=s/2,i=e||o,l=s-i,a=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return Fh([a,c],d)(n)}function Uc(n,e,t="ltr"){const r=go(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,l=o-r,a=t==="ltr"?[0,i]:[i*-1,0],c=op(n,a);return Fh([0,i],[0,l])(c)}function Fh(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function Hh(n,e){return n>0&&n<e}var hw=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const o={left:n.scrollLeft,top:n.scrollTop},i=t.left!==o.left,l=t.top!==o.top;(i||l)&&e(),t=o,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function xo(n,e){const t=Qt(n),r=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),E.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(t,e)},[t,e])}function Hn(n,e){const t=Qt(e);Jc(()=>{let r=0;if(n){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return s.observe(n),()=>{window.cancelAnimationFrame(r),s.unobserve(n)}}},[n,t])}var pw=Ih,mw=Rh,gw=zh;function oT(n){const e=_.c(17);let t,r,s,o;e[0]!==n?({className:r,children:t,hideScrollbar:o,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=o===void 0?!1:o;let l;e[5]!==r?(l=ee("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(mw,{"data-slot":"scroll-area-viewport",className:"h-full w-full overflow-auto rounded-[inherit] outline-none transition-[color,box-shadow] focus-visible:ring-[2px] focus-visible:ring-ring/20",children:p.jsx("div",{className:"flex min-w-0 flex-col",children:t})}),e[7]=t,e[8]=a):a=e[8];let c;e[9]!==i?(c=p.jsx(xw,{hideScrollbar:i}),e[9]=i,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(gw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(pw,{"data-slot":"scroll-area",className:l,...s,children:[a,c,u]}),e[12]=s,e[13]=l,e[14]=a,e[15]=c,e[16]=d):d=e[16],d}function xw(n){const e=_.c(15);let t,r,s,o;e[0]!==n?({className:t,orientation:s,hideScrollbar:o,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=o):(t=e[1],r=e[2],s=e[3],o=e[4]);const i=s===void 0?"vertical":s,l=o===void 0?!1:o,a=i==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",u=l&&"hidden";let d;e[5]!==t||e[6]!==a||e[7]!==c||e[8]!==u?(d=ee("select-none touch-none p-px transition-colors",a,c,u,t),e[5]=t,e[6]=a,e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx($h,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==i||e[12]!==r||e[13]!==d?(h=p.jsx(Dh,{"data-slot":"scroll-area-scrollbar",orientation:i,className:d,...r,children:f}),e[11]=i,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}const Vh=[{ms:6e4,label:"1m"},{ms:12e4,label:"2m"},{ms:3e5,label:"5m"},{ms:6e5,label:"10m"},{ms:9e5,label:"15m"},{ms:18e5,label:"30m"},{ms:36e5,label:"1h"},{ms:72e5,label:"2h"},{ms:216e5,label:"6h"},{ms:432e5,label:"12h"},{ms:864e5,label:"1d"},{ms:6048e5,label:"7d"}],yw=40;function iT(n){const t=(n.endDate.getTime()-n.startDate.getTime())/yw;return Vh.find(s=>s.ms>=t)?.label??"1d"}function Xl(n){const e=Vh.find(o=>o.label===n);if(e)return e.ms;const t=/^(\d+)([mhd])$/.exec(n);if(!t)return 6e4;const r=parseInt(t[1],10),s=t[2];return s==="h"?r*36e5:s==="d"?r*864e5:r*6e4}function bw(n,e){const t=new Date(n);return Xl(e)>=864e5?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function qc(n,e){const t=Xl(e);return new Date(Math.floor(n.getTime()/t)*t)}function kw(n){return n>=1e4?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}function Yl(n){return Number.isFinite(n)?n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:Math.round(n).toLocaleString():"0"}function Ql(n){return Number.isFinite(n)?`$${n.toFixed(n<1?4:2)}`:"$0.00"}function lT(n,e,t){const r=Xl(t),s=qc(e.startDate,t).getTime(),o=e.endDate.getTime(),i=new Map(n.map(a=>[qc(new Date(a.timestamp),t).getTime(),a])),l=[];for(let a=s;a<=o;a+=r){const c=i.get(a),u=new Date(a).toISOString();l.push({t:u,ts:a,label:bw(u,t),calls:c?.calls??0,errors:c?.errors??0,errorRate:c?.errorRate??0,avg:c?.avg??0,p50:c?.p50??0,p95:c?.p95??0,inputTokens:c?.inputTokens??0,outputTokens:c?.outputTokens??0,totalTokens:c?.totalTokens??0,costUsd:c?.costUsd??0})}return l}function aT(n,e){return e==="requests"?n.calls:e==="errors"?n.errorRate:n.avgDurationMs}function cT(n,e){return e==="requests"?n.calls.toLocaleString():e==="errors"?`${n.errorRate.toFixed(1)}%`:kw(n.avgDurationMs)}function Zl(n){return(n.run_config??{}).agent?.id??(n.virtual_mcp_id||null)}function ea(n,e,t,r){if(!n)return r;const s=e.find(i=>i.id===n)??t?.find(i=>i.id===n);if(s?.title)return s.title;const o=up(n);return o?dp(o).title??r:n}function ta(n,e,t){return n?(e.find(s=>s.id===n)??t?.find(s=>s.id===n))?.icon??null:null}function Wh(n){return n?.data?.members??[]}function Li(n){const e=_.c(33),{thread:t,connections:r,virtualMcps:s,selectedIndex:o,total:i,onPrev:l,onNext:a}=n;let c,u;if(e[0]!==r||e[1]!==t||e[2]!==s){const j=Zl(t);c=ea(j,s,r,""),u=ta(j,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=c,e[4]=u}else c=e[3],u=e[4];const d=u,f=c||t.title;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Ui,{}),e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==f?(m=p.jsx(qt,{icon:d,name:f,size:"sm",fallbackIcon:h,className:"shadow-sm shrink-0 rounded-md"}),e[6]=d,e[7]=f,e[8]=m):m=e[8];let g;e[9]!==t.title?(g=p.jsx(tu,{className:"text-sm leading-snug truncate",children:t.title}),e[9]=t.title,e[10]=g):g=e[10];let x;e[11]!==c?(x=c&&p.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:c}),e[11]=c,e[12]=x):x=e[12];let y;e[13]!==g||e[14]!==x?(y=p.jsxs("div",{className:"min-w-0",children:[g,x]}),e[13]=g,e[14]=x,e[15]=y):y=e[15];let b;e[16]!==m||e[17]!==y?(b=p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m,y]}),e[16]=m,e[17]=y,e[18]=b):b=e[18];const k=o===0;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(Qo,{size:14}),e[19]=S):S=e[19];let v;e[20]!==l||e[21]!==k?(v=p.jsx(un,{size:"icon",variant:"ghost",onClick:l,disabled:k,className:"h-7 w-7 text-muted-foreground","aria-label":"Previous chat",children:S}),e[20]=l,e[21]=k,e[22]=v):v=e[22];const w=o===i-1;let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Zr,{size:14}),e[23]=C):C=e[23];let T;e[24]!==a||e[25]!==w?(T=p.jsx(un,{size:"icon",variant:"ghost",onClick:a,disabled:w,className:"h-7 w-7 text-muted-foreground","aria-label":"Next chat",children:C}),e[24]=a,e[25]=w,e[26]=T):T=e[26];let N;e[27]!==v||e[28]!==T?(N=p.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[v,T]}),e[27]=v,e[28]=T,e[29]=N):N=e[29];let M;return e[30]!==N||e[31]!==b?(M=p.jsx(eu,{className:"px-5 md:px-6 pt-6 pb-5 border-b border-border shrink-0",children:p.jsxs("div",{className:"flex items-start justify-between gap-3 pr-8",children:[b,N]})}),e[30]=N,e[31]=b,e[32]=M):M=e[32],M}function Sw(n){const e=_.c(48),{thread:t,connections:r,virtualMcps:s,members:o}=n;let i,l;if(e[0]!==r||e[1]!==t||e[2]!==s){const I=Zl(t);i=ea(I,s,r,""),l=ta(I,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=i,e[4]=l}else i=e[3],l=e[4];const a=l;let c;if(e[5]!==o||e[6]!==t.created_by){const I=Wh(o);let $;e[8]!==t.created_by?($=L=>L.userId===t.created_by,e[8]=t.created_by,e[9]=$):$=e[9],c=I.find($),e[5]=o,e[6]=t.created_by,e[7]=c}else c=e[7];const u=c;let d;e[10]!==u?.user.email||e[11]!==u?.user.name||e[12]!==t.created_by?(d=u?.user.name??u?.user.email??t.created_by?.substring(0,8)??"—",e[10]=u?.user.email,e[11]=u?.user.name,e[12]=t.created_by,e[13]=d):d=e[13];const f=d,h=u?.user.image??void 0;let m;e[14]!==t.created_at?(m=new Date(t.created_at).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),e[14]=t.created_at,e[15]=m):m=e[15];const g=m,x=Rn[t.status]??Rn.completed,y=x.icon;let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Status"}),e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x.iconClassName?(k=p.jsx(y,{size:13,className:x.iconClassName}),e[17]=y,e[18]=x.iconClassName,e[19]=k):k=e[19];let S;e[20]!==x.labelColor?(S=ee("text-sm",x.labelColor),e[20]=x.labelColor,e[21]=S):S=e[21];let v;e[22]!==x.label||e[23]!==S?(v=p.jsx("span",{className:S,children:x.label}),e[22]=x.label,e[23]=S,e[24]=v):v=e[24];let w;e[25]!==k||e[26]!==v?(w=p.jsxs("div",{children:[b,p.jsxs("div",{className:"flex items-center gap-1.5",children:[k,v]})]}),e[25]=k,e[26]=v,e[27]=w):w=e[27];let C;e[28]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Date"}),e[28]=C):C=e[28];let T;e[29]!==g?(T=p.jsxs("div",{children:[C,p.jsx("div",{className:"text-sm text-foreground",children:g})]}),e[29]=g,e[30]=T):T=e[30];let N;e[31]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"User"}),e[31]=N):N=e[31];let M;e[32]!==h||e[33]!==f?(M=p.jsx(lu,{url:h,fallback:f,shape:"circle",size:"2xs",className:"shrink-0"}),e[32]=h,e[33]=f,e[34]=M):M=e[34];let j;e[35]!==f?(j=p.jsx("span",{className:"text-sm text-foreground",children:f}),e[35]=f,e[36]=j):j=e[36];let R;e[37]!==M||e[38]!==j?(R=p.jsxs("div",{children:[N,p.jsxs("div",{className:"flex items-center gap-2",children:[M,j]})]}),e[37]=M,e[38]=j,e[39]=R):R=e[39];let A;e[40]!==a||e[41]!==i?(A=i&&p.jsxs("div",{children:[p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Agent"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(qt,{icon:a,name:i,size:"xs",fallbackIcon:p.jsx(Ui,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),p.jsx("span",{className:"text-sm text-foreground",children:i})]})]}),e[40]=a,e[41]=i,e[42]=A):A=e[42];let D;return e[43]!==T||e[44]!==R||e[45]!==A||e[46]!==w?(D=p.jsxs("div",{className:"px-5 md:px-6 py-5 border-b border-border grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4 text-sm",children:[w,T,R,A]}),e[43]=T,e[44]=R,e[45]=A,e[46]=w,e[47]=D):D=e[47],D}function vw(n){const e=_.c(72),{thread:t,usage:r,members:s,connections:o,virtualMcps:i,onClick:l,lastRowRef:a}=n;let c,u;if(e[0]!==o||e[1]!==t||e[2]!==i){const se=Zl(t);c=ea(se,i,o,"—"),u=ta(se,i,o),e[0]=o,e[1]=t,e[2]=i,e[3]=c,e[4]=u}else c=e[3],u=e[4];const d=u;let f;if(e[5]!==s||e[6]!==t.created_by){const se=Wh(s);let ae;e[8]!==t.created_by?(ae=Te=>Te.userId===t.created_by,e[8]=t.created_by,e[9]=ae):ae=e[9],f=se.find(ae),e[5]=s,e[6]=t.created_by,e[7]=f}else f=e[7];const h=f;let m;e[10]!==h?.user.email||e[11]!==h?.user.name||e[12]!==t.created_by?(m=h?.user.name??h?.user.email??t.created_by?.substring(0,8)??"—",e[10]=h?.user.email,e[11]=h?.user.name,e[12]=t.created_by,e[13]=m):m=e[13];const g=m,x=h?.user.image??void 0;let y,b;if(e[14]!==t.created_at){const se=new Date(t.created_at);y=se.toLocaleDateString("en-US",{month:"short",day:"numeric"}),b=se.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[14]=t.created_at,e[15]=y,e[16]=b}else y=e[15],b=e[16];const k=b,S=Rn[t.status]??Rn.completed,v=S.icon;let w;e[17]!==t.title?(w=p.jsx(Ge,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:t.title})}),e[17]=t.title,e[18]=w):w=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Ui,{}),e[19]=C):C=e[19];let T;e[20]!==d||e[21]!==c?(T=p.jsx(qt,{icon:d,name:c,size:"xs",fallbackIcon:C,className:"shrink-0 size-5! min-w-5! rounded-md"}),e[20]=d,e[21]=c,e[22]=T):T=e[22];let N;e[23]!==c?(N=p.jsx("span",{className:"truncate",children:c}),e[23]=c,e[24]=N):N=e[24];let M;e[25]!==T||e[26]!==N?(M=p.jsx(Ge,{className:"w-36 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[T,N]})}),e[25]=T,e[26]=N,e[27]=M):M=e[27];let j;e[28]!==x||e[29]!==g?(j=p.jsx(lu,{url:x,fallback:g,shape:"circle",size:"2xs",className:"shrink-0"}),e[28]=x,e[29]=g,e[30]=j):j=e[30];let R;e[31]!==g?(R=p.jsx("span",{className:"truncate",children:g}),e[31]=g,e[32]=R):R=e[32];let A;e[33]!==j||e[34]!==R?(A=p.jsx(Ge,{className:"w-28 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[j,R]})}),e[33]=j,e[34]=R,e[35]=A):A=e[35];let D;e[36]!==v||e[37]!==S.iconClassName?(D=p.jsx(v,{size:14,className:S.iconClassName}),e[36]=v,e[37]=S.iconClassName,e[38]=D):D=e[38];let I;e[39]!==S.labelColor?(I=ee("text-sm",S.labelColor),e[39]=S.labelColor,e[40]=I):I=e[40];let $;e[41]!==S.label||e[42]!==I?($=p.jsx("span",{className:I,children:S.label}),e[41]=S.label,e[42]=I,e[43]=$):$=e[43];let L;e[44]!==D||e[45]!==$?(L=p.jsx(Ge,{className:"w-24 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[D,$]})}),e[44]=D,e[45]=$,e[46]=L):L=e[46];let z;e[47]!==r?(z=r?Yl(r.totalTokens):"—",e[47]=r,e[48]=z):z=e[48];let F;e[49]!==z?(F=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:z}),e[49]=z,e[50]=F):F=e[50];let U;e[51]!==r?(U=r&&r.costUsd>0?Ql(r.costUsd):"—",e[51]=r,e[52]=U):U=e[52];let Y;e[53]!==U?(Y=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:U}),e[53]=U,e[54]=Y):Y=e[54];let K;e[55]!==y?(K=p.jsx("div",{children:y}),e[55]=y,e[56]=K):K=e[56];let Q;e[57]!==k?(Q=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:k}),e[57]=k,e[58]=Q):Q=e[58];let ne;e[59]!==K||e[60]!==Q?(ne=p.jsxs(Ge,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[K,Q]}),e[59]=K,e[60]=Q,e[61]=ne):ne=e[61];let re;return e[62]!==a||e[63]!==l||e[64]!==A||e[65]!==L||e[66]!==F||e[67]!==Y||e[68]!==ne||e[69]!==w||e[70]!==M?(re=p.jsxs(Ks,{ref:a,className:"h-14 md:h-16 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:l,children:[w,M,A,L,F,Y,ne]}),e[62]=a,e[63]=l,e[64]=A,e[65]=L,e[66]=F,e[67]=Y,e[68]=ne,e[69]=w,e[70]=M,e[71]=re):re=e[71],re}const _i=100;function ww(n){const e=_.c(37),{client:t,locator:r,thread:s,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==r||e[1]!==s.id?(f=Qe.threadMessages(r,s.id),e[0]=r,e[1]=s.id,e[2]=f):f=e[2];let h;e[3]!==t||e[4]!==s.id?(h=async R=>{const{pageParam:A}=R,D=A===void 0?0:A;if(!t)throw new Error("MCP client is not available");const I=await t.callTool({name:"COLLECTION_THREAD_MESSAGES_LIST",arguments:{thread_id:s.id,limit:_i,offset:D}});return I.structuredContent??I},e[3]=t,e[4]=s.id,e[5]=h):h=e[5];let m;e[6]!==f||e[7]!==h?(m={queryKey:f,queryFn:h,initialPageParam:0,getNextPageParam:Nw,staleTime:6e4},e[6]=f,e[7]=h,e[8]=m):m=e[8];const{data:g,fetchNextPage:x,hasNextPage:y,isFetchingNextPage:b}=gp(m);let k;e[9]!==g.pages?(k=g.pages.flatMap(Tw).filter(Cw),e[9]=g.pages,e[10]=k):k=e[10];const S=k,v=tw(S);let w;e[11]!==x||e[12]!==y||e[13]!==b?(w=()=>{y&&!b&&x()},e[11]=x,e[12]=y,e[13]=b,e[14]=w):w=e[14];const C=Wi(w,y??!1,b);let T;e[15]!==o||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==s||e[20]!==c||e[21]!==i?(T=p.jsx(Li,{thread:s,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[15]=o,e[16]=d,e[17]=u,e[18]=a,e[19]=s,e[20]=c,e[21]=i,e[22]=T):T=e[22];let N;e[23]!==o||e[24]!==l||e[25]!==s||e[26]!==i?(N=p.jsx(Sw,{thread:s,connections:o,virtualMcps:i,members:l}),e[23]=o,e[24]=l,e[25]=s,e[26]=i,e[27]=N):N=e[27];let M;e[28]!==b||e[29]!==C||e[30]!==v||e[31]!==S.length?(M=S.length===0?p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No messages in this chat"}):p.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:p.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[v.map((R,A)=>p.jsx("div",{ref:A===v.length-1?C:void 0,children:p.jsx(nw,{pair:R,isLastPair:A===v.length-1,status:"ready"})},`pair-${R.user?.id??R.assistant?.id}`)),b&&p.jsx("div",{className:"py-4 text-center text-xs text-muted-foreground",children:"Loading more\\u2026"})]})}),e[28]=b,e[29]=C,e[30]=v,e[31]=S.length,e[32]=M):M=e[32];let j;return e[33]!==T||e[34]!==N||e[35]!==M?(j=p.jsxs(p.Fragment,{children:[T,N,M]}),e[33]=T,e[34]=N,e[35]=M,e[36]=j):j=e[36],j}function Cw(n){return n.role==="user"||n.role==="assistant"}function Tw(n){return n.items??[]}function Nw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<_i))return r.length*_i}function Uh(n){const e=_.c(39),{thread:t,client:r,locator:s,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==o||e[1]!==d||e[2]!==u||e[3]!==a||e[4]!==t||e[5]!==c||e[6]!==i?(f=p.jsx(Li,{thread:t,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[0]=o,e[1]=d,e[2]=u,e[3]=a,e[4]=t,e[5]=c,e[6]=i,e[7]=f):f=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Failed to load messages"}),e[8]=h):h=e[8];let m;e[9]!==f?(m=p.jsxs(p.Fragment,{children:[f,h]}),e[9]=f,e[10]=m):m=e[10];let g;e[11]!==o||e[12]!==d||e[13]!==u||e[14]!==a||e[15]!==t||e[16]!==c||e[17]!==i?(g=p.jsx(Li,{thread:t,connections:o,virtualMcps:i,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[11]=o,e[12]=d,e[13]=u,e[14]=a,e[15]=t,e[16]=c,e[17]=i,e[18]=g):g=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Loading conversation\\u2026"}),e[19]=x):x=e[19];let y;e[20]!==g?(y=p.jsxs(p.Fragment,{children:[g,x]}),e[20]=g,e[21]=y):y=e[21];let b;e[22]!==r||e[23]!==o||e[24]!==s||e[25]!==l||e[26]!==d||e[27]!==u||e[28]!==a||e[29]!==t||e[30]!==c||e[31]!==i?(b=p.jsx(ww,{client:r,locator:s,thread:t,connections:o,virtualMcps:i,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[22]=r,e[23]=o,e[24]=s,e[25]=l,e[26]=d,e[27]=u,e[28]=a,e[29]=t,e[30]=c,e[31]=i,e[32]=b):b=e[32];let k;e[33]!==y||e[34]!==b?(k=p.jsx(E.Suspense,{fallback:y,children:b}),e[33]=y,e[34]=b,e[35]=k):k=e[35];let S;return e[36]!==m||e[37]!==k?(S=p.jsx(Xc,{fallback:m,children:k}),e[36]=m,e[37]=k,e[38]=S):S=e[38],S}const $i=50;function uT(n){const e=_.c(29),{client:t,locator:r,membersData:s,allConnections:o,allVirtualMcps:i,dateRange:l,searchQuery:a,filterAgentIds:c,filterUserIds:u,filterStatus:d}=n,[f,h]=E.useState(null),m=l.startDate.toISOString(),g=l.endDate.toISOString(),x=JSON.stringify({startDate:m,endDate:g,search:a,agentIds:c,userIds:u,status:d}),{data:y,fetchNextPage:b,hasNextPage:k,isFetchingNextPage:S,isLoading:v}=Qc({queryKey:Qe.threadsInfinite(r,x),queryFn:async J=>{const{pageParam:ie}=J,ue=ie===void 0?0:ie;if(!t)throw new Error("MCP client is not available");const it=await t.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:$i,offset:ue,startDate:m,endDate:g,...a?{search:a}:{},...c&&c.length>0?{agentId:c[0]}:{},...u&&u.length>0?{userId:u[0]}:{},...d&&d!=="all"?{status:d}:{}}});return it.structuredContent??it},initialPageParam:0,getNextPageParam:Ow,staleTime:3e4}),w=(y?.pages??[]).flatMap(Iw),C=w.map(jw),{data:T}=Mr({queryKey:Qe.monitoringThreadUsage(r,JSON.stringify({ids:C,startDate:m,endDate:g})),queryFn:async()=>{if(!t)throw new Error("MCP client is not available");const J=await t.callTool({name:"MONITORING_THREAD_USAGE",arguments:{threadIds:C,startDate:m,endDate:g}});return J.structuredContent??J},enabled:!!t&&C.length>0,staleTime:3e4}),N=new Map((T?.items??[]).map(Aw)),[M,j]=E.useState(null),[R,A]=E.useState("desc");let D;e[0]!==M?(D=J=>{M===J?A(Ew):(j(J),A("desc"))},e[0]=M,e[1]=D):D=e[1];const I=D,$=J=>{const ie=N.get(J);return ie?M==="cost"?ie.costUsd:ie.totalTokens:0},L=M?[...w].sort((J,ie)=>{const ue=$(J.id),it=$(ie.id);return R==="desc"?it-ue:ue-it}):w,z=f!==null?L[f]??null:null;let F;e[2]!==b||e[3]!==k||e[4]!==S?(F=()=>{k&&!S&&b()},e[2]=b,e[3]=k,e[4]=S,e[5]=F):F=e[5];const Y=Wi(F,k??!1,S),K=!!a||(c?.length??0)>0||(u?.length??0)>0||d&&d!=="all";let Q;e[6]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>h(Mw),e[6]=Q):Q=e[6];const ne=Q,re=()=>h(J=>J!==null&&J<L.length-1?J+1:J),se="flex-1 flex flex-col overflow-auto min-w-0",ae="mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",Te="flex-1 flex flex-col min-w-0",W="flex-1 min-w-0 pt-1",te="min-w-0",he=v?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading\\u2026"})}):w.length===0?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx(Yo,{title:K?"No matching chats":"No chats in this time range",description:K?"Try adjusting your filters or search query.":"Try expanding the time range to see older chats."})}):p.jsxs(p.Fragment,{children:[p.jsxs(nu,{className:"w-full border-collapse",children:[p.jsx(ru,{className:"border-b-0 z-20",children:p.jsxs(Ks,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Je,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Title"}),p.jsx(Je,{className:"w-36 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Agent"}),p.jsx(Je,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"User"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:p.jsxs("button",{type:"button",onClick:()=>I("tokens"),className:"inline-flex items-center gap-1 ml-auto hover:text-foreground transition-colors uppercase",children:["Tokens",M==="tokens"&&(R==="desc"?p.jsx(Zr,{size:12}):p.jsx(Qo,{size:12}))]})}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:p.jsxs("button",{type:"button",onClick:()=>I("cost"),className:"inline-flex items-center gap-1 ml-auto hover:text-foreground transition-colors uppercase",children:["Cost",M==="cost"&&(R==="desc"?p.jsx(Zr,{size:12}):p.jsx(Qo,{size:12}))]})}),p.jsx(Je,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Date"})]})}),p.jsx(su,{children:L.map((J,ie)=>p.jsx(vw,{thread:J,usage:N.get(J.id),members:s,connections:o,virtualMcps:i,onClick:()=>h(ie),lastRowRef:ie===L.length-1?Y:void 0},J.id))})]}),S&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more..."})]});let ge;e[7]!==he?(ge=p.jsx("div",{className:ae,children:p.jsx("div",{className:Te,children:p.jsx("div",{className:W,children:p.jsx("div",{className:te,children:he})})})}),e[7]=he,e[8]=ge):ge=e[8];const Be=f!==null;let Nt;e[9]===Symbol.for("react.memo_cache_sentinel")?(Nt=J=>{J||h(null)},e[9]=Nt):Nt=e[9];let Fe;e[10]!==o||e[11]!==i||e[12]!==t||e[13]!==L||e[14]!==re||e[15]!==ne||e[16]!==r||e[17]!==s||e[18]!==z||e[19]!==f?(Fe=z&&f!==null&&p.jsx(Uh,{thread:z,client:t,locator:r,connections:o,virtualMcps:i,members:s,selectedIndex:f,total:L.length,onPrev:ne,onNext:re}),e[10]=o,e[11]=i,e[12]=t,e[13]=L,e[14]=re,e[15]=ne,e[16]=r,e[17]=s,e[18]=z,e[19]=f,e[20]=Fe):Fe=e[20];let He;e[21]!==Fe?(He=p.jsx(Hi,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:Fe}),e[21]=Fe,e[22]=He):He=e[22];let Ve;e[23]!==Be||e[24]!==He?(Ve=p.jsx(Vi,{open:Be,onOpenChange:Nt,children:He}),e[23]=Be,e[24]=He,e[25]=Ve):Ve=e[25];let mt;return e[26]!==ge||e[27]!==Ve?(mt=p.jsxs("div",{className:se,children:[ge,Ve]}),e[26]=ge,e[27]=Ve,e[28]=mt):mt=e[28],mt}function Mw(n){return n!==null&&n>0?n-1:n}function Ew(n){return n==="desc"?"asc":"desc"}function Aw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function jw(n){return n.id}function Iw(n){return n.items??[]}function Ow(n,e){const t=n,r=e;if(!((t?.items?.length??0)<$i))return r.length*$i}const zi=50;function Kr(n){const e=_.c(10),{title:t,value:r,subtitle:s}=n;let o;e[0]!==t?(o=p.jsx("span",{className:"text-sm text-foreground/70",children:t}),e[0]=t,e[1]=o):o=e[1];let i;e[2]!==r?(i=p.jsx("span",{className:"text-3xl font-normal tabular-nums",children:r}),e[2]=r,e[3]=i):i=e[3];let l;e[4]!==s?(l=s&&p.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let a;return e[6]!==o||e[7]!==i||e[8]!==l?(a=p.jsxs(hp,{className:"pt-4 px-4 pb-5 gap-1",children:[o,i,l]}),e[6]=o,e[7]=i,e[8]=l,e[9]=a):a=e[9],a}function Rw(n){const e=_.c(27),{automationId:t,range:r}=n,{data:s,isLoading:o}=mp(t,r),i=s?.runs,l=s?.usage;let a;e[0]!==i?(a=i&&i.total>0?`${Math.round(i.completed/i.total*100)}%`:"—",e[0]=i,e[1]=a):a=e[1];const c=a,u=l&&l.truncated?`last ${l.sampledRuns} runs`:void 0;let d;e[2]!==o||e[3]!==i?.total?(d=o?"…":i?.total.toLocaleString()??"0",e[2]=o,e[3]=i?.total,e[4]=d):d=e[4];const f=i?`${i.completed} ok · ${i.failed} failed${i.inProgress>0?` · ${i.inProgress} running`:""}`:void 0;let h;e[5]!==d||e[6]!==f?(h=p.jsx(Kr,{title:"Runs",value:d,subtitle:f}),e[5]=d,e[6]=f,e[7]=h):h=e[7];const m=o?"…":c;let g;e[8]!==m?(g=p.jsx(Kr,{title:"Success rate",value:m}),e[8]=m,e[9]=g):g=e[9];let x;e[10]!==o||e[11]!==l?.totalTokens?(x=o?"…":Yl(l?.totalTokens??0),e[10]=o,e[11]=l?.totalTokens,e[12]=x):x=e[12];let y;e[13]!==x||e[14]!==u?(y=p.jsx(Kr,{title:"Tokens",value:x,subtitle:u}),e[13]=x,e[14]=u,e[15]=y):y=e[15];let b;e[16]!==o||e[17]!==l?(b=o?"…":l&&l.costUsd>0?Ql(l.costUsd):"—",e[16]=o,e[17]=l,e[18]=b):b=e[18];let k;e[19]!==b||e[20]!==u?(k=p.jsx(Kr,{title:"Cost",value:b,subtitle:u}),e[19]=b,e[20]=u,e[21]=k):k=e[21];let S;return e[22]!==k||e[23]!==h||e[24]!==g||e[25]!==y?(S=p.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[h,g,y,k]}),e[22]=k,e[23]=h,e[24]=g,e[25]=y,e[26]=S):S=e[26],S}function Dw(n){const e=_.c(39),{run:t,usage:r,onClick:s,lastRowRef:o}=n;let i,l;if(e[0]!==t.created_at){const T=new Date(t.created_at);i=T.toLocaleDateString("en-US",{month:"short",day:"numeric"}),l=T.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}),e[0]=t.created_at,e[1]=i,e[2]=l}else i=e[1],l=e[2];const a=l,c=Rn[t.status]??Rn.completed,u=c.icon;let d;e[3]!==t.title?(d=p.jsx(Ge,{className:"min-w-0 pr-2 pl-4 md:pr-4",children:p.jsx("div",{className:"font-medium text-foreground truncate",children:t.title})}),e[3]=t.title,e[4]=d):d=e[4];let f;e[5]!==u||e[6]!==c.iconClassName?(f=p.jsx(u,{size:14,className:c.iconClassName}),e[5]=u,e[6]=c.iconClassName,e[7]=f):f=e[7];let h;e[8]!==c.labelColor?(h=ee("text-sm",c.labelColor),e[8]=c.labelColor,e[9]=h):h=e[9];let m;e[10]!==c.label||e[11]!==h?(m=p.jsx("span",{className:h,children:c.label}),e[10]=c.label,e[11]=h,e[12]=m):m=e[12];let g;e[13]!==f||e[14]!==m?(g=p.jsx(Ge,{className:"w-28 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[f,m]})}),e[13]=f,e[14]=m,e[15]=g):g=e[15];let x;e[16]!==r?(x=r?Yl(r.totalTokens):"—",e[16]=r,e[17]=x):x=e[17];let y;e[18]!==x?(y=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:x}),e[18]=x,e[19]=y):y=e[19];let b;e[20]!==r?(b=r&&r.costUsd>0?Ql(r.costUsd):"—",e[20]=r,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(Ge,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==i?(S=p.jsx("div",{children:i}),e[24]=i,e[25]=S):S=e[25];let v;e[26]!==a?(v=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:a}),e[26]=a,e[27]=v):v=e[27];let w;e[28]!==S||e[29]!==v?(w=p.jsxs(Ge,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[S,v]}),e[28]=S,e[29]=v,e[30]=w):w=e[30];let C;return e[31]!==o||e[32]!==s||e[33]!==k||e[34]!==w||e[35]!==d||e[36]!==g||e[37]!==y?(C=p.jsxs(Ks,{ref:o,className:"h-14 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:s,children:[d,g,y,k,w]}),e[31]=o,e[32]=s,e[33]=k,e[34]=w,e[35]=d,e[36]=g,e[37]=y,e[38]=C):C=e[38],C}function dT(n){const e=_.c(48),{automationId:t,triggerIds:r,range:s}=n,{org:o,locator:i}=Ct();let l;e[0]!==o.id||e[1]!==o.slug?(l={connectionId:fp,orgId:o.id,orgSlug:o.slug},e[0]=o.id,e[1]=o.slug,e[2]=l):l=e[2];const a=Fi(l),c=iu(),u=ip(),d=ap(),{data:f}=pp(),[h,m]=E.useState(null),g=r.length>0;let x;e[3]!==t||e[4]!==o.id||e[5]!==r?(x=Qe.automationRuns(o.id,t,r),e[3]=t,e[4]=o.id,e[5]=r,e[6]=x):x=e[6];let y;e[7]!==c||e[8]!==r?(y=async W=>{const{pageParam:te}=W,he=te===void 0?0:te;return await c.call("COLLECTION_THREADS_LIST",{limit:zi,offset:he,where:{trigger_ids:r}})},e[7]=c,e[8]=r,e[9]=y):y=e[9];let b;e[10]!==g||e[11]!==x||e[12]!==y?(b={queryKey:x,queryFn:y,initialPageParam:0,getNextPageParam:zw,enabled:g,staleTime:3e4},e[10]=g,e[11]=x,e[12]=y,e[13]=b):b=e[13];const{data:k,fetchNextPage:S,hasNextPage:v,isFetchingNextPage:w,isLoading:C}=Qc(b),T=(k?.pages??[]).flatMap($w),N=T.map(_w),{data:M}=Mr({queryKey:Qe.monitoringThreadUsage(i,JSON.stringify({ids:N,...s})),queryFn:async()=>await c.call("MONITORING_THREAD_USAGE",{threadIds:N,...s.startDate?{startDate:s.startDate}:{},...s.endDate?{endDate:s.endDate}:{}}),enabled:N.length>0,staleTime:3e4});let j;e[14]!==M?.items?(j=new Map((M?.items??[]).map(Lw)),e[14]=M?.items,e[15]=j):j=e[15];const R=j;let A;e[16]!==S||e[17]!==v||e[18]!==w?(A=()=>{v&&!w&&S()},e[16]=S,e[17]=v,e[18]=w,e[19]=A):A=e[19];const D=Wi(A,v??!1,w),I=h!==null?T[h]??null:null;let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=()=>m(Pw),e[20]=$):$=e[20];const L=$,z=()=>m(W=>W!==null&&W<T.length-1?W+1:W),F="flex flex-col gap-5";let U;e[21]!==t||e[22]!==s?(U=p.jsx(Rw,{automationId:t,range:s}),e[21]=t,e[22]=s,e[23]=U):U=e[23];const Y=g?C?p.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Loading runs…"}):T.length===0?p.jsx("div",{className:"py-16",children:p.jsx(Yo,{title:"No runs yet",description:"This automation hasn't run yet. Trigger it or wait for a starter to fire."})}):p.jsxs(nu,{className:"w-full border-collapse",children:[p.jsx(ru,{className:"border-b-0",children:p.jsxs(Ks,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Je,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Run"}),p.jsx(Je,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Tokens"}),p.jsx(Je,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Cost"}),p.jsx(Je,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Started"})]})}),p.jsx(su,{children:T.map((W,te)=>p.jsx(Dw,{run:W,usage:R.get(W.id),onClick:()=>m(te),lastRowRef:te===T.length-1?D:void 0},W.id))})]}):p.jsx("div",{className:"py-16",children:p.jsx(Yo,{title:"No starters yet",description:"Add a starter (cron, event, or webhook) to start collecting runs."})});let K;e[24]!==w?(K=w&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more…"}),e[24]=w,e[25]=K):K=e[25];const Q=h!==null;let ne;e[26]===Symbol.for("react.memo_cache_sentinel")?(ne=W=>{W||m(null)},e[26]=ne):ne=e[26];let re;e[27]!==u||e[28]!==d||e[29]!==a||e[30]!==z||e[31]!==L||e[32]!==i||e[33]!==f||e[34]!==T||e[35]!==I||e[36]!==h?(re=I&&h!==null&&p.jsx(Uh,{thread:I,client:a,locator:i,connections:u,virtualMcps:d,members:f,selectedIndex:h,total:T.length,onPrev:L,onNext:z}),e[27]=u,e[28]=d,e[29]=a,e[30]=z,e[31]=L,e[32]=i,e[33]=f,e[34]=T,e[35]=I,e[36]=h,e[37]=re):re=e[37];let se;e[38]!==re?(se=p.jsx(Hi,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:re}),e[38]=re,e[39]=se):se=e[39];let ae;e[40]!==Q||e[41]!==se?(ae=p.jsx(Vi,{open:Q,onOpenChange:ne,children:se}),e[40]=Q,e[41]=se,e[42]=ae):ae=e[42];let Te;return e[43]!==Y||e[44]!==K||e[45]!==ae||e[46]!==U?(Te=p.jsxs("div",{className:F,children:[U,Y,K,ae]}),e[43]=Y,e[44]=K,e[45]=ae,e[46]=U,e[47]=Te):Te=e[47],Te}function Pw(n){return n!==null&&n>0?n-1:n}function Lw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function _w(n){return n.id}function $w(n){return n.items??[]}function zw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<zi))return r.length*zi}export{uT as $,oT as A,eT as B,nT as C,de as D,Ml as E,Wb as F,LS as G,xe as H,RS as I,DS as J,PS as K,dT as L,uo as M,GS as N,Ov as O,Nm as P,iT as Q,OS as R,ZC as S,tT as T,lT as U,Yl as V,Ql as W,kw as X,cT as Y,aT as Z,Wh as _,Hf as a,ve as b,Ff as c,wm as d,fe as e,QC as f,Yi as g,De as h,YC as i,JC as j,XC as k,$b as l,GC as m,Bb as n,MS as o,Df as p,KC as q,tw as r,Qi as s,Cu as t,jb as u,Sm as v,rT as w,nw as x,sT as y,Iv as z};