dorkos 0.118.0 → 0.120.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 (273) hide show
  1. package/dist/bin/cli.js +3588 -3000
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-BOS59p1y.js → AboutPage-Y8O56Cz5.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-DOmV85tr.js → ActivityErrorState-DlROxqde.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-DbsBpb6N.js → ActivityPage-BdV90CV2.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-B1ZeL7Jb.js → ActivityRow-B5yiD_uD.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-XPLZ-NAi.js → AdapterIcon-Dyq92Eup.js} +1 -1
  9. package/dist/client/assets/AdapterSetupWizard-D9tqz7Hl.js +2 -0
  10. package/dist/client/assets/{AgentOptionRow-C15RQsub.js → AgentOptionRow-BeRqDo7c.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-CydNJYi_.js → AgentPicker-BRyYVJZu.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-BBSbluBs.js → AgentRequestCard-xX6fAKgO.js} +4 -4
  13. package/dist/client/assets/AppearancePage-DKF9BqRt.js +1 -0
  14. package/dist/client/assets/{ApplyToOverridesDialog-Cv3KEf7T.js → ApplyToOverridesDialog-CPvtr_-f.js} +1 -1
  15. package/dist/client/assets/AttentionSignalRow-vBfioH1A.js +1 -0
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-Re2CfOlC.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-B50zNtwB.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-8xnsM47D.js → BindingDialog-CSNjws3F.js} +1 -1
  18. package/dist/client/assets/{BlintzCanvas-DUDSNxlM.js → BlintzCanvas-ClOKWzws.js} +80 -79
  19. package/dist/client/assets/{CanvasCsvContent-D697P3sa.js → CanvasCsvContent-0Mb7uOuA.js} +6 -6
  20. package/dist/client/assets/CanvasFileContent-B_8zsIas.js +2 -0
  21. package/dist/client/assets/CanvasModel3dContent-UokbHY9i.js +2 -0
  22. package/dist/client/assets/{ChatAppsOff-CFEmPGm1.js → ChatAppsOff-CLRB0YU5.js} +1 -1
  23. package/dist/client/assets/{CodeMirrorDiff-B7VUevZG.js → CodeMirrorDiff-B4uFJD6g.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorEditor-BX1bJlnT.js → CodeMirrorEditor-rYOrBAZc.js} +1 -1
  25. package/dist/client/assets/{CommitmentList-CDocwl5K.js → CommitmentList-i-IZ4gbr.js} +1 -1
  26. package/dist/client/assets/{CommitmentsPage-Cr_MvU96.js → CommitmentsPage-ChO1JkrE.js} +1 -1
  27. package/dist/client/assets/{ComputerResourceView-CJMUZPDy.js → ComputerResourceView-pLuD2ie6.js} +1 -1
  28. package/dist/client/assets/{ComputerViewer-BA-9lBBN.js → ComputerViewer-D7tPmpY5.js} +1 -1
  29. package/dist/client/assets/{ConnectionAccessLists-BLLpxhn3.js → ConnectionAccessLists-D6VH1vX3.js} +1 -1
  30. package/dist/client/assets/{ConnectionsPage-BWVfAPd1.js → ConnectionsPage-7x5olD9q.js} +2 -2
  31. package/dist/client/assets/{ConventionPage-EK3WUWVa.js → ConventionPage-BTYLWw6p.js} +1 -1
  32. package/dist/client/assets/{ExtensionPageRoute-C9hsJNX2.js → ExtensionPageRoute-A9AdBBbw.js} +2 -2
  33. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-BeyAgBfh.js → FloatingTanStackRouterDevtools-CqogiFob-ayv0yz1C.js} +1 -1
  34. package/dist/client/assets/HandlePage-BdRWgke2.js +1 -0
  35. package/dist/client/assets/{HeartbeatPage-DfbNenFv.js → HeartbeatPage-Dh6W9Qg5.js} +1 -1
  36. package/dist/client/assets/KeyEntry-owhPGtw3.js +1 -0
  37. package/dist/client/assets/{LexicalField-DC_6Z-Ye.js → LexicalField-B1NFMLD6.js} +2 -2
  38. package/dist/client/assets/{ManagesPage-CYnGvNM2.js → ManagesPage-BAnBmBdo.js} +1 -1
  39. package/dist/client/assets/{Marketplace-CWiiq8of.js → Marketplace-67maxdwz.js} +2 -2
  40. package/dist/client/assets/{MarketplaceSourcesView-DF3cHMR0.js → MarketplaceSourcesView-CzPBNJJj.js} +1 -1
  41. package/dist/client/assets/{McpAppFrame-D5Muf5Sf.js → McpAppFrame-CuObpQTg.js} +2 -2
  42. package/dist/client/assets/McpSigninBody-B-ayj6bQ.js +1 -0
  43. package/dist/client/assets/{Model3dViewer-C9ODHy5I.js → Model3dViewer-DRVqxazk.js} +1 -1
  44. package/dist/client/assets/NamePage-DyH8JAqT.js +1 -0
  45. package/dist/client/assets/NewDirectMessageMenu-B3DxayR2.js +1 -0
  46. package/dist/client/assets/{NotificationsPage-ldulSpVu.js → NotificationsPage-BavEo7VZ.js} +1 -1
  47. package/dist/client/assets/{OpenMeshSwitch-BfEvR7s7.js → OpenMeshSwitch-BwkX2Toa.js} +2 -2
  48. package/dist/client/assets/{OperatorIdentityForm-ZM_zDnjM.js → OperatorIdentityForm-CtWgz2yi.js} +1 -1
  49. package/dist/client/assets/{PermissionHistory-liL_pJDR.js → PermissionHistory-DvM0F2bS.js} +1 -1
  50. package/dist/client/assets/{PermissionsPage-DFMjDQby.js → PermissionsPage-D1DJHezV.js} +1 -1
  51. package/dist/client/assets/{PersonalityPopover-CITFG0_N.js → PersonalityPopover-BV-9wfIl.js} +1 -1
  52. package/dist/client/assets/PhotoPage-BHvRQnex.js +1 -0
  53. package/dist/client/assets/{PresetPicker-CpYu7nb6.js → PresetPicker-BOQKgYAK.js} +2 -2
  54. package/dist/client/assets/{PreviewRefusedNotice-CF3bzfSe.js → PreviewRefusedNotice-BdhUln2h.js} +1 -1
  55. package/dist/client/assets/{ProfileFields-D4p6bhIa.js → ProfileFields-DFRnRR38.js} +1 -1
  56. package/dist/client/assets/{ProfilePanelContainer-XCuCnd1t.js → ProfilePanelContainer-CkxX9Dps.js} +1 -1
  57. package/dist/client/assets/{ProfileRolePicker-qRf3DSdk.js → ProfileRolePicker-BSYi_luB.js} +1 -1
  58. package/dist/client/assets/PromptSuggestionChips-r08GqBH1.js +1 -0
  59. package/dist/client/assets/{ReportsToPopover-Cu-Cnzij.js → ReportsToPopover-BcsM5Eia.js} +1 -1
  60. package/dist/client/assets/{RoomSurface-CsAifwp2.js → RoomSurface-DaRCf4og.js} +7 -7
  61. package/dist/client/assets/{RoomsPage-DZYMR2in.js → RoomsPage-CQqsdVvB.js} +1 -1
  62. package/dist/client/assets/RunsOnPopover-DFb4xEhP.js +1 -0
  63. package/dist/client/assets/RuntimeConnectFlow-pKFJlNSJ.js +1 -0
  64. package/dist/client/assets/RuntimeSetupDialog-DvBJbrmj.js +1 -0
  65. package/dist/client/assets/{SessionsPage-thndqcpY.js → SessionsPage-CGgnEPh7.js} +1 -1
  66. package/dist/client/assets/SettingsDialog-D0cmzjrH.js +12 -0
  67. package/dist/client/assets/{SkillsPage-CmXyAw3J.js → SkillsPage-DDoPlsn2.js} +1 -1
  68. package/dist/client/assets/TaskDialogWrapper-DoIVzbKU.js +1 -0
  69. package/dist/client/assets/TasksEmptyState-B68O6dnT.js +3 -0
  70. package/dist/client/assets/{TasksPage-DGNXrDAk.js → TasksPage-BsBDphim.js} +1 -1
  71. package/dist/client/assets/{TeamComputerEntry-CIfFRo6-.js → TeamComputerEntry-CoQ4EsDm.js} +1 -1
  72. package/dist/client/assets/{ToolsPage-BKZkSarf.js → ToolsPage-Cl1aOpev.js} +2 -2
  73. package/dist/client/assets/{TopologyGraph-og2tlLj7.js → TopologyGraph-D3CxaLGX.js} +2 -2
  74. package/dist/client/assets/TourHost-4O6TJzc-.js +1 -0
  75. package/dist/client/assets/{UnlinkDialog-BTYC_Sit.js → UnlinkDialog-DIMY60Fi.js} +1 -1
  76. package/dist/client/assets/WidgetErrorCard-CzWw_SPD.js +108 -0
  77. package/dist/client/assets/_shell-BRH2Y-U-.js +80 -0
  78. package/dist/client/assets/{_shell._home-CP7HQ7Cs.js → _shell._home-DG3Vw7S5.js} +1 -1
  79. package/dist/client/assets/_shell._home.activity-COI96oAO.js +1 -0
  80. package/dist/client/assets/_shell._home.index-CTwsTjcQ.js +3 -0
  81. package/dist/client/assets/_shell._home.tasks-DOVoPYaf.js +1 -0
  82. package/dist/client/assets/{_shell._home.workspaces-Cdsw2-jI.js → _shell._home.workspaces-ApZhnjwy.js} +1 -1
  83. package/dist/client/assets/_shell.channels-CRkJHU5R.js +10 -0
  84. package/dist/client/assets/{_shell.connections-sF5vS-Lm.js → _shell.connections-bhAK3jnE.js} +1 -1
  85. package/dist/client/assets/{_shell.feedback-requests-hu21WXyA.js → _shell.feedback-requests-k43R8-rW.js} +2 -2
  86. package/dist/client/assets/_shell.marketplace-DGN_IdZY.js +1 -0
  87. package/dist/client/assets/_shell.marketplace_.sources-2YMpLInp.js +1 -0
  88. package/dist/client/assets/_shell.session-D871zZl3.js +61 -0
  89. package/dist/client/assets/{_shell.team-raG7wRwF.js → _shell.team-DHCM1QoO.js} +6 -6
  90. package/dist/client/assets/_shell.x._extensionId-D3-n5IRW.js +1 -0
  91. package/dist/client/assets/_shell.x._extensionId_._-D3-n5IRW.js +1 -0
  92. package/dist/client/assets/{access-copy-CcG3wpsK.js → access-copy-BVzi1REx.js} +1 -1
  93. package/dist/client/assets/{banner-nt7EFLr6.js → banner-3xXXsU5J.js} +2 -2
  94. package/dist/client/assets/{card-B_zeSZiU.js → card-Bt6IU-Bh.js} +1 -1
  95. package/dist/client/assets/{command-CDfYcQI6.js → command-CWokzKS1.js} +1 -1
  96. package/dist/client/assets/{cpu-D861493C.js → cpu-BzByzE9V.js} +1 -1
  97. package/dist/client/assets/{empty-state-CQ1oXLFa.js → empty-state-BgnQDiMZ.js} +1 -1
  98. package/dist/client/assets/{execution-config-on8kVvnW.js → execution-config-D5-SEt2t.js} +1 -1
  99. package/dist/client/assets/{file-Bwo21EVR.js → file-VHDTQub2.js} +1 -1
  100. package/dist/client/assets/{file-exclamation-point-BedYLbs2.js → file-exclamation-point-DbWvGys0.js} +1 -1
  101. package/dist/client/assets/{file-text-BTj3WyHS.js → file-text-BAhi2zct.js} +1 -1
  102. package/dist/client/assets/{find-latest-widget-fence-B8fM5rIs.js → find-latest-widget-fence-Z0HPVqeK.js} +2 -2
  103. package/dist/client/assets/{form-lSBktWDn.js → form-Blrb1xBU.js} +1 -1
  104. package/dist/client/assets/{format-cron-W7G0In8e.js → format-cron-lKWqEmle.js} +1 -1
  105. package/dist/client/assets/{git-branch-CKlZ81Bg.js → git-branch-BObm8Rlz.js} +1 -1
  106. package/dist/client/assets/{heart-BSVjeGLA.js → heart-Du7nuefC.js} +1 -1
  107. package/dist/client/assets/{highlighted-body-KPVGNVTW-Ct8vmPkj.js → highlighted-body-KPVGNVTW-B_GO7V1P.js} +1 -1
  108. package/dist/client/assets/image-lightbox-BZ1TV3mN.js +1 -0
  109. package/dist/client/assets/image-off-hnjcBIzN.js +6 -0
  110. package/dist/client/assets/{index-6pYWHTBx.js → index-1I8qHZDt.js} +1 -1
  111. package/dist/client/assets/{index-CeZ13dpH.js → index-4GC2fkeO.js} +1 -1
  112. package/dist/client/assets/index-4PAAWURd.js +1 -0
  113. package/dist/client/assets/{index-CaKe9EaL.js → index-B0tAedq7.js} +1 -1
  114. package/dist/client/assets/{index-BVedye9r.js → index-BP68J4pb.js} +1 -1
  115. package/dist/client/assets/{index-gbNK9zj5.js → index-BUOcbPfv.js} +3 -3
  116. package/dist/client/assets/{index-DShrfGYE.js → index-BVKXIbLh.js} +1 -1
  117. package/dist/client/assets/{index-CeeHkxIC.js → index-BaRQVgiN.js} +1 -1
  118. package/dist/client/assets/{index-B-C_A3lP.js → index-BeVbHOwX.js} +2 -2
  119. package/dist/client/assets/{index-KaSZDcGa.js → index-BgzgdvDn.js} +1 -1
  120. package/dist/client/assets/{index-C0TknRcB.js → index-Bm0z9mHt.js} +1 -1
  121. package/dist/client/assets/{index-bvqpTKLz.js → index-BnNTKsbt.js} +1 -1
  122. package/dist/client/assets/{index-DjI5vH_U.js → index-BtbZpz4b.js} +1 -1
  123. package/dist/client/assets/{index-D7kjWnlR.js → index-BvjuGXcS.js} +1 -1
  124. package/dist/client/assets/{index-7Fd_Eeda.js → index-C60RrnTd.js} +1 -1
  125. package/dist/client/assets/{index-CQrM6oF9.js → index-CBm3whA-.js} +1 -1
  126. package/dist/client/assets/{index-C96eZrOR.js → index-CCg7yRe1.js} +1 -1
  127. package/dist/client/assets/{index-Dh8D-3Sb.js → index-CQCN6kWR.js} +1 -1
  128. package/dist/client/assets/index-Cdyszxoa.js +17 -0
  129. package/dist/client/assets/index-Ch-ON5gw.js +1 -0
  130. package/dist/client/assets/{index-UNxDevG6.js → index-Ci74HAFs.js} +1 -1
  131. package/dist/client/assets/{index-Dq4bx2np.js → index-CiQxS4Bn.js} +1 -1
  132. package/dist/client/assets/{index-DEOzZEcu.js → index-CqoIjNC2.js} +3 -3
  133. package/dist/client/assets/index-CrflCTqO.css +1 -0
  134. package/dist/client/assets/index-D5TZCu8j.js +1 -0
  135. package/dist/client/assets/{index-CNnnXzI4.js → index-D6y4WeTi.js} +1 -1
  136. package/dist/client/assets/{index-BjTJ6p2k.js → index-DB8TDRSm.js} +1 -1
  137. package/dist/client/assets/index-DCOOlbEt.js +1 -0
  138. package/dist/client/assets/index-DHYvT3nr.js +23 -0
  139. package/dist/client/assets/{index-GINKfP45.js → index-DRea_Gi0.js} +1 -1
  140. package/dist/client/assets/index-Dain_3cO.js +1 -0
  141. package/dist/client/assets/index-Dc5cpBoO.js +1023 -0
  142. package/dist/client/assets/{index-DOuj--Yi.js → index-Df7a-2P5.js} +1 -1
  143. package/dist/client/assets/{index-BHt5KOZA.js → index-DkhM0fDi.js} +1 -1
  144. package/dist/client/assets/{index-CCWSicoJ.js → index-DoMJUxt_.js} +1 -1
  145. package/dist/client/assets/{index-09EqfhW0.js → index-EZHlD3gf.js} +1 -1
  146. package/dist/client/assets/{index-SdTS2P3x.js → index-HxT_wkaZ.js} +1 -1
  147. package/dist/client/assets/{index-RFknyjho.js → index-Lh82Rz5C.js} +1 -1
  148. package/dist/client/assets/{index-DgRqCuFH.js → index-WxtASL5_.js} +1 -1
  149. package/dist/client/assets/{index-CF73kwtO.js → index-_5Dn0bFm.js} +17 -17
  150. package/dist/client/assets/{index-V_EcsvR4.js → index-aXm0xP_2.js} +1 -1
  151. package/dist/client/assets/{index-DeNVXdMl.js → index-ox3ce99A.js} +1 -1
  152. package/dist/client/assets/{index-BdrbKBym.js → index-r_O6CmXY.js} +1 -1
  153. package/dist/client/assets/index.esm-DXsF3Bua.js +41 -0
  154. package/dist/client/assets/{inline-code-Beal0546.js → inline-code-DAEoWvTf.js} +1 -1
  155. package/dist/client/assets/{layers-DUfQMkMa.js → layers-CsM34LRv.js} +1 -1
  156. package/dist/client/assets/{lightbulb-DTSn-mNB.js → lightbulb-B8JAixK_.js} +1 -1
  157. package/dist/client/assets/{link-2-CHr2s4m2.js → link-2-Csc6okl3.js} +1 -1
  158. package/dist/client/assets/{list-runtime-types-CwEp9Lg4.js → list-runtime-types-DQrZNB7x.js} +1 -1
  159. package/dist/client/assets/markdown-content-DPc7aD1j.js +1 -0
  160. package/dist/client/assets/{mention-pill-XE9mX9G8.js → mention-pill-8P_w4muj.js} +1 -1
  161. package/dist/client/assets/{message-square-off-DUkKSITA.js → message-square-off-D5DXu2cY.js} +1 -1
  162. package/dist/client/assets/{more-details-3dDtVYc6.js → more-details-DEeu2M-p.js} +1 -1
  163. package/dist/client/assets/{owner-notice-BKmuWRki.js → owner-notice-BW4k1ycg.js} +1 -1
  164. package/dist/client/assets/{package-DM7e-GVa.js → package-BSwwAFVm.js} +1 -1
  165. package/dist/client/assets/{page-container-nGewlFnj.js → page-container-CjPUNtNw.js} +1 -1
  166. package/dist/client/assets/{paperclip-BgXlvBBI.js → paperclip-DQaRz34E.js} +1 -1
  167. package/dist/client/assets/{path-input-RzOiTE45.js → path-input-CgXSYNZn.js} +1 -1
  168. package/dist/client/assets/plug-BaUXMfIl.js +11 -0
  169. package/dist/client/assets/primer-trigger-DHB0vilf.js +3 -0
  170. package/dist/client/assets/{profile-errors-CFZN0y6a.js → profile-errors-JW2XTgia.js} +1 -1
  171. package/dist/client/assets/{progress-Cvnh4Qcr.js → progress-CErAw8zp.js} +1 -1
  172. package/dist/client/assets/{query-error-state-CfJfYpa3.js → query-error-state-BFWpEXsl.js} +1 -1
  173. package/dist/client/assets/{radio-BOcAjXVO.js → radio-Bkx216ga.js} +1 -1
  174. package/dist/client/assets/registry-Ce1VRIS3.js +1 -0
  175. package/dist/client/assets/{relay-trace-schemas-Cvb7RGjg.js → relay-trace-schemas-DiZj_AFV.js} +2 -2
  176. package/dist/client/assets/{room-files-source-B-ZJA_NM.js → room-files-source-BilZvdpf.js} +2 -2
  177. package/dist/client/assets/{rotate-ccw-clock-vRQP4hWE.js → rotate-ccw-clock-D_SO1stN.js} +1 -1
  178. package/dist/client/assets/{rotate-cw-DD2nOAQ-.js → rotate-cw-C68kM23F.js} +1 -1
  179. package/dist/client/assets/{scroll-area-DTvv8_DS.js → scroll-area-CVWFUmJV.js} +1 -1
  180. package/dist/client/assets/{search-x-Ig8nk-DU.js → search-x-BTFVvyA2.js} +1 -1
  181. package/dist/client/assets/{shield-check-DjnWx7aT.js → shield-check-Dpxi6WqO.js} +1 -1
  182. package/dist/client/assets/{shield-x-BrtccpM7.js → shield-x-CdCCgyXk.js} +1 -1
  183. package/dist/client/assets/signed-in-BxAnDo0S.js +1 -0
  184. package/dist/client/assets/{soul-file-C5mMIP4v.js → soul-file-CRfKVJX3.js} +1 -1
  185. package/dist/client/assets/{table-Rll_Jxd8.js → table-BL3xUC41.js} +1 -1
  186. package/dist/client/assets/{terminal-Bjss9oke.js → terminal-u_UCRzSM.js} +1 -1
  187. package/dist/client/assets/{trust-posture-Dmk2WlZv.js → trust-posture-B-v4BWo7.js} +1 -1
  188. package/dist/client/assets/{unplug-BHYMc4ND.js → unplug-CFbC-L5W.js} +1 -1
  189. package/dist/client/assets/{unverified-catalog-notice-BmIVQhjE.js → unverified-catalog-notice-ZUqscVFM.js} +1 -1
  190. package/dist/client/assets/{use-adapter-catalog-RzlxX2Wa.js → use-adapter-catalog-Z4MDWZAZ.js} +1 -1
  191. package/dist/client/assets/{use-bindings-Ds_MAC67.js → use-bindings-CsTavmf-.js} +1 -1
  192. package/dist/client/assets/{use-composer-prefs-ckA_eZQS.js → use-composer-prefs-BY2dTvep.js} +1 -1
  193. package/dist/client/assets/{use-connector-management-oEqok0QG.js → use-connector-management-L9l21yTi.js} +1 -1
  194. package/dist/client/assets/{use-deep-link-scroll-Clu9Sz2-.js → use-deep-link-scroll-Bn2ZUtDY.js} +1 -1
  195. package/dist/client/assets/{use-delete-binding-B_zHPcy8.js → use-delete-binding-DLvdHtPD.js} +1 -1
  196. package/dist/client/assets/{use-dev-links-BO7-IHe9.js → use-dev-links-DFvL8mIg.js} +1 -1
  197. package/dist/client/assets/{use-external-adapter-catalog-7lRWtn7J.js → use-external-adapter-catalog-Be57G4tz.js} +1 -1
  198. package/dist/client/assets/{use-full-activity-feed-DrcMJL9m.js → use-full-activity-feed-Cp3lYXdi.js} +1 -1
  199. package/dist/client/assets/use-is-below-desktop-DmekpHAF.js +1 -0
  200. package/dist/client/assets/use-is-hub-el7LTkg3.js +1 -0
  201. package/dist/client/assets/{use-jump-back-in-Dav0ttfs.js → use-jump-back-in-ChH1FSEK.js} +3 -3
  202. package/dist/client/assets/{use-local-browser-CtltDlof.js → use-local-browser-zA8gMhcC.js} +1 -1
  203. package/dist/client/assets/{use-mesh-topology-CiS9XQsg.js → use-mesh-topology-CvoD-L1G.js} +1 -1
  204. package/dist/client/assets/{use-mounted-ref-DuK0vm9N.js → use-mounted-ref-Ch0wqQry.js} +1 -1
  205. package/dist/client/assets/{use-notification-prefs-Chf4UNbq.js → use-notification-prefs-DeR05zhp.js} +1 -1
  206. package/dist/client/assets/{use-panel-tab-placements-C5y831aL.js → use-panel-tab-placements-DdjrmaoK.js} +1 -1
  207. package/dist/client/assets/use-pending-read-DBpte0GI.js +1 -0
  208. package/dist/client/assets/use-personality-commit-qQfISO2-.js +1 -0
  209. package/dist/client/assets/use-promo-activation-CwGoE7b-.js +11 -0
  210. package/dist/client/assets/{use-promo-dismissals-8-hGry_v.js → use-promo-dismissals-BBqVN4hx.js} +1 -1
  211. package/dist/client/assets/{use-pulse-freshness-CWudgqNc.js → use-pulse-freshness-BKW7tjvX.js} +1 -1
  212. package/dist/client/assets/{use-relay-config-8mXfegbP.js → use-relay-config-D5iieBXl.js} +1 -1
  213. package/dist/client/assets/{use-room-follow-claim-DgEWUsoP.js → use-room-follow-claim-BwZh2ZPH.js} +1 -1
  214. package/dist/client/assets/{use-roving-tab-list-CXy0Hv5J.js → use-roving-tab-list-Ct7yDAUE.js} +1 -1
  215. package/dist/client/assets/use-session-canvas-CJrfZrYG.js +24 -0
  216. package/dist/client/assets/{use-session-diagnostics-LKiXub1H.js → use-session-diagnostics-Dn-Wnyhh.js} +4 -4
  217. package/dist/client/assets/{use-unclaimed-chats-Cr812OTh.js → use-unclaimed-chats-M-c5tjXH.js} +1 -1
  218. package/dist/client/assets/use-update-config-DhlbZldm.js +1 -0
  219. package/dist/client/assets/{useMutationState-BnXJ-0A_.js → useMutationState-Cd-VqRAv.js} +1 -1
  220. package/dist/client/index.html +2 -2
  221. package/dist/drizzle/20261017113300_session_public_computer.sql +1 -0
  222. package/dist/drizzle/meta/20261017113300_snapshot.json +14020 -0
  223. package/dist/drizzle/meta/_journal.json +7 -0
  224. package/dist/server/index.js +128843 -121508
  225. package/dist/server/index.js.map +2 -2
  226. package/package.json +5 -5
  227. package/dist/client/assets/AdapterSetupWizard-DfNJz5SD.js +0 -2
  228. package/dist/client/assets/AppearancePage-8ALtWGZZ.js +0 -1
  229. package/dist/client/assets/AttentionSignalRow-c-u1cE1l.js +0 -1
  230. package/dist/client/assets/CanvasFileContent-BJ39nHuR.js +0 -2
  231. package/dist/client/assets/CanvasModel3dContent-TaunlbT2.js +0 -2
  232. package/dist/client/assets/HandlePage-CfeEzfDk.js +0 -1
  233. package/dist/client/assets/KeyEntry-CEbe5Xvn.js +0 -6
  234. package/dist/client/assets/McpSigninBody-CLZFoQgC.js +0 -1
  235. package/dist/client/assets/NamePage-B4YrH-ug.js +0 -1
  236. package/dist/client/assets/NewDirectMessageMenu-Co9Uv5t5.js +0 -1
  237. package/dist/client/assets/PhotoPage-DYDJPBfu.js +0 -1
  238. package/dist/client/assets/PromptSuggestionChips-CUwLk83h.js +0 -1
  239. package/dist/client/assets/RunsOnPopover-CTBEMstG.js +0 -1
  240. package/dist/client/assets/RuntimeConnectFlow-DY4sjRgN.js +0 -1
  241. package/dist/client/assets/RuntimeSetupDialog-DJu_-eNa.js +0 -1
  242. package/dist/client/assets/SettingsDialog-CKmcLF66.js +0 -12
  243. package/dist/client/assets/TaskDialogWrapper-Boxr_hgF.js +0 -1
  244. package/dist/client/assets/TasksEmptyState-CQf1YroK.js +0 -3
  245. package/dist/client/assets/TourHost-DzEG8bZP.js +0 -1
  246. package/dist/client/assets/WidgetErrorCard-CT4sl_T6.js +0 -108
  247. package/dist/client/assets/_shell-BDlkTSin.js +0 -90
  248. package/dist/client/assets/_shell._home.activity-DGXa_ouh.js +0 -1
  249. package/dist/client/assets/_shell._home.index-D5kOfqnL.js +0 -3
  250. package/dist/client/assets/_shell._home.tasks-BSMD-atB.js +0 -1
  251. package/dist/client/assets/_shell.channels-B4VQ7tiZ.js +0 -10
  252. package/dist/client/assets/_shell.marketplace-B-T-ALMv.js +0 -1
  253. package/dist/client/assets/_shell.marketplace_.sources-Chu-9-Vi.js +0 -1
  254. package/dist/client/assets/_shell.session-Bz6wvDBp.js +0 -66
  255. package/dist/client/assets/_shell.x._extensionId-DSqMu6Ey.js +0 -1
  256. package/dist/client/assets/_shell.x._extensionId_._-DSqMu6Ey.js +0 -1
  257. package/dist/client/assets/index-BDCqg2iM.css +0 -1
  258. package/dist/client/assets/index-C8-dwIPp.js +0 -1018
  259. package/dist/client/assets/index-CAv_6Po4.js +0 -1
  260. package/dist/client/assets/index-ClELcMX1.js +0 -1
  261. package/dist/client/assets/index-CrEyJcPM.js +0 -17
  262. package/dist/client/assets/index-DQJM5kjJ.js +0 -1
  263. package/dist/client/assets/index-DURo45pu.js +0 -1
  264. package/dist/client/assets/index-sfSRuIXm.js +0 -23
  265. package/dist/client/assets/markdown-content-GoymYcRL.js +0 -1
  266. package/dist/client/assets/primer-trigger-B60oEVY7.js +0 -3
  267. package/dist/client/assets/registry-B9wsS5De.js +0 -1
  268. package/dist/client/assets/use-is-below-desktop-BhzXZsbH.js +0 -1
  269. package/dist/client/assets/use-pending-read-i6TB4gGQ.js +0 -1
  270. package/dist/client/assets/use-personality-commit-KKJ2ve1V.js +0 -1
  271. package/dist/client/assets/use-promo-activation-D45fuXdT.js +0 -11
  272. package/dist/client/assets/use-session-canvas-CUvHGgMf.js +0 -64
  273. package/dist/client/assets/use-update-config-Bad4g6mB.js +0 -1
