decocms 4.72.3 → 4.74.0

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 (260) hide show
  1. package/dist/client/assets/{AlertCircle-CX23NCuO.js → AlertCircle-BaauQIwC.js} +1 -1
  2. package/dist/client/assets/{AreaChart-CRvFGO5O.js → AreaChart-5GoV9SRg.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-ChoUWc1b.js → ArrowUp-C814v0pE.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-Bq-zX9ha.js → ArrowUpRight-BLP3DLju.js} +1 -1
  5. package/dist/client/assets/{Check-BbAbdPfp.js → Check-DYPRi7NO.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-Day5nLHt.js → CheckCircle-D_t3rWUI.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-BsEi-r9q.js → ChevronDown-wHLuFr3i.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-B9mybD1s.js → ChevronRight-BARfL9-W.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-BWoVqFrM.js → ChevronUp-CRmxYAjE.js} +1 -1
  10. package/dist/client/assets/{Circle-Bj_xS3WU.js → Circle-DuelqjM2.js} +1 -1
  11. package/dist/client/assets/Copy01-BwtpNAKR.js +1 -0
  12. package/dist/client/assets/{DotsVertical-BQRa2EB9.js → DotsVertical-B_jKX962.js} +1 -1
  13. package/dist/client/assets/Eye-CM4SfxEo.js +1 -0
  14. package/dist/client/assets/{FilterLines-C5i4i3WB.js → FilterLines-CwEBxGZP.js} +1 -1
  15. package/dist/client/assets/{Flag01-C7YxvVFh.js → Flag01-RtD7xNTJ.js} +1 -1
  16. package/dist/client/assets/{Globe01-CC0A4U7g.js → Globe01-B-4z45oj.js} +1 -1
  17. package/dist/client/assets/{Globe04-BV89vsfi.js → Globe04-D7ZgONc6.js} +1 -1
  18. package/dist/client/assets/{HardDrive-CA9cG4ej.js → HardDrive-DNueik1y.js} +1 -1
  19. package/dist/client/assets/{Key01-Y2tTMtA8.js → Key01-DrwX5nx2.js} +1 -1
  20. package/dist/client/assets/{LayoutLeft-C6uN3ryJ.js → LayoutLeft-CHLKhLgL.js} +1 -1
  21. package/dist/client/assets/{LinkExternal01-CbW1jJhi.js → LinkExternal01-022iaJNF.js} +1 -1
  22. package/dist/client/assets/{List-MOccGrJp.js → List-jObuFUL_.js} +1 -1
  23. package/dist/client/assets/{Monitor01-DBUBWT-e.js → Monitor01-BkHN4rM2.js} +1 -1
  24. package/dist/client/assets/{Package-BL3B6ONo.js → Package-DYdmCLl6.js} +1 -1
  25. package/dist/client/assets/{Palette-B0oAitOJ.js → Palette-BWa7ee-4.js} +1 -1
  26. package/dist/client/assets/{Play-zjQOd6w0.js → Play-DYP9-OJo.js} +1 -1
  27. package/dist/client/assets/{Plus-DATZ4-ND.js → Plus-DKATXnIq.js} +1 -1
  28. package/dist/client/assets/{SearchLg-B4W4xrFH.js → SearchLg-crE3yQZJ.js} +1 -1
  29. package/dist/client/assets/{SearchMd-CKL74aOj.js → SearchMd-CbytZ1-S.js} +1 -1
  30. package/dist/client/assets/{Settings02-DAAnVZLO.js → Settings02-1LTNhTXj.js} +1 -1
  31. package/dist/client/assets/{Shield01-IlYcL8Fi.js → Shield01-CULBCC4Z.js} +1 -1
  32. package/dist/client/assets/{Star01-Bb61R21H.js → Star01-CtWX4nA3.js} +1 -1
  33. package/dist/client/assets/{Stars01-Bnuoinbt.js → Stars01-COE1U6xi.js} +1 -1
  34. package/dist/client/assets/{Stars02-B9xmjTkg.js → Stars02-BzQc7fZz.js} +1 -1
  35. package/dist/client/assets/{Sun-wOtTFTOd.js → Sun-CyoL1WFK.js} +1 -1
  36. package/dist/client/assets/{SwitchHorizontal01-C90B2Auk.js → SwitchHorizontal01-QNGjYcml.js} +1 -1
  37. package/dist/client/assets/{Tool01-BT4kICfE.js → Tool01-BWGVYfev.js} +1 -1
  38. package/dist/client/assets/{Tool02-vM8N2pYB.js → Tool02-DkTMVP4f.js} +1 -1
  39. package/dist/client/assets/{Trash01-CrwbV8c_.js → Trash01-iPP4w9gK.js} +1 -1
  40. package/dist/client/assets/TrendUp01-C3q3M7MG.js +1 -0
  41. package/dist/client/assets/{Upload01-Lp0wJMYr.js → Upload01-CoVAXfWg.js} +1 -1
  42. package/dist/client/assets/{User01-CQV6kRtR.js → User01-2QspS0s6.js} +1 -1
  43. package/dist/client/assets/{UserPlus01-13KHecKW.js → UserPlus01-DoBolndD.js} +1 -1
  44. package/dist/client/assets/{Users01-CDDfUziK.js → Users01-C3FOprDj.js} +1 -1
  45. package/dist/client/assets/{Users03-ZlQye2vY.js → Users03-BYqJADve.js} +1 -1
  46. package/dist/client/assets/{X-CNdIeej8.js → X-Bqs01fCh.js} +1 -1
  47. package/dist/client/assets/{XCircle-C9sRiEE0.js → XCircle-DHCvZwgH.js} +1 -1
  48. package/dist/client/assets/{XClose-4pjmwtT4.js → XClose-P0NM9uUE.js} +1 -1
  49. package/dist/client/assets/{Zap-DHGChPV2.js → Zap-CI5WhuKJ.js} +1 -1
  50. package/dist/client/assets/{ZapSquare-BV8kr37_.js → ZapSquare-BhWmmFEB.js} +1 -1
  51. package/dist/client/assets/{ZoomOut-7nLppLEs.js → ZoomOut-C7W-ZWAB.js} +1 -1
  52. package/dist/client/assets/{access-gate-BAwcBNbs.js → access-gate-BK7GcTMo.js} +1 -1
  53. package/dist/client/assets/{add-section-modal-lhtrhXMg.js → add-section-modal-CfvYLCg2.js} +1 -1
  54. package/dist/client/assets/agent-icon-5pSyq_FH.js +1 -0
  55. package/dist/client/assets/agents-list-pNinhUjp.js +1 -0
  56. package/dist/client/assets/ai-providers-CRHCw5VF.js +1 -0
  57. package/dist/client/assets/{alert-BhYIEI2X.js → alert-D4ttbBAt.js} +1 -1
  58. package/dist/client/assets/{alert-dialog-IVNf28U9.js → alert-dialog-GCrUNzbs.js} +1 -1
  59. package/dist/client/assets/app-editor-DqcvDhID.js +1 -0
  60. package/dist/client/assets/{auth-DIzgjm9h.js → auth-Cf4In3Ce.js} +1 -1
  61. package/dist/client/assets/{auth-catchall-CwgiOIdP.js → auth-catchall-CL7qcaW-.js} +1 -1
  62. package/dist/client/assets/{auth-entry-DhEOJXIL.js → auth-entry-BBn3Oy3I.js} +1 -1
  63. package/dist/client/assets/{auth-split-layout-B-Ji1dsx.js → auth-split-layout-ClDCjxcR.js} +1 -1
  64. package/dist/client/assets/{authenticate-and-persist-oauth-Bb5P11Gd.js → authenticate-and-persist-oauth-DeTua2ma.js} +1 -1
  65. package/dist/client/assets/{automation-list-row-BrrHJBg_.js → automation-list-row-bCHP9GaB.js} +1 -1
  66. package/dist/client/assets/{automation-runs-_xFJy_Wv.js → automation-runs-K5fQtR3Q.js} +10 -10
  67. package/dist/client/assets/automations-BchD7Vmn.js +1 -0
  68. package/dist/client/assets/{autosend-BX8nQnW3.js → autosend-CnfmH4zE.js} +1 -1
  69. package/dist/client/assets/{avatar-CfHetrJ0.js → avatar-BB1BJsL_.js} +1 -1
  70. package/dist/client/assets/{badge-BR8ZoQPH.js → badge-miK_gWS7.js} +1 -1
  71. package/dist/client/assets/{block-document-BeMgCoP0.js → block-document-BnBi9DlX.js} +1 -1
  72. package/dist/client/assets/{brand-context-Dfa00_kA.js → brand-context-Bwk8h-AT.js} +1 -1
  73. package/dist/client/assets/{buckets-BJ3UCF_c.js → buckets-BVny45s4.js} +1 -1
  74. package/dist/client/assets/bulk-category-panel-CI-tBRB_.js +1 -0
  75. package/dist/client/assets/{calendar-D9BWcxij.js → calendar-i7Bgz_TN.js} +1 -1
  76. package/dist/client/assets/{capability-load-error-CWaH-_Bd.js → capability-load-error-ykEHLKnb.js} +1 -1
  77. package/dist/client/assets/{card-1ZIM8JYb.js → card-BjD2_XuX.js} +1 -1
  78. package/dist/client/assets/category-editor-CSZtSGt6.js +1 -0
  79. package/dist/client/assets/{chat-context-BhPkOl45.js → chat-context-De0V13yX.js} +1 -1
  80. package/dist/client/assets/{checkbox-YuHG4ViR.js → checkbox-DnsQEgvs.js} +1 -1
  81. package/dist/client/assets/{cli-auth-success-CP82qKpR.js → cli-auth-success-DlpvQRp0.js} +1 -1
  82. package/dist/client/assets/collection-detail-HRLTqsYR.js +1 -0
  83. package/dist/client/assets/{collection-display-button-CbTgXJt9.js → collection-display-button-CNmqBrih.js} +1 -1
  84. package/dist/client/assets/{collection-search-D4kzf4BZ.js → collection-search-MTrnV0Y_.js} +1 -1
  85. package/dist/client/assets/{collection-table-wrapper-Cyqk04aC.js → collection-table-wrapper-CZMGnyXO.js} +1 -1
  86. package/dist/client/assets/{collection-tabs-CwblhJGY.js → collection-tabs-Dvz33uvw.js} +1 -1
  87. package/dist/client/assets/{command-DRUw9pTQ.js → command-DpdcRmV-.js} +1 -1
  88. package/dist/client/assets/commerce-onboarding-QSGTn2pK.js +1 -0
  89. package/dist/client/assets/{companions-core-CrqiPrVn.js → companions-core-CgTHLTTN.js} +1 -1
  90. package/dist/client/assets/connect-desktop-dialog-BASAvtSw.js +1 -0
  91. package/dist/client/assets/{connection-card-BddaDWk3.js → connection-card-DQ8XLP8C.js} +1 -1
  92. package/dist/client/assets/connection-detail-CwpaZMQ9.js +1 -0
  93. package/dist/client/assets/{connection-form-helpers-B3t0vd0x.js → connection-form-helpers-B4Lj6wNN.js} +1 -1
  94. package/dist/client/assets/connections-C4IOF63g.js +1 -0
  95. package/dist/client/assets/{decopilot-sse-pool-B1izZBf2.js → decopilot-sse-pool-_LHJFrBF.js} +1 -1
  96. package/dist/client/assets/{dialog-DfnhzCwv.js → dialog-CUb_uQeJ.js} +1 -1
  97. package/dist/client/assets/{domain-settings-Dw-3NGKK.js → domain-settings-Cj1WoInJ.js} +1 -1
  98. package/dist/client/assets/{drawer-Cu1H6Zpl.js → drawer-BSFvVMvA.js} +1 -1
  99. package/dist/client/assets/{dropdown-menu-BlorfjU6.js → dropdown-menu-D-nlMdm5.js} +1 -1
  100. package/dist/client/assets/{empty-state-D0Yjh42T.js → empty-state-C_IbZdBr.js} +1 -1
  101. package/dist/client/assets/{extract-connection-data-DkYKg47U.js → extract-connection-data-BIadZZgr.js} +1 -1
  102. package/dist/client/assets/file-explorer-BWAl04Ll.js +2 -0
  103. package/dist/client/assets/{file-type-icon-CyQSc8WD.js → file-type-icon-mrfxFHRk.js} +1 -1
  104. package/dist/client/assets/{files-C98dPcEM.js → files-B6sMQ0N9.js} +1 -1
  105. package/dist/client/assets/{form-ZPjO3One.js → form-CEO5VtKG.js} +1 -1
  106. package/dist/client/assets/{general-mC0-nMIz.js → general-CpcExAES.js} +1 -1
  107. package/dist/client/assets/{github-repo-picker-DneVvY3I.js → github-repo-picker-CH-zkM68.js} +1 -1
  108. package/dist/client/assets/{hooks-DsQUp7L9.js → hooks-G1nBJ-F3.js} +1 -1
  109. package/dist/client/assets/{index-BOaCGG-5.js → index-B3_jWN9S.js} +1 -1
  110. package/dist/client/assets/index-B7Kp0gmf.css +1 -0
  111. package/dist/client/assets/index-B8fJFfFf.js +1 -0
  112. package/dist/client/assets/{index-BeTttHS9.js → index-BW23Hqv6.js} +4 -4
  113. package/dist/client/assets/{index-PCoZIk-M.js → index-BZjBKD1m.js} +23 -23
  114. package/dist/client/assets/{index-B8Idfh3P.js → index-B_nVJPYO.js} +1 -1
  115. package/dist/client/assets/{index-CtT9oMhI.js → index-BlItCfDb.js} +1 -1
  116. package/dist/client/assets/index-C7cs-gci.js +2 -0
  117. package/dist/client/assets/{index-1xWIMGUU.js → index-C9P6Y57L.js} +1 -1
  118. package/dist/client/assets/{index-DZp5yHGX.js → index-CTpTvSxb.js} +1 -1
  119. package/dist/client/assets/{index-emjsrsD0.js → index-DAFjHwsT.js} +1 -1
  120. package/dist/client/assets/{index-BHjtHKuw.js → index-DFuynMdy.js} +1 -1
  121. package/dist/client/assets/{index-CrWfdotU.js → index-DQVI41jj.js} +2 -2
  122. package/dist/client/assets/{index-76rFpqug.js → index-DxwLi9-g.js} +1 -1
  123. package/dist/client/assets/{index-C5JCmVQ0.js → index-lRedQ_8t.js} +3 -3
  124. package/dist/client/assets/{index-redirect-Dog_XssD.js → index-redirect-Mh7_3AcS.js} +1 -1
  125. package/dist/client/assets/{input-DWv95vY4.js → input-DOZlS9i9.js} +1 -1
  126. package/dist/client/assets/{integration-icon-D74EpYgv.js → integration-icon-CN9OtiIm.js} +1 -1
  127. package/dist/client/assets/{invite-member-dialog-DGmwAQAA.js → invite-member-dialog-LDdBeQZc.js} +1 -1
  128. package/dist/client/assets/{label-CjR-YPrA.js → label-u5PrAFB7.js} +1 -1
  129. package/dist/client/assets/{layout-BvMp9WH9.js → layout-46QoqgX4.js} +1 -1
  130. package/dist/client/assets/{login-C4VBhHZf.js → login-BdT0h30g.js} +1 -1
  131. package/dist/client/assets/{mcp-oauth-CDqgI2Xn.js → mcp-oauth-DHDPNOkD.js} +1 -1
  132. package/dist/client/assets/{members-NXDCco5L.js → members-RcOcNeXi.js} +1 -1
  133. package/dist/client/assets/{monaco-editor-DYdw6m6P.js → monaco-editor-D2naC6ph.js} +1 -1
  134. package/dist/client/assets/{monitoring-stats-row-D0csDfCQ.js → monitoring-stats-row-CztePoJD.js} +1 -1
  135. package/dist/client/assets/{oauth-callback-D-qdOpL-.js → oauth-callback-BSA-GLPM.js} +1 -1
  136. package/dist/client/assets/{oauth-callback-ai-provider-CKZ-Ikk0.js → oauth-callback-ai-provider-DgPoj4r4.js} +1 -1
  137. package/dist/client/assets/{onboarding-0XZpcTRa.js → onboarding-Br3afGr-.js} +1 -1
  138. package/dist/client/assets/{org-install-BHAQ5v4F.js → org-install-C190-hBM.js} +1 -1
  139. package/dist/client/assets/{org-layout-x9tM7YJ0.js → org-layout-cPdojne_.js} +1 -1
  140. package/dist/client/assets/{organization-choice-CRDRv9IH.js → organization-choice-Csr-kPrj.js} +1 -1
  141. package/dist/client/assets/{orgs-B4dQ6uWB.js → orgs-WjQsKIGK.js} +1 -1
  142. package/dist/client/assets/{page-seo-form-BoV5cy5K.js → page-seo-form-BocKaLGp.js} +1 -1
  143. package/dist/client/assets/page-seo-sheet-BTjq4xGR.js +1 -0
  144. package/dist/client/assets/{popover-DL95paTt.js → popover-BlN-L-7w.js} +1 -1
  145. package/dist/client/assets/post-editor-DD6k2jq_.js +1 -0
  146. package/dist/client/assets/{primitives-CnjPXZBb.js → primitives-C1zKVkUs.js} +1 -1
  147. package/dist/client/assets/{profile-CCbdBUdo.js → profile-B1TQAd_m.js} +1 -1
  148. package/dist/client/assets/project-app-view-DlsPCtAC.js +1 -0
  149. package/dist/client/assets/record-editor-CE1EwunZ.js +1 -0
  150. package/dist/client/assets/redirect-editor-OokObJNP.js +1 -0
  151. package/dist/client/assets/registry-OH_DROyn.js +2 -0
  152. package/dist/client/assets/{registry-layout-C2G4koz9.js → registry-layout-BjGbzV73.js} +2 -2
  153. package/dist/client/assets/reports-BWI6IDQq.css +1 -0
  154. package/dist/client/assets/reports-DEwGwzSI.js +43 -0
  155. package/dist/client/assets/{require-capability-Coot4cTo.js → require-capability-B_dSH45y.js} +1 -1
  156. package/dist/client/assets/{required-auth-layout-BLRuxjNn.js → required-auth-layout-czUUgGrX.js} +1 -1
  157. package/dist/client/assets/{reset-password-BHfCVVq_.js → reset-password-Md6XPqI1.js} +1 -1
  158. package/dist/client/assets/roles-jjnXT7oA.js +1 -0
  159. package/dist/client/assets/{search-input-B9lRxCGI.js → search-input-BQOeLOTi.js} +1 -1
  160. package/dist/client/assets/{secrets-C7tLxfHf.js → secrets-CWkoKQMY.js} +1 -1
  161. package/dist/client/assets/{sections-editor-CEVFpdKw.js → sections-editor-DJYtpXox.js} +2 -2
  162. package/dist/client/assets/{select-D59HzWyb.js → select-CxRcXiYy.js} +1 -1
  163. package/dist/client/assets/{select-model-D8LB7zlx.js → select-model-CJ1n8oWC.js} +1 -1
  164. package/dist/client/assets/self-tool-result-BCQjUWN7.js +1 -0
  165. package/dist/client/assets/seo-editor-DYp9hHSY.js +1 -0
  166. package/dist/client/assets/{settings-layout-LbxIWaT0.js → settings-layout-BXO3VMKS.js} +1 -1
  167. package/dist/client/assets/{settings-section-CHSsdIIo.js → settings-section-Bs1JjdR4.js} +1 -1
  168. package/dist/client/assets/{shell-controls-C3TSKK-x.js → shell-controls-BoSvKLlP.js} +1 -1
  169. package/dist/client/assets/{shell-layout-TAILJ-da.js → shell-layout-DamsdnEZ.js} +1 -1
  170. package/dist/client/assets/{sidebar-i7yNFNs9.js → sidebar-joQ3ZQPE.js} +1 -1
  171. package/dist/client/assets/{skeleton-D824Y8b-.js → skeleton-BxJ_vH4t.js} +1 -1
  172. package/dist/client/assets/{sso-BzsdnWCZ.js → sso-CoEL8qOV.js} +1 -1
  173. package/dist/client/assets/{store-BNZtOJXh.js → store-mvrTZUgb.js} +1 -1
  174. package/dist/client/assets/store-registry-C-81qMOw.js +2 -0
  175. package/dist/client/assets/{studio-tools--pllMpfK.js → studio-tools-BMyTPyPy.js} +1 -1
  176. package/dist/client/assets/{switch-DLw5svpB.js → switch-C6-Jkvpv.js} +1 -1
  177. package/dist/client/assets/{table-B8kPpHAC.js → table-BBmNComr.js} +1 -1
  178. package/dist/client/assets/{tabs-C19FaLXY.js → tabs-kApe5O6i.js} +1 -1
  179. package/dist/client/assets/{textarea-DGICe7Jx.js → textarea-C5puqxj1.js} +1 -1
  180. package/dist/client/assets/{toggle-group-SYBG9bZR.js → toggle-group-DScHdpkW.js} +1 -1
  181. package/dist/client/assets/{toolbar-icon-button-DapYdi-A.js → toolbar-icon-button-D3Y1-YHW.js} +1 -1
  182. package/dist/client/assets/{toolbar-V6M48IQV.js → toolbar-zpMjKMlc.js} +1 -1
  183. package/dist/client/assets/{tools-list-CvZ2H4zV.js → tools-list-BOMB05RR.js} +1 -1
  184. package/dist/client/assets/{tooltip-DjWNMg5T.js → tooltip-REPIyd2Z.js} +1 -1
  185. package/dist/client/assets/{use-ai-providers-CQmOOELp.js → use-ai-providers-Bo4wIQxq.js} +1 -1
  186. package/dist/client/assets/{use-automations-kY9mTa0N.js → use-automations-DA7j42Hg.js} +1 -1
  187. package/dist/client/assets/{use-autosave-DhXH8ptD.js → use-autosave-DBERSs2x.js} +1 -1
  188. package/dist/client/assets/{use-capability-BtQYj-6N.js → use-capability-CCJ-X1mC.js} +1 -1
  189. package/dist/client/assets/{use-clock-tick-BNpEZMto.js → use-clock-tick-MLdLuh40.js} +1 -1
  190. package/dist/client/assets/{use-collections-Kwxr6RPv.js → use-collections-D-OJag2e.js} +1 -1
  191. package/dist/client/assets/{use-connection-DhRKlWkl.js → use-connection-DmUK9JRy.js} +1 -1
  192. package/dist/client/assets/{use-copy-C62zVzDi.js → use-copy-DzWDd5On.js} +1 -1
  193. package/dist/client/assets/{use-create-virtual-mcp-B-2yNc1r.js → use-create-virtual-mcp-BqyRJeCT.js} +1 -1
  194. package/dist/client/assets/{use-debounced-autosave-Cumlh74L.js → use-debounced-autosave-JbhBBkyc.js} +1 -1
  195. package/dist/client/assets/{use-debounced-value-DEfVi-aN.js → use-debounced-value-DxBZ974h.js} +1 -1
  196. package/dist/client/assets/{use-deco-credits-rxapxW2c.js → use-deco-credits-DR4kDN3B.js} +1 -1
  197. package/dist/client/assets/{use-decopilot-events-Cww7ZCTK.js → use-decopilot-events-BhVWtKJy.js} +1 -1
  198. package/dist/client/assets/{use-delete-connection-DehUW7zF.js → use-delete-connection-Ds3puvR-.js} +1 -1
  199. package/dist/client/assets/{use-deployment-admin-DI6Yo_2O.js → use-deployment-admin-C5hKFITD.js} +1 -1
  200. package/dist/client/assets/{use-file-configs-BaRnwcsF.js → use-file-configs-t6weWLBN.js} +1 -1
  201. package/dist/client/assets/{use-infinite-scroll-WwPPe2Wp.js → use-infinite-scroll-B4v-_NDY.js} +1 -1
  202. package/dist/client/assets/{use-join-requests-B29gIAVf.js → use-join-requests-nORXzBkG.js} +1 -1
  203. package/dist/client/assets/{use-mcp-client-DlCO79GA.js → use-mcp-client-D6H50Mmm.js} +1 -1
  204. package/dist/client/assets/{use-mcp-tools-PUeX7iQD.js → use-mcp-tools-Cs2tX1fK.js} +1 -1
  205. package/dist/client/assets/{use-members-CP1GrgsV.js → use-members-Bz6iBsM4.js} +1 -1
  206. package/dist/client/assets/{use-mobile-vXwkCjTm.js → use-mobile-RU-Nn_Un.js} +1 -1
  207. package/dist/client/assets/{use-navigate-to-agent-DZwula5s.js → use-navigate-to-agent-DYPKcx_j.js} +1 -1
  208. package/dist/client/assets/{use-org-auth-client-BeUafwOm.js → use-org-auth-client-DrmuxI_m.js} +1 -1
  209. package/dist/client/assets/{use-org-sso-CpksLDM-.js → use-org-sso-BLc80T83.js} +1 -1
  210. package/dist/client/assets/{use-organization-roles-BGu4f7lA.js → use-organization-roles-DU1BIeXK.js} +1 -1
  211. package/dist/client/assets/use-organization-settings-CHx_I7VH.js +1 -0
  212. package/dist/client/assets/{use-registry-connections-ml5ez91l.js → use-registry-connections-C9dbuMZN.js} +1 -1
  213. package/dist/client/assets/{use-secrets-DXp4vVpG.js → use-secrets-Cs1UIn3n.js} +1 -1
  214. package/dist/client/assets/{use-status-sounds-DUjqcw9j.js → use-status-sounds-C3Efc5TW.js} +1 -1
  215. package/dist/client/assets/{use-view-mode-CJMBEHOJ.js → use-view-mode-y0S1o9OD.js} +1 -1
  216. package/dist/client/assets/{use-virtual-mcp-KZlYJNMn.js → use-virtual-mcp-D9inM-9h.js} +1 -1
  217. package/dist/client/assets/useInfiniteQuery-XeUdT1mI.js +1 -0
  218. package/dist/client/assets/{useRouterState-ClIV-prS.js → useRouterState-DB6AEQYy.js} +1 -1
  219. package/dist/client/assets/useSuspenseInfiniteQuery-DnwWEYgY.js +1 -0
  220. package/dist/client/assets/{users-CliPNaM4.js → users-DV3bsEcg.js} +1 -1
  221. package/dist/client/assets/variant-calendar-B7qy61Jb.js +1 -0
  222. package/dist/client/assets/{view-mode-toggle-BVGFEj0-.js → view-mode-toggle-BIom5MzH.js} +1 -1
  223. package/dist/client/index.html +2 -2
  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/Eye-CyP9kYwn.js +0 -1
  228. package/dist/client/assets/TrendUp01-CBDxjtVg.js +0 -1
  229. package/dist/client/assets/agent-icon-DMtjBPX3.js +0 -1
  230. package/dist/client/assets/agents-list-BUXICXib.js +0 -1
  231. package/dist/client/assets/ai-providers-DCgzVaX6.js +0 -1
  232. package/dist/client/assets/app-editor-D59Q_5eI.js +0 -1
  233. package/dist/client/assets/automations-BaGIRfvu.js +0 -1
  234. package/dist/client/assets/bulk-category-panel-DYbnXnND.js +0 -1
  235. package/dist/client/assets/category-editor-DzbcKPof.js +0 -1
  236. package/dist/client/assets/collection-detail-DIz6zskG.js +0 -1
  237. package/dist/client/assets/commerce-onboarding-e-v-lCWx.js +0 -1
  238. package/dist/client/assets/connect-desktop-dialog-BSEnA0YE.js +0 -1
  239. package/dist/client/assets/connection-detail-B8oW9DNb.js +0 -1
  240. package/dist/client/assets/connections-DXcLr2b7.js +0 -1
  241. package/dist/client/assets/file-explorer-C3OUWmFe.js +0 -2
  242. package/dist/client/assets/index-BO2t38sV.css +0 -1
  243. package/dist/client/assets/index-ByObdePs.js +0 -1
  244. package/dist/client/assets/index-D-JmKBPU.js +0 -2
  245. package/dist/client/assets/page-seo-sheet-BgE0-fxQ.js +0 -1
  246. package/dist/client/assets/post-editor-Byy_Ap7S.js +0 -1
  247. package/dist/client/assets/project-app-view-3TNqVL2p.js +0 -1
  248. package/dist/client/assets/record-editor-TOFRK4bb.js +0 -1
  249. package/dist/client/assets/redirect-editor-luJZRzL9.js +0 -1
  250. package/dist/client/assets/registry-B_upSRSY.js +0 -2
  251. package/dist/client/assets/reports-CPxel0Tp.js +0 -43
  252. package/dist/client/assets/reports-UJeN0SPp.css +0 -1
  253. package/dist/client/assets/roles-Cbr82vAy.js +0 -1
  254. package/dist/client/assets/self-tool-result-BPaV8G2-.js +0 -1
  255. package/dist/client/assets/seo-editor-Dtca_H4G.js +0 -1
  256. package/dist/client/assets/store-registry-DzS8hV6Q.js +0 -2
  257. package/dist/client/assets/use-organization-settings-BFGZ9YuD.js +0 -1
  258. package/dist/client/assets/useInfiniteQuery-D-yVKxn2.js +0 -1
  259. package/dist/client/assets/useSuspenseInfiniteQuery-QFUkmQtZ.js +0 -1
  260. package/dist/client/assets/variant-calendar-DsUFadYs.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as E,c as L,H as eu,J as rp,M as sp,j as p,B as mt,I as la,bJ as tu,bK as ip,at as op,aM as hn,bL as lp,l as Z,p as ap,aR as cp,aO as Jt,aV as up,aU as Bt,ba as Ar,aS as vn,bM as nu,aQ as ru,C as Mt,n as dp,d as fp,K as nt,t as eo,m as jr,b as qn,E as su,aL as iu,bN as Uo,aT as hp,bO as tn}from"./index-C5JCmVQ0.js";import{e as pp,a as mp,b as gp,c as xp,d as Pr,S as yp}from"./select-D59HzWyb.js";import{u as ou}from"./useInfiniteQuery-D-yVKxn2.js";import{a as lu,u as bp}from"./use-connection-DhRKlWkl.js";import{c as kp,u as qo}from"./use-mcp-client-DlCO79GA.js";import{u as Sp}from"./use-virtual-mcp-KZlYJNMn.js";import{b as vp,i as wp,a as Cp,S as Tp}from"./constants-D_FQAPnt.js";import{C as Np}from"./card-1ZIM8JYb.js";import{o as au,m as cu,p as Ko,q as Jo}from"./sidebar-i7yNFNs9.js";import{c as uu,d as du,a as Ys,e as Qe,b as fu,T as Ze}from"./table-B8kPpHAC.js";import{E as to}from"./empty-state-D0Yjh42T.js";import{u as Go}from"./use-infinite-scroll-WwPPe2Wp.js";import{u as Mp}from"./use-members-CP1GrgsV.js";import{u as hu,S as Pn}from"./use-clock-tick-BNpEZMto.js";import{e as Ep}from"./use-automations-kY9mTa0N.js";import{u as pu}from"./studio-tools--pllMpfK.js";import{u as Ap}from"./useSuspenseInfiniteQuery-QFUkmQtZ.js";import{B as rs}from"./badge-BR8ZoQPH.js";import{C as aa}from"./checkbox-YuHG4ViR.js";import{t as Ln}from"./ChevronDown-BsEi-r9q.js";import{b as jp,C as Ip,a as ca,c as Op,e as Rp,d as Dp}from"./command-DRUw9pTQ.js";import{P as mu,a as gu,b as xu}from"./popover-DL95paTt.js";import{A as yu}from"./avatar-CfHetrJ0.js";import{n as no}from"./ChevronUp-BWoVqFrM.js";import{t as Pp,a as bu,n as Xo}from"./Tool02-vM8N2pYB.js";import{i as Lp}from"./FilterLines-C5i4i3WB.js";import{e as _p,W as $p,v as zp,as as Bp,ac as Fp,ai as Vp,j as Hp,aq as ku,at as Wp,au as Up,A as Su,av as ht,aw as qp,ax as Kp,ay as Jp,m as Gp}from"./agent-icon-DMtjBPX3.js";import{t as Qs}from"./Stars01-Bnuoinbt.js";import{i as vu,b as Lr}from"./XCircle-C9sRiEE0.js";import{i as Yo}from"./Check-BbAbdPfp.js";import{i as ua}from"./ChevronRight-B9mybD1s.js";import{a as wu,s as Xp}from"./Eye-CyP9kYwn.js";import{b as Ut,t as Qo,c as da}from"./format-time-BnbuEtat.js";import{u as Cu}from"./use-copy-C62zVzDi.js";import{T as pn,a as mn,b as gn}from"./tooltip-DjWNMg5T.js";import{M as Zo,I as Tu,F as Yp}from"./file-type-icon-CyQSc8WD.js";import{c as Qp}from"./monaco-editor-DYdw6m6P.js";import{g as Nu,M as Zp}from"./index-emjsrsD0.js";import{S as em,h as Kn,m as tm,c as el,d as nm,b as rm}from"./chat-context-BhPkOl45.js";import{c as sm,r as im,g as om,R as lm}from"./hooks-DsQUp7L9.js";import{f as am,n as cm,o as um}from"./tab-id-BijBBRwE.js";import{i as Mu}from"./AlertCircle-CX23NCuO.js";import{s as ss,t as Eu}from"./Star01-Bb61R21H.js";import{s as dm}from"./XClose-4pjmwtT4.js";import{n as ro}from"./ZapSquare-BV8kr37_.js";import{n as Au,i as fm}from"./Globe01-CC0A4U7g.js";import{d as hm,c as pm,a as _r}from"./Tool01-BT4kICfE.js";import{i as fa,a as mm}from"./ZoomOut-7nLppLEs.js";import{i as ir}from"./Monitor01-DBUBWT-e.js";import{i as gm}from"./SearchMd-CKL74aOj.js";import{i as xm}from"./Upload01-Lp0wJMYr.js";import{u as ym,a as bm}from"./shell-layout-TAILJ-da.js";import{n as ju}from"./LinkExternal01-CbW1jJhi.js";import{I as Gt}from"./integration-icon-D74EpYgv.js";import{i as km}from"./ArrowUpRight-Bq-zX9ha.js";import{a as tl}from"./Users03-ZlQye2vY.js";import{a as pt}from"./Palette-B0oAitOJ.js";import{c as Iu}from"./use-navigate-to-agent-DZwula5s.js";import{a as Sm}from"./Stars02-B9xmjTkg.js";import{g as vm}from"./AreaChart-CRvFGO5O.js";import{a as wm,D as Cm,c as Tm,d as Nm,e as Mm}from"./dialog-DfnhzCwv.js";import{a as Em,F as Am,b as jm,c as Im,d as Om,f as Rm}from"./form-ZPjO3One.js";import{I as Dm}from"./input-DWv95vY4.js";const Pm={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 Ou(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(Pm)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function Ru(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function Du(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+Ou(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function yT(n){return n.reduce((e,t)=>Du(e,t.metadata?.usage),Ru())}const Lm={damping:.7,stiffness:.05,mass:1.25},_m=70,$m=1e3/60,zm=350;let Zs=!1;globalThis.document?.addEventListener("mousedown",()=>{Zs=!0});globalThis.document?.addEventListener("mouseup",()=>{Zs=!1});globalThis.document?.addEventListener("click",()=>{Zs=!1});const Bm=(n={})=>{const[e,t]=E.useState(!1),[r,s]=E.useState(n.initial!==!1),[i,o]=E.useState(!1),l=E.useRef(null);l.current=n;const a=E.useCallback(()=>{if(!Zs)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<=_m}}},[]),f=E.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),S=wi(l.current,b.animation),{ignoreEscapes:v=!1}=b;let C,w=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{C=Date.now()}):C=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(),O=(j-(d.lastTick??j))/$m;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(w,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*O,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return T()}return C>Date.now()?(w=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:wi(l.current,l.current.resize),ignoreEscapes:v,duration:Math.max(0,C-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),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===S)return;if(a()){u(!0),c(!1);return}const C=k>v,w=k<v;if(d.animation?.ignoreEscapes){d.scrollTop=v;return}w&&(u(!0),c(!1)),C&&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=ha(b=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),y=ha(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([S])=>{const{height:v}=S.contentRect,C=v-(k??v);if(d.resizeDifference=C,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),C>=0){const w=wi(l.current,k?l.current.resize:l.current.initial);f({animation:w,wait:!0,preserveScrollPosition:!0,duration:w==="instant"?void 0:zm})}else d.isNearBottom&&(u(!1),c(!0));k=v,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===C&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:y,scrollRef:x,scrollToBottom:f,stopScroll:h,isAtBottom:r||i,isNearBottom:i,escapedFromLock:e,state:d}};function ha(n,e){const t=E.useCallback(r=>(t.current=r,n(r)),e);return t}const vi=new Map;function wi(...n){const e={...Lm};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 vi.has(r)||vi.set(r,Object.freeze(e)),t?"instant":vi.get(r)}function Fm(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function nl(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function rl(n,e){if(!e)return n;const t=`${Fm(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function Vm(n,e){return rl(n,e).replace(/[_-]/g," ").toLowerCase()}function Hm(n){const e={};for(const t of n.arguments??[])e[t.name]=t.required?la().min(1,"Required"):la();return eu(e)}function Wm(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Um(n){const e=L.c(66),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:i}=n,o=E.useId();let l;if(e[0]!==t){const z=t?Hm(t):eu({});l=rp(z),e[0]=t,e[1]=l}else l=e[1];const c=l;let u;e[2]!==i||e[3]!==t?(u=t?Wm(t,i):{},e[2]=i,e[3]=t,e[4]=u):u=e[4];let d;e[5]!==c||e[6]!==u?(d={resolver:c,defaultValues:u,mode:"onChange"},e[5]=c,e[6]=u,e[7]=d):d=e[7];const f=sp(d);let h;e[8]!==t?.arguments?(h=t?.arguments??[],e[8]=t?.arguments,e[9]=h):h=e[9];const m=h;let g;e[10]!==f||e[11]!==s||e[12]!==r?(g=async z=>{await s(z),r(null),f.reset()},e[10]=f,e[11]=s,e[12]=r,e[13]=g):g=e[13];const x=g;let y;e[14]!==f||e[15]!==r?(y=z=>{z||(f.reset(),r(null))},e[14]=f,e[15]=r,e[16]=y):y=e[16];const b=y;if(!t)return null;let k;e[17]!==t._meta||e[18]!==t.name||e[19]!==t.title?(k=t.title||Vm(t.name,nl(t._meta)),e[17]=t._meta,e[18]=t.name,e[19]=t.title,e[20]=k):k=e[20];let S;e[21]!==k?(S=p.jsx(wm,{children:p.jsx("span",{className:"capitalize",children:k})}),e[21]=k,e[22]=S):S=e[22];let v;e[23]!==t.description?(v=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[23]=t.description,e[24]=v):v=e[24];let C;e[25]!==v||e[26]!==S?(C=p.jsxs(Cm,{children:[S,v]}),e[25]=v,e[26]=S,e[27]=C):C=e[27];let w;e[28]!==f||e[29]!==x?(w=z=>{z.stopPropagation(),f.handleSubmit(x)(z)},e[28]=f,e[29]=x,e[30]=w):w=e[30];let T;if(e[31]!==m||e[32]!==f.control||e[33]!==f.formState.isSubmitting){let z;e[35]!==f.control||e[36]!==f.formState.isSubmitting?(z=B=>p.jsx(Am,{control:f.control,name:B.name,render:q=>{const{field:J}=q;return p.jsxs(jm,{children:[p.jsxs(Im,{className:"text-xs",children:[B.name,B.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(Om,{children:p.jsx(Dm,{...J,value:J.value??"",required:B.required,placeholder:B.description??"",className:"h-9",disabled:f.formState.isSubmitting})}),p.jsx(Rm,{})]})}},B.name),e[35]=f.control,e[36]=f.formState.isSubmitting,e[37]=z):z=e[37],T=m.map(z),e[31]=m,e[32]=f.control,e[33]=f.formState.isSubmitting,e[34]=T}else T=e[34];let N;e[38]!==b?(N=()=>b(!1),e[38]=b,e[39]=N):N=e[39];let M;e[40]!==f.formState.isSubmitting||e[41]!==N?(M=p.jsx(mt,{type:"button",variant:"ghost",onClick:N,disabled:f.formState.isSubmitting,children:"Cancel"}),e[40]=f.formState.isSubmitting,e[41]=N,e[42]=M):M=e[42];let j;e[43]!==f.formState.isSubmitting?(j=f.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(em,{size:"xs"}),"Loading..."]}):"Use prompt",e[43]=f.formState.isSubmitting,e[44]=j):j=e[44];let O;e[45]!==f.formState.isSubmitting||e[46]!==o||e[47]!==j?(O=p.jsx(mt,{type:"submit",form:o,disabled:f.formState.isSubmitting,children:j}),e[45]=f.formState.isSubmitting,e[46]=o,e[47]=j,e[48]=O):O=e[48];let A;e[49]!==M||e[50]!==O?(A=p.jsxs(Tm,{children:[M,O]}),e[49]=M,e[50]=O,e[51]=A):A=e[51];let R;e[52]!==o||e[53]!==w||e[54]!==T||e[55]!==A?(R=p.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:w,children:[T,A]}),e[52]=o,e[53]=w,e[54]=T,e[55]=A,e[56]=R):R=e[56];let I;e[57]!==f||e[58]!==R?(I=p.jsx(Em,{...f,children:R}),e[57]=f,e[58]=R,e[59]=I):I=e[59];let _;e[60]!==C||e[61]!==I?(_=p.jsxs(Nm,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,I]}),e[60]=C,e[61]=I,e[62]=_):_=e[62];let $;return e[63]!==b||e[64]!==_?($=p.jsx(Mm,{open:!0,onOpenChange:b,children:_}),e[63]=b,e[64]=_,e[65]=$):$=e[65],$}function Pu(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function ct(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 Jn(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 Oe(n){this.content=n}Oe.prototype={constructor:Oe,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),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Oe(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Oe(t)},addToStart:function(n,e){return new Oe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Oe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Oe(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=Oe.from(n),n.size?new Oe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Oe.from(n),n.size?new Oe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Oe.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}};Oe.from=function(n){if(n instanceof Oe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Oe(e)};function Lu(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),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Lu(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function _u(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=_u(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class D{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,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!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 i="",o=!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&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new D(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 i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new D(r,s)}cutByIndex(e,t){return e==t?D.empty:e==0&&t==this.content.length?this:new D(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new D(s,i)}addToStart(e){return new D([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new D(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 Lu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return _u(this,e,t,r)}findIndex(e){if(e==0)return $r(0,e);if(e==this.size)return $r(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),i=r+s.nodeSize;if(i>=e)return i==e?$r(t+1,i):$r(t,r);r=i}}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 D.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new D(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return D.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new D(t||e,r)}static from(e){if(!e)return D.empty;if(e instanceof D)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new D([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);const Ci={index:0,offset:0};function $r(n,e){return Ci.index=n,Ci.offset=e,Ci}function is(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(!is(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!is(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let fe=class so{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}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&&is(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 so.none;if(e instanceof so)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};fe.none=[];class ls extends Error{}class F{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=zu(this.content,e+this.openStart,t);return r&&new F(r,this.openStart,this.openEnd)}removeBetween(e,t){return new F($u(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 F.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 F(D.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new F(e,r,s)}}F.empty=new F(D.empty,0,0);function $u(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy($u(i.content,e-s-1,t-s-1)))}function zu(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=zu(o.content,e-i-1,t,o);return l&&n.replaceChild(s,o.copy(l))}function qm(n,e,t){if(t.openStart>n.depth)throw new ls("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ls("Inconsistent open depths");return Bu(n,e,t,0)}function Bu(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Bu(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return cn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Km(t,n);return cn(i,Vu(n,o,l,e,r))}else return cn(i,as(n,e,r))}function Fu(n,e){if(!e.type.compatibleContent(n.type))throw new ls("Cannot join "+e.type.name+" onto "+n.type.name)}function io(n,e,t){let r=n.node(t);return Fu(r,e.node(t)),r}function an(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 or(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(an(n.nodeAfter,r),i++));for(let l=i;l<o;l++)an(s.child(l),r);e&&e.depth==t&&e.textOffset&&an(e.nodeBefore,r)}function cn(n,e){return n.type.checkContent(e),n.copy(e)}function Vu(n,e,t,r,s){let i=n.depth>s&&io(n,e,s+1),o=r.depth>s&&io(t,r,s+1),l=[];return or(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Fu(i,o),an(cn(i,Vu(n,e,t,r,s+1)),l)):(i&&an(cn(i,as(n,e,s+1)),l),or(e,t,s,l),o&&an(cn(o,as(t,r,s+1)),l)),or(r,null,s,l),new D(l)}function as(n,e,t){let r=[];if(or(null,n,t,r),n.depth>t){let s=io(n,e,t+1);an(cn(s,as(n,e,t+1)),r)}return or(e,null,t,r),new D(r)}function Km(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(D.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class xr{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 i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return fe.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 i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}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 i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].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 cs(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,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new xr(t,r,i)}static resolveCached(e,t){let r=pa.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else pa.set(e,r=new Jm);let s=r.elts[r.i]=xr.resolve(e,t);return r.i=(r.i+1)%Gm,s}}class Jm{constructor(){this.elts=[],this.i=0}}const Gm=12,pa=new WeakMap;class cs{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 Xm=Object.create(null);class at{constructor(e,t,r,s=fe.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||D.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&&is(this.attrs,t||e.defaultAttrs||Xm)&&fe.sameSet(this.marks,r||fe.none)}copy(e=null){return e==this.content?this:new at(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new at(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 F.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new F(c,s.depth-o,i.depth-o)}replace(e,t,r){return qm(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 xr.resolveCached(this,e)}resolveNoCache(e){return xr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.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()+")"),Hu(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=D.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;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 i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.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=fe.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(!fe.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=D.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}at.prototype.text=void 0;class us extends at{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):Hu(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 us(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new us(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 Hu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class xn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ym(e,t);if(r.next==null)return xn.empty;let s=Wu(r);r.next&&r.err("Unexpected trailing text");let i=sg(rg(s));return ig(i,r),i}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 i=t;s&&i<r;i++)s=s.matchType(e.child(i).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 i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return D.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(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(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!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 i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
1
+ import{r as E,c as L,H as eu,J as rp,M as sp,j as p,B as mt,I as la,bJ as tu,bK as ip,at as op,aM as hn,bL as lp,l as Z,p as ap,aR as cp,aO as Jt,aV as up,aU as Bt,ba as Ar,aS as vn,bM as nu,aQ as ru,C as Mt,n as dp,d as fp,K as nt,t as eo,m as jr,b as qn,E as su,aL as iu,bN as Uo,aT as hp,bO as tn}from"./index-lRedQ_8t.js";import{e as pp,a as mp,b as gp,c as xp,d as Pr,S as yp}from"./select-CxRcXiYy.js";import{u as ou}from"./useInfiniteQuery-XeUdT1mI.js";import{a as lu,u as bp}from"./use-connection-DmUK9JRy.js";import{c as kp,u as qo}from"./use-mcp-client-D6H50Mmm.js";import{u as Sp}from"./use-virtual-mcp-D9inM-9h.js";import{b as vp,i as wp,a as Cp,S as Tp}from"./constants-D_FQAPnt.js";import{C as Np}from"./card-BjD2_XuX.js";import{o as au,m as cu,p as Ko,q as Jo}from"./sidebar-joQ3ZQPE.js";import{c as uu,d as du,a as Ys,e as Qe,b as fu,T as Ze}from"./table-BBmNComr.js";import{E as to}from"./empty-state-C_IbZdBr.js";import{u as Go}from"./use-infinite-scroll-B4v-_NDY.js";import{u as Mp}from"./use-members-Bz6iBsM4.js";import{u as hu,S as Pn}from"./use-clock-tick-MLdLuh40.js";import{e as Ep}from"./use-automations-DA7j42Hg.js";import{u as pu}from"./studio-tools-BMyTPyPy.js";import{u as Ap}from"./useSuspenseInfiniteQuery-DnwWEYgY.js";import{B as rs}from"./badge-miK_gWS7.js";import{C as aa}from"./checkbox-DnsQEgvs.js";import{t as Ln}from"./ChevronDown-wHLuFr3i.js";import{b as jp,C as Ip,a as ca,c as Op,e as Rp,d as Dp}from"./command-DpdcRmV-.js";import{P as mu,a as gu,b as xu}from"./popover-BlN-L-7w.js";import{A as yu}from"./avatar-BB1BJsL_.js";import{n as no}from"./ChevronUp-CRmxYAjE.js";import{t as Pp,a as bu,n as Xo}from"./Tool02-DkTMVP4f.js";import{i as Lp}from"./FilterLines-CwEBxGZP.js";import{e as _p,V as $p,v as zp,aq as Bp,ab as Fp,ag as Vp,j as Hp,ao as ku,ar as Wp,as as Up,A as Su,at as ht,au as qp,av as Kp,aw as Jp,m as Gp}from"./agent-icon-5pSyq_FH.js";import{t as Qs}from"./Stars01-COE1U6xi.js";import{i as vu,b as Lr}from"./XCircle-DHCvZwgH.js";import{i as Yo}from"./Check-DYPRi7NO.js";import{i as ua}from"./ChevronRight-BARfL9-W.js";import{a as wu}from"./Copy01-BwtpNAKR.js";import{b as Ut,t as Qo,c as da}from"./format-time-BnbuEtat.js";import{u as Cu}from"./use-copy-DzWDd5On.js";import{T as pn,a as mn,b as gn}from"./tooltip-REPIyd2Z.js";import{M as Zo,I as Tu,F as Xp}from"./file-type-icon-mrfxFHRk.js";import{c as Yp}from"./monaco-editor-D2naC6ph.js";import{g as Nu,M as Qp}from"./index-DAFjHwsT.js";import{S as Zp,h as Kn,m as em,c as el,d as tm,b as nm}from"./chat-context-De0V13yX.js";import{c as rm,r as sm,g as im,R as om}from"./hooks-G1nBJ-F3.js";import{f as lm,n as am,o as cm}from"./tab-id-BijBBRwE.js";import{i as Mu}from"./AlertCircle-BaauQIwC.js";import{s as um}from"./Eye-CM4SfxEo.js";import{s as ss,t as Eu}from"./Star01-CtWX4nA3.js";import{s as dm}from"./XClose-P0NM9uUE.js";import{n as ro}from"./ZapSquare-BhWmmFEB.js";import{n as Au,i as fm}from"./Globe01-B-4z45oj.js";import{d as hm,c as pm,a as _r}from"./Tool01-BWGVYfev.js";import{i as fa,a as mm}from"./ZoomOut-C7W-ZWAB.js";import{i as ir}from"./Monitor01-BkHN4rM2.js";import{i as gm}from"./SearchMd-CbytZ1-S.js";import{i as xm}from"./Upload01-CoVAXfWg.js";import{u as ym,a as bm}from"./shell-layout-DamsdnEZ.js";import{n as ju}from"./LinkExternal01-022iaJNF.js";import{I as Gt}from"./integration-icon-CN9OtiIm.js";import{i as km}from"./ArrowUpRight-BLP3DLju.js";import{a as tl}from"./Users03-BYqJADve.js";import{a as pt}from"./Palette-BWa7ee-4.js";import{c as Iu}from"./use-navigate-to-agent-DYPKcx_j.js";import{a as Sm}from"./Stars02-BzQc7fZz.js";import{g as vm}from"./AreaChart-5GoV9SRg.js";import{a as wm,D as Cm,c as Tm,d as Nm,e as Mm}from"./dialog-CUb_uQeJ.js";import{a as Em,F as Am,b as jm,c as Im,d as Om,f as Rm}from"./form-CEO5VtKG.js";import{I as Dm}from"./input-DOZlS9i9.js";const Pm={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 Ou(n){if(!n?.providerMetadata)return 0;for(const e of Object.values(Pm)){const t=e(n.providerMetadata);if(t!==null)return t}return 0}function Ru(){return{inputTokens:0,outputTokens:0,reasoningTokens:0,totalTokens:0,cost:0,cacheReadTokens:0,cacheWriteTokens:0}}function Du(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+Ou(e),cacheReadTokens:n.cacheReadTokens+t,cacheWriteTokens:n.cacheWriteTokens+r}}function bT(n){return n.reduce((e,t)=>Du(e,t.metadata?.usage),Ru())}const Lm={damping:.7,stiffness:.05,mass:1.25},_m=70,$m=1e3/60,zm=350;let Zs=!1;globalThis.document?.addEventListener("mousedown",()=>{Zs=!0});globalThis.document?.addEventListener("mouseup",()=>{Zs=!1});globalThis.document?.addEventListener("click",()=>{Zs=!1});const Bm=(n={})=>{const[e,t]=E.useState(!1),[r,s]=E.useState(n.initial!==!1),[i,o]=E.useState(!1),l=E.useRef(null);l.current=n;const a=E.useCallback(()=>{if(!Zs)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<=_m}}},[]),f=E.useCallback((b={})=>{typeof b=="string"&&(b={animation:b}),b.preserveScrollPosition||c(!0);const k=Date.now()+(Number(b.wait)||0),S=wi(l.current,b.animation),{ignoreEscapes:v=!1}=b;let C,w=d.calculatedTargetScrollTop;b.duration instanceof Promise?b.duration.finally(()=>{C=Date.now()}):C=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(),O=(j-(d.lastTick??j))/$m;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(w,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*O,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return T()}return C>Date.now()?(w=d.calculatedTargetScrollTop,T()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:wi(l.current,l.current.resize),ignoreEscapes:v,duration:Math.max(0,C-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),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||k===S)return;if(a()){u(!0),c(!1);return}const C=k>v,w=k<v;if(d.animation?.ignoreEscapes){d.scrollTop=v;return}w&&(u(!0),c(!1)),C&&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=ha(b=>{x.current?.removeEventListener("scroll",m),x.current?.removeEventListener("wheel",g),b?.addEventListener("scroll",m,{passive:!0}),b?.addEventListener("wheel",g,{passive:!0})},[]),y=ha(b=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!b)return;let k;d.resizeObserver=new ResizeObserver(([S])=>{const{height:v}=S.contentRect,C=v-(k??v);if(d.resizeDifference=C,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),C>=0){const w=wi(l.current,k?l.current.resize:l.current.initial);f({animation:w,wait:!0,preserveScrollPosition:!0,duration:w==="instant"?void 0:zm})}else d.isNearBottom&&(u(!1),c(!0));k=v,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===C&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(b)},[]);return{contentRef:y,scrollRef:x,scrollToBottom:f,stopScroll:h,isAtBottom:r||i,isNearBottom:i,escapedFromLock:e,state:d}};function ha(n,e){const t=E.useCallback(r=>(t.current=r,n(r)),e);return t}const vi=new Map;function wi(...n){const e={...Lm};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 vi.has(r)||vi.set(r,Object.freeze(e)),t?"instant":vi.get(r)}function Fm(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function nl(n){if(n&&typeof n=="object"&&"gatewayClientId"in n&&typeof n.gatewayClientId=="string")return n.gatewayClientId}function rl(n,e){if(!e)return n;const t=`${Fm(e)}_`;return n.startsWith(t)?n.slice(t.length):n}function Vm(n,e){return rl(n,e).replace(/[_-]/g," ").toLowerCase()}function Hm(n){const e={};for(const t of n.arguments??[])e[t.name]=t.required?la().min(1,"Required"):la();return eu(e)}function Wm(n,e){const t={};for(const r of n.arguments??[])t[r.name]=e?.[r.name]??"";return t}function Um(n){const e=L.c(66),{prompt:t,setPrompt:r,onSubmit:s,defaultValues:i}=n,o=E.useId();let l;if(e[0]!==t){const z=t?Hm(t):eu({});l=rp(z),e[0]=t,e[1]=l}else l=e[1];const c=l;let u;e[2]!==i||e[3]!==t?(u=t?Wm(t,i):{},e[2]=i,e[3]=t,e[4]=u):u=e[4];let d;e[5]!==c||e[6]!==u?(d={resolver:c,defaultValues:u,mode:"onChange"},e[5]=c,e[6]=u,e[7]=d):d=e[7];const f=sp(d);let h;e[8]!==t?.arguments?(h=t?.arguments??[],e[8]=t?.arguments,e[9]=h):h=e[9];const m=h;let g;e[10]!==f||e[11]!==s||e[12]!==r?(g=async z=>{await s(z),r(null),f.reset()},e[10]=f,e[11]=s,e[12]=r,e[13]=g):g=e[13];const x=g;let y;e[14]!==f||e[15]!==r?(y=z=>{z||(f.reset(),r(null))},e[14]=f,e[15]=r,e[16]=y):y=e[16];const b=y;if(!t)return null;let k;e[17]!==t._meta||e[18]!==t.name||e[19]!==t.title?(k=t.title||Vm(t.name,nl(t._meta)),e[17]=t._meta,e[18]=t.name,e[19]=t.title,e[20]=k):k=e[20];let S;e[21]!==k?(S=p.jsx(wm,{children:p.jsx("span",{className:"capitalize",children:k})}),e[21]=k,e[22]=S):S=e[22];let v;e[23]!==t.description?(v=t.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:t.description}),e[23]=t.description,e[24]=v):v=e[24];let C;e[25]!==v||e[26]!==S?(C=p.jsxs(Cm,{children:[S,v]}),e[25]=v,e[26]=S,e[27]=C):C=e[27];let w;e[28]!==f||e[29]!==x?(w=z=>{z.stopPropagation(),f.handleSubmit(x)(z)},e[28]=f,e[29]=x,e[30]=w):w=e[30];let T;if(e[31]!==m||e[32]!==f.control||e[33]!==f.formState.isSubmitting){let z;e[35]!==f.control||e[36]!==f.formState.isSubmitting?(z=B=>p.jsx(Am,{control:f.control,name:B.name,render:q=>{const{field:J}=q;return p.jsxs(jm,{children:[p.jsxs(Im,{className:"text-xs",children:[B.name,B.required?null:p.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),p.jsx(Om,{children:p.jsx(Dm,{...J,value:J.value??"",required:B.required,placeholder:B.description??"",className:"h-9",disabled:f.formState.isSubmitting})}),p.jsx(Rm,{})]})}},B.name),e[35]=f.control,e[36]=f.formState.isSubmitting,e[37]=z):z=e[37],T=m.map(z),e[31]=m,e[32]=f.control,e[33]=f.formState.isSubmitting,e[34]=T}else T=e[34];let N;e[38]!==b?(N=()=>b(!1),e[38]=b,e[39]=N):N=e[39];let M;e[40]!==f.formState.isSubmitting||e[41]!==N?(M=p.jsx(mt,{type:"button",variant:"ghost",onClick:N,disabled:f.formState.isSubmitting,children:"Cancel"}),e[40]=f.formState.isSubmitting,e[41]=N,e[42]=M):M=e[42];let j;e[43]!==f.formState.isSubmitting?(j=f.formState.isSubmitting?p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx(Zp,{size:"xs"}),"Loading..."]}):"Use prompt",e[43]=f.formState.isSubmitting,e[44]=j):j=e[44];let O;e[45]!==f.formState.isSubmitting||e[46]!==o||e[47]!==j?(O=p.jsx(mt,{type:"submit",form:o,disabled:f.formState.isSubmitting,children:j}),e[45]=f.formState.isSubmitting,e[46]=o,e[47]=j,e[48]=O):O=e[48];let A;e[49]!==M||e[50]!==O?(A=p.jsxs(Tm,{children:[M,O]}),e[49]=M,e[50]=O,e[51]=A):A=e[51];let R;e[52]!==o||e[53]!==w||e[54]!==T||e[55]!==A?(R=p.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:w,children:[T,A]}),e[52]=o,e[53]=w,e[54]=T,e[55]=A,e[56]=R):R=e[56];let I;e[57]!==f||e[58]!==R?(I=p.jsx(Em,{...f,children:R}),e[57]=f,e[58]=R,e[59]=I):I=e[59];let _;e[60]!==C||e[61]!==I?(_=p.jsxs(Nm,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,I]}),e[60]=C,e[61]=I,e[62]=_):_=e[62];let $;return e[63]!==b||e[64]!==_?($=p.jsx(Mm,{open:!0,onOpenChange:b,children:_}),e[63]=b,e[64]=_,e[65]=$):$=e[65],$}function Pu(n){return n?n.replace(/[_-]/g," ").toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function ct(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 Jn(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 Oe(n){this.content=n}Oe.prototype={constructor:Oe,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),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Oe(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Oe(t)},addToStart:function(n,e){return new Oe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Oe(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Oe(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=Oe.from(n),n.size?new Oe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Oe.from(n),n.size?new Oe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Oe.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}};Oe.from=function(n){if(n instanceof Oe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Oe(e)};function Lu(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),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Lu(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function _u(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=_u(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class D{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,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!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 i="",o=!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&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new D(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 i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new D(r,s)}cutByIndex(e,t){return e==t?D.empty:e==0&&t==this.content.length?this:new D(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new D(s,i)}addToStart(e){return new D([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new D(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 Lu(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return _u(this,e,t,r)}findIndex(e){if(e==0)return $r(0,e);if(e==this.size)return $r(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),i=r+s.nodeSize;if(i>=e)return i==e?$r(t+1,i):$r(t,r);r=i}}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 D.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new D(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return D.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new D(t||e,r)}static from(e){if(!e)return D.empty;if(e instanceof D)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new D([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);const Ci={index:0,offset:0};function $r(n,e){return Ci.index=n,Ci.offset=e,Ci}function is(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(!is(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!is(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let fe=class so{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}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&&is(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 so.none;if(e instanceof so)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};fe.none=[];class ls extends Error{}class F{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=zu(this.content,e+this.openStart,t);return r&&new F(r,this.openStart,this.openEnd)}removeBetween(e,t){return new F($u(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 F.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 F(D.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new F(e,r,s)}}F.empty=new F(D.empty,0,0);function $u(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy($u(i.content,e-s-1,t-s-1)))}function zu(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=zu(o.content,e-i-1,t,o);return l&&n.replaceChild(s,o.copy(l))}function qm(n,e,t){if(t.openStart>n.depth)throw new ls("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ls("Inconsistent open depths");return Bu(n,e,t,0)}function Bu(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Bu(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return cn(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Km(t,n);return cn(i,Vu(n,o,l,e,r))}else return cn(i,as(n,e,r))}function Fu(n,e){if(!e.type.compatibleContent(n.type))throw new ls("Cannot join "+e.type.name+" onto "+n.type.name)}function io(n,e,t){let r=n.node(t);return Fu(r,e.node(t)),r}function an(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 or(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(an(n.nodeAfter,r),i++));for(let l=i;l<o;l++)an(s.child(l),r);e&&e.depth==t&&e.textOffset&&an(e.nodeBefore,r)}function cn(n,e){return n.type.checkContent(e),n.copy(e)}function Vu(n,e,t,r,s){let i=n.depth>s&&io(n,e,s+1),o=r.depth>s&&io(t,r,s+1),l=[];return or(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Fu(i,o),an(cn(i,Vu(n,e,t,r,s+1)),l)):(i&&an(cn(i,as(n,e,s+1)),l),or(e,t,s,l),o&&an(cn(o,as(t,r,s+1)),l)),or(r,null,s,l),new D(l)}function as(n,e,t){let r=[];if(or(null,n,t,r),n.depth>t){let s=io(n,e,t+1);an(cn(s,as(n,e,t+1)),r)}return or(e,null,t,r),new D(r)}function Km(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(D.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class xr{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 i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return fe.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 i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}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 i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].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 cs(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,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new xr(t,r,i)}static resolveCached(e,t){let r=pa.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else pa.set(e,r=new Jm);let s=r.elts[r.i]=xr.resolve(e,t);return r.i=(r.i+1)%Gm,s}}class Jm{constructor(){this.elts=[],this.i=0}}const Gm=12,pa=new WeakMap;class cs{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 Xm=Object.create(null);class at{constructor(e,t,r,s=fe.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||D.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&&is(this.attrs,t||e.defaultAttrs||Xm)&&fe.sameSet(this.marks,r||fe.none)}copy(e=null){return e==this.content?this:new at(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new at(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 F.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new F(c,s.depth-o,i.depth-o)}replace(e,t,r){return qm(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 xr.resolveCached(this,e)}resolveNoCache(e){return xr.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.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()+")"),Hu(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=D.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;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 i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.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=fe.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(!fe.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=D.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}at.prototype.text=void 0;class us extends at{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):Hu(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 us(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new us(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 Hu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class xn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ym(e,t);if(r.next==null)return xn.empty;let s=Wu(r);r.next&&r.err("Unexpected trailing text");let i=sg(rg(s));return ig(i,r),i}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 i=t;s&&i<r;i++)s=s.matchType(e.child(i).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 i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return D.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(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(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!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 i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
2
2
  `)}}xn.empty=new xn(!0);class Ym{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 Wu(n){let e=[];do e.push(Qm(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Qm(n){let e=[];do e.push(Zm(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Zm(n){let e=ng(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=eg(n,e);else break;return e}function ma(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function eg(n,e){let t=ma(n),r=t;return n.eat(",")&&(n.next!="}"?r=ma(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function tg(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function ng(n){if(n.eat("(")){let e=Wu(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=tg(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 rg(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Uu(n,e){return e-n}function ga(n,e){let t=[];return r(e),t.sort(Uu);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&t.indexOf(a)==-1&&r(a)}}}function sg(n){let e=Object.create(null);return t(ga(n,0));function t(r){let s=[];r.forEach(o=>{n[o].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]);ga(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new xn(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Uu);i.next.push({type:s[o][0],next:e[l.join(",")]||t(l)})}return i}}function ig(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function qu(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 Ku(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Ju(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 i=n[s];i.validate&&i.validate(e[s])}}function Gu(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new lg(n,r,e[r]);return t}let xa=class Xu{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=Gu(e,r.attrs),this.defaultAttrs=qu(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==xn.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:Ku(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new at(this,this.computeAttrs(e),D.from(t),fe.setFrom(r))}createChecked(e=null,t,r){return t=D.from(t),this.checkContent(t),new at(this,this.computeAttrs(e),t,fe.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=D.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(D.empty,!0);return i?new at(this,e,t.append(i),fe.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){Ju(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:fe.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new Xu(i,t,o));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 i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function og(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class lg{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?og(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ei{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=Gu(e,s.attrs),this.excluded=null;let i=qu(this.attrs);this.instance=i?new fe(this,i):null}create(e=null){return!e&&this.instance?this.instance:new fe(this,Ku(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new ei(i,s++,t,o)),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){Ju(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Yu{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=Oe.from(e.nodes),t.marks=Oe.from(e.marks||{}),this.nodes=xa.compile(this.spec.nodes,this),this.marks=ei.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 i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=xn.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?ya(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:ya(this,o.split(" "))}this.nodeFromJSON=s=>at.fromJSON(this,s),this.markFromJSON=s=>fe.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 xa){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 us(r,r.defaultAttrs,e,fe.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 ya(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);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(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ag(n){return n.tag!=null}function cg(n){return n.style!=null}class Ft{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(ag(s))this.tags.push(s);else if(cg(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new ka(this,t,!1);return r.addAll(e,fe.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ka(this,t,!0);return r.addAll(e,fe.none,t.from,t.to),F.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(fg(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Sa(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Sa(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ft(e,Ft.schemaRules(e)))}}const Qu={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},ug={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zu={ol:!0,ul:!0},yr=1,oo=2,lr=4;function ba(n,e,t){return e!=null?(e?yr:0)|(e==="full"?oo:0):n&&n.whitespace=="pre"?yr|oo:t&~lr}class zr{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=fe.none,this.match=i||(o&lr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.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&yr)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.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&&!Qu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ka{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=ba(null,t.preserveWhitespace,0)|(r?lr:0);s?i=new zr(s.type,s.attrs,fe.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new zr(null,null,fe.none,!0,null,o):i=new zr(e.schema.topNodeType,null,fe.none,!0,null,o),this.nodes=[i],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,i=s.options&oo?"full":this.localPreserveWS||(s.options&yr)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
3
3
  `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.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(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Zu.hasOwnProperty(o)&&this.parser.normalizeLists&&dg(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:ug.hasOwnProperty(o))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(Qu.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.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(i),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 i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,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 i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.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)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=fe.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):va(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=ba(e,i,o.options);o.options&lr&&o.content.length==0&&(l|=lr);let a=fe.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):va(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new zr(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|=yr)}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),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(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 dg(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Zu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function fg(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Sa(n){let e={};for(let t in n)e[t]=n[t];return e}function va(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class wn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Ti(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Qr(Ti(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 i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Qr(Ti(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Qr(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new wn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=wa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return wa(e.marks)}}function wa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Ti(n){return n.document||window.document}const Ca=new WeakMap;function hg(n){let e=Ca.get(n);return e===void 0&&Ca.set(n,e=pg(n)),e}function pg(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 Qr(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],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=hg(r))&&i.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 o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+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}=Qr(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 ed=65535,td=Math.pow(2,16);function mg(n,e){return n+e*td}function Ta(n){return n&ed}function gg(n){return(n-(n&ed))/td}const nd=1,rd=2,Zr=4,sd=8;class lo{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&sd)>0}get deletedBefore(){return(this.delInfo&(nd|Zr))>0}get deletedAfter(){return(this.delInfo&(rd|Zr))>0}get deletedAcross(){return(this.delInfo&Zr)>0}}class Je{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Je.empty)return Je.empty}recover(e){let t=0,r=Ta(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+gg(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,i=this.inverted?2:1,o=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+i],u=this.ranges[l+o],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:mg(l/3,e-a),g=e==a?rd:e==d?nd:Zr;return(t<0?e!=a:e!=d)&&(g|=sd),new lo(h,g,m)}s+=u-c}return r?e+s:new lo(e+s,0,null)}touches(e,t){let r=0,s=Ta(t),i=this.inverted?2:1,o=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+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new Je(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Je.empty:new Je(e<0?[0,-e,0]:[0,0,e])}}Je.empty=new Je([]);class br{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 br(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 br;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 i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new lo(e,s,null)}}const Ni=Object.create(null);class Be{getMap(){return Je.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ni[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 Ni)throw new RangeError("Duplicate use of step JSON ID "+e);return Ni[e]=t,t.prototype.jsonID=e,t}}class Ce{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Ce(e,null)}static fail(e){return new Ce(null,e)}static fromReplace(e,t,r,s){try{return Ce.ok(e.replace(t,r,s))}catch(i){if(i instanceof ls)return Ce.fail(i.message);throw i}}}function sl(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(sl(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return D.fromArray(r)}class _t extends Be{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)),i=new F(sl(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return Ce.fromReplace(e,this.from,this.to,i)}invert(){return new lt(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 _t(t.pos,r.pos,this.mark)}merge(e){return e instanceof _t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _t(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 _t(t.from,t.to,e.markFromJSON(t.mark))}}Be.jsonID("addMark",_t);class lt extends Be{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 F(sl(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return Ce.fromReplace(e,this.from,this.to,r)}invert(){return new _t(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 lt(t.pos,r.pos,this.mark)}merge(e){return e instanceof lt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lt(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 lt(t.from,t.to,e.markFromJSON(t.mark))}}Be.jsonID("removeMark",lt);class $t extends Be{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ce.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ce.fromReplace(e,this.pos,this.pos+1,new F(D.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 $t(this.pos,t.marks[s]);return new $t(this.pos,this.mark)}}return new yn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new $t(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 $t(t.pos,e.markFromJSON(t.mark))}}Be.jsonID("addNodeMark",$t);class yn extends Be{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ce.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Ce.fromReplace(e,this.pos,this.pos+1,new F(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new $t(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new yn(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 yn(t.pos,e.markFromJSON(t.mark))}}Be.jsonID("removeNodeMark",yn);class we extends Be{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&ao(e,this.from,this.to)?Ce.fail("Structure replace would overwrite content"):Ce.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Je([this.from,this.to-this.from,this.slice.size])}invert(e){return new we(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&&we.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new we(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof we)||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?F.empty:new F(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new we(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?F.empty:new F(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new we(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 we(t.from,t.to,F.fromJSON(e,t.slice),!!t.structure)}}we.MAP_BIAS=1;Be.jsonID("replace",we);class Ae extends Be{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ao(e,this.from,this.gapFrom)||ao(e,this.gapTo,this.to)))return Ce.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Ce.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Ce.fromReplace(e,this.from,this.to,r):Ce.fail("Content does not fit in gap")}getMap(){return new Je([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 Ae(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),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new Ae(t.pos,r.pos,s,i,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 Ae(t.from,t.to,t.gapFrom,t.gapTo,F.fromJSON(e,t.slice),t.insert,!!t.structure)}}Be.jsonID("replaceAround",Ae);function ao(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function xg(n,e,t,r){let s=[],i=[],o,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)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:s.push(o=new lt(f,h,d[g])));l&&l.to==f?l.to=h:i.push(l=new _t(f,h,r))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function yg(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof ei){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.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==i-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>n.step(new lt(o.from,o.to,o.style)))}function il(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new we(l,u,F.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new lt(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 F(D.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new we(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(D.empty,!0);n.replace(l,l,new F(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function bg(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Gn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,i=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-i;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!bg(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function kg(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=D.empty,d=0;for(let m=i,g=!1;m>t;m--)g||r.index(m)>0?(g=!0,u=D.from(r.node(m).copy(u)),d++):a--;let f=D.empty,h=0;for(let m=i,g=!1;m>t;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=D.from(s.node(m).copy(f)),h++):c++;n.step(new Ae(a,c,o,l,new F(u.append(f),d,h),u.size-d,!0))}function ol(n,e,t=null,r=n){let s=Sg(n,e),i=s&&vg(r,e);return i?s.map(Na).concat({type:e,attrs:t}).concat(i.map(Na)):null}function Na(n){return{type:n,attrs:null}}function Sg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function vg(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function wg(n,e,t){let r=D.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].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=D.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new Ae(s,i,s,i,new F(r,0,0),t.length,!0))}function Cg(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&Tg(n.doc,n.mapping.slice(i).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&&od(n,o,l,i),il(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new Ae(d,f,d+1,f-1,new F(D.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&id(n,o,l,i),!1}})}function id(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function od(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(`
@@ -82,7 +82,7 @@ img.ProseMirror-separator {
82
82
  display: block;
83
83
  }`;function Fy(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 Vy=class extends Ey{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:iy,createMappablePosition:oy},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:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=pf(e,this.options.autofocus);this.editorState=On.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=Fy(By,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=bf(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 i=typeof s=="string"?`${s}$`:s.key;t=t.filter(o=>!o.key.startsWith(i))}),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?[Lf,Of.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Rf,$f,zf,Ff,Pf,Bf,Df,Vf.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 hi(r,this)}createCommandManager(){this.commandManager=new ai({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=So(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=So(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,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new cf(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,transformPastedHTML:o,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),i=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 o=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o?.getMeta("focus"),a=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return Cf(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return ny(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Nl(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
84
84
 
85
- `,textSerializers:t={}}=n||{};return X0(this.state.doc,{blockSeparator:e,textSerializers:{...wf(this.schema),...t}})}get isEmpty(){return di(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 zy(e,this)}get $doc(){return this.$pos(0)}};function Hn(n){return new fi({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ue(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(Ml(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&&i.delete(u,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}},undoable:n.undoable})}function Hy(n){return new fi({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ue(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:n.undoable})}function wo(n){return new fi({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=ue(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,i)},undoable:n.undoable})}function Wn(n){return new fi({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=ue(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&ol(a,n.type,i);if(!c)return null;if(o.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));o.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Xt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}function Wy(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof W){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function bT(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Uy={};vl(Uy,{createAtomBlockMarkdownSpec:()=>qy,createBlockMarkdownSpec:()=>Ky,createInlineMarkdownSpec:()=>Xy,parseAttributes:()=>Al,parseIndentedBlocks:()=>Co,renderNestedMarkdownContent:()=>Il,serializeAttributes:()=>jl});function Al(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 i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).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 jl(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 qy(n){const{nodeName:e,name:t,parseAttributes:r=Al,serializeAttributes:s=jl,defaultAttributes:i={},requiredAttributes:o=[],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={...i,...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(!o.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 Ky(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Al,serializeAttributes:i=jl,defaultAttributes:o={},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={...o,...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 C="";const w=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(v);for(w.lastIndex=0;;){const N=w.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 O=T.slice(0,M);C=O.trim();const A=d.slice(0,v+M+N[0].length);let R=[];if(C)if(l==="block")for(R=h.blockTokens(O),R.forEach(I=>{I.text&&(!I.tokens||I.tokens.length===0)&&(I.tokens=h.inlineTokens(I.text))});R.length>0;){const I=R[R.length-1];if(I.type==="paragraph"&&(!I.text||I.text.trim()===""))R.pop();else break}else R=h.inlineTokens(C);return{type:e,raw:A,attributes:k,content:C,tokens:R}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=i(h),g=m?` {${m}}`:"",x=f.renderChildren(d.content||[],`
85
+ `,textSerializers:t={}}=n||{};return X0(this.state.doc,{blockSeparator:e,textSerializers:{...wf(this.schema),...t}})}get isEmpty(){return di(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 zy(e,this)}get $doc(){return this.$pos(0)}};function Hn(n){return new fi({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ue(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(Ml(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&&i.delete(u,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}},undoable:n.undoable})}function Hy(n){return new fi({find:n.find,handler:({state:e,range:t,match:r})=>{const s=ue(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:n.undoable})}function wo(n){return new fi({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=ue(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,i)},undoable:n.undoable})}function Wn(n){return new fi({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=ue(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&ol(a,n.type,i);if(!c)return null;if(o.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));o.ensureMarks(g)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Xt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}function Wy(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof W){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function kT(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Uy={};vl(Uy,{createAtomBlockMarkdownSpec:()=>qy,createBlockMarkdownSpec:()=>Ky,createInlineMarkdownSpec:()=>Xy,parseAttributes:()=>Al,parseIndentedBlocks:()=>Co,renderNestedMarkdownContent:()=>Il,serializeAttributes:()=>jl});function Al(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 i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).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 jl(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 qy(n){const{nodeName:e,name:t,parseAttributes:r=Al,serializeAttributes:s=jl,defaultAttributes:i={},requiredAttributes:o=[],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={...i,...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(!o.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 Ky(n){const{nodeName:e,name:t,getContent:r,parseAttributes:s=Al,serializeAttributes:i=jl,defaultAttributes:o={},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={...o,...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 C="";const w=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(v);for(w.lastIndex=0;;){const N=w.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 O=T.slice(0,M);C=O.trim();const A=d.slice(0,v+M+N[0].length);let R=[];if(C)if(l==="block")for(R=h.blockTokens(O),R.forEach(I=>{I.text&&(!I.tokens||I.tokens.length===0)&&(I.tokens=h.inlineTokens(I.text))});R.length>0;){const I=R[R.length-1];if(I.type==="paragraph"&&(!I.text||I.text.trim()===""))R.pop();else break}else R=h.inlineTokens(C);return{type:e,raw:A,attributes:k,content:C,tokens:R}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=i(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 Yy(n,e,t={}){const{state:r}=e,{doc:s,tr:i}=r,o=n;s.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==o)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});i.removeMark(c,u,n.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var Ue=class Hf extends El{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Hf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Qy=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,i,o,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=(o=n.offsetY)!=null?o:(i=n.nativeEvent)==null?void 0:i.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=W.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"),i=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!i&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=W.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||i||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"&&(Cr()||ko())&&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 Sn(n){return new Ry({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=ue(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=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(Ml(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&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Zy,getOwnPropertySymbols:eb}=Object,{hasOwnProperty:tb}=Object.prototype;function Fi(n,e){return function(r,s,i){return n(r,s,i)&&e(r,s,i)}}function Ur(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:i}=s,o=i.get(t),l=i.get(r);if(o&&l)return o===r&&l===t;i.set(t,r),i.set(r,t);const a=n(t,r,s);return i.delete(t),i.delete(r),a}}function nb(n){return n?.[Symbol.toStringTag]}function vc(n){return Zy(n).concat(eb(n))}const rb=Object.hasOwn||((n,e)=>tb.call(n,e));function Tn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const sb="__v",ib="__o",ob="_owner",{getOwnPropertyDescriptor:wc,keys:Cc}=Object;function lb(n,e){return n.byteLength===e.byteLength&&ys(new Uint8Array(n),new Uint8Array(e))}function ab(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 cb(n,e){return n.byteLength===e.byteLength&&ys(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function ub(n,e){return Tn(n.getTime(),e.getTime())}function db(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function fb(n,e){return n===e}function Tc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=n.entries();let o,l,a=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=o.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 hb=Tn;function pb(n,e,t){const r=Cc(n);let s=r.length;if(Cc(e).length!==s)return!1;for(;s-- >0;)if(!Wf(n,e,t,r[s]))return!1;return!0}function Qn(n,e,t){const r=vc(n);let s=r.length;if(vc(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!Wf(n,e,t,i)||(o=wc(n,i),l=wc(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function mb(n,e){return Tn(n.valueOf(),e.valueOf())}function gb(n,e){return n.source===e.source&&n.flags===e.flags}function Nc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=n.values();let o,l;for(;(o=i.next())&&!o.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(o.value,l.value,o.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ys(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 xb(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 Wf(n,e,t,r){return(r===ob||r===ib||r===sb)&&(n.$$typeof||e.$$typeof)?!0:rb(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const yb="[object ArrayBuffer]",bb="[object Arguments]",kb="[object Boolean]",Sb="[object DataView]",vb="[object Date]",wb="[object Error]",Cb="[object Map]",Tb="[object Number]",Nb="[object Object]",Mb="[object RegExp]",Eb="[object Set]",Ab="[object String]",jb={"[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},Ib="[object URL]",Ob=Object.prototype.toString;function Rb({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,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"?i(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 o(x,y,b);if(S===Set)return d(x,y,b);const v=Ob.call(x);if(v===vb)return r(x,y,b);if(v===Mb)return u(x,y,b);if(v===Cb)return o(x,y,b);if(v===Eb)return d(x,y,b);if(v===Nb)return typeof x.then!="function"&&typeof y.then!="function"&&a(x,y,b);if(v===Ib)return h(x,y,b);if(v===wb)return s(x,y,b);if(v===bb)return a(x,y,b);if(jb[v])return f(x,y,b);if(v===yb)return n(x,y,b);if(v===Sb)return t(x,y,b);if(v===kb||v===Tb||v===Ab)return c(x,y,b);if(m){let C=m[v];if(!C){const w=nb(x);w&&(C=m[w])}if(C)return C(x,y,b)}return!1}}function Db({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:lb,areArraysEqual:t?Qn:ab,areDataViewsEqual:cb,areDatesEqual:ub,areErrorsEqual:db,areFunctionsEqual:fb,areMapsEqual:t?Fi(Tc,Qn):Tc,areNumbersEqual:hb,areObjectsEqual:t?Qn:pb,arePrimitiveWrappersEqual:mb,areRegExpsEqual:gb,areSetsEqual:t?Fi(Nc,Qn):Nc,areTypedArraysEqual:t?Fi(ys,Qn):ys,areUrlsEqual:xb,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Ur(r.areArraysEqual),i=Ur(r.areMapsEqual),o=Ur(r.areObjectsEqual),l=Ur(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function Pb(n){return function(e,t,r,s,i,o,l){return n(e,t,l)}}function Lb({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 i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,i)}}const _b=Qt();Qt({strict:!0});Qt({circular:!0});Qt({circular:!0,strict:!0});Qt({createInternalComparator:()=>Tn});Qt({strict:!0,createInternalComparator:()=>Tn});Qt({circular:!0,createInternalComparator:()=>Tn});Qt({circular:!0,createInternalComparator:()=>Tn,strict:!0});function Qt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,i=Db(n),o=Rb(i),l=t?t(o):Pb(o);return Lb({circular:e,comparator:o,createState:r,equals:l,strict:s})}var $b=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},zb=({contentComponent:n})=>{const e=tu.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Bb(){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]:lp.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 Fb=class extends hn.Component{constructor(n){var e;super(n),this.editorContentRef=hn.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=Bb(),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:$b(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(zb,{contentComponent:n.contentComponent})]})}},Vb=E.forwardRef((n,e)=>{const t=hn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return hn.createElement(Fb,{key:t,innerRef:e,...n})}),Uf=hn.memo(Vb),Hb=typeof window<"u"?E.useLayoutEffect:E.useEffect,Wb=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 Ub(n){var e;const[t]=E.useState(()=>new Wb(n.editor)),r=ip.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:_b);return Hb(()=>t.watch(n.editor),[n.editor,t]),E.useDebugValue(r),r}var qb=!1,To=typeof window>"u",Kb=To||!!(typeof window<"u"&&window.next),Jb=class qf{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?To||Kb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new Vy(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,i)=>{var o;return s===((o=t.extensions)==null?void 0:o[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?qf.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 Gb(n={},e=[]){const t=E.useRef(n);t.current=n;const[r]=E.useState(()=>new Jb(t)),s=tu.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),Ub({editor:s,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&i===0?0:i+1}),s}var Ol=E.createContext({editor:null});Ol.Consumer;var kT=()=>E.useContext(Ol),Kf=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Xb=()=>E.useContext(Kf),Jf=hn.forwardRef((n,e)=>{const{onDragStart:t}=Xb(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Mc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function Ec(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Yb(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Qb(n){if(Mc(n)||Ec(n))return!0;if(Yb(n)){const e=n.type;if(e)return Mc(e)||Ec(e)}return!1}function Zb(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var ek=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?op.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=Zb(),i=Qb(e),o={...t};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...o}),(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])})}};hn.createContext({markViewContentRef:()=>{}});var tk=class extends Qy{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 i;return r==="storage"?(i=n.storage[e.name])!=null?i:{}: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,i=E.memo(a=>p.jsx(Kf.Provider,{value:r,children:E.createElement(s,a)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new ek(i,{editor:this.editor,props:n,as:o,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,i=this.decorations,o=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:i,newNode:n,newDecorations:e,oldInnerDecorations:o,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=Vn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Gf(n,e){return t=>t.editor.contentComponent?new tk(n,t,e):{}}var Rl=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Rl.displayName="TiptapContext";var nk=()=>E.useContext(Rl);function Xf({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]),i=E.useMemo(()=>({editor:r}),[r]);return p.jsx(Ol.Provider,{value:i,children:p.jsx(Rl.Provider,{value:s,children:t})})}Xf.displayName="Tiptap";function Yf({...n}){const{editor:e}=nk();return p.jsx(Uf,{editor:e,...n})}Yf.displayName="Tiptap.Content";Object.assign(Xf,{Content:Yf});function rk(n){return n.storage.mention}function ST(n,e,t){n.chain().focus().insertContentAt(e,[Qf(t),{type:"text",text:" "}]).run()}function Qf(n){return{type:"mention",attrs:n}}function sk(n){const e=L.c(19),{node:t,selected:r,view:s,editor:i,getPos:o}=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]!==i||e[2]!==o||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const M=rk(i)?.onEditChip;if(!M||typeof o!="function")return;const j=o();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),M({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=i,e[2]=o,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=Z("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 C;e[12]!==l?(C=l?Pu(l):"",e[12]=l,e[13]=C):C=e[13];let w;return e[14]!==a||e[15]!==x||e[16]!==v||e[17]!==C?(w=p.jsxs(Jf,{onClick:x,className:v,children:[a,C]}),e[14]=a,e[15]=x,e[16]=v,e[17]=C,e[18]=w):w=e[18],w}const ik=Ue.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 Gf(sk)}}),ok=/^mcp__[a-zA-Z0-9_-]+__/;function Zf(n){return n.replace(ok,"")}function pi(n){const e=L.c(18),{id:t,part:r,copyable:s,extraActions:i,alwaysShowActions:o,animate:l}=n,a=s===void 0?!1:s,c=o===void 0?!1:o,u=l===void 0?!1:l,{handleCopy:d}=Cu(),[f,h]=E.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{ap("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&&i,y=x||i;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Zo,{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]!==i||e[10]!==g||e[11]!==f||e[12]!==y||e[13]!==x?(k=y&&p.jsxs("div",{className:Z("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:[i,x&&i&&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(Yo,{className:"size-4"}):p.jsx(wu,{className:"size-4"})})]}),e[8]=c,e[9]=i,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 vT(n,e,t){n.chain().focus().insertContentAt(e,[lk(t),{type:"text",text:" "}]).run()}function lk(n){return{type:"file",attrs:n}}function ak(n){const e=L.c(17),{node:t,selected:r,view:s}=n,{name:i,mimeType:o,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==o?(c=o.startsWith("image/"),e[0]=o,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=Z("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]!==i?(h=p.jsx(pn,{asChild:!0,children:p.jsx("span",{children:i})}),e[4]=i,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==o||e[9]!==i?(m=p.jsx(mn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${o};base64,${l}`,alt:i,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:i}),p.jsx("div",{className:"text-muted-foreground mt-1",children:o})]})}),e[6]=l,e[7]=u,e[8]=o,e[9]=i,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(gn,{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(Jf,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=x):x=e[16],x}const ck=Ue.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 Gf(ak)}});function uk(n={}){return new me({view(e){return new dk(e,n)}})}class dk{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 i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}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,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.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*o;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)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"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,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ad(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class xe extends Q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return xe.valid(r)?new xe(r):Q.near(r)}content(){return F.empty}eq(e){return e instanceof xe&&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 xe(e.resolve(t.pos))}getBookmark(){return new Dl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!fk(e)||!hk(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&&xe.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(xe.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!W.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(xe.valid(l))return l}return null}}}xe.prototype.visible=!1;xe.findFrom=xe.findGapCursorFrom;Q.jsonID("gapcursor",xe);class Dl{constructor(e){this.pos=e}map(e){return new Dl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return xe.valid(t)?new xe(t):Q.near(t)}}function eh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function fk(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||eh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function hk(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||eh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function pk(){return new me({props:{decorations:yk,createSelectionBetween(n,e,t){return e.pos==t.pos&&xe.valid(t)?new xe(t):null},handleClick:gk,handleKeyDown:mk,handleDOMEvents:{beforeinput:xk}}})}const mk=uf({ArrowLeft:qr("horiz",-1),ArrowRight:qr("horiz",1),ArrowUp:qr("vert",-1),ArrowDown:qr("vert",1)});function qr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof G){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=xe.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new xe(c))),!0):!1}}function gk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!xe.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&W.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new xe(r))),!0)}function xk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof xe))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=D.empty;for(let o=r.length-1;o>=0;o--)s=D.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new F(s,0,0));return i.setSelection(G.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function yk(n){if(!(n.selection instanceof xe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pe.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}var bs=200,je=function(){};je.prototype.append=function(e){return e.length?(e=je.from(e),!this.length&&e||e.length<bs&&this.leafAppend(e)||this.length<bs&&e.leafPrepend(this)||this.appendInner(e)):this};je.prototype.prepend=function(e){return e.length?je.from(e).append(this):this};je.prototype.appendInner=function(e){return new bk(this,e)};je.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?je.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};je.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};je.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)};je.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};je.from=function(e){return e instanceof je?e:e&&e.length?new th(e):je.empty};var th=(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,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=bs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=bs)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})(je);je.empty=new th([]);var bk=(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,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},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})(je);const kk=500;class ot{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,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new ut(d.map));let h=d.step.map(s.slice(i)),m;h&&o.maybeStep(h).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],c.push(new ut(m,void 0,void 0,c.length+u.length))),i--,m&&s.appendMap(m,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new ot(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=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 ut(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(o++,t=void 0),s||(a=f)}let c=o-r.depth;return c>vk&&(l=Sk(l,c),o-=c),new ot(l.append(i),o)}remapping(e,t){let r=new br;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new ot(this.items.append(e.map(t=>new ut(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let m=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),x=f.selection&&f.selection.map(i.slice(a+1,h));x&&l++,r.push(new ut(m,g,x))}else r.push(new ut(m))},s);let c=[];for(let f=t;f<o;f++)c.push(new ut(i.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new ot(u,l);return d.emptyItemCount()>kk&&(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=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let d=new ut(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else o.map&&r--},this.items.length,0),new ot(je.from(s.reverse()),i)}}ot.empty=new ot(je.empty,0);function Sk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class ut{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 ut(t.getMap().invert(),t,this.selection)}}}class Rt{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const vk=20;function wk(n,e,t,r){let s=t.getMeta(fn),i;if(s)return s.historyState;t.getMeta(Nk)&&(n=new Rt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(fn))return o.getMeta(fn).redo?new Rt(n.done.addTransform(t,void 0,r,ts(e)),n.undone,Ac(t.mapping.maps),n.prevTime,n.prevComposition):new Rt(n.done,n.undone.addTransform(t,void 0,r,ts(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Ck(t,n.prevRanges)),c=o?Vi(n.prevRanges,t.mapping):Ac(t.mapping.maps);return new Rt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,ts(e)),ot.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Rt(n.done.rebased(t,i),n.undone.rebased(t,i),Vi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Rt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Vi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Ck(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Ac(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function Vi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function Tk(n,e,t){let r=ts(e),s=fn.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Rt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(fn,{redo:t,historyState:a})}let Hi=!1,jc=null;function ts(n){let e=n.plugins;if(jc!=e){Hi=!1,jc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Hi=!0;break}}return Hi}const fn=new Me("history"),Nk=new Me("closeHistory");function Mk(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new me({key:fn,state:{init(){return new Rt(ot.empty,ot.empty,null,0,-1)},apply(e,t,r){return wk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?rh:r=="historyRedo"?sh:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function nh(n,e){return(t,r)=>{let s=fn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=Tk(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const rh=nh(!1,!0),sh=nh(!0,!0);ke.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 me({key:new Me("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;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}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Ek=ke.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[uk(this.options)]}});ke.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new me({key:new Me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!t||!r)return pe.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=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"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Ve.node(c,c+a.nodeSize,{class:this.options.className}))}),pe.create(n,i)}}})]}});var Ak=ke.create({name:"gapCursor",addProseMirrorPlugins(){return[pk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ue(H(n,"allowGapCursor",t)))!=null?e:null}}}),Ic="placeholder";function jk(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var wT=ke.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ic,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${jk(this.options.dataAttribute)}`:`data-${Ic}`;return[new me({key:new Me("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&di(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const f=Ve.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});i.push(f)}return this.options.includeChildren}),pe.create(e,i)}}})]}});ke.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new me({key:new Me("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Nf(t.selection)||n.view.dragging?null:pe.create(t.doc,[Ve.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Oc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Ik=ke.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new Me(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 me({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Oc({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Oc({node:o,types:r})}}})]}}),Ok=ke.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>rh(n,e),redo:()=>({state:n,dispatch:e})=>sh(n,e)}},addProseMirrorPlugins(){return[Mk(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()}}}),ks=(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]},Rk=/^\s*>\s$/,Dk=Ue.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return ks("blockquote",{...Ne(this.options.HTMLAttributes,n),children:ks("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,i)=>{var o,l;const u=((l=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?l:e.renderChildren([s])).split(`
102
+ ${m}`}}),a}function Yy(n,e,t={}){const{state:r}=e,{doc:s,tr:i}=r,o=n;s.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==o)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});i.removeMark(c,u,n.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var Ue=class Hf extends El{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Hf(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Qy=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,i,o,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=(o=n.offsetY)!=null?o:(i=n.nativeEvent)==null?void 0:i.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=W.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"),i=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!i&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=W.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||i||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"&&(Cr()||ko())&&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 Sn(n){return new Ry({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=ue(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=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(Ml(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&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:Zy,getOwnPropertySymbols:eb}=Object,{hasOwnProperty:tb}=Object.prototype;function Fi(n,e){return function(r,s,i){return n(r,s,i)&&e(r,s,i)}}function Ur(n){return function(t,r,s){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,s);const{cache:i}=s,o=i.get(t),l=i.get(r);if(o&&l)return o===r&&l===t;i.set(t,r),i.set(r,t);const a=n(t,r,s);return i.delete(t),i.delete(r),a}}function nb(n){return n?.[Symbol.toStringTag]}function vc(n){return Zy(n).concat(eb(n))}const rb=Object.hasOwn||((n,e)=>tb.call(n,e));function Tn(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const sb="__v",ib="__o",ob="_owner",{getOwnPropertyDescriptor:wc,keys:Cc}=Object;function lb(n,e){return n.byteLength===e.byteLength&&ys(new Uint8Array(n),new Uint8Array(e))}function ab(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 cb(n,e){return n.byteLength===e.byteLength&&ys(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function ub(n,e){return Tn(n.getTime(),e.getTime())}function db(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function fb(n,e){return n===e}function Tc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=n.entries();let o,l,a=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=o.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 hb=Tn;function pb(n,e,t){const r=Cc(n);let s=r.length;if(Cc(e).length!==s)return!1;for(;s-- >0;)if(!Wf(n,e,t,r[s]))return!1;return!0}function Qn(n,e,t){const r=vc(n);let s=r.length;if(vc(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!Wf(n,e,t,i)||(o=wc(n,i),l=wc(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function mb(n,e){return Tn(n.valueOf(),e.valueOf())}function gb(n,e){return n.source===e.source&&n.flags===e.flags}function Nc(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=n.values();let o,l;for(;(o=i.next())&&!o.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&t.equals(o.value,l.value,o.value,l.value,n,e,t)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ys(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 xb(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 Wf(n,e,t,r){return(r===ob||r===ib||r===sb)&&(n.$$typeof||e.$$typeof)?!0:rb(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const yb="[object ArrayBuffer]",bb="[object Arguments]",kb="[object Boolean]",Sb="[object DataView]",vb="[object Date]",wb="[object Error]",Cb="[object Map]",Tb="[object Number]",Nb="[object Object]",Mb="[object RegExp]",Eb="[object Set]",Ab="[object String]",jb={"[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},Ib="[object URL]",Ob=Object.prototype.toString;function Rb({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,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"?i(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 o(x,y,b);if(S===Set)return d(x,y,b);const v=Ob.call(x);if(v===vb)return r(x,y,b);if(v===Mb)return u(x,y,b);if(v===Cb)return o(x,y,b);if(v===Eb)return d(x,y,b);if(v===Nb)return typeof x.then!="function"&&typeof y.then!="function"&&a(x,y,b);if(v===Ib)return h(x,y,b);if(v===wb)return s(x,y,b);if(v===bb)return a(x,y,b);if(jb[v])return f(x,y,b);if(v===yb)return n(x,y,b);if(v===Sb)return t(x,y,b);if(v===kb||v===Tb||v===Ab)return c(x,y,b);if(m){let C=m[v];if(!C){const w=nb(x);w&&(C=m[w])}if(C)return C(x,y,b)}return!1}}function Db({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:lb,areArraysEqual:t?Qn:ab,areDataViewsEqual:cb,areDatesEqual:ub,areErrorsEqual:db,areFunctionsEqual:fb,areMapsEqual:t?Fi(Tc,Qn):Tc,areNumbersEqual:hb,areObjectsEqual:t?Qn:pb,arePrimitiveWrappersEqual:mb,areRegExpsEqual:gb,areSetsEqual:t?Fi(Nc,Qn):Nc,areTypedArraysEqual:t?Fi(ys,Qn):ys,areUrlsEqual:xb,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const s=Ur(r.areArraysEqual),i=Ur(r.areMapsEqual),o=Ur(r.areObjectsEqual),l=Ur(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function Pb(n){return function(e,t,r,s,i,o,l){return n(e,t,l)}}function Lb({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 i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,i)}}const _b=Qt();Qt({strict:!0});Qt({circular:!0});Qt({circular:!0,strict:!0});Qt({createInternalComparator:()=>Tn});Qt({strict:!0,createInternalComparator:()=>Tn});Qt({circular:!0,createInternalComparator:()=>Tn});Qt({circular:!0,createInternalComparator:()=>Tn,strict:!0});function Qt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:s=!1}=n,i=Db(n),o=Rb(i),l=t?t(o):Pb(o);return Lb({circular:e,comparator:o,createState:r,equals:l,strict:s})}var $b=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},zb=({contentComponent:n})=>{const e=tu.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Bb(){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]:lp.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 Fb=class extends hn.Component{constructor(n){var e;super(n),this.editorContentRef=hn.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=Bb(),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:$b(e,this.editorContentRef),...t}),n?.contentComponent&&p.jsx(zb,{contentComponent:n.contentComponent})]})}},Vb=E.forwardRef((n,e)=>{const t=hn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return hn.createElement(Fb,{key:t,innerRef:e,...n})}),Uf=hn.memo(Vb),Hb=typeof window<"u"?E.useLayoutEffect:E.useEffect,Wb=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 Ub(n){var e;const[t]=E.useState(()=>new Wb(n.editor)),r=ip.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:_b);return Hb(()=>t.watch(n.editor),[n.editor,t]),E.useDebugValue(r),r}var qb=!1,To=typeof window>"u",Kb=To||!!(typeof window<"u"&&window.next),Jb=class qf{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?To||Kb?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new Vy(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,i)=>{var o;return s===((o=t.extensions)==null?void 0:o[i])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?qf.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 Gb(n={},e=[]){const t=E.useRef(n);t.current=n;const[r]=E.useState(()=>new Jb(t)),s=tu.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),Ub({editor:s,selector:({transactionNumber:i})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&i===0?0:i+1}),s}var Ol=E.createContext({editor:null});Ol.Consumer;var ST=()=>E.useContext(Ol),Kf=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Xb=()=>E.useContext(Kf),Jf=hn.forwardRef((n,e)=>{const{onDragStart:t}=Xb(),r=n.as||"div";return p.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function Mc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function Ec(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Yb(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Qb(n){if(Mc(n)||Ec(n))return!0;if(Yb(n)){const e=n.type;if(e)return Mc(e)||Ec(e)}return!1}function Zb(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var ek=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?op.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=Zb(),i=Qb(e),o={...t};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...o}),(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])})}};hn.createContext({markViewContentRef:()=>{}});var tk=class extends Qy{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 i;return r==="storage"?(i=n.storage[e.name])!=null?i:{}: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,i=E.memo(a=>p.jsx(Kf.Provider,{value:r,children:E.createElement(s,a)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new ek(i,{editor:this.editor,props:n,as:o,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,i=this.decorations,o=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:s,oldDecorations:i,newNode:n,newDecorations:e,oldInnerDecorations:o,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=Vn(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Gf(n,e){return t=>t.editor.contentComponent?new tk(n,t,e):{}}var Rl=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Rl.displayName="TiptapContext";var nk=()=>E.useContext(Rl);function Xf({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]),i=E.useMemo(()=>({editor:r}),[r]);return p.jsx(Ol.Provider,{value:i,children:p.jsx(Rl.Provider,{value:s,children:t})})}Xf.displayName="Tiptap";function Yf({...n}){const{editor:e}=nk();return p.jsx(Uf,{editor:e,...n})}Yf.displayName="Tiptap.Content";Object.assign(Xf,{Content:Yf});function rk(n){return n.storage.mention}function vT(n,e,t){n.chain().focus().insertContentAt(e,[Qf(t),{type:"text",text:" "}]).run()}function Qf(n){return{type:"mention",attrs:n}}function sk(n){const e=L.c(19),{node:t,selected:r,view:s,editor:i,getPos:o}=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]!==i||e[2]!==o||e[3]!==u||e[4]!==m||e[5]!==l?(g=T=>{if(!m)return;const M=rk(i)?.onEditChip;if(!M||typeof o!="function")return;const j=o();typeof j=="number"&&(T.preventDefault(),T.stopPropagation(),M({promptId:u,promptName:l,args:d??{},pos:j}))},e[0]=d,e[1]=i,e[2]=o,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=Z("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 C;e[12]!==l?(C=l?Pu(l):"",e[12]=l,e[13]=C):C=e[13];let w;return e[14]!==a||e[15]!==x||e[16]!==v||e[17]!==C?(w=p.jsxs(Jf,{onClick:x,className:v,children:[a,C]}),e[14]=a,e[15]=x,e[16]=v,e[17]=C,e[18]=w):w=e[18],w}const ik=Ue.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 Gf(sk)}}),ok=/^mcp__[a-zA-Z0-9_-]+__/;function Zf(n){return n.replace(ok,"")}function pi(n){const e=L.c(18),{id:t,part:r,copyable:s,extraActions:i,alwaysShowActions:o,animate:l}=n,a=s===void 0?!1:s,c=o===void 0?!1:o,u=l===void 0?!1:l,{handleCopy:d}=Cu(),[f,h]=E.useState(!1);let m;e[0]!==d||e[1]!==t||e[2]!==r.text?(m=async()=>{ap("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&&i,y=x||i;let b;e[4]!==u||e[5]!==t||e[6]!==r.text?(b=p.jsx(Zo,{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]!==i||e[10]!==g||e[11]!==f||e[12]!==y||e[13]!==x?(k=y&&p.jsxs("div",{className:Z("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:[i,x&&i&&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(Yo,{className:"size-4"}):p.jsx(wu,{className:"size-4"})})]}),e[8]=c,e[9]=i,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 wT(n,e,t){n.chain().focus().insertContentAt(e,[lk(t),{type:"text",text:" "}]).run()}function lk(n){return{type:"file",attrs:n}}function ak(n){const e=L.c(17),{node:t,selected:r,view:s}=n,{name:i,mimeType:o,data:l}=t.attrs,a=r&&s.editable;let c;e[0]!==o?(c=o.startsWith("image/"),e[0]=o,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=Z("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]!==i?(h=p.jsx(pn,{asChild:!0,children:p.jsx("span",{children:i})}),e[4]=i,e[5]=h):h=e[5];let m;e[6]!==l||e[7]!==u||e[8]!==o||e[9]!==i?(m=p.jsx(mn,{side:"top",className:"max-w-sm p-1.5",children:u?p.jsx("img",{src:`data:${o};base64,${l}`,alt:i,className:"max-w-full max-h-64 object-contain rounded"}):p.jsxs("div",{className:"text-xs",children:[p.jsx("div",{className:"font-medium",children:i}),p.jsx("div",{className:"text-muted-foreground mt-1",children:o})]})}),e[6]=l,e[7]=u,e[8]=o,e[9]=i,e[10]=m):m=e[10];let g;e[11]!==h||e[12]!==m?(g=p.jsxs(gn,{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(Jf,{className:f,children:g}),e[14]=f,e[15]=g,e[16]=x):x=e[16],x}const ck=Ue.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 Gf(ak)}});function uk(n={}){return new me({view(e){return new dk(e,n)}})}class dk{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 i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}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,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.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*o;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)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"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,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ad(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class xe extends Q{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return xe.valid(r)?new xe(r):Q.near(r)}content(){return F.empty}eq(e){return e instanceof xe&&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 xe(e.resolve(t.pos))}getBookmark(){return new Dl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!fk(e)||!hk(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&&xe.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(xe.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!W.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(xe.valid(l))return l}return null}}}xe.prototype.visible=!1;xe.findFrom=xe.findGapCursorFrom;Q.jsonID("gapcursor",xe);class Dl{constructor(e){this.pos=e}map(e){return new Dl(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return xe.valid(t)?new xe(t):Q.near(t)}}function eh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function fk(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||eh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function hk(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||eh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function pk(){return new me({props:{decorations:yk,createSelectionBetween(n,e,t){return e.pos==t.pos&&xe.valid(t)?new xe(t):null},handleClick:gk,handleKeyDown:mk,handleDOMEvents:{beforeinput:xk}}})}const mk=uf({ArrowLeft:qr("horiz",-1),ArrowRight:qr("horiz",1),ArrowUp:qr("vert",-1),ArrowDown:qr("vert",1)});function qr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof G){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=xe.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new xe(c))),!0):!1}}function gk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!xe.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&W.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new xe(r))),!0)}function xk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof xe))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=D.empty;for(let o=r.length-1;o>=0;o--)s=D.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new F(s,0,0));return i.setSelection(G.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function yk(n){if(!(n.selection instanceof xe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pe.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}var bs=200,je=function(){};je.prototype.append=function(e){return e.length?(e=je.from(e),!this.length&&e||e.length<bs&&this.leafAppend(e)||this.length<bs&&e.leafPrepend(this)||this.appendInner(e)):this};je.prototype.prepend=function(e){return e.length?je.from(e).append(this):this};je.prototype.appendInner=function(e){return new bk(this,e)};je.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?je.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};je.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};je.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)};je.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s};je.from=function(e){return e instanceof je?e:e&&e.length?new th(e):je.empty};var th=(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,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=bs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=bs)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})(je);je.empty=new th([]);var bk=(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,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},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})(je);const kk=500;class ot{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,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new ut(d.map));let h=d.step.map(s.slice(i)),m;h&&o.maybeStep(h).doc&&(m=o.mapping.maps[o.mapping.maps.length-1],c.push(new ut(m,void 0,void 0,c.length+u.length))),i--,m&&s.appendMap(m,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new ot(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=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 ut(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(o++,t=void 0),s||(a=f)}let c=o-r.depth;return c>vk&&(l=Sk(l,c),o-=c),new ot(l.append(i),o)}remapping(e,t){let r=new br;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new ot(this.items.append(e.map(t=>new ut(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let m=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),x=f.selection&&f.selection.map(i.slice(a+1,h));x&&l++,r.push(new ut(m,g,x))}else r.push(new ut(m))},s);let c=[];for(let f=t;f<o;f++)c.push(new ut(i.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new ot(u,l);return d.emptyItemCount()>kk&&(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=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.slice(r));u&&i++;let d=new ut(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else o.map&&r--},this.items.length,0),new ot(je.from(s.reverse()),i)}}ot.empty=new ot(je.empty,0);function Sk(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class ut{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 ut(t.getMap().invert(),t,this.selection)}}}class Rt{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const vk=20;function wk(n,e,t,r){let s=t.getMeta(fn),i;if(s)return s.historyState;t.getMeta(Nk)&&(n=new Rt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(fn))return o.getMeta(fn).redo?new Rt(n.done.addTransform(t,void 0,r,ts(e)),n.undone,Ac(t.mapping.maps),n.prevTime,n.prevComposition):new Rt(n.done,n.undone.addTransform(t,void 0,r,ts(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Ck(t,n.prevRanges)),c=o?Vi(n.prevRanges,t.mapping):Ac(t.mapping.maps);return new Rt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,ts(e)),ot.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Rt(n.done.rebased(t,i),n.undone.rebased(t,i),Vi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Rt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Vi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Ck(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Ac(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function Vi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function Tk(n,e,t){let r=ts(e),s=fn.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Rt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(fn,{redo:t,historyState:a})}let Hi=!1,jc=null;function ts(n){let e=n.plugins;if(jc!=e){Hi=!1,jc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Hi=!0;break}}return Hi}const fn=new Me("history"),Nk=new Me("closeHistory");function Mk(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new me({key:fn,state:{init(){return new Rt(ot.empty,ot.empty,null,0,-1)},apply(e,t,r){return wk(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?rh:r=="historyRedo"?sh:null;return!s||!e.editable?!1:(t.preventDefault(),s(e.state,e.dispatch))}}}})}function nh(n,e){return(t,r)=>{let s=fn.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=Tk(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const rh=nh(!1,!0),sh=nh(!0,!0);ke.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 me({key:new Me("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;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}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Ek=ke.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[uk(this.options)]}});ke.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new me({key:new Me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!t||!r)return pe.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=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"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Ve.node(c,c+a.nodeSize,{class:this.options.className}))}),pe.create(n,i)}}})]}});var Ak=ke.create({name:"gapCursor",addProseMirrorPlugins(){return[pk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ue(H(n,"allowGapCursor",t)))!=null?e:null}}}),Ic="placeholder";function jk(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var CT=ke.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ic,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${jk(this.options.dataAttribute)}`:`data-${Ic}`;return[new me({key:new Me("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=t,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,a)=>{const c=s>=a&&s<=a+l.nodeSize,u=!l.isLeaf&&di(l);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const f=Ve.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});i.push(f)}return this.options.includeChildren}),pe.create(e,i)}}})]}});ke.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new me({key:new Me("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||Nf(t.selection)||n.view.dragging?null:pe.create(t.doc,[Ve.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function Oc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var Ik=ke.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new Me(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 me({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,f=c.nodes[t];if(u)return a.insert(d,f.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Oc({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Oc({node:o,types:r})}}})]}}),Ok=ke.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>rh(n,e),redo:()=>({state:n,dispatch:e})=>sh(n,e)}},addProseMirrorPlugins(){return[Mk(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()}}}),ks=(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]},Rk=/^\s*>\s$/,Dk=Ue.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return ks("blockquote",{...Ne(this.options.HTMLAttributes,n),children:ks("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,i)=>{var o,l;const u=((l=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=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
  `),[i,o]=O2(s);if(i.length===0)return;const l=vh(i,0,t);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).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(D2,this.editor.getAttributes(Hc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Wn({find:Wc,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=Wn({find:Wc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Hc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),P2=/^\s*(\[([( |x])?\])\s$/,L2=Ue.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",Ne(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 Il(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"),i=document.createElement("label"),o=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),i.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,i.append(l,o),s.append(i,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=Vn(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[Wn({find:P2,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),_2=Ue.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",Ne(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=i=>{const o=Co(i,{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 o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(i)},s=Co(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:t.inlineTokens(i.mainContent),nestedTokens:o}),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()}}});ke.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(ph.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(mh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Sh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(wh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(L2.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(_2.configure(this.options.taskList)),n}});var Uc="&nbsp;",$2=" ",z2=Ue.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Ne(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===Uc||r[0].text===$2)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const i=Array.isArray(n.content)?n.content:[];if(i.length===0){const o=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Uc:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),B2=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,F2=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,V2=Cn.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",Ne(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[Hn({find:B2,type:this.type})]},addPasteRules(){return[Sn({find:F2,type:this.type})]}}),H2=Ue.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),W2=Cn.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",Ne(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 i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:t.inlineTokens(i)}}},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()}}}),U2=ke.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(zk.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Dk.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(ph.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Vk.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Uk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(qk.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Ek.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Ak.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Kk.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Jk.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Ok.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(Gk.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(e2.configure(this.options.italic)),this.options.listItem!==!1&&s.push(mh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Sh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(T2.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(wh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(z2.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(V2.configure(this.options.strike)),this.options.text!==!1&&s.push(H2.configure(this.options.text)),this.options.underline!==!1&&s.push(W2.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(Ik.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),q2=U2;const en=16,Lo=2.5,_o=(en-Lo)/2,Yi=2*Math.PI*_o;function Ch(n){const e=L.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:i,cost:o}=t;if(!r&&!s&&!i)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(_p,{size:12}),e[0]=l):l=e[0];let a;e[1]!==o||e[2]!==r?(a=o>0?`$${o.toFixed(4)}`:r.toLocaleString(),e[1]=o,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(pn,{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=i-(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]!==o?(k=o>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",o.toFixed(4)]})]}),e[21]=o,e[22]=k):k=e[22];let S;e[23]!==y||e[24]!==b||e[25]!==k||e[26]!==h?(S=p.jsxs(mn,{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(gn,{children:[c,S]}),e[28]=S,e[29]=c,e[30]=v):v=e[30],v}function K2(n){const e=L.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,i=t!=null&&(t.cost??0)>0,o=t!=null&&(t.totalTokens??0)>0;if(!s&&!i&&!o)return null;let l;e[0]!==r||e[1]!==s?(l=s?Ut(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(gn,{children:[p.jsx(pn,{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(mn,{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:Ut(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]!==i||e[8]!==s||e[9]!==o?(u=s&&(i||o)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=i,e[8]=s,e[9]=o,e[10]=u):u=e[10];let d;e[11]!==i||e[12]!==o||e[13]!==t?(d=(i||o)&&p.jsxs(gn,{children:[p.jsx(pn,{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:i?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(mn,{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]=i,e[12]=o,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 CT(n){const e=L.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:i}=n,o=Math.min(r/s*100,100),l=Yi-o/100*Yi,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==o?(d=o.toFixed(0),e[0]=o,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=i?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=Z("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:en/2,cy:en/2,r:_o,fill:"none",stroke:"currentColor",strokeWidth:Lo,className:"opacity-15"}),e[6]=x):x=e[6];const y=o>90?"text-destructive":o>70?"text-warning":"text-muted-foreground";let b;e[7]!==y?(b=Z(y),e[7]=y,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:en,height:en,className:"-rotate-90",children:[x,p.jsx("circle",{cx:en/2,cy:en/2,r:_o,fill:"none",stroke:"currentColor",strokeWidth:Lo,strokeDasharray:Yi,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let S;e[12]!==o?(S=o.toFixed(0),e[12]=o,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 C;e[16]!==S||e[17]!==v?(C=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]=C):C=e[18];let w;e[19]!==i||e[20]!==C||e[21]!==h||e[22]!==g||e[23]!==k?(w=p.jsx(pn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:i,"aria-label":h,className:g,children:[k,C]})}),e[19]=i,e[20]=C,e[21]=h,e[22]=g,e[23]=k,e[24]=w):w=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]!==o?(j=o.toFixed(1),e[30]=o,e[31]=j):j=e[31];let O;e[32]!==N||e[33]!==M||e[34]!==j?(O=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",M," (",j,"%)"]}),e[32]=N,e[33]=M,e[34]=j,e[35]=O):O=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 R;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(R=((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]=R):R=e[43];let I;e[44]!==O||e[45]!==A||e[46]!==R?(I=p.jsx(mn,{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,O,A,R]})}),e[44]=O,e[45]=A,e[46]=R,e[47]=I):I=e[47];let _;return e[48]!==w||e[49]!==I?(_=p.jsxs(gn,{children:[w,I]}),e[48]=w,e[49]=I,e[50]=_):_=e[50],_}var gi="Collapsible",[J2,TT]=ru(gi),[G2,Ul]=J2(gi),Th=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:i,onOpenChange:o,...l}=n,[a,c]=cp({prop:r,defaultProp:s??!1,onChange:o,caller:gi});return p.jsx(G2,{scope:t,disabled:i,contentId:up(),open:a,onOpenToggle:E.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Jt.div,{"data-state":Gl(a),"data-disabled":i?"":void 0,...l,ref:e})})});Th.displayName=gi;var Nh="CollapsibleTrigger",ql=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=Ul(Nh,t);return p.jsx(Jt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Gl(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Bt(n.onClick,s.onOpenToggle)})});ql.displayName=Nh;var Kl="CollapsibleContent",Jl=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Ul(Kl,n.__scopeCollapsible);return p.jsx(Ar,{present:t||s.open,children:({present:i})=>p.jsx(X2,{...r,ref:e,present:i})})});Jl.displayName=Kl;var X2=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...i}=n,o=Ul(Kl,t),[l,a]=E.useState(r),c=E.useRef(null),u=vn(e,c),d=E.useRef(0),f=d.current,h=E.useRef(0),m=h.current,g=o.open||l,x=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),nu(()=>{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)}},[o.open,r]),p.jsx(Jt.div,{"data-state":Gl(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...i,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 Gl(n){return n?"open":"closed"}var Y2=Th,NT=ql,MT=Jl;function Q2(n){const e=L.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(Y2,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function Z2(n){const e=L.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(ql,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function eS(n){const e=L.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(Jl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function ee({icon:n,title:e,usage:t,latency:r,summary:s,state:i,detail:o,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}=Cu(),k=i==="loading",S=i==="error",C=!!(o&&o.trim())||!!m,w=c==="subtask",T=(a??!1)||g,N=Bm({initial:k?"instant":!1}),M=p.jsxs(Q2,{open:T,onOpenChange:a?void 0:x,className:"min-w-0",children:[p.jsxs(Z2,{disabled:!C,className:Z("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",C&&"[@media(hover:hover)]:hover:bg-accent/30",!C&&"cursor-default",k&&"shimmer"),"aria-disabled":!C,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(ua,{className:Z("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:Z("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",C&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),C&&p.jsx("div",{className:Z("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(ua,{className:Z("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:Z("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(Ch,{usage:t})]}),C&&p.jsx(eS,{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:o})})}):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:o})}),p.jsx("button",{type:"button",onClick:()=>y(o),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(Yo,{className:"size-3.5"}):p.jsx(wu,{className:"size-3.5"})})]})})}))})]});return w?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:M}):M}function $e(n){const e=L.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Ut(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 Mh=4;function Eh(n){const e=L.c(5),{count:t,noun:r,onClick:s}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(vu,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=i):i=e[0];let o;return e[1]!==t||e[2]!==r||e[3]!==s?(o=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,i]}),e[1]=t,e[2]=r,e[3]=s,e[4]=o):o=e[4],o}function Ah(n){const e=L.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let i,o,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Qo(s);if(u===null){a=null;break e}const d=new Date(u);i=d.toLocaleString(),e[6]!==r?(o=Z("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=o):o=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=l,e[5]=a}else i=e[2],o=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==i||e[9]!==o||e[10]!==l?(c=p.jsx("span",{title:i,className:o,children:l}),e[8]=i,e[9]=o,e[10]=l,e[11]=c):c=e[11],c}function tS(n){const e=L.c(24),{org:t}=Mt(),r=dp(),s=sm(),i=pu();let o;e[0]!==i||e[1]!==n?(o=async g=>{if(!n)throw new Error("useTaskExpandedTools: no task in context");const y=(await i.call("COLLECTION_THREADS_GET",{id:n})).item?.metadata??{},k=(y.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const S={...y,expanded_tools:k};return await i.call("COLLECTION_THREADS_UPDATE",{id:n,data:{metadata:S}}),k},e[0]=i,e[1]=n,e[2]=o):o=e[2];let l,a,c;e[3]!==t||e[4]!==r||e[5]!==n?(l=async g=>{const x=nt.ensureTask(t.id,n??"");await r.cancelQueries({queryKey:x});const y=r.getQueryData(x),k=(y?.metadata?.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);return k.push({...g,expandedAt:new Date().toISOString()}),r.setQueryData(x,S=>S&&{...S,metadata:{...S.metadata??{},expanded_tools:k}}),{previous:y}},a=()=>{r.invalidateQueries({queryKey:nt.ensureTask(t.id,n??"")})},c=(g,x,y)=>{const b=nt.ensureTask(t.id,n??"");y?.previous===void 0?r.removeQueries({queryKey:b,exact:!0}):r.setQueryData(b,y.previous),eo.error(g instanceof Error?g.message:"Failed to expand tool")},e[3]=t,e[4]=r,e[5]=n,e[6]=l,e[7]=a,e[8]=c):(l=e[6],a=e[7],c=e[8]);let u;e[9]!==o||e[10]!==l||e[11]!==a||e[12]!==c?(u={mutationFn:o,onMutate:l,onSuccess:a,onError:c},e[9]=o,e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13];const d=fp(u);let f;e[14]!==s||e[15]!==d||e[16]!==t||e[17]!==r||e[18]!==n?(f=g=>{if(!n||!s)return;const x=nt.ensureTask(t.id,n),y=r.getQueryData(x),k=(y?.metadata?.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const S={...y?.metadata??{},expanded_tools:k};r.setQueryData(x,v=>v&&{...v,metadata:S}),s.patchThread({id:n,metadata:S}),d.mutate(g)},e[14]=s,e[15]=d,e[16]=t,e[17]=r,e[18]=n,e[19]=f):f=e[19];const h=f;let m;return e[20]!==h||e[21]!==d.isPending||e[22]!==d.mutate?(m={addOrReplace:d.mutate,addOrReplaceEager:h,isPending:d.isPending},e[20]=h,e[21]=d.isPending,e[22]=d.mutate,e[23]=m):m=e[23],m}function nS(n){if(n<1024)return`${n} B`;if(n<1024*1024){const t=n/1024;return t<10?`${t.toFixed(1)} KB`:`${Math.round(t)} KB`}const e=n/(1024*1024);return e<10?`${e.toFixed(1)} MB`:`${Math.round(e)} MB`}function rS(n,e,t,r){const{data:s,isLoading:i}=jr({queryKey:nt.toolDefinitionLookup(e,t,n),queryFn:async()=>{if(!n||!e)return null;const o=await kp({connectionId:e,orgId:t,orgSlug:r});try{const{tools:l}=await o.listTools(),a=Zf(n);return l.find(c=>c.name===a)??null}finally{await o.close().catch(()=>{})}},enabled:!!n&&!!e,staleTime:6e4,gcTime:3e5,retry:!1});return{toolDef:s??void 0,isLoading:i}}const sS={read:{icon:fa,label:"Read File"},write:{icon:pm,label:"Write File"},edit:{icon:Hp,label:"Edit File"},grep:{icon:gm,label:"Search Content"},glob:{icon:mm,label:"Find Files"},bash:{icon:Vp,label:"Run Command"},read_tool_output:{icon:fa,label:"Read Tool Output"},read_resource:{icon:Fp,label:"Read Resource"},read_prompt:{icon:ro,label:"Read Prompt"},skill:{icon:ro,label:"Load Skill"},enable_tool:{icon:hm,label:"Enable Tool"},open_in_agent:{icon:Bp,label:"Open in Agent"},sandbox:{icon:zp,label:"Run Code"},copy_to_sandbox:{icon:Au,label:"Load File"},share_with_user:{icon:xm,label:"Share with User"},take_screenshot:{icon:ir,label:"Take Screenshot"},scrape_url:{icon:ss,label:"Scrape URL"},inspect_page:{icon:$p,label:"Inspect Page"}},iS="bash-sleep-start:";function oS(n){const e=iS+n;try{const t=sessionStorage.getItem(e);if(t!==null){const s=Number.parseInt(t,10);if(Number.isFinite(s))return s}const r=Date.now();return sessionStorage.setItem(e,String(r)),r}catch{return Date.now()}}function lS(n,e){const t=L.c(2);let r;t[0]!==n?(r=()=>oS(n),t[0]=n,t[1]=r):r=t[1];const s=E.useState(r)[0];return e??s}function aS(n){const e=Math.ceil(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),r=e%60;return r?`${t}m ${r}s`:`${t}m`}function cS(n){const e=L.c(4),{toolCallId:t,durationMs:r,anchorMs:s}=n;hu(1e3);const o=lS(t,s)+r-Date.now();let l;e[0]!==o?(l=o>0?`Waiting ${aS(o)}`:"Wrapping up…",e[0]=o,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.jsx("span",{className:"tabular-nums",children:l}),e[2]=l,e[3]=a):a=e[3],a}const uS={s:1e3,m:6e4,h:36e5,d:864e5};function dS(n){const e=/(?:^|[\s;&|(])sleep((?:\s+[\d.]+[smhd]?)+)/g;let t=0,r=!1;for(const s of n.matchAll(e))for(const i of s[1].trim().split(/\s+/)){const o=/^([\d.]+)([smhd]?)$/.exec(i);if(!o)continue;const l=Number.parseFloat(o[1]);Number.isFinite(l)&&(t+=l*(uS[o[2]||"s"]??1e3),r=!0)}return r?t:null}function xi(n,e="An unknown error occurred"){return"errorText"in n&&typeof n.errorText=="string"?n.errorText:e}function In(n){if(n==null)return"";try{return JSON.stringify(n)}catch{return"[Non-serializable value]"}}function Js(n){const e=In(n);if(e===""||e==="[Non-serializable value]")return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const fS=n=>n.type==="dynamic-tool"||n.type.startsWith("tool-");function hS(n){if(!n||typeof n!="object")return null;const e=n;if(!Array.isArray(e.parts))return null;const t=[];for(const r of e.parts)if(r.type==="text"&&typeof r.text=="string")t.push(r.text);else if(r.type==="reasoning")t.push(`## Reasoning
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=i=>{const o=Co(i,{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 o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(i)},s=Co(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:t.inlineTokens(i.mainContent),nestedTokens:o}),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()}}});ke.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(ph.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(mh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(Sh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(wh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(L2.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(_2.configure(this.options.taskList)),n}});var Uc="&nbsp;",$2=" ",z2=Ue.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Ne(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===Uc||r[0].text===$2)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,s;if(!n)return"";const i=Array.isArray(n.content)?n.content:[];if(i.length===0){const o=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((s=t?.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Uc:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),B2=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,F2=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,V2=Cn.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",Ne(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[Hn({find:B2,type:this.type})]},addPasteRules(){return[Sn({find:F2,type:this.type})]}}),H2=Ue.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),W2=Cn.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",Ne(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 i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:t.inlineTokens(i)}}},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()}}}),U2=ke.create({name:"starterKit",addExtensions(){var n,e,t,r;const s=[];return this.options.bold!==!1&&s.push(zk.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Dk.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(ph.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Vk.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Uk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(qk.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Ek.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Ak.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(Kk.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Jk.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Ok.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(Gk.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(e2.configure(this.options.italic)),this.options.listItem!==!1&&s.push(mh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Sh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&s.push(T2.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(wh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(z2.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(V2.configure(this.options.strike)),this.options.text!==!1&&s.push(H2.configure(this.options.text)),this.options.underline!==!1&&s.push(W2.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&s.push(Ik.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),q2=U2;const en=16,Lo=2.5,_o=(en-Lo)/2,Yi=2*Math.PI*_o;function Ch(n){const e=L.c(31),{usage:t}=n;if(!t)return null;const{totalTokens:r,inputTokens:s,outputTokens:i,cost:o}=t;if(!r&&!s&&!i)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(_p,{size:12}),e[0]=l):l=e[0];let a;e[1]!==o||e[2]!==r?(a=o>0?`$${o.toFixed(4)}`:r.toLocaleString(),e[1]=o,e[2]=r,e[3]=a):a=e[3];let c;e[4]!==a?(c=p.jsx(pn,{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=i-(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]!==o?(k=o>0&&p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-muted",children:"cost"}),p.jsxs("span",{className:"text-right tabular-nums",children:["$",o.toFixed(4)]})]}),e[21]=o,e[22]=k):k=e[22];let S;e[23]!==y||e[24]!==b||e[25]!==k||e[26]!==h?(S=p.jsxs(mn,{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(gn,{children:[c,S]}),e[28]=S,e[29]=c,e[30]=v):v=e[30],v}function K2(n){const e=L.c(19),{usage:t,duration:r}=n,s=r!=null&&r>0,i=t!=null&&(t.cost??0)>0,o=t!=null&&(t.totalTokens??0)>0;if(!s&&!i&&!o)return null;let l;e[0]!==r||e[1]!==s?(l=s?Ut(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(gn,{children:[p.jsx(pn,{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(mn,{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:Ut(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]!==i||e[8]!==s||e[9]!==o?(u=s&&(i||o)&&p.jsx("span",{className:"text-muted-foreground/40 select-none",children:"·"}),e[7]=i,e[8]=s,e[9]=o,e[10]=u):u=e[10];let d;e[11]!==i||e[12]!==o||e[13]!==t?(d=(i||o)&&p.jsxs(gn,{children:[p.jsx(pn,{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:i?`$${t.cost.toFixed(4)}`:`${t.totalTokens.toLocaleString()} tok`})}),p.jsxs(mn,{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]=i,e[12]=o,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 TT(n){const e=L.c(51),{usage:t,totalTokens:r,contextWindow:s,onOpenContextPanel:i}=n,o=Math.min(r/s*100,100),l=Yi-o/100*Yi,a=t?.cost??0,c=t?.inputTokens??0,u=t?.outputTokens??0;let d;e[0]!==o?(d=o.toFixed(0),e[0]=o,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=i?"cursor-pointer":"cursor-default";let g;e[4]!==m?(g=Z("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:en/2,cy:en/2,r:_o,fill:"none",stroke:"currentColor",strokeWidth:Lo,className:"opacity-15"}),e[6]=x):x=e[6];const y=o>90?"text-destructive":o>70?"text-warning":"text-muted-foreground";let b;e[7]!==y?(b=Z(y),e[7]=y,e[8]=b):b=e[8];let k;e[9]!==l||e[10]!==b?(k=p.jsxs("svg",{width:en,height:en,className:"-rotate-90",children:[x,p.jsx("circle",{cx:en/2,cy:en/2,r:_o,fill:"none",stroke:"currentColor",strokeWidth:Lo,strokeDasharray:Yi,strokeDashoffset:l,strokeLinecap:"round",className:b})]}),e[9]=l,e[10]=b,e[11]=k):k=e[11];let S;e[12]!==o?(S=o.toFixed(0),e[12]=o,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 C;e[16]!==S||e[17]!==v?(C=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]=C):C=e[18];let w;e[19]!==i||e[20]!==C||e[21]!==h||e[22]!==g||e[23]!==k?(w=p.jsx(pn,{asChild:!0,children:p.jsxs("button",{type:"button",onClick:i,"aria-label":h,className:g,children:[k,C]})}),e[19]=i,e[20]=C,e[21]=h,e[22]=g,e[23]=k,e[24]=w):w=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]!==o?(j=o.toFixed(1),e[30]=o,e[31]=j):j=e[31];let O;e[32]!==N||e[33]!==M||e[34]!==j?(O=p.jsxs("span",{className:"text-right tabular-nums",children:[N," / ",M," (",j,"%)"]}),e[32]=N,e[33]=M,e[34]=j,e[35]=O):O=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 R;e[40]!==c||e[41]!==t?.cacheReadTokens||e[42]!==t?.cacheWriteTokens?(R=((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]=R):R=e[43];let I;e[44]!==O||e[45]!==A||e[46]!==R?(I=p.jsx(mn,{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,O,A,R]})}),e[44]=O,e[45]=A,e[46]=R,e[47]=I):I=e[47];let _;return e[48]!==w||e[49]!==I?(_=p.jsxs(gn,{children:[w,I]}),e[48]=w,e[49]=I,e[50]=_):_=e[50],_}var gi="Collapsible",[J2,NT]=ru(gi),[G2,Ul]=J2(gi),Th=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,open:r,defaultOpen:s,disabled:i,onOpenChange:o,...l}=n,[a,c]=cp({prop:r,defaultProp:s??!1,onChange:o,caller:gi});return p.jsx(G2,{scope:t,disabled:i,contentId:up(),open:a,onOpenToggle:E.useCallback(()=>c(u=>!u),[c]),children:p.jsx(Jt.div,{"data-state":Gl(a),"data-disabled":i?"":void 0,...l,ref:e})})});Th.displayName=gi;var Nh="CollapsibleTrigger",ql=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,...r}=n,s=Ul(Nh,t);return p.jsx(Jt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Gl(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Bt(n.onClick,s.onOpenToggle)})});ql.displayName=Nh;var Kl="CollapsibleContent",Jl=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Ul(Kl,n.__scopeCollapsible);return p.jsx(Ar,{present:t||s.open,children:({present:i})=>p.jsx(X2,{...r,ref:e,present:i})})});Jl.displayName=Kl;var X2=E.forwardRef((n,e)=>{const{__scopeCollapsible:t,present:r,children:s,...i}=n,o=Ul(Kl,t),[l,a]=E.useState(r),c=E.useRef(null),u=vn(e,c),d=E.useRef(0),f=d.current,h=E.useRef(0),m=h.current,g=o.open||l,x=E.useRef(g),y=E.useRef(void 0);return E.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),nu(()=>{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)}},[o.open,r]),p.jsx(Jt.div,{"data-state":Gl(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...i,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 Gl(n){return n?"open":"closed"}var Y2=Th,MT=ql,ET=Jl;function Q2(n){const e=L.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(Y2,{"data-slot":"collapsible",...t}),e[2]=t,e[3]=r):r=e[3],r}function Z2(n){const e=L.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(ql,{"data-slot":"collapsible-trigger",...t}),e[2]=t,e[3]=r):r=e[3],r}function eS(n){const e=L.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(Jl,{"data-slot":"collapsible-content",...t}),e[2]=t,e[3]=r):r=e[3],r}function ee({icon:n,title:e,usage:t,latency:r,summary:s,state:i,detail:o,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}=Cu(),k=i==="loading",S=i==="error",C=!!(o&&o.trim())||!!m,w=c==="subtask",T=(a??!1)||g,N=Bm({initial:k?"instant":!1}),M=p.jsxs(Q2,{open:T,onOpenChange:a?void 0:x,className:"min-w-0",children:[p.jsxs(Z2,{disabled:!C,className:Z("group/tool flex items-center gap-2 w-full py-2.5 text-left transition-colors",C&&"[@media(hover:hover)]:hover:bg-accent/30",!C&&"cursor-default",k&&"shimmer"),"aria-disabled":!C,children:[p.jsx("div",{className:"relative shrink-0 size-4 flex items-center justify-center",children:f?p.jsx(ua,{className:Z("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")}):p.jsxs(p.Fragment,{children:[p.jsx("div",{className:Z("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",C&&(T?"opacity-0":"[@media(hover:hover)]:group-hover/tool:opacity-0")),children:n}),C&&p.jsx("div",{className:Z("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(ua,{className:Z("size-4 text-foreground/60 transition-transform duration-200 ease-in-out",T&&"rotate-90")})})]})}),p.jsx("span",{className:Z("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(Ch,{usage:t})]}),C&&p.jsx(eS,{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:o})})}):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:o})}),p.jsx("button",{type:"button",onClick:()=>y(o),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(Yo,{className:"size-3.5"}):p.jsx(wu,{className:"size-3.5"})})]})})}))})]});return w?p.jsx("div",{className:"pl-4 border-l border-border/40 ml-1.5",children:M}):M}function $e(n){const e=L.c(4),{latency:t}=n;if(t==null||t<=0)return null;let r;e[0]!==t?(r=Ut(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 Mh=4;function Eh(n){const e=L.c(5),{count:t,noun:r,onClick:s}=n;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(vu,{className:"size-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"}),e[0]=i):i=e[0];let o;return e[1]!==t||e[2]!==r||e[3]!==s?(o=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,i]}),e[1]=t,e[2]=r,e[3]=s,e[4]=o):o=e[4],o}function Ah(n){const e=L.c(12),{message:t,className:r}=n,s=t.created_at??t.metadata?.created_at??null;let i,o,l,a;if(e[0]!==r||e[1]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=Qo(s);if(u===null){a=null;break e}const d=new Date(u);i=d.toLocaleString(),e[6]!==r?(o=Z("text-[11px] text-muted-foreground/60 select-none",r),e[6]=r,e[7]=o):o=e[7],l=d.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=l,e[5]=a}else i=e[2],o=e[3],l=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;return e[8]!==i||e[9]!==o||e[10]!==l?(c=p.jsx("span",{title:i,className:o,children:l}),e[8]=i,e[9]=o,e[10]=l,e[11]=c):c=e[11],c}function tS(n){const e=L.c(24),{org:t}=Mt(),r=dp(),s=rm(),i=pu();let o;e[0]!==i||e[1]!==n?(o=async g=>{if(!n)throw new Error("useTaskExpandedTools: no task in context");const y=(await i.call("COLLECTION_THREADS_GET",{id:n})).item?.metadata??{},k=(y.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const S={...y,expanded_tools:k};return await i.call("COLLECTION_THREADS_UPDATE",{id:n,data:{metadata:S}}),k},e[0]=i,e[1]=n,e[2]=o):o=e[2];let l,a,c;e[3]!==t||e[4]!==r||e[5]!==n?(l=async g=>{const x=nt.ensureTask(t.id,n??"");await r.cancelQueries({queryKey:x});const y=r.getQueryData(x),k=(y?.metadata?.expanded_tools??[]).filter(S=>S.toolName!==g.toolName);return k.push({...g,expandedAt:new Date().toISOString()}),r.setQueryData(x,S=>S&&{...S,metadata:{...S.metadata??{},expanded_tools:k}}),{previous:y}},a=()=>{r.invalidateQueries({queryKey:nt.ensureTask(t.id,n??"")})},c=(g,x,y)=>{const b=nt.ensureTask(t.id,n??"");y?.previous===void 0?r.removeQueries({queryKey:b,exact:!0}):r.setQueryData(b,y.previous),eo.error(g instanceof Error?g.message:"Failed to expand tool")},e[3]=t,e[4]=r,e[5]=n,e[6]=l,e[7]=a,e[8]=c):(l=e[6],a=e[7],c=e[8]);let u;e[9]!==o||e[10]!==l||e[11]!==a||e[12]!==c?(u={mutationFn:o,onMutate:l,onSuccess:a,onError:c},e[9]=o,e[10]=l,e[11]=a,e[12]=c,e[13]=u):u=e[13];const d=fp(u);let f;e[14]!==s||e[15]!==d||e[16]!==t||e[17]!==r||e[18]!==n?(f=g=>{if(!n||!s)return;const x=nt.ensureTask(t.id,n),y=r.getQueryData(x),k=(y?.metadata?.expanded_tools??[]).filter(v=>v.toolName!==g.toolName);k.push({...g,expandedAt:new Date().toISOString()});const S={...y?.metadata??{},expanded_tools:k};r.setQueryData(x,v=>v&&{...v,metadata:S}),s.patchThread({id:n,metadata:S}),d.mutate(g)},e[14]=s,e[15]=d,e[16]=t,e[17]=r,e[18]=n,e[19]=f):f=e[19];const h=f;let m;return e[20]!==h||e[21]!==d.isPending||e[22]!==d.mutate?(m={addOrReplace:d.mutate,addOrReplaceEager:h,isPending:d.isPending},e[20]=h,e[21]=d.isPending,e[22]=d.mutate,e[23]=m):m=e[23],m}function nS(n){if(n<1024)return`${n} B`;if(n<1024*1024){const t=n/1024;return t<10?`${t.toFixed(1)} KB`:`${Math.round(t)} KB`}const e=n/(1024*1024);return e<10?`${e.toFixed(1)} MB`:`${Math.round(e)} MB`}function rS(n,e,t,r){const{data:s,isLoading:i}=jr({queryKey:nt.toolDefinitionLookup(e,t,n),queryFn:async()=>{if(!n||!e)return null;const o=await kp({connectionId:e,orgId:t,orgSlug:r});try{const{tools:l}=await o.listTools(),a=Zf(n);return l.find(c=>c.name===a)??null}finally{await o.close().catch(()=>{})}},enabled:!!n&&!!e,staleTime:6e4,gcTime:3e5,retry:!1});return{toolDef:s??void 0,isLoading:i}}const sS={read:{icon:fa,label:"Read File"},write:{icon:pm,label:"Write File"},edit:{icon:Hp,label:"Edit File"},grep:{icon:gm,label:"Search Content"},glob:{icon:mm,label:"Find Files"},bash:{icon:Vp,label:"Run Command"},read_tool_output:{icon:fa,label:"Read Tool Output"},read_resource:{icon:Fp,label:"Read Resource"},read_prompt:{icon:ro,label:"Read Prompt"},skill:{icon:ro,label:"Load Skill"},enable_tool:{icon:hm,label:"Enable Tool"},open_in_agent:{icon:Bp,label:"Open in Agent"},sandbox:{icon:zp,label:"Run Code"},copy_to_sandbox:{icon:Au,label:"Load File"},share_with_user:{icon:xm,label:"Share with User"},take_screenshot:{icon:ir,label:"Take Screenshot"},scrape_url:{icon:ss,label:"Scrape URL"},inspect_page:{icon:$p,label:"Inspect Page"}},iS="bash-sleep-start:";function oS(n){const e=iS+n;try{const t=sessionStorage.getItem(e);if(t!==null){const s=Number.parseInt(t,10);if(Number.isFinite(s))return s}const r=Date.now();return sessionStorage.setItem(e,String(r)),r}catch{return Date.now()}}function lS(n,e){const t=L.c(2);let r;t[0]!==n?(r=()=>oS(n),t[0]=n,t[1]=r):r=t[1];const s=E.useState(r)[0];return e??s}function aS(n){const e=Math.ceil(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),r=e%60;return r?`${t}m ${r}s`:`${t}m`}function cS(n){const e=L.c(4),{toolCallId:t,durationMs:r,anchorMs:s}=n;hu(1e3);const o=lS(t,s)+r-Date.now();let l;e[0]!==o?(l=o>0?`Waiting ${aS(o)}`:"Wrapping up…",e[0]=o,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.jsx("span",{className:"tabular-nums",children:l}),e[2]=l,e[3]=a):a=e[3],a}const uS={s:1e3,m:6e4,h:36e5,d:864e5};function dS(n){const e=/(?:^|[\s;&|(])sleep((?:\s+[\d.]+[smhd]?)+)/g;let t=0,r=!1;for(const s of n.matchAll(e))for(const i of s[1].trim().split(/\s+/)){const o=/^([\d.]+)([smhd]?)$/.exec(i);if(!o)continue;const l=Number.parseFloat(o[1]);Number.isFinite(l)&&(t+=l*(uS[o[2]||"s"]??1e3),r=!0)}return r?t:null}function xi(n,e="An unknown error occurred"){return"errorText"in n&&typeof n.errorText=="string"?n.errorText:e}function In(n){if(n==null)return"";try{return JSON.stringify(n)}catch{return"[Non-serializable value]"}}function Js(n){const e=In(n);if(e===""||e==="[Non-serializable value]")return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const fS=n=>n.type==="dynamic-tool"||n.type.startsWith("tool-");function hS(n){if(!n||typeof n!="object")return null;const e=n;if(!Array.isArray(e.parts))return null;const t=[];for(const r of e.parts)if(r.type==="text"&&typeof r.text=="string")t.push(r.text);else if(r.type==="reasoning")t.push(`## Reasoning
143
143
  ${r.text}`);else if(r.type==="source-url")t.push(`## Source URL
144
144
  ${r.url}`);else if(r.type==="source-document")t.push(`## Source Document
145
145
  ${r.title}`);else if(r.type==="file")t.push(`## File
@@ -160,29 +160,29 @@ Error: Tool responded with an error`)}else if(r.state==="output-denied"){const i
160
160
  Input: ${i||"[No input]"}...
161
161
  Output: Tool execution was denied`)}}}return t.length>0?t.join(`
162
162
 
163
- `):null}function pS(n){const e=n&&typeof n=="object"&&"created_at"in n?n.created_at:void 0;return typeof e=="string"||e instanceof Date?Qo(e):null}function mS(n){const e=n&&typeof n=="object"&&"timeout"in n?n.timeout:void 0;return Math.min(typeof e=="number"?e:3e4,12e4)}function Xr(n){const e=L.c(7),{icon:t,label:r}=n;let s;e[0]!==t?(s=p.jsx(pn,{asChild:!0,children:p.jsx("span",{className:"flex items-center",children:t})}),e[0]=t,e[1]=s):s=e[1];let i;e[2]!==r?(i=p.jsx(mn,{side:"top",children:r}),e[2]=r,e[3]=i):i=e[3];let o;return e[4]!==s||e[5]!==i?(o=p.jsxs(gn,{children:[s,i]}),e[4]=s,e[5]=i,e[6]=o):o=e[6],o}function gS(n){const e=L.c(15),{annotations:t,toolMeta:r}=n;let s;e[0]!==r?(s=Nu(r),e[0]=r,e[1]=s):s=e[1];const i=!!s;if(!t&&!i)return null;let o;e[2]!==i?(o=i&&p.jsx(Xr,{icon:p.jsx(ku,{}),label:"Interactive"}),e[2]=i,e[3]=o):o=e[3];let l;e[4]!==t?.readOnlyHint?(l=t?.readOnlyHint&&p.jsx(Xr,{icon:p.jsx(Xp,{}),label:"Read-only — no side effects"}),e[4]=t?.readOnlyHint,e[5]=l):l=e[5];let a;e[6]!==t?.destructiveHint?(a=t?.destructiveHint&&p.jsx(Xr,{icon:p.jsx(Mu,{}),label:"May modify or delete data"}),e[6]=t?.destructiveHint,e[7]=a):a=e[7];let c;e[8]!==t?.openWorldHint?(c=t?.openWorldHint&&p.jsx(Xr,{icon:p.jsx(ss,{}),label:"Reaches outside this system"}),e[8]=t?.openWorldHint,e[9]=c):c=e[9];let u;return e[10]!==o||e[11]!==l||e[12]!==a||e[13]!==c?(u=p.jsxs(p.Fragment,{children:[o,l,a,c]}),e[10]=o,e[11]=l,e[12]=a,e[13]=c,e[14]=u):u=e[14],u}function xS(n){return n<1?`${Math.round(n*1e3)}ms`:n<10?`${n.toFixed(1)}s`:`${Math.round(n)}s`}function yS(n){const e=L.c(13),{latency:t,outputBytes:r}=n,s=typeof t=="number"&&t>0,i=typeof r=="number"&&r>=0;if(!s&&!i)return null;let o;e[0]!==s||e[1]!==t?(o=s&&p.jsx("span",{children:xS(t)}),e[0]=s,e[1]=t,e[2]=o):o=e[2];let l;e[3]!==i||e[4]!==s?(l=s&&i&&p.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[3]=i,e[4]=s,e[5]=l):l=e[5];let a;e[6]!==i||e[7]!==r?(a=i&&p.jsx("span",{children:nS(r)}),e[6]=i,e[7]=r,e[8]=a):a=e[8];let c;return e[9]!==o||e[10]!==l||e[11]!==a?(c=p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-mono tabular-nums text-muted-foreground/60 px-1 leading-none",children:[o,l,a]}),e[9]=o,e[10]=l,e[11]=a,e[12]=c):c=e[12],c}function bS(n,e,t){switch(n){case"input-streaming":case"input-available":return"Preparing...";case"approval-requested":return"Waiting for your approval";case"output-denied":return"Cancelled";case"output-error":return t??"Failed";case"output-available":{if(e==null)return"Done";if(typeof e=="string"){const r=e.trim();return r.length>100?r.slice(0,100)+"…":r}if(typeof e=="object"){for(const r of Object.keys(e)){const s=e[r];if(typeof s=="string"&&s.trim()){const i=s.trim();return i.length>100?i.slice(0,100)+"…":i}}return""}return String(e).slice(0,100)}default:return""}}function qc(n){const e=L.c(74),{part:t,annotations:r,latency:s,outputBytes:i,isLastMessage:o,toolMeta:l}=n,a="toolName"in t&&typeof t.toolName=="string"?t.toolName:t.type==="dynamic-tool"?"Dynamic Tool":t.type.replace("tool-","")||"Tool",c=Zf(a),u=Kn(),d=tm(),{org:f}=Mt(),{openSidePanel:h}=ym(),m=el()?.taskId??null,{addOrReplaceEager:g}=tS(m),x=qn(),y=l&&typeof l=="object"&&l!==null&&"connectionId"in l&&l.connectionId!=null&&l.connectionId!==""?String(l.connectionId):d?.selectedVirtualMcp?.id??null,{toolDef:b}=rS(y?a:null,y,f.id,f.slug),k=b?._meta??l,S=nl(k),v=rl(c,S),C=sS[v],w=b?.title??C?.label??Pu(v);let T;e[0]!==k?(T=Nu(k),e[0]=k,e[1]=T):T=e[1];const N=T,M=!!N&&t.state==="output-available",j=y?`${y}:${a}`:null,O=!!r?.destructiveHint,A=M&&!!y&&!O&&!!m;let R;e[2]!==g||e[3]!==y||e[4]!==x||e[5]!==t||e[6]!==a?(R=()=>{if(!y)return;const K="input"in t&&t.input&&typeof t.input=="object"?t.input:{};g({toolName:a,appId:y,args:K}),x({to:".",search:ie=>({...ie,main:am(y,a)}),replace:!0})},e[2]=g,e[3]=y,e[4]=x,e[5]=t,e[6]=a,e[7]=R):R=e[7];const I=R;let _;e[8]!==A||e[9]!==I?(_=K=>K==="fullscreen"&&A?(I(),"fullscreen"):"inline",e[8]=A,e[9]=I,e[10]=_):_=e[10];const $=_;let z;e[11]!==u||e[12]!==h?(z=K=>{const ie=Qp(K.content);ie.content.length>0&&(h("chat"),u?.sendMessage(ie))},e[11]=u,e[12]=h,e[13]=z):z=e[13];const B=z,q=t.state==="approval-requested"&&o===!1,J=t.state==="output-denied"||q,U=t.state==="output-available"&&typeof t.output=="object"&&t.output!=null&&"isError"in t.output&&t.output.isError===!0;let X;e[14]!==t.state?(X=ct(t.state),e[14]=t.state,e[15]=X):X=e[15];const te=X,ne=q||te==="approval"?"idle":U?"error":te;let re,le;if(e[16]!==ne||e[17]!==U||e[18]!==q||e[19]!==t||e[20]!==v){re=t.state==="output-error"?xi(t):void 0;const K=v==="bash"&&ne==="loading"&&t.input&&typeof t.input=="object"&&typeof t.input.command=="string"?t.input.command:null;let ie;e[23]!==K?(ie=K!==null?dS(K):null,e[23]=K,e[24]=ie):ie=e[24];const ce=ie;let oe;e[25]!==t.input||e[26]!==ce?(oe=ce!==null?Math.min(ce,mS(t.input)):null,e[25]=t.input,e[26]=ce,e[27]=oe):oe=e[27];const be=oe,At="toolCallId"in t?t.toolCallId:"";le=be!==null?p.jsx(cS,{toolCallId:At,durationMs:be,anchorMs:pS(t)}):q?"Cancelled":U?"Failed":bS(t.state,t.output,re),e[16]=ne,e[17]=U,e[18]=q,e[19]=t,e[20]=v,e[21]=re,e[22]=le}else re=e[21],le=e[22];const ye=le;let V="";t.input!==void 0&&(V=`# Input
163
+ `):null}function pS(n){const e=n&&typeof n=="object"&&"created_at"in n?n.created_at:void 0;return typeof e=="string"||e instanceof Date?Qo(e):null}function mS(n){const e=n&&typeof n=="object"&&"timeout"in n?n.timeout:void 0;return Math.min(typeof e=="number"?e:3e4,12e4)}function Xr(n){const e=L.c(7),{icon:t,label:r}=n;let s;e[0]!==t?(s=p.jsx(pn,{asChild:!0,children:p.jsx("span",{className:"flex items-center",children:t})}),e[0]=t,e[1]=s):s=e[1];let i;e[2]!==r?(i=p.jsx(mn,{side:"top",children:r}),e[2]=r,e[3]=i):i=e[3];let o;return e[4]!==s||e[5]!==i?(o=p.jsxs(gn,{children:[s,i]}),e[4]=s,e[5]=i,e[6]=o):o=e[6],o}function gS(n){const e=L.c(15),{annotations:t,toolMeta:r}=n;let s;e[0]!==r?(s=Nu(r),e[0]=r,e[1]=s):s=e[1];const i=!!s;if(!t&&!i)return null;let o;e[2]!==i?(o=i&&p.jsx(Xr,{icon:p.jsx(ku,{}),label:"Interactive"}),e[2]=i,e[3]=o):o=e[3];let l;e[4]!==t?.readOnlyHint?(l=t?.readOnlyHint&&p.jsx(Xr,{icon:p.jsx(um,{}),label:"Read-only — no side effects"}),e[4]=t?.readOnlyHint,e[5]=l):l=e[5];let a;e[6]!==t?.destructiveHint?(a=t?.destructiveHint&&p.jsx(Xr,{icon:p.jsx(Mu,{}),label:"May modify or delete data"}),e[6]=t?.destructiveHint,e[7]=a):a=e[7];let c;e[8]!==t?.openWorldHint?(c=t?.openWorldHint&&p.jsx(Xr,{icon:p.jsx(ss,{}),label:"Reaches outside this system"}),e[8]=t?.openWorldHint,e[9]=c):c=e[9];let u;return e[10]!==o||e[11]!==l||e[12]!==a||e[13]!==c?(u=p.jsxs(p.Fragment,{children:[o,l,a,c]}),e[10]=o,e[11]=l,e[12]=a,e[13]=c,e[14]=u):u=e[14],u}function xS(n){return n<1?`${Math.round(n*1e3)}ms`:n<10?`${n.toFixed(1)}s`:`${Math.round(n)}s`}function yS(n){const e=L.c(13),{latency:t,outputBytes:r}=n,s=typeof t=="number"&&t>0,i=typeof r=="number"&&r>=0;if(!s&&!i)return null;let o;e[0]!==s||e[1]!==t?(o=s&&p.jsx("span",{children:xS(t)}),e[0]=s,e[1]=t,e[2]=o):o=e[2];let l;e[3]!==i||e[4]!==s?(l=s&&i&&p.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[3]=i,e[4]=s,e[5]=l):l=e[5];let a;e[6]!==i||e[7]!==r?(a=i&&p.jsx("span",{children:nS(r)}),e[6]=i,e[7]=r,e[8]=a):a=e[8];let c;return e[9]!==o||e[10]!==l||e[11]!==a?(c=p.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-mono tabular-nums text-muted-foreground/60 px-1 leading-none",children:[o,l,a]}),e[9]=o,e[10]=l,e[11]=a,e[12]=c):c=e[12],c}function bS(n,e,t){switch(n){case"input-streaming":case"input-available":return"Preparing...";case"approval-requested":return"Waiting for your approval";case"output-denied":return"Cancelled";case"output-error":return t??"Failed";case"output-available":{if(e==null)return"Done";if(typeof e=="string"){const r=e.trim();return r.length>100?r.slice(0,100)+"…":r}if(typeof e=="object"){for(const r of Object.keys(e)){const s=e[r];if(typeof s=="string"&&s.trim()){const i=s.trim();return i.length>100?i.slice(0,100)+"…":i}}return""}return String(e).slice(0,100)}default:return""}}function qc(n){const e=L.c(74),{part:t,annotations:r,latency:s,outputBytes:i,isLastMessage:o,toolMeta:l}=n,a="toolName"in t&&typeof t.toolName=="string"?t.toolName:t.type==="dynamic-tool"?"Dynamic Tool":t.type.replace("tool-","")||"Tool",c=Zf(a),u=Kn(),d=em(),{org:f}=Mt(),{openSidePanel:h}=ym(),m=el()?.taskId??null,{addOrReplaceEager:g}=tS(m),x=qn(),y=l&&typeof l=="object"&&l!==null&&"connectionId"in l&&l.connectionId!=null&&l.connectionId!==""?String(l.connectionId):d?.selectedVirtualMcp?.id??null,{toolDef:b}=rS(y?a:null,y,f.id,f.slug),k=b?._meta??l,S=nl(k),v=rl(c,S),C=sS[v],w=b?.title??C?.label??Pu(v);let T;e[0]!==k?(T=Nu(k),e[0]=k,e[1]=T):T=e[1];const N=T,M=!!N&&t.state==="output-available",j=y?`${y}:${a}`:null,O=!!r?.destructiveHint,A=M&&!!y&&!O&&!!m;let R;e[2]!==g||e[3]!==y||e[4]!==x||e[5]!==t||e[6]!==a?(R=()=>{if(!y)return;const K="input"in t&&t.input&&typeof t.input=="object"?t.input:{};g({toolName:a,appId:y,args:K}),x({to:".",search:ie=>({...ie,main:lm(y,a)}),replace:!0})},e[2]=g,e[3]=y,e[4]=x,e[5]=t,e[6]=a,e[7]=R):R=e[7];const I=R;let _;e[8]!==A||e[9]!==I?(_=K=>K==="fullscreen"&&A?(I(),"fullscreen"):"inline",e[8]=A,e[9]=I,e[10]=_):_=e[10];const $=_;let z;e[11]!==u||e[12]!==h?(z=K=>{const ie=Yp(K.content);ie.content.length>0&&(h("chat"),u?.sendMessage(ie))},e[11]=u,e[12]=h,e[13]=z):z=e[13];const B=z,q=t.state==="approval-requested"&&o===!1,J=t.state==="output-denied"||q,U=t.state==="output-available"&&typeof t.output=="object"&&t.output!=null&&"isError"in t.output&&t.output.isError===!0;let X;e[14]!==t.state?(X=ct(t.state),e[14]=t.state,e[15]=X):X=e[15];const te=X,ne=q||te==="approval"?"idle":U?"error":te;let re,le;if(e[16]!==ne||e[17]!==U||e[18]!==q||e[19]!==t||e[20]!==v){re=t.state==="output-error"?xi(t):void 0;const K=v==="bash"&&ne==="loading"&&t.input&&typeof t.input=="object"&&typeof t.input.command=="string"?t.input.command:null;let ie;e[23]!==K?(ie=K!==null?dS(K):null,e[23]=K,e[24]=ie):ie=e[24];const ce=ie;let oe;e[25]!==t.input||e[26]!==ce?(oe=ce!==null?Math.min(ce,mS(t.input)):null,e[25]=t.input,e[26]=ce,e[27]=oe):oe=e[27];const be=oe,At="toolCallId"in t?t.toolCallId:"";le=be!==null?p.jsx(cS,{toolCallId:At,durationMs:be,anchorMs:pS(t)}):q?"Cancelled":U?"Failed":bS(t.state,t.output,re),e[16]=ne,e[17]=U,e[18]=q,e[19]=t,e[20]=v,e[21]=re,e[22]=le}else re=e[21],le=e[22];const ye=le;let V="";t.input!==void 0&&(V=`# Input
164
164
  `+Js(t.input)),t.state==="output-error"?(V&&(V=V+`
165
165
 
166
166
  `),V=V+(`# Error
167
167
  `+(re??""))):t.output!==void 0&&!M&&(V&&(V=V+`
168
168
 
169
169
  `),V=V+(`# Output
170
- `+Js(t.output)));let se;e:{if(J){let ce;e[28]===Symbol.for("react.memo_cache_sentinel")?(ce=p.jsx(dm,{}),e[28]=ce):ce=e[28],se=ce;break e}if(M){let ce;e[29]===Symbol.for("react.memo_cache_sentinel")?(ce=p.jsx(ku,{className:"size-4 text-muted-foreground"}),e[29]=ce):ce=e[29],se=ce;break e}const K=C?.icon;if(K){let ce;e[30]!==K?(ce=p.jsx(K,{className:"size-4 text-muted-foreground"}),e[30]=K,e[31]=ce):ce=e[31],se=ce;break e}let ie;e[32]===Symbol.for("react.memo_cache_sentinel")?(ie=p.jsx(Wp,{className:"size-4 text-muted-foreground"}),e[32]=ie):ie=e[32],se=ie}let ae;e[33]!==r||e[34]!==l?(ae=p.jsx(gS,{annotations:r,toolMeta:l}),e[33]=r,e[34]=l,e[35]=ae):ae=e[35];let de;e[36]!==s||e[37]!==i?(de=p.jsx(yS,{latency:s,outputBytes:i}),e[36]=s,e[37]=i,e[38]=de):de=e[38];let Ie;e[39]!==ae||e[40]!==de?(Ie=p.jsxs(p.Fragment,{children:[ae,de]}),e[39]=ae,e[40]=de,e[41]=Ie):Ie=e[41];const Fe=V||null;let Ee;e[42]!==ne||e[43]!==w||e[44]!==J||e[45]!==s||e[46]!==ye||e[47]!==Ie||e[48]!==Fe||e[49]!==se?(Ee=p.jsx(ee,{icon:se,iconDestructive:J,trailing:Ie,title:w,latency:s,summary:ye,state:ne,detail:Fe}),e[42]=ne,e[43]=w,e[44]=J,e[45]=s,e[46]=ye,e[47]=Ie,e[48]=Fe,e[49]=se,e[50]=Ee):Ee=e[50];let Se;e[51]!==A||e[52]!==I?(Se=A&&p.jsx("div",{className:"flex justify-end mt-1.5 mb-1",children:p.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground rounded-md [@media(hover:hover)]:hover:bg-accent/50 [@media(hover:hover)]:hover:text-foreground transition-colors",children:[p.jsx(Up,{className:"size-3.5"}),"Open in panel"]})}),e[51]=A,e[52]=I,e[53]=Se):Se=e[53];let ve;e[54]!==A||e[55]!==d||e[56]!==y||e[57]!==w||e[58]!==B||e[59]!==$||e[60]!==M||e[61]!==k||e[62]!==f.id||e[63]!==f.slug||e[64]!==t.input||e[65]!==t.output||e[66]!==j||e[67]!==v||e[68]!==N?(ve=M&&N&&y&&f?.id&&p.jsx(p.Fragment,{children:p.jsx(su,{fallback:K=>{const{resetError:ie}=K;return p.jsxs("div",{className:"mt-2 flex items-center gap-2 px-3 py-2.5 border border-dashed border-destructive/30 bg-destructive/5 rounded-lg",children:[p.jsx(Mu,{size:16,className:"shrink-0 text-destructive"}),p.jsxs("span",{className:"flex-1 text-xs text-destructive font-medium",children:["Failed to load"," ",p.jsx("span",{className:"font-mono",children:w})," app"]}),p.jsxs(mt,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1.5 shrink-0",onClick:ie,children:[p.jsx(iu,{className:"size-3.5"}),"Retry"]})]})},children:p.jsx(E.Suspense,{fallback:p.jsx("div",{className:"mt-2 flex items-center justify-center h-12 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[p.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),p.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),children:p.jsx(vS,{uiResourceUri:N,connectionId:y,orgId:f.id,orgSlug:f.slug,toolName:v,toolInput:t.input,toolResult:t.output,toolMeta:k,onMessage:B,onUpdateModelContext:j&&d?K=>d.setAppContext(j,K):void 0,onTeardown:j&&d?()=>d.clearAppContext(j):void 0,onRequestDisplayMode:A?$:void 0})})})}),e[54]=A,e[55]=d,e[56]=y,e[57]=w,e[58]=B,e[59]=$,e[60]=M,e[61]=k,e[62]=f.id,e[63]=f.slug,e[64]=t.input,e[65]=t.output,e[66]=j,e[67]=v,e[68]=N,e[69]=ve):ve=e[69];let Le;return e[70]!==Ee||e[71]!==Se||e[72]!==ve?(Le=p.jsxs("div",{children:[Ee,Se,ve]}),e[70]=Ee,e[71]=Se,e[72]=ve,e[73]=Le):Le=e[73],Le}function jh(n){return typeof n=="object"&&n!=null&&"type"in n&&n.type==="mcpToolCall"}function kS(n){if(n!=null)return jh(n)?n.arguments??void 0:n}function SS(n){if(n==null)return;if(jh(n)&&n.result!=null)return n.result;if(typeof n=="object"&&"content"in n&&Array.isArray(n.content)){const t=n.content;if(t.length>0&&typeof t[0]=="object"&&t[0]!=null&&"type"in t[0])return n}const e=typeof n=="string"?n:JSON.stringify(n);return{structuredContent:typeof n=="object"&&!Array.isArray(n)?n:void 0,content:[{type:"text",text:e}]}}function vS(n){const e=L.c(27),{uiResourceUri:t,connectionId:r,orgId:s,orgSlug:i,toolName:o,toolInput:l,toolResult:a,toolMeta:c,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h}=n;let m;e[0]!==r||e[1]!==s||e[2]!==i?(m={connectionId:r,orgId:s,orgSlug:i},e[0]=r,e[1]=s,e[2]=i,e[3]=m):m=e[3];const g=qo(m);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x={type:"object"},e[4]=x):x=e[4];let y;e[5]!==c?(y=c!=null&&{_meta:c},e[5]=c,e[6]=y):y=e[6];let b;e[7]!==y||e[8]!==o?(b={name:o,inputSchema:x,...y},e[7]=y,e[8]=o,e[9]=b):b=e[9];const k=b;let S;e[10]!==k?(S={tool:k},e[10]=k,e[11]=S):S=e[11];let v;e[12]!==l?(v=kS(l),e[12]=l,e[13]=v):v=e[13];let C;e[14]!==a?(C=SS(a),e[14]=a,e[15]=C):C=e[15];let w;return e[16]!==g||e[17]!==u||e[18]!==h||e[19]!==f||e[20]!==d||e[21]!==s||e[22]!==S||e[23]!==v||e[24]!==C||e[25]!==t?(w=p.jsx("div",{className:"mt-2 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsx(Zp,{resourceURI:t,orgId:s,toolInfo:S,toolInput:v,toolResult:C,client:g,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h})}),e[16]=g,e[17]=u,e[18]=h,e[19]=f,e[20]=d,e[21]=s,e[22]=S,e[23]=v,e[24]=C,e[25]=t,e[26]=w):w=e[26],w}const Kc="mesh-storage://";function yi(n){return n.startsWith(Kc)?n.slice(Kc.length):null}function Ih(n,e){const t=yi(n);return t!==null?`/api/${e}/files/${t}`:n}function wS(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;return r?{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:0,cacheReadTokens:0,cacheWriteTokens:0}:null}function CS(n){const e=L.c(13),{uri:t,orgSlug:r}=n;let s;e[0]!==r||e[1]!==t?(s=Ih(t,r),e[0]=r,e[1]=t,e[2]=s):s=e[2];const i=s;let o;e[3]!==t?(o=yi(t)!==null?t.slice(t.lastIndexOf("/")+1):"reference",e[3]=t,e[4]=o):o=e[4];const l=o;let a;e[5]!==l?(a=p.jsx(pn,{asChild:!0,children:p.jsx("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 rounded bg-muted text-muted-foreground text-xs cursor-default select-none",children:l})}),e[5]=l,e[6]=a):a=e[6];let c;e[7]!==l||e[8]!==i?(c=p.jsx(mn,{side:"top",className:"max-w-sm p-1.5",children:p.jsx("img",{src:i,alt:l,className:"max-w-full max-h-64 object-contain rounded"})}),e[7]=l,e[8]=i,e[9]=c):c=e[9];let u;return e[10]!==a||e[11]!==c?(u=p.jsxs(gn,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=u):u=e[12],u}function TS(n){const e=L.c(76),{part:t,latency:r}=n,s=Uo();let i;e[0]!==t.state?(i=ct(t.state),e[0]=t.state,e[1]=i):i=e[1];const o=i,l=t.input,a=t.output,c=a?.images;let u;e[2]!==a?(u=wS(a),e[2]=a,e[3]=u):u=e[3];const d=u,f=a?.model;let h,m,g,x,y,b,k,S,v,C,w,T;if(e[4]!==c||e[5]!==l||e[6]!==r||e[7]!==f||e[8]!==s||e[9]!==t||e[10]!==a||e[11]!==o||e[12]!==d){y=Symbol.for("react.early_return_sentinel");e:{const R=Array.isArray(l?.referenceImages)?l.referenceImages.filter(NS):void 0;let I;e[25]!==r?(I=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ut(r)}):null,e[25]=r,e[26]=I):I=e[26];const _=I;if(o==="loading"){let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=p.jsx(_r,{size:14}),e[27]=$):$=e[27];let z;e[28]!==l?(z=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[28]=l,e[29]=z):z=e[29];let B;e[30]!==z?(B=p.jsx(ee,{icon:$,title:"Generating image",summary:z,state:"loading"}),e[30]=z,e[31]=B):B=e[31],y=B;break e}if(a?.background){let $;e[32]===Symbol.for("react.memo_cache_sentinel")?($=p.jsx(_r,{size:14}),e[32]=$):$=e[32];let z;e[33]!==l?(z=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[33]=l,e[34]=z):z=e[34];let B;e[35]!==z?(B=p.jsx(ee,{icon:$,title:"Image queued — generating in the background",summary:z,state:"idle"}),e[35]=z,e[36]=B):B=e[36],y=B;break e}if(o==="error"||!c||c.length===0){let $;e[37]!==t||e[38]!==o?($=o==="error"?xi(t):void 0,e[37]=t,e[38]=o,e[39]=$):$=e[39];const z=$;let B="";l!==void 0&&(B=`# Input
170
+ `+Js(t.output)));let se;e:{if(J){let ce;e[28]===Symbol.for("react.memo_cache_sentinel")?(ce=p.jsx(dm,{}),e[28]=ce):ce=e[28],se=ce;break e}if(M){let ce;e[29]===Symbol.for("react.memo_cache_sentinel")?(ce=p.jsx(ku,{className:"size-4 text-muted-foreground"}),e[29]=ce):ce=e[29],se=ce;break e}const K=C?.icon;if(K){let ce;e[30]!==K?(ce=p.jsx(K,{className:"size-4 text-muted-foreground"}),e[30]=K,e[31]=ce):ce=e[31],se=ce;break e}let ie;e[32]===Symbol.for("react.memo_cache_sentinel")?(ie=p.jsx(Wp,{className:"size-4 text-muted-foreground"}),e[32]=ie):ie=e[32],se=ie}let ae;e[33]!==r||e[34]!==l?(ae=p.jsx(gS,{annotations:r,toolMeta:l}),e[33]=r,e[34]=l,e[35]=ae):ae=e[35];let de;e[36]!==s||e[37]!==i?(de=p.jsx(yS,{latency:s,outputBytes:i}),e[36]=s,e[37]=i,e[38]=de):de=e[38];let Ie;e[39]!==ae||e[40]!==de?(Ie=p.jsxs(p.Fragment,{children:[ae,de]}),e[39]=ae,e[40]=de,e[41]=Ie):Ie=e[41];const Fe=V||null;let Ee;e[42]!==ne||e[43]!==w||e[44]!==J||e[45]!==s||e[46]!==ye||e[47]!==Ie||e[48]!==Fe||e[49]!==se?(Ee=p.jsx(ee,{icon:se,iconDestructive:J,trailing:Ie,title:w,latency:s,summary:ye,state:ne,detail:Fe}),e[42]=ne,e[43]=w,e[44]=J,e[45]=s,e[46]=ye,e[47]=Ie,e[48]=Fe,e[49]=se,e[50]=Ee):Ee=e[50];let Se;e[51]!==A||e[52]!==I?(Se=A&&p.jsx("div",{className:"flex justify-end mt-1.5 mb-1",children:p.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground rounded-md [@media(hover:hover)]:hover:bg-accent/50 [@media(hover:hover)]:hover:text-foreground transition-colors",children:[p.jsx(Up,{className:"size-3.5"}),"Open in panel"]})}),e[51]=A,e[52]=I,e[53]=Se):Se=e[53];let ve;e[54]!==A||e[55]!==d||e[56]!==y||e[57]!==w||e[58]!==B||e[59]!==$||e[60]!==M||e[61]!==k||e[62]!==f.id||e[63]!==f.slug||e[64]!==t.input||e[65]!==t.output||e[66]!==j||e[67]!==v||e[68]!==N?(ve=M&&N&&y&&f?.id&&p.jsx(p.Fragment,{children:p.jsx(su,{fallback:K=>{const{resetError:ie}=K;return p.jsxs("div",{className:"mt-2 flex items-center gap-2 px-3 py-2.5 border border-dashed border-destructive/30 bg-destructive/5 rounded-lg",children:[p.jsx(Mu,{size:16,className:"shrink-0 text-destructive"}),p.jsxs("span",{className:"flex-1 text-xs text-destructive font-medium",children:["Failed to load"," ",p.jsx("span",{className:"font-mono",children:w})," app"]}),p.jsxs(mt,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1.5 shrink-0",onClick:ie,children:[p.jsx(iu,{className:"size-3.5"}),"Retry"]})]})},children:p.jsx(E.Suspense,{fallback:p.jsx("div",{className:"mt-2 flex items-center justify-center h-12 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[p.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),p.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),children:p.jsx(vS,{uiResourceUri:N,connectionId:y,orgId:f.id,orgSlug:f.slug,toolName:v,toolInput:t.input,toolResult:t.output,toolMeta:k,onMessage:B,onUpdateModelContext:j&&d?K=>d.setAppContext(j,K):void 0,onTeardown:j&&d?()=>d.clearAppContext(j):void 0,onRequestDisplayMode:A?$:void 0})})})}),e[54]=A,e[55]=d,e[56]=y,e[57]=w,e[58]=B,e[59]=$,e[60]=M,e[61]=k,e[62]=f.id,e[63]=f.slug,e[64]=t.input,e[65]=t.output,e[66]=j,e[67]=v,e[68]=N,e[69]=ve):ve=e[69];let Le;return e[70]!==Ee||e[71]!==Se||e[72]!==ve?(Le=p.jsxs("div",{children:[Ee,Se,ve]}),e[70]=Ee,e[71]=Se,e[72]=ve,e[73]=Le):Le=e[73],Le}function jh(n){return typeof n=="object"&&n!=null&&"type"in n&&n.type==="mcpToolCall"}function kS(n){if(n!=null)return jh(n)?n.arguments??void 0:n}function SS(n){if(n==null)return;if(jh(n)&&n.result!=null)return n.result;if(typeof n=="object"&&"content"in n&&Array.isArray(n.content)){const t=n.content;if(t.length>0&&typeof t[0]=="object"&&t[0]!=null&&"type"in t[0])return n}const e=typeof n=="string"?n:JSON.stringify(n);return{structuredContent:typeof n=="object"&&!Array.isArray(n)?n:void 0,content:[{type:"text",text:e}]}}function vS(n){const e=L.c(27),{uiResourceUri:t,connectionId:r,orgId:s,orgSlug:i,toolName:o,toolInput:l,toolResult:a,toolMeta:c,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h}=n;let m;e[0]!==r||e[1]!==s||e[2]!==i?(m={connectionId:r,orgId:s,orgSlug:i},e[0]=r,e[1]=s,e[2]=i,e[3]=m):m=e[3];const g=qo(m);let x;e[4]===Symbol.for("react.memo_cache_sentinel")?(x={type:"object"},e[4]=x):x=e[4];let y;e[5]!==c?(y=c!=null&&{_meta:c},e[5]=c,e[6]=y):y=e[6];let b;e[7]!==y||e[8]!==o?(b={name:o,inputSchema:x,...y},e[7]=y,e[8]=o,e[9]=b):b=e[9];const k=b;let S;e[10]!==k?(S={tool:k},e[10]=k,e[11]=S):S=e[11];let v;e[12]!==l?(v=kS(l),e[12]=l,e[13]=v):v=e[13];let C;e[14]!==a?(C=SS(a),e[14]=a,e[15]=C):C=e[15];let w;return e[16]!==g||e[17]!==u||e[18]!==h||e[19]!==f||e[20]!==d||e[21]!==s||e[22]!==S||e[23]!==v||e[24]!==C||e[25]!==t?(w=p.jsx("div",{className:"mt-2 border border-border/75 rounded-lg overflow-hidden p-3",children:p.jsx(Qp,{resourceURI:t,orgId:s,toolInfo:S,toolInput:v,toolResult:C,client:g,onMessage:u,onUpdateModelContext:d,onTeardown:f,onRequestDisplayMode:h})}),e[16]=g,e[17]=u,e[18]=h,e[19]=f,e[20]=d,e[21]=s,e[22]=S,e[23]=v,e[24]=C,e[25]=t,e[26]=w):w=e[26],w}const Kc="mesh-storage://";function yi(n){return n.startsWith(Kc)?n.slice(Kc.length):null}function Ih(n,e){const t=yi(n);return t!==null?`/api/${e}/files/${t}`:n}function wS(n){if(!n?.usage)return null;const e=n.usage.inputTokens??0,t=n.usage.outputTokens??0,r=e+t;return r?{inputTokens:e,outputTokens:t,reasoningTokens:0,totalTokens:r,cost:0,cacheReadTokens:0,cacheWriteTokens:0}:null}function CS(n){const e=L.c(13),{uri:t,orgSlug:r}=n;let s;e[0]!==r||e[1]!==t?(s=Ih(t,r),e[0]=r,e[1]=t,e[2]=s):s=e[2];const i=s;let o;e[3]!==t?(o=yi(t)!==null?t.slice(t.lastIndexOf("/")+1):"reference",e[3]=t,e[4]=o):o=e[4];const l=o;let a;e[5]!==l?(a=p.jsx(pn,{asChild:!0,children:p.jsx("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 rounded bg-muted text-muted-foreground text-xs cursor-default select-none",children:l})}),e[5]=l,e[6]=a):a=e[6];let c;e[7]!==l||e[8]!==i?(c=p.jsx(mn,{side:"top",className:"max-w-sm p-1.5",children:p.jsx("img",{src:i,alt:l,className:"max-w-full max-h-64 object-contain rounded"})}),e[7]=l,e[8]=i,e[9]=c):c=e[9];let u;return e[10]!==a||e[11]!==c?(u=p.jsxs(gn,{children:[a,c]}),e[10]=a,e[11]=c,e[12]=u):u=e[12],u}function TS(n){const e=L.c(76),{part:t,latency:r}=n,s=Uo();let i;e[0]!==t.state?(i=ct(t.state),e[0]=t.state,e[1]=i):i=e[1];const o=i,l=t.input,a=t.output,c=a?.images;let u;e[2]!==a?(u=wS(a),e[2]=a,e[3]=u):u=e[3];const d=u,f=a?.model;let h,m,g,x,y,b,k,S,v,C,w,T;if(e[4]!==c||e[5]!==l||e[6]!==r||e[7]!==f||e[8]!==s||e[9]!==t||e[10]!==a||e[11]!==o||e[12]!==d){y=Symbol.for("react.early_return_sentinel");e:{const R=Array.isArray(l?.referenceImages)?l.referenceImages.filter(NS):void 0;let I;e[25]!==r?(I=r!=null&&r>0?p.jsx("span",{className:"text-[11px] font-mono tabular-nums text-muted-foreground/60",children:Ut(r)}):null,e[25]=r,e[26]=I):I=e[26];const _=I;if(o==="loading"){let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=p.jsx(_r,{size:14}),e[27]=$):$=e[27];let z;e[28]!==l?(z=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[28]=l,e[29]=z):z=e[29];let B;e[30]!==z?(B=p.jsx(ee,{icon:$,title:"Generating image",summary:z,state:"loading"}),e[30]=z,e[31]=B):B=e[31],y=B;break e}if(a?.background){let $;e[32]===Symbol.for("react.memo_cache_sentinel")?($=p.jsx(_r,{size:14}),e[32]=$):$=e[32];let z;e[33]!==l?(z=l?.prompt?`"${l.prompt.slice(0,80)}…"`:void 0,e[33]=l,e[34]=z):z=e[34];let B;e[35]!==z?(B=p.jsx(ee,{icon:$,title:"Image queued — generating in the background",summary:z,state:"idle"}),e[35]=z,e[36]=B):B=e[36],y=B;break e}if(o==="error"||!c||c.length===0){let $;e[37]!==t||e[38]!==o?($=o==="error"?xi(t):void 0,e[37]=t,e[38]=o,e[39]=$):$=e[39];const z=$;let B="";l!==void 0&&(B=`# Input
171
171
  `+Js(l)),z?(B&&(B=B+`
172
172
 
173
173
  `),B=B+(`# Error
174
174
  `+z)):a!==void 0&&(B&&(B=B+`
175
175
 
176
176
  `),B=B+(`# Output
177
- `+Js(a)));let q;e[40]===Symbol.for("react.memo_cache_sentinel")?(q=p.jsx(_r,{size:14}),e[40]=q):q=e[40];const J=o==="error"?"Failed":"No images generated",U=o==="error"?"error":"idle",X=B||null;let te;e[41]!==_||e[42]!==J||e[43]!==U||e[44]!==X||e[45]!==d?(te=p.jsx(ee,{icon:q,title:"Image generation",summary:J,state:U,usage:d,trailing:_,detail:X}),e[41]=_,e[42]=J,e[43]=U,e[44]=X,e[45]=d,e[46]=te):te=e[46],y=te;break e}x="flex flex-col gap-2",h=ee,e[47]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(_r,{size:14,className:"text-pink-500"}),e[47]=v):v=e[47],C="Generated image",w=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=R&&R.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:"}),R.map(($,z)=>{const B=$.uri??$.url;return p.jsx(CS,{uri:B,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]=o,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]=C,e[23]=w,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],C=e[22],w=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]!==C||e[60]!==w||e[61]!==T?(M=p.jsx(h,{icon:v,title:C,summary:w,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]=C,e[60]=w,e[61]=T,e[62]=M):M=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let R;e[67]!==l?.prompt||e[68]!==s?(R=(I,_)=>{const $=I.uri??I.url;if(!$)return null;const z=Ih($,s.slug);return p.jsx(Tu,{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]=R):R=e[69],j=c.map(R),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let O;e[70]!==j?(O=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=O):O=e[71];let A;return e[72]!==x||e[73]!==M||e[74]!==O?(A=p.jsxs("div",{className:x,children:[M,O]}),e[72]=x,e[73]=M,e[74]=O,e[75]=A):A=e[75],A}function NS(n){return n.uri??n.url}function MS(n,e){const t=yi(n);return t!==null?`/api/${e}/files/${t}`:n}function ES(n){const e=L.c(26),{part:t,latency:r}=n,s=Uo(),i=ct(t.state),o=t.input,l=t.output,a=l?.image?.uri,c=l?.url??o?.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:Ut(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(i==="loading"){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ir,{size:14}),e[2]=v):v=e[2];let C;return e[3]!==c?(C=p.jsx(ee,{icon:v,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=C):C=e[4],C}if(i==="error"||l?.success===!1||!a){let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ir,{size:14}),e[5]=v):v=e[5];const C=l?.error??"Failed";let w;return e[6]!==d||e[7]!==C?(w=p.jsx(ee,{icon:v,title:"Take screenshot",summary:C,state:"error",trailing:d}),e[6]=d,e[7]=C,e[8]=w):w=e[8],w}let f;e[9]!==s.slug||e[10]!==a?(f=MS(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(ir,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(ee,{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(Tu,{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 AS(n,e){const t=yi(n);return t!==null?`/api/${e}/files/${t}`:n}function jS(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:Ou(s),cacheReadTokens:0,cacheWriteTokens:0}}function IS(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function OS(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function RS(n){const e=L.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=IS(t.url),e[0]=t.url,e[1]=s):s=e[1];const i=s;let o;e[2]!==t.url?(o=OS(t.url),e[2]=t.url,e[3]=o):o=e[3];const l=o,a=t.title||i;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:DS}),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(ju,{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 DS(n){n.target.style.display="none"}function PS(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,i=e[s];return i?`[\\[${r}\\]](${i.url})`:t})}const Qi=5;function LS(n){const e=L.c(12),{citations:t}=n,[r,s]=E.useState(!1),i=t.length>Qi;let o;e[0]!==t||e[1]!==r?(o=r?t:t.slice(0,Qi),e[0]=t,e[1]=r,e[2]=o):o=e[2];const l=o;let a;e[3]!==l?(a=l.map($S),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==i?(c=i&&p.jsx("button",{type:"button",onClick:()=>s(_S),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-Qi} more`}),e[5]=t.length,e[6]=r,e[7]=i,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 _S(n){return!n}function $S(n,e){return p.jsx(RS,{citation:n,index:e},n.url)}function zS(n){const e=L.c(51),{part:t,latency:r,streamingText:s}=n,i=Uo();let o;e[0]!==t.state?(o=ct(t.state),e[0]=t.state,e[1]=o):o=e[1];const l=o,a=t.input,c=t.output;let u,d,f;e[2]!==i||e[3]!==c?(u=c?.uri?AS(c.uri,i.slug):void 0,f=jr,d=nt.webSearchBlob(u??""),e[2]=i,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 U=await fetch(u);if(!U.ok)throw new Error(`Failed to fetch: ${U.status}`);return U.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=jS(c),e[13]=c,e[14]=S):S=e[14];const v=S,C=c?.content??x??s;let w;e[15]!==k||e[16]!==C?(w=C&&k?.length?PS(C,k):C,e[15]=k,e[16]=C,e[17]=w):w=e[17];const T=w;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:Ut(r)}):null,e[18]=r,e[19]=N):N=e[19];const M=N;if(l==="error"){let U;e[20]===Symbol.for("react.memo_cache_sentinel")?(U=p.jsx(ss,{size:14}),e[20]=U):U=e[20];let X;return e[21]!==M||e[22]!==v?(X=p.jsx(ee,{icon:U,title:"Web search",summary:"Failed",state:"error",usage:v,trailing:M}),e[21]=M,e[22]=v,e[23]=X):X=e[23],X}const j=y?"animate-pulse":"text-blue-500";let O;e[24]!==j?(O=Z(j),e[24]=j,e[25]=O):O=e[25];let A;e[26]!==O?(A=p.jsx(ss,{size:14,className:O}),e[26]=O,e[27]=A):A=e[27];const R=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 $;e[32]!==a?($=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]=$):$=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(Zo,{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 B;e[37]!==k?(B=k&&k.length>0&&p.jsx(LS,{citations:k}),e[37]=k,e[38]=B):B=e[38];let q;e[39]!==$||e[40]!==z||e[41]!==B?(q=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[$,z,B]}),e[39]=$,e[40]=z,e[41]=B,e[42]=q):q=e[42];let J;return e[43]!==M||e[44]!==A||e[45]!==R||e[46]!==I||e[47]!==_||e[48]!==q||e[49]!==v?(J=p.jsx(ee,{icon:A,title:R,summary:I,state:_,usage:v,trailing:M,defaultOpen:!0,children:q}),e[43]=M,e[44]=A,e[45]=R,e[46]=I,e[47]=_,e[48]=q,e[49]=v,e[50]=J):J=e[50],J}function BS(n){const e=L.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,i=t.state==="output-error"||t.state==="output-denied",o=t.state==="output-denied";let l;e[2]!==o||e[3]!==t?(l=o?"Skipped":t.state==="output-error"?xi(t)??"Error":t.output?.response??"",e[2]=o,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(Pp,{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]!==i?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:Z("text-[14px] leading-snug",i?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=i,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 Oh=E.createContext(new Map);function ET(n){const e=L.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const o of t){const l=o.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(o):s.set(l,[o])}e[0]=t,e[1]=s}else s=e[1];let i;return e[2]!==s||e[3]!==r?(i=p.jsx(Oh.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=i):i=e[4],i}function FS(n){const e=L.c(3),t=E.useContext(Oh);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 VS(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:i,value:o}=await t.read();if(i)break;s+=r.decode(o,{stream:!0});let l;for(;(l=s.indexOf(`
177
+ `+Js(a)));let q;e[40]===Symbol.for("react.memo_cache_sentinel")?(q=p.jsx(_r,{size:14}),e[40]=q):q=e[40];const J=o==="error"?"Failed":"No images generated",U=o==="error"?"error":"idle",X=B||null;let te;e[41]!==_||e[42]!==J||e[43]!==U||e[44]!==X||e[45]!==d?(te=p.jsx(ee,{icon:q,title:"Image generation",summary:J,state:U,usage:d,trailing:_,detail:X}),e[41]=_,e[42]=J,e[43]=U,e[44]=X,e[45]=d,e[46]=te):te=e[46],y=te;break e}x="flex flex-col gap-2",h=ee,e[47]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(_r,{size:14,className:"text-pink-500"}),e[47]=v):v=e[47],C="Generated image",w=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=R&&R.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:"}),R.map(($,z)=>{const B=$.uri??$.url;return p.jsx(CS,{uri:B,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]=o,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]=C,e[23]=w,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],C=e[22],w=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]!==C||e[60]!==w||e[61]!==T?(M=p.jsx(h,{icon:v,title:C,summary:w,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]=C,e[60]=w,e[61]=T,e[62]=M):M=e[62];let j;if(e[63]!==c||e[64]!==l?.prompt||e[65]!==s){let R;e[67]!==l?.prompt||e[68]!==s?(R=(I,_)=>{const $=I.uri??I.url;if(!$)return null;const z=Ih($,s.slug);return p.jsx(Tu,{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]=R):R=e[69],j=c.map(R),e[63]=c,e[64]=l?.prompt,e[65]=s,e[66]=j}else j=e[66];let O;e[70]!==j?(O=p.jsx("div",{className:"flex flex-wrap gap-2",children:j}),e[70]=j,e[71]=O):O=e[71];let A;return e[72]!==x||e[73]!==M||e[74]!==O?(A=p.jsxs("div",{className:x,children:[M,O]}),e[72]=x,e[73]=M,e[74]=O,e[75]=A):A=e[75],A}function NS(n){return n.uri??n.url}function MS(n,e){const t=yi(n);return t!==null?`/api/${e}/files/${t}`:n}function ES(n){const e=L.c(26),{part:t,latency:r}=n,s=Uo(),i=ct(t.state),o=t.input,l=t.output,a=l?.image?.uri,c=l?.url??o?.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:Ut(r)}):null,e[0]=r,e[1]=u):u=e[1];const d=u;if(i==="loading"){let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ir,{size:14}),e[2]=v):v=e[2];let C;return e[3]!==c?(C=p.jsx(ee,{icon:v,title:"Taking screenshot",summary:c,state:"loading"}),e[3]=c,e[4]=C):C=e[4],C}if(i==="error"||l?.success===!1||!a){let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=p.jsx(ir,{size:14}),e[5]=v):v=e[5];const C=l?.error??"Failed";let w;return e[6]!==d||e[7]!==C?(w=p.jsx(ee,{icon:v,title:"Take screenshot",summary:C,state:"error",trailing:d}),e[6]=d,e[7]=C,e[8]=w):w=e[8],w}let f;e[9]!==s.slug||e[10]!==a?(f=MS(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(ir,{size:14,className:"text-blue-500"}),e[12]=m):m=e[12];let g;e[13]!==d||e[14]!==c?(g=p.jsx(ee,{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(Tu,{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 AS(n,e){const t=yi(n);return t!==null?`/api/${e}/files/${t}`:n}function jS(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:Ou(s),cacheReadTokens:0,cacheWriteTokens:0}}function IS(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return n}}function OS(n){try{return`${new URL(n).origin}/favicon.ico`}catch{return""}}function RS(n){const e=L.c(16),{citation:t,index:r}=n;let s;e[0]!==t.url?(s=IS(t.url),e[0]=t.url,e[1]=s):s=e[1];const i=s;let o;e[2]!==t.url?(o=OS(t.url),e[2]=t.url,e[3]=o):o=e[3];const l=o,a=t.title||i;let c;e[4]!==l?(c=p.jsx("img",{src:l,alt:"",className:"size-3.5 rounded-sm shrink-0",onError:DS}),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(ju,{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 DS(n){n.target.style.display="none"}function PS(n,e){return n.replace(/\[(\d+)\]/g,(t,r)=>{const s=parseInt(r,10)-1,i=e[s];return i?`[\\[${r}\\]](${i.url})`:t})}const Qi=5;function LS(n){const e=L.c(12),{citations:t}=n,[r,s]=E.useState(!1),i=t.length>Qi;let o;e[0]!==t||e[1]!==r?(o=r?t:t.slice(0,Qi),e[0]=t,e[1]=r,e[2]=o):o=e[2];const l=o;let a;e[3]!==l?(a=l.map($S),e[3]=l,e[4]=a):a=e[4];let c;e[5]!==t.length||e[6]!==r||e[7]!==i?(c=i&&p.jsx("button",{type:"button",onClick:()=>s(_S),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-Qi} more`}),e[5]=t.length,e[6]=r,e[7]=i,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 _S(n){return!n}function $S(n,e){return p.jsx(RS,{citation:n,index:e},n.url)}function zS(n){const e=L.c(51),{part:t,latency:r,streamingText:s}=n,i=Uo();let o;e[0]!==t.state?(o=ct(t.state),e[0]=t.state,e[1]=o):o=e[1];const l=o,a=t.input,c=t.output;let u,d,f;e[2]!==i||e[3]!==c?(u=c?.uri?AS(c.uri,i.slug):void 0,f=jr,d=nt.webSearchBlob(u??""),e[2]=i,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 U=await fetch(u);if(!U.ok)throw new Error(`Failed to fetch: ${U.status}`);return U.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=jS(c),e[13]=c,e[14]=S):S=e[14];const v=S,C=c?.content??x??s;let w;e[15]!==k||e[16]!==C?(w=C&&k?.length?PS(C,k):C,e[15]=k,e[16]=C,e[17]=w):w=e[17];const T=w;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:Ut(r)}):null,e[18]=r,e[19]=N):N=e[19];const M=N;if(l==="error"){let U;e[20]===Symbol.for("react.memo_cache_sentinel")?(U=p.jsx(ss,{size:14}),e[20]=U):U=e[20];let X;return e[21]!==M||e[22]!==v?(X=p.jsx(ee,{icon:U,title:"Web search",summary:"Failed",state:"error",usage:v,trailing:M}),e[21]=M,e[22]=v,e[23]=X):X=e[23],X}const j=y?"animate-pulse":"text-blue-500";let O;e[24]!==j?(O=Z(j),e[24]=j,e[25]=O):O=e[25];let A;e[26]!==O?(A=p.jsx(ss,{size:14,className:O}),e[26]=O,e[27]=A):A=e[27];const R=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 $;e[32]!==a?($=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]=$):$=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(Zo,{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 B;e[37]!==k?(B=k&&k.length>0&&p.jsx(LS,{citations:k}),e[37]=k,e[38]=B):B=e[38];let q;e[39]!==$||e[40]!==z||e[41]!==B?(q=p.jsxs("div",{className:"pl-6 pb-3 flex flex-col gap-1 min-w-0",children:[$,z,B]}),e[39]=$,e[40]=z,e[41]=B,e[42]=q):q=e[42];let J;return e[43]!==M||e[44]!==A||e[45]!==R||e[46]!==I||e[47]!==_||e[48]!==q||e[49]!==v?(J=p.jsx(ee,{icon:A,title:R,summary:I,state:_,usage:v,trailing:M,defaultOpen:!0,children:q}),e[43]=M,e[44]=A,e[45]=R,e[46]=I,e[47]=_,e[48]=q,e[49]=v,e[50]=J):J=e[50],J}function BS(n){const e=L.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,i=t.state==="output-error"||t.state==="output-denied",o=t.state==="output-denied";let l;e[2]!==o||e[3]!==t?(l=o?"Skipped":t.state==="output-error"?xi(t)??"Error":t.output?.response??"",e[2]=o,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(Pp,{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]!==i?(d=a&&p.jsx("div",{className:"ml-6 pl-2 border-l border-border/50",children:p.jsx("span",{className:Z("text-[14px] leading-snug",i?"text-muted-foreground/50 italic":"text-foreground/70"),children:a})}),e[8]=a,e[9]=i,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 Oh=E.createContext(new Map);function AT(n){const e=L.c(5),{messages:t,children:r}=n;let s;if(e[0]!==t){s=new Map;for(const o of t){const l=o.metadata?.subtaskJobId;if(!l)continue;const a=s.get(l);a?a.push(o):s.set(l,[o])}e[0]=t,e[1]=s}else s=e[1];let i;return e[2]!==s||e[3]!==r?(i=p.jsx(Oh.Provider,{value:s,children:r}),e[2]=s,e[3]=r,e[4]=i):i=e[4],i}function FS(n){const e=L.c(3),t=E.useContext(Oh);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 VS(n){return new ReadableStream({async start(e){const t=n.getReader(),r=new TextDecoder;let s="";try{for(;;){const{done:i,value:o}=await t.read();if(i)break;s+=r.decode(o,{stream:!0});let l;for(;(l=s.indexOf(`
178
178
 
179
179
  `))!==-1;){const a=s.slice(0,l);s=s.slice(l+2);const c=a.split(`
180
180
  `).filter(u=>u.startsWith("data:")).map(u=>u.slice(5).trim()).join(`
181
- `);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{t.releaseLock(),e.close()}}})}function HS(n){const{orgSlug:e,threadId:t,jobId:r,enabled:s}=n,[i,o]=E.useState([]),[l,a]=E.useState(!1);return E.useEffect(()=>{if(!s||!r)return;const c=new AbortController;return o([]),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 im({stream:om(VS(u.body),void 0)})){if(c.signal.aborted)return;o([d])}}catch{}finally{c.signal.aborted||a(!1)}})(),()=>c.abort()},[s,r,t,e]),{messages:i,streaming:l}}function WS(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.]
181
+ `);if(c)try{e.enqueue(JSON.parse(c))}catch{}}}}finally{t.releaseLock(),e.close()}}})}function HS(n){const{orgSlug:e,threadId:t,jobId:r,enabled:s}=n,[i,o]=E.useState([]),[l,a]=E.useState(!1);return E.useEffect(()=>{if(!s||!r)return;const c=new AbortController;return o([]),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 sm({stream:im(VS(u.body),void 0)})){if(c.signal.aborted)return;o([d])}}catch{}finally{c.signal.aborted||a(!1)}})(),()=>c.abort()},[s,r,t,e]),{messages:i,streaming:l}}function WS(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.]
182
182
 
183
183
  `:"")+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 hS(n)}function Rh(n){return!!n&&typeof n=="object"&&n.background===!0}function Dh({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,i=n.state==="output-error",o=ct(n.state,"preliminary"in n?n.preliminary:!1),l=o==="approval"?"idle":o,a=t?"Starting subtask...":r?"Subtask running...":s?"Subtask completed":i?"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 Xl(n){const e=L.c(45),{icon:t,title:r,summary:s,state:i,usage:o,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=i==="loading",m=i==="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=Z("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=Z("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 C;e[11]!==v?(C=Z("shrink-0 text-[14px] font-normal",v),e[11]=v,e[12]=C):C=e[12];let w;e[13]!==C||e[14]!==r?(w=p.jsx("span",{className:C,children:r}),e[13]=C,e[14]=r,e[15]=w):w=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(km,{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]!==o?(M=p.jsx(Ch,{usage:o}),e[19]=o,e[20]=M):M=e[20];let j;e[21]!==w||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,w,T,N,M]}),e[21]=w,e[22]=T,e[23]=M,e[24]=g,e[25]=y,e[26]=S,e[27]=j):j=e[27];let O;e[28]!==t?(O=p.jsx("span",{className:"flex items-center [&>svg]:size-4 [&>svg]:text-muted-foreground/75",children:t}),e[28]=t,e[29]=O):O=e[29];let A;e[30]!==O||e[31]!==r?(A=p.jsx(au,{className:"px-4 py-3 border-b border-border shrink-0",children:p.jsxs(cu,{className:"flex items-center gap-2 text-sm font-medium",children:[O,r]})}),e[30]=O,e[31]=r,e[32]=A):A=e[32];let R;e[33]!==a?(R=p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-4",children:a}),e[33]=a,e[34]=R):R=e[34];let I;e[35]!==A||e[36]!==R?(I=p.jsxs(Ko,{side:"right",className:"w-full sm:max-w-2xl flex flex-col p-0 gap-0",children:[A,R]}),e[35]=A,e[36]=R,e[37]=I):I=e[37];let _;e[38]!==c||e[39]!==f||e[40]!==I?(_=p.jsx(Jo,{open:c,onOpenChange:f,children:I}),e[38]=c,e[39]=f,e[40]=I,e[41]=_):_=e[41];let $;return e[42]!==j||e[43]!==_?($=p.jsxs(p.Fragment,{children:[j,_]}),e[42]=j,e[43]=_,e[44]=$):$=e[44],$}function Ph(n){const e=L.c(9),{part:t}=n,r=t.state==="output-error",s=t.input?.prompt??"No prompt provided";let i;if(e[0]!==r||e[1]!==t||e[2]!==s){const o=r?xi(t):WS(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],i=p.jsxs("div",{className:"flex flex-col gap-4",children:[a,p.jsxs("section",{children:[u,o.trim()?p.jsx(Zo,{id:`${t.toolCallId}-result`,text:o}):p.jsx("p",{className:"text-[13px] text-muted-foreground/60 italic",children:"Running…"})]})]}),e[0]=r,e[1]=t,e[2]=s,e[3]=i}else i=e[3];return i}const Zi=600;function US(n){const e=L.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 i=s;let o;if(e[3]!==t.input){const f=t.input!=null?JSON.stringify(t.input):"";o=f.length>80?`${f.slice(0,80)}…`:f||void 0,e[3]=t.input,e[4]=o}else o=e[4];const l=o;let a;if(e[5]!==t.input){const f=t.input!=null?JSON.stringify(t.input,null,2):null;a=f&&f.length>Zi?`${f.slice(0,Zi)}
184
- … (${f.length-Zi} 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(bu,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==i||e[10]!==l?(d=p.jsx(ee,{icon:u,title:i,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=i,e[10]=l,e[11]=d):d=e[11],d}function qS(n){const e=L.c(12),{jobId:t,prompt:r,items:s,streaming:i}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=o):o=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[o,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]!==i?(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(pi,{id:`${t}-sub-${f}`,part:d,animate:i},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx(US,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=i,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 Lh(n){const e=L.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=nm(),{org:i}=Mt(),[o,l]=E.useState(!1),a=FS(r);let c;e[0]!==r||e[1]!==o||e[2]!==i.slug||e[3]!==s?(c={orgSlug:i.slug,threadId:s,jobId:r,enabled:o},e[0]=r,e[1]=o,e[2]=i.slug,e[3]=s,e[4]=c):c=e[4];const u=HS(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(JS),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(KS),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(Gt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(tl,{})}),e[11]=S):S=e[11];const v=k?"loading":"idle",C=u.streaming||k;let w;e[12]!==g||e[13]!==r||e[14]!==x||e[15]!==C?(w=p.jsx(qS,{jobId:r,prompt:x,items:g,streaming:C}),e[12]=g,e[13]=r,e[14]=x,e[15]=C,e[16]=w):w=e[16];let T;return e[17]!==b||e[18]!==v||e[19]!==w?(T=p.jsx(Xl,{icon:S,title:"Subtask",summary:b,state:v,onOpenChange:l,children:w}),e[17]=b,e[18]=v,e[19]=w,e[20]=T):T=e[20],T}function KS(n){return n.parts??[]}function JS(n){return n.parts??[]}function GS(n){const e=L.c(13);if(Rh(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Lh,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=Dh(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:i,state:o}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(Gt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(tl,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(Ph,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==o||e[9]!==s||e[10]!==a||e[11]!==i?(c=p.jsx(Xl,{icon:l,title:r,summary:s,state:o,usage:i,children:a}),e[7]=r,e[8]=o,e[9]=s,e[10]=a,e[11]=i,e[12]=c):c=e[12],c}function XS(n){const e=L.c(17),t=lu(n.part.input?.agent_id);if(Rh(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Lh,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=Dh(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:i,usage:o,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(tl,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(Gt,{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(Ph,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==i||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==o?(m=p.jsx(Xl,{icon:d,title:f,summary:i,state:l,usage:o,children:h}),e[10]=l,e[11]=i,e[12]=d,e[13]=f,e[14]=h,e[15]=o,e[16]=m):m=e[16],m}function YS(n){const e=L.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",i=t.output?.approved===!0;let o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(ro,{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]=o,e[1]=l):(o=e[0],l=e[1]);let a;e[2]!==i?(a=i&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 bg-green-500/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(Yo,{size:12}),"Approved"]}),e[2]=i,e[3]=a):a=e[3];let c;e[4]!==i||e[5]!==t.state?(c=!i&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=i,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:[o,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(pi,{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 Yl={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function QS(n){return n.startsWith("http")?n:`https://${n}`}function Jc(n){const e=L.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 ZS(n){const e=L.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 i;e[2]!==t?(i=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=i):i=e[3];let o;e[4]!==r?(o=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=o):o=e[5];let l;e[6]!==i||e[7]!==o?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[i,o]}),e[6]=i,e[7]=o,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 ev(n){const e=L.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 i;e[2]!==t?(i=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=i):i=e[3];let o;e[4]!==r?(o={fontFamily:r},e[4]=r,e[5]=o):o=e[5];let l;e[6]!==r||e[7]!==o?(l=p.jsx("span",{className:"text-sm text-foreground",style:o,children:r}),e[6]=r,e[7]=o,e[8]=l):l=e[8];let a;e[9]!==i||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[i,l]}),e[9]=i,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 tv(n){const e=L.c(3),{logo:t,favicon:r,name:s}=n,i=t??r;if(!i)return null;const o=s?`${s} logo`:"";let l;return e[0]!==i||e[1]!==o?(l=p.jsx("img",{src:i,alt:o,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:nv}),e[0]=i,e[1]=o,e[2]=l):l=e[2],l}function nv(n){n.target.style.display="none"}function _h(n){const e=L.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(sv),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let i;return e[2]!==s?(i=p.jsx("div",{className:"flex h-1.5",children:s.map(rv)}),e[2]=s,e[3]=i):i=e[3],i}function rv(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${Yl[e]}: ${t}`,"aria-hidden":!0},e)}function sv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function $h(n){const e=L.c(36),{logo:t,favicon:r,name:s,domain:i,overview:o,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(av):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(lv):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(_h,{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(tv,{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(Eu,{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]!==i?(b=i&&p.jsxs("a",{href:QS(i),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[i,p.jsx(ju,{className:"size-3 shrink-0"})]}),e[14]=i,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]!==o?(v=o&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:o}),e[22]=o,e[23]=v):v=e[23];let C;e[24]!==f?(C=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Jc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(ov)})]}),e[24]=f,e[25]=C):C=e[25];let w;e[26]!==m?(w=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Jc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(iv)})]}),e[26]=m,e[27]=w):w=e[27];let T;e[28]!==C||e[29]!==w||e[30]!==S||e[31]!==v?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[S,v,C,w]}),e[28]=C,e[29]=w,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 iv(n){const[e,t]=n;return p.jsx(ev,{role:e,family:t},e)}function ov(n){const[e,t]=n;return p.jsx(ZS,{name:Yl[e],value:t},e)}function lv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function av(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function cv(n){const e=L.c(29),{part:t,latency:r}=n,s=ct(t.state);let i;e[0]!==t.output?(i=Jn(t.output),e[0]=t.output,e[1]=i):i=e[1];const o=i,l=s==="loading",a=s==="error"||o&&o.success===!1;if(l){const w=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(pt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=w?.domain?`from ${w.domain}`:void 0;let M;return e[3]!==N?(M=p.jsx(ee,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=M):M=e[4],M}if(a){let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(pt,{}),e[5]=w):w=e[5];const T=o?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx($e,{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(ee,{icon:w,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(pt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=o?.name?`Brand set: ${o.name}`:"Brand context set",d=o?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx($e,{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(ee,{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=o?.logo,g=o?.favicon,x=o?.name,y=o?.domain,b=o?.overview,k=o?.colors,S=o?.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($h,{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 C;return e[26]!==v||e[27]!==h?(C=p.jsxs(p.Fragment,{children:[h,v]}),e[26]=v,e[27]=h,e[28]=C):C=e[28],C}function uv(n){const e=L.c(27),{part:t,latency:r}=n,s=ct(t.state);let i;e[0]!==t.output?(i=Jn(t.output),e[0]=t.output,e[1]=i):i=e[1];const o=i,l=s==="loading",a=s==="error"||o&&o.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(ee,{icon:p.jsx(pt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!o){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(pt,{}),e[3]=g):g=e[3];let x;e[4]!==r?(x=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[4]=r,e[5]=x):x=e[5];let y;return e[6]!==x?(y=p.jsx(ee,{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(pt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=o.name?`Brand · ${o.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==o.domain||e[12]!==u||e[13]!==d?(f=p.jsx(ee,{icon:c,title:u,summary:o.domain,state:"idle",trailing:d}),e[11]=o.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==o.colors||e[16]!==o.domain||e[17]!==o.favicon||e[18]!==o.fonts||e[19]!==o.isDefault||e[20]!==o.logo||e[21]!==o.name||e[22]!==o.overview?(h=p.jsx($h,{logo:o.logo,favicon:o.favicon,name:o.name,domain:o.domain,overview:o.overview,colors:o.colors,fonts:o.fonts,showDefaultBadge:!0,isDefault:o.isDefault}),e[15]=o.colors,e[16]=o.domain,e[17]=o.favicon,e[18]=o.fonts,e[19]=o.isDefault,e[20]=o.logo,e[21]=o.name,e[22]=o.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 dv(n){const e=L.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=ct(t.state),e[0]=t.state,e[1]=s):s=e[1];const i=s;let o,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const f=Jn(t.output),h=Array.isArray(f?.items)?f.items:[],m=i==="loading",g=i==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ee,{icon:p.jsx(pt,{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(pt,{}),e[10]=k):k=e[10];let S;e[11]!==r?(S=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[11]=r,e[12]=S):S=e[12];let v;e[13]!==S?(v=p.jsx(ee,{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(pt,{}),e[15]=k):k=e[15];let S;e[16]!==r?(S=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[16]=r,e[17]=S):S=e[17];let v;e[18]!==S?(v=p.jsx(ee,{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(pt,{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($e,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==y||e[24]!==b?(a=p.jsx(ee,{icon:x,title:y,state:"idle",trailing:b}),e[23]=y,e[24]=b,e[25]=a):a=e[25],o="mt-2 flex flex-col gap-1.5",l=h.map(fv)}e[2]=r,e[3]=t.output,e[4]=i,e[5]=o,e[6]=l,e[7]=a,e[8]=c}else o=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]!==o||e[27]!==l?(u=p.jsx("div",{className:o,children:l}),e[26]=o,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 fv(n){const e=n.colors?Object.entries(n.colors).filter(mv):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(_h,{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:pv}),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(Eu,{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(hv)})]})]},n.id??`${n.name}-${n.domain}`)}function hv(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${Yl[e]}: ${t}`,"aria-hidden":!0},e)}function pv(n){n.target.style.display="none"}function mv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function $o(n){const e=L.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,i=lu(t);if(!i)return null;let o;return e[0]!==i.icon||e[1]!==i.title||e[2]!==s?(o=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(Gt,{icon:i.icon,name:i.title,size:s})}),e[0]=i.icon,e[1]=i.title,e[2]=s,e[3]=o):o=e[3],o}$o.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:Z(t,"rounded bg-muted animate-pulse")})})};function Er(n){const e=L.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:i}=n,o=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==i||e[1]!==t||e[2]!==l||e[3]!==o){const h=t.slice(0,o);a=t.length-o,e[7]!==i?(c=Z("flex items-center justify-end -space-x-2",i),e[7]=i,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(E.Suspense,{fallback:p.jsx($o.Fallback,{iconSize:l}),children:p.jsx($o,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=i,e[1]=t,e[2]=l,e[3]=o,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:Z("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:Z(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}Er.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",i=r==="sm"?"size-8":"size-6",o=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:Z(s,"rounded bg-muted animate-pulse")})},a)),o&&p.jsx("div",{className:Z("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",i),children:p.jsx("div",{className:Z(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const gv="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. ",Gc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function xv(n){const e=L.c(64),{part:t,latency:r}=n,s=Iu(),i=ct(t.state),o=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=()=>{Gc?.matches||(u.current=o.current?.getBoundingClientRect()??null,o.current&&(o.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=V=>{if(Gc?.matches)return;const se=u.current,ae=o.current;if(!se||!ae)return;const de=(V.clientX-se.left)/se.width*100,Ie=(V.clientY-se.top)/se.height*100;ae.style.transform=`perspective(800px) rotateY(${(de-50)*.05}deg) rotateX(${(Ie-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(de-50)*.15}px, ${(Ie-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 V=o.current;V&&(V.style.transform="none",V.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(i==="loading"){let V;return e[3]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ee,{icon:p.jsx(ht,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=V):V=e[3],V}if(i==="approval"){let V;return e[4]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ee,{icon:p.jsx(ht,{}),title:"Create agent",state:"idle"}),e[4]=V):V=e[4],V}if(i==="error"){let V;e[5]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ht,{}),e[5]=V):V=e[5];const se=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let ae;e[6]!==r?(ae=p.jsx($e,{latency:r}),e[6]=r,e[7]=ae):ae=e[7];let de;return e[8]!==se||e[9]!==ae?(de=p.jsx(ee,{icon:V,title:se,state:"error",trailing:ae}),e[8]=se,e[9]=ae,e[10]=de):de=e[10],de}let y,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(y=Jn(t.output)?.item,!y?.id||!y?.title){let V;e[16]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ht,{}),e[16]=V):V=e[16];let se;e[17]!==r?(se=p.jsx(ee,{icon:V,title:"Agent created",state:"idle",trailing:p.jsx($e,{latency:r})}),e[17]=r,e[18]=se):se=e[18],k=se;break e}b=(y.connections??[]).map(yv)}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(ht,{className:"text-emerald-500"}),e[19]=v):v=e[19];const C=`Agent created: ${y.title}`;let w;e[20]!==r?(w=p.jsx($e,{latency:r}),e[20]=r,e[21]=w):w=e[21];let T;e[22]!==C||e[23]!==w?(T=p.jsx(ee,{icon:v,title:C,state:"idle",trailing:w}),e[22]=C,e[23]=w,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 O,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(O=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:gv.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]=O,e[29]=A):(O=e[28],A=e[29]);let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=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]=R):R=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(Su,{icon:y.icon,name:y.title,size:"md"}),e[32]=y.icon,e[33]=y.title,e[34]=_):_=e[34];let $;e[35]!==y.title?($=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]=$):$=e[36];let z;e[37]!==_||e[38]!==$?(z=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[_,$]}),e[37]=_,e[38]=$,e[39]=z):z=e[39];let B;e[40]!==y.description?(B=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]=B):B=e[41];let q;e[42]!==z||e[43]!==B?(q=p.jsxs("div",{className:"relative",children:[z,B]}),e[42]=z,e[43]=B,e[44]=q):q=e[44];let J;e[45]!==S?(J=S.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Er.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:S.length}),children:p.jsx(Er,{connectionIds:S,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=S,e[46]=J):J=e[46];let U;e[47]!==J?(U=p.jsx("div",{className:"flex-1 min-w-0",children:J}),e[47]=J,e[48]=U):U=e[48];let X;e[49]!==y.id||e[50]!==s?(X=()=>s(y.id),e[49]=y.id,e[50]=s,e[51]=X):X=e[51];const te=`See agent: ${y.title}`;let ne;e[52]!==X||e[53]!==te?(ne=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(mt,{size:"sm",className:"h-7",onClick:X,"aria-label":te,children:"See agent"})}),e[52]=X,e[53]=te,e[54]=ne):ne=e[54];let re;e[55]!==U||e[56]!==ne?(re=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[U,ne]}),e[55]=U,e[56]=ne,e[57]=re):re=e[57];let le;e[58]!==q||e[59]!==re?(le=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:o,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:x,children:[M,O,A,R,I,q,re]})}),e[58]=q,e[59]=re,e[60]=le):le=e[60];let ye;return e[61]!==le||e[62]!==T?(ye=p.jsxs(p.Fragment,{children:[T,le]}),e[61]=le,e[62]=T,e[63]=ye):ye=e[63],ye}function yv(n){return n.connection_id}function bv(n){const e=L.c(24),{agent:t}=n,r=Iu();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 i;e[2]!==s?(i=s.map(kv),e[2]=s,e[3]=i):i=e[3];const o=i;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(Su,{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]!==o?(f=o.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Er.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:o.length}),children:p.jsx(Er,{connectionIds:o,iconSize:"xs",maxVisibleIcons:3})}),e[17]=o,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 kv(n){return n.connection_id}function Sv(n){const e=L.c(41),{part:t,latency:r}=n,s=qn(),{org:i}=Mt();let o;e[0]!==t.state?(o=ct(t.state),e[0]=t.state,e[1]=o):o=e[1];const l=o;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=Jn(t.output);if(c=Array.isArray(y?.items)?y.items:[],l==="loading"){let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ee,{icon:p.jsx(ht,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=C):C=e[12],h=C;break e}if(l==="approval"){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ee,{icon:p.jsx(ht,{}),title:"List agents",state:"idle"}),e[13]=C):C=e[13],h=C;break e}if(l==="error"){let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ht,{}),e[14]=C):C=e[14];const w=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx($e,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==w||e[18]!==T?(N=p.jsx(ee,{icon:C,title:w,state:"error",trailing:T}),e[17]=w,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ht,{}),e[20]=C):C=e[20];let w;e[21]!==r?(w=p.jsx(ee,{icon:C,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx($e,{latency:r})}),e[21]=r,e[22]=w):w=e[22],h=w;break e}const b=c.slice(0,Mh);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ht,{className:"text-emerald-500"}),e[23]=k):k=e[23];const S=c.length===1?"1 agent":`${c.length} agents`;let v;e[24]!==r?(v=p.jsx($e,{latency:r}),e[24]=r,e[25]=v):v=e[25],e[26]!==S||e[27]!==v?(f=p.jsx(ee,{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(vv)}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]!==i?(m=a>0&&p.jsx(Eh,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:i.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=i,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 vv(n){return p.jsx(bv,{agent:n},n.id)}const wv={active:"bg-emerald-500",inactive:"bg-muted-foreground",error:"bg-destructive"};function Cv(n){const e=L.c(27),{connection:t}=n,r=qn(),{org:s}=Mt(),i=t.slug,o=t.description||t.app_name,l=!i||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==i?(a=()=>i&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:i}}),e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(Gt,{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]!==o?(d=o&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:o}),e[9]=o,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=wv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=Z("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 Tv(n){const e=L.c(40),{part:t,latency:r}=n,s=qn(),{org:i}=Mt();let o;e[0]!==t.state?(o=ct(t.state),e[0]=t.state,e[1]=o):o=e[1];const l=o;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=Jn(t.output);if(c=(Array.isArray(y?.items)?y.items:[]).filter(Mv),l==="loading"||l==="approval"){let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ee,{icon:p.jsx(Lr,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=C):C=e[12],h=C;break e}if(l==="error"){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Lr,{}),e[13]=C):C=e[13];const w=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx($e,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==w||e[17]!==T?(N=p.jsx(ee,{icon:C,title:w,state:"error",trailing:T}),e[16]=w,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Lr,{}),e[19]=C):C=e[19];let w;e[20]!==r?(w=p.jsx(ee,{icon:C,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx($e,{latency:r})}),e[20]=r,e[21]=w):w=e[21],h=w;break e}const b=c.slice(0,Mh);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Lr,{className:"text-emerald-500"}),e[22]=k):k=e[22];const S=c.length===1?"1 connection":`${c.length} connections`;let v;e[23]!==r?(v=p.jsx($e,{latency:r}),e[23]=r,e[24]=v):v=e[24],e[25]!==S||e[26]!==v?(f=p.jsx(ee,{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(Nv)}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]!==i?(m=a>0&&p.jsx(Eh,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:i.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=i,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 Nv(n){return p.jsx(Cv,{connection:n},n.id)}function Mv(n){return n.connection_type!=="VIRTUAL"}function Ev(){const n=L.c(37),e=el(),{sendMessage:t,isStreaming:r,messages:s}=rm(),{org:i}=Mt(),o=e?.virtualMcpId,{prompts:l}=bm(i.slug),a=o??null;let c;n[0]!==i.id||n[1]!==i.slug||n[2]!==a?(c={connectionId:a,orgId:i.id,orgSlug:i.slug},n[0]=i.id,n[1]=i.slug,n[2]=a,n[3]=c):c=n[3];const u=qo(c),[d,f]=E.useState(null);if(!o||r||!vp(o)||!s.some(Av))return null;let m;if(n[4]!==l||n[5]!==o){let A;n[7]!==o?(A=R=>R.agentId===o&&R.promptName,n[7]=o,n[8]=A):A=n[8],m=l.find(A),n[4]=l,n[5]=o,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,R)=>{if(!u){eo.error("MCP client not available");return}try{const I=await vm(u,A.name,R);await t({type:"doc",content:[{type:"paragraph",content:[Qf({id:A.name,name:rl(A.name,nl(A._meta)),metadata:I.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]})}catch(I){console.error("[next-action-chip] failed",I),eo.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(Sm,{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 C;n[21]!==g.title?(C=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=C):C=n[22];let w;n[23]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(vu,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=w):w=n[23];let T;n[24]!==k||n[25]!==C?(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,C,w]}),n[24]=k,n[25]=C,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 R=d;f(null),R&&await y(R,A)},n[28]=d,n[29]=y,n[30]=M):M=n[30];let j;n[31]!==d||n[32]!==M?(j=p.jsx(Um,{prompt:d,setPrompt:N,onSubmit:M}),n[31]=d,n[32]=M,n[33]=j):j=n[33];let O;return n[34]!==j||n[35]!==T?(O=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=O):O=n[36],O}function Av(n){return n.role==="user"||n.parts.some(jv)}function jv(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function Iv(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 i=s;if(i.type!=="data-deck-updated")continue;const o=i.data;if(!o?.path)continue;const l=`deck:${o.path}`;e.has(l)||e.set(l,{tabId:cm(o.path),label:o.name||o.path,kind:o.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function Ov(){const n=L.c(9),e=qn(),t=Kn()?.messages??[],r=Iv(t);if(r.length===0)return null;const s=r.some(Dv),i=r.some(Rv),o=s?i?"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]!==o?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:o}),n[0]=o,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(ir,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(fm,{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 Rv(n){return n.kind==="page"}function Dv(n){return n.kind==="deck"}async function Pv(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 AT(){const n=L.c(2),e=Kn()?.messages??[];let t;return n[0]!==e?(t=e.some(Lv),n[0]=e,n[1]=t):t=n[1],t}function Lv(n){return n.parts?.some(_v)}function _v(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function $v(n,e){const t=L.c(9),{org:r}=Mt();let s;t[0]!==n?(s=nt.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let i;t[2]!==r||t[3]!==n?(i=()=>Pv(n??"",r.slug),t[2]=r,t[3]=n,t[4]=i):i=t[4];const o=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==i||t[7]!==o?(l={queryKey:s,queryFn:i,enabled:o,staleTime:0},t[5]=s,t[6]=i,t[7]=o,t[8]=l):l=t[8],jr(l)}function zv(n){const e=L.c(20),{file:t}=n,r=qn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:um(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const i=s;let o;e[3]!==t.filename?(o=p.jsx(Yp,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=o):o=e[4];let l;e[5]!==t.filename||e[6]!==i?(l=p.jsx("button",{type:"button",onClick:i,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]=i,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Au,{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]!==i?(d=p.jsx(mt,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:i,children:"Open"}),e[13]=i,e[14]=d):d=e[14];let f;return e[15]!==o||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:[o,l,u,d]}),e[15]=o,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Xc(n){return n.split("/").pop()??n}const Bv=/(^|\/)output\//;function Fv(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?Xc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&Bv.test(s)&&e.add(Xc(s))}}}return e}function Vv(n){const e=L.c(4),{threadId:t,message:r}=n,s=Fv(r),i=s.size>0;let o;e[0]!==i?(o={enabled:i},e[0]=i,e[1]=o):o=e[1];const{data:l}=$v(t,o);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(Hv);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 Hv(n){return p.jsx(zv,{file:n},n.key)}function Wv(n){return n.type==="reasoning"}function Uv(n){const e=[],t=new Set,r=new Map,s=new Map,i=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(Wv(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;i.set(u,d.text??"");continue}}}const o=[];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&&o.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||o.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:o,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:i}}}function zo(n){const e=L.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>da(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,i]=E.useState(r);let o,l;e[2]!==t?(o=()=>{const d=setInterval(()=>i(da(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=o,e[4]=l):(o=e[3],l=e[4]),E.useEffect(o,l);const a=s/1e3;let c;e[5]!==a?(c=Ut(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 zh=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function qv(){const n=L.c(5),[e]=E.useState(Kv);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=zh.map((i,o)=>{const{delay:l}=i;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[o],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},o)}),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 Kv(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return zh.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const Jv={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(Qs,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},Gv=1200;function Bo(n){const e=L.c(9),{icon:t,title:r,summary:s,detail:i,state:o,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==i||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==o||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(ee,{icon:t,title:r,summary:s,detail:i,state:o,detailVariant:u,latency:a,trailing:c}),e[0]=i,e[1]=u,e[2]=t,e[3]=a,e[4]=o,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function Xv(n){const e=L.c(17),{startedAt:t}=n,r=Kn()?.runStatusStage??null,[s,i]=E.useState("planning");let o,l;if(e[0]!==r?(o=()=>{if(r!==null)return;const f=setTimeout(()=>{i("thinking")},Gv);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=o,e[2]=l):(o=e[1],l=e[2]),E.useEffect(o,l),r!==null){const f=lm[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Qs,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(zo,{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(Bo,{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=Jv[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(zo,{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(Bo,{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 Yv(n){const e=L.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(qv,{}),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(zo,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const Qv=2e4;function Zv(n){const e=L.c(8),{startedAt:t}=n;hu(1e3);const r=Kn(),i=(t!==null?Date.now()-t:0)>=Qv;let o;e[0]!==t?(o=p.jsx(Xv,{startedAt:t}),e[0]=t,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==r?(l=i&&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]=i,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a}function ew(n){const e=L.c(20),{duration:t,parts:r,isStreaming:s}=n;let i;e[0]!==r?(i=r.every(rw),e[0]=r,e[1]=i):i=e[1];const o=i;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Ut(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==o||e[5]!==s||e[6]!==r){const k=r.map(nw).join(`
184
+ … (${f.length-Zi} 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(bu,{}),e[7]=u):u=e[7];let d;return e[8]!==c||e[9]!==i||e[10]!==l?(d=p.jsx(ee,{icon:u,title:i,summary:l,state:"idle",detail:c,detailVariant:"code"}),e[8]=c,e[9]=i,e[10]=l,e[11]=d):d=e[11],d}function qS(n){const e=L.c(12),{jobId:t,prompt:r,items:s,streaming:i}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx("h3",{className:"text-xs font-medium text-muted-foreground/70 mb-1.5",children:"Task"}),e[0]=o):o=e[0];let l;e[1]!==r?(l=p.jsxs("section",{children:[o,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]!==i?(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(pi,{id:`${t}-sub-${f}`,part:d,animate:i},`${t}-sub-${f}`):null:m==="dynamic-tool"||m.startsWith("tool-")&&m!=="tool-todo_write"&&m!=="tool-update_interests"?p.jsx(US,{part:h},`${t}-sub-${f}`):null}),e[3]=s,e[4]=t,e[5]=i,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 Lh(n){const e=L.c(21),{part:t}=n,r=t.output?.jobId,{taskId:s}=tm(),{org:i}=Mt(),[o,l]=E.useState(!1),a=FS(r);let c;e[0]!==r||e[1]!==o||e[2]!==i.slug||e[3]!==s?(c={orgSlug:i.slug,threadId:s,jobId:r,enabled:o},e[0]=r,e[1]=o,e[2]=i.slug,e[3]=s,e[4]=c):c=e[4];const u=HS(c);let d;e[5]!==u.messages?(d=u.messages.flatMap(JS),e[5]=u.messages,e[6]=d):d=e[6];const f=d;let h;e[7]!==a?(h=a.flatMap(KS),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(Gt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(tl,{})}),e[11]=S):S=e[11];const v=k?"loading":"idle",C=u.streaming||k;let w;e[12]!==g||e[13]!==r||e[14]!==x||e[15]!==C?(w=p.jsx(qS,{jobId:r,prompt:x,items:g,streaming:C}),e[12]=g,e[13]=r,e[14]=x,e[15]=C,e[16]=w):w=e[16];let T;return e[17]!==b||e[18]!==v||e[19]!==w?(T=p.jsx(Xl,{icon:S,title:"Subtask",summary:b,state:v,onOpenChange:l,children:w}),e[17]=b,e[18]=v,e[19]=w,e[20]=T):T=e[20],T}function KS(n){return n.parts??[]}function JS(n){return n.parts??[]}function GS(n){const e=L.c(13);if(Rh(n.part.output)){let u;return e[0]!==n?(u=p.jsx(Lh,{...n}),e[0]=n,e[1]=u):u=e[1],u}let t;e[2]!==n?(t=Dh(n),e[2]=n,e[3]=t):t=e[3];const{fallbackTitle:r,summary:s,usage:i,state:o}=t;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(Gt,{icon:void 0,name:"Subtask",size:"2xs",className:"rounded-xs",fallbackIcon:p.jsx(tl,{})}),e[4]=l):l=e[4];let a;e[5]!==n.part?(a=p.jsx(Ph,{part:n.part}),e[5]=n.part,e[6]=a):a=e[6];let c;return e[7]!==r||e[8]!==o||e[9]!==s||e[10]!==a||e[11]!==i?(c=p.jsx(Xl,{icon:l,title:r,summary:s,state:o,usage:i,children:a}),e[7]=r,e[8]=o,e[9]=s,e[10]=a,e[11]=i,e[12]=c):c=e[12],c}function XS(n){const e=L.c(17),t=lu(n.part.input?.agent_id);if(Rh(n.part.output)){let g;return e[0]!==n?(g=p.jsx(Lh,{...n}),e[0]=n,e[1]=g):g=e[1],g}let r;e[2]!==n?(r=Dh(n),e[2]=n,e[3]=r):r=e[3];const{fallbackTitle:s,summary:i,usage:o,state:l}=r,a=t?.icon,c=t?.title??"Subtask";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(tl,{}),e[4]=u):u=e[4];let d;e[5]!==a||e[6]!==c?(d=p.jsx(Gt,{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(Ph,{part:n.part}),e[8]=n.part,e[9]=h):h=e[9];let m;return e[10]!==l||e[11]!==i||e[12]!==d||e[13]!==f||e[14]!==h||e[15]!==o?(m=p.jsx(Xl,{icon:d,title:f,summary:i,state:l,usage:o,children:h}),e[10]=l,e[11]=i,e[12]=d,e[13]=f,e[14]=h,e[15]=o,e[16]=m):m=e[16],m}function YS(n){const e=L.c(16),{part:t}=n;if(!t.state.startsWith("output-"))return null;const r=t.input?.plan??"",i=t.output?.approved===!0;let o,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(ro,{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]=o,e[1]=l):(o=e[0],l=e[1]);let a;e[2]!==i?(a=i&&p.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 bg-green-500/10 px-1.5 py-0.5 rounded-md",children:[p.jsx(Yo,{size:12}),"Approved"]}),e[2]=i,e[3]=a):a=e[3];let c;e[4]!==i||e[5]!==t.state?(c=!i&&t.state==="output-available"&&p.jsx("span",{className:"text-xs text-muted-foreground/70 italic",children:"Rejected"}),e[4]=i,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:[o,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(pi,{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 Yl={primary:"Primary",secondary:"Secondary",accent:"Accent",background:"Background",foreground:"Foreground"};function QS(n){return n.startsWith("http")?n:`https://${n}`}function Jc(n){const e=L.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 ZS(n){const e=L.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 i;e[2]!==t?(i=p.jsx("span",{className:"text-sm text-foreground",children:t}),e[2]=t,e[3]=i):i=e[3];let o;e[4]!==r?(o=p.jsx("span",{className:"text-xs font-mono tabular-nums text-muted-foreground",children:r}),e[4]=r,e[5]=o):o=e[5];let l;e[6]!==i||e[7]!==o?(l=p.jsxs("div",{className:"flex flex-col leading-tight min-w-0",children:[i,o]}),e[6]=i,e[7]=o,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 ev(n){const e=L.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 i;e[2]!==t?(i=p.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=i):i=e[3];let o;e[4]!==r?(o={fontFamily:r},e[4]=r,e[5]=o):o=e[5];let l;e[6]!==r||e[7]!==o?(l=p.jsx("span",{className:"text-sm text-foreground",style:o,children:r}),e[6]=r,e[7]=o,e[8]=l):l=e[8];let a;e[9]!==i||e[10]!==l?(a=p.jsxs("div",{className:"flex flex-col leading-tight",children:[i,l]}),e[9]=i,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 tv(n){const e=L.c(3),{logo:t,favicon:r,name:s}=n,i=t??r;if(!i)return null;const o=s?`${s} logo`:"";let l;return e[0]!==i||e[1]!==o?(l=p.jsx("img",{src:i,alt:o,className:"size-16 shrink-0 rounded-lg border border-border bg-background object-contain p-2",onError:nv}),e[0]=i,e[1]=o,e[2]=l):l=e[2],l}function nv(n){n.target.style.display="none"}function _h(n){const e=L.c(4),{colors:t}=n;let r;e[0]!==t?(r=Object.entries(t).filter(sv),e[0]=t,e[1]=r):r=e[1];const s=r;if(s.length===0)return null;let i;return e[2]!==s?(i=p.jsx("div",{className:"flex h-1.5",children:s.map(rv)}),e[2]=s,e[3]=i):i=e[3],i}function rv(n){const[e,t]=n;return p.jsx("span",{className:"flex-1",style:{backgroundColor:t},title:`${Yl[e]}: ${t}`,"aria-hidden":!0},e)}function sv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function $h(n){const e=L.c(36),{logo:t,favicon:r,name:s,domain:i,overview:o,colors:l,fonts:a,showDefaultBadge:c,isDefault:u}=n;let d;e[0]!==l?(d=l?Object.entries(l).filter(av):[],e[0]=l,e[1]=d):d=e[1];const f=d;let h;e[2]!==a?(h=a?Object.entries(a).filter(lv):[],e[2]=a,e[3]=h):h=e[3];const m=h;let g;e[4]!==l?(g=l&&p.jsx(_h,{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(tv,{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(Eu,{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]!==i?(b=i&&p.jsxs("a",{href:QS(i),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[i,p.jsx(ju,{className:"size-3 shrink-0"})]}),e[14]=i,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]!==o?(v=o&&p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:o}),e[22]=o,e[23]=v):v=e[23];let C;e[24]!==f?(C=f.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Jc,{children:"Colors"}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-3",children:f.map(ov)})]}),e[24]=f,e[25]=C):C=e[25];let w;e[26]!==m?(w=m.length>0&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx(Jc,{children:"Typography"}),p.jsx("div",{className:"flex flex-wrap gap-2.5",children:m.map(iv)})]}),e[26]=m,e[27]=w):w=e[27];let T;e[28]!==C||e[29]!==w||e[30]!==S||e[31]!==v?(T=p.jsxs("div",{className:"p-5 flex flex-col gap-6",children:[S,v,C,w]}),e[28]=C,e[29]=w,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 iv(n){const[e,t]=n;return p.jsx(ev,{role:e,family:t},e)}function ov(n){const[e,t]=n;return p.jsx(ZS,{name:Yl[e],value:t},e)}function lv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function av(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function cv(n){const e=L.c(29),{part:t,latency:r}=n,s=ct(t.state);let i;e[0]!==t.output?(i=Jn(t.output),e[0]=t.output,e[1]=i):i=e[1];const o=i,l=s==="loading",a=s==="error"||o&&o.success===!1;if(l){const w=t.input;let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(pt,{className:"animate-pulse"}),e[2]=T):T=e[2];const N=w?.domain?`from ${w.domain}`:void 0;let M;return e[3]!==N?(M=p.jsx(ee,{icon:T,title:"Extracting brand",summary:N,state:"loading",defaultOpen:!0}),e[3]=N,e[4]=M):M=e[4],M}if(a){let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(pt,{}),e[5]=w):w=e[5];const T=o?.error??"Unknown error";let N;e[6]!==r?(N=r!=null&&r>0?p.jsx($e,{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(ee,{icon:w,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(pt,{className:"text-fuchsia-500"}),e[11]=c):c=e[11];const u=o?.name?`Brand set: ${o.name}`:"Brand context set",d=o?.domain;let f;e[12]!==r?(f=r!=null&&r>0?p.jsx($e,{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(ee,{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=o?.logo,g=o?.favicon,x=o?.name,y=o?.domain,b=o?.overview,k=o?.colors,S=o?.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($h,{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 C;return e[26]!==v||e[27]!==h?(C=p.jsxs(p.Fragment,{children:[h,v]}),e[26]=v,e[27]=h,e[28]=C):C=e[28],C}function uv(n){const e=L.c(27),{part:t,latency:r}=n,s=ct(t.state);let i;e[0]!==t.output?(i=Jn(t.output),e[0]=t.output,e[1]=i):i=e[1];const o=i,l=s==="loading",a=s==="error"||o&&o.success===!1;if(l){let g;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(ee,{icon:p.jsx(pt,{className:"animate-pulse"}),title:"Loading brand",state:"loading"}),e[2]=g):g=e[2],g}if(a||!o){let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx(pt,{}),e[3]=g):g=e[3];let x;e[4]!==r?(x=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[4]=r,e[5]=x):x=e[5];let y;return e[6]!==x?(y=p.jsx(ee,{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(pt,{className:"text-fuchsia-500"}),e[8]=c):c=e[8];const u=o.name?`Brand · ${o.name}`:"Brand";let d;e[9]!==r?(d=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[9]=r,e[10]=d):d=e[10];let f;e[11]!==o.domain||e[12]!==u||e[13]!==d?(f=p.jsx(ee,{icon:c,title:u,summary:o.domain,state:"idle",trailing:d}),e[11]=o.domain,e[12]=u,e[13]=d,e[14]=f):f=e[14];let h;e[15]!==o.colors||e[16]!==o.domain||e[17]!==o.favicon||e[18]!==o.fonts||e[19]!==o.isDefault||e[20]!==o.logo||e[21]!==o.name||e[22]!==o.overview?(h=p.jsx($h,{logo:o.logo,favicon:o.favicon,name:o.name,domain:o.domain,overview:o.overview,colors:o.colors,fonts:o.fonts,showDefaultBadge:!0,isDefault:o.isDefault}),e[15]=o.colors,e[16]=o.domain,e[17]=o.favicon,e[18]=o.fonts,e[19]=o.isDefault,e[20]=o.logo,e[21]=o.name,e[22]=o.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 dv(n){const e=L.c(32),{part:t,latency:r}=n;let s;e[0]!==t.state?(s=ct(t.state),e[0]=t.state,e[1]=s):s=e[1];const i=s;let o,l,a,c;if(e[2]!==r||e[3]!==t.output||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const f=Jn(t.output),h=Array.isArray(f?.items)?f.items:[],m=i==="loading",g=i==="error";if(m){let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ee,{icon:p.jsx(pt,{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(pt,{}),e[10]=k):k=e[10];let S;e[11]!==r?(S=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[11]=r,e[12]=S):S=e[12];let v;e[13]!==S?(v=p.jsx(ee,{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(pt,{}),e[15]=k):k=e[15];let S;e[16]!==r?(S=r!=null&&r>0?p.jsx($e,{latency:r}):void 0,e[16]=r,e[17]=S):S=e[17];let v;e[18]!==S?(v=p.jsx(ee,{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(pt,{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($e,{latency:r}):void 0,e[21]=r,e[22]=b):b=e[22],e[23]!==y||e[24]!==b?(a=p.jsx(ee,{icon:x,title:y,state:"idle",trailing:b}),e[23]=y,e[24]=b,e[25]=a):a=e[25],o="mt-2 flex flex-col gap-1.5",l=h.map(fv)}e[2]=r,e[3]=t.output,e[4]=i,e[5]=o,e[6]=l,e[7]=a,e[8]=c}else o=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]!==o||e[27]!==l?(u=p.jsx("div",{className:o,children:l}),e[26]=o,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 fv(n){const e=n.colors?Object.entries(n.colors).filter(mv):[];return p.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[n.colors&&p.jsx(_h,{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:pv}),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(Eu,{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(hv)})]})]},n.id??`${n.name}-${n.domain}`)}function hv(n){const[e,t]=n;return p.jsx("span",{className:"size-3 rounded-full border border-border",style:{backgroundColor:t},title:`${Yl[e]}: ${t}`,"aria-hidden":!0},e)}function pv(n){n.target.style.display="none"}function mv(n){const[,e]=n;return typeof e=="string"&&e.trim().length>0}function $o(n){const e=L.c(4),{connection_id:t,iconSize:r}=n,s=r===void 0?"xs":r,i=lu(t);if(!i)return null;let o;return e[0]!==i.icon||e[1]!==i.title||e[2]!==s?(o=p.jsx("div",{className:"shrink-0 bg-background ring-1 ring-background rounded-lg",children:p.jsx(Gt,{icon:i.icon,name:i.title,size:s})}),e[0]=i.icon,e[1]=i.title,e[2]=s,e[3]=o):o=e[3],o}$o.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:Z(t,"rounded bg-muted animate-pulse")})})};function Er(n){const e=L.c(18),{connectionIds:t,maxVisibleIcons:r,iconSize:s,className:i}=n,o=r===void 0?2:r,l=s===void 0?"xs":s;if(t.length===0)return null;let a,c,u;if(e[0]!==i||e[1]!==t||e[2]!==l||e[3]!==o){const h=t.slice(0,o);a=t.length-o,e[7]!==i?(c=Z("flex items-center justify-end -space-x-2",i),e[7]=i,e[8]=c):c=e[8];let m;e[9]!==l?(m=g=>p.jsx(E.Suspense,{fallback:p.jsx($o.Fallback,{iconSize:l}),children:p.jsx($o,{connection_id:g,iconSize:l})},g),e[9]=l,e[10]=m):m=e[10],u=h.map(m),e[0]=i,e[1]=t,e[2]=l,e[3]=o,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:Z("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:Z(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}Er.Fallback=function({maxVisibleIcons:e=2,totalCount:t,iconSize:r="xs"}){const s=r==="sm"?"size-6":"size-5",i=r==="sm"?"size-8":"size-6",o=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:Z(s,"rounded bg-muted animate-pulse")})},a)),o&&p.jsx("div",{className:Z("shrink-0 bg-background ring-1 ring-background border border-border rounded-lg flex items-center justify-center",i),children:p.jsx("div",{className:Z(r==="sm"?"h-3.5 w-5":"h-3 w-4","rounded bg-muted animate-pulse")})})]})};const gv="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. ",Gc=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null;function xv(n){const e=L.c(64),{part:t,latency:r}=n,s=Iu(),i=ct(t.state),o=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=()=>{Gc?.matches||(u.current=o.current?.getBoundingClientRect()??null,o.current&&(o.current.style.willChange="transform"))},e[0]=d):d=e[0];const f=d;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=V=>{if(Gc?.matches)return;const se=u.current,ae=o.current;if(!se||!ae)return;const de=(V.clientX-se.left)/se.width*100,Ie=(V.clientY-se.top)/se.height*100;ae.style.transform=`perspective(800px) rotateY(${(de-50)*.05}deg) rotateX(${(Ie-50)*-.05}deg)`,l.current&&(l.current.style.opacity="1",l.current.style.transform=`translate(${(de-50)*.15}px, ${(Ie-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 V=o.current;V&&(V.style.transform="none",V.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(i==="loading"){let V;return e[3]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ee,{icon:p.jsx(ht,{className:"animate-pulse"}),title:"Creating agent",state:"loading",defaultOpen:!0}),e[3]=V):V=e[3],V}if(i==="approval"){let V;return e[4]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ee,{icon:p.jsx(ht,{}),title:"Create agent",state:"idle"}),e[4]=V):V=e[4],V}if(i==="error"){let V;e[5]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ht,{}),e[5]=V):V=e[5];const se=t.state==="output-denied"?"Agent creation cancelled":"Couldn't create agent";let ae;e[6]!==r?(ae=p.jsx($e,{latency:r}),e[6]=r,e[7]=ae):ae=e[7];let de;return e[8]!==se||e[9]!==ae?(de=p.jsx(ee,{icon:V,title:se,state:"error",trailing:ae}),e[8]=se,e[9]=ae,e[10]=de):de=e[10],de}let y,b,k;if(e[11]!==r||e[12]!==t.output){k=Symbol.for("react.early_return_sentinel");e:{if(y=Jn(t.output)?.item,!y?.id||!y?.title){let V;e[16]===Symbol.for("react.memo_cache_sentinel")?(V=p.jsx(ht,{}),e[16]=V):V=e[16];let se;e[17]!==r?(se=p.jsx(ee,{icon:V,title:"Agent created",state:"idle",trailing:p.jsx($e,{latency:r})}),e[17]=r,e[18]=se):se=e[18],k=se;break e}b=(y.connections??[]).map(yv)}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(ht,{className:"text-emerald-500"}),e[19]=v):v=e[19];const C=`Agent created: ${y.title}`;let w;e[20]!==r?(w=p.jsx($e,{latency:r}),e[20]=r,e[21]=w):w=e[21];let T;e[22]!==C||e[23]!==w?(T=p.jsx(ee,{icon:v,title:C,state:"idle",trailing:w}),e[22]=C,e[23]=w,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 O,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(O=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:gv.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]=O,e[29]=A):(O=e[28],A=e[29]);let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=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]=R):R=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(Su,{icon:y.icon,name:y.title,size:"md"}),e[32]=y.icon,e[33]=y.title,e[34]=_):_=e[34];let $;e[35]!==y.title?($=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]=$):$=e[36];let z;e[37]!==_||e[38]!==$?(z=p.jsxs("div",{className:"flex items-center gap-2.5 p-2",children:[_,$]}),e[37]=_,e[38]=$,e[39]=z):z=e[39];let B;e[40]!==y.description?(B=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]=B):B=e[41];let q;e[42]!==z||e[43]!==B?(q=p.jsxs("div",{className:"relative",children:[z,B]}),e[42]=z,e[43]=B,e[44]=q):q=e[44];let J;e[45]!==S?(J=S.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Er.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:S.length}),children:p.jsx(Er,{connectionIds:S,iconSize:"xs",maxVisibleIcons:3,className:"flex items-center justify-start -space-x-1"})}),e[45]=S,e[46]=J):J=e[46];let U;e[47]!==J?(U=p.jsx("div",{className:"flex-1 min-w-0",children:J}),e[47]=J,e[48]=U):U=e[48];let X;e[49]!==y.id||e[50]!==s?(X=()=>s(y.id),e[49]=y.id,e[50]=s,e[51]=X):X=e[51];const te=`See agent: ${y.title}`;let ne;e[52]!==X||e[53]!==te?(ne=p.jsx("div",{className:"flex items-center gap-2 shrink-0",children:p.jsx(mt,{size:"sm",className:"h-7",onClick:X,"aria-label":te,children:"See agent"})}),e[52]=X,e[53]=te,e[54]=ne):ne=e[54];let re;e[55]!==U||e[56]!==ne?(re=p.jsxs("div",{className:"relative z-[3] flex items-center gap-2.5 px-2 pt-6 pb-1",children:[U,ne]}),e[55]=U,e[56]=ne,e[57]=re):re=e[57];let le;e[58]!==q||e[59]!==re?(le=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:o,className:"relative overflow-hidden rounded-lg bg-accent/25 p-2",style:N,onMouseEnter:f,onMouseMove:m,onMouseLeave:x,children:[M,O,A,R,I,q,re]})}),e[58]=q,e[59]=re,e[60]=le):le=e[60];let ye;return e[61]!==le||e[62]!==T?(ye=p.jsxs(p.Fragment,{children:[T,le]}),e[61]=le,e[62]=T,e[63]=ye):ye=e[63],ye}function yv(n){return n.connection_id}function bv(n){const e=L.c(24),{agent:t}=n,r=Iu();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 i;e[2]!==s?(i=s.map(kv),e[2]=s,e[3]=i):i=e[3];const o=i;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(Su,{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]!==o?(f=o.length>0&&p.jsx(E.Suspense,{fallback:p.jsx(Er.Fallback,{iconSize:"xs",maxVisibleIcons:3,totalCount:o.length}),children:p.jsx(Er,{connectionIds:o,iconSize:"xs",maxVisibleIcons:3})}),e[17]=o,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 kv(n){return n.connection_id}function Sv(n){const e=L.c(41),{part:t,latency:r}=n,s=qn(),{org:i}=Mt();let o;e[0]!==t.state?(o=ct(t.state),e[0]=t.state,e[1]=o):o=e[1];const l=o;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=Jn(t.output);if(c=Array.isArray(y?.items)?y.items:[],l==="loading"){let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ee,{icon:p.jsx(ht,{className:"animate-pulse"}),title:"Loading agents",state:"loading"}),e[12]=C):C=e[12],h=C;break e}if(l==="approval"){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ee,{icon:p.jsx(ht,{}),title:"List agents",state:"idle"}),e[13]=C):C=e[13],h=C;break e}if(l==="error"){let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ht,{}),e[14]=C):C=e[14];const w=t.state==="output-denied"?"Agent list unavailable":"Couldn't load agents";let T;e[15]!==r?(T=p.jsx($e,{latency:r}),e[15]=r,e[16]=T):T=e[16];let N;e[17]!==w||e[18]!==T?(N=p.jsx(ee,{icon:C,title:w,state:"error",trailing:T}),e[17]=w,e[18]=T,e[19]=N):N=e[19],h=N;break e}if(c.length===0){let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ht,{}),e[20]=C):C=e[20];let w;e[21]!==r?(w=p.jsx(ee,{icon:C,title:"No agents yet",summary:"This organization hasn't created any agents.",state:"idle",trailing:p.jsx($e,{latency:r})}),e[21]=r,e[22]=w):w=e[22],h=w;break e}const b=c.slice(0,Mh);a=c.length-b.length;let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(ht,{className:"text-emerald-500"}),e[23]=k):k=e[23];const S=c.length===1?"1 agent":`${c.length} agents`;let v;e[24]!==r?(v=p.jsx($e,{latency:r}),e[24]=r,e[25]=v):v=e[25],e[26]!==S||e[27]!==v?(f=p.jsx(ee,{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(vv)}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]!==i?(m=a>0&&p.jsx(Eh,{count:c.length,noun:"agents",onClick:()=>s({to:"/$org/settings/agents",params:{org:i.slug}})}),e[29]=a,e[30]=c,e[31]=s,e[32]=i,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 vv(n){return p.jsx(bv,{agent:n},n.id)}const wv={active:"bg-emerald-500",inactive:"bg-muted-foreground",error:"bg-destructive"};function Cv(n){const e=L.c(27),{connection:t}=n,r=qn(),{org:s}=Mt(),i=t.slug,o=t.description||t.app_name,l=!i||void 0;let a;e[0]!==r||e[1]!==s||e[2]!==i?(a=()=>i&&r({to:"/$org/settings/connections/$appSlug",params:{org:s.slug,appSlug:i}}),e[0]=r,e[1]=s,e[2]=i,e[3]=a):a=e[3];let c;e[4]!==t.icon||e[5]!==t.title?(c=p.jsx(Gt,{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]!==o?(d=o&&p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:o}),e[9]=o,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=wv[t.status]??"bg-muted-foreground";let m;e[14]!==h?(m=Z("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 Tv(n){const e=L.c(40),{part:t,latency:r}=n,s=qn(),{org:i}=Mt();let o;e[0]!==t.state?(o=ct(t.state),e[0]=t.state,e[1]=o):o=e[1];const l=o;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=Jn(t.output);if(c=(Array.isArray(y?.items)?y.items:[]).filter(Mv),l==="loading"||l==="approval"){let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(ee,{icon:p.jsx(Lr,{className:"animate-pulse"}),title:"Loading connections",state:"loading"}),e[12]=C):C=e[12],h=C;break e}if(l==="error"){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Lr,{}),e[13]=C):C=e[13];const w=t.state==="output-denied"?"Connection list unavailable":"Couldn't load connections";let T;e[14]!==r?(T=p.jsx($e,{latency:r}),e[14]=r,e[15]=T):T=e[15];let N;e[16]!==w||e[17]!==T?(N=p.jsx(ee,{icon:C,title:w,state:"error",trailing:T}),e[16]=w,e[17]=T,e[18]=N):N=e[18],h=N;break e}if(c.length===0){let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx(Lr,{}),e[19]=C):C=e[19];let w;e[20]!==r?(w=p.jsx(ee,{icon:C,title:"No connections yet",summary:"This organization hasn't connected any MCPs.",state:"idle",trailing:p.jsx($e,{latency:r})}),e[20]=r,e[21]=w):w=e[21],h=w;break e}const b=c.slice(0,Mh);a=c.length-b.length;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx(Lr,{className:"text-emerald-500"}),e[22]=k):k=e[22];const S=c.length===1?"1 connection":`${c.length} connections`;let v;e[23]!==r?(v=p.jsx($e,{latency:r}),e[23]=r,e[24]=v):v=e[24],e[25]!==S||e[26]!==v?(f=p.jsx(ee,{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(Nv)}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]!==i?(m=a>0&&p.jsx(Eh,{count:c.length,noun:"connections",onClick:()=>s({to:"/$org/settings/connections",params:{org:i.slug}})}),e[28]=a,e[29]=c,e[30]=s,e[31]=i,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 Nv(n){return p.jsx(Cv,{connection:n},n.id)}function Mv(n){return n.connection_type!=="VIRTUAL"}function Ev(){const n=L.c(37),e=el(),{sendMessage:t,isStreaming:r,messages:s}=nm(),{org:i}=Mt(),o=e?.virtualMcpId,{prompts:l}=bm(i.slug),a=o??null;let c;n[0]!==i.id||n[1]!==i.slug||n[2]!==a?(c={connectionId:a,orgId:i.id,orgSlug:i.slug},n[0]=i.id,n[1]=i.slug,n[2]=a,n[3]=c):c=n[3];const u=qo(c),[d,f]=E.useState(null);if(!o||r||!vp(o)||!s.some(Av))return null;let m;if(n[4]!==l||n[5]!==o){let A;n[7]!==o?(A=R=>R.agentId===o&&R.promptName,n[7]=o,n[8]=A):A=n[8],m=l.find(A),n[4]=l,n[5]=o,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,R)=>{if(!u){eo.error("MCP client not available");return}try{const I=await vm(u,A.name,R);await t({type:"doc",content:[{type:"paragraph",content:[Qf({id:A.name,name:rl(A.name,nl(A._meta)),metadata:I.messages,char:"/",kind:"prompt",args:R}),{type:"text",text:" "}]}]})}catch(I){console.error("[next-action-chip] failed",I),eo.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(Sm,{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 C;n[21]!==g.title?(C=p.jsx("span",{className:"truncate",children:g.title}),n[21]=g.title,n[22]=C):C=n[22];let w;n[23]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(vu,{size:12,className:"shrink-0 transition-transform duration-150 group-hover:translate-x-0.5"}),n[23]=w):w=n[23];let T;n[24]!==k||n[25]!==C?(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,C,w]}),n[24]=k,n[25]=C,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 R=d;f(null),R&&await y(R,A)},n[28]=d,n[29]=y,n[30]=M):M=n[30];let j;n[31]!==d||n[32]!==M?(j=p.jsx(Um,{prompt:d,setPrompt:N,onSubmit:M}),n[31]=d,n[32]=M,n[33]=j):j=n[33];let O;return n[34]!==j||n[35]!==T?(O=p.jsxs(p.Fragment,{children:[T,j]}),n[34]=j,n[35]=T,n[36]=O):O=n[36],O}function Av(n){return n.role==="user"||n.parts.some(jv)}function jv(n){return n.type==="tool-user_ask"&&n.state==="output-available"}function Iv(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 i=s;if(i.type!=="data-deck-updated")continue;const o=i.data;if(!o?.path)continue;const l=`deck:${o.path}`;e.has(l)||e.set(l,{tabId:am(o.path),label:o.name||o.path,kind:o.kind==="page"?"page":"deck"})}}return Array.from(e.values())}function Ov(){const n=L.c(9),e=qn(),t=Kn()?.messages??[],r=Iv(t);if(r.length===0)return null;const s=r.some(Dv),i=r.some(Rv),o=s?i?"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]!==o?(a=p.jsx("div",{className:"text-[12px] text-muted-foreground/70 uppercase tracking-wide",children:o}),n[0]=o,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(ir,{className:"size-3.5 shrink-0 text-muted-foreground"}):p.jsx(fm,{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 Rv(n){return n.kind==="page"}function Dv(n){return n.kind==="deck"}async function Pv(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 jT(){const n=L.c(2),e=Kn()?.messages??[];let t;return n[0]!==e?(t=e.some(Lv),n[0]=e,n[1]=t):t=n[1],t}function Lv(n){return n.parts?.some(_v)}function _v(n){const e=n;return(e.type==="tool-share_with_user"||e.type==="tool-bash"||e.type==="tool-write")&&e.state==="output-available"}function $v(n,e){const t=L.c(9),{org:r}=Mt();let s;t[0]!==n?(s=nt.threadOutputs(n??""),t[0]=n,t[1]=s):s=t[1];let i;t[2]!==r||t[3]!==n?(i=()=>Pv(n??"",r.slug),t[2]=r,t[3]=n,t[4]=i):i=t[4];const o=!!n&&(e?.enabled??!0);let l;return t[5]!==s||t[6]!==i||t[7]!==o?(l={queryKey:s,queryFn:i,enabled:o,staleTime:0},t[5]=s,t[6]=i,t[7]=o,t[8]=l):l=t[8],jr(l)}function zv(n){const e=L.c(20),{file:t}=n,r=qn();let s;e[0]!==t.key||e[1]!==r?(s=()=>r({to:".",search:h=>({...h,main:cm(t.key)}),replace:!0}),e[0]=t.key,e[1]=r,e[2]=s):s=e[2];const i=s;let o;e[3]!==t.filename?(o=p.jsx(Xp,{filename:t.filename,className:"h-5 w-4 shrink-0"}),e[3]=t.filename,e[4]=o):o=e[4];let l;e[5]!==t.filename||e[6]!==i?(l=p.jsx("button",{type:"button",onClick:i,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]=i,e[7]=l):l=e[7];const a=`Download ${t.filename}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Au,{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]!==i?(d=p.jsx(mt,{variant:"outline",size:"sm",className:"h-7 shrink-0 px-2.5 text-xs",onClick:i,children:"Open"}),e[13]=i,e[14]=d):d=e[14];let f;return e[15]!==o||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:[o,l,u,d]}),e[15]=o,e[16]=l,e[17]=u,e[18]=d,e[19]=f):f=e[19],f}function Xc(n){return n.split("/").pop()??n}const Bv=/(^|\/)output\//;function Fv(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?Xc(r.input.source):null);s&&e.add(s)}else if(r.type==="tool-write"){const s=r.input?.path;s&&Bv.test(s)&&e.add(Xc(s))}}}return e}function Vv(n){const e=L.c(4),{threadId:t,message:r}=n,s=Fv(r),i=s.size>0;let o;e[0]!==i?(o={enabled:i},e[0]=i,e[1]=o):o=e[1];const{data:l}=$v(t,o);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(Hv);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 Hv(n){return p.jsx(zv,{file:n},n.key)}function Wv(n){return n.type==="reasoning"}function Uv(n){const e=[],t=new Set,r=new Map,s=new Map,i=new Map;if(n){let l=null;for(let a=0;a<n.parts.length;a++){const c=n.parts[a];if(Wv(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;i.set(u,d.text??"");continue}}}const o=[];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&&o.push({kind:"reasoning-group",group:c});continue}a.type.startsWith("data-")||o.push({kind:"part",index:l})}}return{reasoningGroups:e,renderOrder:o,dataParts:{toolMetadata:r,toolSubtaskMetadata:s,webSearchStreaming:i}}}function zo(n){const e=L.c(9),{since:t}=n;let r;e[0]!==t?(r=()=>da(t,Date.now()),e[0]=t,e[1]=r):r=e[1];const[s,i]=E.useState(r);let o,l;e[2]!==t?(o=()=>{const d=setInterval(()=>i(da(t,Date.now())),100);return()=>clearInterval(d)},l=[t],e[2]=t,e[3]=o,e[4]=l):(o=e[3],l=e[4]),E.useEffect(o,l);const a=s/1e3;let c;e[5]!==a?(c=Ut(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 zh=[{delay:0},{delay:100},{delay:200},{delay:100},{delay:200},{delay:200},{delay:300},{delay:300},{delay:400}];function qv(){const n=L.c(5),[e]=E.useState(Kv);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=zh.map((i,o)=>{const{delay:l}=i;return p.jsx("div",{className:"rounded-[1px]",style:{width:3,height:3,"--cell-color":e[o],animation:"grid-ripple 1s ease infinite",animationDelay:`${l}ms`}},o)}),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 Kv(){const n=`var(--chart-${Math.ceil(Math.random()*5)})`;return zh.map(()=>Math.random()<.6?"color-mix(in srgb, var(--muted-foreground) 25%, transparent)":n)}const Jv={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(Qs,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking",detail:"Working through the next response"}},Gv=1200;function Bo(n){const e=L.c(9),{icon:t,title:r,summary:s,detail:i,state:o,detailVariant:l,latency:a,trailing:c}=n,u=l===void 0?"prose":l;let d;return e[0]!==i||e[1]!==u||e[2]!==t||e[3]!==a||e[4]!==o||e[5]!==s||e[6]!==r||e[7]!==c?(d=p.jsx(ee,{icon:t,title:r,summary:s,detail:i,state:o,detailVariant:u,latency:a,trailing:c}),e[0]=i,e[1]=u,e[2]=t,e[3]=a,e[4]=o,e[5]=s,e[6]=r,e[7]=c,e[8]=d):d=e[8],d}function Xv(n){const e=L.c(17),{startedAt:t}=n,r=Kn()?.runStatusStage??null,[s,i]=E.useState("planning");let o,l;if(e[0]!==r?(o=()=>{if(r!==null)return;const f=setTimeout(()=>{i("thinking")},Gv);return()=>{clearTimeout(f)}},l=[r],e[0]=r,e[1]=o,e[2]=l):(o=e[1],l=e[2]),E.useEffect(o,l),r!==null){const f=om[r];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx(Qs,{className:"size-4"}),e[3]=h):h=e[3];const m=`${f.label}...`;let g;e[4]!==t?(g=t!==null&&p.jsx(zo,{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(Bo,{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=Jv[s],c=`${a.label}...`;let u;e[10]!==t?(u=t!==null&&p.jsx(zo,{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(Bo,{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 Yv(n){const e=L.c(3),{startedAt:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(qv,{}),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(zo,{since:t})]}),e[1]=t,e[2]=s):s=e[2],s}const Qv=2e4;function Zv(n){const e=L.c(8),{startedAt:t}=n;hu(1e3);const r=Kn(),i=(t!==null?Date.now()-t:0)>=Qv;let o;e[0]!==t?(o=p.jsx(Xv,{startedAt:t}),e[0]=t,e[1]=o):o=e[1];let l;e[2]!==i||e[3]!==r?(l=i&&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]=i,e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=p.jsxs("div",{className:"flex flex-col gap-0.5",children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a}function ew(n){const e=L.c(20),{duration:t,parts:r,isStreaming:s}=n;let i;e[0]!==r?(i=r.every(rw),e[0]=r,e[1]=i):i=e[1];const o=i;let l;e[2]!==t?(l=t&&t/1e3>1?`Thought for ${Ut(t/1e3)}`:"Thought",e[2]=t,e[3]=l):l=e[3];const a=l;let c;if(e[4]!==o||e[5]!==s||e[6]!==r){const k=r.map(nw).join(`
185
185
  `).trim().split(`
186
186
  `).filter(Boolean),S=s?k[k.length-1]??"":k[0]??"";c=!o&&S?S.length>100?S.slice(0,100)+"…":S:void 0,e[4]=o,e[5]=s,e[6]=r,e[7]=c}else c=e[7];const u=c;let d;if(e[8]!==o||e[9]!==r){const b=r.map(tw).join(`
187
187
 
188
- `);d=!o&&b.trim()?b:null,e[8]=o,e[9]=r,e[10]=d}else d=e[10];const f=d,h=!s&&t!=null?t/1e3:void 0;let m;e[11]!==s?(m=s?p.jsx(Qs,{className:"size-4"}):p.jsx(qp,{className:"size-4"}),e[11]=s,e[12]=m):m=e[12];const g=s?"Thinking...":a,x=s?"loading":"idle";let y;return e[13]!==f||e[14]!==h||e[15]!==u||e[16]!==m||e[17]!==g||e[18]!==x?(y=p.jsx(Bo,{icon:m,title:g,summary:u,detail:f,state:x,detailVariant:"prose",latency:h}),e[13]=f,e[14]=h,e[15]=u,e[16]=m,e[17]=g,e[18]=x,e[19]=y):y=e[19],y}function tw(n){return n.text??""}function nw(n){return n.text??""}function rw(n){return n.text?.includes("REDACTED")}const sw=3;function iw(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 ow(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const i=e[s.index]?.type;i==="text"?r++:(i==="dynamic-tool"||i?.startsWith("tool-"))&&i!=="tool-todo_write"&&i!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function lw(n){const e=L.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(bu,{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 i;e[3]!==r?(i=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Jp,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=i):i=e[4];let o;return e[5]!==s||e[6]!==i?(o=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,i]}),e[5]=s,e[6]=i,e[7]=o):o=e[7],o}function aw(n){const e=L.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:i,totalDuration:o,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=ow(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(lw,{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]!==i||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==o){let y;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==i||e[19]!==r||e[20]!==s||e[21]!==o?(y=(b,k)=>Bh({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:i,totalDuration:o,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=i,e[19]=r,e[20]=s,e[21]=o,e[22]=y):y=e[22],m=t.map(y),e[6]=l,e[7]=c,e[8]=a,e[9]=i,e[10]=t,e[11]=r,e[12]=s,e[13]=o,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(ee,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=x):x=e[27],x}function Bh({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:i,dataParts:o,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?i:null;return p.jsx(ew,{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?Du(Ru(),t.metadata?.usage):null;return p.jsx(cw,{part:d,id:t.id,usageStats:f&&p.jsx(K2,{usage:h,duration:i}),dataParts:o,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function cw(n){const e=L.c(121),{part:t,id:r,usageStats:s,dataParts:i,isLoading:o,isLastMessage:l}=n;let a;e[0]!==i.toolMetadata?(a=f=>i.toolMetadata.get(f),e[0]=i.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==i.toolSubtaskMetadata?(u=f=>i.toolSubtaskMetadata.get(f),e[2]=i.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(qc,{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(BS,{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(YS,{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(TS,{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(ES,{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]!==i.webSearchStreaming||e[47]!==t.toolCallId?(h=i.webSearchStreaming.get(t.toolCallId),e[46]=i.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(zS,{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(GS,{...x}),children:p.jsx(XS,{...x})}),e[67]=x,e[68]=y):y=e[68],y}case"text":{const f=!!s&&!o,h=o&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(pi,{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(cv,{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(uv,{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(dv,{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(xv,{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(Sv,{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(Tv,{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]!==i.toolMetadata||e[112]!==h?(m=i.toolMetadata.get(h),e[111]=i.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(qc,{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 uw(n){const e=L.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(Qs,{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 dw(n){const e=L.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=Z("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 i;e[2]!==r?(i=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]=i):i=e[3];let o;return e[4]!==s||e[5]!==i?(o=p.jsx("div",{className:s,children:i}),e[4]=s,e[5]=i,e[6]=o):o=e[6],o}function fw(n){const e=L.c(31),{message:t,turnStartedAt:r,status:s,className:i,isLast:o}=n,l=o===void 0?!1:o,{isRunInProgress:a}=Kn()??{},c=a===void 0?!1:a,u=el()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Qo(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:C,renderOrder:w,dataParts:T}=Uv(t),N=t!==null&&w.length>0,M=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&M?.type==="reasoning";let O;if(e[4]!==t){const B=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,q=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;O=B!==null?q.getTime()-B.getTime():null,e[4]=t,e[5]=O}else O=e[5];const A=O;let R;e[6]!==l||e[7]!==t?(R=!l||!t||!t.parts.some(pw),e[6]=l,e[7]=t,e[8]=R):R=e[8];const I=R;let _;e[9]!==N||e[10]!==h||e[11]!==I||e[12]!==t||e[13]!==w?(_=!h&&N&&I&&(()=>{let B=0;for(const q of w)if(q.kind==="part"){const J=t.parts[q.index]?.type;(J==="dynamic-tool"||J?.startsWith("tool-"))&&B++}return B>=sw})(),e[9]=N,e[10]=h,e[11]=I,e[12]=t,e[13]=w,e[14]=_):_=e[14];const $=_;let z;if(e[15]!==i||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]!==C||e[25]!==w||e[26]!==$||e[27]!==v||e[28]!==u||e[29]!==A){const{collapsed:B,tail:q}=$?iw(w,t.parts):{collapsed:[],tail:w};z=p.jsx(dw,{className:i,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(iu,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),B.length>0&&p.jsx(aw,{items:B,message:t,reasoningGroups:C,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l}),q.map((J,U)=>{const X=B.length+U,te=q.findLastIndex(hw)===U;return Bh({item:J,renderIndex:X,message:t,reasoningGroups:C,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:te,renderOrder:w})}),u&&p.jsx(Vv,{threadId:u,message:t}),l&&h&&v!==null&&p.jsx(Yv,{startedAt:v}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(Ov,{}),I&&p.jsx(Ev,{})]}),!h&&p.jsx(Ah,{message:t})]}):h?p.jsx(Zv,{startedAt:v}):p.jsx(uw,{isRunInProgress:l&&c})}),e[15]=i,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]=C,e[25]=w,e[26]=$,e[27]=v,e[28]=u,e[29]=A,e[30]=z}else z=e[30];return z}function hw(n){return n.kind==="part"}function pw(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 mw(n){const e=L.c(21),{event:t}=n,[r,s]=E.useState(!1);let i;e[0]!==t.data?(i=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=i):i=e[1];const o=i;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(gw),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(Gp,{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=Z("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(Ln,{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]!==o?(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:o})]}),e[14]=t.source,e[15]=r,e[16]=o,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 gw(n){return!n}const xw=[q2.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),ik,ck];function yw(n){const e=L.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:xw,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const i=Gb(s);if(!i)return null;let o;return e[3]!==i?(o=p.jsx(Uf,{editor:i,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=i,e[4]=o):o=e[4],o}function bw(n){const e=L.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:i,parts:o,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(!o||o.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=Z("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 C;e[8]!==a||e[9]!==u?(C=Z("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":Z("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=C):C=e[10];let w;if(e[11]!==i||e[12]!==o){let I;e[14]!==i?(I=(_,$)=>_.type==="data-trigger-event"?p.jsx(mw,{event:_.data},`${i}-${$}`):null,e[14]=i,e[15]=I):I=e[15],w=o.map(I),e[11]=i,e[12]=o,e[13]=w}else w=e[13];let T;e[16]!==y||e[17]!==i||e[18]!==l||e[19]!==o?(T=y?p.jsx(yw,{tiptapDoc:l.tiptapDoc}):o.map((I,_)=>I.type==="text"?o[_-1]?.type==="data-trigger-event"?null:p.jsx(pi,{id:i,part:I},`${i}-${_}`):null),e[16]=y,e[17]=i,e[18]=l,e[19]=o,e[20]=T):T=e[20];let N;e[21]!==w||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[w,T]}),e[21]=w,e[22]=T,e[23]=N):N=e[23];let M;e[24]!==N||e[25]!==C?(M=p.jsx("div",{ref:m,className:C,children:N}),e[24]=N,e[25]=C,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 O;e[30]!==t?(O=p.jsx(Ah,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=O):O=e[31];let A;e[32]!==j||e[33]!==O?(A=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,O]}),e[32]=j,e[33]=O,e[34]=A):A=e[34];let R;return e[35]!==A||e[36]!==b?(R=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:A})}),e[35]=A,e[36]=b,e[37]=R):R=e[37],R}function kw(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 i=t[r+1];i&&i.role==="assistant"?(e.push({user:s,assistant:i}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function Sw(n){const e=L.c(19),{pair:t,isLastPair:r,status:s}=n,i=E.useRef(null),o=E.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{i.current&&i.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(i.current=y,!r||!y||o.current||(o.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=Z("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(bw,{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(fw,{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 vw(n,e){return E.useReducer((t,r)=>e[t][r]??t,n)}var Ql="ScrollArea",[Fh]=ru(Ql),[ww,it]=Fh(Ql),Vh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:i=600,...o}=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,C]=E.useState(!1),[w,T]=E.useState(!1),N=vn(e,j=>a(j)),M=hp(s);return p.jsx(ww,{scope:t,type:r,dir:M,scrollHideDelay:i,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:v,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:S,children:p.jsx(Jt.div,{dir:M,...o,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Vh.displayName=Ql;var Hh="ScrollAreaViewport",Wh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...i}=n,o=it(Hh,t),l=E.useRef(null),a=vn(e,l,o.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(Jt.div,{"data-radix-scroll-area-viewport":"",...i,ref:a,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wh.displayName=Hh;var yt="ScrollAreaScrollbar",Uh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=it(yt,n.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=s,l=n.orientation==="horizontal";return E.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),s.type==="hover"?p.jsx(Cw,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(Tw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(qh,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Zl,{...r,ref:e}):null});Uh.displayName=yt;var Cw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=it(yt,n.__scopeScrollArea),[i,o]=E.useState(!1);return E.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),o(!0)},u=()=>{a=window.setTimeout(()=>o(!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(Ar,{present:t||i,children:p.jsx(qh,{"data-state":i?"visible":"hidden",...r,ref:e})})}),Tw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=it(yt,n.__scopeScrollArea),i=n.orientation==="horizontal",o=ki(()=>a("SCROLL_END"),100),[l,a]=vw("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=i?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),o()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,i,a,o]),p.jsx(Ar,{present:t||l!=="hidden",children:p.jsx(Zl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:Bt(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:Bt(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),qh=E.forwardRef((n,e)=>{const t=it(yt,n.__scopeScrollArea),{forceMount:r,...s}=n,[i,o]=E.useState(!1),l=n.orientation==="horizontal",a=ki(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;o(l?c:u)}},10);return Un(t.viewport,a),Un(t.content,a),p.jsx(Ar,{present:r||i,children:p.jsx(Zl,{"data-state":i?"visible":"hidden",...s,ref:e})})}),Zl=E.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=it(yt,n.__scopeScrollArea),i=E.useRef(null),o=E.useRef(0),[l,a]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Yh(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>i.current=f,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:f=>o.current=f};function d(f,h){return Iw(f,o.current,l,h)}return t==="horizontal"?p.jsx(Nw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollLeft,h=Yc(f,l,s.dir);i.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(Mw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollTop,h=Yc(f,l);i.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}),Nw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,i=it(yt,n.__scopeScrollArea),[o,l]=E.useState(),a=E.useRef(null),c=vn(e,a,i.onScrollbarXChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(Jh,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":bi(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(i.viewport){const f=i.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),Zh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:Xs(o.paddingLeft),paddingEnd:Xs(o.paddingRight)}})}})}),Mw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,i=it(yt,n.__scopeScrollArea),[o,l]=E.useState(),a=E.useRef(null),c=vn(e,a,i.onScrollbarYChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(Jh,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":bi(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(i.viewport){const f=i.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),Zh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:Xs(o.paddingTop),paddingEnd:Xs(o.paddingBottom)}})}})}),[Ew,Kh]=Fh(yt),Jh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=it(yt,t),[m,g]=E.useState(null),x=vn(e,N=>g(N)),y=E.useRef(null),b=E.useRef(""),k=h.viewport,S=r.content-r.viewport,v=tn(u),C=tn(a),w=ki(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(C,[r,C]),Un(m,w),Un(h.content,w),p.jsx(Ew,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:tn(i),onThumbPointerUp:tn(o),onThumbPositionChange:C,onThumbPointerDown:tn(l),children:p.jsx(Jt.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:Bt(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:Bt(n.onPointerMove,T),onPointerUp:Bt(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})})})}),Gs="ScrollAreaThumb",Gh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Kh(Gs,n.__scopeScrollArea);return p.jsx(Ar,{present:t||s.hasThumb,children:p.jsx(Aw,{ref:e,...r})})}),Aw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,i=it(Gs,t),o=Kh(Gs,t),{onThumbPositionChange:l}=o,a=vn(e,d=>o.onThumbChange(d)),c=E.useRef(void 0),u=ki(()=>{c.current&&(c.current(),c.current=void 0)},100);return E.useEffect(()=>{const d=i.viewport;if(d){const f=()=>{if(u(),!c.current){const h=Ow(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[i.viewport,u,l]),p.jsx(Jt.div,{"data-state":o.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Bt(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;o.onThumbPointerDown({x:m,y:g})}),onPointerUp:Bt(n.onPointerUp,o.onThumbPointerUp)})});Gh.displayName=Gs;var ea="ScrollAreaCorner",Xh=E.forwardRef((n,e)=>{const t=it(ea,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(jw,{...n,ref:e}):null});Xh.displayName=ea;var jw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=it(ea,t),[i,o]=E.useState(0),[l,a]=E.useState(0),c=!!(i&&l);return Un(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Un(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),o(u)}),c?p.jsx(Jt.div,{...r,ref:e,style:{width:i,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function Xs(n){return n?parseInt(n,10):0}function Yh(n,e){const t=n/e;return isNaN(t)?0:t}function bi(n){const e=Yh(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function Iw(n,e,t,r="ltr"){const s=bi(t),i=s/2,o=e||i,l=s-o,a=t.scrollbar.paddingStart+o,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return Qh([a,c],d)(n)}function Yc(n,e,t="ltr"){const r=bi(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=e.scrollbar.size-s,o=e.content-e.viewport,l=i-r,a=t==="ltr"?[0,o]:[o*-1,0],c=pp(n,a);return Qh([0,o],[0,l])(c)}function Qh(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 Zh(n,e){return n>0&&n<e}var Ow=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const i={left:n.scrollLeft,top:n.scrollTop},o=t.left!==i.left,l=t.top!==i.top;(o||l)&&e(),t=i,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function ki(n,e){const t=tn(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 Un(n,e){const t=tn(e);nu(()=>{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 Rw=Vh,Dw=Wh,Pw=Xh;function jT(n){const e=L.c(17);let t,r,s,i;e[0]!==n?({className:r,children:t,hideScrollbar:i,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=i):(t=e[1],r=e[2],s=e[3],i=e[4]);const o=i===void 0?!1:i;let l;e[5]!==r?(l=Z("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(Dw,{"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]!==o?(c=p.jsx(Lw,{hideScrollbar:o}),e[9]=o,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Pw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(Rw,{"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 Lw(n){const e=L.c(15);let t,r,s,i;e[0]!==n?({className:t,orientation:s,hideScrollbar:i,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=i):(t=e[1],r=e[2],s=e[3],i=e[4]);const o=s===void 0?"vertical":s,l=i===void 0?!1:i,a=o==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=o==="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=Z("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(Gh,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==o||e[12]!==r||e[13]!==d?(h=p.jsx(Uh,{"data-slot":"scroll-area-scrollbar",orientation:o,className:d,...r,children:f}),e[11]=o,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}function Qc(n){const e=L.c(74),{options:t,onValueChange:r,defaultValue:s,placeholder:i,variant:o,animation:l,maxCount:a,modalPopover:c,asChild:u,className:d,disabled:f,onSearchChange:h}=n;let m;e[0]!==s?(m=s===void 0?[]:s,e[0]=s,e[1]=m):m=e[1];const g=m,x=i===void 0?"Select items":i,y=o===void 0?"default":o,b=l===void 0?0:l,k=a===void 0?3:a,S=c===void 0?!1:c,v=u===void 0?!1:u,C=f===void 0?!1:f,[w,T]=E.useState(g),[N,M]=E.useState(!1);let j,O;e[2]!==g||e[3]!==w?(j=()=>{JSON.stringify(w)!==JSON.stringify(g)&&T(g)},O=[g,w],e[2]=g,e[3]=w,e[4]=j,e[5]=O):(j=e[4],O=e[5]),E.useEffect(j,O);let A;e[6]!==r||e[7]!==w?(A=oe=>{if(oe.key==="Enter")M(!0);else if(oe.key==="Backspace"&&!oe.currentTarget.value){const be=[...w];be.pop(),T(be),r(be)}},e[6]=r,e[7]=w,e[8]=A):A=e[8];const R=A;let I;e[9]!==r||e[10]!==w?(I=oe=>{const be=w.includes(oe.value)?w.filter(At=>At!==oe.value):[...w,oe.value];T(be),r(be)},e[9]=r,e[10]=w,e[11]=I):I=e[11];const _=I;let $;e[12]!==r?($=()=>{T([]),r([])},e[12]=r,e[13]=$):$=e[13];const z=$;let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{M(Bw)},e[14]=B):B=e[14];const q=B;let J;e[15]!==z||e[16]!==r||e[17]!==t||e[18]!==w.length?(J=()=>{if(w.length===t.length)z();else{const oe=t.map(zw);T(oe),r(oe)}},e[15]=z,e[16]=r,e[17]=t,e[18]=w.length,e[19]=J):J=e[19];const U=J;let X;e[20]!==v?(X=v?{}:{variant:"outline"},e[20]=v,e[21]=X):X=e[21];let te;e[22]!==d?(te=Z("border-input data-[placeholder]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full max-w-xs items-center justify-between gap-2 rounded-xl border bg-transparent px-3 py-2 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[2px] disabled:cursor-not-allowed disabled:opacity-50 h-10 min-h-10",d),e[22]=d,e[23]=te):te=e[23];let ne;e[24]!==b||e[25]!==k||e[26]!==t||e[27]!==x||e[28]!==w||e[29]!==y?(ne=w.length>0?p.jsxs("div",{className:"flex items-center justify-between w-full min-w-0",children:[p.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[w.slice(0,k).map(oe=>{const be=t.find(Si=>Si.value===oe),At=be?.icon;return p.jsxs(rs,{variant:y==="default"?"default":"secondary",className:"max-w-24",style:{animationDuration:`${b}s`},children:[At&&p.jsx(At,{className:"h-3 w-3 shrink-0"}),p.jsx("span",{className:"truncate",children:be?.label})]},oe)}),w.length>k&&p.jsxs(rs,{variant:y==="default"?"default":"secondary",className:"flex-shrink-0",style:{animationDuration:`${b}s`},children:["+",w.length-k]})]}),p.jsx("div",{className:"flex items-center shrink-0 ml-2",children:p.jsx(Ln,{size:20,className:"shrink-0 opacity-50"})})]}):p.jsxs("div",{className:"flex items-center justify-between w-full",children:[p.jsx("span",{className:"text-sm text-muted-foreground",children:x}),p.jsx(Ln,{size:20,className:"shrink-0 opacity-50"})]}),e[24]=b,e[25]=k,e[26]=t,e[27]=x,e[28]=w,e[29]=y,e[30]=ne):ne=e[30];let re;e[31]!==C||e[32]!==X||e[33]!==te||e[34]!==ne?(re=p.jsx(mu,{asChild:!0,children:p.jsx(mt,{ref:null,...X,onClick:q,className:te,disabled:C,children:ne})}),e[31]=C,e[32]=X,e[33]=te,e[34]=ne,e[35]=re):re=e[35];let le;e[36]===Symbol.for("react.memo_cache_sentinel")?(le=()=>M(!1),e[36]=le):le=e[36];const ye=!h;let V;e[37]!==R||e[38]!==h?(V=p.jsx(jp,{placeholder:"Search...",onKeyDown:R,onValueChange:h,className:"rounded-t-xl"}),e[37]=R,e[38]=h,e[39]=V):V=e[39];let se;e[40]===Symbol.for("react.memo_cache_sentinel")?(se=p.jsx(Ip,{children:"No results found."}),e[40]=se):se=e[40];let ae;e[41]!==U?(ae=()=>{U()},e[41]=U,e[42]=ae):ae=e[42];let de;e[43]!==U?(de=oe=>{oe.stopPropagation(),U()},e[43]=U,e[44]=de):de=e[44];const Ie=w.length===t.length&&t.length>0;let Fe;e[45]!==Ie||e[46]!==U?(Fe=p.jsx(aa,{checked:Ie,onCheckedChange:U,className:"mr-2 [&_svg]:!text-primary-foreground",onClick:$w}),e[45]=Ie,e[46]=U,e[47]=Fe):Fe=e[47];let Ee;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ee=p.jsx("span",{children:"(Select All)"}),e[48]=Ee):Ee=e[48];let Se;e[49]!==de||e[50]!==Fe?(Se=p.jsxs("div",{className:"flex items-center w-full",onClick:de,children:[Fe,Ee]}),e[49]=de,e[50]=Fe,e[51]=Se):Se=e[51];let ve;e[52]!==ae||e[53]!==Se?(ve=p.jsx(ca,{onSelect:ae,className:"cursor-pointer",children:Se},"all"),e[52]=ae,e[53]=Se,e[54]=ve):ve=e[54];let Le;if(e[55]!==t||e[56]!==w||e[57]!==_){let oe;e[59]!==w||e[60]!==_?(oe=be=>{const At=w.includes(be.value);return p.jsx(ca,{onSelect:()=>{_(be)},className:"cursor-pointer",children:p.jsxs("div",{className:"flex items-center w-full",onClick:Si=>{Si.stopPropagation(),_(be)},children:[p.jsx(aa,{checked:At,onCheckedChange:()=>{_(be)},className:"mr-2 [&_svg]:!text-primary-foreground",onClick:_w}),be.icon&&p.jsx(be.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),p.jsx("span",{children:be.label})]})},be.value)},e[59]=w,e[60]=_,e[61]=oe):oe=e[61],Le=t.map(oe),e[55]=t,e[56]=w,e[57]=_,e[58]=Le}else Le=e[58];let K;e[62]!==ve||e[63]!==Le?(K=p.jsxs(Op,{className:"rounded-b-xl",children:[se,p.jsxs(Rp,{children:[ve,Le]})]}),e[62]=ve,e[63]=Le,e[64]=K):K=e[64];let ie;e[65]!==ye||e[66]!==V||e[67]!==K?(ie=p.jsx(gu,{className:"w-auto p-0 max-w-xs rounded-xl",align:"start",onEscapeKeyDown:le,children:p.jsxs(Dp,{shouldFilter:ye,className:"rounded-xl",children:[V,K]})}),e[65]=ye,e[66]=V,e[67]=K,e[68]=ie):ie=e[68];let ce;return e[69]!==N||e[70]!==S||e[71]!==re||e[72]!==ie?(ce=p.jsxs(xu,{open:N,onOpenChange:M,modal:S,children:[re,ie]}),e[69]=N,e[70]=S,e[71]=re,e[72]=ie,e[73]=ce):ce=e[73],ce}function _w(n){return n.stopPropagation()}function $w(n){return n.stopPropagation()}function zw(n){return n.value}function Bw(n){return!n}const ep=[{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"}],Fw=40;function IT(n){const t=(n.endDate.getTime()-n.startDate.getTime())/Fw;return ep.find(s=>s.ms>=t)?.label??"1d"}function ta(n){const e=ep.find(i=>i.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 Vw(n,e){const t=new Date(n);return ta(e)>=864e5?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zc(n,e){const t=ta(e);return new Date(Math.floor(n.getTime()/t)*t)}function Hw(n){return n>=1e4?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}function na(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 ra(n){return Number.isFinite(n)?`$${n.toFixed(n<1?4:2)}`:"$0.00"}function OT(n,e,t){const r=ta(t),s=Zc(e.startDate,t).getTime(),i=e.endDate.getTime(),o=new Map(n.map(a=>[Zc(new Date(a.timestamp),t).getTime(),a])),l=[];for(let a=s;a<=i;a+=r){const c=o.get(a),u=new Date(a).toISOString();l.push({t:u,ts:a,label:Vw(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 RT(n,e){return e==="requests"?n.calls:e==="errors"?n.errorRate:n.avgDurationMs}function DT(n,e){return e==="requests"?n.calls.toLocaleString():e==="errors"?`${n.errorRate.toFixed(1)}%`:Hw(n.avgDurationMs)}function sa(n){return(n.run_config??{}).agent?.id??(n.virtual_mcp_id||null)}function ia(n,e,t,r){if(!n)return r;const s=e.find(o=>o.id===n)??t?.find(o=>o.id===n);if(s?.title)return s.title;const i=wp(n);return i?Cp(i).title??r:n}function oa(n,e,t){return n?(e.find(s=>s.id===n)??t?.find(s=>s.id===n))?.icon??null:null}function tp(n){return n?.data?.members??[]}function Fo(n){const e=L.c(33),{thread:t,connections:r,virtualMcps:s,selectedIndex:i,total:o,onPrev:l,onNext:a}=n;let c,u;if(e[0]!==r||e[1]!==t||e[2]!==s){const j=sa(t);c=ia(j,s,r,""),u=oa(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(Xo,{}),e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==f?(m=p.jsx(Gt,{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(cu,{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=i===0;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(no,{size:14}),e[19]=S):S=e[19];let v;e[20]!==l||e[21]!==k?(v=p.jsx(mt,{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 C=i===o-1;let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Ln,{size:14}),e[23]=w):w=e[23];let T;e[24]!==a||e[25]!==C?(T=p.jsx(mt,{size:"icon",variant:"ghost",onClick:a,disabled:C,className:"h-7 w-7 text-muted-foreground","aria-label":"Next chat",children:w}),e[24]=a,e[25]=C,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(au,{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 Ww(n){const e=L.c(48),{thread:t,connections:r,virtualMcps:s,members:i}=n;let o,l;if(e[0]!==r||e[1]!==t||e[2]!==s){const I=sa(t);o=ia(I,s,r,""),l=oa(I,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=o,e[4]=l}else o=e[3],l=e[4];const a=l;let c;if(e[5]!==i||e[6]!==t.created_by){const I=tp(i);let _;e[8]!==t.created_by?(_=$=>$.userId===t.created_by,e[8]=t.created_by,e[9]=_):_=e[9],c=I.find(_),e[5]=i,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=Pn[t.status]??Pn.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=Z("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 C;e[25]!==k||e[26]!==v?(C=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]=C):C=e[27];let w;e[28]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Date"}),e[28]=w):w=e[28];let T;e[29]!==g?(T=p.jsxs("div",{children:[w,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(yu,{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 O;e[37]!==M||e[38]!==j?(O=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]=O):O=e[39];let A;e[40]!==a||e[41]!==o?(A=o&&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(Gt,{icon:a,name:o,size:"xs",fallbackIcon:p.jsx(Xo,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),p.jsx("span",{className:"text-sm text-foreground",children:o})]})]}),e[40]=a,e[41]=o,e[42]=A):A=e[42];let R;return e[43]!==T||e[44]!==O||e[45]!==A||e[46]!==C?(R=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:[C,T,O,A]}),e[43]=T,e[44]=O,e[45]=A,e[46]=C,e[47]=R):R=e[47],R}function Uw(n){const e=L.c(72),{thread:t,usage:r,members:s,connections:i,virtualMcps:o,onClick:l,lastRowRef:a}=n;let c,u;if(e[0]!==i||e[1]!==t||e[2]!==o){const re=sa(t);c=ia(re,o,i,"—"),u=oa(re,o,i),e[0]=i,e[1]=t,e[2]=o,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 re=tp(s);let le;e[8]!==t.created_by?(le=ye=>ye.userId===t.created_by,e[8]=t.created_by,e[9]=le):le=e[9],f=re.find(le),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 re=new Date(t.created_at);y=re.toLocaleDateString("en-US",{month:"short",day:"numeric"}),b=re.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=Pn[t.status]??Pn.completed,v=S.icon;let C;e[17]!==t.title?(C=p.jsx(Ze,{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]=C):C=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Xo,{}),e[19]=w):w=e[19];let T;e[20]!==d||e[21]!==c?(T=p.jsx(Gt,{icon:d,name:c,size:"xs",fallbackIcon:w,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(Ze,{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(yu,{url:x,fallback:g,shape:"circle",size:"2xs",className:"shrink-0"}),e[28]=x,e[29]=g,e[30]=j):j=e[30];let O;e[31]!==g?(O=p.jsx("span",{className:"truncate",children:g}),e[31]=g,e[32]=O):O=e[32];let A;e[33]!==j||e[34]!==O?(A=p.jsx(Ze,{className:"w-28 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[j,O]})}),e[33]=j,e[34]=O,e[35]=A):A=e[35];let R;e[36]!==v||e[37]!==S.iconClassName?(R=p.jsx(v,{size:14,className:S.iconClassName}),e[36]=v,e[37]=S.iconClassName,e[38]=R):R=e[38];let I;e[39]!==S.labelColor?(I=Z("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 $;e[44]!==R||e[45]!==_?($=p.jsx(Ze,{className:"w-24 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[R,_]})}),e[44]=R,e[45]=_,e[46]=$):$=e[46];let z;e[47]!==r?(z=r?na(r.totalTokens):"—",e[47]=r,e[48]=z):z=e[48];let B;e[49]!==z?(B=p.jsx(Ze,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:z}),e[49]=z,e[50]=B):B=e[50];let q;e[51]!==r?(q=r&&r.costUsd>0?ra(r.costUsd):"—",e[51]=r,e[52]=q):q=e[52];let J;e[53]!==q?(J=p.jsx(Ze,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:q}),e[53]=q,e[54]=J):J=e[54];let U;e[55]!==y?(U=p.jsx("div",{children:y}),e[55]=y,e[56]=U):U=e[56];let X;e[57]!==k?(X=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:k}),e[57]=k,e[58]=X):X=e[58];let te;e[59]!==U||e[60]!==X?(te=p.jsxs(Ze,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[U,X]}),e[59]=U,e[60]=X,e[61]=te):te=e[61];let ne;return e[62]!==a||e[63]!==l||e[64]!==A||e[65]!==$||e[66]!==B||e[67]!==J||e[68]!==te||e[69]!==C||e[70]!==M?(ne=p.jsxs(Ys,{ref:a,className:"h-14 md:h-16 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:l,children:[C,M,A,$,B,J,te]}),e[62]=a,e[63]=l,e[64]=A,e[65]=$,e[66]=B,e[67]=J,e[68]=te,e[69]=C,e[70]=M,e[71]=ne):ne=e[71],ne}const Vo=100;function qw(n){const e=L.c(37),{client:t,locator:r,thread:s,connections:i,virtualMcps:o,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==r||e[1]!==s.id?(f=nt.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 O=>{const{pageParam:A}=O,R=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:Vo,offset:R}});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:Gw,staleTime:6e4},e[6]=f,e[7]=h,e[8]=m):m=e[8];const{data:g,fetchNextPage:x,hasNextPage:y,isFetchingNextPage:b}=Ap(m);let k;e[9]!==g.pages?(k=g.pages.flatMap(Jw).filter(Kw),e[9]=g.pages,e[10]=k):k=e[10];const S=k,v=kw(S);let C;e[11]!==x||e[12]!==y||e[13]!==b?(C=()=>{y&&!b&&x()},e[11]=x,e[12]=y,e[13]=b,e[14]=C):C=e[14];const w=Go(C,y??!1,b);let T;e[15]!==i||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==s||e[20]!==c||e[21]!==o?(T=p.jsx(Fo,{thread:s,connections:i,virtualMcps:o,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[15]=i,e[16]=d,e[17]=u,e[18]=a,e[19]=s,e[20]=c,e[21]=o,e[22]=T):T=e[22];let N;e[23]!==i||e[24]!==l||e[25]!==s||e[26]!==o?(N=p.jsx(Ww,{thread:s,connections:i,virtualMcps:o,members:l}),e[23]=i,e[24]=l,e[25]=s,e[26]=o,e[27]=N):N=e[27];let M;e[28]!==b||e[29]!==w||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((O,A)=>p.jsx("div",{ref:A===v.length-1?w:void 0,children:p.jsx(Sw,{pair:O,isLastPair:A===v.length-1,status:"ready"})},`pair-${O.user?.id??O.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]=w,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 Kw(n){return n.role==="user"||n.role==="assistant"}function Jw(n){return n.items??[]}function Gw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<Vo))return r.length*Vo}function np(n){const e=L.c(39),{thread:t,client:r,locator:s,connections:i,virtualMcps:o,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==i||e[1]!==d||e[2]!==u||e[3]!==a||e[4]!==t||e[5]!==c||e[6]!==o?(f=p.jsx(Fo,{thread:t,connections:i,virtualMcps:o,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[0]=i,e[1]=d,e[2]=u,e[3]=a,e[4]=t,e[5]=c,e[6]=o,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]!==i||e[12]!==d||e[13]!==u||e[14]!==a||e[15]!==t||e[16]!==c||e[17]!==o?(g=p.jsx(Fo,{thread:t,connections:i,virtualMcps:o,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[11]=i,e[12]=d,e[13]=u,e[14]=a,e[15]=t,e[16]=c,e[17]=o,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]!==i||e[24]!==s||e[25]!==l||e[26]!==d||e[27]!==u||e[28]!==a||e[29]!==t||e[30]!==c||e[31]!==o?(b=p.jsx(qw,{client:r,locator:s,thread:t,connections:i,virtualMcps:o,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[22]=r,e[23]=i,e[24]=s,e[25]=l,e[26]=d,e[27]=u,e[28]=a,e[29]=t,e[30]=c,e[31]=o,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(su,{fallback:m,children:k}),e[36]=m,e[37]=k,e[38]=S):S=e[38],S}function PT(n){const e=L.c(43),{filterAgentIds:t,filterUserIds:r,filterStatus:s,virtualMcpOptions:i,memberOptions:o,activeFiltersCount:l,onUpdateFilters:a}=n,[c,u]=E.useState(!1);let d,f;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx(Lp,{size:16}),f=p.jsx("span",{className:"hidden sm:inline",children:"Filters"}),e[0]=d,e[1]=f):(d=e[0],f=e[1]);let h;e[2]!==l?(h=l>0&&p.jsxs(p.Fragment,{children:[p.jsx(rs,{variant:"default",className:"sm:hidden absolute -top-1.5 -right-1.5 h-4 min-w-4 px-1 text-[10px] leading-none",children:l}),p.jsx(rs,{variant:"default",className:"hidden sm:flex ml-1 h-5 w-5 rounded-full p-0 items-center justify-center text-xs",children:l})]}),e[2]=l,e[3]=h):h=e[3];let m;e[4]!==h?(m=p.jsx(mu,{asChild:!0,children:p.jsxs(mt,{variant:"outline",className:"relative",children:[d,f,h]})}),e[4]=h,e[5]=m):m=e[5];let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx("h4",{className:"font-medium text-sm",children:"Filter Chats"}),e[6]=g):g=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Agent"}),e[7]=x):x=e[7];let y;e[8]!==a?(y=I=>a({filterAgentIds:I.slice(0,1)}),e[8]=a,e[9]=y):y=e[9];let b;e[10]!==t||e[11]!==y||e[12]!==i?(b=p.jsxs("div",{children:[x,p.jsx(Qc,{options:i,defaultValue:t,onValueChange:y,placeholder:"All agents",variant:"secondary",className:"w-full",maxCount:1})]}),e[10]=t,e[11]=y,e[12]=i,e[13]=b):b=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"User"}),e[14]=k):k=e[14];let S;e[15]!==a?(S=I=>a({filterUserIds:I.slice(0,1)}),e[15]=a,e[16]=S):S=e[16];let v;e[17]!==r||e[18]!==o||e[19]!==S?(v=p.jsxs("div",{children:[k,p.jsx(Qc,{options:o,defaultValue:r,onValueChange:S,placeholder:"All users",variant:"secondary",className:"w-full",maxCount:1})]}),e[17]=r,e[18]=o,e[19]=S,e[20]=v):v=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Status"}),e[21]=C):C=e[21];let w;e[22]!==a?(w=I=>a({filterStatus:I}),e[22]=a,e[23]=w):w=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(mp,{className:"w-full",children:p.jsx(gp,{})}),e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsxs(xp,{children:[p.jsx(Pr,{value:"all",children:"All statuses"}),p.jsx(Pr,{value:"completed",children:"Completed"}),p.jsx(Pr,{value:"active",children:"Active"}),p.jsx(Pr,{value:"failed",children:"Failed"})]}),e[25]=N):N=e[25];let M;e[26]!==s||e[27]!==w?(M=p.jsxs("div",{children:[C,p.jsxs(yp,{value:s,onValueChange:w,children:[T,N]})]}),e[26]=s,e[27]=w,e[28]=M):M=e[28];let j;e[29]!==v||e[30]!==M||e[31]!==b?(j=p.jsxs("div",{className:"space-y-3",children:[b,v,M]}),e[29]=v,e[30]=M,e[31]=b,e[32]=j):j=e[32];let O;e[33]!==l||e[34]!==a?(O=l>0&&p.jsx(mt,{variant:"ghost",size:"sm",className:"w-full",onClick:()=>{a({filterAgentIds:[],filterUserIds:[],filterStatus:"all"}),u(!1)},children:"Clear all filters"}),e[33]=l,e[34]=a,e[35]=O):O=e[35];let A;e[36]!==j||e[37]!==O?(A=p.jsx(gu,{align:"end",className:"w-[280px]",children:p.jsxs("div",{className:"space-y-4",children:[g,j,O]})}),e[36]=j,e[37]=O,e[38]=A):A=e[38];let R;return e[39]!==c||e[40]!==A||e[41]!==m?(R=p.jsxs(xu,{open:c,onOpenChange:u,children:[m,A]}),e[39]=c,e[40]=A,e[41]=m,e[42]=R):R=e[42],R}const Ho=50;function LT(n){const e=L.c(29),{client:t,locator:r,membersData:s,allConnections:i,allVirtualMcps:o,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}=ou({queryKey:nt.threadsInfinite(r,x),queryFn:async K=>{const{pageParam:ie}=K,ce=ie===void 0?0:ie;if(!t)throw new Error("MCP client is not available");const oe=await t.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:Ho,offset:ce,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 oe.structuredContent??oe},initialPageParam:0,getNextPageParam:tC,staleTime:3e4}),C=(y?.pages??[]).flatMap(eC),w=C.map(Zw),{data:T}=jr({queryKey:nt.monitoringThreadUsage(r,JSON.stringify({ids:w,startDate:m,endDate:g})),queryFn:async()=>{if(!t)throw new Error("MCP client is not available");const K=await t.callTool({name:"MONITORING_THREAD_USAGE",arguments:{threadIds:w,startDate:m,endDate:g}});return K.structuredContent??K},enabled:!!t&&w.length>0,staleTime:3e4}),N=new Map((T?.items??[]).map(Qw)),[M,j]=E.useState(null),[O,A]=E.useState("desc");let R;e[0]!==M?(R=K=>{M===K?A(Yw):(j(K),A("desc"))},e[0]=M,e[1]=R):R=e[1];const I=R,_=K=>{const ie=N.get(K);return ie?M==="cost"?ie.costUsd:ie.totalTokens:0},$=M?[...C].sort((K,ie)=>{const ce=_(K.id),oe=_(ie.id);return O==="desc"?oe-ce:ce-oe}):C,z=f!==null?$[f]??null:null;let B;e[2]!==b||e[3]!==k||e[4]!==S?(B=()=>{k&&!S&&b()},e[2]=b,e[3]=k,e[4]=S,e[5]=B):B=e[5];const J=Go(B,k??!1,S),U=!!a||(c?.length??0)>0||(u?.length??0)>0||d&&d!=="all";let X;e[6]===Symbol.for("react.memo_cache_sentinel")?(X=()=>h(Xw),e[6]=X):X=e[6];const te=X,ne=()=>h(K=>K!==null&&K<$.length-1?K+1:K),re="flex-1 flex flex-col overflow-auto min-w-0",le="mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",ye="flex-1 flex flex-col min-w-0",V="flex-1 min-w-0 pt-1",se="min-w-0",ae=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"})}):C.length===0?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx(to,{title:U?"No matching chats":"No chats in this time range",description:U?"Try adjusting your filters or search query.":"Try expanding the time range to see older chats."})}):p.jsxs(p.Fragment,{children:[p.jsxs(uu,{className:"w-full border-collapse",children:[p.jsx(du,{className:"border-b-0 z-20",children:p.jsxs(Ys,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Qe,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Title"}),p.jsx(Qe,{className:"w-36 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Agent"}),p.jsx(Qe,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"User"}),p.jsx(Qe,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Qe,{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"&&(O==="desc"?p.jsx(Ln,{size:12}):p.jsx(no,{size:12}))]})}),p.jsx(Qe,{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"&&(O==="desc"?p.jsx(Ln,{size:12}):p.jsx(no,{size:12}))]})}),p.jsx(Qe,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Date"})]})}),p.jsx(fu,{children:$.map((K,ie)=>p.jsx(Uw,{thread:K,usage:N.get(K.id),members:s,connections:i,virtualMcps:o,onClick:()=>h(ie),lastRowRef:ie===$.length-1?J:void 0},K.id))})]}),S&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more..."})]});let de;e[7]!==ae?(de=p.jsx("div",{className:le,children:p.jsx("div",{className:ye,children:p.jsx("div",{className:V,children:p.jsx("div",{className:se,children:ae})})})}),e[7]=ae,e[8]=de):de=e[8];const Ie=f!==null;let Fe;e[9]===Symbol.for("react.memo_cache_sentinel")?(Fe=K=>{K||h(null)},e[9]=Fe):Fe=e[9];let Ee;e[10]!==i||e[11]!==o||e[12]!==t||e[13]!==$||e[14]!==ne||e[15]!==te||e[16]!==r||e[17]!==s||e[18]!==z||e[19]!==f?(Ee=z&&f!==null&&p.jsx(np,{thread:z,client:t,locator:r,connections:i,virtualMcps:o,members:s,selectedIndex:f,total:$.length,onPrev:te,onNext:ne}),e[10]=i,e[11]=o,e[12]=t,e[13]=$,e[14]=ne,e[15]=te,e[16]=r,e[17]=s,e[18]=z,e[19]=f,e[20]=Ee):Ee=e[20];let Se;e[21]!==Ee?(Se=p.jsx(Ko,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:Ee}),e[21]=Ee,e[22]=Se):Se=e[22];let ve;e[23]!==Ie||e[24]!==Se?(ve=p.jsx(Jo,{open:Ie,onOpenChange:Fe,children:Se}),e[23]=Ie,e[24]=Se,e[25]=ve):ve=e[25];let Le;return e[26]!==de||e[27]!==ve?(Le=p.jsxs("div",{className:re,children:[de,ve]}),e[26]=de,e[27]=ve,e[28]=Le):Le=e[28],Le}function Xw(n){return n!==null&&n>0?n-1:n}function Yw(n){return n==="desc"?"asc":"desc"}function Qw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function Zw(n){return n.id}function eC(n){return n.items??[]}function tC(n,e){const t=n,r=e;if(!((t?.items?.length??0)<Ho))return r.length*Ho}const Wo=50;function Yr(n){const e=L.c(10),{title:t,value:r,subtitle:s}=n;let i;e[0]!==t?(i=p.jsx("span",{className:"text-sm text-foreground/70",children:t}),e[0]=t,e[1]=i):i=e[1];let o;e[2]!==r?(o=p.jsx("span",{className:"text-3xl font-normal tabular-nums",children:r}),e[2]=r,e[3]=o):o=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]!==i||e[7]!==o||e[8]!==l?(a=p.jsxs(Np,{className:"pt-4 px-4 pb-5 gap-1",children:[i,o,l]}),e[6]=i,e[7]=o,e[8]=l,e[9]=a):a=e[9],a}function nC(n){const e=L.c(27),{automationId:t,range:r}=n,{data:s,isLoading:i}=Ep(t,r),o=s?.runs,l=s?.usage;let a;e[0]!==o?(a=o&&o.total>0?`${Math.round(o.completed/o.total*100)}%`:"—",e[0]=o,e[1]=a):a=e[1];const c=a,u=l&&l.truncated?`last ${l.sampledRuns} runs`:void 0;let d;e[2]!==i||e[3]!==o?.total?(d=i?"…":o?.total.toLocaleString()??"0",e[2]=i,e[3]=o?.total,e[4]=d):d=e[4];const f=o?`${o.completed} ok · ${o.failed} failed${o.inProgress>0?` · ${o.inProgress} running`:""}`:void 0;let h;e[5]!==d||e[6]!==f?(h=p.jsx(Yr,{title:"Runs",value:d,subtitle:f}),e[5]=d,e[6]=f,e[7]=h):h=e[7];const m=i?"…":c;let g;e[8]!==m?(g=p.jsx(Yr,{title:"Success rate",value:m}),e[8]=m,e[9]=g):g=e[9];let x;e[10]!==i||e[11]!==l?.totalTokens?(x=i?"…":na(l?.totalTokens??0),e[10]=i,e[11]=l?.totalTokens,e[12]=x):x=e[12];let y;e[13]!==x||e[14]!==u?(y=p.jsx(Yr,{title:"Tokens",value:x,subtitle:u}),e[13]=x,e[14]=u,e[15]=y):y=e[15];let b;e[16]!==i||e[17]!==l?(b=i?"…":l&&l.costUsd>0?ra(l.costUsd):"—",e[16]=i,e[17]=l,e[18]=b):b=e[18];let k;e[19]!==b||e[20]!==u?(k=p.jsx(Yr,{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 rC(n){const e=L.c(39),{run:t,usage:r,onClick:s,lastRowRef:i}=n;let o,l;if(e[0]!==t.created_at){const T=new Date(t.created_at);o=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]=o,e[2]=l}else o=e[1],l=e[2];const a=l,c=Pn[t.status]??Pn.completed,u=c.icon;let d;e[3]!==t.title?(d=p.jsx(Ze,{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=Z("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(Ze,{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?na(r.totalTokens):"—",e[16]=r,e[17]=x):x=e[17];let y;e[18]!==x?(y=p.jsx(Ze,{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?ra(r.costUsd):"—",e[20]=r,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(Ze,{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]!==o?(S=p.jsx("div",{children:o}),e[24]=o,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 C;e[28]!==S||e[29]!==v?(C=p.jsxs(Ze,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[S,v]}),e[28]=S,e[29]=v,e[30]=C):C=e[30];let w;return e[31]!==i||e[32]!==s||e[33]!==k||e[34]!==C||e[35]!==d||e[36]!==g||e[37]!==y?(w=p.jsxs(Ys,{ref:i,className:"h-14 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:s,children:[d,g,y,k,C]}),e[31]=i,e[32]=s,e[33]=k,e[34]=C,e[35]=d,e[36]=g,e[37]=y,e[38]=w):w=e[38],w}function _T(n){const e=L.c(48),{automationId:t,triggerIds:r,range:s}=n,{org:i,locator:o}=Mt();let l;e[0]!==i.id||e[1]!==i.slug?(l={connectionId:Tp,orgId:i.id,orgSlug:i.slug},e[0]=i.id,e[1]=i.slug,e[2]=l):l=e[2];const a=qo(l),c=pu(),u=bp(),d=Sp(),{data:f}=Mp(),[h,m]=E.useState(null),g=r.length>0;let x;e[3]!==t||e[4]!==i.id||e[5]!==r?(x=nt.automationRuns(i.id,t,r),e[3]=t,e[4]=i.id,e[5]=r,e[6]=x):x=e[6];let y;e[7]!==c||e[8]!==r?(y=async V=>{const{pageParam:se}=V,ae=se===void 0?0:se;return await c.call("COLLECTION_THREADS_LIST",{limit:Wo,offset:ae,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:aC,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:C,isLoading:w}=ou(b),T=(k?.pages??[]).flatMap(lC),N=T.map(oC),{data:M}=jr({queryKey:nt.monitoringThreadUsage(o,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(iC)),e[14]=M?.items,e[15]=j):j=e[15];const O=j;let A;e[16]!==S||e[17]!==v||e[18]!==C?(A=()=>{v&&!C&&S()},e[16]=S,e[17]=v,e[18]=C,e[19]=A):A=e[19];const R=Go(A,v??!1,C),I=h!==null?T[h]??null:null;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=()=>m(sC),e[20]=_):_=e[20];const $=_,z=()=>m(V=>V!==null&&V<T.length-1?V+1:V),B="flex flex-col gap-5";let q;e[21]!==t||e[22]!==s?(q=p.jsx(nC,{automationId:t,range:s}),e[21]=t,e[22]=s,e[23]=q):q=e[23];const J=g?w?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(to,{title:"No runs yet",description:"This automation hasn't run yet. Trigger it or wait for a starter to fire."})}):p.jsxs(uu,{className:"w-full border-collapse",children:[p.jsx(du,{className:"border-b-0",children:p.jsxs(Ys,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Qe,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Run"}),p.jsx(Qe,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Qe,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Tokens"}),p.jsx(Qe,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Cost"}),p.jsx(Qe,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Started"})]})}),p.jsx(fu,{children:T.map((V,se)=>p.jsx(rC,{run:V,usage:O.get(V.id),onClick:()=>m(se),lastRowRef:se===T.length-1?R:void 0},V.id))})]}):p.jsx("div",{className:"py-16",children:p.jsx(to,{title:"No starters yet",description:"Add a starter (cron, event, or webhook) to start collecting runs."})});let U;e[24]!==C?(U=C&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more…"}),e[24]=C,e[25]=U):U=e[25];const X=h!==null;let te;e[26]===Symbol.for("react.memo_cache_sentinel")?(te=V=>{V||m(null)},e[26]=te):te=e[26];let ne;e[27]!==u||e[28]!==d||e[29]!==a||e[30]!==z||e[31]!==$||e[32]!==o||e[33]!==f||e[34]!==T||e[35]!==I||e[36]!==h?(ne=I&&h!==null&&p.jsx(np,{thread:I,client:a,locator:o,connections:u,virtualMcps:d,members:f,selectedIndex:h,total:T.length,onPrev:$,onNext:z}),e[27]=u,e[28]=d,e[29]=a,e[30]=z,e[31]=$,e[32]=o,e[33]=f,e[34]=T,e[35]=I,e[36]=h,e[37]=ne):ne=e[37];let re;e[38]!==ne?(re=p.jsx(Ko,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:ne}),e[38]=ne,e[39]=re):re=e[39];let le;e[40]!==X||e[41]!==re?(le=p.jsx(Jo,{open:X,onOpenChange:te,children:re}),e[40]=X,e[41]=re,e[42]=le):le=e[42];let ye;return e[43]!==J||e[44]!==U||e[45]!==le||e[46]!==q?(ye=p.jsxs("div",{className:B,children:[q,J,U,le]}),e[43]=J,e[44]=U,e[45]=le,e[46]=q,e[47]=ye):ye=e[47],ye}function sC(n){return n!==null&&n>0?n-1:n}function iC(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function oC(n){return n.id}function lC(n){return n.items??[]}function aC(n,e){const t=n,r=e;if(!((t?.items?.length??0)<Wo))return r.length*Wo}export{PT as $,jT as A,TT as B,MT as C,pe as D,Ol as E,ck as F,qv as G,ke as H,Q2 as I,Z2 as J,eS as K,_T as L,pi as M,nS as N,zv as O,Um as P,IT as Q,Y2 as R,CT as S,NT as T,OT as U,na as V,ra as W,Hw as X,DT as Y,RT as Z,tp as _,Zf as a,LT as a0,Qc as a1,Me as b,Qf as c,Vm as d,me as e,wT as f,nl as g,Ve as h,vT as i,bT as j,ST as k,rk as l,kT as m,ik as n,q2 as o,Uf as p,yT as q,kw as r,rl as s,Pu as t,Gb as u,Bm as v,ET as w,Sw as x,AT as y,$v as z};
188
+ `);d=!o&&b.trim()?b:null,e[8]=o,e[9]=r,e[10]=d}else d=e[10];const f=d,h=!s&&t!=null?t/1e3:void 0;let m;e[11]!==s?(m=s?p.jsx(Qs,{className:"size-4"}):p.jsx(qp,{className:"size-4"}),e[11]=s,e[12]=m):m=e[12];const g=s?"Thinking...":a,x=s?"loading":"idle";let y;return e[13]!==f||e[14]!==h||e[15]!==u||e[16]!==m||e[17]!==g||e[18]!==x?(y=p.jsx(Bo,{icon:m,title:g,summary:u,detail:f,state:x,detailVariant:"prose",latency:h}),e[13]=f,e[14]=h,e[15]=u,e[16]=m,e[17]=g,e[18]=x,e[19]=y):y=e[19],y}function tw(n){return n.text??""}function nw(n){return n.text??""}function rw(n){return n.text?.includes("REDACTED")}const sw=3;function iw(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 ow(n,e){let t=0,r=0;for(const s of n)if(s.kind==="reasoning-group")r++;else{const i=e[s.index]?.type;i==="text"?r++:(i==="dynamic-tool"||i?.startsWith("tool-"))&&i!=="tool-todo_write"&&i!=="tool-update_interests"&&t++}return{toolCalls:t,messages:r}}function lw(n){const e=L.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(bu,{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 i;e[3]!==r?(i=r>0&&p.jsxs(p.Fragment,{children:[p.jsx(Jp,{className:"size-3.5 shrink-0"}),p.jsxs("span",{children:[r," message",r===1?"":"s"]})]}),e[3]=r,e[4]=i):i=e[4];let o;return e[5]!==s||e[6]!==i?(o=p.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[s,i]}),e[5]=s,e[6]=i,e[7]=o):o=e[7],o}function aw(n){const e=L.c(28),{items:t,message:r,reasoningGroups:s,isReasoningActive:i,totalDuration:o,dataParts:l,isLoading:a,isLast:c}=n;let u;e[0]!==t||e[1]!==r.parts?(u=ow(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(lw,{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]!==i||e[10]!==t||e[11]!==r||e[12]!==s||e[13]!==o){let y;e[15]!==l||e[16]!==c||e[17]!==a||e[18]!==i||e[19]!==r||e[20]!==s||e[21]!==o?(y=(b,k)=>Bh({item:b,renderIndex:k,message:r,reasoningGroups:s,isReasoningActive:i,totalDuration:o,dataParts:l,isLoading:a,isLast:c,isLastVisiblePart:!1}),e[15]=l,e[16]=c,e[17]=a,e[18]=i,e[19]=r,e[20]=s,e[21]=o,e[22]=y):y=e[22],m=t.map(y),e[6]=l,e[7]=c,e[8]=a,e[9]=i,e[10]=t,e[11]=r,e[12]=s,e[13]=o,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(ee,{icon:null,alwaysChevron:!0,title:h,state:"idle",children:g}),e[25]=h,e[26]=g,e[27]=x):x=e[27],x}function Bh({item:n,renderIndex:e,message:t,reasoningGroups:r,isReasoningActive:s,totalDuration:i,dataParts:o,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?i:null;return p.jsx(ew,{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?Du(Ru(),t.metadata?.usage):null;return p.jsx(cw,{part:d,id:t.id,usageStats:f&&p.jsx(K2,{usage:h,duration:i}),dataParts:o,isLoading:l,isLastMessage:a},`${t.id}-${n.index}`)}function cw(n){const e=L.c(121),{part:t,id:r,usageStats:s,dataParts:i,isLoading:o,isLastMessage:l}=n;let a;e[0]!==i.toolMetadata?(a=f=>i.toolMetadata.get(f),e[0]=i.toolMetadata,e[1]=a):a=e[1];const c=a;let u;e[2]!==i.toolSubtaskMetadata?(u=f=>i.toolSubtaskMetadata.get(f),e[2]=i.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(qc,{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(BS,{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(YS,{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(TS,{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(ES,{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]!==i.webSearchStreaming||e[47]!==t.toolCallId?(h=i.webSearchStreaming.get(t.toolCallId),e[46]=i.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(zS,{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(GS,{...x}),children:p.jsx(XS,{...x})}),e[67]=x,e[68]=y):y=e[68],y}case"text":{const f=!!s&&!o,h=o&&l;let m;return e[69]!==r||e[70]!==t||e[71]!==f||e[72]!==h||e[73]!==s?(m=p.jsx(pi,{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(cv,{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(uv,{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(dv,{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(xv,{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(Sv,{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(Tv,{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]!==i.toolMetadata||e[112]!==h?(m=i.toolMetadata.get(h),e[111]=i.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(qc,{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 uw(n){const e=L.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(Qs,{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 dw(n){const e=L.c(7),{className:t,children:r}=n;let s;e[0]!==t?(s=Z("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 i;e[2]!==r?(i=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]=i):i=e[3];let o;return e[4]!==s||e[5]!==i?(o=p.jsx("div",{className:s,children:i}),e[4]=s,e[5]=i,e[6]=o):o=e[6],o}function fw(n){const e=L.c(31),{message:t,turnStartedAt:r,status:s,className:i,isLast:o}=n,l=o===void 0?!1:o,{isRunInProgress:a}=Kn()??{},c=a===void 0?!1:a,u=el()?.taskId??null,d=s==="streaming",h=d||s==="submitted";let m;e[0]!==r?(m=Qo(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:C,renderOrder:w,dataParts:T}=Uv(t),N=t!==null&&w.length>0,M=t&&t.parts.length>0?t.parts[t.parts.length-1]:null,j=d&&M?.type==="reasoning";let O;if(e[4]!==t){const B=t?.metadata?.reasoning_start_at?new Date(t.metadata.reasoning_start_at):null,q=t?.metadata?.reasoning_end_at?new Date(t.metadata.reasoning_end_at):new Date;O=B!==null?q.getTime()-B.getTime():null,e[4]=t,e[5]=O}else O=e[5];const A=O;let R;e[6]!==l||e[7]!==t?(R=!l||!t||!t.parts.some(pw),e[6]=l,e[7]=t,e[8]=R):R=e[8];const I=R;let _;e[9]!==N||e[10]!==h||e[11]!==I||e[12]!==t||e[13]!==w?(_=!h&&N&&I&&(()=>{let B=0;for(const q of w)if(q.kind==="part"){const J=t.parts[q.index]?.type;(J==="dynamic-tool"||J?.startsWith("tool-"))&&B++}return B>=sw})(),e[9]=N,e[10]=h,e[11]=I,e[12]=t,e[13]=w,e[14]=_):_=e[14];const $=_;let z;if(e[15]!==i||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]!==C||e[25]!==w||e[26]!==$||e[27]!==v||e[28]!==u||e[29]!==A){const{collapsed:B,tail:q}=$?iw(w,t.parts):{collapsed:[],tail:w};z=p.jsx(dw,{className:i,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(iu,{className:"size-3 shrink-0"}),p.jsx("span",{children:"Resumed — background task completed"})]}),B.length>0&&p.jsx(aw,{items:B,message:t,reasoningGroups:C,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l}),q.map((J,U)=>{const X=B.length+U,te=q.findLastIndex(hw)===U;return Bh({item:J,renderIndex:X,message:t,reasoningGroups:C,isReasoningActive:j,totalDuration:A,dataParts:T,isLoading:h,isLast:l,isLastVisiblePart:te,renderOrder:w})}),u&&p.jsx(Vv,{threadId:u,message:t}),l&&h&&v!==null&&p.jsx(Yv,{startedAt:v}),l&&!h&&u&&p.jsxs(p.Fragment,{children:[p.jsx(Ov,{}),I&&p.jsx(Ev,{})]}),!h&&p.jsx(Ah,{message:t})]}):h?p.jsx(Zv,{startedAt:v}):p.jsx(uw,{isRunInProgress:l&&c})}),e[15]=i,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]=C,e[25]=w,e[26]=$,e[27]=v,e[28]=u,e[29]=A,e[30]=z}else z=e[30];return z}function hw(n){return n.kind==="part"}function pw(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 mw(n){const e=L.c(21),{event:t}=n,[r,s]=E.useState(!1);let i;e[0]!==t.data?(i=JSON.stringify(t.data,null,2),e[0]=t.data,e[1]=i):i=e[1];const o=i;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>s(gw),e[2]=l):l=e[2];let a,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx(Gp,{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=Z("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(Ln,{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]!==o?(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:o})]}),e[14]=t.source,e[15]=r,e[16]=o,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 gw(n){return!n}const xw=[q2.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),ik,ck];function yw(n){const e=L.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:xw,content:t,editable:!1,editorProps:r},e[1]=t,e[2]=s):s=e[2];const i=Gb(s);if(!i)return null;let o;return e[3]!==i?(o=p.jsx(Uf,{editor:i,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:cursor-text"}),e[3]=i,e[4]=o):o=e[4],o}function bw(n){const e=L.c(38),{message:t,className:r,onScrollToPair:s}=n,{id:i,parts:o,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(!o||o.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=Z("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 C;e[8]!==a||e[9]!==u?(C=Z("z-10 px-4 py-2 flex-1 transition-[max-height,opacity] duration-300 ease-out",a?"max-h-[50vh] overflow-auto opacity-100":Z("max-h-[84px] overflow-hidden opacity-99",u&&"mask-b-from-1%")),e[8]=a,e[9]=u,e[10]=C):C=e[10];let w;if(e[11]!==i||e[12]!==o){let I;e[14]!==i?(I=(_,$)=>_.type==="data-trigger-event"?p.jsx(mw,{event:_.data},`${i}-${$}`):null,e[14]=i,e[15]=I):I=e[15],w=o.map(I),e[11]=i,e[12]=o,e[13]=w}else w=e[13];let T;e[16]!==y||e[17]!==i||e[18]!==l||e[19]!==o?(T=y?p.jsx(yw,{tiptapDoc:l.tiptapDoc}):o.map((I,_)=>I.type==="text"?o[_-1]?.type==="data-trigger-event"?null:p.jsx(pi,{id:i,part:I},`${i}-${_}`):null),e[16]=y,e[17]=i,e[18]=l,e[19]=o,e[20]=T):T=e[20];let N;e[21]!==w||e[22]!==T?(N=p.jsxs("div",{className:"flex flex-col gap-2",children:[w,T]}),e[21]=w,e[22]=T,e[23]=N):N=e[23];let M;e[24]!==N||e[25]!==C?(M=p.jsx("div",{ref:m,className:C,children:N}),e[24]=N,e[25]=C,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 O;e[30]!==t?(O=p.jsx(Ah,{message:t,className:"mt-1 mr-1 self-end"}),e[30]=t,e[31]=O):O=e[31];let A;e[32]!==j||e[33]!==O?(A=p.jsxs("div",{className:"w-full min-w-0 flex flex-col",children:[j,O]}),e[32]=j,e[33]=O,e[34]=A):A=e[34];let R;return e[35]!==A||e[36]!==b?(R=p.jsx(p.Fragment,{children:p.jsx("div",{className:b,children:A})}),e[35]=A,e[36]=b,e[37]=R):R=e[37],R}function kw(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 i=t[r+1];i&&i.role==="assistant"?(e.push({user:s,assistant:i}),r++):e.push({user:s,assistant:null})}else s.role==="assistant"&&e.push({user:null,assistant:s})}return e}function Sw(n){const e=L.c(19),{pair:t,isLastPair:r,status:s}=n,i=E.useRef(null),o=E.useRef(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{i.current&&i.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(i.current=y,!r||!y||o.current||(o.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=Z("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(bw,{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(fw,{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 vw(n,e){return E.useReducer((t,r)=>e[t][r]??t,n)}var Ql="ScrollArea",[Fh]=ru(Ql),[ww,it]=Fh(Ql),Vh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:i=600,...o}=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,C]=E.useState(!1),[w,T]=E.useState(!1),N=vn(e,j=>a(j)),M=hp(s);return p.jsx(ww,{scope:t,type:r,dir:M,scrollHideDelay:i,scrollArea:l,viewport:c,onViewportChange:u,content:d,onContentChange:f,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:v,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:w,onScrollbarYEnabledChange:T,onCornerWidthChange:b,onCornerHeightChange:S,children:p.jsx(Jt.div,{dir:M,...o,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...n.style}})})});Vh.displayName=Ql;var Hh="ScrollAreaViewport",Wh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...i}=n,o=it(Hh,t),l=E.useRef(null),a=vn(e,l,o.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(Jt.div,{"data-radix-scroll-area-viewport":"",...i,ref:a,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...n.style},children:p.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wh.displayName=Hh;var yt="ScrollAreaScrollbar",Uh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=it(yt,n.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=s,l=n.orientation==="horizontal";return E.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),s.type==="hover"?p.jsx(Cw,{...r,ref:e,forceMount:t}):s.type==="scroll"?p.jsx(Tw,{...r,ref:e,forceMount:t}):s.type==="auto"?p.jsx(qh,{...r,ref:e,forceMount:t}):s.type==="always"?p.jsx(Zl,{...r,ref:e}):null});Uh.displayName=yt;var Cw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=it(yt,n.__scopeScrollArea),[i,o]=E.useState(!1);return E.useEffect(()=>{const l=s.scrollArea;let a=0;if(l){const c=()=>{window.clearTimeout(a),o(!0)},u=()=>{a=window.setTimeout(()=>o(!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(Ar,{present:t||i,children:p.jsx(qh,{"data-state":i?"visible":"hidden",...r,ref:e})})}),Tw=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=it(yt,n.__scopeScrollArea),i=n.orientation==="horizontal",o=ki(()=>a("SCROLL_END"),100),[l,a]=vw("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=i?"scrollLeft":"scrollTop";if(c){let d=c[u];const f=()=>{const h=c[u];d!==h&&(a("SCROLL"),o()),d=h};return c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)}},[s.viewport,i,a,o]),p.jsx(Ar,{present:t||l!=="hidden",children:p.jsx(Zl,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:Bt(n.onPointerEnter,()=>a("POINTER_ENTER")),onPointerLeave:Bt(n.onPointerLeave,()=>a("POINTER_LEAVE"))})})}),qh=E.forwardRef((n,e)=>{const t=it(yt,n.__scopeScrollArea),{forceMount:r,...s}=n,[i,o]=E.useState(!1),l=n.orientation==="horizontal",a=ki(()=>{if(t.viewport){const c=t.viewport.offsetWidth<t.viewport.scrollWidth,u=t.viewport.offsetHeight<t.viewport.scrollHeight;o(l?c:u)}},10);return Un(t.viewport,a),Un(t.content,a),p.jsx(Ar,{present:r||i,children:p.jsx(Zl,{"data-state":i?"visible":"hidden",...s,ref:e})})}),Zl=E.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=it(yt,n.__scopeScrollArea),i=E.useRef(null),o=E.useRef(0),[l,a]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Yh(l.viewport,l.content),u={...r,sizes:l,onSizesChange:a,hasThumb:c>0&&c<1,onThumbChange:f=>i.current=f,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:f=>o.current=f};function d(f,h){return Iw(f,o.current,l,h)}return t==="horizontal"?p.jsx(Nw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollLeft,h=Yc(f,l,s.dir);i.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(Mw,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollTop,h=Yc(f,l);i.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}),Nw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,i=it(yt,n.__scopeScrollArea),[o,l]=E.useState(),a=E.useRef(null),c=vn(e,a,i.onScrollbarXChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(Jh,{"data-orientation":"horizontal",...s,ref:c,sizes:t,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":bi(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.x),onDragScroll:u=>n.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(i.viewport){const f=i.viewport.scrollLeft+u.deltaX;n.onWheelScroll(f),Zh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:Xs(o.paddingLeft),paddingEnd:Xs(o.paddingRight)}})}})}),Mw=E.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,i=it(yt,n.__scopeScrollArea),[o,l]=E.useState(),a=E.useRef(null),c=vn(e,a,i.onScrollbarYChange);return E.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),p.jsx(Jh,{"data-orientation":"vertical",...s,ref:c,sizes:t,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":bi(t)+"px",...n.style},onThumbPointerDown:u=>n.onThumbPointerDown(u.y),onDragScroll:u=>n.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(i.viewport){const f=i.viewport.scrollTop+u.deltaY;n.onWheelScroll(f),Zh(f,d)&&u.preventDefault()}},onResize:()=>{a.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:Xs(o.paddingTop),paddingEnd:Xs(o.paddingBottom)}})}})}),[Ew,Kh]=Fh(yt),Jh=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=n,h=it(yt,t),[m,g]=E.useState(null),x=vn(e,N=>g(N)),y=E.useRef(null),b=E.useRef(""),k=h.viewport,S=r.content-r.viewport,v=tn(u),C=tn(a),w=ki(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(C,[r,C]),Un(m,w),Un(h.content,w),p.jsx(Ew,{scope:t,scrollbar:m,hasThumb:s,onThumbChange:tn(i),onThumbPointerUp:tn(o),onThumbPositionChange:C,onThumbPointerDown:tn(l),children:p.jsx(Jt.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:Bt(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:Bt(n.onPointerMove,T),onPointerUp:Bt(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})})})}),Gs="ScrollAreaThumb",Gh=E.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=Kh(Gs,n.__scopeScrollArea);return p.jsx(Ar,{present:t||s.hasThumb,children:p.jsx(Aw,{ref:e,...r})})}),Aw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,i=it(Gs,t),o=Kh(Gs,t),{onThumbPositionChange:l}=o,a=vn(e,d=>o.onThumbChange(d)),c=E.useRef(void 0),u=ki(()=>{c.current&&(c.current(),c.current=void 0)},100);return E.useEffect(()=>{const d=i.viewport;if(d){const f=()=>{if(u(),!c.current){const h=Ow(d,l);c.current=h,l()}};return l(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[i.viewport,u,l]),p.jsx(Jt.div,{"data-state":o.hasThumb?"visible":"hidden",...s,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Bt(n.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;o.onThumbPointerDown({x:m,y:g})}),onPointerUp:Bt(n.onPointerUp,o.onThumbPointerUp)})});Gh.displayName=Gs;var ea="ScrollAreaCorner",Xh=E.forwardRef((n,e)=>{const t=it(ea,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?p.jsx(jw,{...n,ref:e}):null});Xh.displayName=ea;var jw=E.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=it(ea,t),[i,o]=E.useState(0),[l,a]=E.useState(0),c=!!(i&&l);return Un(s.scrollbarX,()=>{const u=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(u),a(u)}),Un(s.scrollbarY,()=>{const u=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(u),o(u)}),c?p.jsx(Jt.div,{...r,ref:e,style:{width:i,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function Xs(n){return n?parseInt(n,10):0}function Yh(n,e){const t=n/e;return isNaN(t)?0:t}function bi(n){const e=Yh(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function Iw(n,e,t,r="ltr"){const s=bi(t),i=s/2,o=e||i,l=s-o,a=t.scrollbar.paddingStart+o,c=t.scrollbar.size-t.scrollbar.paddingEnd-l,u=t.content-t.viewport,d=r==="ltr"?[0,u]:[u*-1,0];return Qh([a,c],d)(n)}function Yc(n,e,t="ltr"){const r=bi(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=e.scrollbar.size-s,o=e.content-e.viewport,l=i-r,a=t==="ltr"?[0,o]:[o*-1,0],c=pp(n,a);return Qh([0,o],[0,l])(c)}function Qh(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 Zh(n,e){return n>0&&n<e}var Ow=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const i={left:n.scrollLeft,top:n.scrollTop},o=t.left!==i.left,l=t.top!==i.top;(o||l)&&e(),t=i,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function ki(n,e){const t=tn(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 Un(n,e){const t=tn(e);nu(()=>{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 Rw=Vh,Dw=Wh,Pw=Xh;function IT(n){const e=L.c(17);let t,r,s,i;e[0]!==n?({className:r,children:t,hideScrollbar:i,...s}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=i):(t=e[1],r=e[2],s=e[3],i=e[4]);const o=i===void 0?!1:i;let l;e[5]!==r?(l=Z("relative h-full w-full",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]!==t?(a=p.jsx(Dw,{"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]!==o?(c=p.jsx(Lw,{hideScrollbar:o}),e[9]=o,e[10]=c):c=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx(Pw,{}),e[11]=u):u=e[11];let d;return e[12]!==s||e[13]!==l||e[14]!==a||e[15]!==c?(d=p.jsxs(Rw,{"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 Lw(n){const e=L.c(15);let t,r,s,i;e[0]!==n?({className:t,orientation:s,hideScrollbar:i,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s,e[4]=i):(t=e[1],r=e[2],s=e[3],i=e[4]);const o=s===void 0?"vertical":s,l=i===void 0?!1:i,a=o==="vertical"&&"h-full w-2.5 border-l border-l-transparent",c=o==="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=Z("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(Gh,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"}),e[10]=f):f=e[10];let h;return e[11]!==o||e[12]!==r||e[13]!==d?(h=p.jsx(Uh,{"data-slot":"scroll-area-scrollbar",orientation:o,className:d,...r,children:f}),e[11]=o,e[12]=r,e[13]=d,e[14]=h):h=e[14],h}function Qc(n){const e=L.c(74),{options:t,onValueChange:r,defaultValue:s,placeholder:i,variant:o,animation:l,maxCount:a,modalPopover:c,asChild:u,className:d,disabled:f,onSearchChange:h}=n;let m;e[0]!==s?(m=s===void 0?[]:s,e[0]=s,e[1]=m):m=e[1];const g=m,x=i===void 0?"Select items":i,y=o===void 0?"default":o,b=l===void 0?0:l,k=a===void 0?3:a,S=c===void 0?!1:c,v=u===void 0?!1:u,C=f===void 0?!1:f,[w,T]=E.useState(g),[N,M]=E.useState(!1);let j,O;e[2]!==g||e[3]!==w?(j=()=>{JSON.stringify(w)!==JSON.stringify(g)&&T(g)},O=[g,w],e[2]=g,e[3]=w,e[4]=j,e[5]=O):(j=e[4],O=e[5]),E.useEffect(j,O);let A;e[6]!==r||e[7]!==w?(A=oe=>{if(oe.key==="Enter")M(!0);else if(oe.key==="Backspace"&&!oe.currentTarget.value){const be=[...w];be.pop(),T(be),r(be)}},e[6]=r,e[7]=w,e[8]=A):A=e[8];const R=A;let I;e[9]!==r||e[10]!==w?(I=oe=>{const be=w.includes(oe.value)?w.filter(At=>At!==oe.value):[...w,oe.value];T(be),r(be)},e[9]=r,e[10]=w,e[11]=I):I=e[11];const _=I;let $;e[12]!==r?($=()=>{T([]),r([])},e[12]=r,e[13]=$):$=e[13];const z=$;let B;e[14]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{M(Bw)},e[14]=B):B=e[14];const q=B;let J;e[15]!==z||e[16]!==r||e[17]!==t||e[18]!==w.length?(J=()=>{if(w.length===t.length)z();else{const oe=t.map(zw);T(oe),r(oe)}},e[15]=z,e[16]=r,e[17]=t,e[18]=w.length,e[19]=J):J=e[19];const U=J;let X;e[20]!==v?(X=v?{}:{variant:"outline"},e[20]=v,e[21]=X):X=e[21];let te;e[22]!==d?(te=Z("border-input data-[placeholder]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/20 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full max-w-xs items-center justify-between gap-2 rounded-xl border bg-transparent px-3 py-2 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[2px] disabled:cursor-not-allowed disabled:opacity-50 h-10 min-h-10",d),e[22]=d,e[23]=te):te=e[23];let ne;e[24]!==b||e[25]!==k||e[26]!==t||e[27]!==x||e[28]!==w||e[29]!==y?(ne=w.length>0?p.jsxs("div",{className:"flex items-center justify-between w-full min-w-0",children:[p.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[w.slice(0,k).map(oe=>{const be=t.find(Si=>Si.value===oe),At=be?.icon;return p.jsxs(rs,{variant:y==="default"?"default":"secondary",className:"max-w-24",style:{animationDuration:`${b}s`},children:[At&&p.jsx(At,{className:"h-3 w-3 shrink-0"}),p.jsx("span",{className:"truncate",children:be?.label})]},oe)}),w.length>k&&p.jsxs(rs,{variant:y==="default"?"default":"secondary",className:"flex-shrink-0",style:{animationDuration:`${b}s`},children:["+",w.length-k]})]}),p.jsx("div",{className:"flex items-center shrink-0 ml-2",children:p.jsx(Ln,{size:20,className:"shrink-0 opacity-50"})})]}):p.jsxs("div",{className:"flex items-center justify-between w-full",children:[p.jsx("span",{className:"text-sm text-muted-foreground",children:x}),p.jsx(Ln,{size:20,className:"shrink-0 opacity-50"})]}),e[24]=b,e[25]=k,e[26]=t,e[27]=x,e[28]=w,e[29]=y,e[30]=ne):ne=e[30];let re;e[31]!==C||e[32]!==X||e[33]!==te||e[34]!==ne?(re=p.jsx(mu,{asChild:!0,children:p.jsx(mt,{ref:null,...X,onClick:q,className:te,disabled:C,children:ne})}),e[31]=C,e[32]=X,e[33]=te,e[34]=ne,e[35]=re):re=e[35];let le;e[36]===Symbol.for("react.memo_cache_sentinel")?(le=()=>M(!1),e[36]=le):le=e[36];const ye=!h;let V;e[37]!==R||e[38]!==h?(V=p.jsx(jp,{placeholder:"Search...",onKeyDown:R,onValueChange:h,className:"rounded-t-xl"}),e[37]=R,e[38]=h,e[39]=V):V=e[39];let se;e[40]===Symbol.for("react.memo_cache_sentinel")?(se=p.jsx(Ip,{children:"No results found."}),e[40]=se):se=e[40];let ae;e[41]!==U?(ae=()=>{U()},e[41]=U,e[42]=ae):ae=e[42];let de;e[43]!==U?(de=oe=>{oe.stopPropagation(),U()},e[43]=U,e[44]=de):de=e[44];const Ie=w.length===t.length&&t.length>0;let Fe;e[45]!==Ie||e[46]!==U?(Fe=p.jsx(aa,{checked:Ie,onCheckedChange:U,className:"mr-2 [&_svg]:!text-primary-foreground",onClick:$w}),e[45]=Ie,e[46]=U,e[47]=Fe):Fe=e[47];let Ee;e[48]===Symbol.for("react.memo_cache_sentinel")?(Ee=p.jsx("span",{children:"(Select All)"}),e[48]=Ee):Ee=e[48];let Se;e[49]!==de||e[50]!==Fe?(Se=p.jsxs("div",{className:"flex items-center w-full",onClick:de,children:[Fe,Ee]}),e[49]=de,e[50]=Fe,e[51]=Se):Se=e[51];let ve;e[52]!==ae||e[53]!==Se?(ve=p.jsx(ca,{onSelect:ae,className:"cursor-pointer",children:Se},"all"),e[52]=ae,e[53]=Se,e[54]=ve):ve=e[54];let Le;if(e[55]!==t||e[56]!==w||e[57]!==_){let oe;e[59]!==w||e[60]!==_?(oe=be=>{const At=w.includes(be.value);return p.jsx(ca,{onSelect:()=>{_(be)},className:"cursor-pointer",children:p.jsxs("div",{className:"flex items-center w-full",onClick:Si=>{Si.stopPropagation(),_(be)},children:[p.jsx(aa,{checked:At,onCheckedChange:()=>{_(be)},className:"mr-2 [&_svg]:!text-primary-foreground",onClick:_w}),be.icon&&p.jsx(be.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),p.jsx("span",{children:be.label})]})},be.value)},e[59]=w,e[60]=_,e[61]=oe):oe=e[61],Le=t.map(oe),e[55]=t,e[56]=w,e[57]=_,e[58]=Le}else Le=e[58];let K;e[62]!==ve||e[63]!==Le?(K=p.jsxs(Op,{className:"rounded-b-xl",children:[se,p.jsxs(Rp,{children:[ve,Le]})]}),e[62]=ve,e[63]=Le,e[64]=K):K=e[64];let ie;e[65]!==ye||e[66]!==V||e[67]!==K?(ie=p.jsx(gu,{className:"w-auto p-0 max-w-xs rounded-xl",align:"start",onEscapeKeyDown:le,children:p.jsxs(Dp,{shouldFilter:ye,className:"rounded-xl",children:[V,K]})}),e[65]=ye,e[66]=V,e[67]=K,e[68]=ie):ie=e[68];let ce;return e[69]!==N||e[70]!==S||e[71]!==re||e[72]!==ie?(ce=p.jsxs(xu,{open:N,onOpenChange:M,modal:S,children:[re,ie]}),e[69]=N,e[70]=S,e[71]=re,e[72]=ie,e[73]=ce):ce=e[73],ce}function _w(n){return n.stopPropagation()}function $w(n){return n.stopPropagation()}function zw(n){return n.value}function Bw(n){return!n}const ep=[{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"}],Fw=40;function OT(n){const t=(n.endDate.getTime()-n.startDate.getTime())/Fw;return ep.find(s=>s.ms>=t)?.label??"1d"}function ta(n){const e=ep.find(i=>i.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 Vw(n,e){const t=new Date(n);return ta(e)>=864e5?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zc(n,e){const t=ta(e);return new Date(Math.floor(n.getTime()/t)*t)}function Hw(n){return n>=1e4?`${(n/1e3).toFixed(1)}s`:`${Math.round(n)}ms`}function na(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 ra(n){return Number.isFinite(n)?`$${n.toFixed(n<1?4:2)}`:"$0.00"}function RT(n,e,t){const r=ta(t),s=Zc(e.startDate,t).getTime(),i=e.endDate.getTime(),o=new Map(n.map(a=>[Zc(new Date(a.timestamp),t).getTime(),a])),l=[];for(let a=s;a<=i;a+=r){const c=o.get(a),u=new Date(a).toISOString();l.push({t:u,ts:a,label:Vw(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 DT(n,e){return e==="requests"?n.calls:e==="errors"?n.errorRate:n.avgDurationMs}function PT(n,e){return e==="requests"?n.calls.toLocaleString():e==="errors"?`${n.errorRate.toFixed(1)}%`:Hw(n.avgDurationMs)}function sa(n){return(n.run_config??{}).agent?.id??(n.virtual_mcp_id||null)}function ia(n,e,t,r){if(!n)return r;const s=e.find(o=>o.id===n)??t?.find(o=>o.id===n);if(s?.title)return s.title;const i=wp(n);return i?Cp(i).title??r:n}function oa(n,e,t){return n?(e.find(s=>s.id===n)??t?.find(s=>s.id===n))?.icon??null:null}function tp(n){return n?.data?.members??[]}function Fo(n){const e=L.c(33),{thread:t,connections:r,virtualMcps:s,selectedIndex:i,total:o,onPrev:l,onNext:a}=n;let c,u;if(e[0]!==r||e[1]!==t||e[2]!==s){const j=sa(t);c=ia(j,s,r,""),u=oa(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(Xo,{}),e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==f?(m=p.jsx(Gt,{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(cu,{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=i===0;let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(no,{size:14}),e[19]=S):S=e[19];let v;e[20]!==l||e[21]!==k?(v=p.jsx(mt,{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 C=i===o-1;let w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Ln,{size:14}),e[23]=w):w=e[23];let T;e[24]!==a||e[25]!==C?(T=p.jsx(mt,{size:"icon",variant:"ghost",onClick:a,disabled:C,className:"h-7 w-7 text-muted-foreground","aria-label":"Next chat",children:w}),e[24]=a,e[25]=C,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(au,{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 Ww(n){const e=L.c(48),{thread:t,connections:r,virtualMcps:s,members:i}=n;let o,l;if(e[0]!==r||e[1]!==t||e[2]!==s){const I=sa(t);o=ia(I,s,r,""),l=oa(I,s,r),e[0]=r,e[1]=t,e[2]=s,e[3]=o,e[4]=l}else o=e[3],l=e[4];const a=l;let c;if(e[5]!==i||e[6]!==t.created_by){const I=tp(i);let _;e[8]!==t.created_by?(_=$=>$.userId===t.created_by,e[8]=t.created_by,e[9]=_):_=e[9],c=I.find(_),e[5]=i,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=Pn[t.status]??Pn.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=Z("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 C;e[25]!==k||e[26]!==v?(C=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]=C):C=e[27];let w;e[28]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Date"}),e[28]=w):w=e[28];let T;e[29]!==g?(T=p.jsxs("div",{children:[w,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(yu,{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 O;e[37]!==M||e[38]!==j?(O=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]=O):O=e[39];let A;e[40]!==a||e[41]!==o?(A=o&&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(Gt,{icon:a,name:o,size:"xs",fallbackIcon:p.jsx(Xo,{}),className:"shrink-0 size-5! min-w-5! rounded-md"}),p.jsx("span",{className:"text-sm text-foreground",children:o})]})]}),e[40]=a,e[41]=o,e[42]=A):A=e[42];let R;return e[43]!==T||e[44]!==O||e[45]!==A||e[46]!==C?(R=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:[C,T,O,A]}),e[43]=T,e[44]=O,e[45]=A,e[46]=C,e[47]=R):R=e[47],R}function Uw(n){const e=L.c(72),{thread:t,usage:r,members:s,connections:i,virtualMcps:o,onClick:l,lastRowRef:a}=n;let c,u;if(e[0]!==i||e[1]!==t||e[2]!==o){const re=sa(t);c=ia(re,o,i,"—"),u=oa(re,o,i),e[0]=i,e[1]=t,e[2]=o,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 re=tp(s);let le;e[8]!==t.created_by?(le=ye=>ye.userId===t.created_by,e[8]=t.created_by,e[9]=le):le=e[9],f=re.find(le),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 re=new Date(t.created_at);y=re.toLocaleDateString("en-US",{month:"short",day:"numeric"}),b=re.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=Pn[t.status]??Pn.completed,v=S.icon;let C;e[17]!==t.title?(C=p.jsx(Ze,{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]=C):C=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Xo,{}),e[19]=w):w=e[19];let T;e[20]!==d||e[21]!==c?(T=p.jsx(Gt,{icon:d,name:c,size:"xs",fallbackIcon:w,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(Ze,{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(yu,{url:x,fallback:g,shape:"circle",size:"2xs",className:"shrink-0"}),e[28]=x,e[29]=g,e[30]=j):j=e[30];let O;e[31]!==g?(O=p.jsx("span",{className:"truncate",children:g}),e[31]=g,e[32]=O):O=e[32];let A;e[33]!==j||e[34]!==O?(A=p.jsx(Ze,{className:"w-28 px-3 text-muted-foreground",children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[j,O]})}),e[33]=j,e[34]=O,e[35]=A):A=e[35];let R;e[36]!==v||e[37]!==S.iconClassName?(R=p.jsx(v,{size:14,className:S.iconClassName}),e[36]=v,e[37]=S.iconClassName,e[38]=R):R=e[38];let I;e[39]!==S.labelColor?(I=Z("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 $;e[44]!==R||e[45]!==_?($=p.jsx(Ze,{className:"w-24 px-3",children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[R,_]})}),e[44]=R,e[45]=_,e[46]=$):$=e[46];let z;e[47]!==r?(z=r?na(r.totalTokens):"—",e[47]=r,e[48]=z):z=e[48];let B;e[49]!==z?(B=p.jsx(Ze,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:z}),e[49]=z,e[50]=B):B=e[50];let q;e[51]!==r?(q=r&&r.costUsd>0?ra(r.costUsd):"—",e[51]=r,e[52]=q):q=e[52];let J;e[53]!==q?(J=p.jsx(Ze,{className:"w-24 px-3 text-right tabular-nums text-muted-foreground",children:q}),e[53]=q,e[54]=J):J=e[54];let U;e[55]!==y?(U=p.jsx("div",{children:y}),e[55]=y,e[56]=U):U=e[56];let X;e[57]!==k?(X=p.jsx("div",{className:"text-xs text-muted-foreground/60",children:k}),e[57]=k,e[58]=X):X=e[58];let te;e[59]!==U||e[60]!==X?(te=p.jsxs(Ze,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[U,X]}),e[59]=U,e[60]=X,e[61]=te):te=e[61];let ne;return e[62]!==a||e[63]!==l||e[64]!==A||e[65]!==$||e[66]!==B||e[67]!==J||e[68]!==te||e[69]!==C||e[70]!==M?(ne=p.jsxs(Ys,{ref:a,className:"h-14 md:h-16 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:l,children:[C,M,A,$,B,J,te]}),e[62]=a,e[63]=l,e[64]=A,e[65]=$,e[66]=B,e[67]=J,e[68]=te,e[69]=C,e[70]=M,e[71]=ne):ne=e[71],ne}const Vo=100;function qw(n){const e=L.c(37),{client:t,locator:r,thread:s,connections:i,virtualMcps:o,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==r||e[1]!==s.id?(f=nt.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 O=>{const{pageParam:A}=O,R=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:Vo,offset:R}});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:Gw,staleTime:6e4},e[6]=f,e[7]=h,e[8]=m):m=e[8];const{data:g,fetchNextPage:x,hasNextPage:y,isFetchingNextPage:b}=Ap(m);let k;e[9]!==g.pages?(k=g.pages.flatMap(Jw).filter(Kw),e[9]=g.pages,e[10]=k):k=e[10];const S=k,v=kw(S);let C;e[11]!==x||e[12]!==y||e[13]!==b?(C=()=>{y&&!b&&x()},e[11]=x,e[12]=y,e[13]=b,e[14]=C):C=e[14];const w=Go(C,y??!1,b);let T;e[15]!==i||e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==s||e[20]!==c||e[21]!==o?(T=p.jsx(Fo,{thread:s,connections:i,virtualMcps:o,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[15]=i,e[16]=d,e[17]=u,e[18]=a,e[19]=s,e[20]=c,e[21]=o,e[22]=T):T=e[22];let N;e[23]!==i||e[24]!==l||e[25]!==s||e[26]!==o?(N=p.jsx(Ww,{thread:s,connections:i,virtualMcps:o,members:l}),e[23]=i,e[24]=l,e[25]=s,e[26]=o,e[27]=N):N=e[27];let M;e[28]!==b||e[29]!==w||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((O,A)=>p.jsx("div",{ref:A===v.length-1?w:void 0,children:p.jsx(Sw,{pair:O,isLastPair:A===v.length-1,status:"ready"})},`pair-${O.user?.id??O.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]=w,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 Kw(n){return n.role==="user"||n.role==="assistant"}function Jw(n){return n.items??[]}function Gw(n,e){const t=n,r=e;if(!((t?.items?.length??0)<Vo))return r.length*Vo}function np(n){const e=L.c(39),{thread:t,client:r,locator:s,connections:i,virtualMcps:o,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}=n;let f;e[0]!==i||e[1]!==d||e[2]!==u||e[3]!==a||e[4]!==t||e[5]!==c||e[6]!==o?(f=p.jsx(Fo,{thread:t,connections:i,virtualMcps:o,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[0]=i,e[1]=d,e[2]=u,e[3]=a,e[4]=t,e[5]=c,e[6]=o,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]!==i||e[12]!==d||e[13]!==u||e[14]!==a||e[15]!==t||e[16]!==c||e[17]!==o?(g=p.jsx(Fo,{thread:t,connections:i,virtualMcps:o,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[11]=i,e[12]=d,e[13]=u,e[14]=a,e[15]=t,e[16]=c,e[17]=o,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]!==i||e[24]!==s||e[25]!==l||e[26]!==d||e[27]!==u||e[28]!==a||e[29]!==t||e[30]!==c||e[31]!==o?(b=p.jsx(qw,{client:r,locator:s,thread:t,connections:i,virtualMcps:o,members:l,selectedIndex:a,total:c,onPrev:u,onNext:d}),e[22]=r,e[23]=i,e[24]=s,e[25]=l,e[26]=d,e[27]=u,e[28]=a,e[29]=t,e[30]=c,e[31]=o,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(su,{fallback:m,children:k}),e[36]=m,e[37]=k,e[38]=S):S=e[38],S}function LT(n){const e=L.c(43),{filterAgentIds:t,filterUserIds:r,filterStatus:s,virtualMcpOptions:i,memberOptions:o,activeFiltersCount:l,onUpdateFilters:a}=n,[c,u]=E.useState(!1);let d,f;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx(Lp,{size:16}),f=p.jsx("span",{className:"hidden sm:inline",children:"Filters"}),e[0]=d,e[1]=f):(d=e[0],f=e[1]);let h;e[2]!==l?(h=l>0&&p.jsxs(p.Fragment,{children:[p.jsx(rs,{variant:"default",className:"sm:hidden absolute -top-1.5 -right-1.5 h-4 min-w-4 px-1 text-[10px] leading-none",children:l}),p.jsx(rs,{variant:"default",className:"hidden sm:flex ml-1 h-5 w-5 rounded-full p-0 items-center justify-center text-xs",children:l})]}),e[2]=l,e[3]=h):h=e[3];let m;e[4]!==h?(m=p.jsx(mu,{asChild:!0,children:p.jsxs(mt,{variant:"outline",className:"relative",children:[d,f,h]})}),e[4]=h,e[5]=m):m=e[5];let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=p.jsx("h4",{className:"font-medium text-sm",children:"Filter Chats"}),e[6]=g):g=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Agent"}),e[7]=x):x=e[7];let y;e[8]!==a?(y=I=>a({filterAgentIds:I.slice(0,1)}),e[8]=a,e[9]=y):y=e[9];let b;e[10]!==t||e[11]!==y||e[12]!==i?(b=p.jsxs("div",{children:[x,p.jsx(Qc,{options:i,defaultValue:t,onValueChange:y,placeholder:"All agents",variant:"secondary",className:"w-full",maxCount:1})]}),e[10]=t,e[11]=y,e[12]=i,e[13]=b):b=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=p.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"User"}),e[14]=k):k=e[14];let S;e[15]!==a?(S=I=>a({filterUserIds:I.slice(0,1)}),e[15]=a,e[16]=S):S=e[16];let v;e[17]!==r||e[18]!==o||e[19]!==S?(v=p.jsxs("div",{children:[k,p.jsx(Qc,{options:o,defaultValue:r,onValueChange:S,placeholder:"All users",variant:"secondary",className:"w-full",maxCount:1})]}),e[17]=r,e[18]=o,e[19]=S,e[20]=v):v=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Status"}),e[21]=C):C=e[21];let w;e[22]!==a?(w=I=>a({filterStatus:I}),e[22]=a,e[23]=w):w=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=p.jsx(mp,{className:"w-full",children:p.jsx(gp,{})}),e[24]=T):T=e[24];let N;e[25]===Symbol.for("react.memo_cache_sentinel")?(N=p.jsxs(xp,{children:[p.jsx(Pr,{value:"all",children:"All statuses"}),p.jsx(Pr,{value:"completed",children:"Completed"}),p.jsx(Pr,{value:"active",children:"Active"}),p.jsx(Pr,{value:"failed",children:"Failed"})]}),e[25]=N):N=e[25];let M;e[26]!==s||e[27]!==w?(M=p.jsxs("div",{children:[C,p.jsxs(yp,{value:s,onValueChange:w,children:[T,N]})]}),e[26]=s,e[27]=w,e[28]=M):M=e[28];let j;e[29]!==v||e[30]!==M||e[31]!==b?(j=p.jsxs("div",{className:"space-y-3",children:[b,v,M]}),e[29]=v,e[30]=M,e[31]=b,e[32]=j):j=e[32];let O;e[33]!==l||e[34]!==a?(O=l>0&&p.jsx(mt,{variant:"ghost",size:"sm",className:"w-full",onClick:()=>{a({filterAgentIds:[],filterUserIds:[],filterStatus:"all"}),u(!1)},children:"Clear all filters"}),e[33]=l,e[34]=a,e[35]=O):O=e[35];let A;e[36]!==j||e[37]!==O?(A=p.jsx(gu,{align:"end",className:"w-[280px]",children:p.jsxs("div",{className:"space-y-4",children:[g,j,O]})}),e[36]=j,e[37]=O,e[38]=A):A=e[38];let R;return e[39]!==c||e[40]!==A||e[41]!==m?(R=p.jsxs(xu,{open:c,onOpenChange:u,children:[m,A]}),e[39]=c,e[40]=A,e[41]=m,e[42]=R):R=e[42],R}const Ho=50;function _T(n){const e=L.c(29),{client:t,locator:r,membersData:s,allConnections:i,allVirtualMcps:o,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}=ou({queryKey:nt.threadsInfinite(r,x),queryFn:async K=>{const{pageParam:ie}=K,ce=ie===void 0?0:ie;if(!t)throw new Error("MCP client is not available");const oe=await t.callTool({name:"COLLECTION_THREADS_LIST",arguments:{limit:Ho,offset:ce,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 oe.structuredContent??oe},initialPageParam:0,getNextPageParam:tC,staleTime:3e4}),C=(y?.pages??[]).flatMap(eC),w=C.map(Zw),{data:T}=jr({queryKey:nt.monitoringThreadUsage(r,JSON.stringify({ids:w,startDate:m,endDate:g})),queryFn:async()=>{if(!t)throw new Error("MCP client is not available");const K=await t.callTool({name:"MONITORING_THREAD_USAGE",arguments:{threadIds:w,startDate:m,endDate:g}});return K.structuredContent??K},enabled:!!t&&w.length>0,staleTime:3e4}),N=new Map((T?.items??[]).map(Qw)),[M,j]=E.useState(null),[O,A]=E.useState("desc");let R;e[0]!==M?(R=K=>{M===K?A(Yw):(j(K),A("desc"))},e[0]=M,e[1]=R):R=e[1];const I=R,_=K=>{const ie=N.get(K);return ie?M==="cost"?ie.costUsd:ie.totalTokens:0},$=M?[...C].sort((K,ie)=>{const ce=_(K.id),oe=_(ie.id);return O==="desc"?oe-ce:ce-oe}):C,z=f!==null?$[f]??null:null;let B;e[2]!==b||e[3]!==k||e[4]!==S?(B=()=>{k&&!S&&b()},e[2]=b,e[3]=k,e[4]=S,e[5]=B):B=e[5];const J=Go(B,k??!1,S),U=!!a||(c?.length??0)>0||(u?.length??0)>0||d&&d!=="all";let X;e[6]===Symbol.for("react.memo_cache_sentinel")?(X=()=>h(Xw),e[6]=X):X=e[6];const te=X,ne=()=>h(K=>K!==null&&K<$.length-1?K+1:K),re="flex-1 flex flex-col overflow-auto min-w-0",le="mx-auto w-full max-w-[1200px] px-4 md:px-10 flex flex-col flex-1 min-h-0",ye="flex-1 flex flex-col min-w-0",V="flex-1 min-w-0 pt-1",se="min-w-0",ae=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"})}):C.length===0?p.jsx("div",{className:"flex flex-1 items-center justify-center py-20",children:p.jsx(to,{title:U?"No matching chats":"No chats in this time range",description:U?"Try adjusting your filters or search query.":"Try expanding the time range to see older chats."})}):p.jsxs(p.Fragment,{children:[p.jsxs(uu,{className:"w-full border-collapse",children:[p.jsx(du,{className:"border-b-0 z-20",children:p.jsxs(Ys,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Qe,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Title"}),p.jsx(Qe,{className:"w-36 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Agent"}),p.jsx(Qe,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"User"}),p.jsx(Qe,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Qe,{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"&&(O==="desc"?p.jsx(Ln,{size:12}):p.jsx(no,{size:12}))]})}),p.jsx(Qe,{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"&&(O==="desc"?p.jsx(Ln,{size:12}):p.jsx(no,{size:12}))]})}),p.jsx(Qe,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Date"})]})}),p.jsx(fu,{children:$.map((K,ie)=>p.jsx(Uw,{thread:K,usage:N.get(K.id),members:s,connections:i,virtualMcps:o,onClick:()=>h(ie),lastRowRef:ie===$.length-1?J:void 0},K.id))})]}),S&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more..."})]});let de;e[7]!==ae?(de=p.jsx("div",{className:le,children:p.jsx("div",{className:ye,children:p.jsx("div",{className:V,children:p.jsx("div",{className:se,children:ae})})})}),e[7]=ae,e[8]=de):de=e[8];const Ie=f!==null;let Fe;e[9]===Symbol.for("react.memo_cache_sentinel")?(Fe=K=>{K||h(null)},e[9]=Fe):Fe=e[9];let Ee;e[10]!==i||e[11]!==o||e[12]!==t||e[13]!==$||e[14]!==ne||e[15]!==te||e[16]!==r||e[17]!==s||e[18]!==z||e[19]!==f?(Ee=z&&f!==null&&p.jsx(np,{thread:z,client:t,locator:r,connections:i,virtualMcps:o,members:s,selectedIndex:f,total:$.length,onPrev:te,onNext:ne}),e[10]=i,e[11]=o,e[12]=t,e[13]=$,e[14]=ne,e[15]=te,e[16]=r,e[17]=s,e[18]=z,e[19]=f,e[20]=Ee):Ee=e[20];let Se;e[21]!==Ee?(Se=p.jsx(Ko,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:Ee}),e[21]=Ee,e[22]=Se):Se=e[22];let ve;e[23]!==Ie||e[24]!==Se?(ve=p.jsx(Jo,{open:Ie,onOpenChange:Fe,children:Se}),e[23]=Ie,e[24]=Se,e[25]=ve):ve=e[25];let Le;return e[26]!==de||e[27]!==ve?(Le=p.jsxs("div",{className:re,children:[de,ve]}),e[26]=de,e[27]=ve,e[28]=Le):Le=e[28],Le}function Xw(n){return n!==null&&n>0?n-1:n}function Yw(n){return n==="desc"?"asc":"desc"}function Qw(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function Zw(n){return n.id}function eC(n){return n.items??[]}function tC(n,e){const t=n,r=e;if(!((t?.items?.length??0)<Ho))return r.length*Ho}const Wo=50;function Yr(n){const e=L.c(10),{title:t,value:r,subtitle:s}=n;let i;e[0]!==t?(i=p.jsx("span",{className:"text-sm text-foreground/70",children:t}),e[0]=t,e[1]=i):i=e[1];let o;e[2]!==r?(o=p.jsx("span",{className:"text-3xl font-normal tabular-nums",children:r}),e[2]=r,e[3]=o):o=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]!==i||e[7]!==o||e[8]!==l?(a=p.jsxs(Np,{className:"pt-4 px-4 pb-5 gap-1",children:[i,o,l]}),e[6]=i,e[7]=o,e[8]=l,e[9]=a):a=e[9],a}function nC(n){const e=L.c(27),{automationId:t,range:r}=n,{data:s,isLoading:i}=Ep(t,r),o=s?.runs,l=s?.usage;let a;e[0]!==o?(a=o&&o.total>0?`${Math.round(o.completed/o.total*100)}%`:"—",e[0]=o,e[1]=a):a=e[1];const c=a,u=l&&l.truncated?`last ${l.sampledRuns} runs`:void 0;let d;e[2]!==i||e[3]!==o?.total?(d=i?"…":o?.total.toLocaleString()??"0",e[2]=i,e[3]=o?.total,e[4]=d):d=e[4];const f=o?`${o.completed} ok · ${o.failed} failed${o.inProgress>0?` · ${o.inProgress} running`:""}`:void 0;let h;e[5]!==d||e[6]!==f?(h=p.jsx(Yr,{title:"Runs",value:d,subtitle:f}),e[5]=d,e[6]=f,e[7]=h):h=e[7];const m=i?"…":c;let g;e[8]!==m?(g=p.jsx(Yr,{title:"Success rate",value:m}),e[8]=m,e[9]=g):g=e[9];let x;e[10]!==i||e[11]!==l?.totalTokens?(x=i?"…":na(l?.totalTokens??0),e[10]=i,e[11]=l?.totalTokens,e[12]=x):x=e[12];let y;e[13]!==x||e[14]!==u?(y=p.jsx(Yr,{title:"Tokens",value:x,subtitle:u}),e[13]=x,e[14]=u,e[15]=y):y=e[15];let b;e[16]!==i||e[17]!==l?(b=i?"…":l&&l.costUsd>0?ra(l.costUsd):"—",e[16]=i,e[17]=l,e[18]=b):b=e[18];let k;e[19]!==b||e[20]!==u?(k=p.jsx(Yr,{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 rC(n){const e=L.c(39),{run:t,usage:r,onClick:s,lastRowRef:i}=n;let o,l;if(e[0]!==t.created_at){const T=new Date(t.created_at);o=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]=o,e[2]=l}else o=e[1],l=e[2];const a=l,c=Pn[t.status]??Pn.completed,u=c.icon;let d;e[3]!==t.title?(d=p.jsx(Ze,{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=Z("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(Ze,{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?na(r.totalTokens):"—",e[16]=r,e[17]=x):x=e[17];let y;e[18]!==x?(y=p.jsx(Ze,{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?ra(r.costUsd):"—",e[20]=r,e[21]=b):b=e[21];let k;e[22]!==b?(k=p.jsx(Ze,{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]!==o?(S=p.jsx("div",{children:o}),e[24]=o,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 C;e[28]!==S||e[29]!==v?(C=p.jsxs(Ze,{className:"w-32 px-3 pr-5 text-muted-foreground",children:[S,v]}),e[28]=S,e[29]=v,e[30]=C):C=e[30];let w;return e[31]!==i||e[32]!==s||e[33]!==k||e[34]!==C||e[35]!==d||e[36]!==g||e[37]!==y?(w=p.jsxs(Ys,{ref:i,className:"h-14 cursor-pointer hover:bg-muted/40 transition-colors border-b-0",onClick:s,children:[d,g,y,k,C]}),e[31]=i,e[32]=s,e[33]=k,e[34]=C,e[35]=d,e[36]=g,e[37]=y,e[38]=w):w=e[38],w}function $T(n){const e=L.c(48),{automationId:t,triggerIds:r,range:s}=n,{org:i,locator:o}=Mt();let l;e[0]!==i.id||e[1]!==i.slug?(l={connectionId:Tp,orgId:i.id,orgSlug:i.slug},e[0]=i.id,e[1]=i.slug,e[2]=l):l=e[2];const a=qo(l),c=pu(),u=bp(),d=Sp(),{data:f}=Mp(),[h,m]=E.useState(null),g=r.length>0;let x;e[3]!==t||e[4]!==i.id||e[5]!==r?(x=nt.automationRuns(i.id,t,r),e[3]=t,e[4]=i.id,e[5]=r,e[6]=x):x=e[6];let y;e[7]!==c||e[8]!==r?(y=async V=>{const{pageParam:se}=V,ae=se===void 0?0:se;return await c.call("COLLECTION_THREADS_LIST",{limit:Wo,offset:ae,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:aC,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:C,isLoading:w}=ou(b),T=(k?.pages??[]).flatMap(lC),N=T.map(oC),{data:M}=jr({queryKey:nt.monitoringThreadUsage(o,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(iC)),e[14]=M?.items,e[15]=j):j=e[15];const O=j;let A;e[16]!==S||e[17]!==v||e[18]!==C?(A=()=>{v&&!C&&S()},e[16]=S,e[17]=v,e[18]=C,e[19]=A):A=e[19];const R=Go(A,v??!1,C),I=h!==null?T[h]??null:null;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=()=>m(sC),e[20]=_):_=e[20];const $=_,z=()=>m(V=>V!==null&&V<T.length-1?V+1:V),B="flex flex-col gap-5";let q;e[21]!==t||e[22]!==s?(q=p.jsx(nC,{automationId:t,range:s}),e[21]=t,e[22]=s,e[23]=q):q=e[23];const J=g?w?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(to,{title:"No runs yet",description:"This automation hasn't run yet. Trigger it or wait for a starter to fire."})}):p.jsxs(uu,{className:"w-full border-collapse",children:[p.jsx(du,{className:"border-b-0",children:p.jsxs(Ys,{className:"h-9 hover:bg-transparent border-b border-border",children:[p.jsx(Qe,{className:"pl-4 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Run"}),p.jsx(Qe,{className:"w-28 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Status"}),p.jsx(Qe,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Tokens"}),p.jsx(Qe,{className:"w-24 px-3 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide text-right",children:"Cost"}),p.jsx(Qe,{className:"w-32 px-3 pr-5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Started"})]})}),p.jsx(fu,{children:T.map((V,se)=>p.jsx(rC,{run:V,usage:O.get(V.id),onClick:()=>m(se),lastRowRef:se===T.length-1?R:void 0},V.id))})]}):p.jsx("div",{className:"py-16",children:p.jsx(to,{title:"No starters yet",description:"Add a starter (cron, event, or webhook) to start collecting runs."})});let U;e[24]!==C?(U=C&&p.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"Loading more…"}),e[24]=C,e[25]=U):U=e[25];const X=h!==null;let te;e[26]===Symbol.for("react.memo_cache_sentinel")?(te=V=>{V||m(null)},e[26]=te):te=e[26];let ne;e[27]!==u||e[28]!==d||e[29]!==a||e[30]!==z||e[31]!==$||e[32]!==o||e[33]!==f||e[34]!==T||e[35]!==I||e[36]!==h?(ne=I&&h!==null&&p.jsx(np,{thread:I,client:a,locator:o,connections:u,virtualMcps:d,members:f,selectedIndex:h,total:T.length,onPrev:$,onNext:z}),e[27]=u,e[28]=d,e[29]=a,e[30]=z,e[31]=$,e[32]=o,e[33]=f,e[34]=T,e[35]=I,e[36]=h,e[37]=ne):ne=e[37];let re;e[38]!==ne?(re=p.jsx(Ko,{className:"sm:max-w-2xl flex flex-col p-0 gap-0",children:ne}),e[38]=ne,e[39]=re):re=e[39];let le;e[40]!==X||e[41]!==re?(le=p.jsx(Jo,{open:X,onOpenChange:te,children:re}),e[40]=X,e[41]=re,e[42]=le):le=e[42];let ye;return e[43]!==J||e[44]!==U||e[45]!==le||e[46]!==q?(ye=p.jsxs("div",{className:B,children:[q,J,U,le]}),e[43]=J,e[44]=U,e[45]=le,e[46]=q,e[47]=ye):ye=e[47],ye}function sC(n){return n!==null&&n>0?n-1:n}function iC(n){return[n.threadId,{calls:n.calls,inputTokens:n.inputTokens,outputTokens:n.outputTokens,totalTokens:n.totalTokens,costUsd:n.costUsd}]}function oC(n){return n.id}function lC(n){return n.items??[]}function aC(n,e){const t=n,r=e;if(!((t?.items?.length??0)<Wo))return r.length*Wo}export{LT as $,IT as A,NT as B,ET as C,pe as D,Ol as E,ck as F,qv as G,ke as H,Q2 as I,Z2 as J,eS as K,$T as L,pi as M,nS as N,zv as O,Um as P,OT as Q,Y2 as R,TT as S,MT as T,RT as U,na as V,ra as W,Hw as X,PT as Y,DT as Z,tp as _,Zf as a,_T as a0,Qc as a1,Me as b,Qf as c,Vm as d,me as e,CT as f,nl as g,Ve as h,wT as i,kT as j,vT as k,rk as l,ST as m,ik as n,q2 as o,Uf as p,bT as q,kw as r,rl as s,Pu as t,Gb as u,Bm as v,AT as w,Sw as x,jT as y,$v as z};