@@ -1,15 +1,15 @@
1
- import{eh as Ee,a1 as xe,aV as Re,r as ve,a2 as Se,j,G as Ce}from"./index-C8-dwIPp.js";import{u as Oe}from"./index-CeZ13dpH.js";import{r as Te}from"./use-session-canvas-CUvHGgMf.js";import"./rotate-cw-DD2nOAQ-.js";import"./WidgetErrorCard-CT4sl_T6.js";import"./card-B_zeSZiU.js";import"./progress-Cvnh4Qcr.js";import"./markdown-content-GoymYcRL.js";import"./table-Rll_Jxd8.js";import"./terminal-Bjss9oke.js";import"./package-DM7e-GVa.js";import"./heart-BSVjeGLA.js";import"./git-branch-CKlZ81Bg.js";import"./file-text-BTj3WyHS.js";import"./file-Bwo21EVR.js";import"./McpAppFrame-D5Muf5Sf.js";import"./more-details-3dDtVYc6.js";var he={exports:{}};/* @license
1
+ import{em as Ee,a1 as xe,aW as Re,r as ve,a2 as Se,j,G as Ce}from"./index-Dc5cpBoO.js";import{u as Oe}from"./index-4GC2fkeO.js";import{r as Te}from"./use-session-canvas-CJrfZrYG.js";import"./rotate-cw-C68kM23F.js";import"./index.esm-DXsF3Bua.js";import"./WidgetErrorCard-CzWw_SPD.js";import"./index-Ch-ON5gw.js";import"./card-Bt6IU-Bh.js";import"./progress-CErAw8zp.js";import"./markdown-content-DPc7aD1j.js";import"./table-BL3xUC41.js";import"./terminal-u_UCRzSM.js";import"./package-BSwwAFVm.js";import"./heart-Du7nuefC.js";import"./git-branch-BObm8Rlz.js";import"./file-text-BAhi2zct.js";import"./file-VHDTQub2.js";import"./McpAppFrame-CuObpQTg.js";import"./more-details-DEeu2M-p.js";var he={exports:{}};/* @license
2
2
  Papa Parse
3
3
  v5.7.0
4
4
  https://github.com/mholt/PapaParse
5
5
  License: MIT
6
- */var Ie=he.exports,ke;function Ae(){return ke||(ke=1,(function(H,X){((G,m)=>{H.exports=m()})(Ie,function G(){var m=typeof self<"u"?self:typeof window<"u"?window:m!==void 0?m:{},C=!m.document&&!!m.postMessage,N=m.IS_PAPA_WORKER||!1,J={},Y=0,o={};function P(t){return t.charCodeAt(0)===65279?t.slice(1):t}function z(t){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(e){var r=de(e);r.chunkSize=parseInt(r.chunkSize),e.step||e.chunk||(r.chunkSize=null),this._handle=new pe(r),(this._handle.streamer=this)._config=r}).call(this,t),this.parseChunk=function(e,r){var s=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<s){let g=this._config.newline;g||(i=this._config.quoteChar||'"',g=this._handle.guessLineEndings(e,i)),e=[...e.split(g).slice(s)].join(g)}this.isFirstChunk&&E(this._config.beforeFirstChunk)&&(i=this._config.beforeFirstChunk(e))!==void 0&&(e=i),this.isFirstChunk=!1,this._halted=!1;var s=this._partialLine+e,i=(this._partialLine="",this._handle.parse(s,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(e=i.meta.cursor,s=(this._finished||(this._partialLine=s.substring(e-this._baseIndex),this._baseIndex=e),i&&i.data&&(this._rowCount+=i.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),N)m.postMessage({results:i,workerId:o.WORKER_ID,finished:s});else if(E(this._config.chunk)&&!r){if(this._config.chunk(i,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=i=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(i.data),this._completeResults.errors=this._completeResults.errors.concat(i.errors),this._completeResults.meta=i.meta),this._completed||!s||!E(this._config.complete)||i&&i.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),s||i&&i.meta.paused||this._nextChunk(),i}this._halted=!0},this._sendError=function(e){E(this._config.error)?this._config.error(e):N&&this._config.error&&m.postMessage({workerId:o.WORKER_ID,error:e,finished:!1})}}function re(t){var e;(t=t||{}).chunkSize||(t.chunkSize=o.RemoteChunkSize),z.call(this,t),this._nextChunk=C?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(r){this._input=r,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(e=new XMLHttpRequest,this._config.withCredentials&&(e.withCredentials=this._config.withCredentials),C||(e.onload=$(this._chunkLoaded,this),e.onerror=$(this._chunkError,this)),e.ontimeout=$(this._chunkTimeout,this),e.open(this._config.downloadRequestBody?"POST":"GET",this._input,!C),this._config.downloadTimeout&&!C&&(e.timeout=this._config.downloadTimeout),this._config.downloadRequestHeaders){var r,s=this._config.downloadRequestHeaders;for(r in s)e.setRequestHeader(r,s[r])}var i;this._config.chunkSize&&(i=this._start+this._config.chunkSize-1,e.setRequestHeader("Range","bytes="+this._start+"-"+i));try{e.send(this._config.downloadRequestBody)}catch(g){this._chunkError(g.message)}C&&e.status===0&&this._chunkError()}},this._chunkLoaded=function(){e.readyState===4&&(e.status<200||400<=e.status?this._chunkError():(this._start+=this._config.chunkSize||e.responseText.length,this._finished=!this._config.chunkSize||this._start>=(r=>(r=r.getResponseHeader("Content-Range"))!==null?parseInt(r.substring(r.lastIndexOf("/")+1)):-1)(e),this.parseChunk(e.responseText)))},this._chunkError=function(r){r=e.statusText||r,this._sendError(new Error(r))},this._chunkTimeout=function(){this._chunkError("Request timed out after "+this._config.downloadTimeout+"ms")}}function oe(t){(t=t||{}).chunkSize||(t.chunkSize=o.LocalChunkSize),z.call(this,t);var e,r,s=typeof FileReader<"u";this.stream=function(i){this._input=i,r=i.slice||i.webkitSlice||i.mozSlice,s?((e=new FileReader).onload=$(this._chunkLoaded,this),e.onerror=$(this._chunkError,this)):e=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var i=this._input,g=(this._config.chunkSize&&(g=Math.min(this._start+this._config.chunkSize,this._input.size),i=r.call(i,this._start,g)),e.readAsText(i,this._config.encoding));s||this._chunkLoaded({target:{result:g}})},this._chunkLoaded=function(i){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(i.target.result)},this._chunkError=function(){this._sendError(e.error)}}function ie(t){var e;z.call(this,t=t||{}),this.stream=function(r){return e=r,this._nextChunk()},this._nextChunk=function(){var r,s;if(!this._finished)return r=this._config.chunkSize,e=r?(s=e.substring(0,r),e.substring(r)):(s=e,""),this._finished=!e,this.parseChunk(s)}}function ue(t){z.call(this,t=t||{});var e=[],r=!0,s=!1;this.pause=function(){z.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){z.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(i){this._input=i,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){s&&e.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),e.length?this.parseChunk(e.shift()):r=!0},this._streamData=$(function(i){try{e.push(typeof i=="string"?i:i.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(e.shift()))}catch(g){this._streamError(g)}},this),this._streamError=$(function(i){this._streamCleanUp(),this._sendError(i)},this),this._streamEnd=$(function(){this._streamCleanUp(),s=!0,this._streamData("")},this),this._streamCleanUp=$(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function pe(t){var e,r,s,i,g=Math.pow(2,53),I=-g,U=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,V=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,w=this,A=0,u=0,D=!1,l=!1,d=[],n={data:[],errors:[],meta:{}};function F(p){return t.skipEmptyLines==="greedy"?p.join("").trim()==="":p.length===1&&p[0].length===0}function k(){if(n&&s&&(M("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+o.DefaultDelimiter+"'"),s=!1),t.skipEmptyLines&&(n.data=n.data.filter(function(a){return!F(a)})),x()){let a=function(R){d.push(R)};if(n)if(Array.isArray(n.data[0])){for(var p=0;x()&&p<n.data.length;p++)n.data[p].forEach(a);n.data.splice(0,1)}else n.data.forEach(a)}function f(a,R){for(var O=t.header?{}:[],_=0;_<a.length;_++){var y=_,c=a[_],c=((q,h)=>(v=>(t.dynamicTypingFunction&&t.dynamicTyping[v]===void 0&&(t.dynamicTyping[v]=t.dynamicTypingFunction(v)),(t.dynamicTyping[v]||t.dynamicTyping)===!0))(q)?h==="true"||h==="TRUE"||h!=="false"&&h!=="FALSE"&&((v=>{if(U.test(v)&&(v=parseFloat(v),I<v&&v<g))return 1})(h)?parseFloat(h):V.test(h)?new Date(h):h===""?null:h):h)(y=t.header?_>=d.length?"__parsed_extra":d[_]:y,c=t.transform?t.transform(c,y):c);y==="__parsed_extra"?(O[y]=O[y]||[],O[y].push(c)):O[y]=c}return t.header&&(_>d.length?M("FieldMismatch","TooManyFields","Too many fields: expected "+d.length+" fields but parsed "+_,u+R):_<d.length&&M("FieldMismatch","TooFewFields","Too few fields: expected "+d.length+" fields but parsed "+_,u+R)),O}var b;n&&(t.header||t.dynamicTyping||t.transform)&&(b=1,!n.data.length||Array.isArray(n.data[0])?(n.data=n.data.map(f),b=n.data.length):n.data=f(n.data,0),t.header&&n.meta&&(n.meta.fields=d),u+=b)}function x(){return t.header&&d.length===0}function M(p,f,b,a){p={type:p,code:f,message:b},a!==void 0&&(p.row=a),n.errors.push(p)}E(t.step)&&(i=t.step,t.step=function(p){n=p,x()?k():(k(),n.data.length!==0&&(A+=p.data.length,t.preview&&A>t.preview?r.abort():(n.data=n.data[0],i(n,w))))}),this.parse=function(p,f,b){var a=t.quoteChar||'"',a=(t.newline||(t.newline=this.guessLineEndings(p,a)),s=!1,t.delimiter?E(t.delimiter)&&(t.delimiter=t.delimiter(p),n.meta.delimiter=t.delimiter):((a=((R,O,_,y,c)=>{var q,h,v,Z;c=c||[","," ","|",";",o.RECORD_SEP,o.UNIT_SEP];for(var ee=0;ee<c.length;ee++){for(var B,se=c[ee],T=0,K=0,S=0,L=(v=void 0,new le({comments:y,delimiter:se,newline:O,preview:10}).parse(R)),Q=0;Q<L.data.length;Q++)_&&F(L.data[Q])?S++:(B=L.data[Q].length,K+=B,v===void 0?v=B:0<B&&(T+=Math.abs(B-v),v=B));0<L.data.length&&(K/=L.data.length-S),1.99<K&&(h===void 0||T<h||T===h&&Z<K)&&(h=T,q=se,Z=K)}return{successful:!!(t.delimiter=q),bestDelimiter:q}})(p,t.newline,t.skipEmptyLines,t.comments,t.delimitersToGuess)).successful?t.delimiter=a.bestDelimiter:(s=!0,t.delimiter=o.DefaultDelimiter),n.meta.delimiter=t.delimiter),de(t));return a.header=x(),t.preview&&t.header&&a.preview++,e=p,r=new le(a),n=r.parse(e,f,b),k(),D?{meta:{paused:!0}}:n||{meta:{paused:!1}}},this.paused=function(){return D},this.pause=function(){D=!0,r.abort(),e=E(t.chunk)?"":e.substring(r.getCharIndex())},this.resume=function(){w.streamer._halted?(D=!1,w.streamer.parseChunk(e,!0)):setTimeout(w.resume,3)},this.aborted=function(){return l},this.abort=function(){l=!0,r.abort(),n.meta.aborted=!0,E(t.complete)&&t.complete(n),e=""},this.guessLineEndings=function(R,a){R=R.substring(0,1048576);var a=new RegExp(ne(a)+"([^]*?)"+ne(a),"gm"),b=(R=R.replace(a,"")).split("\r"),a=R.split(`
6
+ */var Ie=he.exports,ke;function Ae(){return ke||(ke=1,(function(H,X){((G,m)=>{H.exports=m()})(Ie,function G(){var m=typeof self<"u"?self:typeof window<"u"?window:m!==void 0?m:{},C=!m.document&&!!m.postMessage,N=m.IS_PAPA_WORKER||!1,J={},Y=0,o={};function P(t){return t.charCodeAt(0)===65279?t.slice(1):t}function z(t){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(e){var r=de(e);r.chunkSize=parseInt(r.chunkSize),e.step||e.chunk||(r.chunkSize=null),this._handle=new pe(r),(this._handle.streamer=this)._config=r}).call(this,t),this.parseChunk=function(e,r){var s=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<s){let g=this._config.newline;g||(i=this._config.quoteChar||'"',g=this._handle.guessLineEndings(e,i)),e=[...e.split(g).slice(s)].join(g)}this.isFirstChunk&&E(this._config.beforeFirstChunk)&&(i=this._config.beforeFirstChunk(e))!==void 0&&(e=i),this.isFirstChunk=!1,this._halted=!1;var s=this._partialLine+e,i=(this._partialLine="",this._handle.parse(s,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(e=i.meta.cursor,s=(this._finished||(this._partialLine=s.substring(e-this._baseIndex),this._baseIndex=e),i&&i.data&&(this._rowCount+=i.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),N)m.postMessage({results:i,workerId:o.WORKER_ID,finished:s});else if(E(this._config.chunk)&&!r){if(this._config.chunk(i,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=i=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(i.data),this._completeResults.errors=this._completeResults.errors.concat(i.errors),this._completeResults.meta=i.meta),this._completed||!s||!E(this._config.complete)||i&&i.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),s||i&&i.meta.paused||this._nextChunk(),i}this._halted=!0},this._sendError=function(e){E(this._config.error)?this._config.error(e):N&&this._config.error&&m.postMessage({workerId:o.WORKER_ID,error:e,finished:!1})}}function re(t){var e;(t=t||{}).chunkSize||(t.chunkSize=o.RemoteChunkSize),z.call(this,t),this._nextChunk=C?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(r){this._input=r,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(e=new XMLHttpRequest,this._config.withCredentials&&(e.withCredentials=this._config.withCredentials),C||(e.onload=$(this._chunkLoaded,this),e.onerror=$(this._chunkError,this)),e.ontimeout=$(this._chunkTimeout,this),e.open(this._config.downloadRequestBody?"POST":"GET",this._input,!C),this._config.downloadTimeout&&!C&&(e.timeout=this._config.downloadTimeout),this._config.downloadRequestHeaders){var r,s=this._config.downloadRequestHeaders;for(r in s)e.setRequestHeader(r,s[r])}var i;this._config.chunkSize&&(i=this._start+this._config.chunkSize-1,e.setRequestHeader("Range","bytes="+this._start+"-"+i));try{e.send(this._config.downloadRequestBody)}catch(g){this._chunkError(g.message)}C&&e.status===0&&this._chunkError()}},this._chunkLoaded=function(){e.readyState===4&&(e.status<200||400<=e.status?this._chunkError():(this._start+=this._config.chunkSize||e.responseText.length,this._finished=!this._config.chunkSize||this._start>=(r=>(r=r.getResponseHeader("Content-Range"))!==null?parseInt(r.substring(r.lastIndexOf("/")+1)):-1)(e),this.parseChunk(e.responseText)))},this._chunkError=function(r){r=e.statusText||r,this._sendError(new Error(r))},this._chunkTimeout=function(){this._chunkError("Request timed out after "+this._config.downloadTimeout+"ms")}}function oe(t){(t=t||{}).chunkSize||(t.chunkSize=o.LocalChunkSize),z.call(this,t);var e,r,s=typeof FileReader<"u";this.stream=function(i){this._input=i,r=i.slice||i.webkitSlice||i.mozSlice,s?((e=new FileReader).onload=$(this._chunkLoaded,this),e.onerror=$(this._chunkError,this)):e=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var i=this._input,g=(this._config.chunkSize&&(g=Math.min(this._start+this._config.chunkSize,this._input.size),i=r.call(i,this._start,g)),e.readAsText(i,this._config.encoding));s||this._chunkLoaded({target:{result:g}})},this._chunkLoaded=function(i){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(i.target.result)},this._chunkError=function(){this._sendError(e.error)}}function ie(t){var e;z.call(this,t=t||{}),this.stream=function(r){return e=r,this._nextChunk()},this._nextChunk=function(){var r,s;if(!this._finished)return r=this._config.chunkSize,e=r?(s=e.substring(0,r),e.substring(r)):(s=e,""),this._finished=!e,this.parseChunk(s)}}function ue(t){z.call(this,t=t||{});var e=[],r=!0,s=!1;this.pause=function(){z.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){z.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(i){this._input=i,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){s&&e.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),e.length?this.parseChunk(e.shift()):r=!0},this._streamData=$(function(i){try{e.push(typeof i=="string"?i:i.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(e.shift()))}catch(g){this._streamError(g)}},this),this._streamError=$(function(i){this._streamCleanUp(),this._sendError(i)},this),this._streamEnd=$(function(){this._streamCleanUp(),s=!0,this._streamData("")},this),this._streamCleanUp=$(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function pe(t){var e,r,s,i,g=Math.pow(2,53),I=-g,U=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,Q=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,w=this,A=0,u=0,D=!1,l=!1,d=[],n={data:[],errors:[],meta:{}};function F(p){return t.skipEmptyLines==="greedy"?p.join("").trim()==="":p.length===1&&p[0].length===0}function k(){if(n&&s&&(M("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+o.DefaultDelimiter+"'"),s=!1),t.skipEmptyLines&&(n.data=n.data.filter(function(a){return!F(a)})),x()){let a=function(R){d.push(R)};if(n)if(Array.isArray(n.data[0])){for(var p=0;x()&&p<n.data.length;p++)n.data[p].forEach(a);n.data.splice(0,1)}else n.data.forEach(a)}function f(a,R){for(var O=t.header?{}:[],_=0;_<a.length;_++){var y=_,c=a[_],c=((q,h)=>(v=>(t.dynamicTypingFunction&&t.dynamicTyping[v]===void 0&&(t.dynamicTyping[v]=t.dynamicTypingFunction(v)),(t.dynamicTyping[v]||t.dynamicTyping)===!0))(q)?h==="true"||h==="TRUE"||h!=="false"&&h!=="FALSE"&&((v=>{if(U.test(v)&&(v=parseFloat(v),I<v&&v<g))return 1})(h)?parseFloat(h):Q.test(h)?new Date(h):h===""?null:h):h)(y=t.header?_>=d.length?"__parsed_extra":d[_]:y,c=t.transform?t.transform(c,y):c);y==="__parsed_extra"?(O[y]=O[y]||[],O[y].push(c)):O[y]=c}return t.header&&(_>d.length?M("FieldMismatch","TooManyFields","Too many fields: expected "+d.length+" fields but parsed "+_,u+R):_<d.length&&M("FieldMismatch","TooFewFields","Too few fields: expected "+d.length+" fields but parsed "+_,u+R)),O}var b;n&&(t.header||t.dynamicTyping||t.transform)&&(b=1,!n.data.length||Array.isArray(n.data[0])?(n.data=n.data.map(f),b=n.data.length):n.data=f(n.data,0),t.header&&n.meta&&(n.meta.fields=d),u+=b)}function x(){return t.header&&d.length===0}function M(p,f,b,a){p={type:p,code:f,message:b},a!==void 0&&(p.row=a),n.errors.push(p)}E(t.step)&&(i=t.step,t.step=function(p){n=p,x()?k():(k(),n.data.length!==0&&(A+=p.data.length,t.preview&&A>t.preview?r.abort():(n.data=n.data[0],i(n,w))))}),this.parse=function(p,f,b){var a=t.quoteChar||'"',a=(t.newline||(t.newline=this.guessLineEndings(p,a)),s=!1,t.delimiter?E(t.delimiter)&&(t.delimiter=t.delimiter(p),n.meta.delimiter=t.delimiter):((a=((R,O,_,y,c)=>{var q,h,v,Z;c=c||[","," ","|",";",o.RECORD_SEP,o.UNIT_SEP];for(var ee=0;ee<c.length;ee++){for(var W,se=c[ee],T=0,B=0,S=0,L=(v=void 0,new le({comments:y,delimiter:se,newline:O,preview:10}).parse(R)),V=0;V<L.data.length;V++)_&&F(L.data[V])?S++:(W=L.data[V].length,B+=W,v===void 0?v=W:0<W&&(T+=Math.abs(W-v),v=W));0<L.data.length&&(B/=L.data.length-S),1.99<B&&(h===void 0||T<h||T===h&&Z<B)&&(h=T,q=se,Z=B)}return{successful:!!(t.delimiter=q),bestDelimiter:q}})(p,t.newline,t.skipEmptyLines,t.comments,t.delimitersToGuess)).successful?t.delimiter=a.bestDelimiter:(s=!0,t.delimiter=o.DefaultDelimiter),n.meta.delimiter=t.delimiter),de(t));return a.header=x(),t.preview&&t.header&&a.preview++,e=p,r=new le(a),n=r.parse(e,f,b),k(),D?{meta:{paused:!0}}:n||{meta:{paused:!1}}},this.paused=function(){return D},this.pause=function(){D=!0,r.abort(),e=E(t.chunk)?"":e.substring(r.getCharIndex())},this.resume=function(){w.streamer._halted?(D=!1,w.streamer.parseChunk(e,!0)):setTimeout(w.resume,3)},this.aborted=function(){return l},this.abort=function(){l=!0,r.abort(),n.meta.aborted=!0,E(t.complete)&&t.complete(n),e=""},this.guessLineEndings=function(R,a){R=R.substring(0,1048576);var a=new RegExp(ne(a)+"([^]*?)"+ne(a),"gm"),b=(R=R.replace(a,"")).split("\r"),a=R.split(`
7
7
  `),R=1<a.length&&a[0].length<b[0].length;if(b.length===1||R)return`
8
8
  `;for(var O=0,_=0;_<b.length;_++)b[_][0]===`
9
9
  `&&O++;return O>=b.length/2?`\r
10
- `:"\r"}}function ne(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function le(t){var e=(t=t||{}).delimiter,r=t.newline,s=t.comments,i=t.step,g=t.preview,I=t.fastMode,U=null,V=!1,w=t.quoteChar==null?'"':t.quoteChar,A=w;if(t.escapeChar!==void 0&&(A=t.escapeChar),(typeof e!="string"||-1<o.BAD_DELIMITERS.indexOf(e))&&(e=","),s===e)throw new Error("Comment character same as delimiter");s===!0?s="#":(typeof s!="string"||-1<o.BAD_DELIMITERS.indexOf(s))&&(s=!1),r!==`
10
+ `:"\r"}}function ne(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function le(t){var e=(t=t||{}).delimiter,r=t.newline,s=t.comments,i=t.step,g=t.preview,I=t.fastMode,U=null,Q=!1,w=t.quoteChar==null?'"':t.quoteChar,A=w;if(t.escapeChar!==void 0&&(A=t.escapeChar),(typeof e!="string"||-1<o.BAD_DELIMITERS.indexOf(e))&&(e=","),s===e)throw new Error("Comment character same as delimiter");s===!0?s="#":(typeof s!="string"||-1<o.BAD_DELIMITERS.indexOf(s))&&(s=!1),r!==`
11
11
  `&&r!=="\r"&&r!==`\r
12
12
  `&&(r=`
13
- `);var u=0,D=!1;this.parse=function(l,d,n){if(typeof l!="string")throw new Error("Input must be a string");var F=l.length,k=e.length,x=r.length,M=s.length,p=E(i),f=[],b=[],a=[],R=u=0;if(!l)return T();if(I||I!==!1&&l.indexOf(w)===-1){for(var O=l.split(r),_=0;_<O.length;_++){if(a=O[_],u+=a.length,_!==O.length-1)u+=r.length;else if(n)return T();if(!s||a.substring(0,M)!==s){if(p){if(f=[],Z(a.split(e)),K(),D)return T()}else Z(a.split(e));if(g&&g<=_)return f=f.slice(0,g),T(!0)}}return T()}for(var y=l.indexOf(e,u),c=l.indexOf(r,u),q=new RegExp(ne(A)+ne(w),"g"),h=l.indexOf(w,u);;)if(l[u]===w)for(h=u,u++;;){if((h=l.indexOf(w,h+1))===-1)return n||b.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:f.length,index:u}),B();if(h===F-1)return B(l.substring(u,h).replace(q,w));if(w===A&&l[h+1]===A)h++;else if(w===A||h===0||l[h-1]!==A){y!==-1&&y<h+1&&(y=l.indexOf(e,h+1));var v=ee((c=c!==-1&&c<h+1?l.indexOf(r,h+1):c)===-1?y:Math.min(y,c));if(l.substr(h+1+v,k)===e){a.push(l.substring(u,h).replace(q,w)),l[u=h+1+v+k]!==w&&(h=l.indexOf(w,u)),y=l.indexOf(e,u),c=l.indexOf(r,u);break}if(v=ee(c),l.substring(h+1+v,h+1+v+x)===r){if(a.push(l.substring(u,h).replace(q,w)),se(h+1+v+x),y=l.indexOf(e,u),h=l.indexOf(w,u),p&&(K(),D))return T();if(g&&f.length>=g)return T(!0);break}b.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:f.length,index:u}),h++}}else if(s&&a.length===0&&l.substring(u,u+M)===s){if(c===-1)return T();u=c+x,c=l.indexOf(r,u),y=l.indexOf(e,u)}else if(y!==-1&&(y<c||c===-1))a.push(l.substring(u,y)),u=y+k,y=l.indexOf(e,u);else{if(c===-1)break;if(a.push(l.substring(u,c)),se(c+x),p&&(K(),D))return T();if(g&&f.length>=g)return T(!0)}return B();function Z(S){f.push(S),R=u}function ee(S){var L=0;return L=S!==-1&&(S=l.substring(h+1,S))&&S.trim()===""?S.length:L}function B(S){return n||(S===void 0&&(S=l.substring(u)),a.push(S),u=F,Z(a),p&&K()),T()}function se(S){u=S,Z(a),a=[],c=l.indexOf(r,u)}function T(S){if(t.header&&!d&&f.length&&!V){var L=f[0],Q=Object.create(null),fe=new Set(L);let me=!1;for(let te=0;te<L.length;te++){let W=P(L[te]);if(Q[W=E(t.transformHeader)?t.transformHeader(W,te):W]){let ae,ye=Q[W];for(;ae=W+"_"+ye,ye++,fe.has(ae););fe.add(ae),L[te]=ae,Q[W]++,me=!0,(U=U===null?{}:U)[ae]=W}else Q[W]=1,L[te]=W;fe.add(W)}me&&console.warn("Duplicate headers found and renamed."),V=!0}return{data:f,errors:b,meta:{delimiter:e,linebreak:r,aborted:D,truncated:!!S,cursor:R+(d||0),renamedHeaders:U}}}function K(){i(T()),f=[],b=[]}},this.abort=function(){D=!0},this.getCharIndex=function(){return u}}function be(t){var e=t.data,r=J[e.workerId],s=!1;if(e.error)r.userError(e.error,e.file);else if(e.results&&e.results.data){var i={abort:function(){s=!0,ge(e.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:_e,resume:_e};if(E(r.userStep)){for(var g=0;g<e.results.data.length&&(r.userStep({data:e.results.data[g],errors:e.results.errors,meta:e.results.meta},i),!s);g++);delete e.results}else E(r.userChunk)&&(r.userChunk(e.results,i,e.file),delete e.results)}e.finished&&!s&&ge(e.workerId,e.results)}function ge(t,e){var r=J[t];E(r.userComplete)&&r.userComplete(e),r.terminate(),delete J[t]}function _e(){throw new Error("Not implemented.")}function de(t){if(typeof t!="object"||t===null)return t;var e,r=Array.isArray(t)?[]:{};for(e in t)r[e]=de(t[e]);return r}function $(t,e){return function(){t.apply(e,arguments)}}function E(t){return typeof t=="function"}return o.parse=function(t,e){var r=(e=e||{}).dynamicTyping||!1;if(E(r)&&(e.dynamicTypingFunction=r,r={}),e.dynamicTyping=r,e.transform=!!E(e.transform)&&e.transform,e.downloadTimeout!==void 0){var r=parseInt(e.downloadTimeout);if(isNaN(r))throw new Error("Config downloadTimeout value ("+e.downloadTimeout+") not parsable by parseInt(val).");e.downloadTimeout=r}if(!e.worker||!o.WORKERS_SUPPORTED)return r=null,o.NODE_STREAM_INPUT,typeof t=="string"?(t=P(t),r=new(e.download?re:ie)(e)):t.readable===!0&&E(t.read)&&E(t.on)?r=new ue(e):(m.File&&t instanceof File||t instanceof Object)&&(r=new oe(e)),r.stream(t);(r=(()=>{var s;return!!o.WORKERS_SUPPORTED&&(s=(()=>{var i=m.URL||m.webkitURL||null,g=G.toString();return o.BLOB_URL||(o.BLOB_URL=i.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",g,")();"],{type:"text/javascript"})))})(),(s=new m.Worker(s)).onmessage=be,s.id=Y++,J[s.id]=s)})()).userStep=e.step,r.userChunk=e.chunk,r.userComplete=e.complete,r.userError=e.error,e.step=E(e.step),e.chunk=E(e.chunk),e.complete=E(e.complete),e.error=E(e.error),delete e.worker,r.postMessage({input:t,config:e,workerId:r.id})},o.unparse=function(t,e){var r=!1,s=!0,i=",",g=`\r
14
- `,I='"',U=I+I,V=!1,w=null,A=!1,u=((()=>{if(typeof e=="object"){if(typeof e.delimiter!="string"||o.BAD_DELIMITERS.filter(function(d){return e.delimiter.indexOf(d)!==-1}).length||(i=e.delimiter),typeof e.quotes!="boolean"&&typeof e.quotes!="function"&&!Array.isArray(e.quotes)||(r=e.quotes),typeof e.skipEmptyLines!="boolean"&&typeof e.skipEmptyLines!="string"||(V=e.skipEmptyLines),typeof e.newline=="string"&&(g=e.newline),typeof e.quoteChar=="string"&&(I=e.quoteChar,U=I+I),typeof e.header=="boolean"&&(s=e.header),Array.isArray(e.columns)){if(e.columns.length===0)throw new Error("Option columns is empty");w=e.columns}e.escapeChar!==void 0&&(U=e.escapeChar+I),e.escapeFormulae instanceof RegExp?A=e.escapeFormulae:typeof e.escapeFormulae=="boolean"&&e.escapeFormulae&&(A=/^[=+\-@\t\r].*$/)}})(),new RegExp(ne(I),"g"));if(typeof t=="string"&&(t=JSON.parse(t)),Array.isArray(t)){if(!t.length||Array.isArray(t[0]))return D(null,t,V);if(typeof t[0]=="object")return D(w||Object.keys(t[0]),t,V)}else if(typeof t=="object")return typeof t.data=="string"&&(t.data=JSON.parse(t.data)),Array.isArray(t.data)&&(t.fields||(t.fields=t.meta&&t.meta.fields||w),t.fields||(t.fields=Array.isArray(t.data[0])?t.fields:typeof t.data[0]=="object"?Object.keys(t.data[0]):[]),Array.isArray(t.data[0])||typeof t.data[0]=="object"||(t.data=[t.data])),D(t.fields||[],t.data||[],V);throw new Error("Unable to serialize unrecognized input");function D(d,n,F){var k="",x=(typeof d=="string"&&(d=JSON.parse(d)),typeof n=="string"&&(n=JSON.parse(n)),Array.isArray(d)&&0<d.length),M=!Array.isArray(n[0]);if(x&&s){for(var p=0;p<d.length;p++)0<p&&(k+=i),k+=l(d[p],p);0<n.length&&(k+=g)}for(var f=0;f<n.length;f++){var b=(x?d:n[f]).length,a=!1,R=x?Object.keys(n[f]).length===0:n[f].length===0;if(F&&!x&&(a=F==="greedy"?n[f].join("").trim()==="":n[f].length===1&&n[f][0].length===0),F==="greedy"&&x){for(var O=[],_=0;_<b;_++){var y=M?d[_]:_;O.push(n[f][y])}a=O.join("").trim()===""}if(!a){for(var c=0;c<b;c++){0<c&&!R&&(k+=i);var q=x&&M?d[c]:c;k+=l(n[f][q],c)}f<n.length-1&&(!F||0<b&&!R)&&(k+=g)}}return k}function l(d,n){var F,k,x;return d==null?"":d.constructor===Date?isNaN(d.getTime())?"":d.toISOString():(x=!1,A&&typeof d=="string"&&A.test(d)&&(d="'"+d,x=!0),k=(F=d.toString()).replace(u,U),(x=x||r===!0||typeof r=="function"&&r(d,n)||Array.isArray(r)&&r[n]||((M,p)=>{for(var f=0;f<p.length;f++)if(-1<M.indexOf(p[f]))return!0;return!1})(k,o.BAD_DELIMITERS)||-1<k.indexOf(i)||-1<F.indexOf(I)||k.charAt(0)===" "||k.charAt(k.length-1)===" ")?I+k+I:k)}},o.RECORD_SEP="",o.UNIT_SEP="",o.BYTE_ORDER_MARK="\uFEFF",o.BAD_DELIMITERS=["\r",`
15
- `,'"',o.BYTE_ORDER_MARK],o.WORKERS_SUPPORTED=!C&&!!m.Worker,o.NODE_STREAM_INPUT=1,o.LocalChunkSize=10485760,o.RemoteChunkSize=5242880,o.DefaultDelimiter=",",o.Parser=le,o.ParserHandle=pe,o.NetworkStreamer=re,o.FileStreamer=oe,o.StringStreamer=ie,o.ReadableStreamStreamer=ue,N&&(m.onmessage=function(t){t=t.data,o.WORKER_ID===void 0&&t&&(o.WORKER_ID=t.workerId),typeof t.input=="string"?m.postMessage({workerId:o.WORKER_ID,results:o.parse(t.input,t.config),finished:!0}):(m.File&&t.input instanceof File||t.input instanceof Object)&&(t=o.parse(t.input,t.config))&&m.postMessage({workerId:o.WORKER_ID,results:t,finished:!0})}),(re.prototype=Object.create(z.prototype)).constructor=re,(oe.prototype=Object.create(z.prototype)).constructor=oe,(ie.prototype=Object.create(ie.prototype)).constructor=ie,(ue.prototype=Object.create(z.prototype)).constructor=ue,o})})(he)),he.exports}var De=Ae();const Le=Ee(De),we=32;function Ze({content:H}){const X=xe(),G=Re(P=>P.selectedCwd),m=ve.useMemo(()=>Te(H.src,P=>X.mediaUrl(G??"",P)),[H.src,X,G]),{data:C,error:N,isLoading:J}=Se({queryKey:["canvas-csv",m.url],enabled:m.url!==null,queryFn:async()=>{const P=await fetch(m.url);if(!P.ok)throw new Error(`Failed to load CSV (${P.status})`);const z=await P.text();return Le.parse(z.trim(),{skipEmptyLines:!0}).data},staleTime:6e4,retry:!1});if(m.url===null)return j.jsx(ce,{children:"This CSV source can’t be displayed here."});if(J)return j.jsx(ce,{children:"Loading CSV…"});if(N||!C||C.length===0)return j.jsx(ce,{children:"This CSV couldn’t be loaded."});const[Y,...o]=C;return j.jsx(je,{header:Y,rows:o})}function je({header:H,rows:X}){const G=ve.useRef(null),m=Oe({count:X.length,getScrollElement:()=>G.current,estimateSize:()=>we,overscan:12});return j.jsx("div",{ref:G,className:"h-full overflow-auto",children:j.jsxs("table",{className:"w-full border-collapse text-sm",children:[j.jsx("thead",{className:"bg-muted sticky top-0 z-10",children:j.jsx("tr",{children:H.map((C,N)=>j.jsx("th",{className:"text-muted-foreground border-b px-3 py-1.5 text-left font-medium whitespace-nowrap",children:C},N))})}),j.jsx("tbody",{style:{height:m.getTotalSize(),position:"relative"},children:m.getVirtualItems().map(C=>{const N=X[C.index];return j.jsx("tr",{className:Ce("absolute flex w-full",C.index%2===1&&"bg-muted/30"),style:{transform:`translateY(${C.start}px)`,height:we},children:H.map((J,Y)=>j.jsx("td",{className:"flex-1 truncate border-b px-3 py-1.5 whitespace-nowrap",title:N[Y]??"",children:N[Y]??""},Y))},C.key)})})]})})}function ce({children:H}){return j.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:j.jsx("p",{children:H})})}export{Ze as CanvasCsvContent};
13
+ `);var u=0,D=!1;this.parse=function(l,d,n){if(typeof l!="string")throw new Error("Input must be a string");var F=l.length,k=e.length,x=r.length,M=s.length,p=E(i),f=[],b=[],a=[],R=u=0;if(!l)return T();if(I||I!==!1&&l.indexOf(w)===-1){for(var O=l.split(r),_=0;_<O.length;_++){if(a=O[_],u+=a.length,_!==O.length-1)u+=r.length;else if(n)return T();if(!s||a.substring(0,M)!==s){if(p){if(f=[],Z(a.split(e)),B(),D)return T()}else Z(a.split(e));if(g&&g<=_)return f=f.slice(0,g),T(!0)}}return T()}for(var y=l.indexOf(e,u),c=l.indexOf(r,u),q=new RegExp(ne(A)+ne(w),"g"),h=l.indexOf(w,u);;)if(l[u]===w)for(h=u,u++;;){if((h=l.indexOf(w,h+1))===-1)return n||b.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:f.length,index:u}),W();if(h===F-1)return W(l.substring(u,h).replace(q,w));if(w===A&&l[h+1]===A)h++;else if(w===A||h===0||l[h-1]!==A){y!==-1&&y<h+1&&(y=l.indexOf(e,h+1));var v=ee((c=c!==-1&&c<h+1?l.indexOf(r,h+1):c)===-1?y:Math.min(y,c));if(l.substr(h+1+v,k)===e){a.push(l.substring(u,h).replace(q,w)),l[u=h+1+v+k]!==w&&(h=l.indexOf(w,u)),y=l.indexOf(e,u),c=l.indexOf(r,u);break}if(v=ee(c),l.substring(h+1+v,h+1+v+x)===r){if(a.push(l.substring(u,h).replace(q,w)),se(h+1+v+x),y=l.indexOf(e,u),h=l.indexOf(w,u),p&&(B(),D))return T();if(g&&f.length>=g)return T(!0);break}b.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:f.length,index:u}),h++}}else if(s&&a.length===0&&l.substring(u,u+M)===s){if(c===-1)return T();u=c+x,c=l.indexOf(r,u),y=l.indexOf(e,u)}else if(y!==-1&&(y<c||c===-1))a.push(l.substring(u,y)),u=y+k,y=l.indexOf(e,u);else{if(c===-1)break;if(a.push(l.substring(u,c)),se(c+x),p&&(B(),D))return T();if(g&&f.length>=g)return T(!0)}return W();function Z(S){f.push(S),R=u}function ee(S){var L=0;return L=S!==-1&&(S=l.substring(h+1,S))&&S.trim()===""?S.length:L}function W(S){return n||(S===void 0&&(S=l.substring(u)),a.push(S),u=F,Z(a),p&&B()),T()}function se(S){u=S,Z(a),a=[],c=l.indexOf(r,u)}function T(S){if(t.header&&!d&&f.length&&!Q){var L=f[0],V=Object.create(null),fe=new Set(L);let me=!1;for(let te=0;te<L.length;te++){let K=P(L[te]);if(V[K=E(t.transformHeader)?t.transformHeader(K,te):K]){let ae,ye=V[K];for(;ae=K+"_"+ye,ye++,fe.has(ae););fe.add(ae),L[te]=ae,V[K]++,me=!0,(U=U===null?{}:U)[ae]=K}else V[K]=1,L[te]=K;fe.add(K)}me&&console.warn("Duplicate headers found and renamed."),Q=!0}return{data:f,errors:b,meta:{delimiter:e,linebreak:r,aborted:D,truncated:!!S,cursor:R+(d||0),renamedHeaders:U}}}function B(){i(T()),f=[],b=[]}},this.abort=function(){D=!0},this.getCharIndex=function(){return u}}function be(t){var e=t.data,r=J[e.workerId],s=!1;if(e.error)r.userError(e.error,e.file);else if(e.results&&e.results.data){var i={abort:function(){s=!0,ge(e.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:_e,resume:_e};if(E(r.userStep)){for(var g=0;g<e.results.data.length&&(r.userStep({data:e.results.data[g],errors:e.results.errors,meta:e.results.meta},i),!s);g++);delete e.results}else E(r.userChunk)&&(r.userChunk(e.results,i,e.file),delete e.results)}e.finished&&!s&&ge(e.workerId,e.results)}function ge(t,e){var r=J[t];E(r.userComplete)&&r.userComplete(e),r.terminate(),delete J[t]}function _e(){throw new Error("Not implemented.")}function de(t){if(typeof t!="object"||t===null)return t;var e,r=Array.isArray(t)?[]:{};for(e in t)r[e]=de(t[e]);return r}function $(t,e){return function(){t.apply(e,arguments)}}function E(t){return typeof t=="function"}return o.parse=function(t,e){var r=(e=e||{}).dynamicTyping||!1;if(E(r)&&(e.dynamicTypingFunction=r,r={}),e.dynamicTyping=r,e.transform=!!E(e.transform)&&e.transform,e.downloadTimeout!==void 0){var r=parseInt(e.downloadTimeout);if(isNaN(r))throw new Error("Config downloadTimeout value ("+e.downloadTimeout+") not parsable by parseInt(val).");e.downloadTimeout=r}if(!e.worker||!o.WORKERS_SUPPORTED)return r=null,o.NODE_STREAM_INPUT,typeof t=="string"?(t=P(t),r=new(e.download?re:ie)(e)):t.readable===!0&&E(t.read)&&E(t.on)?r=new ue(e):(m.File&&t instanceof File||t instanceof Object)&&(r=new oe(e)),r.stream(t);(r=(()=>{var s;return!!o.WORKERS_SUPPORTED&&(s=(()=>{var i=m.URL||m.webkitURL||null,g=G.toString();return o.BLOB_URL||(o.BLOB_URL=i.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",g,")();"],{type:"text/javascript"})))})(),(s=new m.Worker(s)).onmessage=be,s.id=Y++,J[s.id]=s)})()).userStep=e.step,r.userChunk=e.chunk,r.userComplete=e.complete,r.userError=e.error,e.step=E(e.step),e.chunk=E(e.chunk),e.complete=E(e.complete),e.error=E(e.error),delete e.worker,r.postMessage({input:t,config:e,workerId:r.id})},o.unparse=function(t,e){var r=!1,s=!0,i=",",g=`\r
14
+ `,I='"',U=I+I,Q=!1,w=null,A=!1,u=((()=>{if(typeof e=="object"){if(typeof e.delimiter!="string"||o.BAD_DELIMITERS.filter(function(d){return e.delimiter.indexOf(d)!==-1}).length||(i=e.delimiter),typeof e.quotes!="boolean"&&typeof e.quotes!="function"&&!Array.isArray(e.quotes)||(r=e.quotes),typeof e.skipEmptyLines!="boolean"&&typeof e.skipEmptyLines!="string"||(Q=e.skipEmptyLines),typeof e.newline=="string"&&(g=e.newline),typeof e.quoteChar=="string"&&(I=e.quoteChar,U=I+I),typeof e.header=="boolean"&&(s=e.header),Array.isArray(e.columns)){if(e.columns.length===0)throw new Error("Option columns is empty");w=e.columns}e.escapeChar!==void 0&&(U=e.escapeChar+I),e.escapeFormulae instanceof RegExp?A=e.escapeFormulae:typeof e.escapeFormulae=="boolean"&&e.escapeFormulae&&(A=/^[=+\-@\t\r].*$/)}})(),new RegExp(ne(I),"g"));if(typeof t=="string"&&(t=JSON.parse(t)),Array.isArray(t)){if(!t.length||Array.isArray(t[0]))return D(null,t,Q);if(typeof t[0]=="object")return D(w||Object.keys(t[0]),t,Q)}else if(typeof t=="object")return typeof t.data=="string"&&(t.data=JSON.parse(t.data)),Array.isArray(t.data)&&(t.fields||(t.fields=t.meta&&t.meta.fields||w),t.fields||(t.fields=Array.isArray(t.data[0])?t.fields:typeof t.data[0]=="object"?Object.keys(t.data[0]):[]),Array.isArray(t.data[0])||typeof t.data[0]=="object"||(t.data=[t.data])),D(t.fields||[],t.data||[],Q);throw new Error("Unable to serialize unrecognized input");function D(d,n,F){var k="",x=(typeof d=="string"&&(d=JSON.parse(d)),typeof n=="string"&&(n=JSON.parse(n)),Array.isArray(d)&&0<d.length),M=!Array.isArray(n[0]);if(x&&s){for(var p=0;p<d.length;p++)0<p&&(k+=i),k+=l(d[p],p);0<n.length&&(k+=g)}for(var f=0;f<n.length;f++){var b=(x?d:n[f]).length,a=!1,R=x?Object.keys(n[f]).length===0:n[f].length===0;if(F&&!x&&(a=F==="greedy"?n[f].join("").trim()==="":n[f].length===1&&n[f][0].length===0),F==="greedy"&&x){for(var O=[],_=0;_<b;_++){var y=M?d[_]:_;O.push(n[f][y])}a=O.join("").trim()===""}if(!a){for(var c=0;c<b;c++){0<c&&!R&&(k+=i);var q=x&&M?d[c]:c;k+=l(n[f][q],c)}f<n.length-1&&(!F||0<b&&!R)&&(k+=g)}}return k}function l(d,n){var F,k,x;return d==null?"":d.constructor===Date?isNaN(d.getTime())?"":d.toISOString():(x=!1,A&&typeof d=="string"&&A.test(d)&&(d="'"+d,x=!0),k=(F=d.toString()).replace(u,U),(x=x||r===!0||typeof r=="function"&&r(d,n)||Array.isArray(r)&&r[n]||((M,p)=>{for(var f=0;f<p.length;f++)if(-1<M.indexOf(p[f]))return!0;return!1})(k,o.BAD_DELIMITERS)||-1<k.indexOf(i)||-1<F.indexOf(I)||k.charAt(0)===" "||k.charAt(k.length-1)===" ")?I+k+I:k)}},o.RECORD_SEP="",o.UNIT_SEP="",o.BYTE_ORDER_MARK="\uFEFF",o.BAD_DELIMITERS=["\r",`
15
+ `,'"',o.BYTE_ORDER_MARK],o.WORKERS_SUPPORTED=!C&&!!m.Worker,o.NODE_STREAM_INPUT=1,o.LocalChunkSize=10485760,o.RemoteChunkSize=5242880,o.DefaultDelimiter=",",o.Parser=le,o.ParserHandle=pe,o.NetworkStreamer=re,o.FileStreamer=oe,o.StringStreamer=ie,o.ReadableStreamStreamer=ue,N&&(m.onmessage=function(t){t=t.data,o.WORKER_ID===void 0&&t&&(o.WORKER_ID=t.workerId),typeof t.input=="string"?m.postMessage({workerId:o.WORKER_ID,results:o.parse(t.input,t.config),finished:!0}):(m.File&&t.input instanceof File||t.input instanceof Object)&&(t=o.parse(t.input,t.config))&&m.postMessage({workerId:o.WORKER_ID,results:t,finished:!0})}),(re.prototype=Object.create(z.prototype)).constructor=re,(oe.prototype=Object.create(z.prototype)).constructor=oe,(ie.prototype=Object.create(ie.prototype)).constructor=ie,(ue.prototype=Object.create(z.prototype)).constructor=ue,o})})(he)),he.exports}var De=Ae();const Le=Ee(De),we=32;function et({content:H}){const X=xe(),G=Re(P=>P.selectedCwd),m=ve.useMemo(()=>Te(H.src,P=>X.mediaUrl(G??"",P)),[H.src,X,G]),{data:C,error:N,isLoading:J}=Se({queryKey:["canvas-csv",m.url],enabled:m.url!==null,queryFn:async()=>{const P=await fetch(m.url);if(!P.ok)throw new Error(`Failed to load CSV (${P.status})`);const z=await P.text();return Le.parse(z.trim(),{skipEmptyLines:!0}).data},staleTime:6e4,retry:!1});if(m.url===null)return j.jsx(ce,{children:"This CSV source can’t be displayed here."});if(J)return j.jsx(ce,{children:"Loading CSV…"});if(N||!C||C.length===0)return j.jsx(ce,{children:"This CSV couldn’t be loaded."});const[Y,...o]=C;return j.jsx(je,{header:Y,rows:o})}function je({header:H,rows:X}){const G=ve.useRef(null),m=Oe({count:X.length,getScrollElement:()=>G.current,estimateSize:()=>we,overscan:12});return j.jsx("div",{ref:G,className:"h-full overflow-auto",children:j.jsxs("table",{className:"w-full border-collapse text-sm",children:[j.jsx("thead",{className:"bg-muted sticky top-0 z-10",children:j.jsx("tr",{children:H.map((C,N)=>j.jsx("th",{className:"text-muted-foreground border-b px-3 py-1.5 text-left font-medium whitespace-nowrap",children:C},N))})}),j.jsx("tbody",{style:{height:m.getTotalSize(),position:"relative"},children:m.getVirtualItems().map(C=>{const N=X[C.index];return j.jsx("tr",{className:Ce("absolute flex w-full",C.index%2===1&&"bg-muted/30"),style:{transform:`translateY(${C.start}px)`,height:we},children:H.map((J,Y)=>j.jsx("td",{className:"flex-1 truncate border-b px-3 py-1.5 whitespace-nowrap",title:N[Y]??"",children:N[Y]??""},Y))},C.key)})})]})})}function ce({children:H}){return j.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:j.jsx("p",{children:H})})}export{et as CanvasCsvContent};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeMirrorEditor-rYOrBAZc.js","assets/index-Dc5cpBoO.js","assets/index-CrflCTqO.css","assets/index-CBm3whA-.js","assets/index-BUOcbPfv.js","assets/BlintzCanvas-ClOKWzws.js","assets/BlintzCanvas-GgiCXV7C.css"])))=>i.map(i=>d[i]);
2
+ import{r as n,aW as z,gB as re,j as t,B as S,a3 as ne,G as se,J as ae,go as ie,gC as ce,aX as $,a1 as ue,gD as oe,a2 as le}from"./index-Dc5cpBoO.js";import{u as de,a as fe}from"./use-session-canvas-CJrfZrYG.js";import{R as he}from"./rotate-cw-C68kM23F.js";import"./index.esm-DXsF3Bua.js";import"./WidgetErrorCard-CzWw_SPD.js";import"./index-Ch-ON5gw.js";import"./card-Bt6IU-Bh.js";import"./progress-CErAw8zp.js";import"./markdown-content-DPc7aD1j.js";import"./table-BL3xUC41.js";import"./terminal-u_UCRzSM.js";import"./package-BSwwAFVm.js";import"./heart-Du7nuefC.js";import"./git-branch-BObm8Rlz.js";import"./file-text-BAhi2zct.js";import"./file-VHDTQub2.js";import"./McpAppFrame-CuObpQTg.js";import"./more-details-DEeu2M-p.js";function B(e,i){return["canvas-file",e,i]}function ve({documentId:e,sourcePath:i,binding:j,save:o,draftRef:x,revisionRef:r,finishAttemptRef:C,timerRef:g,finalSaveRef:b,invalidateConfirmedFile:d}){const m=n.useRef({binding:j,save:o,invalidateConfirmedFile:d}),F=n.useRef(null),l=n.useRef(null);return n.useLayoutEffect(()=>{m.current={binding:j,save:o,invalidateConfirmedFile:d}}),n.useLayoutEffect(()=>{const k=z.getState().openDocuments.find(f=>f.id===e);if(!k||typeof k.openedAt!="number")return;const w=re(e,k.openedAt,i,{required:()=>!!m.current.binding,current:()=>{const f=l.current;return!!f&&f.revision===r.current&&f.attempt===C.current&&f.binding===m.current.binding&&f.save===m.current.save&&f.binding.current()},invalidateConfirmedFile:()=>m.current.invalidateConfirmedFile(),prepare:async()=>{var a;l.current=null;const{binding:f,save:_}=m.current;if(!(f!=null&&f.current()))return!1;g.current&&(clearTimeout(g.current),g.current=null);const N=x.current,y=r.current,u=++C.current,s=await _(N);return s.status!=="changed"&&s.status!=="no_op"||s.confirmed.content!==N||r.current!==y||C.current!==u||m.current.binding!==f||m.current.save!==_||!f.current()?!1:((a=b.current)==null||a.cancel(),b.current=null,l.current={revision:y,attempt:u,binding:f,save:_},!0)}});return F.current=w,()=>w.retire()},[e,i,x,r,C,g,b]),F}function pe(e,i,j){var u;const o=n.useRef(e),x=n.useRef(null),r=n.useRef(null),[C,g]=n.useState({identity:e.identity,phase:"pending",busy:!1});n.useLayoutEffect(()=>{o.current=e},[e]);const b=n.useCallback((s,a)=>{x.current===s&&o.current.identity===s&&o.current.current()&&g(h=>({identity:s,...a,historical:a.historical??(h.identity===s?h.historical:void 0)}))},[]),d=n.useCallback(s=>{x.current!==s||o.current.identity!==s||g(a=>a.identity===s?{...a,phase:"unavailable",busy:!1}:{identity:s,phase:"unavailable",busy:!1})},[]),m=e.identity,F=e.supported;n.useLayoutEffect(()=>{const s=o.current;r.current=null,x.current=m;let a=!1;return F&&i==="ready"&&s.discover().then(h=>{a||(h.status==="observed"?b(m,{phase:"ready",discovery:h.value,busy:!1}):h.status!=="idle"?b(m,{phase:"unavailable",busy:!1}):d(m))}),()=>{a=!0,r.current=null,x.current===m&&(x.current=null)}},[m,F,i,j,b,d]);const l=C.identity===e.identity?C:void 0,k=n.useCallback(async()=>{const s=o.current,a=s.identity;if(x.current!==a||!s.current())return;r.current=null,g(c=>({identity:a,phase:"pending",busy:!0,historical:c.identity===a?c.historical:void 0}));const h=await s.discover(!0);h.status==="observed"?b(a,{phase:"ready",discovery:h.value,busy:!1}):h.status!=="idle"?b(a,{phase:"unavailable",busy:!1}):d(a)},[b,d]),w=n.useCallback(async s=>{const a=o.current,h=a.identity;if(x.current!==h||!a.current())return;r.current=null,g(p=>({identity:h,phase:"pending",busy:!0,discovery:p.identity===h?p.discovery:void 0,historical:p.identity===h?p.historical:void 0}));const c=await a.recover(s);c.status==="observed"?b(h,{phase:"ready",discovery:c.value.discovery,historical:c.value.result.entry,busy:!1}):c.status!=="idle"?b(h,{phase:c.status==="local_uncertain"?"local_uncertain":"unavailable",busy:!1}):d(h)},[b,d]),f=n.useCallback(async()=>{const s=o.current,a=s.identity;if(x.current!==a||!s.current())return{status:"idle"};const h={};r.current=h,g(p=>p.identity===a?{...p,phase:"pending",busy:!0}:p);const c=await s.inspectCurrent();return r.current!==h?{status:"idle"}:(r.current=null,c.status==="idle"&&d(a),x.current===a&&o.current.identity===a&&s.current()&&c.status!=="idle"&&g(p=>p.identity===a?{...p,phase:c.status==="observed"?"ready":c.status==="local_uncertain"?"local_uncertain":"unavailable",busy:!1}:p),c)},[d]),_=e.supported&&i==="ready",N=i==="pending"?"pending":(l==null?void 0:l.phase)??"pending",y=_&&(N!=="ready"||((u=l==null?void 0:l.discovery)==null?void 0:u.admission)==="blocked");return{supported:_,phase:N,editBlocked:y,busy:(l==null?void 0:l.busy)??N==="pending",discovery:l==null?void 0:l.discovery,historical:l==null?void 0:l.historical,refresh:k,recover:w,inspectCurrent:f}}function me({recovery:e,editing:i,loadCurrent:j}){var o,x;return e.supported?t.jsxs("section",{"aria-label":"Previous file saves",className:"mx-2 mt-2 rounded border p-2 text-sm",children:[e.phase==="pending"&&t.jsx("p",{role:"status",children:"Checking previous saves…"}),e.phase==="unavailable"&&t.jsx("p",{role:"alert",children:"Previous save evidence is unavailable. New saves stay blocked until it can be checked."}),e.phase==="local_uncertain"&&t.jsx("p",{role:"alert",children:"Use Retry original save. Checking previous saves won’t confirm this save."}),((o=e.discovery)==null?void 0:o.admission)==="blocked"&&t.jsx("p",{role:"alert",children:"An unresolved original save blocks this file. This list may not include the blocking operation."}),e.discovery&&t.jsxs(t.Fragment,{children:[!e.discovery.entries.length&&t.jsx("p",{children:"No matching recent saves."}),e.discovery.hasMore&&t.jsx("p",{children:"Only the latest 25 matching saves are shown. Older evidence is omitted."}),t.jsx("ul",{children:e.discovery.entries.map(r=>t.jsxs("li",{children:[t.jsxs("span",{children:[r.eventId,":"," ",r.state==="receipt"?"Historical save recorded":r.state==="review"?"Original save needs review":r.state==="no_op"?"Original save made no change":"Original save failed before replacement"]}),r.state==="review"&&(r.reason==="prepared_without_replacement"?t.jsx("p",{children:"This save needs manual review. These controls won’t write the file."}):t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"The original saved replacement must be proven before its receipt can be settled."}),t.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:e.busy||i,onClick:()=>void e.recover(r.eventId),children:"Recover original receipt"})]}))]},r.eventId))})]}),((x=e.historical)==null?void 0:x.state)==="receipt"&&t.jsxs("div",{role:"status",children:[t.jsx("p",{children:"Previous save confirmed. Your current draft may differ."}),t.jsx("p",{children:e.historical.currentFileMatch==="different"?"The current file differs from that historical save.":e.historical.currentFileMatch==="same_saved_replacement"?"The saved replacement matched when checked; current bytes still require a fresh load.":"The current file was not checked."})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:e.busy||i,onClick:()=>void e.refresh(),children:"Check previous saves"}),t.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:i||e.editBlocked||e.busy,onClick:j,children:"Load current file"})]}),t.jsx("p",{children:"These controls don’t resend drafts or confirm agent delivery. Use Load current file."})]}):null}const ye=n.lazy(()=>$(()=>import("./CodeMirrorEditor-rYOrBAZc.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.CodeMirrorEditor}))),xe=n.lazy(()=>$(()=>import("./BlintzCanvas-ClOKWzws.js"),__vite__mapDeps([5,1,2,4,6])).then(e=>({default:e.BlintzCanvas}))),be=500;function ge(e,i){return i==="markdown"||/\.(md|markdown|mdx)$/i.test(e)}function je(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn’t save";case"uncertain":return"Save not confirmed";default:return null}}function G({content:e,documentId:i,cwd:j,loaded:o,theme:x,isEditing:r,onEditingChange:C,setDocumentEditing:g,observedBinding:b,fileSaveObservation:d="unavailable",recoveryBinding:m}){const F=e.readOnly!==!0,l=ge(e.sourcePath,e.language),k=ne(),[w,f]=n.useState(o),[_,N]=n.useState(),y=n.useRef(b);n.useLayoutEffect(()=>{y.current=b},[b]);const u=de({documentId:i,sourcePath:e.sourcePath,cwd:j,loadedContent:o,documentSaveBinding:_,documentRecoveryBinding:m}),s=pe(u.recovery,d,m),a=n.useRef(!1),h=n.useRef(r);n.useLayoutEffect(()=>(a.current=!0,h.current=r,()=>{a.current=!1}),[r]);const c=n.useRef(null),p=n.useRef(w),L=n.useRef(0),O=n.useRef(0),E=n.useRef(u.save),I=n.useRef(u.prepareFinalSave),Q=n.useRef(u.waitForCloseDrain),D=n.useRef(null),U=n.useRef(C),H=ve({documentId:i,sourcePath:e.sourcePath,binding:_,save:u.save,draftRef:p,revisionRef:L,finishAttemptRef:O,timerRef:c,finalSaveRef:D,invalidateConfirmedFile:()=>{k.invalidateQueries({queryKey:B(j,e.sourcePath)}).catch(()=>{})}});n.useEffect(()=>{p.current=w,E.current=u.save,I.current=u.prepareFinalSave,Q.current=u.waitForCloseDrain,U.current=C});const K=n.useCallback(v=>{var R;L.current+=1,p.current=v,f(v),(R=D.current)==null||R.cancel(),D.current=I.current(v),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,E.current(p.current)},be)},[]),J=()=>{var P;if(s.editBlocked||d==="pending"||d==="ready"&&!((P=y.current)!=null&&P.current()))return;const v=y.current,R=v&&Object.freeze({...v.incarnation});N(v!=null&&v.current()&&R?{incarnation:R,current:()=>{const T=y.current;return!!T&&ce(R,T.incarnation)&&T.current()}}:void 0),L.current+=1,p.current=o,f(o),C(!0),g(i,!0)},W=async()=>{c.current&&(clearTimeout(c.current),c.current=null);const v=p.current,R=L.current,P=++O.current,T=await E.current(v);if(T.status!=="changed"&&T.status!=="no_op"||L.current!==R||O.current!==P||T.confirmed.content!==v)return;const A=T.confirmed;A.content===p.current&&k.setQueryData(B(j,e.sourcePath),M=>M&&{...M,content:A.content,hash:A.hash}),C(!1),g(i,!1)},X=()=>{k.invalidateQueries({queryKey:B(j,e.sourcePath)})};n.useEffect(()=>{var v;r||(c.current&&clearTimeout(c.current),c.current=null,(v=D.current)==null||v.cancel(),D.current=null)},[r]),n.useEffect(()=>{const v=H.current;return()=>{var T;c.current&&(clearTimeout(c.current),c.current=null);const R=(T=D.current)==null?void 0:T.flush(),P=p.current;v==null||v.settleRetirement(Promise.resolve(R).then(()=>Q.current(P))),D.current=null,g(i,!1),U.current(!1)}},[i,g,H]);const Z=async()=>{if(r||!a.current||s.editBlocked)return;const v=L.current,R=await s.inspectCurrent();R.status!=="observed"||!a.current||h.current||L.current!==v||!u.recovery.current()||k.setQueryData(B(j,e.sourcePath),P=>P&&{...P,...R.value})},ee=()=>{const v=u.adoptDisk();v!=null&&f(v)},te=()=>{u.overwrite(p.current)},V=u.status==="saved"?u.confirmedContent!==w?"Unsaved changes":u.documentReceipt?"Save recorded":"Saved to file":je(u.status),Y=r?w:o;return t.jsxs("div",{className:"relative flex h-full flex-col",children:[t.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[F&&V&&t.jsx("span",{className:se("mt-3 text-xs",u.status==="error"?"text-destructive":"text-muted-foreground"),"aria-live":"polite",children:V}),!r&&d==="pending"&&t.jsx("span",{role:"status",children:"Checking document…"}),!r&&t.jsx(S,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:X,"aria-label":"Refresh from disk",children:t.jsx(he,{className:"size-4"})}),F&&t.jsx(S,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:r?()=>void W():J,"aria-label":r?"Finish editing":"Edit file",disabled:!r&&(d==="pending"||s.editBlocked),"data-document-save-observation":d,children:r?t.jsx(ae,{className:"size-4"}):t.jsx(ie,{className:"size-4"})})]}),t.jsx(me,{recovery:s,editing:r,loadCurrent:()=>void Z()}),u.status==="uncertain"&&t.jsxs("div",{role:"status",className:"mx-2 mt-2 flex items-center gap-2 text-sm",children:[t.jsx("span",{children:"Save not confirmed. Retry the original save before saving another draft."}),t.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:()=>void u.retryUnconfirmed(),children:"Retry original save"})]}),u.status==="conflict"&&t.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[t.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),t.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:ee,children:"Reload"}),t.jsx(S,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:te,children:"Overwrite"})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(n.Suspense,{fallback:t.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:l?t.jsx("div",{className:"px-2 pb-6",children:t.jsx(xe,{value:Y,editable:r,onChange:r?K:void 0})}):t.jsx(ye,{value:Y,editable:r,filename:e.sourcePath,languageHint:e.language,theme:x,onChange:r?K:void 0})})})]})}function Ce(e){const{fileSaveBinding:i,fileSaveObservation:j}=fe(e.documentId);return t.jsx(G,{...e,observedBinding:i,recoveryBinding:i,fileSaveObservation:j})}function Re(e){switch(e==null?void 0:e.code){case"NOT_FOUND":return"This file doesn’t exist.";case"NOT_A_FILE":return"This path is a directory, not a file.";case"TOO_LARGE":return"This file is too large to open here.";case"BINARY_FILE":return"This file isn’t text, so the editor can’t show it.";default:return"This file couldn’t be loaded."}}function Qe({content:e,documentId:i}){const j=ue(),o=z(y=>y.selectedCwd),x=z(y=>y.setDocumentEditing),r=z(y=>{var u;return((u=y.openDocuments.find(s=>s.id===i))==null?void 0:u.editing)??!1}),C=oe(),g=z(y=>y.canvasSessionId),b=z(y=>y.roomCanvasLiveRoomId),{data:d,error:m,isLoading:F}=le({queryKey:B(o,e.sourcePath),enabled:o!==null,queryFn:()=>j.readFileContent(o,e.sourcePath),staleTime:3e4,retry:!1}),[l,k]=n.useState(null),w=y=>{k(y&&d?{pinnedHash:d.hash}:null)};if(o===null)return t.jsx(q,{children:"Open a chat to view files."});if(F)return t.jsx(q,{children:"Loading file…"});if(m||!d)return t.jsx(q,{children:Re(m)});const f=l!==null&&r,_=(f?l==null?void 0:l.pinnedHash:null)??d.hash,N=g&&!b?Ce:G;return t.jsx(N,{content:e,documentId:i,cwd:o,loaded:d.content,theme:C,isEditing:f,onEditingChange:w,setDocumentEditing:x},`${e.sourcePath}:${_}`)}function q({children:e}){return t.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:t.jsx("p",{children:e})})}export{Qe as CanvasFileContent};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Model3dViewer-DRVqxazk.js","assets/index-Dc5cpBoO.js","assets/index-CrflCTqO.css"])))=>i.map(i=>d[i]);
2
+ import{a1 as m,aW as n,r as s,j as t,aX as p}from"./index-Dc5cpBoO.js";import{r as u}from"./use-session-canvas-CJrfZrYG.js";import"./rotate-cw-C68kM23F.js";import"./index.esm-DXsF3Bua.js";import"./WidgetErrorCard-CzWw_SPD.js";import"./index-Ch-ON5gw.js";import"./card-Bt6IU-Bh.js";import"./progress-CErAw8zp.js";import"./markdown-content-DPc7aD1j.js";import"./table-BL3xUC41.js";import"./terminal-u_UCRzSM.js";import"./package-BSwwAFVm.js";import"./heart-Du7nuefC.js";import"./git-branch-BObm8Rlz.js";import"./file-text-BAhi2zct.js";import"./file-VHDTQub2.js";import"./McpAppFrame-CuObpQTg.js";import"./more-details-DEeu2M-p.js";const d=s.lazy(()=>p(()=>import("./Model3dViewer-DRVqxazk.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.Model3dViewer})));function f(e){var o;const r=(o=e.split(".").pop())==null?void 0:o.toLowerCase();return r==="glb"||r==="gltf"?"gltf":r==="stl"?"stl":r==="obj"?"obj":r==="3mf"?"3mf":r==="ply"?"ply":r==="fbx"?"fbx":r==="dae"?"dae":null}function A({content:e}){const r=m(),o=n(i=>i.selectedCwd),l=s.useMemo(()=>u(e.src,i=>r.mediaUrl(o??"",i)),[e.src,r,o]),a=s.useMemo(()=>f(e.src),[e.src]);return l.url===null||a===null?t.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:t.jsx("p",{children:"This 3D model can’t be displayed here."})}):t.jsx("div",{className:"bg-muted/40 h-full w-full",children:t.jsx(s.Suspense,{fallback:t.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading 3D viewer…"}),children:t.jsx(d,{url:l.url,format:a,label:e.title??"Canvas 3D model"})})})}export{A as CanvasModel3dContent,f as formatOf};
@@ -1,4 +1,4 @@
1
- import{W as m,a1 as x,aV as k,r as v,j as t,B as d,G as p,a7 as y}from"./index-C8-dwIPp.js";import{u as R}from"./use-update-config-Bad4g6mB.js";import{I as S}from"./inline-code-Beal0546.js";/**
1
+ import{W as m,a1 as x,aW as k,r as v,j as t,B as d,G as p,a7 as y}from"./index-Dc5cpBoO.js";import{u as R}from"./use-update-config-DhlbZldm.js";import{I as S}from"./inline-code-DAEoWvTf.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,3 +1,3 @@
1
- import{j as J,r as T}from"./index-C8-dwIPp.js";import{R as lt}from"./index-CQrM6oF9.js";import{o as Q,E as B,q as ne,C as Ge,S as G,r as Ne,u as Fe,v as st,w as H,x as M,V as ot,F as Ve,y as je,R as N,W as Y,G as oe,z as at,A as ft,B as Ie,H as dt,m as ht,n as ct}from"./index-gbNK9zj5.js";class v{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new v(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function y(t,e,n,l,i,r){if(t==l)return[];let s=fe(t,e,n,l,i,r),o=de(t,e+s,n,l,i+s,r);e+=s,n-=o,i+=s,r-=o;let f=n-e,h=r-i;if(!f||!h)return[new v(e,n,i,r)];if(f>h){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new v(e,e+d,i,i),new v(e+d+h,n,r,r)]}else if(h>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new v(e,e,i,i+d),new v(n,n,i+d+f,r)]}if(f==1||h==1)return[new v(e,n,i,r)];let a=He(t,e,n,l,i,r);if(a){let[d,c,u]=a;return y(t,e,d,l,i,c).concat(y(t,d+u,n,l,c+u,r))}return ut(t,e,n,l,i,r)}let I=1e9,U=0,ae=!1;function ut(t,e,n,l,i,r){let s=n-e,o=r-i;if(I<1e9&&Math.min(s,o)>I*16||U>0&&Date.now()>U)return Math.min(s,o)>I*64?[new v(e,n,i,r)]:ge(t,e,n,l,i,r);let f=Math.ceil((s+o)/2);ee.reset(f),te.reset(f);let h=(u,m)=>t.charCodeAt(e+u)==l.charCodeAt(i+m),a=(u,m)=>t.charCodeAt(n-u-1)==l.charCodeAt(r-m-1),d=(s-o)%2!=0?te:null,c=d?null:ee;for(let u=0;u<f;u++){if(u>I||U>0&&!(u&63)&&Date.now()>U)return ge(t,e,n,l,i,r);let m=ee.advance(u,s,o,f,d,!1,h)||te.advance(u,s,o,f,c,!0,a);if(m)return mt(t,e,n,e+m[0],l,i,r,i+m[1])}return[new v(e,n,i,r)]}class Ue{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,s,o){for(let f=-e+this.start;f<=e-this.end;f+=2){let h=i+f,a=f==-e||f!=e&&this.vec[h-1]<this.vec[h+1]?this.vec[h+1]:this.vec[h-1]+1,d=a-f;for(;a<n&&d<l&&o(a,d);)a++,d++;if(this.vec[h]=a,a>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let c=i+(n-l)-f;if(c>=0&&c<this.len&&r.vec[c]!=-1)if(s){let u=r.vec[c];if(u>=n-a)return[u,i+u-c]}else{let u=n-r.vec[c];if(a>=u)return[a,d]}}}return null}}const ee=new Ue,te=new Ue;function mt(t,e,n,l,i,r,s,o){let f=!1;return!F(t,l)&&++l==n&&(f=!0),!F(i,o)&&++o==s&&(f=!0),f?[new v(e,n,r,s)]:y(t,e,l,i,r,o).concat(y(t,l,n,i,o,s))}function We(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function fe(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let s=We(n-e,r-i);for(let o=e,f=i;;){let h=o+s,a=f+s;if(h>n||a>r||t.slice(o,h)!=l.slice(f,a)){if(s==1)return o-e-(F(t,o)?0:1);s=s>>1}else{if(h==n||a==r)return h-e;o=h,f=a}}}function de(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let s=We(n-e,r-i);for(let o=n,f=r;;){let h=o-s,a=f-s;if(h<e||a<i||t.slice(h,o)!=l.slice(a,f)){if(s==1)return n-o-(F(t,o)?0:1);s=s>>1}else{if(h==e||a==i)return n-h;o=h,f=a}}}function re(t,e,n,l,i,r,s,o){let f=l.slice(i,r),h=null;for(;;){if(h||s<o)return h;for(let a=e+s;;){F(t,a)||a++;let d=a+s;if(F(t,d)||(d+=d==a+1?1:-1),d>=n)break;let c=t.slice(a,d),u=-1;for(;(u=f.indexOf(c,u+1))!=-1;){let m=fe(t,d,n,l,i+u+c.length,r),p=de(t,e,a,l,i,i+u),g=c.length+m+p;(!h||h[2]<g)&&(h=[a-p,i+u-p,g])}a=d}if(o<0)return h;s=s>>1}}function He(t,e,n,l,i,r){let s=n-e,o=r-i;if(s<o){let f=He(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return s<4||o*2<s?null:re(t,e,n,l,i,r,Math.floor(s/4),-1)}function ge(t,e,n,l,i,r){ae=!0;let s=n-e,o=r-i,f;if(s<o){let c=re(l,i,r,t,e,n,Math.floor(s/6),50);f=c&&[c[1],c[0],c[2]]}else f=re(t,e,n,l,i,r,Math.floor(o/6),50);if(!f)return[new v(e,n,i,r)];let[h,a,d]=f;return y(t,e,h,l,i,a).concat(y(t,h+d,n,l,a+d,r))}function ze(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new v(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function gt(t,e,n){for(;;){ze(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],s,o;(s=fe(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new v(r.fromA+s,r.toA,r.fromB+s,r.toB)),(o=de(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new v(r.fromA,r.toA-o,r.fromB,r.toB-o));let f=r.toA-r.fromA,h=r.toB-r.fromB;if(f&&h)continue;let a=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!a||!d)continue;let c=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);a<=c.length&&t.slice(r.fromA-a,r.fromA)==c.slice(c.length-a)?(n[i]=new v(r.fromA-a,r.toA-a,r.fromB-a,r.toB-a),l=!0):d<=c.length&&t.slice(r.toA,r.toA+d)==c.slice(0,d)&&(n[i]=new v(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function pt(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],s=r.toA-r.fromA,o=r.toB-r.fromB;if(s&&o||s>3||o>3){let f=i==t.length-1?e.length:t[i+1].fromA,h=r.fromA-l,a=f-r.toA,d=Ce(e,r.fromA,h),c=pe(e,r.toA,a),u=r.fromA-d,m=c-r.toA;if((!s||!o)&&u&&m){let p=Math.max(s,o),[g,C,S]=s?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>u&&e.slice(d,r.fromA)==g.slice(S-u,S)?(r=t[i]=new v(d,d+s,r.fromB-u,r.toB-u),d=r.fromA,c=pe(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,c)==g.slice(C,C+m)&&(r=t[i]=new v(c-s,c,r.fromB+m,r.toB+m),c=r.toA,d=Ce(e,r.fromA,r.fromA-l)),u=r.fromA-d,m=c-r.toA}if(u||m)r=t[i]=new v(r.fromA-u,r.toA+m,r.fromB-u,r.toB+m);else if(s){if(!o){let p=Ae(e,r.fromA,r.toA),g,C=p<0?-1:ve(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=a&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):C>-1&&(g=r.toA-C)<=h&&e.slice(r.fromA-g,r.fromA)==e.slice(C,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=Ae(n,r.fromB,r.toB),g,C=p<0?-1:ve(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=a&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):C>-1&&(g=r.toB-C)<=h&&n.slice(r.fromB-g,r.fromB)==n.slice(C,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return ze(t,3),t}let E;try{E=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Pe(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function qe(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Pe(n)?1:0:E?!Je(n)||e==t.length-1?E.test(String.fromCharCode(n))?1:0:E.test(t.slice(e,e+2))?2:0:0}function _e(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Pe(n)?1:0:E?!Ke(n)||e==1?E.test(String.fromCharCode(n))?1:0:E.test(t.slice(e-2,e))?2:0:0}const $e=8;function pe(t,e,n){if(e==t.length||!_e(t,e))return e;for(let l=e,i=e+n,r=0;r<$e;r++){let s=qe(t,l);if(!s||l+s>i)return l;l+=s}return e}function Ce(t,e,n){if(!e||!qe(t,e))return e;for(let l=e,i=e-n,r=0;r<$e;r++){let s=_e(t,l);if(!s||l-s<i)return l;l-=s}return e}function ve(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function Ae(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Je=t=>t>=55296&&t<=56319,Ke=t=>t>=56320&&t<=57343;function F(t,e){return!e||e==t.length||!Je(t.charCodeAt(e-1))||!Ke(t.charCodeAt(e))}function Ct(t,e,n){var l;let i=n==null?void 0:n.override;return i?i(t,e):(I=((l=n==null?void 0:n.scanLimit)!==null&&l!==void 0?l:1e9)>>1,U=n!=null&&n.timeout?Date.now()+n.timeout:0,ae=!1,gt(t,e,y(t,0,t.length,e,0,e.length)))}function Qe(){return!ae}function Ye(t,e,n){return pt(Ct(t,e,n),t,e)}const b=Ve.define({combine:t=>t[0]}),ie=G.define(),Ze=Ve.define(),k=H.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ie)&&(t=n.value);for(let n of e.state.facet(Ze))t=n(t,e);return t}});function vt(t){let e=t.field(k,!1);if(!e)return null;let n=t.facet(b);return{chunks:e,side:n?n.side:null}}class O{constructor(e,n,l,i,r,s=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=s}offset(e,n){return e||n?new O(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Ye(e.toString(),n.toString(),l);return Xe(i,e,n,0,0,Qe())}static updateA(e,n,l,i,r){return be(Be(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return be(Be(e,i,!1,n.length),e,n,l,r)}}function xe(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function we(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function Xe(t,e,n,l,i,r){let s=[];for(let o=0;o<t.length;o++){let f=t[o],[h,a]=xe(f.fromA+l,f.fromB+i,e,n),[d,c]=we(f.toA+l,f.toB+i,e,n),u=[f.offset(-h+l,-a+i)];for(;o<t.length-1;){let m=t[o+1],[p,g]=xe(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>c+1)break;u.push(m.offset(-h+l,-a+i)),[d,c]=we(m.toA+l,m.toB+i,e,n),o++}s.push(new O(u,h,Math.max(h,d),a,Math.max(a,c),r))}return s}const z=1e3;function ke(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let a=0,d=0;i&&({toA:a,toB:d}=t[i-1]);let c=e-(n?a:d);return[a+c,d+c]}let s=i+r>>1,o=t[s],[f,h]=n?[o.fromA,o.toA]:[o.fromB,o.toB];if(f>e)r=s;else if(h<=e)i=s+1;else return l?[o.fromA,o.fromB]:[o.toA,o.toB]}}function Be(t,e,n,l){let i=[];return e.iterChangedRanges((r,s,o,f)=>{let h=0,a=n?e.length:l,d=0,c=n?l:e.length;r>z&&([h,d]=ke(t,r-z,n,!0)),s<e.length-z&&([a,c]=ke(t,s+z,n,!1));let u=f-o-(s-r),m,[p,g]=n?[u,0]:[0,u];i.length&&(m=i[i.length-1]).toA>=h?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:a,toB:c,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:h,toA:a,fromB:d,toB:c,diffA:p,diffB:g})}),i}function be(t,e,n,l,i){if(!t.length)return e;let r=[];for(let s=0,o=0,f=0,h=0;;s++){let a=s==t.length?null:t[s],d=a?a.fromA+o:n.length,c=a?a.fromB+f:l.length;for(;h<e.length;){let g=e[h];if(a&&(g.toA+o>d||g.toB+f>c))break;r.push(g.offset(o,f)),h++}if(!a)break;let u=a.toA+o+a.diffA,m=a.toB+f+a.diffB,p=Ye(n.sliceString(d,u),l.sliceString(c,m),i);for(let g of Xe(p,n,l,d,c,Qe()))r.push(g);for(o+=a.diffA,f+=a.diffB;h<e.length;){let g=e[h];if(g.fromA+o>u&&g.fromB+f>m)break;h++}}return r}const et={scanLimit:500},Z=ot.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Le(t))}update(t){(t.docChanged||t.viewportChanged||At(t.startState,t.state)||xt(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Le(t.view))}},{decorations:t=>t.deco}),P=Q.low(je({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(Z))===null||e===void 0?void 0:e.gutter)||Ie.empty}}));function At(t,e){return t.field(k,!1)!=e.field(k,!1)}function xt(t,e){return t.facet(b)!=e.facet(b)}const Me=M.line({class:"cm-changedLine"}),tt=M.mark({class:"cm-changedText"}),wt=M.mark({tagName:"ins",class:"cm-insertedLine"}),kt=M.mark({tagName:"del",class:"cm-deletedLine"}),De=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Bt(t,e,n,l,i,r){let s=n?t.fromA:t.fromB,o=n?t.toA:t.toB,f=0;if(s!=o){i.add(s,s,Me),i.add(s,o,n?kt:wt),r&&r.add(s,s,De);for(let h=e.iterRange(s,o-1),a=s;!h.next().done;){if(h.lineBreak){a++,i.add(a,a,Me),r&&r.add(a,a,De);continue}let d=a+h.value.length;if(l)for(;f<t.changes.length;){let c=t.changes[f],u=s+(n?c.fromA:c.fromB),m=s+(n?c.toA:c.toB),p=Math.max(a,u),g=Math.min(d,m);if(p<g&&i.add(p,g,tt),m<d)f++;else break}a=d}}}function Le(t){let e=t.state.field(k),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(b),s=n=="a",o=new N,f=i?new N:null,{from:h,to:a}=t.viewport;for(let d of e){if((s?d.fromA:d.fromB)>=a)break;(s?d.toA:d.toB)>h&&(!r||!r(t.state,d,o,f))&&Bt(d,t.state.doc,s,l,o,f)}return{deco:o.finish(),gutter:f&&f.finish()}}class q extends Y{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const K=G.define({map:(t,e)=>t.map(e)}),W=H.define({create:()=>M.none,update:(t,e)=>{for(let n of e.effects)if(n.is(K))return n.value;return t.map(e.changes)},provide:t=>B.decorations.from(t)}),_=.01;function Se(t,e){if(t.size!=e.size)return!1;let n=t.iter(),l=e.iter();for(;n.value;){if(n.from!=l.from||Math.abs(n.value.spec.widget.height-l.value.spec.widget.height)>1)return!1;n.next(),l.next()}return!0}function bt(t,e,n){let l=new N,i=new N,r=t.state.field(W).iter(),s=e.state.field(W).iter(),o=0,f=0,h=0,a=0,d=t.viewport,c=e.viewport;for(let g=0;;g++){let C=g<n.length?n[g]:null,S=C?C.fromA:t.state.doc.length,R=C?C.fromB:e.state.doc.length;if(o<S){let x=t.lineBlockAt(o).top+h,D=e.lineBlockAt(f).top+a,w=x-D;w<-_?(h-=w,l.add(o,o,M.widget({widget:new q(-w),block:!0,side:-1}))):w>_&&(a+=w,i.add(f,f,M.widget({widget:new q(w),block:!0,side:-1})))}if(S>o+1e3&&o<d.from&&S>d.from&&f<c.from&&R>c.from){let x=Math.min(d.from-o,c.from-f);o+=x,f+=x,g--}else if(C)o=C.toA,f=C.toB;else break;for(;r.value&&r.from<o;)h-=r.value.spec.widget.height,r.next();for(;s.value&&s.from<f;)a-=s.value.spec.widget.height,s.next()}for(;r.value;)h-=r.value.spec.widget.height,r.next();for(;s.value;)a-=s.value.spec.widget.height,s.next();let u=t.contentHeight+h-(e.contentHeight+a);u<_?l.add(t.state.doc.length,t.state.doc.length,M.widget({widget:new q(-u),block:!0,side:1})):u>_&&i.add(e.state.doc.length,e.state.doc.length,M.widget({widget:new q(u),block:!0,side:1}));let m=l.finish(),p=i.finish();Se(m,t.state.field(W))||t.dispatch({effects:K.of(m)}),Se(p,e.state.field(W))||e.dispatch({effects:K.of(p)})}const le=G.define({map:(t,e)=>e.mapPos(t)});class Mt extends Y{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:le.of(i)});let{side:r,sibling:s}=e.state.facet(b);s&&s().dispatch({effects:le.of(Dt(i,e.state.field(k),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Dt(t,e,n){let l=0,i=0;for(let r=0;;r++){let s=r<e.length?e[r]:null;if(!s||(n?s.fromA:s.fromB)>=t)return i+(t-l);[l,i]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const Lt=H.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(le)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(k)!=e.startState.field(k,!1)){let n=e.state.facet(b).side=="a",l=[];for(let i of e.state.field(k))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>B.decorations.from(t)});function se({margin:t=3,minSize:e=4}){return Lt.init(n=>St(n,t,e))}function St(t,e,n){let l=new N,i=t.facet(b).side=="a",r=t.field(k),s=1;for(let o=0;;o++){let f=o<r.length?r[o]:null,h=o?s+e:1,a=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=a-h+1;if(d>=n&&l.add(t.doc.line(h).from,t.doc.line(a).to,M.replace({widget:new Mt(d),block:!0})),!f)break;s=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const Ot=B.styleModule.of(new st({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),nt=B.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Oe=new Ge,$=new Ge;class Et{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||et;let n=[Q.low(Z),nt,Ot,W,B.updateListener.of(d=>{this.measuring<0&&(d.heightChanged||d.viewportChanged)&&!d.transactions.some(c=>c.effects.some(u=>u.is(K)))&&this.measure()})],l=[b.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&l.push(P);let i=ne.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],B.editorAttributes.of({class:"cm-merge-a"}),$.of(l),n]}),r=[b.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&r.push(P);let s=ne.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],B.editorAttributes.of({class:"cm-merge-b"}),$.of(r),n]});this.chunks=O.build(i.doc,s.doc,this.diffConf);let o=[k.init(()=>this.chunks),Oe.of(e.collapseUnchanged?se(e.collapseUnchanged):[])];i=i.update({effects:G.appendConfig.of(o)}).state,s=s.update({effects:G.appendConfig.of(o)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let f=e.orientation||"a-b",h=document.createElement("div");h.className="cm-mergeViewEditor";let a=document.createElement("div");a.className="cm-mergeViewEditor",this.editorDOM.appendChild(f=="a-b"?h:a),this.editorDOM.appendChild(f=="a-b"?a:h),this.a=new B({state:i,parent:h,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.a)}),this.b=new B({state:s,parent:a,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(l=>l.docChanged)){let l=e[e.length-1],i=e.reduce((s,o)=>s.compose(o.changes),Ne.empty(e[0].startState.doc.length));this.chunks=n==this.a?O.updateA(this.chunks,l.newDoc,this.b.state.doc,i,this.diffConf):O.updateB(this.chunks,this.a.state.doc,l.newDoc,i,this.diffConf),n.update([...e,l.state.update({effects:ie.of(this.chunks)})]);let r=n==this.a?this.b:this.a;r.update([r.state.update({effects:ie.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let r=e.orientation!="b-a";if(r!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let s=this.a.dom.parentNode,o=this.b.dom.parentNode;s.remove(),o.remove(),this.editorDOM.insertBefore(r?s:o,this.editorDOM.firstChild),this.editorDOM.appendChild(r?o:s),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let r=!!this.revertDOM,s=this.revertToA,o=this.renderRevert;"revertControls"in e&&(r=!!e.revertControls,s=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(r,s,o)}let n="highlightChanges"in e,l="gutter"in e,i="collapseUnchanged"in e;if(n||l||i){let r=[],s=[];if(n||l){let o=this.a.state.facet(b),f=l?e.gutter!==!1:o.markGutter,h=n?e.highlightChanges!==!1:o.highlightChanges;r.push($.reconfigure([b.of({side:"a",sibling:()=>this.b,highlightChanges:h,markGutter:f}),f?P:[]])),s.push($.reconfigure([b.of({side:"b",sibling:()=>this.a,highlightChanges:h,markGutter:f}),f?P:[]]))}if(i){let o=Oe.reconfigure(e.collapseUnchanged?se(e.collapseUnchanged):[]);r.push(o),s.push(o)}this.a.dispatch({effects:r}),this.b.dispatch({effects:s})}this.scheduleMeasure()}setupRevertControls(e,n,l){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=l,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",i=>this.revertClicked(i)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){bt(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,l=this.a.viewport,i=this.b.viewport;for(let r=0;r<this.chunks.length;r++){let s=this.chunks[r];if(s.fromA>l.to||s.fromB>i.to)break;if(s.fromA<l.from||s.fromB<i.from)continue;let o=this.a.lineBlockAt(s.fromA).top+"px";for(;n&&+n.dataset.chunk<r;)n=Ee(n);n&&n.dataset.chunk==String(r)?(n.style.top!=o&&(n.style.top=o),n=n.nextSibling):e.insertBefore(this.renderRevertButton(o,r),n)}for(;n;)n=Ee(n)}renderRevertButton(e,n){let l;if(this.renderRevert)l=this.renderRevert();else{l=document.createElement("button");let i=this.a.state.phrase("Revert this chunk");l.setAttribute("aria-label",i),l.setAttribute("title",i),l.textContent=this.revertToLeft?"⇜":"⇝"}return l.style.top=e,l.setAttribute("data-chunk",String(n)),l}revertClicked(e){let n=e.target,l;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(l=this.chunks[n.dataset.chunk])){let[i,r,s,o,f,h]=this.revertToA?[this.b,this.a,l.fromB,l.toB,l.fromA,l.toA]:[this.a,this.b,l.fromA,l.toA,l.fromB,l.toB],a=i.state.sliceDoc(s,Math.max(s,o-1));s!=o&&h<=r.state.doc.length&&(a+=i.state.lineBreak),r.dispatch({changes:{from:f,to:Math.min(r.state.doc.length,h),insert:a},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Ee(t){let e=t.nextSibling;return t.remove(),e}const yt=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Rt=Q.low(je({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(Z))===null||e===void 0?void 0:e.gutter)||Ie.empty},widgetMarker:(t,e)=>e instanceof rt?yt:null}));function Tt(t){var e;let n=typeof t.original=="string"?Fe.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||et;return[Q.low(Z),Vt,nt,B.editorAttributes.of({class:"cm-merge-b"}),Ze.of((i,r)=>{let s=r.effects.find(o=>o.is(he));return s&&(i=O.updateA(i,s.value.doc,r.startState.doc,s.value.changes,l)),r.docChanged&&(i=O.updateB(i,r.state.field(V),r.newDoc,r.changes,l)),i}),b.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Wt:void 0,side:"b"}),V.init(()=>n),t.gutter!==!1?Rt:[],t.collapseUnchanged?se(t.collapseUnchanged):[],k.init(i=>O.build(n,i.doc,l))]}const he=G.define(),V=H.define({create:()=>Fe.empty,update(t,e){for(let n of e.effects)n.is(he)&&(t=n.value.doc);return t}}),ye=new WeakMap;class rt extends Y{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Gt(t,e,n){let l=ye.get(e.changes);if(l)return l;let i=s=>{let{highlightChanges:o,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:h,mergeControls:a}=t.facet(b),d=document.createElement("div");if(d.className="cm-deletedChunk",a){let x=d.appendChild(document.createElement("div"));x.className="cm-chunkButtons";let D=A=>{A.preventDefault(),Nt(s,s.posAtDOM(d))},w=A=>{A.preventDefault(),Ft(s,s.posAtDOM(d))};if(typeof a=="function")x.appendChild(a("accept",D)),x.appendChild(a("reject",w));else{let A=x.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=D;let L=x.appendChild(document.createElement("button"));L.name="reject",L.textContent=t.phrase("Reject"),L.onmousedown=w}}if(n||e.fromA>=e.toA)return d;let c=s.state.field(V).sliceString(e.fromA,e.endA),u=f&&t.facet(at),m=S(),p=e.changes,g=0,C=!1;function S(){let x=d.appendChild(document.createElement("div"));return x.className="cm-deletedLine",x.appendChild(document.createElement("del"))}function R(x,D,w){for(let A=x;A<D;){if(c.charAt(A)==`
1
+ import{j as J,r as T}from"./index-Dc5cpBoO.js";import{R as lt}from"./index-CBm3whA-.js";import{o as Q,E as B,q as ne,C as Ge,S as G,r as Ne,u as Fe,v as st,w as H,x as M,V as ot,F as Ve,y as je,R as N,W as Y,G as oe,z as at,A as ft,B as Ie,H as dt,m as ht,n as ct}from"./index-BUOcbPfv.js";class v{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new v(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function y(t,e,n,l,i,r){if(t==l)return[];let s=fe(t,e,n,l,i,r),o=de(t,e+s,n,l,i+s,r);e+=s,n-=o,i+=s,r-=o;let f=n-e,h=r-i;if(!f||!h)return[new v(e,n,i,r)];if(f>h){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new v(e,e+d,i,i),new v(e+d+h,n,r,r)]}else if(h>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new v(e,e,i,i+d),new v(n,n,i+d+f,r)]}if(f==1||h==1)return[new v(e,n,i,r)];let a=He(t,e,n,l,i,r);if(a){let[d,c,u]=a;return y(t,e,d,l,i,c).concat(y(t,d+u,n,l,c+u,r))}return ut(t,e,n,l,i,r)}let I=1e9,U=0,ae=!1;function ut(t,e,n,l,i,r){let s=n-e,o=r-i;if(I<1e9&&Math.min(s,o)>I*16||U>0&&Date.now()>U)return Math.min(s,o)>I*64?[new v(e,n,i,r)]:ge(t,e,n,l,i,r);let f=Math.ceil((s+o)/2);ee.reset(f),te.reset(f);let h=(u,m)=>t.charCodeAt(e+u)==l.charCodeAt(i+m),a=(u,m)=>t.charCodeAt(n-u-1)==l.charCodeAt(r-m-1),d=(s-o)%2!=0?te:null,c=d?null:ee;for(let u=0;u<f;u++){if(u>I||U>0&&!(u&63)&&Date.now()>U)return ge(t,e,n,l,i,r);let m=ee.advance(u,s,o,f,d,!1,h)||te.advance(u,s,o,f,c,!0,a);if(m)return mt(t,e,n,e+m[0],l,i,r,i+m[1])}return[new v(e,n,i,r)]}class Ue{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,s,o){for(let f=-e+this.start;f<=e-this.end;f+=2){let h=i+f,a=f==-e||f!=e&&this.vec[h-1]<this.vec[h+1]?this.vec[h+1]:this.vec[h-1]+1,d=a-f;for(;a<n&&d<l&&o(a,d);)a++,d++;if(this.vec[h]=a,a>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let c=i+(n-l)-f;if(c>=0&&c<this.len&&r.vec[c]!=-1)if(s){let u=r.vec[c];if(u>=n-a)return[u,i+u-c]}else{let u=n-r.vec[c];if(a>=u)return[a,d]}}}return null}}const ee=new Ue,te=new Ue;function mt(t,e,n,l,i,r,s,o){let f=!1;return!F(t,l)&&++l==n&&(f=!0),!F(i,o)&&++o==s&&(f=!0),f?[new v(e,n,r,s)]:y(t,e,l,i,r,o).concat(y(t,l,n,i,o,s))}function We(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function fe(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let s=We(n-e,r-i);for(let o=e,f=i;;){let h=o+s,a=f+s;if(h>n||a>r||t.slice(o,h)!=l.slice(f,a)){if(s==1)return o-e-(F(t,o)?0:1);s=s>>1}else{if(h==n||a==r)return h-e;o=h,f=a}}}function de(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let s=We(n-e,r-i);for(let o=n,f=r;;){let h=o-s,a=f-s;if(h<e||a<i||t.slice(h,o)!=l.slice(a,f)){if(s==1)return n-o-(F(t,o)?0:1);s=s>>1}else{if(h==e||a==i)return n-h;o=h,f=a}}}function re(t,e,n,l,i,r,s,o){let f=l.slice(i,r),h=null;for(;;){if(h||s<o)return h;for(let a=e+s;;){F(t,a)||a++;let d=a+s;if(F(t,d)||(d+=d==a+1?1:-1),d>=n)break;let c=t.slice(a,d),u=-1;for(;(u=f.indexOf(c,u+1))!=-1;){let m=fe(t,d,n,l,i+u+c.length,r),p=de(t,e,a,l,i,i+u),g=c.length+m+p;(!h||h[2]<g)&&(h=[a-p,i+u-p,g])}a=d}if(o<0)return h;s=s>>1}}function He(t,e,n,l,i,r){let s=n-e,o=r-i;if(s<o){let f=He(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return s<4||o*2<s?null:re(t,e,n,l,i,r,Math.floor(s/4),-1)}function ge(t,e,n,l,i,r){ae=!0;let s=n-e,o=r-i,f;if(s<o){let c=re(l,i,r,t,e,n,Math.floor(s/6),50);f=c&&[c[1],c[0],c[2]]}else f=re(t,e,n,l,i,r,Math.floor(o/6),50);if(!f)return[new v(e,n,i,r)];let[h,a,d]=f;return y(t,e,h,l,i,a).concat(y(t,h+d,n,l,a+d,r))}function ze(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new v(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function gt(t,e,n){for(;;){ze(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],s,o;(s=fe(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new v(r.fromA+s,r.toA,r.fromB+s,r.toB)),(o=de(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new v(r.fromA,r.toA-o,r.fromB,r.toB-o));let f=r.toA-r.fromA,h=r.toB-r.fromB;if(f&&h)continue;let a=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!a||!d)continue;let c=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);a<=c.length&&t.slice(r.fromA-a,r.fromA)==c.slice(c.length-a)?(n[i]=new v(r.fromA-a,r.toA-a,r.fromB-a,r.toB-a),l=!0):d<=c.length&&t.slice(r.toA,r.toA+d)==c.slice(0,d)&&(n[i]=new v(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function pt(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],s=r.toA-r.fromA,o=r.toB-r.fromB;if(s&&o||s>3||o>3){let f=i==t.length-1?e.length:t[i+1].fromA,h=r.fromA-l,a=f-r.toA,d=Ce(e,r.fromA,h),c=pe(e,r.toA,a),u=r.fromA-d,m=c-r.toA;if((!s||!o)&&u&&m){let p=Math.max(s,o),[g,C,S]=s?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>u&&e.slice(d,r.fromA)==g.slice(S-u,S)?(r=t[i]=new v(d,d+s,r.fromB-u,r.toB-u),d=r.fromA,c=pe(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,c)==g.slice(C,C+m)&&(r=t[i]=new v(c-s,c,r.fromB+m,r.toB+m),c=r.toA,d=Ce(e,r.fromA,r.fromA-l)),u=r.fromA-d,m=c-r.toA}if(u||m)r=t[i]=new v(r.fromA-u,r.toA+m,r.fromB-u,r.toB+m);else if(s){if(!o){let p=Ae(e,r.fromA,r.toA),g,C=p<0?-1:ve(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=a&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):C>-1&&(g=r.toA-C)<=h&&e.slice(r.fromA-g,r.fromA)==e.slice(C,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=Ae(n,r.fromB,r.toB),g,C=p<0?-1:ve(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=a&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):C>-1&&(g=r.toB-C)<=h&&n.slice(r.fromB-g,r.fromB)==n.slice(C,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return ze(t,3),t}let E;try{E=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Pe(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function qe(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Pe(n)?1:0:E?!Je(n)||e==t.length-1?E.test(String.fromCharCode(n))?1:0:E.test(t.slice(e,e+2))?2:0:0}function _e(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Pe(n)?1:0:E?!Ke(n)||e==1?E.test(String.fromCharCode(n))?1:0:E.test(t.slice(e-2,e))?2:0:0}const $e=8;function pe(t,e,n){if(e==t.length||!_e(t,e))return e;for(let l=e,i=e+n,r=0;r<$e;r++){let s=qe(t,l);if(!s||l+s>i)return l;l+=s}return e}function Ce(t,e,n){if(!e||!qe(t,e))return e;for(let l=e,i=e-n,r=0;r<$e;r++){let s=_e(t,l);if(!s||l-s<i)return l;l-=s}return e}function ve(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function Ae(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Je=t=>t>=55296&&t<=56319,Ke=t=>t>=56320&&t<=57343;function F(t,e){return!e||e==t.length||!Je(t.charCodeAt(e-1))||!Ke(t.charCodeAt(e))}function Ct(t,e,n){var l;let i=n==null?void 0:n.override;return i?i(t,e):(I=((l=n==null?void 0:n.scanLimit)!==null&&l!==void 0?l:1e9)>>1,U=n!=null&&n.timeout?Date.now()+n.timeout:0,ae=!1,gt(t,e,y(t,0,t.length,e,0,e.length)))}function Qe(){return!ae}function Ye(t,e,n){return pt(Ct(t,e,n),t,e)}const b=Ve.define({combine:t=>t[0]}),ie=G.define(),Ze=Ve.define(),k=H.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ie)&&(t=n.value);for(let n of e.state.facet(Ze))t=n(t,e);return t}});function vt(t){let e=t.field(k,!1);if(!e)return null;let n=t.facet(b);return{chunks:e,side:n?n.side:null}}class O{constructor(e,n,l,i,r,s=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=s}offset(e,n){return e||n?new O(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Ye(e.toString(),n.toString(),l);return Xe(i,e,n,0,0,Qe())}static updateA(e,n,l,i,r){return be(Be(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return be(Be(e,i,!1,n.length),e,n,l,r)}}function xe(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function we(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function Xe(t,e,n,l,i,r){let s=[];for(let o=0;o<t.length;o++){let f=t[o],[h,a]=xe(f.fromA+l,f.fromB+i,e,n),[d,c]=we(f.toA+l,f.toB+i,e,n),u=[f.offset(-h+l,-a+i)];for(;o<t.length-1;){let m=t[o+1],[p,g]=xe(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>c+1)break;u.push(m.offset(-h+l,-a+i)),[d,c]=we(m.toA+l,m.toB+i,e,n),o++}s.push(new O(u,h,Math.max(h,d),a,Math.max(a,c),r))}return s}const z=1e3;function ke(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let a=0,d=0;i&&({toA:a,toB:d}=t[i-1]);let c=e-(n?a:d);return[a+c,d+c]}let s=i+r>>1,o=t[s],[f,h]=n?[o.fromA,o.toA]:[o.fromB,o.toB];if(f>e)r=s;else if(h<=e)i=s+1;else return l?[o.fromA,o.fromB]:[o.toA,o.toB]}}function Be(t,e,n,l){let i=[];return e.iterChangedRanges((r,s,o,f)=>{let h=0,a=n?e.length:l,d=0,c=n?l:e.length;r>z&&([h,d]=ke(t,r-z,n,!0)),s<e.length-z&&([a,c]=ke(t,s+z,n,!1));let u=f-o-(s-r),m,[p,g]=n?[u,0]:[0,u];i.length&&(m=i[i.length-1]).toA>=h?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:a,toB:c,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:h,toA:a,fromB:d,toB:c,diffA:p,diffB:g})}),i}function be(t,e,n,l,i){if(!t.length)return e;let r=[];for(let s=0,o=0,f=0,h=0;;s++){let a=s==t.length?null:t[s],d=a?a.fromA+o:n.length,c=a?a.fromB+f:l.length;for(;h<e.length;){let g=e[h];if(a&&(g.toA+o>d||g.toB+f>c))break;r.push(g.offset(o,f)),h++}if(!a)break;let u=a.toA+o+a.diffA,m=a.toB+f+a.diffB,p=Ye(n.sliceString(d,u),l.sliceString(c,m),i);for(let g of Xe(p,n,l,d,c,Qe()))r.push(g);for(o+=a.diffA,f+=a.diffB;h<e.length;){let g=e[h];if(g.fromA+o>u&&g.fromB+f>m)break;h++}}return r}const et={scanLimit:500},Z=ot.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Le(t))}update(t){(t.docChanged||t.viewportChanged||At(t.startState,t.state)||xt(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Le(t.view))}},{decorations:t=>t.deco}),P=Q.low(je({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(Z))===null||e===void 0?void 0:e.gutter)||Ie.empty}}));function At(t,e){return t.field(k,!1)!=e.field(k,!1)}function xt(t,e){return t.facet(b)!=e.facet(b)}const Me=M.line({class:"cm-changedLine"}),tt=M.mark({class:"cm-changedText"}),wt=M.mark({tagName:"ins",class:"cm-insertedLine"}),kt=M.mark({tagName:"del",class:"cm-deletedLine"}),De=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Bt(t,e,n,l,i,r){let s=n?t.fromA:t.fromB,o=n?t.toA:t.toB,f=0;if(s!=o){i.add(s,s,Me),i.add(s,o,n?kt:wt),r&&r.add(s,s,De);for(let h=e.iterRange(s,o-1),a=s;!h.next().done;){if(h.lineBreak){a++,i.add(a,a,Me),r&&r.add(a,a,De);continue}let d=a+h.value.length;if(l)for(;f<t.changes.length;){let c=t.changes[f],u=s+(n?c.fromA:c.fromB),m=s+(n?c.toA:c.toB),p=Math.max(a,u),g=Math.min(d,m);if(p<g&&i.add(p,g,tt),m<d)f++;else break}a=d}}}function Le(t){let e=t.state.field(k),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(b),s=n=="a",o=new N,f=i?new N:null,{from:h,to:a}=t.viewport;for(let d of e){if((s?d.fromA:d.fromB)>=a)break;(s?d.toA:d.toB)>h&&(!r||!r(t.state,d,o,f))&&Bt(d,t.state.doc,s,l,o,f)}return{deco:o.finish(),gutter:f&&f.finish()}}class q extends Y{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const K=G.define({map:(t,e)=>t.map(e)}),W=H.define({create:()=>M.none,update:(t,e)=>{for(let n of e.effects)if(n.is(K))return n.value;return t.map(e.changes)},provide:t=>B.decorations.from(t)}),_=.01;function Se(t,e){if(t.size!=e.size)return!1;let n=t.iter(),l=e.iter();for(;n.value;){if(n.from!=l.from||Math.abs(n.value.spec.widget.height-l.value.spec.widget.height)>1)return!1;n.next(),l.next()}return!0}function bt(t,e,n){let l=new N,i=new N,r=t.state.field(W).iter(),s=e.state.field(W).iter(),o=0,f=0,h=0,a=0,d=t.viewport,c=e.viewport;for(let g=0;;g++){let C=g<n.length?n[g]:null,S=C?C.fromA:t.state.doc.length,R=C?C.fromB:e.state.doc.length;if(o<S){let x=t.lineBlockAt(o).top+h,D=e.lineBlockAt(f).top+a,w=x-D;w<-_?(h-=w,l.add(o,o,M.widget({widget:new q(-w),block:!0,side:-1}))):w>_&&(a+=w,i.add(f,f,M.widget({widget:new q(w),block:!0,side:-1})))}if(S>o+1e3&&o<d.from&&S>d.from&&f<c.from&&R>c.from){let x=Math.min(d.from-o,c.from-f);o+=x,f+=x,g--}else if(C)o=C.toA,f=C.toB;else break;for(;r.value&&r.from<o;)h-=r.value.spec.widget.height,r.next();for(;s.value&&s.from<f;)a-=s.value.spec.widget.height,s.next()}for(;r.value;)h-=r.value.spec.widget.height,r.next();for(;s.value;)a-=s.value.spec.widget.height,s.next();let u=t.contentHeight+h-(e.contentHeight+a);u<_?l.add(t.state.doc.length,t.state.doc.length,M.widget({widget:new q(-u),block:!0,side:1})):u>_&&i.add(e.state.doc.length,e.state.doc.length,M.widget({widget:new q(u),block:!0,side:1}));let m=l.finish(),p=i.finish();Se(m,t.state.field(W))||t.dispatch({effects:K.of(m)}),Se(p,e.state.field(W))||e.dispatch({effects:K.of(p)})}const le=G.define({map:(t,e)=>e.mapPos(t)});class Mt extends Y{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:le.of(i)});let{side:r,sibling:s}=e.state.facet(b);s&&s().dispatch({effects:le.of(Dt(i,e.state.field(k),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Dt(t,e,n){let l=0,i=0;for(let r=0;;r++){let s=r<e.length?e[r]:null;if(!s||(n?s.fromA:s.fromB)>=t)return i+(t-l);[l,i]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const Lt=H.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(le)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(k)!=e.startState.field(k,!1)){let n=e.state.facet(b).side=="a",l=[];for(let i of e.state.field(k))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>B.decorations.from(t)});function se({margin:t=3,minSize:e=4}){return Lt.init(n=>St(n,t,e))}function St(t,e,n){let l=new N,i=t.facet(b).side=="a",r=t.field(k),s=1;for(let o=0;;o++){let f=o<r.length?r[o]:null,h=o?s+e:1,a=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=a-h+1;if(d>=n&&l.add(t.doc.line(h).from,t.doc.line(a).to,M.replace({widget:new Mt(d),block:!0})),!f)break;s=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const Ot=B.styleModule.of(new st({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),nt=B.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Oe=new Ge,$=new Ge;class Et{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||et;let n=[Q.low(Z),nt,Ot,W,B.updateListener.of(d=>{this.measuring<0&&(d.heightChanged||d.viewportChanged)&&!d.transactions.some(c=>c.effects.some(u=>u.is(K)))&&this.measure()})],l=[b.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&l.push(P);let i=ne.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],B.editorAttributes.of({class:"cm-merge-a"}),$.of(l),n]}),r=[b.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&r.push(P);let s=ne.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],B.editorAttributes.of({class:"cm-merge-b"}),$.of(r),n]});this.chunks=O.build(i.doc,s.doc,this.diffConf);let o=[k.init(()=>this.chunks),Oe.of(e.collapseUnchanged?se(e.collapseUnchanged):[])];i=i.update({effects:G.appendConfig.of(o)}).state,s=s.update({effects:G.appendConfig.of(o)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let f=e.orientation||"a-b",h=document.createElement("div");h.className="cm-mergeViewEditor";let a=document.createElement("div");a.className="cm-mergeViewEditor",this.editorDOM.appendChild(f=="a-b"?h:a),this.editorDOM.appendChild(f=="a-b"?a:h),this.a=new B({state:i,parent:h,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.a)}),this.b=new B({state:s,parent:a,root:e.root,dispatchTransactions:d=>this.dispatch(d,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(l=>l.docChanged)){let l=e[e.length-1],i=e.reduce((s,o)=>s.compose(o.changes),Ne.empty(e[0].startState.doc.length));this.chunks=n==this.a?O.updateA(this.chunks,l.newDoc,this.b.state.doc,i,this.diffConf):O.updateB(this.chunks,this.a.state.doc,l.newDoc,i,this.diffConf),n.update([...e,l.state.update({effects:ie.of(this.chunks)})]);let r=n==this.a?this.b:this.a;r.update([r.state.update({effects:ie.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let r=e.orientation!="b-a";if(r!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let s=this.a.dom.parentNode,o=this.b.dom.parentNode;s.remove(),o.remove(),this.editorDOM.insertBefore(r?s:o,this.editorDOM.firstChild),this.editorDOM.appendChild(r?o:s),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let r=!!this.revertDOM,s=this.revertToA,o=this.renderRevert;"revertControls"in e&&(r=!!e.revertControls,s=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(r,s,o)}let n="highlightChanges"in e,l="gutter"in e,i="collapseUnchanged"in e;if(n||l||i){let r=[],s=[];if(n||l){let o=this.a.state.facet(b),f=l?e.gutter!==!1:o.markGutter,h=n?e.highlightChanges!==!1:o.highlightChanges;r.push($.reconfigure([b.of({side:"a",sibling:()=>this.b,highlightChanges:h,markGutter:f}),f?P:[]])),s.push($.reconfigure([b.of({side:"b",sibling:()=>this.a,highlightChanges:h,markGutter:f}),f?P:[]]))}if(i){let o=Oe.reconfigure(e.collapseUnchanged?se(e.collapseUnchanged):[]);r.push(o),s.push(o)}this.a.dispatch({effects:r}),this.b.dispatch({effects:s})}this.scheduleMeasure()}setupRevertControls(e,n,l){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=l,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",i=>this.revertClicked(i)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){bt(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,l=this.a.viewport,i=this.b.viewport;for(let r=0;r<this.chunks.length;r++){let s=this.chunks[r];if(s.fromA>l.to||s.fromB>i.to)break;if(s.fromA<l.from||s.fromB<i.from)continue;let o=this.a.lineBlockAt(s.fromA).top+"px";for(;n&&+n.dataset.chunk<r;)n=Ee(n);n&&n.dataset.chunk==String(r)?(n.style.top!=o&&(n.style.top=o),n=n.nextSibling):e.insertBefore(this.renderRevertButton(o,r),n)}for(;n;)n=Ee(n)}renderRevertButton(e,n){let l;if(this.renderRevert)l=this.renderRevert();else{l=document.createElement("button");let i=this.a.state.phrase("Revert this chunk");l.setAttribute("aria-label",i),l.setAttribute("title",i),l.textContent=this.revertToLeft?"⇜":"⇝"}return l.style.top=e,l.setAttribute("data-chunk",String(n)),l}revertClicked(e){let n=e.target,l;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(l=this.chunks[n.dataset.chunk])){let[i,r,s,o,f,h]=this.revertToA?[this.b,this.a,l.fromB,l.toB,l.fromA,l.toA]:[this.a,this.b,l.fromA,l.toA,l.fromB,l.toB],a=i.state.sliceDoc(s,Math.max(s,o-1));s!=o&&h<=r.state.doc.length&&(a+=i.state.lineBreak),r.dispatch({changes:{from:f,to:Math.min(r.state.doc.length,h),insert:a},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Ee(t){let e=t.nextSibling;return t.remove(),e}const yt=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Rt=Q.low(je({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(Z))===null||e===void 0?void 0:e.gutter)||Ie.empty},widgetMarker:(t,e)=>e instanceof rt?yt:null}));function Tt(t){var e;let n=typeof t.original=="string"?Fe.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||et;return[Q.low(Z),Vt,nt,B.editorAttributes.of({class:"cm-merge-b"}),Ze.of((i,r)=>{let s=r.effects.find(o=>o.is(he));return s&&(i=O.updateA(i,s.value.doc,r.startState.doc,s.value.changes,l)),r.docChanged&&(i=O.updateB(i,r.state.field(V),r.newDoc,r.changes,l)),i}),b.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Wt:void 0,side:"b"}),V.init(()=>n),t.gutter!==!1?Rt:[],t.collapseUnchanged?se(t.collapseUnchanged):[],k.init(i=>O.build(n,i.doc,l))]}const he=G.define(),V=H.define({create:()=>Fe.empty,update(t,e){for(let n of e.effects)n.is(he)&&(t=n.value.doc);return t}}),ye=new WeakMap;class rt extends Y{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Gt(t,e,n){let l=ye.get(e.changes);if(l)return l;let i=s=>{let{highlightChanges:o,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:h,mergeControls:a}=t.facet(b),d=document.createElement("div");if(d.className="cm-deletedChunk",a){let x=d.appendChild(document.createElement("div"));x.className="cm-chunkButtons";let D=A=>{A.preventDefault(),Nt(s,s.posAtDOM(d))},w=A=>{A.preventDefault(),Ft(s,s.posAtDOM(d))};if(typeof a=="function")x.appendChild(a("accept",D)),x.appendChild(a("reject",w));else{let A=x.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=D;let L=x.appendChild(document.createElement("button"));L.name="reject",L.textContent=t.phrase("Reject"),L.onmousedown=w}}if(n||e.fromA>=e.toA)return d;let c=s.state.field(V).sliceString(e.fromA,e.endA),u=f&&t.facet(at),m=S(),p=e.changes,g=0,C=!1;function S(){let x=d.appendChild(document.createElement("div"));return x.className="cm-deletedLine",x.appendChild(document.createElement("del"))}function R(x,D,w){for(let A=x;A<D;){if(c.charAt(A)==`
2
2
  `){m.firstChild||m.appendChild(document.createElement("br")),m=S(),A++;continue}let L=D,ce=w+(C?" cm-deletedText":""),ue=!1,X=c.indexOf(`
3
3
  `,A);if(X>-1&&X<D&&(L=X),o&&g<p.length){let j=Math.max(0,C?p[g].toA:p[g].fromA);j<=L&&(L=j,C&&g++,ue=!0)}if(L>A){let j=document.createTextNode(c.slice(A,L));if(ce){let me=m.appendChild(document.createElement("span"));me.className=ce,me.appendChild(j)}else m.appendChild(j);A=L}ue&&(C=!C)}}if(u&&e.toA-e.fromA<=h){let x=u.parser.parse(c),D=0;ft(x,{style:w=>dt(t,w)},(w,A,L)=>{w>D&&R(D,w,""),R(w,A,L),D=A}),R(D,c.length,"")}else R(0,c.length,"");return m.firstChild||m.appendChild(document.createElement("br")),d},r=M.widget({block:!0,side:-1,widget:new rt(i)});return ye.set(e.changes,r),r}function Nt(t,e){let{state:n}=t,l=e??n.selection.main.head,i=t.state.field(k).find(f=>f.fromB<=l&&f.endB>=l);if(!i)return!1;let r=t.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),s=t.state.field(V);i.fromB!=i.toB&&i.toA<=s.length&&(r+=t.state.lineBreak);let o=Ne.of({from:i.fromA,to:Math.min(s.length,i.toA),insert:r},s.length);return t.dispatch({effects:he.of({doc:o.apply(s),changes:o}),userEvent:"accept"}),!0}function Ft(t,e){let{state:n}=t,l=e??n.selection.main.head,i=n.field(k).find(o=>o.fromB<=l&&o.endB>=l);if(!i)return!1;let s=n.field(V).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(s+=n.lineBreak),t.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:s},userEvent:"revert"}),!0}function Re(t){let e=new N;for(let n of t.field(k)){let l=t.facet(b).overrideChunk&&it(t,n);e.add(n.fromB,n.fromB,Gt(t,n,!!l))}return e.finish()}const Vt=H.define({create:t=>Re(t),update(t,e){return e.state.field(k,!1)!=e.startState.field(k,!1)?Re(e.state):t},provide:t=>B.decorations.from(t)}),Te=new WeakMap;function it(t,e){let n=Te.get(e);if(n!==void 0)return n;n=null;let l=t.field(V),i=t.doc,r=l.lineAt(e.endA).number-l.lineAt(e.fromA).number+1,s=i.lineAt(e.endB).number-i.lineAt(e.fromB).number+1;e:if(r==s&&r<10){let o=[],f=0,h=e.fromA,a=e.fromB;for(let d of e.changes){if(d.fromA<d.toA){f+=d.toA-d.fromA;let c=l.sliceString(h+d.fromA,h+d.toA);if(/\n/.test(c))break e;o.push(M.widget({widget:new jt(c),side:-1}).range(a+d.fromB))}d.fromB<d.toB&&o.push(tt.range(a+d.fromB,a+d.toB))}f<e.endA-e.fromA-r*2&&(n=o)}return Te.set(e,n),n}class jt extends Y{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const It=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Ut=M.line({class:"cm-inlineChangedLine"});function Wt(t,e,n,l){let i=it(t,e),r=0;if(!i)return!1;for(let s=t.doc.lineAt(e.fromB);;){for(l&&l.add(s.from,s.from,It),n.add(s.from,s.from,Ut);r<i.length&&i[r].to<=s.to;){let o=i[r++];n.add(o.from,o.to,o.value)}if(s.to>=e.endB)break;s=t.doc.lineAt(s.to+1)}return!0}function Ht(t){const[e,n]=T.useState([]);return T.useEffect(()=>{let l=!1;const i=ht.matchFilename(ct,t);if(!i){n([]);return}return i.load().then(r=>{l||n([r])}).catch(()=>{l||n([])}),()=>{l=!0}},[t]),e}function Kt({baseline:t,current:e,theme:n,filename:l,sideBySide:i,onRejectHunk:r,onHunkCountChange:s}){const o=Ht(l);return i?J.jsx(Pt,{baseline:t,current:e,theme:n,languageExtension:o}):J.jsx(zt,{baseline:t,current:e,theme:n,languageExtension:o,onRejectHunk:r,onHunkCountChange:s})}function zt({baseline:t,current:e,theme:n,languageExtension:l,onRejectHunk:i,onHunkCountChange:r}){const s=T.useRef(-1),o=T.useMemo(()=>[B.lineWrapping,Tt({original:t,gutter:!0,mergeControls:!0,collapseUnchanged:{margin:3,minSize:4}}),...l],[t,l]);return J.jsx(lt,{value:e,editable:!1,readOnly:!0,theme:n,height:"100%",className:"desktop:select-text h-full text-sm",extensions:o,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},onChange:f=>i(f),onUpdate:f=>{var a;const h=((a=vt(f.state))==null?void 0:a.chunks.length)??null;h!==null&&h!==s.current&&(s.current=h,r(h))}})}function Pt({baseline:t,current:e,theme:n,languageExtension:l}){const i=T.useRef(null);return T.useEffect(()=>{const r=i.current;if(!r)return;const s=[B.editable.of(!1),ne.readOnly.of(!0),B.lineWrapping,...n==="dark"?[qt()]:[],...l],o=new Et({a:{doc:t,extensions:s},b:{doc:e,extensions:s},parent:r,collapseUnchanged:{margin:3,minSize:4},highlightChanges:!0,gutter:!0});return()=>o.destroy()},[t,e,n,l]),J.jsx("div",{ref:i,className:"cm-diff-split h-full overflow-auto text-sm"})}function qt(){return B.theme({"&":{backgroundColor:"transparent",color:"inherit"}},{dark:!0})}export{Kt as CodeMirrorDiff};
@@ -1 +1 @@
1
- import{r as n,j as f}from"./index-C8-dwIPp.js";import{R as l}from"./index-CQrM6oF9.js";import{m as a,n as c,E as x}from"./index-gbNK9zj5.js";function j({value:u,editable:t,filename:i,languageHint:e,theme:h,onChange:m}){const[g,r]=n.useState([]);return n.useEffect(()=>{let s=!1;const o=e?a.matchLanguageName(c,e,!0):a.matchFilename(c,i);if(!o){r([]);return}return o.load().then(p=>{s||r([p])}).catch(()=>{s||r([])}),()=>{s=!0}},[i,e]),f.jsx(l,{value:u,editable:t,readOnly:!t,onChange:m,theme:h,height:"100%",className:"desktop:select-text h-full text-sm",extensions:[x.lineWrapping,...g],basicSetup:{highlightActiveLine:t,highlightActiveLineGutter:t}})}export{j as CodeMirrorEditor};
1
+ import{r as n,j as f}from"./index-Dc5cpBoO.js";import{R as l}from"./index-CBm3whA-.js";import{m as a,n as c,E as x}from"./index-BUOcbPfv.js";function j({value:u,editable:t,filename:i,languageHint:e,theme:h,onChange:m}){const[g,r]=n.useState([]);return n.useEffect(()=>{let s=!1;const o=e?a.matchLanguageName(c,e,!0):a.matchFilename(c,i);if(!o){r([]);return}return o.load().then(p=>{s||r([p])}).catch(()=>{s||r([])}),()=>{s=!0}},[i,e]),f.jsx(l,{value:u,editable:t,readOnly:!t,onChange:m,theme:h,height:"100%",className:"desktop:select-text h-full text-sm",extensions:[x.lineWrapping,...g],basicSetup:{highlightActiveLine:t,highlightActiveLineGutter:t}})}export{j as CodeMirrorEditor};
@@ -1 +1 @@
1
- import{a1 as A,a3 as E,a4 as k,fn as I,fo as $,fp as R,fq as j,fr as o,fs as q,ft as P,fu as z,r as p,j as t,I as y,B as v,G as w,fv as U,e as W,Q as F,R as X,C as K,U as Q,f as B,a7 as H}from"./index-C8-dwIPp.js";function G(){const e=A(),s=E();return k({mutationFn:({agentId:n,body:a})=>e.createCommitment(n,a),onSettled:()=>s.invalidateQueries({queryKey:I.all})})}function Z(){const e=A(),s=E();return k({mutationFn:({id:n,body:a})=>e.updateCommitment(n,a),onSettled:()=>s.invalidateQueries({queryKey:I.all})})}$();const _=300,J=500,O=200,M="external:",T=R(["open","kept","missed","dropped"]).openapi("CommitmentState"),V=j({id:o(),agentId:o(),to:o().nullable(),what:o(),dueAt:o().nullable(),state:T,overdue:q(),sourceSessionId:o().nullable(),sourceRoomEntryId:o().nullable(),createdAt:o(),closedAt:o().nullable(),note:o().nullable()}).openapi("Commitment"),L=o().datetime({offset:!0});j({what:o().trim().min(1).max(_),to:o().trim().min(1).max(O).optional(),dueAt:L.optional()}).openapi("CreateCommitmentRequest");j({state:T,dueAt:L.nullable().optional(),note:o().trim().max(J).optional(),from:T.optional()}).openapi("UpdateCommitmentRequest");const Y=500;j({agentId:o().min(1).optional(),state:T.optional(),to:o().min(1).optional(),limit:P().int().min(1).max(Y).optional()}).openapi("ListCommitmentsQuery");j({commitments:z(V)}).openapi("ListCommitmentsResponse");function ee(e,s=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const a=n.getTime()<s.getTime()?"Overdue ·":"Due",d=n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n.toDateString()===s.toDateString()?`${a} ${d}`:Math.abs(n.getTime()-s.getTime())/864e5<6?`${a} ${n.toLocaleDateString(void 0,{weekday:"short"})} ${d}`:`${a} ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`}function te(e,s){return e?e.startsWith(M)?`To ${e.slice(M.length)}`:`To ${(s==null?void 0:s(e))??e}`:null}function se(e){return{open:e.filter(s=>s.state==="open"),closed:e.filter(s=>s.state!=="open")}}const ae={kept:"Kept",missed:"Missed",dropped:"Dropped"};function de(e){var n;const s=new Map;for(const a of e)s.set(a.id,a.displayName),(n=a.agent)!=null&&n.manifestId&&s.set(a.agent.manifestId,a.displayName);return a=>s.get(a)}const ne=6e4;function oe(){const e=new Date;return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function ie({agentId:e,onDone:s}){var m;const n=G(),[a,d]=p.useState(""),[r,l]=p.useState(""),u=p.useId(),g=p.useId(),x=a.trim(),N=n.isError&&((m=n.error)==null?void 0:m.code)==="PAST_DUE",h=r?new Date(r).getTime():null,[c,S]=p.useState(!1),[b]=p.useState(oe);function i(C){if(C.preventDefault(),!x||c)return;const f=h!==null?new Date(h).toISOString():void 0;n.mutate({agentId:e,body:{what:x,...f?{dueAt:f}:{}}},{onSuccess:s})}return t.jsxs("form",{onSubmit:i,"data-slot":"add-commitment-form",className:"flex flex-col gap-2 rounded-md border p-3",children:[t.jsx("label",{htmlFor:u,className:"text-xs font-medium",children:"What was promised"}),t.jsx(y,{id:u,value:a,maxLength:_,onChange:C=>d(C.target.value),placeholder:"Send Acme the revised quote"}),t.jsx("label",{htmlFor:g,className:"text-xs font-medium",children:"Due (optional)"}),t.jsx(y,{id:g,type:"datetime-local",value:r,min:b,"aria-invalid":c||void 0,onChange:C=>{const f=C.target.value;l(f),S(f!==""&&new Date(f).getTime()<Date.now()-ne)}}),(c||N)&&t.jsx("p",{className:"text-destructive text-xs",children:"That time has passed."}),n.isError&&!N&&t.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save the commitment. Try again."}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(v,{type:"button",size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),t.jsx(v,{type:"submit",size:"sm",disabled:!x||c||n.isPending,children:"Add commitment"})]})]})}function D({commitment:e,agentName:s,nameOf:n,onClose:a,busy:d}){const r=e.state==="open",l=[s,te(e.to,n)].filter(Boolean).join(" · "),u=r?ee(e.dueAt):null;return t.jsxs("li",{"data-slot":"commitment-row","data-state":e.state,"data-overdue":e.overdue||void 0,className:"flex flex-col gap-2 rounded-md px-2 py-2 sm:flex-row sm:items-center sm:gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:w("text-sm break-words",!r&&"text-muted-foreground",e.state==="dropped"&&"line-through"),children:e.what}),(l||u||!r)&&t.jsxs("div",{className:"text-muted-foreground mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[e.state!=="open"&&t.jsx("span",{children:ae[e.state]}),l&&t.jsx("span",{className:"min-w-0 truncate",children:l}),u&&t.jsx("span",{className:w(e.overdue&&"text-destructive font-medium"),children:u})]})]}),r&&a&&t.jsxs("div",{className:"flex shrink-0 gap-1",children:[t.jsx(v,{size:"xs",variant:"outline",disabled:d,onClick:()=>a("kept"),"aria-label":`Mark kept: ${e.what}`,children:"Mark kept"}),t.jsx(v,{size:"xs",variant:"ghost",disabled:d,onClick:()=>a("dropped"),"aria-label":`Drop: ${e.what}`,children:"Drop"})]})]})}const re={kept:"Marked kept",dropped:"Commitment dropped"};function ue({agentId:e,nameOf:s,canAdd:n=!1,readOnly:a=!1,canChange:d}){var b;const r=U(e?{agentId:e}:{}),l=Z(),[u,g]=p.useState(!1),x=e===void 0;function N(i,m){l.mutate({id:i.id,body:{state:m}},{onSuccess:()=>H.success(re[m],{action:{label:"Undo",onClick:()=>l.mutate({id:i.id,body:{state:"open",from:m}})}})})}if(r.isPending)return t.jsx(W,{className:"h-16 w-full"});if(r.isError)return t.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read commitments."});const{open:h,closed:c}=se(r.data),S=l.isPending?(b=l.variables)==null?void 0:b.id:void 0;return t.jsxs("div",{"data-slot":"commitment-list",className:"flex flex-col gap-2",children:[h.length===0&&c.length===0&&!u&&t.jsx("p",{className:"text-muted-foreground text-sm",children:"No commitments yet."}),h.length>0&&t.jsx("ul",{className:"flex flex-col","aria-label":"Open commitments",children:h.map(i=>t.jsx(D,{commitment:i,agentName:x?s==null?void 0:s(i.agentId):void 0,nameOf:s,busy:S===i.id,...a||d&&!d(i)?{}:{onClose:m=>N(i,m)}},i.id))}),l.isError&&t.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t change that commitment. Try again."}),c.length>0&&t.jsxs(F,{children:[t.jsxs(X,{className:"focus-ring text-muted-foreground hover:text-foreground group flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[t.jsx(K,{"aria-hidden":!0,className:"size-3.5 transition-transform group-data-[state=open]:rotate-90"}),"Closed (",c.length,")"]}),t.jsx(Q,{children:t.jsx("ul",{className:"flex flex-col","aria-label":"Closed commitments",children:c.map(i=>t.jsx(D,{commitment:i,agentName:x?s==null?void 0:s(i.agentId):void 0,nameOf:s},i.id))})})]}),n&&!a&&e&&u&&t.jsx(ie,{agentId:e,onDone:()=>g(!1)}),n&&!a&&e&&!u&&t.jsxs(v,{size:"sm",variant:"ghost",className:"self-start",onClick:()=>g(!0),children:[t.jsx(B,{"aria-hidden":!0}),"Add commitment"]})]})}export{ue as C,de as r};
1
+ import{a1 as A,a3 as E,a4 as k,fA as I,fB as $,fC as P,fD as j,fE as o,fF as R,fG as q,fH as z,r as p,j as t,I as y,B as v,G as w,fI as F,e as U,O as W,Q as X,C as B,U as K,f as Q,a7 as H}from"./index-Dc5cpBoO.js";function G(){const e=A(),s=E();return k({mutationFn:({agentId:n,body:a})=>e.createCommitment(n,a),onSettled:()=>s.invalidateQueries({queryKey:I.all})})}function O(){const e=A(),s=E();return k({mutationFn:({id:n,body:a})=>e.updateCommitment(n,a),onSettled:()=>s.invalidateQueries({queryKey:I.all})})}$();const _=300,Z=500,J=200,D="external:",T=P(["open","kept","missed","dropped"]).openapi("CommitmentState"),V=j({id:o(),agentId:o(),to:o().nullable(),what:o(),dueAt:o().nullable(),state:T,overdue:R(),sourceSessionId:o().nullable(),sourceRoomEntryId:o().nullable(),createdAt:o(),closedAt:o().nullable(),note:o().nullable()}).openapi("Commitment"),L=o().datetime({offset:!0});j({what:o().trim().min(1).max(_),to:o().trim().min(1).max(J).optional(),dueAt:L.optional()}).openapi("CreateCommitmentRequest");j({state:T,dueAt:L.nullable().optional(),note:o().trim().max(Z).optional(),from:T.optional()}).openapi("UpdateCommitmentRequest");const Y=500;j({agentId:o().min(1).optional(),state:T.optional(),to:o().min(1).optional(),limit:q().int().min(1).max(Y).optional()}).openapi("ListCommitmentsQuery");j({commitments:z(V)}).openapi("ListCommitmentsResponse");function ee(e,s=new Date){if(!e)return null;const n=new Date(e);if(Number.isNaN(n.getTime()))return null;const a=n.getTime()<s.getTime()?"Overdue ·":"Due",d=n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n.toDateString()===s.toDateString()?`${a} ${d}`:Math.abs(n.getTime()-s.getTime())/864e5<6?`${a} ${n.toLocaleDateString(void 0,{weekday:"short"})} ${d}`:`${a} ${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`}function te(e,s){return e?e.startsWith(D)?`To ${e.slice(D.length)}`:`To ${(s==null?void 0:s(e))??e}`:null}function se(e){return{open:e.filter(s=>s.state==="open"),closed:e.filter(s=>s.state!=="open")}}const ae={kept:"Kept",missed:"Missed",dropped:"Dropped"};function de(e){var n;const s=new Map;for(const a of e)s.set(a.id,a.displayName),(n=a.agent)!=null&&n.manifestId&&s.set(a.agent.manifestId,a.displayName);return a=>s.get(a)}const ne=6e4;function oe(){const e=new Date;return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function ie({agentId:e,onDone:s}){var m;const n=G(),[a,d]=p.useState(""),[r,l]=p.useState(""),u=p.useId(),g=p.useId(),x=a.trim(),N=n.isError&&((m=n.error)==null?void 0:m.code)==="PAST_DUE",h=r?new Date(r).getTime():null,[c,S]=p.useState(!1),[b]=p.useState(oe);function i(C){if(C.preventDefault(),!x||c)return;const f=h!==null?new Date(h).toISOString():void 0;n.mutate({agentId:e,body:{what:x,...f?{dueAt:f}:{}}},{onSuccess:s})}return t.jsxs("form",{onSubmit:i,"data-slot":"add-commitment-form",className:"flex flex-col gap-2 rounded-md border p-3",children:[t.jsx("label",{htmlFor:u,className:"text-xs font-medium",children:"What was promised"}),t.jsx(y,{id:u,value:a,maxLength:_,onChange:C=>d(C.target.value),placeholder:"Send Acme the revised quote"}),t.jsx("label",{htmlFor:g,className:"text-xs font-medium",children:"Due (optional)"}),t.jsx(y,{id:g,type:"datetime-local",value:r,min:b,"aria-invalid":c||void 0,onChange:C=>{const f=C.target.value;l(f),S(f!==""&&new Date(f).getTime()<Date.now()-ne)}}),(c||N)&&t.jsx("p",{className:"text-destructive text-xs",children:"That time has passed."}),n.isError&&!N&&t.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save the commitment. Try again."}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(v,{type:"button",size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),t.jsx(v,{type:"submit",size:"sm",disabled:!x||c||n.isPending,children:"Add commitment"})]})]})}function M({commitment:e,agentName:s,nameOf:n,onClose:a,busy:d}){const r=e.state==="open",l=[s,te(e.to,n)].filter(Boolean).join(" · "),u=r?ee(e.dueAt):null;return t.jsxs("li",{"data-slot":"commitment-row","data-state":e.state,"data-overdue":e.overdue||void 0,className:"flex flex-col gap-2 rounded-md px-2 py-2 sm:flex-row sm:items-center sm:gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:w("text-sm break-words",!r&&"text-muted-foreground",e.state==="dropped"&&"line-through"),children:e.what}),(l||u||!r)&&t.jsxs("div",{className:"text-muted-foreground mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[e.state!=="open"&&t.jsx("span",{children:ae[e.state]}),l&&t.jsx("span",{className:"min-w-0 truncate",children:l}),u&&t.jsx("span",{className:w(e.overdue&&"text-destructive font-medium"),children:u})]})]}),r&&a&&t.jsxs("div",{className:"flex shrink-0 gap-1",children:[t.jsx(v,{size:"xs",variant:"outline",disabled:d,onClick:()=>a("kept"),"aria-label":`Mark kept: ${e.what}`,children:"Mark kept"}),t.jsx(v,{size:"xs",variant:"ghost",disabled:d,onClick:()=>a("dropped"),"aria-label":`Drop: ${e.what}`,children:"Drop"})]})]})}const re={kept:"Marked kept",dropped:"Commitment dropped"};function ue({agentId:e,nameOf:s,canAdd:n=!1,readOnly:a=!1,canChange:d}){var b;const r=F(e?{agentId:e}:{}),l=O(),[u,g]=p.useState(!1),x=e===void 0;function N(i,m){l.mutate({id:i.id,body:{state:m}},{onSuccess:()=>H.success(re[m],{action:{label:"Undo",onClick:()=>l.mutate({id:i.id,body:{state:"open",from:m}})}})})}if(r.isPending)return t.jsx(U,{className:"h-16 w-full"});if(r.isError)return t.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read commitments."});const{open:h,closed:c}=se(r.data),S=l.isPending?(b=l.variables)==null?void 0:b.id:void 0;return t.jsxs("div",{"data-slot":"commitment-list",className:"flex flex-col gap-2",children:[h.length===0&&c.length===0&&!u&&t.jsx("p",{className:"text-muted-foreground text-sm",children:"No commitments yet."}),h.length>0&&t.jsx("ul",{className:"flex flex-col","aria-label":"Open commitments",children:h.map(i=>t.jsx(M,{commitment:i,agentName:x?s==null?void 0:s(i.agentId):void 0,nameOf:s,busy:S===i.id,...a||d&&!d(i)?{}:{onClose:m=>N(i,m)}},i.id))}),l.isError&&t.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t change that commitment. Try again."}),c.length>0&&t.jsxs(W,{children:[t.jsxs(X,{className:"focus-ring text-muted-foreground hover:text-foreground group flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[t.jsx(B,{"aria-hidden":!0,className:"size-3.5 transition-transform group-data-[state=open]:rotate-90"}),"Closed (",c.length,")"]}),t.jsx(K,{children:t.jsx("ul",{className:"flex flex-col","aria-label":"Closed commitments",children:c.map(i=>t.jsx(M,{commitment:i,agentName:x?s==null?void 0:s(i.agentId):void 0,nameOf:s},i.id))})})]}),n&&!a&&e&&u&&t.jsx(ie,{agentId:e,onDone:()=>g(!1)}),n&&!a&&e&&!u&&t.jsxs(v,{size:"sm",variant:"ghost",className:"self-start",onClick:()=>g(!0),children:[t.jsx(Q,{"aria-hidden":!0}),"Add commitment"]})]})}export{ue as C,de as r};
@@ -1 +1 @@
1
- import{r,d,j as m}from"./index-C8-dwIPp.js";import{r as c,C as l}from"./CommitmentList-CDocwl5K.js";function u({member:s,roster:t}){var o;const e=(o=s.agent)==null?void 0:o.manifestId,i=r.useMemo(()=>c(t),[t]),n=d(s,t),a=n==="managed"||n==="system";return e?m.jsx("div",{className:"min-h-0 flex-1","data-slot":"profile-commitments",children:m.jsx(l,{agentId:e,nameOf:i,canAdd:a,readOnly:!a})}):null}export{u as CommitmentsPage};
1
+ import{r,d,j as m}from"./index-Dc5cpBoO.js";import{r as c,C as l}from"./CommitmentList-i-IZ4gbr.js";function u({member:s,roster:t}){var o;const e=(o=s.agent)==null?void 0:o.manifestId,i=r.useMemo(()=>c(t),[t]),n=d(s,t),a=n==="managed"||n==="system";return e?m.jsx("div",{className:"min-h-0 flex-1","data-slot":"profile-commitments",children:m.jsx(l,{agentId:e,nameOf:i,canAdd:a,readOnly:!a})}):null}export{u as CommitmentsPage};
@@ -1,4 +1,4 @@
1
- import{W as g,a1 as x,aV as o,r as C,j as e,B as d,Y as P}from"./index-C8-dwIPp.js";import{r as m,u as f,C as w}from"./ComputerViewer-BA-9lBBN.js";import{u as v}from"./use-is-below-desktop-BhzXZsbH.js";/**
1
+ import{W as g,a1 as x,aW as o,r as C,j as e,B as d,Y as P}from"./index-Dc5cpBoO.js";import{r as m,u as f,C as w}from"./ComputerViewer-D7tPmpY5.js";import{u as v}from"./use-is-below-desktop-DmekpHAF.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- var R=Object.defineProperty;var S=(i,t,e)=>t in i?R(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>S(i,typeof t!="symbol"?t+"":t,e);import{a1 as D,a2 as F,r as h,j as a,I as O,B as y,G as I}from"./index-C8-dwIPp.js";const Y=["computer","local"];function z(){const i=D();return F({queryKey:Y,queryFn:()=>i.getComputer(),networkMode:"always",refetchInterval:2e3,retry:!1})}class B{constructor(t,e,r){o(this,"snapshot",{frame:null,lease:null,owner:null,busy:!1,error:!1,controlError:!1});o(this,"listeners",new Map);o(this,"timer");o(this,"epoch",0);o(this,"acquisition",0);o(this,"queue",Promise.resolve());o(this,"movePending",!1);o(this,"polling",!1);o(this,"retired",!1);o(this,"pendingOwner",null);o(this,"frameRequest",null);o(this,"getSnapshot",()=>this.snapshot);o(this,"subscribe",(t,e)=>(this.listeners.set(t,e),!this.polling&&!this.retired&&this.start(),()=>{this.listeners.delete(t),this.releaseFor(t),this.listeners.size===0&&(this.epoch+=1,this.polling=!1,clearTimeout(this.timer),this.update({frame:null}))}));o(this,"release",async()=>{const t=this.snapshot.lease;this.drop();const e=this.acquisition;if(t)try{await this.transport.releaseComputerControl(t.leaseId)}catch{e===this.acquisition&&this.update({error:!0,frame:null})}});o(this,"releaseFor",t=>this.snapshot.owner===t||this.pendingOwner===t?this.release():Promise.resolve());o(this,"acquire",async t=>{if(this.retired||!this.listeners.has(t)||this.snapshot.busy||!this.snapshot.frame||this.snapshot.lease)return;const e=++this.acquisition;this.pendingOwner=t,this.update({busy:!0,controlError:!1});try{const r=await this.transport.acquireComputerControl();if(!this.listeners.has(t)||e!==this.acquisition||r.generation!==this.generation){await this.transport.releaseComputerControl(r.leaseId);return}this.update({lease:r,owner:t,controlError:!1})}catch{e===this.acquisition&&this.update({controlError:!0})}finally{e===this.acquisition&&(this.pendingOwner=null,this.update({busy:!1}))}});o(this,"send",(t,e)=>{const r=this.snapshot.lease;if(!r||this.snapshot.owner!==t||!this.listeners.has(t))return Promise.resolve(!1);const l=e.kind==="pointer"&&e.action==="move";if(l&&this.movePending)return Promise.resolve(!1);l&&(this.movePending=!0);const n=this.queue.then(async()=>{if(this.snapshot.lease!==r||this.snapshot.owner!==t||!this.listeners.has(t))return l&&(this.movePending=!1),!1;try{return await this.transport.sendComputerInput({...e,...r}),!0}catch{return this.snapshot.lease===r&&this.snapshot.owner===t&&(this.update({error:!0,frame:null}),await this.release()),!1}finally{l&&(this.movePending=!1)}});return this.queue=n.then(()=>{}),n});this.transport=t,this.generation=e,this.previous=r}update(t){this.snapshot={...this.snapshot,...t};for(const e of this.listeners.values())e()}retire(){this.retired=!0,this.epoch+=1,this.polling=!1,clearTimeout(this.timer),this.release(),this.update({frame:null,error:!0})}start(){var r;(r=this.previous)==null||r.retire(),this.previous=void 0,this.polling=!0;const t=++this.epoch,e=async()=>{const l=this.snapshot.lease;try{const n=this.frameRequest??this.transport.getComputerFrame();this.frameRequest=n;const u=await n.finally(()=>{this.frameRequest===n&&(this.frameRequest=null)});if(t!==this.epoch)return;u.generation!==this.generation?(this.update({frame:null,error:!0}),this.release()):(u.controlledByYou===!1&&l&&this.snapshot.lease===l&&this.drop(),this.update({frame:u,error:!1}))}catch{if(t!==this.epoch)return;this.update({frame:null,error:!0}),this.release()}t===this.epoch&&(this.timer=setTimeout(()=>void e(),500))};e()}drop(){this.acquisition+=1,this.movePending=!1,this.pendingOwner=null,this.update({lease:null,owner:null,busy:!1,controlError:!1})}}const k=new WeakMap;function Q(i){var t;return((t=k.get(i))==null?void 0:t.release())??Promise.resolve()}function K(i,t){let e=k.get(i);return(!e||e.generation!==t)&&(e=new B(i,t,e),k.set(i,e)),e}function L(i){const t=D(),e=h.useId(),r=h.useMemo(()=>K(t,i),[t,i]),l=h.useCallback(u=>r.subscribe(e,u),[r,e]),n=h.useSyncExternalStore(l,r.getSnapshot);return{...n,lease:n.owner===e?n.lease:null,controlledElsewhere:!!(n.lease&&n.owner!==e),session:r,owner:e}}function U({send:i}){const[t,e]=h.useState(""),[r,l]=h.useState(!1),n=h.useRef(!0);return h.useEffect(()=>(n.current=!0,()=>{n.current=!1}),[]),a.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{if(u.preventDefault(),!t||r)return;const m=t;l(!0),i({kind:"text",text:m}).then(c=>{n.current&&c&&e(d=>d===m?"":d)}).finally(()=>{n.current&&l(!1)})},children:[a.jsx(O,{"aria-label":"Type on computer",placeholder:"Type on computer",value:t,maxLength:4096,autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1,className:"min-w-0 flex-1",onChange:u=>e(u.target.value)}),a.jsx(y,{type:"submit","aria-disabled":r||!t,"aria-busy":r,children:"Type"}),a.jsx(y,{type:"button",variant:"outline",onClick:()=>{i({kind:"key",key:"Enter",action:"down"}),i({kind:"key",key:"Enter",action:"up"})},children:"Enter"})]})}function _({generation:i,onClose:t}){const{frame:e,lease:r,busy:l,error:n,controlError:u,controlledElsewhere:m,session:c,owner:d}=L(i),E=h.useRef(null),q=h.useId(),v=c.release,x=s=>c.send(d,s),N=async()=>{var s;await c.acquire(d),(s=E.current)==null||s.focus()};h.useEffect(()=>{const s=()=>{c.releaseFor(d)},g=()=>{document.hidden&&s()};return window.addEventListener("blur",s),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",g)}},[c,d,v]);const w=(s,g)=>{var j,P,T,M;if(!r||!e)return;const p=s.currentTarget.getBoundingClientRect();if(!p.width||!p.height)return;const f=Math.min(p.width/e.width,p.height/e.height),b=p.left+(p.width-e.width*f)/2,C=p.top+(p.height-e.height*f)/2;(s.clientX<b||s.clientX>b+e.width*f||s.clientY<C||s.clientY>C+e.height*f)&&!((P=(j=s.currentTarget).hasPointerCapture)!=null&&P.call(j,s.pointerId))||(s.preventDefault(),g==="down"&&(s.currentTarget.focus(),(M=(T=s.currentTarget).setPointerCapture)==null||M.call(T,s.pointerId)),x({kind:"pointer",action:g,button:Math.max(0,Math.min(2,s.button)),x:Math.max(0,Math.min(e.width-1,Math.floor((s.clientX-b)/f))),y:Math.max(0,Math.min(e.height-1,Math.floor((s.clientY-C)/f)))}))};return a.jsxs("section",{"data-slot":"computer-viewer","aria-label":"Computer desktop",className:"flex h-full min-h-0 flex-col gap-2 overflow-auto p-3",onBlur:s=>{s.currentTarget.contains(s.relatedTarget)||c.releaseFor(d)},children:[a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[a.jsx("p",{className:"text-muted-foreground mr-auto text-sm",role:"status",children:n?"Disconnected":r?"You have control":e?"Watching":"Connecting…"}),r?a.jsx(y,{variant:"outline",onClick:()=>void v(),children:"Return control"}):a.jsx(y,{variant:"outline",disabled:!e||m,"aria-disabled":l||!e||m,"aria-busy":l,onClick:()=>void N(),children:"Take over"}),t&&a.jsx(y,{variant:"ghost",onClick:t,children:"Close view"})]}),n&&a.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Disconnected. Trying to reconnect…"}),u&&!n&&a.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t take control. Try again."}),e?a.jsx("div",{ref:E,role:"application","aria-label":"Computer desktop control","aria-describedby":q,tabIndex:r?0:-1,className:I("focus-visible:ring-ring block min-h-20 w-full flex-1 rounded-md outline-none select-none focus-visible:ring-2",r?"touch-none":"touch-pan-y"),onDragStart:s=>s.preventDefault(),onContextMenu:s=>s.preventDefault(),onPointerDown:s=>w(s,"down"),onPointerMove:s=>w(s,"move"),onPointerUp:s=>w(s,"up"),onPointerCancel:()=>void c.releaseFor(d),onKeyDown:s=>{if(r){if(s.preventDefault(),s.key==="Escape"&&s.ctrlKey&&s.shiftKey){v();return}s.repeat||x({kind:"key",key:s.key,action:"down"})}},onKeyUp:s=>{r&&(s.preventDefault(),x({kind:"key",key:s.key,action:"up"}))},children:a.jsx("img",{src:e.dataUrl,width:e.width,height:e.height,alt:"Live computer desktop",draggable:!1,className:"block h-full w-full rounded-md object-contain"})}):a.jsx("p",{role:"status",className:"text-muted-foreground py-10 text-center text-sm",children:"Waiting for the desktop…"}),r&&a.jsx(U,{send:x},r.leaseId),a.jsx("p",{id:q,className:I("text-muted-foreground shrink-0 text-xs",!r&&"sr-only"),children:"Press Control + Shift + Escape to return control."}),t&&a.jsx("p",{className:"text-muted-foreground shrink-0 text-xs",children:"Closing this view keeps the computer running."})]})}export{_ as C,Y as a,Q as r,z as u};
1
+ var R=Object.defineProperty;var S=(i,t,e)=>t in i?R(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>S(i,typeof t!="symbol"?t+"":t,e);import{a1 as D,a2 as F,r as h,j as a,I as O,B as y,G as I}from"./index-Dc5cpBoO.js";const Y=["computer","local"];function z(){const i=D();return F({queryKey:Y,queryFn:()=>i.getComputer(),networkMode:"always",refetchInterval:2e3,retry:!1})}class B{constructor(t,e,r){o(this,"snapshot",{frame:null,lease:null,owner:null,busy:!1,error:!1,controlError:!1});o(this,"listeners",new Map);o(this,"timer");o(this,"epoch",0);o(this,"acquisition",0);o(this,"queue",Promise.resolve());o(this,"movePending",!1);o(this,"polling",!1);o(this,"retired",!1);o(this,"pendingOwner",null);o(this,"frameRequest",null);o(this,"getSnapshot",()=>this.snapshot);o(this,"subscribe",(t,e)=>(this.listeners.set(t,e),!this.polling&&!this.retired&&this.start(),()=>{this.listeners.delete(t),this.releaseFor(t),this.listeners.size===0&&(this.epoch+=1,this.polling=!1,clearTimeout(this.timer),this.update({frame:null}))}));o(this,"release",async()=>{const t=this.snapshot.lease;this.drop();const e=this.acquisition;if(t)try{await this.transport.releaseComputerControl(t.leaseId)}catch{e===this.acquisition&&this.update({error:!0,frame:null})}});o(this,"releaseFor",t=>this.snapshot.owner===t||this.pendingOwner===t?this.release():Promise.resolve());o(this,"acquire",async t=>{if(this.retired||!this.listeners.has(t)||this.snapshot.busy||!this.snapshot.frame||this.snapshot.lease)return;const e=++this.acquisition;this.pendingOwner=t,this.update({busy:!0,controlError:!1});try{const r=await this.transport.acquireComputerControl();if(!this.listeners.has(t)||e!==this.acquisition||r.generation!==this.generation){await this.transport.releaseComputerControl(r.leaseId);return}this.update({lease:r,owner:t,controlError:!1})}catch{e===this.acquisition&&this.update({controlError:!0})}finally{e===this.acquisition&&(this.pendingOwner=null,this.update({busy:!1}))}});o(this,"send",(t,e)=>{const r=this.snapshot.lease;if(!r||this.snapshot.owner!==t||!this.listeners.has(t))return Promise.resolve(!1);const l=e.kind==="pointer"&&e.action==="move";if(l&&this.movePending)return Promise.resolve(!1);l&&(this.movePending=!0);const n=this.queue.then(async()=>{if(this.snapshot.lease!==r||this.snapshot.owner!==t||!this.listeners.has(t))return l&&(this.movePending=!1),!1;try{return await this.transport.sendComputerInput({...e,...r}),!0}catch{return this.snapshot.lease===r&&this.snapshot.owner===t&&(this.update({error:!0,frame:null}),await this.release()),!1}finally{l&&(this.movePending=!1)}});return this.queue=n.then(()=>{}),n});this.transport=t,this.generation=e,this.previous=r}update(t){this.snapshot={...this.snapshot,...t};for(const e of this.listeners.values())e()}retire(){this.retired=!0,this.epoch+=1,this.polling=!1,clearTimeout(this.timer),this.release(),this.update({frame:null,error:!0})}start(){var r;(r=this.previous)==null||r.retire(),this.previous=void 0,this.polling=!0;const t=++this.epoch,e=async()=>{const l=this.snapshot.lease;try{const n=this.frameRequest??this.transport.getComputerFrame();this.frameRequest=n;const u=await n.finally(()=>{this.frameRequest===n&&(this.frameRequest=null)});if(t!==this.epoch)return;u.generation!==this.generation?(this.update({frame:null,error:!0}),this.release()):(u.controlledByYou===!1&&l&&this.snapshot.lease===l&&this.drop(),this.update({frame:u,error:!1}))}catch{if(t!==this.epoch)return;this.update({frame:null,error:!0}),this.release()}t===this.epoch&&(this.timer=setTimeout(()=>void e(),500))};e()}drop(){this.acquisition+=1,this.movePending=!1,this.pendingOwner=null,this.update({lease:null,owner:null,busy:!1,controlError:!1})}}const k=new WeakMap;function Q(i){var t;return((t=k.get(i))==null?void 0:t.release())??Promise.resolve()}function K(i,t){let e=k.get(i);return(!e||e.generation!==t)&&(e=new B(i,t,e),k.set(i,e)),e}function L(i){const t=D(),e=h.useId(),r=h.useMemo(()=>K(t,i),[t,i]),l=h.useCallback(u=>r.subscribe(e,u),[r,e]),n=h.useSyncExternalStore(l,r.getSnapshot);return{...n,lease:n.owner===e?n.lease:null,controlledElsewhere:!!(n.lease&&n.owner!==e),session:r,owner:e}}function U({send:i}){const[t,e]=h.useState(""),[r,l]=h.useState(!1),n=h.useRef(!0);return h.useEffect(()=>(n.current=!0,()=>{n.current=!1}),[]),a.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{if(u.preventDefault(),!t||r)return;const m=t;l(!0),i({kind:"text",text:m}).then(c=>{n.current&&c&&e(d=>d===m?"":d)}).finally(()=>{n.current&&l(!1)})},children:[a.jsx(O,{"aria-label":"Type on computer",placeholder:"Type on computer",value:t,maxLength:4096,autoComplete:"off",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1,className:"min-w-0 flex-1",onChange:u=>e(u.target.value)}),a.jsx(y,{type:"submit","aria-disabled":r||!t,"aria-busy":r,children:"Type"}),a.jsx(y,{type:"button",variant:"outline",onClick:()=>{i({kind:"key",key:"Enter",action:"down"}),i({kind:"key",key:"Enter",action:"up"})},children:"Enter"})]})}function _({generation:i,onClose:t}){const{frame:e,lease:r,busy:l,error:n,controlError:u,controlledElsewhere:m,session:c,owner:d}=L(i),E=h.useRef(null),q=h.useId(),v=c.release,x=s=>c.send(d,s),N=async()=>{var s;await c.acquire(d),(s=E.current)==null||s.focus()};h.useEffect(()=>{const s=()=>{c.releaseFor(d)},g=()=>{document.hidden&&s()};return window.addEventListener("blur",s),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",g)}},[c,d,v]);const w=(s,g)=>{var j,P,T,M;if(!r||!e)return;const p=s.currentTarget.getBoundingClientRect();if(!p.width||!p.height)return;const f=Math.min(p.width/e.width,p.height/e.height),b=p.left+(p.width-e.width*f)/2,C=p.top+(p.height-e.height*f)/2;(s.clientX<b||s.clientX>b+e.width*f||s.clientY<C||s.clientY>C+e.height*f)&&!((P=(j=s.currentTarget).hasPointerCapture)!=null&&P.call(j,s.pointerId))||(s.preventDefault(),g==="down"&&(s.currentTarget.focus(),(M=(T=s.currentTarget).setPointerCapture)==null||M.call(T,s.pointerId)),x({kind:"pointer",action:g,button:Math.max(0,Math.min(2,s.button)),x:Math.max(0,Math.min(e.width-1,Math.floor((s.clientX-b)/f))),y:Math.max(0,Math.min(e.height-1,Math.floor((s.clientY-C)/f)))}))};return a.jsxs("section",{"data-slot":"computer-viewer","aria-label":"Computer desktop",className:"flex h-full min-h-0 flex-col gap-2 overflow-auto p-3",onBlur:s=>{s.currentTarget.contains(s.relatedTarget)||c.releaseFor(d)},children:[a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[a.jsx("p",{className:"text-muted-foreground mr-auto text-sm",role:"status",children:n?"Disconnected":r?"You have control":e?"Watching":"Connecting…"}),r?a.jsx(y,{variant:"outline",onClick:()=>void v(),children:"Return control"}):a.jsx(y,{variant:"outline",disabled:!e||m,"aria-disabled":l||!e||m,"aria-busy":l,onClick:()=>void N(),children:"Take over"}),t&&a.jsx(y,{variant:"ghost",onClick:t,children:"Close view"})]}),n&&a.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Disconnected. Trying to reconnect…"}),u&&!n&&a.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t take control. Try again."}),e?a.jsx("div",{ref:E,role:"application","aria-label":"Computer desktop control","aria-describedby":q,tabIndex:r?0:-1,className:I("focus-visible:ring-ring block min-h-20 w-full flex-1 rounded-md outline-none select-none focus-visible:ring-2",r?"touch-none":"touch-pan-y"),onDragStart:s=>s.preventDefault(),onContextMenu:s=>s.preventDefault(),onPointerDown:s=>w(s,"down"),onPointerMove:s=>w(s,"move"),onPointerUp:s=>w(s,"up"),onPointerCancel:()=>void c.releaseFor(d),onKeyDown:s=>{if(r){if(s.preventDefault(),s.key==="Escape"&&s.ctrlKey&&s.shiftKey){v();return}s.repeat||x({kind:"key",key:s.key,action:"down"})}},onKeyUp:s=>{r&&(s.preventDefault(),x({kind:"key",key:s.key,action:"up"}))},children:a.jsx("img",{src:e.dataUrl,width:e.width,height:e.height,alt:"Live computer desktop",draggable:!1,className:"block h-full w-full rounded-md object-contain"})}):a.jsx("p",{role:"status",className:"text-muted-foreground py-10 text-center text-sm",children:"Waiting for the desktop…"}),r&&a.jsx(U,{send:x},r.leaseId),a.jsx("p",{id:q,className:I("text-muted-foreground shrink-0 text-xs",!r&&"sr-only"),children:"Press Control + Shift + Escape to return control."}),t&&a.jsx("p",{className:"text-muted-foreground shrink-0 text-xs",children:"Closing this view keeps the computer running."})]})}export{_ as C,Y as a,Q as r,z as u};
@@ -1 +1 @@
1
- import{j as s,e as x,B as o,Y as m,Z as u,_ as h,$ as g}from"./index-C8-dwIPp.js";import{u as p,s as l,a as j,b as f}from"./access-copy-CcG3wpsK.js";import{Q as N}from"./query-error-state-CfJfYpa3.js";const v={agent:"From the agent",this_chat:"Only in this chat"};function k({agentId:n,onManage:e}){var i;const a=p(n);if(a.isPending)return s.jsx(x,{className:"h-24 w-full rounded-lg"});if(a.isError)return s.jsx(N,{title:"Couldn’t load account access",description:"Nothing changed. Try again.",onRetry:()=>void a.refetch(),isRetrying:a.isFetching});const c=((i=a.data)==null?void 0:i.connections)??[];return s.jsxs("section",{"aria-labelledby":"agent-account-access",className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{id:"agent-account-access",className:"text-sm font-semibold",children:"Account access"}),s.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Accounts this agent can use."})]}),e&&s.jsxs(o,{variant:"ghost",size:"sm",onClick:e,children:["Manage",s.jsx(m,{className:"size-3.5","aria-hidden":!0})]})]}),c.length===0?s.jsxs("div",{className:"bg-muted/40 rounded-lg p-4 text-sm",children:[s.jsx("p",{className:"font-medium",children:"No account access"}),s.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Give access from the Connections page."})]}):s.jsx("ul",{className:"space-y-1.5",children:c.map(t=>{const r=t.readiness.state==="ready";return s.jsxs("li",{"data-testid":`agent-connection-${t.connectionId}`,className:"bg-muted/40 flex min-h-11 items-center gap-3 rounded-lg px-3 py-2",children:[s.jsx(u,{iconKey:t.toolkit,displayName:l(t.toolkit),className:"size-7"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"truncate text-sm font-medium",children:[l(t.toolkit)," (",t.label,")"]}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.operationRevisionIds.length," approved"," ",t.operationRevisionIds.length===1?"action":"actions",t.everyAgent&&" · given to every agent"]})]}),s.jsx(h,{size:"xs",variant:r?"secondary":"outline",title:r?void 0:t.readiness.copy.owner,children:r?"Available":"Unavailable"})]},t.connectionId)})})]})}const y="This only affects this chat. Turning an app back on never adds access.",C="Couldn’t change access for this chat. Try again.";function b(n){return(n==null?void 0:n.code)==="session_access_other_agent"?n.message:C}function _({sessionId:n,onManage:e,emptyAction:a,footer:c}){var r;const i=j(n);if(i.isPending)return s.jsx(x,{className:"h-16 w-full rounded-lg"});if(i.isError)return s.jsxs("section",{"data-testid":"session-connectors",className:"space-y-2",children:[s.jsx("p",{role:"alert",className:"text-destructive px-1 text-xs",children:"Couldn’t load account access."}),s.jsx(o,{variant:"ghost",size:"sm",onClick:()=>void i.refetch(),children:"Try again"})]});const t=((r=i.data)==null?void 0:r.connections)??[];return s.jsxs("section",{"data-testid":"session-connectors","aria-labelledby":"session-account-access",className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 pb-1",children:[s.jsx("h3",{id:"session-account-access",className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Connections"}),e&&s.jsxs(o,{variant:"ghost",size:"xs",onClick:e,children:["Manage agent access",s.jsx(m,{className:"size-3","aria-hidden":!0})]})]}),t.length===0?s.jsxs("div",{className:"bg-muted/40 space-y-2 rounded-md px-2.5 py-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"No account access"}),s.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Ask this agent to request the access it needs."})]}),a]}):s.jsxs(s.Fragment,{children:[t.some(d=>d.thisChat)&&s.jsx("p",{className:"text-muted-foreground px-1 pb-1 text-xs",children:y}),t.map(d=>s.jsx(S,{sessionId:n,connection:d},d.connectionId))]}),t.length>0&&c]})}function S({sessionId:n,connection:e}){const a=f(n),c=e.readiness.state==="ready",i=`${l(e.toolkit)} (${e.label})`;return s.jsxs("div",{"data-testid":`session-connection-${e.connectionId}`,"data-reason":e.readiness.reason,className:"bg-muted/40 rounded-md px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-medium",children:i}),s.jsx(h,{size:"xs",variant:c?"secondary":"outline",children:c?v[e.source]:"Not available"})]}),s.jsx("p",{className:c?"text-muted-foreground mt-1 text-xs":"text-status-warning-fg mt-1 text-xs",children:c?`${e.operationRevisionIds.length} ${e.operationRevisionIds.length===1?"action":"actions"} available in this chat.`:e.readiness.copy.owner})]}),e.thisChat&&s.jsx(g,{"aria-label":`${i} in this chat`,"data-testid":`session-connection-switch-${e.connectionId}`,checked:e.thisChat==="on",disabled:a.isPending,onCheckedChange:t=>a.mutate({connectionId:e.connectionId,on:t}),className:"mt-0.5 shrink-0"})]}),a.isError&&e.thisChat&&s.jsx("p",{role:"alert",className:"text-destructive mt-1 text-xs",children:b(a.error)})]})}export{k as A,_ as S};
1
+ import{j as s,e as x,B as o,Y as m,Z as u,_ as h,$ as g}from"./index-Dc5cpBoO.js";import{u as p,s as l,a as j,b as f}from"./access-copy-BVzi1REx.js";import{Q as N}from"./query-error-state-BFWpEXsl.js";const v={agent:"From the agent",this_chat:"Only in this chat"};function k({agentId:n,onManage:e}){var i;const a=p(n);if(a.isPending)return s.jsx(x,{className:"h-24 w-full rounded-lg"});if(a.isError)return s.jsx(N,{title:"Couldn’t load account access",description:"Nothing changed. Try again.",onRetry:()=>void a.refetch(),isRetrying:a.isFetching});const c=((i=a.data)==null?void 0:i.connections)??[];return s.jsxs("section",{"aria-labelledby":"agent-account-access",className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h3",{id:"agent-account-access",className:"text-sm font-semibold",children:"Account access"}),s.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Accounts this agent can use."})]}),e&&s.jsxs(o,{variant:"ghost",size:"sm",onClick:e,children:["Manage",s.jsx(m,{className:"size-3.5","aria-hidden":!0})]})]}),c.length===0?s.jsxs("div",{className:"bg-muted/40 rounded-lg p-4 text-sm",children:[s.jsx("p",{className:"font-medium",children:"No account access"}),s.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Give access from the Connections page."})]}):s.jsx("ul",{className:"space-y-1.5",children:c.map(t=>{const r=t.readiness.state==="ready";return s.jsxs("li",{"data-testid":`agent-connection-${t.connectionId}`,className:"bg-muted/40 flex min-h-11 items-center gap-3 rounded-lg px-3 py-2",children:[s.jsx(u,{iconKey:t.toolkit,displayName:l(t.toolkit),className:"size-7"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"truncate text-sm font-medium",children:[l(t.toolkit)," (",t.label,")"]}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[t.operationRevisionIds.length," approved"," ",t.operationRevisionIds.length===1?"action":"actions",t.everyAgent&&" · given to every agent"]})]}),s.jsx(h,{size:"xs",variant:r?"secondary":"outline",title:r?void 0:t.readiness.copy.owner,children:r?"Available":"Unavailable"})]},t.connectionId)})})]})}const y="This only affects this chat. Turning an app back on never adds access.",C="Couldn’t change access for this chat. Try again.";function b(n){return(n==null?void 0:n.code)==="session_access_other_agent"?n.message:C}function _({sessionId:n,onManage:e,emptyAction:a,footer:c}){var r;const i=j(n);if(i.isPending)return s.jsx(x,{className:"h-16 w-full rounded-lg"});if(i.isError)return s.jsxs("section",{"data-testid":"session-connectors",className:"space-y-2",children:[s.jsx("p",{role:"alert",className:"text-destructive px-1 text-xs",children:"Couldn’t load account access."}),s.jsx(o,{variant:"ghost",size:"sm",onClick:()=>void i.refetch(),children:"Try again"})]});const t=((r=i.data)==null?void 0:r.connections)??[];return s.jsxs("section",{"data-testid":"session-connectors","aria-labelledby":"session-account-access",className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-1 pb-1",children:[s.jsx("h3",{id:"session-account-access",className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Connections"}),e&&s.jsxs(o,{variant:"ghost",size:"xs",onClick:e,children:["Manage agent access",s.jsx(m,{className:"size-3","aria-hidden":!0})]})]}),t.length===0?s.jsxs("div",{className:"bg-muted/40 space-y-2 rounded-md px-2.5 py-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"No account access"}),s.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Ask this agent to request the access it needs."})]}),a]}):s.jsxs(s.Fragment,{children:[t.some(d=>d.thisChat)&&s.jsx("p",{className:"text-muted-foreground px-1 pb-1 text-xs",children:y}),t.map(d=>s.jsx(S,{sessionId:n,connection:d},d.connectionId))]}),t.length>0&&c]})}function S({sessionId:n,connection:e}){const a=f(n),c=e.readiness.state==="ready",i=`${l(e.toolkit)} (${e.label})`;return s.jsxs("div",{"data-testid":`session-connection-${e.connectionId}`,"data-reason":e.readiness.reason,className:"bg-muted/40 rounded-md px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-medium",children:i}),s.jsx(h,{size:"xs",variant:c?"secondary":"outline",children:c?v[e.source]:"Not available"})]}),s.jsx("p",{className:c?"text-muted-foreground mt-1 text-xs":"text-status-warning-fg mt-1 text-xs",children:c?`${e.operationRevisionIds.length} ${e.operationRevisionIds.length===1?"action":"actions"} available in this chat.`:e.readiness.copy.owner})]}),e.thisChat&&s.jsx(g,{"aria-label":`${i} in this chat`,"data-testid":`session-connection-switch-${e.connectionId}`,checked:e.thisChat==="on",disabled:a.isPending,onCheckedChange:t=>a.mutate({connectionId:e.connectionId,on:t}),className:"mt-0.5 shrink-0"})]}),a.isError&&e.thisChat&&s.jsx("p",{role:"alert",className:"text-destructive mt-1 text-xs",children:b(a.error)})]})}export{k as A,_ as S};
@@ -1,6 +1,6 @@
1
- import{W as G,a1 as H,a4 as K,r,b5 as Q,j as e,G as I,bC as X,_ as L,cN as Y,cO as J,cP as ee,fO as se,fP as te,B,fQ as ae,fR as ne,fS as R,x as ie,fT as re,fU as F,fV as ce,fW as oe,fX as de,fY as le,fZ as me,f_ as ue,f$ as pe,g0 as xe,g1 as he,g2 as ge,eK as fe,eL as je,f as ye,eM as ve,g3 as U,a7 as N,ak as Ne,b as Ce,e as be}from"./index-C8-dwIPp.js";import{A as Te}from"./ConnectionAccessLists-BLLpxhn3.js";import{u as Ie}from"./use-bindings-Ds_MAC67.js";import{b as Ae,u as Se,a as we,t as ke,B as De}from"./BindingDialog-8xnsM47D.js";import{u as Re}from"./use-delete-binding-B_zHPcy8.js";import{u as Me,A as Pe}from"./AdapterSetupWizard-DfNJz5SD.js";import{u as Be}from"./use-relay-config-8mXfegbP.js";import{u as Ee}from"./use-external-adapter-catalog-7lRWtn7J.js";import"./relay-trace-schemas-Cvb7RGjg.js";import{A as _,a as P,b as ze}from"./AdapterIcon-XPLZ-NAi.js";import{R as $}from"./radio-BOcAjXVO.js";import"./access-copy-CcG3wpsK.js";import"./query-error-state-CfJfYpa3.js";import"./empty-state-CQ1oXLFa.js";import"./form-lSBktWDn.js";import"./use-adapter-catalog-RzlxX2Wa.js";import"./trust-posture-Dmk2WlZv.js";import"./markdown-content-GoymYcRL.js";/**
1
+ import{W as Z,a1 as H,a4 as Q,r,b6 as J,j as e,G as I,bD as K,_ as F,cM as X,cN as Y,cO as ee,f$ as se,g0 as te,B,g1 as ae,g2 as ne,g3 as R,x as ie,g4 as re,g5 as L,g6 as ce,g7 as oe,g8 as de,g9 as le,ga as me,gb as ue,gc as pe,gd as xe,ge,gf as he,eP as fe,eQ as je,f as ye,eR as ve,gg as U,a7 as N,ak as Ne,b as be,e as Ce}from"./index-Dc5cpBoO.js";import{A as Te}from"./ConnectionAccessLists-D6VH1vX3.js";import{u as Ie}from"./use-bindings-CsTavmf-.js";import{b as Ae,u as we,a as Se,t as ke,B as De}from"./BindingDialog-CSNjws3F.js";import{u as Re}from"./use-delete-binding-DLvdHtPD.js";import{u as Me,A as Pe}from"./AdapterSetupWizard-D9tqz7Hl.js";import{u as Be}from"./use-relay-config-D5iieBXl.js";import{u as Ee}from"./use-external-adapter-catalog-Be57G4tz.js";import"./relay-trace-schemas-DiZj_AFV.js";import{A as _,a as P,b as ze}from"./AdapterIcon-Dyq92Eup.js";import{R as $}from"./radio-Bkx216ga.js";import"./access-copy-BVzi1REx.js";import"./query-error-state-BFWpEXsl.js";import"./empty-state-BgnQDiMZ.js";import"./form-Blrb1xBU.js";import"./use-adapter-catalog-Z4MDWZAZ.js";import"./trust-posture-B-v4BWo7.js";import"./markdown-content-DPc7aD1j.js";/**
2
2
  * @license lucide-react v1.48.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const V={name:"plug-2",size:24,node:[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]};V.node;const Oe=G(V);function _e(){const a=H();return K({mutationFn:i=>a.testBinding(i),meta:{errorLabel:"Couldn’t test the connection"}})}const Le={connected:P.connected,disconnected:X.warning,error:P.error,connecting:P.starting};function Fe(a){const i=[];return a.canInitiate&&i.push("Can message first"),a.canReply||i.push("Can’t reply"),a.canReceive||i.push("Can’t receive"),i.join(" · ")}function $e({binding:a,integrationName:i,integrationIconId:y,integrationAdapterType:l,adapterState:x,errorMessage:h,chatDisplayName:g,lastMessageAt:d,onTogglePause:f,onTest:n,onEdit:m,onRemove:u}){const[t,o]=r.useState(!1),[j,v]=r.useState(!1),p=a.enabled===!1,[A,S]=r.useState(0);r.useEffect(()=>{if(!d||p)return;const C=setInterval(()=>S(s=>s+1),6e4);return()=>clearInterval(C)},[d,p]);const E=g?`${i} · ${g}`:i,w=Ae({sessionStrategy:a.sessionStrategy,chatDisplayName:g,channelType:a.channelType}),k=a.canInitiate||!a.canReply||!a.canReceive,z=k?Fe(a):"",D=r.useMemo(()=>p?"Paused: no messages delivered":d?`Last received ${Q(d).toLowerCase()}`:"No recent activity",[p,d,A]),O=async()=>{v(!0);try{await n()}finally{v(!1)}};return e.jsxs("div",{className:I("relative rounded-xl border px-4 py-3 transition-colors",x==="error"&&!p&&"border-red-500/50 bg-red-500/[0.02]",p&&"opacity-60"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(_,{iconId:y,adapterType:l,size:32}),e.jsx("span",{className:I("ring-background absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full ring-2",p?"bg-muted-foreground/40":Le[x])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:E}),p&&e.jsx(L,{variant:"secondary",children:"Paused"})]}),p?e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:D}):x==="error"&&h?e.jsx("p",{className:"text-destructive text-xs",children:h}):e.jsxs(e.Fragment,{children:[w&&e.jsx("p",{className:"text-muted-foreground truncate text-xs italic",children:w}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:D})]})]}),k&&e.jsxs(Y,{children:[e.jsx(J,{asChild:!0,children:e.jsx(L,{variant:"outline",children:"Restricted"})}),e.jsx(ee,{children:z})]}),e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs(B,{variant:"ghost",size:"icon-md",responsive:!1,className:"h-8 w-8 shrink-0",children:[e.jsx(ae,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ne,{align:"end",children:[e.jsxs(R,{onClick:O,disabled:j||p,children:[j?e.jsx(ie,{className:"mr-2"}):e.jsx(re,{className:"mr-2 size-(--size-icon-sm)"}),"Send test"]}),e.jsx(F,{}),e.jsx(R,{onClick:()=>f(!a.enabled),children:p?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"mr-2 size-4"}),"Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"mr-2 size-4"}),"Pause"]})}),e.jsx(F,{}),e.jsx(R,{onClick:m,children:"Edit"}),e.jsx(R,{onClick:()=>o(!0),className:"text-destructive focus:text-destructive",children:"Remove"})]})]})]}),e.jsx(de,{open:t,onOpenChange:o,children:e.jsxs(le,{children:[e.jsxs(me,{children:[e.jsxs(ue,{children:["Remove the ",i," connection?"]}),e.jsx(pe,{children:"This agent stops getting messages from it."})]}),e.jsxs(xe,{children:[e.jsx(he,{children:"Cancel"}),e.jsx(ge,{onClick:()=>{u(),o(!1)},className:"bg-red-600 hover:bg-red-700",children:"Remove connection"})]})]})})]})}function We({binding:a,integrationName:i,integrationIconId:y,integrationAdapterType:l,adapterState:x,errorMessage:h,onTogglePause:g,onTest:d,onEdit:f,onRemove:n}){const{data:m=[]}=Se(a.adapterId),u=a.chatId?m.find(j=>j.chatId===a.chatId):void 0,t=(u==null?void 0:u.displayName)??(a.chatId?`#${a.chatId.slice(-4)}`:void 0),o=r.useMemo(()=>{if(u)return u.lastMessageAt;if(m.length!==0)return m.reduce((j,v)=>v.lastMessageAt>j?v.lastMessageAt:j,m[0].lastMessageAt)},[u,m]);return e.jsx($e,{binding:a,integrationName:i,integrationIconId:y,integrationAdapterType:l,adapterState:x,errorMessage:h,chatDisplayName:t,lastMessageAt:o,onTogglePause:g,onTest:d,onEdit:f,onRemove:n})}function W({catalog:a,boundAdapterIds:i,onSelectIntegration:y,onRequestSetup:l,disabled:x}){const[h,g]=r.useState(!1),d=r.useMemo(()=>a.flatMap(t=>t.instances.map(o=>({id:o.id,displayName:o.status.displayName??t.manifest.displayName,label:o.label,state:o.status.state,isDisabled:o.status.state==="error"||!o.enabled,alreadyBound:i.has(o.id),iconId:t.manifest.iconId,adapterType:t.manifest.type}))),[a,i]),f=r.useMemo(()=>a.filter(t=>!t.manifest.deprecated&&(t.instances.length===0||t.manifest.multiInstance)),[a]);function n(t){y(t),g(!1)}function m(t){g(!1),l(t)}const u=d.length===0&&f.length===0;return e.jsxs(fe,{open:h,onOpenChange:g,children:[e.jsx(je,{asChild:!0,children:e.jsxs(B,{variant:"outline",size:"sm",disabled:x,children:[e.jsx(ye,{className:"mr-1.5 size-3.5"}),"Add connection"]})}),e.jsx(ve,{className:"w-72 p-0",align:"start",children:e.jsx("div",{className:"max-h-64 overflow-y-auto",children:u?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No connections available"})}):e.jsxs(e.Fragment,{children:[d.length>0&&e.jsx("div",{className:"py-1",children:d.map(t=>e.jsxs("button",{disabled:t.isDisabled||t.alreadyBound,onClick:()=>n(t.id),className:I("flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors","hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"),children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(_,{iconId:t.iconId,adapterType:t.adapterType,size:20,className:"text-muted-foreground"}),e.jsx("span",{className:I("ring-background absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full ring-[1.5px]",P[t.state])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-medium",children:t.displayName}),t.label&&e.jsx("p",{className:"text-muted-foreground truncate text-xs",children:t.label})]}),e.jsx("span",{className:"text-muted-foreground/60 text-xs",children:t.alreadyBound?"Connected":ze[t.state]})]},t.id))}),f.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"text-muted-foreground px-3 py-1 text-xs font-medium",children:"Available to set up"}),f.map(t=>e.jsxs("button",{onClick:()=>m(t.manifest),className:I("flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors","hover:bg-accent"),children:[e.jsx(_,{iconId:t.manifest.iconId,adapterType:t.manifest.type,size:14,className:"text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:t.manifest.displayName})]},t.manifest.type))]})]})]})})})]})}const M={open:!1,binding:null,adapterName:""},q={open:!1};function qe({agent:a}){const i=Be(),{data:y=[]}=Ie(),{data:l=[]}=Ee(i),x=we(),h=Re(),g=_e(),d=Me(),f=U(),[n,m]=r.useState(M),[u,t]=r.useState(q),o=y.filter(s=>s.agentId===a.id),j=r.useMemo(()=>{const s=new Map;for(const c of l)for(const b of c.instances){const T=b.status.state,Z=T==="connected"||T==="error"?T:T==="starting"||T==="stopping"||T==="reconnecting"?"connecting":"disconnected";s.set(b.id,{state:Z,name:b.status.displayName??c.manifest.displayName,iconId:c.manifest.iconId,adapterType:c.manifest.type,errorMessage:b.status.lastError??void 0})}return s},[l]),v=r.useCallback(s=>j.get(s)??{state:"disconnected",name:s,adapterType:s},[j]),p=r.useMemo(()=>new Set(o.map(s=>s.adapterId)),[o]),A=r.useCallback(async s=>{try{await x.mutateAsync({adapterId:s,agentId:a.id,sessionStrategy:"per-chat",label:"",canInitiate:!1,canReply:!0,canReceive:!0}),N.success("Connection added")}catch{}},[a.id,x]),S=r.useCallback(s=>{t({open:!0,manifest:s})},[]),E=r.useCallback(s=>{m({open:!0,binding:s,adapterName:v(s.adapterId).name})},[v]),w=r.useCallback(async s=>{try{await h.mutateAsync(s),N.success("Connection removed")}catch{}},[h]),k=r.useCallback(async(s,c)=>{try{await d.mutateAsync({id:s,updates:{enabled:c}}),N.success(c?"Connection resumed":"Connection paused")}catch{}},[d]),z=r.useCallback(async s=>{const c=await g.mutateAsync(s);return c.ok?N.success(`Test message delivered in ${c.latencyMs}ms`):N.error(c.reason?`Test message didn’t arrive: ${c.reason}`:"Test message didn’t arrive. Try again."),c},[g]),D=r.useCallback(async s=>{if(n.binding)try{await d.mutateAsync({id:n.binding.id,updates:ke(s)}),N.success("Connection updated"),m(M)}catch{}},[n.binding,d]),O=r.useCallback(async s=>{try{await h.mutateAsync(s),N.success("Connection removed"),m(M)}catch{}},[h]),C=e.jsxs(e.Fragment,{children:[n.binding&&e.jsx(De,{open:n.open,onOpenChange:s=>{s||m(M)},mode:"edit",initialValues:{adapterId:n.binding.adapterId,agentId:n.binding.agentId,sessionStrategy:n.binding.sessionStrategy,label:n.binding.label,permissionMode:n.binding.permissionMode,chatId:n.binding.chatId,channelType:n.binding.channelType,canInitiate:n.binding.canInitiate,canReply:n.binding.canReply,canReceive:n.binding.canReceive,notifyOnTaskComplete:n.binding.notifyOnTaskComplete},adapterName:n.adapterName,agentName:Ne(a),bindingId:n.binding.id,onConfirm:D,onDelete:O,isPending:d.isPending||h.isPending}),u.manifest&&e.jsx(Pe,{open:u.open,onOpenChange:s=>{s||t(q)},manifest:u.manifest,existingAdapterIds:l.flatMap(s=>s.instances.map(c=>c.id))})]});return i?l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx($,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"No connections available"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Add Telegram, Slack or a webhook, then connect it here."})]}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>f(),children:"Add a connection"})]}),C]}):o.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx($,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"Message this agent from anywhere"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Connect a chat app to message it while you’re away."})]}),e.jsx(W,{catalog:l,boundAdapterIds:p,onSelectIntegration:A,onRequestSetup:S,disabled:x.isPending})]}),C]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-2",children:o.map(s=>{const c=v(s.adapterId);return e.jsx(We,{binding:s,integrationName:c.name,integrationIconId:c.iconId,integrationAdapterType:c.adapterType,adapterState:c.state,errorMessage:c.errorMessage,onTogglePause:b=>k(s.id,b),onTest:()=>z(s.id),onEdit:()=>E(s),onRemove:()=>w(s.id)},s.id)})}),e.jsx(W,{catalog:l,boundAdapterIds:p,onSelectIntegration:A,onRequestSetup:S,disabled:x.isPending}),C]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx(Oe,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"Chat apps are off"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Turn them on in Connections to reach this agent from chat."})]}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>f(),children:"Open Connections"})]}),C]})}function os({member:a}){const{agent:i,isPending:y}=Ce(a),l=U();return y?e.jsx(be,{className:"h-32 w-full"}):i?e.jsxs("div",{className:"space-y-6",children:[e.jsx(Te,{agentId:i.id,onManage:()=>l()}),e.jsxs("section",{"aria-labelledby":"agent-messaging-access",className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"agent-messaging-access",className:"text-sm font-semibold",children:"Messaging"}),e.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Places where people can reach this agent."})]}),e.jsx(qe,{agent:i})]})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s connections."})}export{os as ConnectionsPage};
6
+ */const G={name:"plug-2",size:24,node:[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]};G.node;const Oe=Z(G);function _e(){const a=H();return Q({mutationFn:i=>a.testBinding(i),meta:{errorLabel:"Couldn’t test the connection"}})}const Fe={connected:P.connected,disconnected:K.warning,error:P.error,connecting:P.starting};function Le(a){const i=[];return a.canInitiate&&i.push("Can message first"),a.canReply||i.push("Can’t reply"),a.canReceive||i.push("Can’t receive"),i.join(" · ")}function $e({binding:a,integrationName:i,integrationIconId:y,integrationAdapterType:l,adapterState:x,errorMessage:g,chatDisplayName:h,lastMessageAt:d,onTogglePause:f,onTest:n,onEdit:m,onRemove:u}){const[t,o]=r.useState(!1),[j,v]=r.useState(!1),p=a.enabled===!1,[A,w]=r.useState(0);r.useEffect(()=>{if(!d||p)return;const b=setInterval(()=>w(s=>s+1),6e4);return()=>clearInterval(b)},[d,p]);const E=h?`${i} · ${h}`:i,S=Ae({sessionStrategy:a.sessionStrategy,chatDisplayName:h,channelType:a.channelType}),k=a.canInitiate||!a.canReply||!a.canReceive,z=k?Le(a):"",D=r.useMemo(()=>p?"Paused: no messages delivered":d?`Last received ${J(d).toLowerCase()}`:"No recent activity",[p,d,A]),O=async()=>{v(!0);try{await n()}finally{v(!1)}};return e.jsxs("div",{className:I("relative rounded-xl border px-4 py-3 transition-colors",x==="error"&&!p&&"border-red-500/50 bg-red-500/[0.02]",p&&"opacity-60"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(_,{iconId:y,adapterType:l,size:32}),e.jsx("span",{className:I("ring-background absolute -right-0.5 -bottom-0.5 size-2.5 rounded-full ring-2",p?"bg-muted-foreground/40":Fe[x])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:E}),p&&e.jsx(F,{variant:"secondary",children:"Paused"})]}),p?e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:D}):x==="error"&&g?e.jsx("p",{className:"text-destructive text-xs",children:g}):e.jsxs(e.Fragment,{children:[S&&e.jsx("p",{className:"text-muted-foreground truncate text-xs italic",children:S}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:D})]})]}),k&&e.jsxs(X,{children:[e.jsx(Y,{asChild:!0,children:e.jsx(F,{variant:"outline",children:"Restricted"})}),e.jsx(ee,{children:z})]}),e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs(B,{variant:"ghost",size:"icon-md",responsive:!1,className:"h-8 w-8 shrink-0",children:[e.jsx(ae,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ne,{align:"end",children:[e.jsxs(R,{onClick:O,disabled:j||p,children:[j?e.jsx(ie,{className:"mr-2"}):e.jsx(re,{className:"mr-2 size-(--size-icon-sm)"}),"Send test"]}),e.jsx(L,{}),e.jsx(R,{onClick:()=>f(!a.enabled),children:p?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"mr-2 size-4"}),"Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"mr-2 size-4"}),"Pause"]})}),e.jsx(L,{}),e.jsx(R,{onClick:m,children:"Edit"}),e.jsx(R,{onClick:()=>o(!0),className:"text-destructive focus:text-destructive",children:"Remove"})]})]})]}),e.jsx(de,{open:t,onOpenChange:o,children:e.jsxs(le,{children:[e.jsxs(me,{children:[e.jsxs(ue,{children:["Remove the ",i," connection?"]}),e.jsx(pe,{children:"This agent stops getting messages from it."})]}),e.jsxs(xe,{children:[e.jsx(ge,{children:"Cancel"}),e.jsx(he,{onClick:()=>{u(),o(!1)},className:"bg-red-600 hover:bg-red-700",children:"Remove connection"})]})]})})]})}function qe({binding:a,integrationName:i,integrationIconId:y,integrationAdapterType:l,adapterState:x,errorMessage:g,onTogglePause:h,onTest:d,onEdit:f,onRemove:n}){const{data:m=[]}=we(a.adapterId),u=a.chatId?m.find(j=>j.chatId===a.chatId):void 0,t=(u==null?void 0:u.displayName)??(a.chatId?`#${a.chatId.slice(-4)}`:void 0),o=r.useMemo(()=>{if(u)return u.lastMessageAt;if(m.length!==0)return m.reduce((j,v)=>v.lastMessageAt>j?v.lastMessageAt:j,m[0].lastMessageAt)},[u,m]);return e.jsx($e,{binding:a,integrationName:i,integrationIconId:y,integrationAdapterType:l,adapterState:x,errorMessage:g,chatDisplayName:t,lastMessageAt:o,onTogglePause:h,onTest:d,onEdit:f,onRemove:n})}function q({catalog:a,boundAdapterIds:i,onSelectIntegration:y,onRequestSetup:l,disabled:x}){const[g,h]=r.useState(!1),d=r.useMemo(()=>a.flatMap(t=>t.instances.map(o=>({id:o.id,displayName:o.status.displayName??t.manifest.displayName,label:o.label,state:o.status.state,isDisabled:o.status.state==="error"||!o.enabled,alreadyBound:i.has(o.id),iconId:t.manifest.iconId,adapterType:t.manifest.type}))),[a,i]),f=r.useMemo(()=>a.filter(t=>!t.manifest.deprecated&&(t.instances.length===0||t.manifest.multiInstance)),[a]);function n(t){y(t),h(!1)}function m(t){h(!1),l(t)}const u=d.length===0&&f.length===0;return e.jsxs(fe,{open:g,onOpenChange:h,children:[e.jsx(je,{asChild:!0,children:e.jsxs(B,{variant:"outline",size:"sm",disabled:x,children:[e.jsx(ye,{className:"mr-1.5 size-3.5"}),"Add connection"]})}),e.jsx(ve,{className:"w-72 p-0",align:"start",children:e.jsx("div",{className:"max-h-64 overflow-y-auto",children:u?e.jsx("div",{className:"px-3 py-4 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No connections available"})}):e.jsxs(e.Fragment,{children:[d.length>0&&e.jsx("div",{className:"py-1",children:d.map(t=>e.jsxs("button",{disabled:t.isDisabled||t.alreadyBound,onClick:()=>n(t.id),className:I("flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors","hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"),children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(_,{iconId:t.iconId,adapterType:t.adapterType,size:20,className:"text-muted-foreground"}),e.jsx("span",{className:I("ring-background absolute -right-0.5 -bottom-0.5 size-1.5 rounded-full ring-[1.5px]",P[t.state])})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-medium",children:t.displayName}),t.label&&e.jsx("p",{className:"text-muted-foreground truncate text-xs",children:t.label})]}),e.jsx("span",{className:"text-muted-foreground/60 text-xs",children:t.alreadyBound?"Connected":ze[t.state]})]},t.id))}),f.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"text-muted-foreground px-3 py-1 text-xs font-medium",children:"Available to set up"}),f.map(t=>e.jsxs("button",{onClick:()=>m(t.manifest),className:I("flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition-colors","hover:bg-accent"),children:[e.jsx(_,{iconId:t.manifest.iconId,adapterType:t.manifest.type,size:14,className:"text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:t.manifest.displayName})]},t.manifest.type))]})]})]})})})]})}const M={open:!1,binding:null,adapterName:""},W={open:!1};function We({agent:a}){const i=Be(),{data:y=[]}=Ie(),{data:l=[]}=Ee(i),x=Se(),g=Re(),h=_e(),d=Me(),f=U(),[n,m]=r.useState(M),[u,t]=r.useState(W),o=y.filter(s=>s.agentId===a.id),j=r.useMemo(()=>{const s=new Map;for(const c of l)for(const C of c.instances){const T=C.status.state,V=T==="connected"||T==="error"?T:T==="starting"||T==="stopping"||T==="reconnecting"?"connecting":"disconnected";s.set(C.id,{state:V,name:C.status.displayName??c.manifest.displayName,iconId:c.manifest.iconId,adapterType:c.manifest.type,errorMessage:C.status.lastError??void 0})}return s},[l]),v=r.useCallback(s=>j.get(s)??{state:"disconnected",name:s,adapterType:s},[j]),p=r.useMemo(()=>new Set(o.map(s=>s.adapterId)),[o]),A=r.useCallback(async s=>{try{await x.mutateAsync({adapterId:s,agentId:a.id,sessionStrategy:"per-chat",label:"",canInitiate:!1,canReply:!0,canReceive:!0}),N.success("Connection added")}catch{}},[a.id,x]),w=r.useCallback(s=>{t({open:!0,manifest:s})},[]),E=r.useCallback(s=>{m({open:!0,binding:s,adapterName:v(s.adapterId).name})},[v]),S=r.useCallback(async s=>{try{await g.mutateAsync(s),N.success("Connection removed")}catch{}},[g]),k=r.useCallback(async(s,c)=>{try{await d.mutateAsync({id:s,updates:{enabled:c}}),N.success(c?"Connection resumed":"Connection paused")}catch{}},[d]),z=r.useCallback(async s=>{const c=await h.mutateAsync(s);return c.ok?N.success(`Test message delivered in ${c.latencyMs}ms`):N.error(c.reason?`Test message didn’t arrive: ${c.reason}`:"Test message didn’t arrive. Try again."),c},[h]),D=r.useCallback(async s=>{if(n.binding)try{await d.mutateAsync({id:n.binding.id,updates:ke(s)}),N.success("Connection updated"),m(M)}catch{}},[n.binding,d]),O=r.useCallback(async s=>{try{await g.mutateAsync(s),N.success("Connection removed"),m(M)}catch{}},[g]),b=e.jsxs(e.Fragment,{children:[n.binding&&e.jsx(De,{open:n.open,onOpenChange:s=>{s||m(M)},mode:"edit",initialValues:{adapterId:n.binding.adapterId,agentId:n.binding.agentId,sessionStrategy:n.binding.sessionStrategy,label:n.binding.label,permissionMode:n.binding.permissionMode,chatId:n.binding.chatId,channelType:n.binding.channelType,canInitiate:n.binding.canInitiate,canReply:n.binding.canReply,canReceive:n.binding.canReceive,notifyOnTaskComplete:n.binding.notifyOnTaskComplete},adapterName:n.adapterName,agentName:Ne(a),bindingId:n.binding.id,onConfirm:D,onDelete:O,isPending:d.isPending||g.isPending}),u.manifest&&e.jsx(Pe,{open:u.open,onOpenChange:s=>{s||t(W)},manifest:u.manifest,existingAdapterIds:l.flatMap(s=>s.instances.map(c=>c.id))})]});return i?l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx($,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"No connections available"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Add Telegram, Slack or a webhook, then connect it here."})]}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>f(),children:"Add a connection"})]}),b]}):o.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx($,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"Message this agent from anywhere"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Connect a chat app to message it while you’re away."})]}),e.jsx(q,{catalog:l,boundAdapterIds:p,onSelectIntegration:A,onRequestSetup:w,disabled:x.isPending})]}),b]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-2",children:o.map(s=>{const c=v(s.adapterId);return e.jsx(qe,{binding:s,integrationName:c.name,integrationIconId:c.iconId,integrationAdapterType:c.adapterType,adapterState:c.state,errorMessage:c.errorMessage,onTogglePause:C=>k(s.id,C),onTest:()=>z(s.id),onEdit:()=>E(s),onRemove:()=>S(s.id)},s.id)})}),e.jsx(q,{catalog:l,boundAdapterIds:p,onSelectIntegration:A,onRequestSetup:w,disabled:x.isPending}),b]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed px-6 py-10",children:[e.jsx(Oe,{className:"text-muted-foreground/40 size-8"}),e.jsxs("div",{className:"space-y-1 text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:"Chat apps are off"}),e.jsx("p",{className:"text-muted-foreground max-w-xs text-xs leading-relaxed",children:"Turn them on in Connections to reach this agent from chat."})]}),e.jsx(B,{variant:"outline",size:"sm",onClick:()=>f(),children:"Open Connections"})]}),b]})}function os({member:a}){const{agent:i,isPending:y}=be(a),l=U();return y?e.jsx(Ce,{className:"h-32 w-full"}):i?e.jsxs("div",{className:"space-y-6",children:[e.jsx(Te,{agentId:i.id,onManage:()=>l()}),e.jsxs("section",{"aria-labelledby":"agent-messaging-access",className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"agent-messaging-access",className:"text-sm font-semibold",children:"Messaging"}),e.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Places where people can reach this agent."})]}),e.jsx(We,{agent:i})]})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this agent’s connections."})}export{os as ConnectionsPage};