decocms 4.92.0 → 4.92.1

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 (234) hide show
  1. package/dist/client/assets/{AlertCircle-BtNVN6lT.js → AlertCircle-Clv-C2np.js} +1 -1
  2. package/dist/client/assets/{AreaChart-G7ca0KYF.js → AreaChart-C4-p1gQK.js} +1 -1
  3. package/dist/client/assets/{ArrowUp-SfmKmvG1.js → ArrowUp-DCJUk93H.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-DPmhEMyl.js → ArrowUpRight-DwUunkDC.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-Dqg_7udX.js → CheckCircle-BHKn_v25.js} +1 -1
  6. package/dist/client/assets/{ChevronDown-CtpYRw0N.js → ChevronDown-DDT8b8rP.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-DQFD5vOs.js → ChevronRight-HnufFvB9.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-Bu3KYaYp.js → ChevronUp-D-P6SBrW.js} +1 -1
  9. package/dist/client/assets/{Copy01-B4AQ9voq.js → Copy01-CyfFXTKR.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-4fMK5hdE.js → DotsVertical-4aFvnFGK.js} +1 -1
  11. package/dist/client/assets/{Eye-7UpR5EsV.js → Eye-DTlsPxh1.js} +1 -1
  12. package/dist/client/assets/{FilterLines-jo0eHglf.js → FilterLines-CDNj37OS.js} +1 -1
  13. package/dist/client/assets/{Globe01-BEuNOgWE.js → Globe01-7xljr_EC.js} +1 -1
  14. package/dist/client/assets/{Globe04-ezZLp1FH.js → Globe04-ljGt4Lg6.js} +1 -1
  15. package/dist/client/assets/{HardDrive-Bx0yMIUr.js → HardDrive-BroB03OF.js} +1 -1
  16. package/dist/client/assets/{Image01-BemfbeRy.js → Image01-CPHpxpf1.js} +1 -1
  17. package/dist/client/assets/{Key01-wlopeCn8.js → Key01-BMPHkbEG.js} +1 -1
  18. package/dist/client/assets/{LayoutLeft-DgCOjEX2.js → LayoutLeft-1eHZDH0T.js} +1 -1
  19. package/dist/client/assets/{LinkExternal01-DjHN0DVc.js → LinkExternal01-CNmFDmgO.js} +1 -1
  20. package/dist/client/assets/{Monitor01-CvVGHJ2u.js → Monitor01-6Irz93Em.js} +1 -1
  21. package/dist/client/assets/{Package-Dkg7P-qU.js → Package-Cy8-91a-.js} +1 -1
  22. package/dist/client/assets/{Palette-DnEGtR5r.js → Palette-C1a_XOsl.js} +1 -1
  23. package/dist/client/assets/{Play-pFWdRfmo.js → Play-CwA4-KOo.js} +1 -1
  24. package/dist/client/assets/{Plus-BhgoGeba.js → Plus-us-N9JUq.js} +1 -1
  25. package/dist/client/assets/{SearchLg-D7iDyCtR.js → SearchLg-BUP3ozF2.js} +1 -1
  26. package/dist/client/assets/{SearchMd-DU7sZsGX.js → SearchMd-Dd7ZGI56.js} +1 -1
  27. package/dist/client/assets/{Settings02-Kn3GUgY3.js → Settings02-DrOPo3mj.js} +1 -1
  28. package/dist/client/assets/{Shield01-BF7nZR91.js → Shield01-BI58H8tV.js} +1 -1
  29. package/dist/client/assets/{Star01-UbWAuLRP.js → Star01-BTYXST43.js} +1 -1
  30. package/dist/client/assets/{Stars01-CKHcD24W.js → Stars01-B6N3EY9X.js} +1 -1
  31. package/dist/client/assets/{Stars02-ByALJtc-.js → Stars02-BY1cpg45.js} +1 -1
  32. package/dist/client/assets/{Sun-ERdj2Ruh.js → Sun-CeoIcGEC.js} +1 -1
  33. package/dist/client/assets/{SwitchHorizontal01-B2hcs1rw.js → SwitchHorizontal01-DSaA1AAh.js} +1 -1
  34. package/dist/client/assets/{Tool01-DoTp9Ymb.js → Tool01-Cg68N3nA.js} +1 -1
  35. package/dist/client/assets/{Tool02-f6hCEEx5.js → Tool02-DED34rla.js} +1 -1
  36. package/dist/client/assets/{Trash01-Dgm4FHaX.js → Trash01-CKx7yRIc.js} +1 -1
  37. package/dist/client/assets/{TrendUp01-DdLolkHU.js → TrendUp01-CW6Njakg.js} +1 -1
  38. package/dist/client/assets/{Upload01-DPgiWRF2.js → Upload01-BEXZOkzx.js} +1 -1
  39. package/dist/client/assets/{User01-4oxhkWpc.js → User01-WL7UxAwC.js} +1 -1
  40. package/dist/client/assets/{Users01-CbDWoQDz.js → Users01-BVVqJkbL.js} +1 -1
  41. package/dist/client/assets/{Users03-DQDFsIZA.js → Users03-kQPt9_XZ.js} +1 -1
  42. package/dist/client/assets/{X-BJznV24Z.js → X-B4leRLqf.js} +1 -1
  43. package/dist/client/assets/{XCircle-Mn7Ozb-Q.js → XCircle-Di8Uo4pL.js} +1 -1
  44. package/dist/client/assets/{XClose-BYGQndp2.js → XClose-DMc7p4CW.js} +1 -1
  45. package/dist/client/assets/{Zap-SMAt3bB0.js → Zap-Zy5e7I3t.js} +1 -1
  46. package/dist/client/assets/{ZapSquare-Chem9D1s.js → ZapSquare-DiRNwHBE.js} +1 -1
  47. package/dist/client/assets/{ZoomOut-znim4joS.js → ZoomOut-tXRohD9g.js} +1 -1
  48. package/dist/client/assets/{access-gate-CXUaT8Bg.js → access-gate-AwksVSKW.js} +1 -1
  49. package/dist/client/assets/{add-section-modal-Bu0jJfTp.js → add-section-modal-IG-4jW3o.js} +1 -1
  50. package/dist/client/assets/{agent-icon-CMi9hXve.js → agent-icon-n_DJILEj.js} +1 -1
  51. package/dist/client/assets/{agents-list-CxMjWnYV.js → agents-list-C5V-ldBY.js} +1 -1
  52. package/dist/client/assets/{ai-providers-V_ToPNx9.js → ai-providers-D_fbUUoy.js} +1 -1
  53. package/dist/client/assets/{alert-dialog-9jx8jzEO.js → alert-dialog-De7Jj0Gd.js} +1 -1
  54. package/dist/client/assets/{alert-DCHONWz2.js → alert-fgtNa48Y.js} +1 -1
  55. package/dist/client/assets/{app-editor-B5Y1RFnh.js → app-editor-C5o42oU3.js} +1 -1
  56. package/dist/client/assets/{auth-wA89jw5z.js → auth-Ta6fwTa4.js} +1 -1
  57. package/dist/client/assets/{auth-catchall-gpLRqkDV.js → auth-catchall-BINtcQPS.js} +1 -1
  58. package/dist/client/assets/{auth-entry-ByL0Zb6R.js → auth-entry-CMZVqZD1.js} +1 -1
  59. package/dist/client/assets/{auth-split-layout-BoMjBMXD.js → auth-split-layout-BE16rQGL.js} +1 -1
  60. package/dist/client/assets/{authenticate-and-persist-oauth-CO2Dkq5Q.js → authenticate-and-persist-oauth-BWqn4KLF.js} +1 -1
  61. package/dist/client/assets/{automation-list-row-CZVotwYb.js → automation-list-row-BcxbDbRm.js} +1 -1
  62. package/dist/client/assets/{automation-runs-oeg4SZH2.js → automation-runs-eB3UxPqQ.js} +1 -1
  63. package/dist/client/assets/{automations-kL1ULwau.js → automations-BfGGsIrT.js} +1 -1
  64. package/dist/client/assets/{autosend-DFAdUSMh.js → autosend-BhmTfxCS.js} +1 -1
  65. package/dist/client/assets/{avatar-D2faXu9B.js → avatar-B8_a8C3S.js} +1 -1
  66. package/dist/client/assets/{badge-C22fJvJ9.js → badge-BZilNB5D.js} +1 -1
  67. package/dist/client/assets/{block-document-F7Fz2w43.js → block-document-CU_R1go5.js} +1 -1
  68. package/dist/client/assets/{brand-context-CwktNs2n.js → brand-context-nl5okTqp.js} +1 -1
  69. package/dist/client/assets/{buckets-BqmVHHty.js → buckets-CWGAX4Op.js} +1 -1
  70. package/dist/client/assets/{bulk-category-panel-DEnhQv4x.js → bulk-category-panel-CgSvwA00.js} +1 -1
  71. package/dist/client/assets/{calendar-C55pfZGp.js → calendar-CM0d8cf3.js} +1 -1
  72. package/dist/client/assets/{capability-load-error-D-GHd7kt.js → capability-load-error-DyXw79vO.js} +1 -1
  73. package/dist/client/assets/{card-BZY4DqkC.js → card-DNiOb8C_.js} +1 -1
  74. package/dist/client/assets/category-editor-omUhw8hw.js +1 -0
  75. package/dist/client/assets/{chat-context-8zti4wkh.js → chat-context-CaE1IrMD.js} +1 -1
  76. package/dist/client/assets/{checkbox-DvRekaoI.js → checkbox-BiboLXsd.js} +1 -1
  77. package/dist/client/assets/{cli-auth-success-BwJqzavM.js → cli-auth-success-hGSoasXF.js} +1 -1
  78. package/dist/client/assets/{collection-detail-BCNd0Ifz.js → collection-detail-_5X_l9MF.js} +1 -1
  79. package/dist/client/assets/{collection-display-button-Su2JKz2G.js → collection-display-button-CINCvS0U.js} +1 -1
  80. package/dist/client/assets/{collection-search-B4ji9AjC.js → collection-search-DkaBDE88.js} +1 -1
  81. package/dist/client/assets/{collection-table-wrapper-DhT1Pcxz.js → collection-table-wrapper-B31K-mZy.js} +1 -1
  82. package/dist/client/assets/{collection-tabs-DTWzD8v3.js → collection-tabs-CjttU7gV.js} +1 -1
  83. package/dist/client/assets/{command-BeMVvNyF.js → command-DtXbWX2t.js} +1 -1
  84. package/dist/client/assets/{commerce-onboarding-wd060R0w.js → commerce-onboarding-DSEpOAMV.js} +1 -1
  85. package/dist/client/assets/{companions-core-D6ZCzGBn.js → companions-core-DU4JOcgk.js} +1 -1
  86. package/dist/client/assets/{connect-desktop-dialog-ekgjUng_.js → connect-desktop-dialog-rRtqIhuV.js} +1 -1
  87. package/dist/client/assets/{connection-card-7Jlr5ou8.js → connection-card-DH9eHpgr.js} +1 -1
  88. package/dist/client/assets/{connection-detail-CVc89tOZ.js → connection-detail-BPx_l57r.js} +1 -1
  89. package/dist/client/assets/{connection-form-helpers-BT4sViBb.js → connection-form-helpers-9cIttTn5.js} +1 -1
  90. package/dist/client/assets/{connections-U8gRLumN.js → connections-AVIhTzcp.js} +1 -1
  91. package/dist/client/assets/{decopilot-sse-pool-us-M5mS8.js → decopilot-sse-pool-BD-E8GML.js} +1 -1
  92. package/dist/client/assets/{dialog-B_MtszrV.js → dialog-CEJEmlAZ.js} +1 -1
  93. package/dist/client/assets/{domain-settings-C_FTyjE2.js → domain-settings-BkzI_Z14.js} +1 -1
  94. package/dist/client/assets/{drawer-BsQ2VY2t.js → drawer-B16UsJ9z.js} +1 -1
  95. package/dist/client/assets/{dropdown-menu-CCf9b-Ue.js → dropdown-menu-Bohi0euR.js} +1 -1
  96. package/dist/client/assets/{empty-state-uOmVY7AV.js → empty-state-DAC9lF38.js} +1 -1
  97. package/dist/client/assets/{extract-connection-data-B1PMDhhA.js → extract-connection-data-BOVpLxWL.js} +1 -1
  98. package/dist/client/assets/{file-explorer-Cq-sGwnZ.js → file-explorer-C83rSApL.js} +1 -1
  99. package/dist/client/assets/{file-type-icon-DLDSmTyC.js → file-type-icon-CA2uuZ7F.js} +1 -1
  100. package/dist/client/assets/{files-CCiFVnRx.js → files-Cgp73tmq.js} +1 -1
  101. package/dist/client/assets/{form-CBH5rcB6.js → form-xwt17q8h.js} +1 -1
  102. package/dist/client/assets/{general-DnViTnDI.js → general-CWptcVqJ.js} +1 -1
  103. package/dist/client/assets/{github-repo-picker-DWdab-4Y.js → github-repo-picker-Ce0749m3.js} +1 -1
  104. package/dist/client/assets/{hooks-CQZHp8Dt.js → hooks-9fTm-ZdN.js} +1 -1
  105. package/dist/client/assets/{index-F-zmfSqw.js → index--Rru8MRb.js} +1 -1
  106. package/dist/client/assets/{index-QeeIyPD-.js → index-BE6hzuPl.js} +3 -3
  107. package/dist/client/assets/index-BIBRA2uz.js +519 -0
  108. package/dist/client/assets/{index-DWS4NoqH.js → index-BQh3gSSP.js} +1 -1
  109. package/dist/client/assets/{index-hhU2F3WQ.js → index-BaUSa1j3.js} +1 -1
  110. package/dist/client/assets/{index-CmemNDJU.js → index-BqyYrFv3.js} +1 -1
  111. package/dist/client/assets/{index-B-kvMeNd.js → index-C6Xwww_u.js} +1 -1
  112. package/dist/client/assets/{index-C1alCXBf.js → index-CCMPN7OD.js} +3 -3
  113. package/dist/client/assets/{index-BfunopXO.js → index-CXnbxDhA.js} +1 -1
  114. package/dist/client/assets/{index-d_66hXvz.js → index-CdhReIUf.js} +1 -1
  115. package/dist/client/assets/{index-CAK7n_FO.js → index-DEAM6UpC.js} +2 -2
  116. package/dist/client/assets/{index-C_AuPrej.js → index-DLt5Gc69.js} +1 -1
  117. package/dist/client/assets/{index-CodlhltM.js → index-DsTc8yYr.js} +1 -1
  118. package/dist/client/assets/{index-DWmvNX0u.js → index-Jz0CuEFl.js} +1 -1
  119. package/dist/client/assets/{index-redirect-BRH-3ZCu.js → index-redirect-DAbgHTCC.js} +1 -1
  120. package/dist/client/assets/{input-ksjqlSwm.js → input-BgHT8C_Y.js} +1 -1
  121. package/dist/client/assets/{integration-icon-nHJfLZDJ.js → integration-icon-GEOjw9nA.js} +1 -1
  122. package/dist/client/assets/{invite-member-dialog-C6cxYu7U.js → invite-member-dialog-Bn-S9yCN.js} +1 -1
  123. package/dist/client/assets/{label-B8xrTNKP.js → label-BUEwzrLz.js} +1 -1
  124. package/dist/client/assets/{layout-BJDwPfq0.js → layout-C6WVIkZ1.js} +1 -1
  125. package/dist/client/assets/{login-DlJSNcQs.js → login-DxawahhV.js} +1 -1
  126. package/dist/client/assets/{mcp-oauth-C_zNkYXB.js → mcp-oauth-y10dB3OG.js} +1 -1
  127. package/dist/client/assets/{members-BM7Uqu1Q.js → members-BekqX_Ri.js} +1 -1
  128. package/dist/client/assets/{monaco-editor-CAwKA7tN.js → monaco-editor-Bh8y4XGF.js} +1 -1
  129. package/dist/client/assets/{monitoring-stats-row-CC7F0Phb.js → monitoring-stats-row-CmNpuSe3.js} +1 -1
  130. package/dist/client/assets/{multi-select-5dvonfKB.js → multi-select-AV0FE5T3.js} +1 -1
  131. package/dist/client/assets/{oauth-callback-8qeP_w61.js → oauth-callback-Dsy_qURW.js} +1 -1
  132. package/dist/client/assets/{oauth-callback-ai-provider-BmIt9KYD.js → oauth-callback-ai-provider-DxmqFpZS.js} +1 -1
  133. package/dist/client/assets/{onboarding-Cg0DtUJd.js → onboarding-DZ--Mi0J.js} +1 -1
  134. package/dist/client/assets/{org-install-CTi6z1kk.js → org-install-CLR3-44w.js} +1 -1
  135. package/dist/client/assets/{org-layout-tdajFZ6u.js → org-layout-kthKrGx0.js} +1 -1
  136. package/dist/client/assets/{organization-choice-GMUL1NeO.js → organization-choice-BRPibyv7.js} +1 -1
  137. package/dist/client/assets/{orgs-6ZiXdiJ2.js → orgs-DBHsCjWx.js} +1 -1
  138. package/dist/client/assets/{page-seo-form-CGZUz0ph.js → page-seo-form-BytIEBTv.js} +1 -1
  139. package/dist/client/assets/page-seo-sheet-mJW0tAP8.js +1 -0
  140. package/dist/client/assets/{popover-3l0deoOx.js → popover-BEGdNmUQ.js} +1 -1
  141. package/dist/client/assets/post-editor-CEMsCtDO.js +1 -0
  142. package/dist/client/assets/{primitives-DGvfP5N2.js → primitives-DrykBhU_.js} +1 -1
  143. package/dist/client/assets/{profile-BjX7gD7e.js → profile-DnMb85h-.js} +1 -1
  144. package/dist/client/assets/project-app-view-Cag9gDj3.js +1 -0
  145. package/dist/client/assets/record-editor-BEQrV1d8.js +1 -0
  146. package/dist/client/assets/redirect-editor-Bh-8Ulfx.js +1 -0
  147. package/dist/client/assets/registry-CvS_UwLO.js +2 -0
  148. package/dist/client/assets/{registry-layout-50Nc58LU.js → registry-layout-DZNagoau.js} +1 -1
  149. package/dist/client/assets/{reports-CMuw_Eim.js → reports-GLGMCsVS.js} +1 -1
  150. package/dist/client/assets/{require-capability-BMCPfqFj.js → require-capability-BvIdOAAp.js} +1 -1
  151. package/dist/client/assets/{required-auth-layout-BON6U2A_.js → required-auth-layout-DN9CNJ17.js} +1 -1
  152. package/dist/client/assets/{reset-password-CuQp3WxW.js → reset-password-C1pIm0Iv.js} +1 -1
  153. package/dist/client/assets/{roles-flCogJRV.js → roles-DokzsAwQ.js} +1 -1
  154. package/dist/client/assets/{search-input-UOEApV9M.js → search-input-B-DY-xf1.js} +1 -1
  155. package/dist/client/assets/{secrets-CUe-abV1.js → secrets-BXnB__ih.js} +1 -1
  156. package/dist/client/assets/{sections-editor-BCCsHWJ1.js → sections-editor-Dpco23Fg.js} +2 -2
  157. package/dist/client/assets/{select-BK6Fwx47.js → select-_BdZTxPS.js} +1 -1
  158. package/dist/client/assets/{select-model-FeZ2YvBx.js → select-model-CdCA5sAQ.js} +1 -1
  159. package/dist/client/assets/{self-tool-result-BblMArR-.js → self-tool-result-DxwgmlEg.js} +1 -1
  160. package/dist/client/assets/{seo-editor-D48-7A97.js → seo-editor-pHkOR1VP.js} +1 -1
  161. package/dist/client/assets/{settings-layout-DEiZmbv4.js → settings-layout-Bay6czqP.js} +1 -1
  162. package/dist/client/assets/{settings-section--wnksRdd.js → settings-section-WJlRZThP.js} +1 -1
  163. package/dist/client/assets/{shell-controls-6ZpSpxU3.js → shell-controls-BVv8dxtB.js} +1 -1
  164. package/dist/client/assets/{shell-layout-CGSn6NPr.js → shell-layout-BzSeIhlb.js} +1 -1
  165. package/dist/client/assets/{sidebar-BjCGlNJL.js → sidebar-D06GkkF0.js} +1 -1
  166. package/dist/client/assets/{skeleton-4wAys1SB.js → skeleton-peXMJuH3.js} +1 -1
  167. package/dist/client/assets/{sso-C8y4ysn5.js → sso-CX3xGBAk.js} +1 -1
  168. package/dist/client/assets/{store-EbX-J8BD.js → store-Dk-YRB6l.js} +1 -1
  169. package/dist/client/assets/store-registry-D31ldEYe.js +2 -0
  170. package/dist/client/assets/{studio-tools-Dz5m3DDC.js → studio-tools-BccAxrVu.js} +1 -1
  171. package/dist/client/assets/{switch-BGTwAogo.js → switch-DYnCFD5-.js} +1 -1
  172. package/dist/client/assets/{table-FWVzL2nm.js → table-BjiI-gaG.js} +1 -1
  173. package/dist/client/assets/{tabs-BovIXRni.js → tabs-Dwdnv16R.js} +1 -1
  174. package/dist/client/assets/{textarea-B0BnrQRd.js → textarea-BE7D_QqU.js} +1 -1
  175. package/dist/client/assets/{toggle-group-DvzPCkJs.js → toggle-group-CmVcJdNh.js} +1 -1
  176. package/dist/client/assets/{toolbar-icon-button-BGzii147.js → toolbar-icon-button-CSOZwc8p.js} +1 -1
  177. package/dist/client/assets/{toolbar-Dde3UP0K.js → toolbar-kZcoGdr4.js} +1 -1
  178. package/dist/client/assets/{tooltip-CfmdP-aL.js → tooltip-XFj2xRwa.js} +1 -1
  179. package/dist/client/assets/{use-ai-providers-UWnZZKKY.js → use-ai-providers-Bc2W8TAS.js} +1 -1
  180. package/dist/client/assets/{use-automations-URCauyn7.js → use-automations-5XmapDED.js} +1 -1
  181. package/dist/client/assets/{use-autosave-BjhwOY2t.js → use-autosave-iqnZwi6W.js} +1 -1
  182. package/dist/client/assets/{use-capability-B2RpFGXs.js → use-capability-BMD-Q3c_.js} +1 -1
  183. package/dist/client/assets/{use-clock-tick-CI9n9Iqh.js → use-clock-tick-Bs8YFyZt.js} +1 -1
  184. package/dist/client/assets/{use-collections-CI5XorIY.js → use-collections-D0Q6wvcH.js} +1 -1
  185. package/dist/client/assets/{use-connection-BlWYloF8.js → use-connection-1A7IHNnw.js} +1 -1
  186. package/dist/client/assets/{use-copy-CCSClSvL.js → use-copy-Ddqaz7gu.js} +1 -1
  187. package/dist/client/assets/{use-create-virtual-mcp-D97QNssr.js → use-create-virtual-mcp-DT1cqpNs.js} +1 -1
  188. package/dist/client/assets/{use-debounced-autosave-DbO1S1EK.js → use-debounced-autosave-DA0Wn7VJ.js} +1 -1
  189. package/dist/client/assets/{use-debounced-value-DuzsGBjb.js → use-debounced-value-DBDdUa8t.js} +1 -1
  190. package/dist/client/assets/{use-deco-credits-Bov6Ef1l.js → use-deco-credits-Mofa-D5b.js} +1 -1
  191. package/dist/client/assets/{use-decopilot-events-CqSDZlRU.js → use-decopilot-events-XyNhQjC6.js} +1 -1
  192. package/dist/client/assets/{use-delete-connection-B_AyED2-.js → use-delete-connection-CihVR_F9.js} +1 -1
  193. package/dist/client/assets/{use-deployment-admin-CSBPrawc.js → use-deployment-admin-CyJ5Uxw6.js} +1 -1
  194. package/dist/client/assets/{use-file-configs-BsBJamST.js → use-file-configs-BtA47JHd.js} +1 -1
  195. package/dist/client/assets/{use-infinite-scroll-Cylb4hyl.js → use-infinite-scroll-ZPVDShE1.js} +1 -1
  196. package/dist/client/assets/{use-join-requests-Cy4mJo9l.js → use-join-requests-CULFkSOG.js} +1 -1
  197. package/dist/client/assets/{use-mcp-auth-status-D-mrOgSF.js → use-mcp-auth-status-C9suHuMS.js} +1 -1
  198. package/dist/client/assets/{use-mcp-client-DXFWWHbs.js → use-mcp-client-DS0Emn8e.js} +1 -1
  199. package/dist/client/assets/{use-mcp-tools-ePfAnuof.js → use-mcp-tools-BAfp0q-e.js} +1 -1
  200. package/dist/client/assets/{use-members-C1OZBryu.js → use-members-NR_NeOoj.js} +1 -1
  201. package/dist/client/assets/{use-mobile-CEVETdVq.js → use-mobile-DSBAMYJF.js} +1 -1
  202. package/dist/client/assets/{use-navigate-to-agent-CflMFlHw.js → use-navigate-to-agent-DvIjbi8Z.js} +1 -1
  203. package/dist/client/assets/{use-org-auth-client-BFFpNQiA.js → use-org-auth-client-Brlf7KHt.js} +1 -1
  204. package/dist/client/assets/{use-org-sso-QrZAqFtN.js → use-org-sso-D_69Sai0.js} +1 -1
  205. package/dist/client/assets/{use-organization-roles-CYJSylgX.js → use-organization-roles-D5oSFijj.js} +1 -1
  206. package/dist/client/assets/{use-organization-settings-BpxUnud5.js → use-organization-settings-B09wmnaH.js} +1 -1
  207. package/dist/client/assets/{use-registry-app-CkuNrX2M.js → use-registry-app-lYXnJYv0.js} +1 -1
  208. package/dist/client/assets/{use-registry-connections-DWBXDDYI.js → use-registry-connections-CK8Y9s5Q.js} +1 -1
  209. package/dist/client/assets/{use-secrets-C8ssS7Ik.js → use-secrets-CrZ0-Hfb.js} +1 -1
  210. package/dist/client/assets/{use-status-sounds-2UIUBUS4.js → use-status-sounds-xXWp62ox.js} +1 -1
  211. package/dist/client/assets/{use-t-BKpqHjpb.js → use-t-CzC_cXLB.js} +1 -1
  212. package/dist/client/assets/{use-view-mode-BEQ3VoIc.js → use-view-mode-CyGc5cDF.js} +1 -1
  213. package/dist/client/assets/{use-virtual-mcp-D9jFTGjm.js → use-virtual-mcp-CSfbKXoe.js} +1 -1
  214. package/dist/client/assets/useInfiniteQuery-MB3W9wV7.js +1 -0
  215. package/dist/client/assets/{useRouterState-d9mo2HNv.js → useRouterState-Cz3yhvXr.js} +1 -1
  216. package/dist/client/assets/useSuspenseInfiniteQuery-D5GJvpsH.js +1 -0
  217. package/dist/client/assets/{users-B6WaBMxE.js → users-VpBU_WzK.js} +1 -1
  218. package/dist/client/assets/{variant-calendar-D4S-Oofs.js → variant-calendar-Bhk3fwgs.js} +1 -1
  219. package/dist/client/assets/{view-mode-toggle-CQ-IPomp.js → view-mode-toggle-DVDSH_UO.js} +1 -1
  220. package/dist/client/index.html +1 -1
  221. package/dist/server/cli.js +1 -1
  222. package/dist/server/server.js +1 -1
  223. package/package.json +1 -1
  224. package/dist/client/assets/category-editor-DZf03BWu.js +0 -1
  225. package/dist/client/assets/index-D_TDrkT8.js +0 -519
  226. package/dist/client/assets/page-seo-sheet-DB06C8Zh.js +0 -1
  227. package/dist/client/assets/post-editor-Cf2q6koS.js +0 -1
  228. package/dist/client/assets/project-app-view-CInCPGOf.js +0 -1
  229. package/dist/client/assets/record-editor-C1rBRosQ.js +0 -1
  230. package/dist/client/assets/redirect-editor-DH3saw4e.js +0 -1
  231. package/dist/client/assets/registry-BIMV2dS4.js +0 -2
  232. package/dist/client/assets/store-registry-C4UWjh6m.js +0 -2
  233. package/dist/client/assets/useInfiniteQuery-DvViU0Gq.js +0 -1
  234. package/dist/client/assets/useSuspenseInfiniteQuery-COT_NVJE.js +0 -1
@@ -0,0 +1,519 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sections-editor-Dpco23Fg.js","assets/index-BE6hzuPl.js","assets/index-DxTnZ0Oo.css","assets/ChevronDown-DDT8b8rP.js","assets/agent-icon-n_DJILEj.js","assets/AlertCircle-Clv-C2np.js","assets/Tool01-Cg68N3nA.js","assets/ArrowUp-DCJUk93H.js","assets/Settings02-DrOPo3mj.js","assets/Tool02-DED34rla.js","assets/XCircle-Di8Uo4pL.js","assets/ArrowUpRight-DwUunkDC.js","assets/TrendUp01-CW6Njakg.js","assets/ZapSquare-DiRNwHBE.js","assets/ZoomOut-tXRohD9g.js","assets/Users03-kQPt9_XZ.js","assets/CheckCircle-BHKn_v25.js","assets/ChevronUp-D-P6SBrW.js","assets/ChevronRight-HnufFvB9.js","assets/DotsVertical-4aFvnFGK.js","assets/Stars02-BY1cpg45.js","assets/Copy01-CyfFXTKR.js","assets/Globe01-7xljr_EC.js","assets/Eye-DTlsPxh1.js","assets/FilterLines-CDNj37OS.js","assets/Star01-BTYXST43.js","assets/Globe04-ljGt4Lg6.js","assets/SwitchHorizontal01-DSaA1AAh.js","assets/HardDrive-BroB03OF.js","assets/Image01-CPHpxpf1.js","assets/Key01-BMPHkbEG.js","assets/LayoutLeft-1eHZDH0T.js","assets/LinkExternal01-CNmFDmgO.js","assets/Monitor01-6Irz93Em.js","assets/Sun-CeoIcGEC.js","assets/Package-Cy8-91a-.js","assets/Palette-C1a_XOsl.js","assets/Play-CwA4-KOo.js","assets/Plus-us-N9JUq.js","assets/SearchLg-BUP3ozF2.js","assets/SearchMd-Dd7ZGI56.js","assets/Shield01-BI58H8tV.js","assets/Stars01-B6N3EY9X.js","assets/Trash01-CKx7yRIc.js","assets/Upload01-BEXZOkzx.js","assets/User01-WL7UxAwC.js","assets/Users01-BVVqJkbL.js","assets/XClose-DMc7p4CW.js","assets/X-B4leRLqf.js","assets/Zap-Zy5e7I3t.js","assets/automation-runs-eB3UxPqQ.js","assets/select-_BdZTxPS.js","assets/tooltip-XFj2xRwa.js","assets/useInfiniteQuery-MB3W9wV7.js","assets/use-infinite-scroll-ZPVDShE1.js","assets/use-connection-1A7IHNnw.js","assets/use-collections-D0Q6wvcH.js","assets/use-mcp-client-DS0Emn8e.js","assets/auth-Ta6fwTa4.js","assets/use-virtual-mcp-CSfbKXoe.js","assets/card-DNiOb8C_.js","assets/sidebar-D06GkkF0.js","assets/use-mobile-DSBAMYJF.js","assets/table-BjiI-gaG.js","assets/empty-state-DAC9lF38.js","assets/use-members-NR_NeOoj.js","assets/use-org-auth-client-Brlf7KHt.js","assets/use-clock-tick-Bs8YFyZt.js","assets/use-automations-5XmapDED.js","assets/studio-tools-BccAxrVu.js","assets/useSuspenseInfiniteQuery-D5GJvpsH.js","assets/avatar-B8_a8C3S.js","assets/format-time-BnbuEtat.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-Ddqaz7gu.js","assets/file-type-icon-CA2uuZ7F.js","assets/dialog-CEJEmlAZ.js","assets/tab-id-BijBBRwE.js","assets/hooks-9fTm-ZdN.js","assets/decopilot-sse-pool-BD-E8GML.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/chat-context-CaE1IrMD.js","assets/autosend-BhmTfxCS.js","assets/use-ai-providers-Bc2W8TAS.js","assets/location-BpLtHjTZ.js","assets/use-decopilot-events-XyNhQjC6.js","assets/use-organization-settings-B09wmnaH.js","assets/monaco-editor-Bh8y4XGF.js","assets/index-C6Xwww_u.js","assets/index-CdhReIUf.js","assets/calendar-CM0d8cf3.js","assets/shell-layout-BzSeIhlb.js","assets/use-t-CzC_cXLB.js","assets/required-auth-layout-DN9CNJ17.js","assets/use-org-sso-D_69Sai0.js","assets/integration-icon-GEOjw9nA.js","assets/use-navigate-to-agent-DvIjbi8Z.js","assets/reusable-new-chat-CouMjkYR.js","assets/AreaChart-C4-p1gQK.js","assets/form-xwt17q8h.js","assets/label-BUEwzrLz.js","assets/input-BgHT8C_Y.js","assets/dropdown-menu-Bohi0euR.js","assets/page-seo-form-BytIEBTv.js","assets/switch-DYnCFD5-.js","assets/add-section-modal-IG-4jW3o.js","assets/drawer-B16UsJ9z.js","assets/collection-search-DkaBDE88.js","assets/index-DEAM6UpC.js","assets/get-initials-D-f_fDFw.js","assets/use-registry-app-lYXnJYv0.js","assets/use-mcp-tools-BAfp0q-e.js","assets/github-repo-scope-DjMZbiKa.js","assets/authenticate-and-persist-oauth-BWqn4KLF.js","assets/mcp-oauth-y10dB3OG.js","assets/extract-connection-data-BOVpLxWL.js","assets/popover-BEGdNmUQ.js","assets/command-DtXbWX2t.js","assets/index-Jz0CuEFl.js","assets/companions-core-DU4JOcgk.js","assets/tabs-Dwdnv16R.js","assets/toggle-group-CmVcJdNh.js","assets/use-deco-credits-Mofa-D5b.js","assets/connection-card-DH9eHpgr.js","assets/use-registry-connections-CK8Y9s5Q.js","assets/retry-CErkP7V6.js","assets/connection-slug-eyAPH6o3.js","assets/textarea-BE7D_QqU.js","assets/connection-form-helpers-9cIttTn5.js","assets/collection-tabs-CjttU7gV.js","assets/badge-BZilNB5D.js","assets/connect-desktop-dialog-rRtqIhuV.js","assets/select-model-CdCA5sAQ.js","assets/checkbox-BiboLXsd.js","assets/skeleton-peXMJuH3.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-WJlRZThP.js","assets/index-CCMPN7OD.js","assets/alert-dialog-De7Jj0Gd.js","assets/toolbar-kZcoGdr4.js","assets/use-debounced-value-DBDdUa8t.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-xXWp62ox.js","assets/use-capability-BMD-Q3c_.js","assets/toolbar-icon-button-CSOZwc8p.js","assets/use-debounced-autosave-DA0Wn7VJ.js","assets/index--Rru8MRb.js","assets/search-input-B-DY-xf1.js","assets/use-mcp-auth-status-C9suHuMS.js","assets/github-repo-picker-Ce0749m3.js","assets/provision-repo-scoped-github-connection-2iDn-wQ1.js","assets/use-secrets-CrZ0-Hfb.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/use-file-configs-BtA47JHd.js","assets/automation-list-row-BcxbDbRm.js","assets/page-seo-sheet-mJW0tAP8.js","assets/file-explorer-C83rSApL.js","assets/app-editor-C5o42oU3.js","assets/post-editor-CEMsCtDO.js","assets/multi-select-AV0FE5T3.js","assets/block-document-CU_R1go5.js","assets/primitives-DrykBhU_.js","assets/use-autosave-iqnZwi6W.js","assets/record-editor-BEQrV1d8.js","assets/category-editor-omUhw8hw.js","assets/bulk-category-panel-CgSvwA00.js","assets/index-BQh3gSSP.js","assets/seo-editor-pHkOR1VP.js","assets/variant-calendar-Bhk3fwgs.js","assets/view-mode-toggle-DVDSH_UO.js","assets/redirect-editor-Bh-8Ulfx.js","assets/project-app-view-Cag9gDj3.js"])))=>i.map(i=>d[i]);
2
+ import{n as bs,r as k,a0 as N5,_ as A5,c as M,C as Ee,l as te,j as i,E as vs,t as de,H as en,ad as T5,I as ns,ae as Id,B as re,M as Dd,J as J1,af as E5,ag as R5,U as vr,ah as ws,ai as no,aj as Iu,b as yt,d as Gs,p as Ne,ak as P5,x as br,al as I5,am as X1,ac as Q1,K as it,an as Bl,a as Ai,ao as D5,ap as Z1,aq as O5,ar as un,as as Ec,at as qi,au as M5,av as Rc,aw as $5,ax as B5,ay as z5,az as F5,aA as U5,aB as H5,aC as K5,aD as W5,aE as em,aF as go,m as Ut,i as Xe,w as Od,u as _r,e as zl,G as q5,D as G5,v as tm,aG as Y5,L as sm,aH as J5,aI as nm,aJ as X5,aK as Fl,aL as ir,aM as et,aN as rr,aO as im,aP as Q5,aQ as Z5,aR as rm,aS as ex,aT as tx,aU as sx,aV as nx,aW as io,aX as Os,Y as ix}from"./index-BE6hzuPl.js";import{i as Md,n as rx}from"./ArrowUp-DCJUk93H.js";import{a as Vs,b as Ys,S as or,c as Ti,u as om,d as Qt,e as am,s as ox,f as ax,g as lx,p as lm,h as $d,A as cx,i as dx,j as ux,t as hx,k as fx,l as mx}from"./chat-context-CaE1IrMD.js";import{s as yr,g as mn,P as No,d as Bd,a as px,M as gx,i as xx,b as vx,F as bx,c as cm,e as dm,S as _x,u as yx,f as Lx,h as Sx,j as Du,k as wx,l as um,O as jx,m as ti,T as Cx,n as hm,R as kx,C as Vx,G as Nx,o as Ax,p as Tx,q as Ex,A as Rx}from"./automation-runs-eB3UxPqQ.js";import{c as _i,T as Ie,a as De,b as Oe}from"./tooltip-XFj2xRwa.js";import{D as us,a as hs,d as Zt,e as es,h as si,c as Ei}from"./dialog-CEJEmlAZ.js";import{c as Px,b as fm,a as mm,D as pm}from"./drawer-B16UsJ9z.js";import{C as Ix}from"./collection-search-DkaBDE88.js";import{u as Lr}from"./use-mobile-DSBAMYJF.js";import{a as qo,u as ut,S as Go,i as Za,c as Dx,d as Ox,W as Mx,e as $x,C as Ou,g as el,f as gm,b as Mu,m as Bx}from"./use-mcp-client-DS0Emn8e.js";import{u as xm,g as Yo,l as j0,X as zx,C as Fx,a as Ux,A as Hx,b as Kx,c as Wx}from"./AreaChart-C4-p1gQK.js";import{c as zd,t as yi,P as qx,a as Gx,i as ar,g as Yx,u as vm,E as Jx,b as Fd,M as Xx,d as bm,e as Qx,f as Zx,C as ev}from"./calendar-CM0d8cf3.js";import{t as ts}from"./ChevronDown-DDT8b8rP.js";import{i as js}from"./X-B4leRLqf.js";import{t as tv,z as sv,u as Ul,b as _m}from"./hooks-9fTm-ZdN.js";import{K as nv,i as ym,u as Jo,r as iv,a as Lm}from"./shell-layout-BzSeIhlb.js";import{u as Xo,a as fs,b as Ud,c as rv}from"./use-virtual-mcp-CSfbKXoe.js";import{w as Sm,A as ov}from"./autosend-BhmTfxCS.js";import{u as av,S as lv,a as cv,b as dv,r as $u,i as uv,c as hv,w as fv,H as mv,d as pv,e as gv,f as xv,g as wm,h as vv,j as bv,T as _v,k as yv,P as Lv,l as Sv,m as wv}from"./index-DEAM6UpC.js";import{n as lr,b as jm}from"./ZapSquare-DiRNwHBE.js";import{i as Ot}from"./ChevronUp-D-P6SBrW.js";import{s as pn}from"./Star01-BTYXST43.js";import{a as An}from"./Image01-CPHpxpf1.js";import{t as Hl,j as Cm,k as Hd,l as jv,m as Qs,n as Kd,o as Wd,p as km,q as Cv,A as Yn,r as Vm,u as Nm,v as kv,w as Vv,b as Am,x as Bu,d as Tm,y as Nv,z as Em,B as Av,C as Kl,D as Ri,E as qd,F as Rm,G as Pm,H as C0,I as Pc,J as zu,K as Tv,L as Ev,M as Rv,N as Pv,O as Iv,P as Dv,Q as Gd,R as Im,S as ni,T as Yd,U as Dm,e as Jd,h as Om,V as Xd,W as Ov,X as Mv,Y as $v,Z as kn,_ as tl,$ as Qo,a0 as Fu,a1 as Bv,a2 as zv,a3 as Fv,a4 as Uv,a5 as Mm,a6 as sl,a7 as $m,a8 as Hv,a9 as Kv,aa as Wv,ab as qv,ac as Gv,ad as Yv,ae as Jv,af as Xv,ag as Qv,ah as Uu,ai as Zv,aj as eb,ak as tb,al as sb,am as nb,an as ib,ao as rb,ap as Bm,aq as zm,ar as Fm}from"./agent-icon-n_DJILEj.js";import{i as Pi}from"./Upload01-BEXZOkzx.js";import{i as Sn}from"./AlertCircle-Clv-C2np.js";import{a as Ds}from"./Copy01-CyfFXTKR.js";import{a as k0,b as Qd,d as Zd,f as e9,F as Um}from"./form-xwt17q8h.js";import{c as Yt,S as Jt,d as pt,a as Xt,b as rs}from"./select-_BdZTxPS.js";import{b as Wl,a as ob,i as ab}from"./Settings02-DrOPo3mj.js";import{i as Sr,b as Hm,a as lb}from"./XCircle-Di8Uo4pL.js";import{T as gi,a as wr,b as Zo,c as gn}from"./tabs-Dwdnv16R.js";import{t as V0}from"./Tool02-DED34rla.js";import{a as t9,T as Ao}from"./toggle-group-CmVcJdNh.js";import{I as tt}from"./input-BgHT8C_Y.js";import{u as s9,b as ea,g as n9,A as i9,c as Km,a as tn,r as cb,f as db,d as ub}from"./use-deco-credits-Mofa-D5b.js";import{u as Ms}from"./studio-tools-BccAxrVu.js";import{i as jr}from"./Monitor01-6Irz93Em.js";import{C as hb,a as fb,b as mb,l as pb}from"./connect-desktop-dialog-rRtqIhuV.js";import{s as Tn}from"./XClose-DMc7p4CW.js";import{m as ql,i as gb,g as Wm,a as xb,N as vb,M as bb}from"./select-model-CdCA5sAQ.js";import{u as _b,a as qm}from"./use-members-NR_NeOoj.js";import{g as yb}from"./get-initials-D-f_fDFw.js";import{A as Ji}from"./avatar-B8_a8C3S.js";import{C as Jn,e as Is,a as Cs,f as Hu,d as Cr,b as Ii,c as Di,g as Lb}from"./command-DtXbWX2t.js";import{b as Ns,P as As,a as Ts}from"./popover-BEGdNmUQ.js";import{u as Gm}from"./useInfiniteQuery-MB3W9wV7.js";import{u as ta,a as r9,b as Ym}from"./use-mcp-tools-BAfp0q-e.js";import{D as as,a as ls,b as ro,c as cs,d as Ge,e as To,f as Eo,g as Ro,h as N0,i as sa,j as Xi}from"./dropdown-menu-Bohi0euR.js";import{t as Kn}from"./Stars01-B6N3EY9X.js";import{f as Sb,a as wb,s as jb,u as Cb,b as kb,c as Vb,d as Nb,g as Ab,e as Jm,h as Tb,R as Xm,i as nl,j as Qm,k as Eb,F as Rb,l as Pb,m as Ib,n as Db,o as Ob,p as Mb,q as $b,H as Bb,L as zb,r as Fb,S as Ub,B as Hb,t as Gl,T as o9,v as Kb}from"./index-CCMPN7OD.js";import{s as kt}from"./Plus-us-N9JUq.js";import{p as Wb,q as qb}from"./question-004-sINsf4GQ.js";import{i as vn}from"./ChevronRight-HnufFvB9.js";import{u as Zm}from"./use-ai-providers-Bc2W8TAS.js";import{i as Yl}from"./CheckCircle-BHKn_v25.js";import{I as on}from"./integration-icon-GEOjw9nA.js";import{u as Gb}from"./use-status-sounds-xXWp62ox.js";import{E as Li}from"./empty-state-DAC9lF38.js";import{r as il,a as Yb,p as e2,f as Ba,b as t2,c as s2,d as n2,e as Jb,F as Xb,g as Qb,h as Zb,i as e6,j as t6,k as s6,O as n6,l as i6,m as r6}from"./tab-id-BijBBRwE.js";import{T as rl}from"./toolbar-kZcoGdr4.js";import{a as Xn,b as na,i as i2,c as cr,d as o6,e as a6}from"./ZoomOut-tXRohD9g.js";import{u as Jl,a as r2,b as o2}from"./use-organization-settings-B09wmnaH.js";import{i as ii,n as l6}from"./Globe01-7xljr_EC.js";import{u as En,a as a9,b as a2}from"./use-connection-1A7IHNnw.js";import{g as Xl,M as c6}from"./index-CdhReIUf.js";import{e as l2}from"./backoff-CrEUbyZT.js";import{F as dr,M as l9,O as d6}from"./file-type-icon-CA2uuZ7F.js";import{u as u6}from"./use-capability-BMD-Q3c_.js";import{T as ur}from"./textarea-BE7D_QqU.js";import{s as c2}from"./Eye-DTlsPxh1.js";import{l as h6,w as f6}from"./index-C6Xwww_u.js";import{T as A0}from"./toolbar-icon-button-CSOZwc8p.js";import{g as m6}from"./extract-connection-data-BOVpLxWL.js";import{a as p6,i as Ku}from"./mcp-oauth-y10dB3OG.js";import{f as ol,a as al,b as ll,c as cl,d as dl,e as ul,A as hl,g as fl}from"./alert-dialog-De7Jj0Gd.js";import{C as c9,a as ml}from"./card-DNiOb8C_.js";import{i as Si}from"./Play-CwA4-KOo.js";import{s as ks}from"./Trash01-CKx7yRIc.js";import{u as pl}from"./use-debounced-autosave-DA0Wn7VJ.js";import{i as Po}from"./SearchMd-Dd7ZGI56.js";import{P as Zs}from"./index--Rru8MRb.js";import{C as kr}from"./checkbox-BiboLXsd.js";import{S as d9}from"./search-input-B-DY-xf1.js";import{C as d2}from"./collection-tabs-CjttU7gV.js";import{T as u2,u as h2}from"./use-mcp-auth-status-C9suHuMS.js";import{g as g6,s as f2}from"./connection-slug-eyAPH6o3.js";import{L as rt}from"./label-BUEwzrLz.js";import{S as hr}from"./switch-DYnCFD5-.js";import{i as x6}from"./LayoutLeft-1eHZDH0T.js";import{i as u9}from"./Key01-BMPHkbEG.js";import{G as Io}from"./use-registry-app-lYXnJYv0.js";import{G as m2}from"./github-repo-picker-Ce0749m3.js";import{S as Et}from"./skeleton-peXMJuH3.js";import{s as v6}from"./User01-WL7UxAwC.js";import{t as h9}from"./Users01-BVVqJkbL.js";import{u as b6,a as _6}from"./use-secrets-CrZ0-Hfb.js";import{f as y6}from"./formatDistanceToNow-Cb2QZZJn.js";import{a as p2}from"./format-time-BnbuEtat.js";import{i as g2}from"./ArrowUpRight-DwUunkDC.js";import{c as f9,s as m9,b as L6}from"./TrendUp01-CW6Njakg.js";import{g as S6}from"./github-repo-scope-DjMZbiKa.js";import{f as x2}from"./provision-repo-scoped-github-connection-2iDn-wQ1.js";import{m as w6,n as j6,o as C6,p as k6,q as V6}from"./sidebar-D06GkkF0.js";import{n as Rn}from"./LinkExternal01-CNmFDmgO.js";import{i as p9}from"./SearchLg-BUP3ozF2.js";import{i as g9,a as N6,b as x9,c as v9}from"./Tool01-Cg68N3nA.js";import{d as A6}from"./delay-CnY5UFtP.js";import{c as v2,i as T6}from"./SwitchHorizontal01-DSaA1AAh.js";import{i as wi}from"./Zap-Zy5e7I3t.js";import{M as ia}from"./monaco-editor-Bh8y4XGF.js";import{i as b2}from"./DotsVertical-4aFvnFGK.js";import{u as E6}from"./use-debounced-value-DBDdUa8t.js";import{u as R6,a as _2}from"./use-file-configs-BtA47JHd.js";import{i as P6}from"./FilterLines-CDNj37OS.js";import{B as I6}from"./badge-BZilNB5D.js";import{u as ra,a as D6,b as O6,c as M6,d as $6}from"./use-automations-5XmapDED.js";import{s as xo}from"./Stars02-BY1cpg45.js";import{A as B6}from"./automation-list-row-BcxbDbRm.js";function z6(t,e){const s=bs(e);return F6({filters:{...t,status:"pending"}},s).length}function Wu(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function F6(t={},e){const s=bs(e).getMutationCache(),n=k.useRef(t),r=k.useRef(null);return r.current===null&&(r.current=Wu(s,t)),k.useEffect(()=>{n.current=t}),k.useSyncExternalStore(k.useCallback(o=>s.subscribe(()=>{const a=N5(r.current,Wu(s,n.current));r.current!==a&&(r.current=a,A5.schedule(o))}),[s]),()=>r.current,()=>r.current)}const qu=3,y2="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",U6="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function L2(t){const e=M.c(46),{item:s,onSelect:n,isLoading:r,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const S=mn(c._meta);d=c.title??Bd(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let S;e[4]!==n||e[5]!==c?(S=()=>n(c),e[4]=n,e[5]=c,e[6]=S):S=e[6];const j=o||r,C=r&&"bg-accent/40",V=(o||r)&&"cursor-not-allowed opacity-50";let N;e[7]!==C||e[8]!==V?(N=te(U6,"hover:bg-accent/60 text-foreground",C,V),e[7]=C,e[8]=V,e[9]=N):N=e[9];let T;e[10]!==h?(T=i.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=T):T=e[11];let A;e[12]!==r?(A=r&&i.jsx(or,{size:"xs"}),e[12]=r,e[13]=A):A=e[13];let E;e[14]!==T||e[15]!==A?(E=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[T,A]}),e[14]=T,e[15]=A,e[16]=E):E=e[16];let R;e[17]!==u?(R=u&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=R):R=e[18];let D;return e[19]!==E||e[20]!==R||e[21]!==S||e[22]!==j||e[23]!==N?(D=i.jsxs("button",{type:"button",onClick:S,disabled:j,className:N,children:[E,R]}),e[19]=E,e[20]=R,e[21]=S,e[22]=j,e[23]=N,e[24]=D):D=e[24],D}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=te(y2,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=i.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let _;e[33]!==r?(_=r&&i.jsx(or,{size:"xs"}),e[33]=r,e[34]=_):_=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==_?(b=i.jsx(Ie,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,_]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=_,e[40]=b):b=e[40];const y=u??h;let L;e[41]!==y?(L=i.jsx(De,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==b||e[44]!==L?(w=i.jsxs(Oe,{delayDuration:400,children:[b,L]}),e[43]=b,e[44]=L,e[45]=w):w=e[45],w}function H6(t){const e=M.c(41),{items:s,open:n,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=k.useState(""),d=!!a;let h;e[0]!==s||e[1]!==l?(h=l.trim()?s.filter(j=>{const C=l.toLowerCase();return j.prompt.name.toLowerCase().includes(C)||(j.prompt.title??"").toLowerCase().includes(C)||(j.prompt.description??"").toLowerCase().includes(C)}):s,e[0]=s,e[1]=l,e[2]=h):h=e[2];const u=h,f=Lr();let m;e[3]!==u.length||e[4]!==l?(m=u.length===0&&i.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=u.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==u||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let j;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(j=C=>i.jsx(L2,{item:C,variant:"card",onSelect:V=>{r(!1),o(V)},isLoading:a?.name===C.prompt.name,isDisabled:d&&a?.name!==C.prompt.name},C.prompt.name),e[12]=d,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=j):j=e[16],p=u.map(j),e[6]=u,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=i.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const x=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{j.key==="Escape"&&c("")},e[20]=v):v=e[20];let _;e[21]!==l?(_=i.jsx(Ix,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=_):_=e[22];const b=_;if(f){let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Px,{className:"sr-only",children:i.jsx(fm,{children:"All prompts"})}),e[23]=j):j=e[23];let C;e[24]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=C):C=e[24];let V;e[25]!==x||e[26]!==b?(V=i.jsxs(mm,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[j,C,b,x]}),e[25]=x,e[26]=b,e[27]=V):V=e[27];let N;return e[28]!==r||e[29]!==n||e[30]!==V?(N=i.jsx(_i,{delayDuration:400,children:i.jsx(pm,{open:n,onOpenChange:r,children:V})}),e[28]=r,e[29]=n,e[30]=V,e[31]=N):N=e[31],N}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(us,{className:"sr-only",children:i.jsx(hs,{children:"All prompts"})}),e[32]=y):y=e[32];let L;e[33]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=L):L=e[33];let w;e[34]!==x||e[35]!==b?(w=i.jsxs(Zt,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,L,b,x]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let S;return e[37]!==r||e[38]!==n||e[39]!==w?(S=i.jsx(_i,{delayDuration:400,children:i.jsx(es,{open:n,onOpenChange:r,children:w})}),e[37]=r,e[38]=n,e[39]=w,e[40]=S):S=e[40],S}function K6(t){const e=M.c(29),{items:s,onSelect:n,loadingPrompt:r,className:o}=t,[a,l]=k.useState(!1);if(s.length===0)return null;let c,d,h;if(e[0]!==s||e[1]!==r||e[2]!==n){const v=s.slice(0,qu);let _;e[6]!==s?(_=s.slice(qu),e[6]=s,e[7]=_):_=e[7],c=_,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==n?(b=y=>i.jsx(L2,{item:y,onSelect:n,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=n,e[11]=b):b=e[11],h=v.map(b),e[0]=s,e[1]=r,e[2]=n,e[3]=c,e[4]=d,e[5]=h}else c=e[3],d=e[4],h=e[5];const u=h;let f;e[12]!==o?(f=te("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&i.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:te(y2,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=m):m=e[16];let p;e[17]!==u||e[18]!==f||e[19]!==m?(p=i.jsxs("div",{className:f,children:[u,m]}),e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==n?(g=i.jsx(H6,{items:s,open:a,onOpenChange:l,onSelect:n,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=n,e[25]=g):g=e[25];let x;return e[26]!==p||e[27]!==g?(x=i.jsxs(_i,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=x):x=e[28],x}function W6(){return null}function q6(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function G6(t){const e=M.c(30),{connectionId:s}=t,{sendMessage:n}=Ys(),{org:r}=Ee();let o;e[0]!==s||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:s,orgId:r.id,orgSlug:r.slug},e[0]=s,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const a=ut(o);let l;e[4]!==a?(l={client:a,staleTime:6e4},e[4]=a,e[5]=l):l=e[5];const{data:c}=xm(l);let d;e[6]!==c?.prompts?(d=c?.prompts??[],e[6]=c?.prompts,e[7]=d):d=e[7];const h=d;let u;e[8]!==h?(u=h.map(Y6),e[8]=h,e[9]=u):u=e[9];const f=u;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[p,g]=k.useReducer(q6,m),[x,v]=k.useState(null);let _;e[11]!==a||e[12]!==n?(_=async(A,E)=>{if(!a){de.error("MCP client not available"),g({type:"RESET"});return}try{const R=await Yo(a,A.name,E);g({type:"RESET"});const D={type:"doc",content:[{type:"paragraph",content:[zd({id:A.name,name:yr(A.name,mn(A._meta)),metadata:R.messages,char:"/",kind:"prompt",args:E}),{type:"text",text:" "}]}]};await n(D)}catch(R){console.error("[ice-breakers] Failed to fetch prompt:",R),de.error("Failed to load prompt. Please try again."),g({type:"RESET"})}},e[11]=a,e[12]=n,e[13]=_):_=e[13];const b=_;let y;e[14]!==b?(y=async A=>{if(A.arguments&&A.arguments.length>0){g({type:"SELECT_PROMPT",prompt:A}),v(A);return}g({type:"START_LOADING",prompt:A}),await b(A)},e[14]=b,e[15]=y):y=e[15];const L=y;let w;e[16]!==x||e[17]!==b?(w=async A=>{x&&(g({type:"START_LOADING",prompt:x,arguments:A}),v(null),await b(x,A))},e[16]=x,e[17]=b,e[18]=w):w=e[18];const S=w;if(f.length===0)return null;const j=p.stage==="loading"?p.prompt:null;let C;e[19]!==L||e[20]!==f||e[21]!==j?(C=i.jsx(K6,{items:f,onSelect:L,loadingPrompt:j}),e[19]=L,e[20]=f,e[21]=j,e[22]=C):C=e[22];let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{v(null),g({type:"RESET"})},e[23]=V):V=e[23];let N;e[24]!==x||e[25]!==S?(N=i.jsx(No,{prompt:x,setPrompt:V,onSubmit:S}),e[24]=x,e[25]=S,e[26]=N):N=e[26];let T;return e[27]!==C||e[28]!==N?(T=i.jsxs(i.Fragment,{children:[C,N]}),e[27]=C,e[28]=N,e[29]=T):T=e[29],T}function Y6(t){return{prompt:t}}function J6(t){const e=M.c(13),{className:s}=t,{selectedVirtualMcp:n}=Vs(),{org:r}=Ee();let o;e[0]!==r.id?(o=qo(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=te("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(W6,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=i.jsx(G6,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=i.jsx(vs,{fallback:null,children:i.jsx(k.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=i.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const Ic="cubic-bezier(0.645, 0.045, 0.355, 1)",X6=44,Q6={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-warning/5 after:pointer-events-none after:-z-10"},Z6={default:"border-border",error:"border-destructive/30",warning:"border-warning/30"},e_={default:"text-muted-foreground",error:"text-destructive",warning:"text-warning"};function Qn(t){const e=M.c(61),{icon:s,label:n,count:r,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,[m,p]=k.useState(d),[g,x]=k.useState(!1);let v;e[0]!==u?(v=()=>{x(!0),u?.()},e[0]=u,e[1]=v):v=e[1];const _=v;if(g)return null;const b=Z6[f],y=Q6[f];let L;e[2]!==b||e[3]!==y?(L=te("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",b,y),e[2]=b,e[3]=y,e[4]=L):L=e[4];let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(t_),e[5]=w):w=e[5];const S=m&&"rounded-b-none",j=!m&&"rounded-b-xl";let C;e[6]!==S||e[7]!==j?(C=te("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,j),e[6]=S,e[7]=j,e[8]=C):C=e[8];const V=e_[f];let N;e[9]!==V?(N=te("shrink-0",V),e[9]=V,e[10]=N):N=e[10];let T;e[11]!==s||e[12]!==N?(T=i.jsx("span",{className:N,children:s}),e[11]=s,e[12]=N,e[13]=T):T=e[13];let A;e[14]!==n?(A=i.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=A):A=e[15];let E;e[16]!==r?(E=r?i.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=E):E=e[17];const R=m?"rotate(180deg)":"rotate(0deg)";let D;e[18]!==R?(D=i.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:i.jsx(ts,{size:16,style:{transform:R,transition:`transform 180ms ${Ic}`}})}),e[18]=R,e[19]=D):D=e[19];let P,I;e[20]!==_?(P=ee=>{ee.stopPropagation(),_()},I=ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),ee.stopPropagation(),_())},e[20]=_,e[21]=P,e[22]=I):(P=e[21],I=e[22]);let O;e[23]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx(js,{size:16}),e[23]=O):O=e[23];let B;e[24]!==P||e[25]!==I?(B=i.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:P,onKeyDown:I,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:O}),e[24]=P,e[25]=I,e[26]=B):B=e[26];let z;e[27]!==m||e[28]!==T||e[29]!==A||e[30]!==E||e[31]!==D||e[32]!==B||e[33]!==C?(z=i.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:w,className:C,children:[T,A,E,D,B]}),e[27]=m,e[28]=T,e[29]=A,e[30]=E,e[31]=D,e[32]=B,e[33]=C,e[34]=z):z=e[34];const $=m?"1fr":"0fr";let U;e[35]!==$?(U={display:"grid",gridTemplateRows:$,transition:`grid-template-rows 180ms ${Ic}`},e[35]=$,e[36]=U):U=e[36];let W;e[37]===Symbol.for("react.memo_cache_sentinel")?(W={overflow:"hidden",minHeight:0},e[37]=W):W=e[37];const X=m?1:0;let H;e[38]!==X?(H={opacity:X,transition:`opacity 120ms ${Ic}`},e[38]=X,e[39]=H):H=e[39];let Z;e[40]!==o?(Z=o?i.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:i.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):i.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=Z):Z=e[41];let K;e[42]!==c||e[43]!==o?(K=c?i.jsx("div",{className:te("overflow-clip pb-4",!o&&"pt-4"),children:c}):null,e[42]=c,e[43]=o,e[44]=K):K=e[44];let Y;e[45]!==a||e[46]!==l?(Y=a||l?i.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=a,e[46]=l,e[47]=Y):Y=e[47];let F;e[48]!==H||e[49]!==Z||e[50]!==K||e[51]!==Y?(F=i.jsx("div",{style:W,children:i.jsxs("div",{style:H,children:[Z,K,Y]})}),e[48]=H,e[49]=Z,e[50]=K,e[51]=Y,e[52]=F):F=e[52];let Q;e[53]!==U||e[54]!==F?(Q=i.jsx("div",{"data-testid":"collapsible-highlight-body",style:U,children:F}),e[53]=U,e[54]=F,e[55]=Q):Q=e[55];let J;return e[56]!==z||e[57]!==Q||e[58]!==L||e[59]!==f?(J=i.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:L,children:[z,Q]}),e[56]=z,e[57]=Q,e[58]=L,e[59]=f,e[60]=J):J=e[60],J}function t_(t){return!t}const s_=en({content:ns().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:Id(["pending","in_progress","completed"]),activeForm:ns().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),S2=en({todos:T5(s_)}),n_="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";tv({description:n_,inputSchema:sv(S2),execute:async({todos:t})=>({ok:!0,count:t.length})});const i_="tool-todo_write",r_=new Set(["input-available","output-available"]);function o_(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type!==i_||typeof o.state!="string"||!r_.has(o.state))continue;const a=S2.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function w2(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const n="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:n,friendlyName:yi(px(n)),input:s.input})}return e}function j2(t){return t.at(-1)}function C2(t){const e=[];for(const s of t)s.type==="tool-propose_plan"&&s.state==="input-available"&&e.push({toolCallId:s.toolCallId,plan:s.input.plan,state:s.state});return e}function a_(t){return t?t.message.startsWith("[CREDITS]"):!1}const l_={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1,todos:[]};function c_(t){const{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&s&&a_(s))return{...l_,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(b=>b.type==="tool-user_ask").filter(b=>b.state!=="output-available").length,u=C2(l),f=w2(c),m=o_(e),p=!r&&!!s,g=f.length>0||r&&o,x=u.length>0,_=!r&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:_,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h,todos:m}}function k2(){const t=M.c(6),{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=Ys(),a=s??null,l=n??null;let c;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=c_({messages:e,error:a,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function d_(){const t=k2();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function u_(t){const e=M.c(21),{current:s,total:n,onPrev:r,onNext:o}=t;if(n<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=te("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Wl,{size:14}),e[2]=d):d=e[2];let h;e[3]!==r||e[4]!==a||e[5]!==c?(h=i.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=h):h=e[6];const u=s+1;let f;e[7]!==u||e[8]!==n?(f=i.jsxs("span",{className:"tabular-nums text-xs",children:[u," of ",n]}),e[7]=u,e[8]=n,e[9]=f):f=e[9];const m=s===n-1,p=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=te("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Sr,{size:14}),e[12]=x):x=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=i.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:x}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let _;return e[17]!==v||e[18]!==h||e[19]!==f?(_=i.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[h,f,v]}),e[17]=v,e[18]=h,e[19]=f,e[20]=_):_=e[20],_}function V2(t){const e=M.c(8),{currentIndex:s,total:n,onPrev:r,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(l=i.jsx(u_,{current:s,total:n,onPrev:r,onNext:o}),e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function h_(t){const e=M.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!r,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=te("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=i.jsx(re,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let _;e[10]!==v?(_=i.jsx(Ie,{asChild:!0,children:v}),e[10]=v,e[11]=_):_=e[11];let b;e[12]!==f?(b=i.jsx(De,{children:f}),e[12]=f,e[13]=b):b=e[13];let y;return e[14]!==_||e[15]!==b?(y=i.jsxs(Oe,{children:[_,b]}),e[14]=_,e[15]=b,e[16]=y):y=e[16],y}function N2(t,e,s){return t.findIndex(n=>e(n)===s)}function Gu(t,e,s,n){return t.length===0?!1:t.every(r=>n(s[e(r)]))}function Yu(t,e,s,n,r){if(t.length===0)return null;const o=N2(t,e,r);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==r&&!n(s[c]))return c}return null}function f_(t){return!t.isStreaming&&t.allAnswered}function A2(t){const{parts:e,partKey:s,schema:n,defaultValues:r,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=k.useState(c),[u,f]=k.useState(!1),m=Dd({resolver:J1(n),defaultValues:r}),p=m.watch(),g=N2(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),_=Gu(e,s,p,a),b=f_({isStreaming:o,allAnswered:_}),y=()=>{if(g>0){const N=e[g-1];N&&h(s(N))}},L=()=>{if(g>=0&&g<e.length-1){const N=e[g+1];N&&h(s(N))}},w=()=>{const N=m.getValues(),T=Yu(e,s,N,a,d);T&&h(T)},S=()=>{m.handleSubmit(N=>{const T=N;for(const A of e)l(A,T[s(A)])})()},j=k.useRef(S);j.current=S;const C=()=>{b&&(f(!1),j.current())},V=()=>{const N=m.getValues();if(Gu(e,s,N,a)){if(o){f(!0);return}f(!1),j.current()}else{const T=Yu(e,s,N,a,d);T&&h(T)}};return k.useEffect(()=>{if(u&&!o){if(!_){f(!1);return}f(!1),j.current()}},[u,o,_]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:_,canSubmit:b,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:C,submitOrAdvance:V}}const T2="User denied this tool call, give other alternatives.";function E2(t){const e=M.c(9),{onYolo:s}=t,[n,r]=vr();let o;e[0]!==s||e[1]!==n||e[2]!==r?(o=h=>{const u=h,f=n.toolApprovalLevel??"readonly";r({...n,toolApprovalLevel:u}),u==="auto"&&s(f)},e[0]=s,e[1]=n,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(Xt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:p_,children:i.jsx(rs,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Yt,{children:no.map(m_)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==n.toolApprovalLevel?(d=i.jsxs(Jt,{value:n.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=n.toolApprovalLevel,e[8]=d):d=e[8],d}function m_(t){return i.jsx(pt,{value:t.value,children:t.label},t.value)}function p_(t){return t.stopPropagation()}function R2(t){const e=M.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let n;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],n=o}catch{n=String(s)}let r;return e[3]!==n?(r=i.jsx("div",{className:"px-4",children:i.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:n})}),e[3]=n,e[4]=r):r=e[4],r}function g_(t){const e=M.c(28),{approval:s,onRespond:n}=t,[r]=vr(),o=r.toolApprovalLevel??"readonly";let a;e[0]!==s.approvalId||e[1]!==o||e[2]!==n?(a=()=>n(s.approvalId,!1,T2,o),e[0]=s.approvalId,e[1]=o,e[2]=n,e[3]=a):a=e[3];const l=a;let c;e[4]!==s.approvalId||e[5]!==o||e[6]!==n?(c=()=>n(s.approvalId,!0,void 0,o),e[4]=s.approvalId,e[5]=o,e[6]=n,e[7]=c):c=e[7];const d=c;let h;e[8]!==s.approvalId||e[9]!==n?(h=L=>n(s.approvalId,!0,void 0,L),e[8]=s.approvalId,e[9]=n,e[10]=h):h=e[10];const u=h;let f;e[11]!==u?(f=i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(E2,{onYolo:u})}),e[11]=u,e[12]=f):f=e[12];const m=f;let p;e[13]!==l?(p=i.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:l,children:"Deny"}),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==d?(g=i.jsx(re,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=i.jsxs(i.Fragment,{children:[p,g]}),e[17]=p,e[18]=g,e[19]=x):x=e[19];const v=x;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(Hl,{size:14}),e[20]=_):_=e[20];let b;e[21]!==s.input?(b=i.jsx(R2,{input:s.input}),e[21]=s.input,e[22]=b):b=e[22];let y;return e[23]!==s.friendlyName||e[24]!==m||e[25]!==v||e[26]!==b?(y=i.jsx(Qn,{icon:_,label:"Approval needed",title:s.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:v,children:b}),e[23]=s.friendlyName,e[24]=m,e[25]=v,e[26]=b,e[27]=y):y=e[27],y}const x_=E5(ns(),en({approved:R5().optional(),levelOverride:Id(["auto","readonly"]).optional()}));function v_(t){const e=M.c(42),{approvals:s,isStreaming:n,onRespond:r}=t,[o]=vr(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s?(l=Object.fromEntries(s.map(y_)),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==a||e[3]!==r?(d=(V,N)=>{const T=N;typeof T?.approved=="boolean"&&r(V.approvalId,T.approved,T.approved===!1?T2:void 0,T.levelOverride??a)},e[2]=a,e[3]=r,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==c||e[7]!==n||e[8]!==d?(h={parts:s,partKey:__,schema:x_,defaultValues:c,isStreaming:n,hasAnswer:b_,onSubmit:d},e[5]=s,e[6]=c,e[7]=n,e[8]=d,e[9]=h):h=e[9];const u=A2(h);let f;e[10]!==s||e[11]!==u?(f=V=>{u.form.reset(Object.fromEntries(s.map(N=>[N.approvalId,{approved:!0,levelOverride:V}]))),u.submitOrAdvance()},e[10]=s,e[11]=u,e[12]=f):f=e[12];const m=f,p=u.currentPart;let g;e[13]!==u?(g=V=>{V.preventDefault(),u.submit()},e[13]=u,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Hl,{size:14}),e[15]=x):x=e[15];const v=`${s.length} approvals pending`,_=p?.friendlyName??"";let b;e[16]!==m?(b=i.jsx(E2,{onYolo:m}),e[16]=m,e[17]=b):b=e[17];let y;e[18]!==s.length||e[19]!==u.currentIndex||e[20]!==u.goNext||e[21]!==u.goPrev||e[22]!==b?(y=i.jsx(V2,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext,extraLeft:b}),e[18]=s.length,e[19]=u.currentIndex,e[20]=u.goNext,e[21]=u.goPrev,e[22]=b,e[23]=y):y=e[23];let L;e[24]!==p||e[25]!==u.form.control||e[26]!==u.submitOrAdvance?(L=p?i.jsx(L_,{approvalId:p.approvalId,control:u.form.control,onChange:u.submitOrAdvance}):null,e[24]=p,e[25]=u.form.control,e[26]=u.submitOrAdvance,e[27]=L):L=e[27];let w;e[28]!==p?(w=p?i.jsx(R2,{input:p.input}):null,e[28]=p,e[29]=w):w=e[29];let S;e[30]!==y||e[31]!==L||e[32]!==w||e[33]!==v||e[34]!==_?(S=i.jsx(Qn,{icon:x,label:v,title:_,defaultExpanded:!0,footerLeft:y,footerRight:L,children:w}),e[30]=y,e[31]=L,e[32]=w,e[33]=v,e[34]=_,e[35]=S):S=e[35];let j;e[36]!==S||e[37]!==g?(j=i.jsx("form",{onSubmit:g,children:S}),e[36]=S,e[37]=g,e[38]=j):j=e[38];let C;return e[39]!==u.form||e[40]!==j?(C=i.jsx(k0,{...u.form,children:j}),e[39]=u.form,e[40]=j,e[41]=C):C=e[41],C}function b_(t){return typeof t?.approved=="boolean"}function __(t){return t.approvalId}function y_(t){return[t.approvalId,{approved:void 0}]}function L_(t){const e=M.c(6),{approvalId:s,control:n,onChange:r}=t,o=`${s}.approved`;let a;e[0]!==r?(a=c=>{const{field:d}=c,h=d.value===!0,u=d.value===!1;return i.jsxs(i.Fragment,{children:[i.jsx(re,{type:"button",variant:u?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":u,children:"Deny"}),i.jsx(re,{type:"button",variant:h?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":h,children:"Accept"})]})},e[0]=r,e[1]=a):a=e[1];let l;return e[2]!==n||e[3]!==o||e[4]!==a?(l=i.jsx(ws,{control:n,name:o,render:a}),e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function S_(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(Hl,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function w_(t){const e=M.c(8),{approvals:s,isStreaming:n,onRespond:r}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(S_,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==r||e[2]!==a?(l=i.jsx(g_,{approval:a,onRespond:r}),e[1]=r,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==r?(o=i.jsx(v_,{approvals:s,isStreaming:n,onRespond:r}),e[4]=s,e[5]=n,e[6]=r,e[7]=o):o=e[7],o}function j_(t){const e=M.c(16),{plan:s,onApprove:n,onDismiss:r}=t;let o;e[0]!==n||e[1]!==s.plan?(o=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=i.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=i.jsx(re,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=i.jsxs(i.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const h=d;let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Cm,{size:14}),e[10]=u):u=e[10];let f;e[11]!==s.plan?(f=i.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:i.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:i.jsx(gx,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[11]=s.plan,e[12]=f):f=e[12];let m;return e[13]!==h||e[14]!==f?(m=i.jsx(Qn,{icon:u,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:h,children:f}),e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function C_(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(Ot,{className:"size-5 text-purple-500 shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function k_(t){const e=M.c(7),{plans:s,isStreaming:n,onApprove:r,onDismiss:o}=t;if(n&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(C_,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=j2(s),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==r||e[5]!==o?(c=i.jsx(j_,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function P2(t){return t?"response"in t?t.response:t.option??t.draft:""}const Ju=en({response:ns().min(1,"Response is required")}),V_=en({option:ns().nullable(),draft:ns()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),N_=en({response:Id(["yes","no"])});function A_(t){switch(t.type){case"text":return Ju;case"choice":return V_;case"confirm":return N_;default:return Ju}}function T_(t){const e={};for(const s of t)e[s.toolCallId]=A_(s.input);return en(e)}function E_(t){const e=M.c(6),{control:s,name:n,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l,d=c.value??"";return i.jsxs(Qd,{children:[i.jsx(Zd,{children:i.jsx("div",{className:"px-2",children:i.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(Hd,{size:16,className:"text-muted-foreground"})}),i.jsx("input",{...c,value:d,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),i.jsx(e9,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==n||e[4]!==o?(a=i.jsx(Um,{control:s,name:n,render:o}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5],a}function I2(t,e){const s=M.c(4);let n,r;s[0]!==t||s[1]!==e?(n=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=r):(n=s[2],r=s[3]),k.useEffect(n,r)}function R_(t){const e=M.c(40),{control:s,name:n,options:r}=t,o=`${n}.option`;let a;e[0]!==s||e[1]!==o?(a={control:s,name:o,defaultValue:null},e[0]=s,e[1]=o,e[2]=a):a=e[2];const{field:l}=Iu(a),c=`${n}.draft`;let d;e[3]!==s||e[4]!==c?(d={control:s,name:c,defaultValue:""},e[3]=s,e[4]=c,e[5]=d):d=e[5];const{field:h}=Iu(d),u=l.value,f=h.value??"";let m;if(e[6]!==l||e[7]!==r?(m=T=>{const A=r[T];A!=null&&l.onChange(A)},e[6]=l,e[7]=r,e[8]=m):m=e[8],I2(r.length,m),r.length===0)return null;const p=u===null;let g;if(e[9]!==l||e[10]!==u||e[11]!==r){let T;e[13]!==l||e[14]!==u?(T=(A,E)=>{const R=u===A;return i.jsxs("button",{type:"button",onClick:()=>l.onChange(A),className:te("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",R&&"bg-accent/50",!R&&"hover:bg-accent/30"),"aria-label":`Select ${A}`,children:[i.jsx("span",{className:te("flex items-center justify-center size-6 rounded-md text-sm shrink-0",R?"bg-chart-1 text-white":"bg-muted text-foreground"),children:E+1}),i.jsx("span",{className:"text-sm text-foreground truncate",children:A})]},`${E}-${A}`)},e[13]=l,e[14]=u,e[15]=T):T=e[15],g=r.map(T),e[9]=l,e[10]=u,e[11]=r,e[12]=g}else g=e[12];const x=p&&"bg-accent/50",v=!p&&"hover:bg-accent/30";let _;e[16]!==x||e[17]!==v?(_=te("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x,v),e[16]=x,e[17]=v,e[18]=_):_=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(Hd,{size:16,className:"text-muted-foreground"})}),e[19]=b):b=e[19];const y=p?f:"";let L;e[20]!==h||e[21]!==l||e[22]!==u?(L=T=>{h.onChange(T.target.value),u!==null&&l.onChange(null)},e[20]=h,e[21]=l,e[22]=u,e[23]=L):L=e[23];let w;e[24]!==l||e[25]!==u?(w=()=>{u!==null&&l.onChange(null)},e[24]=l,e[25]=u,e[26]=w):w=e[26];let S;e[27]!==y||e[28]!==L||e[29]!==w?(S=i.jsx("input",{type:"text",value:y,onChange:L,onFocus:w,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=y,e[28]=L,e[29]=w,e[30]=S):S=e[30];let j;e[31]!==S||e[32]!==_?(j=i.jsxs("label",{className:_,children:[b,S]}),e[31]=S,e[32]=_,e[33]=j):j=e[33];let C;e[34]!==j||e[35]!==g?(C=i.jsx(Zd,{children:i.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[g,j]})}),e[34]=j,e[35]=g,e[36]=C):C=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(e9,{}),e[37]=V):V=e[37];let N;return e[38]!==C?(N=i.jsxs(Qd,{children:[C,V]}),e[38]=C,e[39]=N):N=e[39],N}function P_(t){const e=M.c(6),{control:s,name:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=k.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=h=>{a.current?.onChange(o[h]??"")},e[1]=l):l=e[1],I2(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=h=>{const{field:u}=h;return a.current=u,i.jsxs(Qd,{children:[i.jsx(Zd,{children:i.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=u.value===f;return i.jsxs("button",{type:"button",onClick:()=>u.onChange(f),className:te("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[i.jsx("span",{className:te("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),i.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),i.jsx(e9,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==n?(d=i.jsx(Um,{control:s,name:n,render:c}),e[3]=s,e[4]=n,e[5]=d):d=e[5],d}function Xu(t){const e=M.c(13),{input:s,control:n,toolCallId:r}=t;switch(s.type){case"text":{const o=`${r}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=i.jsx(E_,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let l;return e[6]!==n||e[7]!==a||e[8]!==r?(l=i.jsx(R_,{control:n,name:r,options:a}),e[6]=n,e[7]=a,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let a;return e[10]!==n||e[11]!==o?(a=i.jsx(P_,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function I_(t){const e=M.c(71),{parts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=T_(s.map($_)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(M_)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==r?(d=(P,I)=>{const O=P2(I);O&&r(P,O)},e[4]=r,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:O_,schema:a,defaultValues:c,isStreaming:n,hasAnswer:D_,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=A2(h),f=u.currentPart;let m;e[12]!==f||e[13]!==u?(m=()=>{const P=f;if(!P)return;const I=P.toolCallId;P.input?.type==="choice"?(u.form.setValue(`${I}.option`,null),u.form.setValue(`${I}.draft`,"user has skip this question")):u.form.setValue(`${I}.response`,"user has skip this question"),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=m;let g;e[15]!==u.currentIndex||e[16]!==u.goNext||e[17]!==u.goPrev||e[18]!==s.length?(g=i.jsx(V2,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[15]=u.currentIndex,e[16]=u.goNext,e[17]=u.goPrev,e[18]=s.length,e[19]=g):g=e[19];const x=g;let v;e[20]!==p?(v=i.jsx(re,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),e[20]=p,e[21]=v):v=e[21];let _;e[22]!==u.isAllAnswered||e[23]!==u.isCurrentAnswered||e[24]!==u.submitOrAdvance||e[25]!==n?(_=i.jsx(h_,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[22]=u.isAllAnswered,e[23]=u.isCurrentAnswered,e[24]=u.submitOrAdvance,e[25]=n,e[26]=_):_=e[26];let b;e[27]!==v||e[28]!==_?(b=i.jsxs(i.Fragment,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=b):b=e[29];const y=b;if(s.length===1){const P=s[0];if(!P?.input)return null;let I;e[30]!==u?(I=H=>{H.preventDefault(),u.submit()},e[30]=u,e[31]=I):I=e[31];let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx(V0,{size:14}),e[32]=O):O=e[32];const B=P.input?.prompt??"Question",z=P.input;let $;e[33]!==u.form.control||e[34]!==P.toolCallId||e[35]!==z?($=i.jsx(Xu,{input:z,control:u.form.control,toolCallId:P.toolCallId}),e[33]=u.form.control,e[34]=P.toolCallId,e[35]=z,e[36]=$):$=e[36];let U;e[37]!==y||e[38]!==B||e[39]!==$?(U=i.jsx(Qn,{icon:O,label:"Question pending",title:B,defaultExpanded:!0,footerRight:y,children:$}),e[37]=y,e[38]=B,e[39]=$,e[40]=U):U=e[40];let W;e[41]!==I||e[42]!==U?(W=i.jsx("form",{onSubmit:I,autoComplete:"off",children:U}),e[41]=I,e[42]=U,e[43]=W):W=e[43];let X;return e[44]!==u.form||e[45]!==W?(X=i.jsx(k0,{...u.form,children:W}),e[44]=u.form,e[45]=W,e[46]=X):X=e[46],X}const L=u.form;let w;e[47]!==u?(w=P=>{P.preventDefault(),u.submit()},e[47]=u,e[48]=w):w=e[48];let S;e[49]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(V0,{size:14}),e[49]=S):S=e[49];const j=`${u.currentIndex+1} of ${s.length}`,C=f?.input?.prompt??"Question",V=u.activeKey,N=u.setActiveKey;let T;if(e[50]!==u.form||e[51]!==s){let P;e[53]!==u.form?(P=I=>i.jsx(gi,{value:I.toolCallId,className:"mt-0",children:i.jsx(Xu,{input:I.input,control:u.form.control,toolCallId:I.toolCallId})},I.toolCallId),e[53]=u.form,e[54]=P):P=e[54],T=s.map(P),e[50]=u.form,e[51]=s,e[52]=T}else T=e[52];let A;e[55]!==u.activeKey||e[56]!==u.setActiveKey||e[57]!==T?(A=i.jsx(wr,{value:V,onValueChange:N,children:T}),e[55]=u.activeKey,e[56]=u.setActiveKey,e[57]=T,e[58]=A):A=e[58];let E;e[59]!==x||e[60]!==y||e[61]!==j||e[62]!==C||e[63]!==A?(E=i.jsx(Qn,{icon:S,label:"Question pending",count:j,title:C,defaultExpanded:!0,footerLeft:x,footerRight:y,children:A}),e[59]=x,e[60]=y,e[61]=j,e[62]=C,e[63]=A,e[64]=E):E=e[64];let R;e[65]!==w||e[66]!==E?(R=i.jsx("form",{onSubmit:w,autoComplete:"off",children:E}),e[65]=w,e[66]=E,e[67]=R):R=e[67];let D;return e[68]!==u.form||e[69]!==R?(D=i.jsx(k0,{...L,children:R}),e[68]=u.form,e[69]=R,e[70]=D):D=e[70],D}function D_(t){return!!P2(t)}function O_(t){return t.toolCallId}function M_(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function $_(t){return{toolCallId:t.toolCallId,input:t.input}}function B_(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(V0,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function D2(t){const e=M.c(7),{userAskParts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(z_),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(B_,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==r||e[5]!==a?(l=i.jsx(I_,{parts:a,isStreaming:n,onSubmit:r}),e[3]=n,e[4]=r,e[5]=a,e[6]=l):l=e[6],l}function z_(t){return t.state==="input-available"}function F_(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function U_(t){const e=M.c(13),{todos:s}=t;if(s.length===0)return null;let n;e[0]!==s?(n=F_(s),e[0]=s,e[1]=n):n=e[1];const r=n;let o;e[2]!==r.icon?(o=i.jsx(q_,{status:r.icon}),e[2]=r.icon,e[3]=o):o=e[3];const a=r.activity,l=r.progress;let c;e[4]!==s?(c=s.map(H_),e[4]=s,e[5]=c):c=e[5];let d;e[6]!==c?(d=i.jsx("ul",{"data-testid":"todos-list",className:"flex flex-col px-2 max-h-[40vh] overflow-y-auto",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==r.activity||e[9]!==r.progress||e[10]!==o||e[11]!==d?(h=i.jsx(Qn,{icon:o,label:a,count:l,defaultExpanded:!1,children:d}),e[8]=r.activity,e[9]=r.progress,e[10]=o,e[11]=d,e[12]=h):h=e[12],h}function H_(t,e){return i.jsx(K_,{todo:t},e)}function K_(t){const e=M.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=i.jsx(W_,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=te("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=i.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=i.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function W_(t){const e=M.c(4),{status:s}=t,n=s==="completed"?"true":void 0,r=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("svg",{viewBox:"0 0 21 21",children:i.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let a;return e[1]!==n||e[2]!==r?(a=i.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function q_(t){const e=M.c(3),{status:s}=t;if(s==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:i.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:i.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(s==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=n):n=e[2],n}const G_={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},Y_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function O2(t){const e=M.c(41),{onDismiss:s}=t,{org:n}=Ee(),r=yt(),{decoKeyId:o}=s9(),a=Ms(),[l,c]=k.useState(""),[d,h]=k.useState(!1),[u,f]=k.useState("usd"),m=u==="brl"?"R$":"$";let p,g;e[0]!==n.id?(p=()=>{Ne("credits_exhausted_shown",{organization_id:n.id})},g=[n.id],e[0]=n.id,e[1]=p,e[2]=g):(p=e[1],g=e[2]),k.useEffect(p,g);let x;e[3]!==u||e[4]!==a?(x=async P=>{const{url:I}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:P,currency:u});return I},e[3]=u,e[4]=a,e[5]=x):x=e[5];let v;e[6]!==s?(v=P=>{P&&window.open(P,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=v):v=e[7];let _;e[8]!==x||e[9]!==v?(_={mutationFn:x,onSuccess:v,onError:Q_},e[8]=x,e[9]=v,e[10]=_):_=e[10];const{mutate:b,isPending:y}=Gs(_),L=parseFloat(l),w=!isNaN(L)&&L>=1;let S;e[11]!==s?(S=P=>!P&&s?.(),e[11]=s,e[12]=S):S=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[13]=j):j=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=C):C=e[14];let V;e[15]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[C,i.jsxs(us,{className:"relative gap-4",children:[i.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),i.jsxs("div",{children:[i.jsx(hs,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),i.jsx(si,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[15]=V):V=e[15];let N;e[16]!==u||e[17]!==m||e[18]!==l||e[19]!==L||e[20]!==o||e[21]!==w||e[22]!==y||e[23]!==d||e[24]!==b?(N=o&&i.jsxs("div",{className:"px-8 pt-5 pb-6",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(t9,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:P=>{P&&f(P)},children:[i.jsx(Ao,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(Ao,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsxs("div",{className:"rounded-xl border border-border p-5",children:[i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:G_[u].map(P=>{const{dollars:I,label:O}=P;return i.jsxs("button",{type:"button",disabled:y,onClick:()=>{Ne("credits_topup_clicked",{amount_cents:I*100,currency:u,tier_label:O,source:"exhausted_banner"}),b(I*100)},className:te("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,I]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},I)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(tt,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:P=>c(P.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(re,{className:"h-10",disabled:!w||y,onClick:()=>{Ne("credits_topup_clicked",{amount_cents:Math.round(L*100),currency:u,tier_label:"custom",source:"exhausted_banner"}),b(Math.round(L*100))},children:y?"Opening...":"Add"})]}):i.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),i.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Y_.map(J_)})]}),e[16]=u,e[17]=m,e[18]=l,e[19]=L,e[20]=o,e[21]=w,e[22]=y,e[23]=d,e[24]=b,e[25]=N):N=e[25];let T;e[26]!==s?(T=i.jsx(re,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[26]=s,e[27]=T):T=e[27];let A;e[28]!==r||e[29]!==s||e[30]!==n.slug?(A=i.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},children:"Manage providers"}),e[28]=r,e[29]=s,e[30]=n.slug,e[31]=A):A=e[31];let E;e[32]!==T||e[33]!==A?(E=i.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[T,A]}),e[32]=T,e[33]=A,e[34]=E):E=e[34];let R;e[35]!==N||e[36]!==E?(R=i.jsxs(Zt,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:X_,children:[V,N,E]}),e[35]=N,e[36]=E,e[37]=R):R=e[37];let D;return e[38]!==R||e[39]!==S?(D=i.jsx(es,{open:!0,onOpenChange:S,children:R}),e[38]=R,e[39]=S,e[40]=D):D=e[40],D}function J_(t){return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:i.jsx(Ot,{size:12,className:"text-[hsl(var(--chart-1))]"})}),i.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function X_(t){return t.preventDefault()}function Q_(t){de.error(`Top-up failed: ${t.message}`)}function Z_(){const t=M.c(5),e=Ti(),s=om(),[n,r]=k.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!s.ready||s.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(jr,{size:14}),t[0]=a):a=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(re,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Qn,{icon:a,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:l,children:i.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",i.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=c):c=t[2];let d;return t[3]!==n?(d=i.jsxs(i.Fragment,{children:[c,i.jsx(hb,{open:n,onOpenChange:r})]}),t[3]=n,t[4]=d):d=t[4],d}function ey(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const ty={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function gl(t){const e=M.c(19),{variant:s,onDismiss:n}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?Sn:br,l=r?t.error.message:ty[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let c;e[0]!==r||e[1]!==l?(c=r?ey(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=c):c=e[2];const{summary:d,rawDetails:h}=c;let u;e[3]!==a?(u=i.jsx(a,{size:14}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(f=r?i.jsx(re,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):i.jsx(re,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=f):f=e[8];let m;e[9]!==h?(m=h?i.jsxs("details",{className:"group mx-4",children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"m4.5 3 3 3-3 3"})}),i.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),i.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),i.jsxs("div",{className:"relative mt-2",children:[i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(h).then(ny).catch(sy)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:i.jsx(Ds,{className:"size-3.5"})}),i.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:h})]})]}):null,e[9]=h,e[10]=m):m=e[10];let p;return e[11]!==o||e[12]!==n||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m||e[17]!==s?(p=i.jsx(Qn,{icon:u,label:o,title:d,defaultExpanded:!0,variant:s,onClose:n,footerRight:f,children:m}),e[11]=o,e[12]=n,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=s,e[18]=p):p=e[18],p}function sy(){return de.error("Could not copy")}function ny(){return de.success("Copied to clipboard")}function Ql(){const t=M.c(64),{error:e,clearError:s,finishReason:n,clearFinishReason:r,messages:o,isStreaming:a,submit:l,sendMessage:c}=Ys(),[d,h]=vr(),{virtualMcpId:u,createTaskWithMessage:f}=Qt(),{chatMode:m,simpleModeTier:p}=Vs();let g;t[0]!==m||t[1]!==p||t[2]!==u?(g=q=>({tier:p,mode:m,toolApprovalLevel:q,agent:u?{id:u}:void 0}),t[0]=m,t[1]=p,t[2]=u,t[3]=g):g=t[3];const x=g;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??P5(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const _=v,b=o.at(-1),y=b?.role==="assistant"?b.parts:[],L=y.filter(ay),w=C2(y),S=w2(y);let j;t[6]!==e||t[7]!==c?(j=()=>{if(e){const se={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};c(se)}},t[6]=e,t[7]=c,t[8]=j):j=t[8];const C=j;let V;t[9]!==c?(V=()=>{c({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=c,t[10]=V):V=t[10];const N=V;let T;t[11]!==x||t[12]!==_||t[13]!==l?(T=(q,se)=>{l({kind:"toolOutput",toolCallId:q.toolCallId,output:{response:se}},x(_))},t[11]=x,t[12]=_,t[13]=l,t[14]=T):T=t[14];const A=T;let E;t[15]!==f||t[16]!==d||t[17]!==h||t[18]!==u?(E=q=>{h({...d,toolApprovalLevel:"auto"}),f({virtualMcpId:u,message:{parts:[{type:"text",text:`Implement this plan:
3
+
4
+ ${q}`}]}})},t[15]=f,t[16]=d,t[17]=h,t[18]=u,t[19]=E):E=t[19];const R=E,D=oy;let P;t[20]!==x||t[21]!==l?(P=(q,se,ne,le)=>{l({kind:"approval",approvalId:q,approved:se,...ne?{reason:ne}:{}},x(le))},t[20]=x,t[21]=l,t[22]=P):P=t[22];const I=P,O=k2();if(O.isCreditExhausted){let q;return t[23]!==s?(q=i.jsx(O2,{onDismiss:s}),t[23]=s,t[24]=q):q=t[24],q}const{showError:B,showWarning:z,hasApprovals:$}=O,U=L.map(ry).join("|"),W=j2(w)?.toolCallId??"",X=S.map(iy).join("|");let H;t[25]!==O.todos?(H=i.jsx(U_,{todos:O.todos}),t[25]=O.todos,t[26]=H):H=t[26];let Z;t[27]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx(Z_,{}),t[27]=Z):Z=t[27];let K;t[28]!==s||t[29]!==e||t[30]!==C||t[31]!==B?(K=B&&i.jsx(gl,{variant:"error",error:e,onDismiss:s,onFixInChat:C}),t[28]=s,t[29]=e,t[30]=C,t[31]=B,t[32]=K):K=t[32];let Y;t[33]!==r||t[34]!==n||t[35]!==N||t[36]!==z?(Y=z&&i.jsx(gl,{variant:"warning",finishReason:n,onDismiss:r,onContinue:N}),t[33]=r,t[34]=n,t[35]=N,t[36]=z,t[37]=Y):Y=t[37];let F;t[38]!==X||t[39]!==I||t[40]!==$||t[41]!==a||t[42]!==S?(F=$&&i.jsx(w_,{approvals:S,isStreaming:a,onRespond:I},X),t[38]=X,t[39]=I,t[40]=$,t[41]=a,t[42]=S,t[43]=F):F=t[43];let Q;t[44]!==O.hasPlans||t[45]!==R||t[46]!==D||t[47]!==a||t[48]!==w||t[49]!==W?(Q=O.hasPlans&&i.jsx(k_,{plans:w,isStreaming:a,onApprove:R,onDismiss:D},W),t[44]=O.hasPlans,t[45]=R,t[46]=D,t[47]=a,t[48]=w,t[49]=W,t[50]=Q):Q=t[50];let J;t[51]!==O.isWaitingForUserInput||t[52]!==A||t[53]!==a||t[54]!==U||t[55]!==L?(J=O.isWaitingForUserInput&&i.jsx(D2,{userAskParts:L,isStreaming:a,onSubmit:A},U),t[51]=O.isWaitingForUserInput,t[52]=A,t[53]=a,t[54]=U,t[55]=L,t[56]=J):J=t[56];let ee;return t[57]!==Y||t[58]!==F||t[59]!==Q||t[60]!==J||t[61]!==H||t[62]!==K?(ee=i.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[H,Z,K,Y,F,Q,J]}),t[57]=Y,t[58]=F,t[59]=Q,t[60]=J,t[61]=H,t[62]=K,t[63]=ee):ee=t[63],ee}function iy(t){return t.approvalId}function ry(t){return t.toolCallId}function oy(){document.querySelector("[data-chat-input]")?.focus()}function ay(t){return t.type==="tool-user_ask"}Ql.Error=function(e){return i.jsx(gl,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Ql.Warning=function(e){return i.jsx(gl,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Ql.UserAskQuestion=D2;function ly(t){const e=M.c(12),{taskId:s}=t,n=am(s),r=ox(n),o=ax(),{stop:a,removeLocalMessage:l}=Ys();if(r.length===0)return null;let c;e[0]!==a?(c=()=>{a()},e[0]=a,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Md,{size:14}),e[2]=d):d=e[2];let h;e[3]!==c?(h=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon-sm",onClick:c,children:d})}),e[3]=c,e[4]=h):h=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(De,{side:"top",children:i.jsx("p",{className:"text-xs",children:"Send now"})}),e[5]=u):u=e[5];let f;e[6]!==h?(f=i.jsxs(Oe,{delayDuration:400,children:[h,u]}),e[6]=h,e[7]=f):f=e[7];let m;return e[8]!==o||e[9]!==l||e[10]!==s?(m=(p,g)=>i.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[i.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:g+1}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:p.text}),i.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:i.jsx(re,{type:"button",variant:"ghost",size:"icon-sm",title:"Remove from queue",onClick:()=>{o.cancel(s,p.messageId).then(x=>{x&&(lx(s,p.messageId),l(p.messageId))})},children:i.jsx(Tn,{className:"size-3.5"})})})]},p.messageId),e[8]=o,e[9]=l,e[10]=s,e[11]=m):m=e[11],i.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[i.jsxs("span",{children:[r.length," queued message",r.length>1?"s":""]}),f]}),r.map(m)]})}function cy(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function M2(t){const e=cy(t),s=Date.now().toString(36).split("").reverse().join("");return`${e}-${s}`}const dy={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function fr(t){return t?t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,(e,s)=>{if(s.startsWith("#x")||s.startsWith("#X")){const n=Number.parseInt(s.slice(2),16);return Number.isFinite(n)?String.fromCodePoint(n):e}if(s.startsWith("#")){const n=Number.parseInt(s.slice(1),10);return Number.isFinite(n)?String.fromCodePoint(n):e}return dy[s]??e}):""}const uy=10080*60*1e3;function hy({sandboxMap:t,userId:e,rawBranches:s,now:n}){const r=new Map;for(const[u,f]of Object.entries(t??{}))for(const[m,p]of Object.entries(f??{})){let g=r.get(m);g||(g={userIds:new Set,lastActiveAt:0},r.set(m,g)),g.userIds.add(u);for(const x of Object.values(p??{})){const v=x?.createdAt??0;v>g.lastActiveAt&&(g.lastActiveAt=v)}}const o=n-uy,a=[...r.entries()].filter(([,u])=>u.lastActiveAt>=o).sort((u,f)=>f[1].lastActiveAt-u[1].lastActiveAt).map(([u,f])=>({name:u,source:"recent",contributors:[...f.userIds],lastActiveAt:f.lastActiveAt})),l=new Set(a.map(u=>u.name)),c=new Set(Object.keys(t?.[e]??{})),d=[...c].filter(u=>!l.has(u)).sort().map(u=>({name:u,source:"yours"})),h=s.filter(u=>!c.has(u.name)&&!l.has(u.name)).map(u=>({name:u.name,source:"other",author:u.author??null}));return{recent:a,yours:d,others:h}}const za=100;function fy(t,e,s){const n=e.trim().toLowerCase();return n?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(n))):!0}function my(t,e){const s=e.trim().toLowerCase();return s?[...t].some(n=>n.toLowerCase().includes(s)):!0}function py(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(n=>n.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function gy(t){const e=M.c(47),{orgId:s,orgSlug:n,userId:r,connectionId:o,sandboxMap:a,owner:l,repo:c,enabled:d}=t,h=d===void 0?!0:d,u=o??null;let f;e[0]!==s||e[1]!==n||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:n},e[0]=s,e[1]=n,e[2]=u,e[3]=f):f=e[3];const m=ut(f);let p;e[4]!==o||e[5]!==s||e[6]!==n||e[7]!==l||e[8]!==c?(p=I5.githubBranches(s,n,o,l,c),e[4]=o,e[5]=s,e[6]=n,e[7]=l,e[8]=c,e[9]=p):p=e[9];const g=h&&!!o&&!!l&&!!c;let x;e[10]!==m||e[11]!==l||e[12]!==c?(x=async B=>{const{pageParam:z,signal:$}=B,U=Number(z),W=await m.callTool({name:"list_branches",arguments:{owner:l,repo:c,page:U,perPage:za}},void 0,{signal:$}),X=py(W);return{branches:Array.isArray(X)?X:X.branches??[],default_branch:Array.isArray(X)?null:X.default_branch??null,page:U}},e[10]=m,e[11]=l,e[12]=c,e[13]=x):x=e[13];let v;e[14]!==p||e[15]!==g||e[16]!==x?(v={queryKey:p,enabled:g,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:x,getNextPageParam:Ly},e[14]=p,e[15]=g,e[16]=x,e[17]=v):v=e[17];const{data:_,isLoading:b,isError:y,hasNextPage:L,isFetchingNextPage:w,fetchNextPage:S}=Gm(v);let j,C,V,N;if(e[18]!==_?.pages||e[19]!==a||e[20]!==r){const B=new Map;for(const $ of _?.pages??[])for(const U of $.branches)typeof U.name=="string"&&B.set(U.name,U);const z=[...B.values()].filter(yy).map(_y);({recent:C,yours:N,others:j}=hy({sandboxMap:a,userId:r,rawBranches:z,now:Date.now()})),V=new Set([...C,...N].map(by)),e[18]=_?.pages,e[19]=a,e[20]=r,e[21]=j,e[22]=C,e[23]=V,e[24]=N}else j=e[21],C=e[22],V=e[23],N=e[24];const T=V;let A;e[25]!==_?.pages?(A=_?.pages.find(vy)?.default_branch??null,e[25]=_?.pages,e[26]=A):A=e[26];const E=A;let R;e[27]!==_?.pages||e[28]!==S||e[29]!==w||e[30]!==T?(R=async(B,z)=>{const $=z===void 0?xy:z;if(!$()||my(T,B)||w)return;let U=_?.pages??[];for(;$()&&!fy(U,B,T)&&(U.at(-1)?.branches.length??za)>=za;){const W=await S();if(!$())break;const X=W.data?.pages??U;if(X.length===U.length)break;U=X}},e[27]=_?.pages,e[28]=S,e[29]=w,e[30]=T,e[31]=R):R=e[31];const D=R,P=L??!1;let I;e[32]!==S||e[33]!==L||e[34]!==w?(I=()=>{L&&!w&&S()},e[32]=S,e[33]=L,e[34]=w,e[35]=I):I=e[35];let O;return e[36]!==E||e[37]!==D||e[38]!==y||e[39]!==w||e[40]!==b||e[41]!==j||e[42]!==C||e[43]!==P||e[44]!==I||e[45]!==N?(O={recent:C,yours:N,others:j,defaultBase:E,isLoading:b,isError:y,hasMore:P,isFetchingMore:w,fetchMore:I,fetchUntilMatch:D},e[36]=E,e[37]=D,e[38]=y,e[39]=w,e[40]=b,e[41]=j,e[42]=C,e[43]=P,e[44]=I,e[45]=N,e[46]=O):O=e[46],O}function xy(){return!0}function vy(t){return t.default_branch}function by(t){return t.name}function _y(t){return{name:t.name,author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function yy(t){return typeof t.name=="string"}function Ly(t){if(!(t.branches.length<za))return t.page+1}function Sy(t){try{return JSON.parse(t)}catch{return null}}function wy(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?Sy(s):null,r=e.structuredContent;return r==null?n:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?n??r:r}function Oi(t){const e=wy(t);return e===null?null:e}function b9(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function jy(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=b9(s);return!n||!s?null:{number:n,htmlUrl:s}}const Qu=/[\r\n<>]/,Cy=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function oa(t){const e=t?.userName?.trim();if(!e||Qu.test(e))return null;const s=t?.userEmail?.trim();return!s||Qu.test(s)?{userName:e}:Cy.test(s)?{userName:e,userEmail:s}:{userName:e}}function ky(t){return t.split(`
5
+ `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
6
+ `).trimEnd()}function Vy(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function $2(t,e){const s=oa(e);if(!s)return t;const n=ky(t),r=Vy(s);if(n.includes(r))return n;const o=n.trimEnd();return o.length>0?`${o}
7
+
8
+ ${r}`:r}function B2(t,e){const s=t?.trim();return s?$2(s,e):s||void 0}const Ny=["dev","start"];function Ay(t){if(!t||typeof t!="object")return null;const e=t;return e.isError?e.content?.find(n=>n.type==="text")?.text?.trim()||"GitHub MCP tool returned an error":null}function _9(t){const e=Ay(t);if(e)throw new Error(e)}function z2(t,e){for(const s of e){const n=t[s];if(typeof n=="string"&&n.length>0)return n}}function F2(t,e){for(const s of e){const n=t[s];if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(typeof n=="string"&&/^\d+$/.test(n)){const r=Number(n);if(r>0)return r}}}function Ty(t){const s=t.head?.ref;return typeof s=="string"&&s.length>0?s:null}function Ey(t,e){return Ty(t)===e}function Zl(t){const e=Oi(t);if(Array.isArray(e))return e.filter(s=>s!=null&&typeof s=="object");if(e&&typeof e=="object"){const s=e;for(const n of["pull_requests","items","data"]){const r=s[n];if(Array.isArray(r))return r.filter(o=>o!=null&&typeof o=="object")}}return[]}function Ry(t){const e=z2(t,["html_url","htmlUrl","url","URL"]),s=F2(t,["number","pullNumber"])??b9(e);return!s||!e?null:{number:s,htmlUrl:e}}function Py(t){_9(t);const e=jy(t);if(e)return e;const s=Oi(t);if(s&&typeof s=="object"){const n=z2(s,["url","URL","html_url","htmlUrl"]),r=F2(s,["number","pullNumber"])??b9(n);if(r&&n)return{number:r,htmlUrl:n}}throw new Error("Failed to open pull request")}function Iy(t){return/already exists|pull request already/i.test(t)}async function Dy(t,e){const s=await t.callTool({name:"list_pull_requests",arguments:{owner:e.owner,repo:e.repo,state:"open",...e.head?{head:e.head}:{},perPage:10}});return _9(s),Zl(s)}async function Zu(t,e){const s=[`${e.owner}:${e.branch}`,e.branch];for(const n of s){const o=(await Dy(t,{owner:e.owner,repo:e.repo,head:n})).find(l=>Ey(l,e.branch)),a=o?Ry(o):null;if(a)return a}return null}async function Oy(t,e){const s=B2(e.body,oa(e.coAuthor));if(s)try{await t.callTool({name:"update_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,body:s}})}catch{}}async function My(t,e){const s=B2(e.body,oa(e.coAuthor)),n=await t.callTool({name:"create_pull_request",arguments:{owner:e.owner,repo:e.repo,title:e.title,body:s||void 0,head:e.head,base:e.base}});return Py(n)}async function eh(t,e){const s=await Zu(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(s)return await Oy(t,{owner:e.owner,repo:e.repo,pullNumber:s.number,body:e.body,coAuthor:e.coAuthor}),s;try{return await My(t,{owner:e.owner,repo:e.repo,title:e.title,body:e.body,head:e.branch,base:e.base,coAuthor:e.coAuthor})}catch(n){const r=n instanceof Error?n.message:String(n);if(!Iy(r))throw n;const o=await Zu(t,{owner:e.owner,repo:e.repo,branch:e.branch});if(o)return o;throw n}}async function U2(t,e){const s=oa(e.coAuthor),n=s?$2(e.commitMessage?.trim()??"",s):e.commitMessage?.trim()||void 0,r=await t.callTool({name:"merge_pull_request",arguments:{owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,merge_method:"squash",...e.commitTitle?{commit_title:e.commitTitle}:{},...n?{commit_message:n}:{}}});_9(r);const o=Oi(r);if(!o||o.merged!==!0)throw new Error(o?.message??"Failed to merge pull request");return{merged:!0,message:o.message??"Pull request merged"}}const y9=6e4,ec=3e4;function H2(t){const e=t.base,s=t.head,n=s?.repo,r=t.user;return{number:t.number??0,title:t.title??"",body:t.body??"",state:t.state==="closed"?"closed":"open",merged:t.merged_at!=null,mergedAt:t.merged_at??null,base:e?.ref??"main",head:s?.ref??"",headSha:s?.sha??"",headRepoFullName:n?.full_name??null,htmlUrl:t.html_url??"",author:r?.login??""}}function L9(t){const e=M.c(15);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ut(s);let r;e[4]!==t.branch||e[5]!==t.owner?(r=t.branch?{head:`${t.owner}:${t.branch}`}:{},e[4]=t.branch,e[5]=t.owner,e[6]=r):r=e[6];let o;e[7]!==t.owner||e[8]!==t.repo||e[9]!==r?(o={owner:t.owner,repo:t.repo,state:"all",...r,perPage:1},e[7]=t.owner,e[8]=t.repo,e[9]=r,e[10]=o):o=e[10];const a=!!t.branch&&!!t.connectionId&&!!t.owner&&!!t.repo;let l;return e[11]!==n||e[12]!==o||e[13]!==a?(l={client:n,toolName:"list_pull_requests",toolArguments:o,enabled:a,refetchInterval:y9,refetchIntervalInBackground:!1,staleTime:ec,select:$y},e[11]=n,e[12]=o,e[13]=a,e[14]=l):l=e[14],ta(l)}function $y(t){const e=Zl(t);return e.length===0?null:H2(e[0])}const By=50;function zy(t){const e=M.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ut(s);let r;e[4]!==t.owner||e[5]!==t.repo?(r={owner:t.owner,repo:t.repo,state:"open",perPage:By},e[4]=t.owner,e[5]=t.repo,e[6]=r):r=e[6];const o=(t.enabled??!0)&&!!t.connectionId&&!!t.owner&&!!t.repo;let a;return e[7]!==n||e[8]!==r||e[9]!==o?(a={client:n,toolName:"list_pull_requests",toolArguments:r,enabled:o,staleTime:ec,select:Fy},e[7]=n,e[8]=r,e[9]=o,e[10]=a):a=e[10],ta(a)}function Fy(t){return Zl(t).map(H2)}function K2(t){const e=M.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ut(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_check_runs",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:y9,refetchIntervalInBackground:!1,staleTime:ec,select:Uy},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],ta(l)}function Uy(t){const e=Oi(t);return(Array.isArray(e)?e:e?.check_runs??[]).map(Hy)}function Hy(t){const e=t.started_at,s=t.completed_at,n=e&&s?new Date(s).getTime()-new Date(e).getTime():null;return{id:String(t.id??""),name:String(t.name??""),status:t.status??"completed",conclusion:t.conclusion??null,htmlUrl:String(t.html_url??""),durationMs:n}}function Ky(t){const e=M.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ut(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get_comments",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:y9,refetchIntervalInBackground:!1,staleTime:ec,select:Wy},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],ta(l)}function Wy(t){const e=Oi(t);return Array.isArray(e)?e.map(qy):[]}function qy(t){const e=t.user;return{id:Number(t.id??0),author:e?.login??"",body:String(t.body??""),createdAt:String(t.created_at??""),htmlUrl:String(t.html_url??"")}}function Gy(t){const e=M.c(129),{orgId:s,orgSlug:n,userId:r,userLabel:o,connectionId:a,owner:l,repo:c,sandboxMap:d,value:h,onChange:u,disabled:f,placement:m}=t,p=f===void 0?!1:f,x=(m===void 0?"chat":m)==="header",[v,_]=k.useState(!1),[b,y]=k.useState("branches"),[L,w]=k.useState(""),[S,j]=k.useState(!1),C=k.useRef(0);let V;e[0]!==a||e[1]!==v||e[2]!==s||e[3]!==n||e[4]!==l||e[5]!==c||e[6]!==d||e[7]!==r?(V={orgId:s,orgSlug:n,userId:r,connectionId:a,sandboxMap:d,owner:l,repo:c,enabled:v},e[0]=a,e[1]=v,e[2]=s,e[3]=n,e[4]=l,e[5]=c,e[6]=d,e[7]=r,e[8]=V):V=e[8];const{recent:N,yours:T,others:A,isLoading:E,isError:R,hasMore:D,isFetchingMore:P,fetchMore:I,fetchUntilMatch:O}=gy(V);let B;e[9]!==v?(B={enabled:v},e[9]=v,e[10]=B):B=e[10];const{data:z}=_b(B);let $;e[11]!==z?.data?.members?($=new Map((z?.data?.members??[]).map(Yy)),e[11]=z?.data?.members,e[12]=$):$=e[12];const U=$,W=a??"",X=v&&b==="prs";let H;e[13]!==s||e[14]!==n||e[15]!==l||e[16]!==c||e[17]!==W||e[18]!==X?(H={orgId:s,orgSlug:n,connectionId:W,owner:l,repo:c,enabled:X},e[13]=s,e[14]=n,e[15]=l,e[16]=c,e[17]=W,e[18]=X,e[19]=H):H=e[19];const{data:Z,isLoading:K,isError:Y}=zy(H);let F,Q,J,ee,q,se,ne,le,G,oe,me,ue,ye;if(e[20]!==p||e[21]!==I||e[22]!==O||e[23]!==D||e[24]!==R||e[25]!==P||e[26]!==x||e[27]!==E||e[28]!==S||e[29]!==U||e[30]!==u||e[31]!==v||e[32]!==A||e[33]!==l||e[34]!==Y||e[35]!==K||e[36]!==N||e[37]!==c||e[38]!==L||e[39]!==Z||e[40]!==b||e[41]!==o||e[42]!==h||e[43]!==T){const Se=Z===void 0?[]:Z,be=`${l}/${c}`;let Re;e[57]!==be?(Re=be.toLowerCase(),e[57]=be,e[58]=Re):Re=e[58];const Ve=Re;let he;e[59]!==Ve?(he=Be=>Be.headRepoFullName?.toLowerCase()===Ve,e[59]=Ve,e[60]=he):he=e[60];const Pe=Se.filter(he),Me=Se.length-Pe.length;let xe;e[61]!==u?(xe=Be=>{u(Be),_(!1)},e[61]=u,e[62]=xe):xe=e[62];const Ae=xe,pe=h??"Select branch…";let ke;e[63]!==O||e[64]!==b?(ke=Be=>{w(Be),C.current=C.current+1;const Pt=C.current,Bs=Be.trim();if(!Bs||b!=="branches"){j(!1);return}j(!0),O(Bs,()=>Pt===C.current).finally(()=>{Pt===C.current&&j(!1)})},e[63]=O,e[64]=b,e[65]=ke):ke=e[65];const $e=ke;let ge;e[66]!==I||e[67]!==b?(ge=Be=>{const Pt=Be.currentTarget,Bs=Pt.scrollHeight-Pt.scrollTop-Pt.clientHeight;b==="branches"&&Bs<48&&I()},e[66]=I,e[67]=b,e[68]=ge):ge=e[68];const Ke=ge;ee=Ns,me=v,ue=p?void 0:_;const gt=x?"outline":"ghost",nt=x?"sm":"default";let lt;e[69]!==p||e[70]!==x?(lt=te("font-mono shrink min-w-0 max-w-[200px]",x?"gap-1.5 text-xs":te("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",p?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[69]=p,e[70]=x,e[71]=lt):lt=e[71];let qe;e[72]===Symbol.for("react.memo_cache_sentinel")?(qe=i.jsx(Qs,{className:"h-3.5 w-3.5 shrink-0"}),e[72]=qe):qe=e[72];const Rt=x?"":"transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100";let ct;e[73]!==Rt?(ct=te("min-w-0 truncate",Rt),e[73]=Rt,e[74]=ct):ct=e[74];let Ye;e[75]!==pe||e[76]!==ct?(Ye=i.jsx("span",{className:ct,children:pe}),e[75]=pe,e[76]=ct,e[77]=Ye):Ye=e[77];let ot;e[78]!==p||e[79]!==x?(ot=!p&&i.jsx(ts,{size:12,className:te("opacity-60 shrink-0",x?"":"hidden @[320px]/chat-bottom:inline-block")}),e[78]=p,e[79]=x,e[80]=ot):ot=e[80];let ht;e[81]!==p||e[82]!==pe||e[83]!==gt||e[84]!==nt||e[85]!==lt||e[86]!==Ye||e[87]!==ot?(ht=i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"inline-flex min-w-0 shrink",children:i.jsx(As,{asChild:!0,children:i.jsxs(re,{variant:gt,size:nt,"aria-label":pe,disabled:p,className:lt,children:[qe,Ye,ot]})})})}),e[81]=p,e[82]=pe,e[83]=gt,e[84]=nt,e[85]=lt,e[86]=Ye,e[87]=ot,e[88]=ht):ht=e[88];let ae;e[89]!==pe?(ae=i.jsx(De,{children:pe}),e[89]=pe,e[90]=ae):ae=e[90],e[91]!==ht||e[92]!==ae?(ye=i.jsxs(Oe,{children:[ht,ae]}),e[91]=ht,e[92]=ae,e[93]=ye):ye=e[93],J=Ts,G="w-[min(420px,calc(100vw-2rem))] p-0",oe="start",Q=Cr;const Fe=b==="branches"?"Search loaded branches…":"Search pull requests…";let Ze;e[94]!==$e||e[95]!==L||e[96]!==Fe?(Ze=i.jsx(Ii,{placeholder:Fe,value:L,onValueChange:$e}),e[94]=$e,e[95]=L,e[96]=Fe,e[97]=Ze):Ze=e[97];let mt;e[98]!==Ae||e[99]!==b||e[100]!==o?(mt=b==="branches"&&i.jsx(re,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>Ae(M2(o)),children:"New"}),e[98]=Ae,e[99]=b,e[100]=o,e[101]=mt):mt=e[101],e[102]!==Ze||e[103]!==mt?(ne=i.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[Ze,mt]}),e[102]=Ze,e[103]=mt,e[104]=ne):ne=e[104];let Nt;e[105]===Symbol.for("react.memo_cache_sentinel")?(Nt=Be=>{y(Be),w("")},e[105]=Nt):Nt=e[105];let ms;e[106]===Symbol.for("react.memo_cache_sentinel")?(ms=i.jsxs(Zo,{className:"h-auto w-fit justify-start gap-1 bg-accent p-1",variant:"pill",children:[i.jsx(gn,{value:"branches",className:"h-6 px-2.5 text-xs",children:"Branches"}),i.jsx(gn,{value:"prs",className:"h-6 px-2.5 text-xs",children:"PRs"})]}),e[106]=ms):ms=e[106],e[107]!==b?(le=i.jsx(wr,{className:"px-2 pt-2 pb-1",value:b,onValueChange:Nt,children:ms}),e[107]=b,e[108]=le):le=e[108],F=Di,q=Ke,se=b==="prs"?i.jsxs(i.Fragment,{children:[Y&&i.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load pull requests from GitHub."}),K&&i.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Loading pull requests…"}),!Y&&!K&&i.jsx(Jn,{children:L.trim()?"No pull requests match your search.":"No open pull requests."}),Pe.length>0&&i.jsx(Is,{heading:"Open pull requests",children:Pe.map(Be=>i.jsxs(Cs,{value:`#${Be.number} ${Be.title} ${Be.head}`,className:"cursor-pointer",onSelect:()=>Ae(Be.head),children:[i.jsx(jv,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground"}),i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"truncate",children:fr(Be.title)}),i.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["#",Be.number," · ",Be.head,Be.author?` · @${Be.author}`:""]})]})]},Be.number))}),Me>0&&i.jsxs("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:[Me," PR",Me>1?"s":""," from forks hidden — open on a branch in this repo"]})]}):i.jsxs(i.Fragment,{children:[R&&i.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),!R&&!E&&i.jsx(Jn,{children:D?"Looking through more branches...":"No branches found."}),N.length>0&&i.jsx(Is,{heading:"Last 7 days",children:N.map(Be=>i.jsxs(Cs,{value:Be.name,className:"cursor-pointer",onSelect:()=>Ae(Be.name),children:[i.jsx(Qs,{className:"mr-2 h-4 w-4 shrink-0"}),i.jsx("span",{className:"flex-1 truncate",children:Be.name}),i.jsx(Jy,{userIds:Be.contributors??[],memberById:U})]},Be.name))}),T.length>0&&i.jsxs(i.Fragment,{children:[N.length>0&&i.jsx(Hu,{}),i.jsx(Is,{heading:"Your branches",children:T.map(Be=>i.jsxs(Cs,{value:Be.name,className:"cursor-pointer",onSelect:()=>Ae(Be.name),children:[i.jsx(Qs,{className:"mr-2 h-4 w-4 shrink-0"}),i.jsx("span",{className:"flex-1 truncate",children:Be.name})]},Be.name))})]}),A.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Hu,{}),i.jsx(Is,{heading:"Other branches in repo",children:A.map(Be=>i.jsxs(Cs,{value:Be.name,className:"cursor-pointer",onSelect:()=>Ae(Be.name),children:[i.jsx(Qs,{className:"mr-2 h-4 w-4"}),i.jsx("span",{className:"flex-1 truncate",children:Be.name}),Be.author&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",Be.author]})]},Be.name))})]}),D&&i.jsx("div",{className:"border-t p-2",children:i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:P,onClick:I,children:P||S?"Loading more…":"Load more branches"})}),!D&&A.length>0&&i.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"})]}),e[20]=p,e[21]=I,e[22]=O,e[23]=D,e[24]=R,e[25]=P,e[26]=x,e[27]=E,e[28]=S,e[29]=U,e[30]=u,e[31]=v,e[32]=A,e[33]=l,e[34]=Y,e[35]=K,e[36]=N,e[37]=c,e[38]=L,e[39]=Z,e[40]=b,e[41]=o,e[42]=h,e[43]=T,e[44]=F,e[45]=Q,e[46]=J,e[47]=ee,e[48]=q,e[49]=se,e[50]=ne,e[51]=le,e[52]=G,e[53]=oe,e[54]=me,e[55]=ue,e[56]=ye}else F=e[44],Q=e[45],J=e[46],ee=e[47],q=e[48],se=e[49],ne=e[50],le=e[51],G=e[52],oe=e[53],me=e[54],ue=e[55],ye=e[56];let Le;e[109]!==F||e[110]!==q||e[111]!==se?(Le=i.jsx(F,{onScroll:q,children:se}),e[109]=F,e[110]=q,e[111]=se,e[112]=Le):Le=e[112];let Ce;e[113]!==Q||e[114]!==ne||e[115]!==le||e[116]!==Le?(Ce=i.jsxs(Q,{children:[ne,le,Le]}),e[113]=Q,e[114]=ne,e[115]=le,e[116]=Le,e[117]=Ce):Ce=e[117];let ze;e[118]!==J||e[119]!==G||e[120]!==oe||e[121]!==Ce?(ze=i.jsx(J,{className:G,align:oe,children:Ce}),e[118]=J,e[119]=G,e[120]=oe,e[121]=Ce,e[122]=ze):ze=e[122];let Te;return e[123]!==ee||e[124]!==me||e[125]!==ue||e[126]!==ye||e[127]!==ze?(Te=i.jsxs(ee,{open:me,onOpenChange:ue,children:[ye,ze]}),e[123]=ee,e[124]=me,e[125]=ue,e[126]=ye,e[127]=ze,e[128]=Te):Te=e[128],Te}function Yy(t){return[t.userId,t.user]}function Jy(t){const e=M.c(13),{userIds:s,memberById:n}=t;if(s.length===0)return null;let r,o,a;if(e[0]!==n||e[1]!==s){const d=s.slice(0,3);r=s.length-d.length,o="ml-2 flex shrink-0 items-center -space-x-1.5";let h;e[5]!==n?(h=u=>{const f=n.get(u);return i.jsx(Ji,{url:f?.image??void 0,fallback:yb(f?.name??void 0),shape:"circle",size:"xs",className:"ring-2 ring-background"},u)},e[5]=n,e[6]=h):h=e[6],a=d.map(h),e[0]=n,e[1]=s,e[2]=r,e[3]=o,e[4]=a}else r=e[2],o=e[3],a=e[4];let l;e[7]!==r?(l=r>0&&i.jsxs("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-[9px] font-semibold text-muted-foreground ring-2 ring-background",children:["+",r]}),e[7]=r,e[8]=l):l=e[8];let c;return e[9]!==o||e[10]!==a||e[11]!==l?(c=i.jsxs("span",{className:o,children:[a,l]}),e[9]=o,e[10]=a,e[11]=l,e[12]=c):c=e[12],c}function Xy(t){const e=M.c(25);let s,n,r,o;e[0]!==t?({locked:s,placement:n,value:o,...r}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=r,e[4]=o):(s=e[1],n=e[2],r=e[3],o=e[4]);const a=n==="header";if(s){const c=o??"(no branch)",d=a?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let h;e[5]!==d?(h=te("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",d),e[5]=d,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Qs,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=u):u=e[7];const f=a?"":"max-w-0 opacity-0";let m;e[8]!==f?(m=te("min-w-0 truncate",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=i.jsx("span",{className:m,children:c}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==h||e[14]!==p?(g=i.jsx(Ie,{asChild:!0,children:i.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:h,children:[u,p]})}),e[13]=h,e[14]=p,e[15]=g):g=e[15];let x;e[16]!==c?(x=i.jsxs(De,{children:["This chat is using branch ",c,". Start a new chat to use a different branch."]}),e[16]=c,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=i.jsxs(Oe,{children:[g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let l;return e[21]!==n||e[22]!==r||e[23]!==o?(l=i.jsx(Gy,{...r,value:o,placement:n}),e[21]=n,e[22]=r,e[23]=o,e[24]=l):l=e[24],l}function tc(){const t=M.c(11),e=om(),s=X1();let n;t[0]!==e.capabilities||t[1]!==e.online?(n=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=n):n=t[2];let r;t[3]!==e.capabilities||t[4]!==e.online?(r=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=r):r=t[5];let o;return t[6]!==e.online||t[7]!==s.runtime.agentSandbox||t[8]!==n||t[9]!==r?(o={agentSandbox:s.runtime.agentSandbox,userDesktop:e.online,claudeCode:n,codex:r},t[6]=e.online,t[7]=s.runtime.agentSandbox,t[8]=n,t[9]=r,t[10]=o):o=t[10],o}function W2(t){const e=Object.values(t),[s]=e;return s?e.find(n=>n.sandboxProviderKind!=="user-desktop")??s:null}async function Qy(t,e,s){const n=await t.callTool({name:e,arguments:s});if(n.isError){const r=n.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return n}const q2=["SANDBOX_START"],ga=new Map,Zy=t=>`${t.virtualMcpId}::${t.branch??""}`,Dc=new Set,xl={mark:(t,e)=>Dc.add(`${t}::${e}`),clear:(t,e)=>Dc.delete(`${t}::${e}`),isStopped:(t,e)=>Dc.has(`${t}::${e}`)};function S9(t){const e=bs();return Gs({mutationKey:q2,mutationFn:async s=>{s.branch&&xl.clear(s.virtualMcpId,s.branch);const n=Zy(s),r=ga.get(n);if(r)return r;const o=(async()=>(await Qy(t,"SANDBOX_START",s)).structuredContent)();ga.set(n,o);try{return await o}finally{ga.get(n)===o&&ga.delete(n)}},onSuccess:()=>{Q1(e)}})}function e8(t,e){const s=M.c(3);let n;return s[0]!==e||s[1]!==t?(n={mutationKey:q2,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=n):n=s[2],z6(n)>0}const t8={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{},subscribeReloadStart:()=>()=>{}},G2=k.createContext(t8),th=16384;class s8{data="";append(e){this.data+=e,this.data.length>th&&(this.data=this.data.slice(this.data.length-th))}get(){return this.data}clear(){this.data=""}}const n8=1e3,i8=3e4,r8=3e3,sh=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],nh="log";function o8(t,e,s,n){return t[0]==="live-meta"&&t[1]===e&&t[2]===s&&t[3]===n}function a8(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function l8(t){return t===404}async function c8(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(r8)});return await e.body?.cancel().catch(()=>{}),l8(e.status)}catch{return!1}}function d8({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:n=!0,children:r}){const{org:o}=Ee(),a=bs(),[l,c]=k.useState(null),[d,h]=k.useState({phase:"idle"}),[u,f]=k.useState({state:"running"}),[m,p]=k.useState({kind:"unknown"}),[g,x]=k.useState(!1),[v,_]=k.useState([]),[b,y]=k.useState([]),[,L]=k.useState(0),w=k.useRef(new Map),S=k.useRef(new Set),j=k.useRef(new Set),C=k.useRef(new Set),V=k.useRef(null),N=a8(s),T=E=>{let R=w.current.get(E);return R||(R=new s8,w.current.set(E,R)),R};k.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),V.current=null,x(!1),_([]),y([]),w.current.clear(),!t||!e||!n)return;const E=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let R=!1,D=0,P=null,I=null,O=null,B=null,z=null,$=null;const U=Q=>{try{const J=JSON.parse(Q.data);c(J),J.kind!=="failed"&&(x(!1),D=0),J.kind==="ready"&&K()}catch(J){console.warn("[vm-events] bad phase payload",J)}},W=()=>{x(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),_([]),y([]),w.current.clear()},X=Q=>{try{const J=JSON.parse(Q.data);if(typeof J.data!="string")return;D=0;const ee=J.data.replace(/\r?\n/g,`\r
9
+ `);T(J.source).append(ee);for(const q of S.current)try{q(J.source,ee)}catch{}L(q=>q+1)}catch{}},H=Q=>{const J=Q.type;try{const ee=JSON.parse(Q.data);switch(D=0,J){case"lifecycle":{const q=ee;if(h(q.state),q.state.phase==="running"&&$!=="running"){const le=`${o.slug}/${t}/${e}`;a.invalidateQueries({queryKey:it.decofile(le)}),a.invalidateQueries({predicate:G=>G.queryKey[0]==="live-meta"&&typeof G.queryKey[1]=="string"&&G.queryKey[1].startsWith(`${le}/`)})}$=q.state.phase;const se=q.state.phase==="running"?q.state.port:null,ne=V.current;if(V.current=se,ne!==null&&se!==null&&ne!==se)for(const le of j.current)try{le()}catch{}return}case"status":f(ee);return;case"tasks":{const se=ee.active.map(ne=>ne.logName??"").filter(Boolean);y(se);return}case"scripts":_(ee.scripts);return;case"branch":{const q=ee.meta;p(q);return}case"reload":for(const q of j.current)try{q()}catch{}return;case"file-changed":{const{path:q}=ee,se=`${o.slug}/${t}/${e}`;if(q.startsWith(".deco/")||q.includes("/.deco/")){if($!=="running")return;for(const le of C.current)try{le()}catch{}O&&clearTimeout(O),O=setTimeout(()=>{O=null,a.invalidateQueries({queryKey:it.decofile(se)});for(const le of j.current)try{le()}catch{}},500)}else I&&clearTimeout(I),I=setTimeout(()=>{I=null,a.invalidateQueries({predicate:le=>o8(le.queryKey,o.slug,t,e)})},1e3);return}}}catch{}};function Z(){if(R)return;const Q=new EventSource(E);B=Q,Q.onopen=()=>{},Q.onerror=()=>{B===Q&&Q.readyState===EventSource.CLOSED&&F("studio")},Q.addEventListener("phase",U),Q.addEventListener("gone",W),Q.addEventListener(nh,X);for(const J of sh)Q.addEventListener(J,H)}function K(){if(R||!N||z)return;const Q=new EventSource(N);z=Q;let J=!1;Q.onopen=()=>{if(R||z!==Q)return;J=!0,D=0;const ee=B;B=null,ee?.close()},Q.onerror=()=>{z===Q&&Q.readyState===EventSource.CLOSED&&Y(Q,J)},Q.addEventListener(nh,X);for(const ee of sh)Q.addEventListener(ee,H)}async function Y(Q,J){const ee=N?await c8(N):!1;if(!(R||z!==Q)){if(Q.close(),z=null,ee){W(),B||Z();return}J&&F("direct")}}function F(Q){if(R||P)return;const J=Math.min(n8*2**D,i8);D++,P=setTimeout(()=>{if(P=null,!R){if(Q==="direct"){z?.close(),z=null,K();return}B?.close(),B=null,Z()}},J)}return Z(),()=>{R=!0,B?.close(),z?.close(),P&&clearTimeout(P),I&&clearTimeout(I),O&&clearTimeout(O)}},[t,e,o.slug,n,N,a]);const A={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:b,getBuffer:E=>w.current.get(E)?.get()??"",hasData:E=>(w.current.get(E)?.get().length??0)>0,subscribeChunks:E=>(S.current.add(E),()=>{S.current.delete(E)}),subscribeReload:E=>(j.current.add(E),()=>{j.current.delete(E)}),subscribeReloadStart:E=>(C.current.add(E),()=>{C.current.delete(E)})};return i.jsx(G2,{value:A,children:r})}function $s(){return k.use(G2)}function Y2(t){const{subscribeChunks:e}=$s(),s=k.useRef(t);s.current=t,k.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function u8(t){const{subscribeReload:e}=$s(),s=k.useRef(t);s.current=t,k.useEffect(()=>e(()=>{s.current?.()}),[e])}function h8(t){const{subscribeReloadStart:e}=$s(),s=k.useRef(t);s.current=t,k.useEffect(()=>e(()=>{s.current?.()}),[e])}function J2(t){return t.appPaused||t.userStopped?{kind:"suspended"}:t.startError&&!t.previewUrl?{kind:"errored",error:t.startError}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}const X2={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},ih="::";function Q2(t){const e=t.indexOf(ih);if(e>0){const s=t.slice(0,e);if(Object.values(X2).includes(s))return{code:s,message:t.slice(e+ih.length)}}return{code:null,message:t}}function f8(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted}function m8(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&t.deadVmId!==t.lastDeadVmId}function Oc(t,e,s){const n={virtualMcpId:t};return e&&(n.branch=e),s&&(n.sandboxProviderKind=s),n}function p8(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored"}}const g8={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{}},Z2=k.createContext(g8);function Vr(){return k.use(Z2)}function x8({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:n,sandboxMap:r,sandboxProviderKind:o,children:a}){const{org:l}=Ee(),{setCurrentTaskBranch:c}=Qt(),d=$s(),h=bs(),u=ut({connectionId:Go,orgId:l.id,orgSlug:l.slug}),f=S9(u),{mutate:m,reset:p}=f,g=k.useRef(new Set),x=k.useRef(null),v=s&&e?Bl(r?.[s]?.[e]):{},_=o?v[o]??null:W2(v),b=_?.previewUrl??null,y=!!t&&!!e&&xl.isStopped(t,e),L=d.status.state==="paused",w=f.isError&&f.error?Q2(f.error.message):null,S=J2({previewUrl:b,appPaused:L,userStopped:y,startError:w}),j=p8(S),C=e??"",V=g.current.has(C),N=f8({hasActiveGithubRepo:n,userId:s,vmEntry:_,userStopped:y,isPending:f.isPending,attempted:V});k.useEffect(()=>{if(!N||!t)return;g.current.add(C);const B=Oc(t,e,o);m(B,{onSuccess:z=>{z?.branch&&!e&&c(z.branch)},onError:z=>{console.error("[sandbox-lifecycle] auto-start failed:",z)}})},[N,C,e,t,o,m,c]);const T=d.notFound?_?.sandboxHandle??null:null,A=m8({notFound:d.notFound,deadVmId:T,lastDeadVmId:x.current,isPending:f.isPending,userStopped:y});k.useEffect(()=>{if(!A||!T||!t)return;x.current=T;const B=Oc(t,e,o);m(B,{onSuccess:z=>{z?.branch&&!e&&c(z.branch)},onError:z=>{console.error("[sandbox-lifecycle] self-heal failed:",z)}})},[A,T,t,e,o,m,c]);const E=()=>{if(!t)return;const B=Oc(t,e,o);m(B,{onSuccess:z=>{z?.branch&&!e&&c(z.branch)},onError:z=>{console.error("[sandbox-lifecycle] user start failed:",z)}})},R=async()=>{if(!t||!e)return;const B=_?.sandboxProviderKind;if(B){xl.mark(t,e);try{await u.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:B}})}catch{}Q1(h)}},D=async()=>{await R(),E()},P=()=>{g.current=new Set,x.current=null,p(),E()},O={branch:e,previewState:S,status:j,vmEntry:_,previewUrl:b,userStopped:y,start:E,stop:R,restart:D,retry:P,resume:P};return i.jsx(Z2,{value:O,children:a})}function v8(t){return t==="user-desktop"?{key:"local",label:"This device",Icon:jr}:{key:"cloud",label:"Cloud sandbox",Icon:Kd}}function rh(t){const e=M.c(20),{icon:s,label:n,description:r,active:o,available:a,disabledHint:l,onSelect:c}=t,d=!a,h=a?"cursor-pointer hover:bg-accent":"cursor-not-allowed opacity-50";let u;e[0]!==h?(u=te("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==s?(f=i.jsx("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:s}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==o?(m=o&&i.jsx(Ot,{size:13,className:"text-muted-foreground"}),e[4]=o,e[5]=m):m=e[5];let p;e[6]!==n||e[7]!==m?(p=i.jsxs("span",{className:"flex items-center gap-1.5 text-[13px] font-medium text-foreground",children:[n,m]}),e[6]=n,e[7]=m,e[8]=p):p=e[8];const g=a?r:l;let x;e[9]!==g?(x=i.jsx("span",{className:"block text-xs text-muted-foreground",children:g}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==p||e[12]!==x?(v=i.jsxs("span",{className:"min-w-0 flex-1",children:[p,x]}),e[11]=p,e[12]=x,e[13]=v):v=e[13];let _;return e[14]!==c||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==v?(_=i.jsxs("button",{type:"button",disabled:d,onClick:c,className:u,children:[f,v]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f,e[18]=v,e[19]=_):_=e[19],_}function b8(t){const e=M.c(50);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{showLabel:n}=s,r=n===void 0?!1:n,{pendingSandboxProviderKind:o,setPendingAgentOption:a}=Vs(),{isThreadLocked:l}=Qt(),{vmEntry:c}=Vr(),d=tc();if(l)return null;let h;e[2]!==d?(h=lm(d),e[2]=d,e[3]=h):h=e[3];const u=h,f=c?.sandboxProviderKind??o??(d.agentSandbox?"agent-sandbox":u?"user-desktop":null);let m,p,g,x,v,_,b,y;if(e[4]!==f||e[5]!==r){x=v8(f);const O=x.Icon;g=as,p=Oe;const B=r?"h-9 gap-1.5 px-2 text-xs font-medium":"size-9";let z;e[14]!==B?(z=te("text-muted-foreground hover:text-foreground",B),e[14]=B,e[15]=z):z=e[15];const $=i.jsxs(re,{variant:"ghost",size:r?"sm":"icon","aria-label":`Runtime: ${x.label}`,className:z,children:[i.jsx(O,{size:16}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"truncate",children:x.label}),i.jsx(ts,{size:12,className:"shrink-0 opacity-70"})]})]});e[16]!==$?(y=i.jsx(Ie,{asChild:!0,children:i.jsx(ls,{asChild:!0,children:$})}),e[16]=$,e[17]=y):y=e[17],m=De,v="bottom",_="Running on ",b=x.label.toLowerCase(),e[4]=f,e[5]=r,e[6]=m,e[7]=p,e[8]=g,e[9]=x,e[10]=v,e[11]=_,e[12]=b,e[13]=y}else m=e[6],p=e[7],g=e[8],x=e[9],v=e[10],_=e[11],b=e[12],y=e[13];let L;e[18]!==m||e[19]!==v||e[20]!==_||e[21]!==b?(L=i.jsxs(m,{side:v,children:[_,b]}),e[18]=m,e[19]=v,e[20]=_,e[21]=b,e[22]=L):L=e[22];let w;e[23]!==p||e[24]!==y||e[25]!==L?(w=i.jsxs(p,{children:[y,L]}),e[23]=p,e[24]=y,e[25]=L,e[26]=w):w=e[26];let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(ro,{className:"text-xs font-normal text-muted-foreground",children:"Run on"}),e[27]=S):S=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Kd,{size:14}),e[28]=j):j=e[28];const C=x.key==="cloud";let V;e[29]!==a?(V=()=>a("decopilot"),e[29]=a,e[30]=V):V=e[30];let N;e[31]!==d.agentSandbox||e[32]!==C||e[33]!==V?(N=i.jsx(rh,{icon:j,label:"Cloud sandbox",description:"Runs in deco's cloud",active:C,available:d.agentSandbox,disabledHint:"Not available on this deployment",onSelect:V}),e[31]=d.agentSandbox,e[32]=C,e[33]=V,e[34]=N):N=e[34];let T;e[35]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(jr,{size:14}),e[35]=T):T=e[35];const A=x.key==="local",E=u!==null;let R;e[36]!==u||e[37]!==a?(R=()=>u&&a(u),e[36]=u,e[37]=a,e[38]=R):R=e[38];let D;e[39]!==A||e[40]!==E||e[41]!==R?(D=i.jsx(rh,{icon:T,label:"This device",description:"Runs on your machine via deco link",active:A,available:E,disabledHint:"Run `decocms link` on your desktop",onSelect:R}),e[39]=A,e[40]=E,e[41]=R,e[42]=D):D=e[42];let P;e[43]!==N||e[44]!==D?(P=i.jsxs(cs,{align:"start",className:"w-64 p-1",children:[S,N,D]}),e[43]=N,e[44]=D,e[45]=P):P=e[45];let I;return e[46]!==g||e[47]!==P||e[48]!==w?(I=i.jsxs(g,{children:[w,P]}),e[46]=g,e[47]=P,e[48]=w,e[49]=I):I=e[49],I}function _8(t){const e=M.c(2),{branchPill:s}=t;if(!s)return null;let n;return e[0]!==s?(n=i.jsx(i.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function ep(t){const e=M.c(27),{virtualMcp:s,currentBranch:n,showRuntimeLabel:r}=t,o=r===void 0?!1:r,a=$d(),l=Ti();let c;e[0]!==a?.messages||e[1]!==l?.isThreadLocked?(c=(a?.messages??[]).length>0||(l?.isThreadLocked??!1),e[0]=a?.messages,e[1]=l?.isThreadLocked,e[2]=c):c=e[2];const d=c,h=l?.setCurrentTaskBranch;let u;e[3]!==s?(u=ea(s),e[3]=s,e[4]=u):u=e[4];const f=u,m=f?.connectionId,p=!!f,{data:g}=Ai.useSession(),x=g?.user?.id??"";let v;e[5]!==g?.user?.email||e[6]!==g?.user?.name?(v=g?.user?.name??g?.user?.email?.split("@")[0],e[5]=g?.user?.email,e[6]=g?.user?.name,e[7]=v):v=e[7];const _=v,{org:b}=Ee();let y;e[8]!==m||e[9]!==n||e[10]!==f||e[11]!==d||e[12]!==b||e[13]!==h||e[14]!==x||e[15]!==_||e[16]!==s?.id||e[17]!==s?.metadata?.sandboxMap?(y=f&&m?i.jsx(Xy,{orgId:b.id,orgSlug:b.slug,userId:x,userLabel:_,virtualMcpId:s?.id??"",connectionId:m,owner:f.owner,repo:f.name,sandboxMap:s?.metadata?.sandboxMap,value:n,onChange:C=>{h&&h(C)},locked:d,placement:"chat"}):null,e[8]=m,e[9]=n,e[10]=f,e[11]=d,e[12]=b,e[13]=h,e[14]=x,e[15]=_,e[16]=s?.id,e[17]=s?.metadata?.sandboxMap,e[18]=y):y=e[18];const L=y;let w;e[19]!==p||e[20]!==o?(w=p&&i.jsx(b8,{showLabel:o}),e[19]=p,e[20]=o,e[21]=w):w=e[21];let S;e[22]!==L?(S=i.jsx(_8,{branchPill:L}),e[22]=L,e[23]=S):S=e[23];let j;return e[24]!==w||e[25]!==S?(j=i.jsxs(i.Fragment,{children:[w,S]}),e[24]=w,e[25]=S,e[26]=j):j=e[26],j}const y8={fast:{modelId:"claude-code:haiku",label:"Haiku 4.5"},smart:{modelId:"claude-code:sonnet",label:"Sonnet 5"},thinking:{modelId:"claude-code:opus-1m",label:"Opus 4.8 1M"}},L8={fast:{modelId:"codex:gpt-5.6-luna",label:"GPT-5.6 Luna"},smart:{modelId:"codex:gpt-5.6-terra",label:"GPT-5.6 Terra"},thinking:{modelId:"codex:gpt-5.6-sol",label:"GPT-5.6 Sol"}};function S8(t){return t==="claude-code"?y8:t==="codex"?L8:null}function oh(t,e){return S8(t)?.[e]??null}const w8={decopilot:"cloud-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function j8(t){return t===null?"cloud-decopilot":w8[t]}function C8(){const t=M.c(2),{pendingAgentOption:e}=Vs();let s;return t[0]!==e?(s=j8(e),t[0]=e,t[1]=s):s=t[1],s}function k8(){return Vs().simpleModeTier}function V8(){return Vs().setSimpleModeTier}const N8={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function tp(t,e){return t==="local-claude-code"?oh("claude-code",e)?.label??null:t==="local-codex"?oh("codex",e)?.label??null:N8[e]}const sp=["fast","smart","thinking"],Qi={fast:"Fast",smart:"Smart",thinking:"Thinking"};function A8(t){const e=M.c(29),{tier:s,pillIcon:n,pillLabel:r,groups:o,header:a}=t,l=r===void 0?Qi[s]:r,[c,d]=k.useState(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=C=>{C.onSelect(),d(!1)},e[0]=h):h=e[0];const u=h;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=te("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[1]=f):f=e[1];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=te("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),e[2]=m):m=e[2];const p=Qi[s];let g;e[3]!==p?(g=i.jsx("span",{className:m,children:p}),e[3]=p,e[4]=g):g=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(ts,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[5]=x):x=e[5];let v;e[6]!==n||e[7]!==l||e[8]!==g?(v=i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"inline-flex min-w-0 shrink",children:i.jsx(As,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"ghost",size:"default","aria-label":l,className:f,children:[n,g,x]})})})}),e[6]=n,e[7]=l,e[8]=g,e[9]=v):v=e[9];let _;e[10]!==l?(_=i.jsx(De,{children:l}),e[10]=l,e[11]=_):_=e[11];let b;e[12]!==v||e[13]!==_?(b=i.jsxs(Oe,{children:[v,_]}),e[12]=v,e[13]=_,e[14]=b):b=e[14];let y;e[15]!==a?(y=a&&i.jsx("div",{className:"mb-1 border-b border-border/60 pb-1",children:a}),e[15]=a,e[16]=y):y=e[16];let L;if(e[17]!==o){let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=V=>i.jsxs("div",{className:"flex flex-col",children:[V.label&&i.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1.5 pb-0.5 text-xs font-medium text-muted-foreground",children:i.jsx("span",{className:"truncate",children:V.label})}),V.rows.map(N=>i.jsxs("button",{type:"button",role:"menuitem","aria-label":V.label?`${V.label} ${N.title}`:N.title,onClick:()=>u(N),className:te("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[N.icon&&i.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:N.icon}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:N.title}),N.subtitle&&i.jsx("div",{className:"text-xs text-muted-foreground",children:N.subtitle})]}),N.active&&i.jsx(Ot,{size:14,className:"text-foreground mt-0.5"})]},N.key))]},V.key),e[19]=C):C=e[19],L=o.map(C),e[17]=o,e[18]=L}else L=e[18];let w;e[20]!==L?(w=i.jsx("div",{role:"menu",className:"flex flex-col",children:L}),e[20]=L,e[21]=w):w=e[21];let S;e[22]!==y||e[23]!==w?(S=i.jsxs(Ts,{align:"end",className:"p-1 w-64",children:[y,w]}),e[22]=y,e[23]=w,e[24]=S):S=e[24];let j;return e[25]!==c||e[26]!==b||e[27]!==S?(j=i.jsxs(Ns,{open:c,onOpenChange:d,children:[b,S]}),e[25]=c,e[26]=b,e[27]=S,e[28]=j):j=e[28],j}function ah(t){return t==="fast"?i.jsx(Wd,{size:16}):t==="thinking"?i.jsx(km,{size:16}):i.jsx(Kn,{size:16})}const T8="flex items-center justify-center gap-1.5 flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors min-w-0",E8="bg-background text-foreground shadow-sm",R8="text-muted-foreground hover:text-foreground";function P8(t){const e=M.c(4),{options:s}=t;let n;e[0]!==s?(n=s.map(I8),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg bg-muted",children:n}),e[2]=n,e[3]=r):r=e[3],r}function I8(t){return i.jsxs("button",{type:"button",onClick:t.onSelect,className:te(T8,t.active?E8:R8),children:[t.icon,i.jsx("span",{className:"truncate",children:t.label})]},t.key)}function D8(){const t=M.c(18),{pendingHarnessId:e,setPendingAgentOption:s}=Vs(),n=tc(),r=e==="claude-code"||e==="codex";let o;t[0]!==n?(o=lm(n)??"claude-code-desktop",t[0]=n,t[1]=o):o=t[1];const a=o;let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(Kd,{size:14}),t[2]=l):l=t[2];const c=!r;let d;t[3]!==s?(d=()=>s("decopilot"),t[3]=s,t[4]=d):d=t[4];let h;t[5]!==c||t[6]!==d?(h={key:"cloud",icon:l,label:"Cloud",active:c,onSelect:d},t[5]=c,t[6]=d,t[7]=h):h=t[7];let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(jr,{size:14}),t[8]=u):u=t[8];let f;t[9]!==a||t[10]!==s?(f=()=>s(a),t[9]=a,t[10]=s,t[11]=f):f=t[11];let m;t[12]!==r||t[13]!==f?(m={key:"local",icon:u,label:"This device",active:r,onSelect:f},t[12]=r,t[13]=f,t[14]=m):m=t[14];let p;return t[15]!==h||t[16]!==m?(p=i.jsx("div",{className:"p-1",children:i.jsx(P8,{options:[h,m]})}),t[15]=h,t[16]=m,t[17]=p):p=t[17],p}function lh(t){return{key:t.key,label:t.label,rows:sp.map(e=>({key:`${t.key}-${e}`,icon:t.icon,title:Qi[e],subtitle:tp(t.mode,e),active:t.isActiveRuntime&&t.currentTier===e,onSelect:()=>{t.setOption(t.option),t.setTier(e)}}))}}function O8(){const t=M.c(42),e=k8(),s=V8(),n=C8(),{pendingHarnessId:r,setPendingAgentOption:o}=Vs(),a=tc(),c=Ti()?.isThreadLocked??!1,d=a.claudeCode||a.codex,h=n!=="cloud-decopilot";let u;if(h){const b=c?r==="claude-code":a.claudeCode||r==="claude-code",y=c?r==="codex":a.codex||r==="codex",L=b&&y;let w;if(t[0]!==L||t[1]!==r||t[2]!==o||t[3]!==s||t[4]!==b||t[5]!==y||t[6]!==e){if(w=[],b){const S=L?"Claude Code":void 0;let j;t[8]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(fb,{size:16}),t[8]=j):j=t[8];const C=r==="claude-code";let V;t[9]!==o||t[10]!==s||t[11]!==S||t[12]!==C||t[13]!==e?(V=lh({key:"claude-code",label:S,icon:j,mode:"local-claude-code",option:"claude-code-desktop",isActiveRuntime:C,currentTier:e,setOption:o,setTier:s}),t[9]=o,t[10]=s,t[11]=S,t[12]=C,t[13]=e,t[14]=V):V=t[14],w.push(V)}if(y){const S=L?"Codex":void 0;let j;t[15]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(mb,{size:16}),t[15]=j):j=t[15];const C=r==="codex";let V;t[16]!==o||t[17]!==s||t[18]!==S||t[19]!==C||t[20]!==e?(V=lh({key:"codex",label:S,icon:j,mode:"local-codex",option:"codex-desktop",isActiveRuntime:C,currentTier:e,setOption:o,setTier:s}),t[16]=o,t[17]=s,t[18]=S,t[19]=C,t[20]=e,t[21]=V):V=t[21],w.push(V)}t[0]=L,t[1]=r,t[2]=o,t[3]=s,t[4]=b,t[5]=y,t[6]=e,t[7]=w}else w=t[7];u=w}else{let b;t[22]!==s||t[23]!==e?(b=sp.map(L=>({key:`cloud-${L}`,icon:ah(L),title:Qi[L],subtitle:tp("cloud-decopilot",L),active:e===L,onSelect:()=>s(L)})),t[22]=s,t[23]=e,t[24]=b):b=t[24];let y;t[25]!==b?(y=[{key:"cloud",rows:b}],t[25]=b,t[26]=y):y=t[26],u=y}let f;t[27]!==h||t[28]!==r?(f=h?pb(r):null,t[27]=h,t[28]=r,t[29]=f):f=t[29];const m=f,p=m?.Icon;let g;t[30]!==p||t[31]!==e?(g=p?i.jsx(p,{size:16}):ah(e),t[30]=p,t[31]=e,t[32]=g):g=t[32];const x=m?`${m.label} ${Qi[e]}`:Qi[e];let v;t[33]!==d||t[34]!==c?(v=d&&!c?i.jsx(D8,{}):void 0,t[33]=d,t[34]=c,t[35]=v):v=t[35];let _;return t[36]!==u||t[37]!==g||t[38]!==x||t[39]!==v||t[40]!==e?(_=i.jsx(A8,{tier:e,pillIcon:g,pillLabel:x,groups:u,header:v}),t[36]=u,t[37]=g,t[38]=x,t[39]=v,t[40]=e,t[41]=_):_=t[41],_}async function w9(t,e,s,n,r){if(!ql(e)){de.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!gb(o,e)){const l=Wm(e),c=e?.title??"This model";r?r({fileName:s.name,modelName:c,accepted:l}):de.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}.`});return}const a=10*1024*1024;if(s.size>a){de.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((u,f)=>{l.onload=()=>{const m=l.result;if(typeof m!="string"){f(new Error("Failed to read file as data URL"));return}const p=m.includes(",")?m.split(",")[1]??m:m;u(p)},l.onerror=f});l.readAsDataURL(s);const d=await c,h={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};xx(t,{from:n,to:n},h)}catch(l){console.error("Failed to process file:",l),de.error(`Failed to load file "${s.name}"`)}}function M8(t){const e=M.c(8),{editor:s,selectedModel:n,onUnsupportedFile:r}=t,o=k.useRef(B8);let a,l;e[0]!==s||e[1]!==r||e[2]!==n?(a=()=>{o.current=async(h,u)=>{await w9(s,n,h,u,r)}},l=[s,n,r],e[0]=s,e[1]=r,e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),k.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const h=new qx("fileDropHandler");s.state.plugins.find(m=>m.spec.key===h)&&s.unregisterPlugin(h);const f=new Gx({key:h,props:{handleDrop:(m,p,g,x)=>{if(x)return!1;const v=p.dataTransfer?.files;if(!v||v.length===0)return!1;p.preventDefault();const _=m.posAtCoords({left:p.clientX,top:p.clientY});if(!_)return!1;const b=Array.from(v);return(async()=>{let y=_.pos;for(const L of b)await o.current?.(L,y),y=m.state.selection.to})(),!0},handlePaste:(m,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const x=Array.from(g).filter($8);return x.length===0?!1:(p.preventDefault(),(async()=>{let v=m.state.selection.from;for(const _ of x){const b=_.getAsFile();b&&(await o.current?.(b,v),v=m.state.selection.to)}})(),!0)}}});return s.registerPlugin(f),()=>{s?.isDestroyed||s.unregisterPlugin(h)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),k.useEffect(c,d),null}function $8(t){return t.kind==="file"}function B8(){return Promise.resolve()}function z8(t){const e=M.c(26),{info:s,onClose:n}=t,r=s!==null;let o;e[0]!==n?(o=L=>!L&&n(),e[0]=n,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=l):l=e[3];let c,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-warning/15 text-warning",children:i.jsx(br,{size:18})}),d=i.jsx(hs,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]);const h=s?.fileName;let u;e[6]!==h?(u=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,i.jsxs(us,{className:"relative gap-4",children:[c,i.jsxs("div",{children:[d,i.jsxs(si,{className:"mt-1.5 text-sm leading-relaxed",children:[i.jsxs("span",{className:"font-medium text-foreground",children:["“",h,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=h,e[7]=u):u=e[7];const f=s?.modelName;let m;e[8]!==f?(m=i.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[f," accepts"]}),e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Cv,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let x;e[11]!==g?(x=i.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,i.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:i.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,x]})}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==n?(_=i.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:i.jsx(re,{onClick:n,children:"Got it"})}),e[16]=n,e[17]=_):_=e[17];let b;e[18]!==v||e[19]!==_||e[20]!==u?(b=i.jsxs(Zt,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:F8,children:[u,v,_]}),e[18]=v,e[19]=_,e[20]=u,e[21]=b):b=e[21];let y;return e[22]!==r||e[23]!==b||e[24]!==o?(y=i.jsx(es,{open:r,onOpenChange:o,children:b}),e[22]=r,e[23]=b,e[24]=o,e[25]=y):y=e[25],y}function F8(t){return t.preventDefault()}function U8(){const t=M.c(3),[e,s]=k.useState(null);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>s(null),t[0]=n):n=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:n},t[1]=e,t[2]=r):r=t[2],r}var H8=vx;var K8=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],T0=K8.join(","),np=typeof Element>"u",Do=np?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,vl=!np&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},bl=function(e,s){var n;s===void 0&&(s=!0);var r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):bl(e.parentNode));return a},W8=function(e){var s,n=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return n===""||n==="true"},q8=function(e,s,n){if(bl(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(T0));return s&&Do.call(e,T0)&&r.unshift(e),r=r.filter(n),r},E0=function(e,s,n){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!bl(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=E0(c,!0,n);n.flatten?r.push.apply(r,d):r.push({scopeParent:a,candidates:d})}else{var h=Do.call(a,T0);h&&n.filter(a)&&(s||!e.includes(a))&&r.push(a);var u=a.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(a),f=!bl(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(u&&f){var m=E0(u===!0?a.children:u.children,!0,n);n.flatten?r.push.apply(r,m):r.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return r},ip=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},rp=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||W8(e))&&!ip(e)?0:e.tabIndex},G8=function(e,s){var n=rp(e);return n<0&&s&&!ip(e)?0:n},Y8=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},op=function(e){return e.tagName==="INPUT"},J8=function(e){return op(e)&&e.type==="hidden"},X8=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return s},Q8=function(e,s){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===s)return e[n]},Z8=function(e){if(!e.name)return!0;var s=e.form||vl(e),n=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=n(window.CSS.escape(e.name));else try{r=n(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=Q8(r,e.form);return!o||o===e},eL=function(e){return op(e)&&e.type==="radio"},tL=function(e){return eL(e)&&!Z8(e)},sL=function(e){var s,n=e&&vl(e),r=(s=n)===null||s===void 0?void 0:s.host,o=!1;if(n&&n!==e){var a,l,c;for(o=!!((a=r)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(r)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&r;){var d,h,u;n=vl(r),r=(d=n)===null||d===void 0?void 0:d.host,o=!!((h=r)!==null&&h!==void 0&&(u=h.ownerDocument)!==null&&u!==void 0&&u.contains(r))}}return o},ch=function(e){var s=e.getBoundingClientRect(),n=s.width,r=s.height;return n===0&&r===0},nL=function(e,s){var n=s.displayCheck,r=s.getShadowRoot;if(n==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=Do.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Do.call(l,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof r=="function"){for(var c=e;e;){var d=e.parentElement,h=vl(e);if(d&&!d.shadowRoot&&r(d)===!0)return ch(e);e.assignedSlot?e=e.assignedSlot:!d&&h!==e.ownerDocument?e=h.host:e=d}e=c}if(sL(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return ch(e);return!1},iL=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var n=0;n<s.children.length;n++){var r=s.children.item(n);if(r.tagName==="LEGEND")return Do.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},rL=function(e,s){return!(s.disabled||J8(s)||nL(s,e)||X8(s)||iL(s))},dh=function(e,s){return!(tL(s)||rp(s)<0||!rL(e,s))},oL=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},ap=function(e){var s=[],n=[];return e.forEach(function(r,o){var a=!!r.scopeParent,l=a?r.scopeParent:r,c=G8(l,a),d=a?ap(r.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):n.push({documentOrder:o,tabIndex:c,item:r,isScope:a,content:d})}),n.sort(Y8).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},lp=function(e,s){s=s||{};var n;return s.getShadowRoot?n=E0([e],s.includeContainer,{filter:dh.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:oL}):n=q8(e,s.includeContainer,dh.bind(null,s)),ap(n)};function aL(){return/apple/i.test(navigator.vendor)}const uh="data-floating-ui-focusable";function lL(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function R0(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&D5(s)){let n=e;for(;n;){if(t===n)return!0;n=n.parentNode||n.host}}return!1}function Hr(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Mc(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function cL(t){return t.matches("html,body")}function Oo(t){return t?.ownerDocument||document}function dL(t){return t?t.hasAttribute(uh)?t:t.querySelector("["+uh+"]")||t:null}function Fa(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...Fa(t,r.id,s)])}function uL(t){return"nativeEvent"in t}var hL=typeof document<"u",fL=function(){},xi=hL?k.useLayoutEffect:fL;const mL={...Z1},pL=mL.useInsertionEffect,gL=pL||(t=>t());function Ki(t){const e=k.useRef(()=>{});return gL(()=>{e.current=t}),k.useCallback(function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}const cp=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function dp(t,e){const s=lp(t,cp()),n=s.length;if(n===0)return;const r=lL(Oo(t)),o=s.indexOf(r),a=o===-1?e===1?0:n-1:o+e;return s[a]}function xL(t){return dp(Oo(t).body,1)||t}function vL(t){return dp(Oo(t).body,-1)||t}function $c(t,e){const s=e||t.currentTarget,n=t.relatedTarget;return!n||!R0(s,n)}function bL(t){lp(t,cp()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function hh(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const n=s.dataset.tabindex;delete s.dataset.tabindex,n?s.setAttribute("tabindex",n):s.removeAttribute("tabindex")})}const _L="data-floating-ui-focusable",fh="active",mh="selected",yL={...Z1};let ph=!1,LL=0;const gh=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+LL++;function SL(){const[t,e]=k.useState(()=>ph?gh():void 0);return xi(()=>{t==null&&e(gh())},[]),k.useEffect(()=>{ph=!0},[]),t}const wL=yL.useId,j9=wL||SL;function jL(){const t=new Map;return{emit(e,s){var n;(n=t.get(e))==null||n.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var n;(n=t.get(e))==null||n.delete(s)}}}const CL=k.createContext(null),kL=k.createContext(null),up=()=>{var t;return((t=k.useContext(CL))==null?void 0:t.id)||null},hp=()=>k.useContext(kL);function C9(t){return"data-floating-ui-"+t}const VL={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},xh=k.forwardRef(function(e,s){const[n,r]=k.useState();xi(()=>{aL()&&r("button")},[]);const o={ref:s,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[C9("focus-guard")]:"",style:VL};return i.jsx("span",{...e,...o})}),NL={clipPath:"inset(50%)",position:"fixed",top:0,left:0},fp=k.createContext(null),vh=C9("portal");function AL(t){t===void 0&&(t={});const{id:e,root:s}=t,n=j9(),r=EL(),[o,a]=k.useState(null),l=k.useRef(null);return xi(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),xi(()=>{if(!n||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=n,d.setAttribute(vh,""),c.appendChild(d),l.current=d,a(d)},[e,n]),xi(()=>{if(s===null||!n||l.current)return;let c=s||r?.portalNode;c&&!F5(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const h=document.createElement("div");h.id=n,h.setAttribute(vh,""),c=d||c,c.appendChild(h),l.current=h,a(h)},[e,s,n,r]),o}function TL(t){const{children:e,id:s,root:n,preserveTabOrder:r=!0}=t,o=AL({id:s,root:n}),[a,l]=k.useState(null),c=k.useRef(null),d=k.useRef(null),h=k.useRef(null),u=k.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&r&&!!(n||o);return k.useEffect(()=>{if(!o||!r||f)return;function g(x){o&&$c(x)&&(x.type==="focusin"?hh:bL)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,f]),k.useEffect(()=>{o&&(m||hh(o))},[m,o]),i.jsxs(fp.Provider,{value:k.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:u,portalNode:o,setFocusManagerState:l}),[r,o]),children:[p&&o&&i.jsx(xh,{"data-type":"outside",ref:c,onFocus:g=>{if($c(g,o)){var x;(x=h.current)==null||x.focus()}else{const v=a?a.domReference:null,_=vL(v);_?.focus()}}}),p&&o&&i.jsx("span",{"aria-owns":o.id,style:NL}),o&&qi.createPortal(e,o),p&&o&&i.jsx(xh,{"data-type":"outside",ref:d,onFocus:g=>{if($c(g,o)){var x;(x=u.current)==null||x.focus()}else{const v=a?a.domReference:null,_=xL(v);_?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const EL=()=>k.useContext(fp),RL={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},PL={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},bh=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function IL(t,e){e===void 0&&(e={});const{open:s,onOpenChange:n,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:h=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=hp(),x=Ki(typeof c=="function"?c:()=>!1),v=typeof c=="function"?x:c,_=k.useRef(!1),{escapeKey:b,outsidePress:y}=bh(m),{escapeKey:L,outsidePress:w}=bh(p),S=k.useRef(!1),j=Ki(E=>{var R;if(!s||!a||!l||E.key!=="Escape"||S.current)return;const D=(R=o.current.floatingContext)==null?void 0:R.nodeId,P=g?Fa(g.nodesRef.current,D):[];if(!b&&(E.stopPropagation(),P.length>0)){let I=!0;if(P.forEach(O=>{var B;if((B=O.context)!=null&&B.open&&!O.context.dataRef.current.__escapeKeyBubbles){I=!1;return}}),!I)return}n(!1,uL(E)?E.nativeEvent:E,"escape-key")}),C=Ki(E=>{var R;const D=()=>{var P;j(E),(P=Hr(E))==null||P.removeEventListener("keydown",D)};(R=Hr(E))==null||R.addEventListener("keydown",D)}),V=Ki(E=>{var R;const D=o.current.insideReactTree;o.current.insideReactTree=!1;const P=_.current;if(_.current=!1,d==="click"&&P||D||typeof v=="function"&&!v(E))return;const I=Hr(E),O="["+C9("inert")+"]",B=Oo(r.floating).querySelectorAll(O);let z=un(I)?I:null;for(;z&&!Rc(z);){const X=$5(z);if(Rc(X)||!un(X))break;z=X}if(B.length&&un(I)&&!cL(I)&&!R0(I,r.floating)&&Array.from(B).every(X=>!R0(z,X)))return;if(B5(I)&&A){const X=Rc(I),H=z5(I),Z=/auto|scroll/,K=X||Z.test(H.overflowX),Y=X||Z.test(H.overflowY),F=K&&I.clientWidth>0&&I.scrollWidth>I.clientWidth,Q=Y&&I.clientHeight>0&&I.scrollHeight>I.clientHeight,J=H.direction==="rtl",ee=Q&&(J?E.offsetX<=I.offsetWidth-I.clientWidth:E.offsetX>I.clientWidth),q=F&&E.offsetY>I.clientHeight;if(ee||q)return}const $=(R=o.current.floatingContext)==null?void 0:R.nodeId,U=g&&Fa(g.nodesRef.current,$).some(X=>{var H;return Mc(E,(H=X.context)==null?void 0:H.elements.floating)});if(Mc(E,r.floating)||Mc(E,r.domReference)||U)return;const W=g?Fa(g.nodesRef.current,$):[];if(W.length>0){let X=!0;if(W.forEach(H=>{var Z;if((Z=H.context)!=null&&Z.open&&!H.context.dataRef.current.__outsidePressBubbles){X=!1;return}}),!X)return}n(!1,E,"outside-press")}),N=Ki(E=>{var R;const D=()=>{var P;V(E),(P=Hr(E))==null||P.removeEventListener(d,D)};(R=Hr(E))==null||R.addEventListener(d,D)});k.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let E=-1;function R(B){n(!1,B,"ancestor-scroll")}function D(){window.clearTimeout(E),S.current=!0}function P(){E=window.setTimeout(()=>{S.current=!1},M5()?5:0)}const I=Oo(r.floating);l&&(I.addEventListener("keydown",L?C:j,L),I.addEventListener("compositionstart",D),I.addEventListener("compositionend",P)),v&&I.addEventListener(d,w?N:V,w);let O=[];return f&&(un(r.domReference)&&(O=Ec(r.domReference)),un(r.floating)&&(O=O.concat(Ec(r.floating))),!un(r.reference)&&r.reference&&r.reference.contextElement&&(O=O.concat(Ec(r.reference.contextElement)))),O=O.filter(B=>{var z;return B!==((z=I.defaultView)==null?void 0:z.visualViewport)}),O.forEach(B=>{B.addEventListener("scroll",R,{passive:!0})}),()=>{l&&(I.removeEventListener("keydown",L?C:j,L),I.removeEventListener("compositionstart",D),I.removeEventListener("compositionend",P)),v&&I.removeEventListener(d,w?N:V,w),O.forEach(B=>{B.removeEventListener("scroll",R)}),window.clearTimeout(E)}},[o,r,l,v,d,s,n,f,a,b,y,j,L,C,V,w,N]),k.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const T=k.useMemo(()=>({onKeyDown:j,...h&&{[RL[u]]:E=>{n(!1,E.nativeEvent,"reference-press")},...u!=="click"&&{onClick(E){n(!1,E.nativeEvent,"reference-press")}}}}),[j,n,h,u]),A=k.useMemo(()=>{function E(R){R.button===0&&(_.current=!0)}return{onKeyDown:j,onMouseDown:E,onMouseUp:E,[PL[d]]:()=>{o.current.insideReactTree=!0}}},[j,d,o]);return k.useMemo(()=>a?{reference:T,floating:A}:{},[a,T,A])}function DL(t){const{open:e=!1,onOpenChange:s,elements:n}=t,r=j9(),o=k.useRef({}),[a]=k.useState(()=>jL()),l=up()!=null,[c,d]=k.useState(n.reference),h=Ki((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),u=k.useMemo(()=>({setPositionReference:d}),[]),f=k.useMemo(()=>({reference:c||n.reference||null,floating:n.floating||null,domReference:n.reference}),[c,n.reference,n.floating]);return k.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:f,events:a,floatingId:r,refs:u}),[e,h,f,a,r,u])}function OL(t){t===void 0&&(t={});const{nodeId:e}=t,s=DL({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||s,r=n.elements,[o,a]=k.useState(null),[l,c]=k.useState(null),h=r?.domReference||o,u=k.useRef(null),f=hp();xi(()=>{h&&(u.current=h)},[h]);const m=O5({...t,elements:{...r,...l&&{reference:l}}}),p=k.useCallback(b=>{const y=un(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),m.refs.setReference(y)},[m.refs]),g=k.useCallback(b=>{(un(b)||b===null)&&(u.current=b,a(b)),(un(m.refs.reference.current)||m.refs.reference.current===null||b!==null&&!un(b))&&m.refs.setReference(b)},[m.refs]),x=k.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:u}),[m.refs,g,p]),v=k.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),_=k.useMemo(()=>({...m,...n,refs:x,elements:v,nodeId:e}),[m,x,v,e,n]);return xi(()=>{n.dataRef.current.floatingContext=_;const b=f?.nodesRef.current.find(y=>y.id===e);b&&(b.context=_)}),k.useMemo(()=>({...m,context:_,refs:x,elements:v}),[m,x,v,_])}function Bc(t,e,s){const n=new Map,r=s==="item";let o=t;if(r&&t){const{[fh]:a,[mh]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[_L]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,h]=c;if(!(r&&[fh,mh].includes(d)))if(d.indexOf("on")===0){if(n.has(d)||n.set(d,[]),typeof h=="function"){var u;(u=n.get(d))==null||u.push(h),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=n.get(d))==null?void 0:f.map(x=>x(...p)).find(x=>x!==void 0)}}}else a[d]=h}),a),{})}}function ML(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),n=t.map(l=>l?.item),r=k.useCallback(l=>Bc(l,t,"reference"),e),o=k.useCallback(l=>Bc(l,t,"floating"),s),a=k.useCallback(l=>Bc(l,t,"item"),n);return k.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const $L=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function BL(t,e){var s,n;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=j9(),h=((s=o.domReference)==null?void 0:s.id)||d,u=k.useMemo(()=>{var _;return((_=dL(o.floating))==null?void 0:_.id)||a},[o.floating,a]),f=(n=$L.get(c))!=null?n:c,p=up()!=null,g=k.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:r?u:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":r?u:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:h},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,u,p,r,h,c]),x=k.useMemo(()=>{const _={id:u,...f&&{role:f}};return f==="tooltip"||c==="label"?_:{..._,...f==="menu"&&{"aria-labelledby":h}}},[f,u,h,c]),v=k.useCallback(_=>{let{active:b,selected:y}=_;const L={role:"option",...b&&{id:u+"-fui-option"}};switch(c){case"select":case"combobox":return{...L,"aria-selected":y}}return{}},[u,c]);return k.useMemo(()=>l?{reference:g,floating:x,item:v}:{},[l,g,x,v])}function zL({children:t}){const{state:e,dispatch:s}=cv(),{open:n,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=OL({placement:"bottom-start",open:n,onOpenChange:f=>{f||o()},elements:{reference:r},middleware:[U5(10),H5(),K5()],whileElementsMounted:W5}),d=IL(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),h=BL(c,{role:"listbox"}),{getFloatingProps:u}=ML([d,h]);return n?i.jsx(TL,{children:i.jsx("div",{ref:a.setFloating,style:l,...u(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const FL=t=>{const e=M.c(29),{item:s,isSelected:n,onSelect:r,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const w=mn(s._meta);l=s.title||Bd(s.name,w),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,h=s.icon,u=n&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==u||e[3]!==f?(m=te("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",u,f),e[2]=u,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==h||e[6]!==c?(p=h!==void 0&&i.jsx(Yn,{icon:h,name:c,size:"xs",className:"mr-2"}),e[5]=h,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=i.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let x;e[10]!==o?(x=o&&i.jsx(or,{size:"xs"}),e[10]=o,e[11]=x):x=e[11];let v;e[12]!==g||e[13]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,x]}),e[12]=g,e[13]=x,e[14]=v):v=e[14];let _;e[15]!==d?(_=d&&i.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=_):_=e[16];let b;e[17]!==v||e[18]!==_?(b=i.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,_]}),e[17]=v,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&i.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=y):y=e[21];let L;return e[22]!==r||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==m||e[27]!==p?(L=i.jsxs("div",{ref:a,onClick:r,className:m,children:[p,b,y]}),e[22]=r,e[23]=a,e[24]=b,e[25]=y,e[26]=m,e[27]=p,e[28]=L):L=e[28],L},UL=t=>{const e=M.c(18),{editor:s,queryKey:n,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(a={editor:s,queryKey:n,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:h}=dv(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=p):p=e[5],p}let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=u):u=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==h?.name){let p;e[12]!==d||e[13]!==c||e[14]!==h?.name?(p=(g,x)=>i.jsx(FL,{item:g,isSelected:x===c,ref:x===c?WL:void 0,onSelect:()=>d(g,x),isLoading:h?.name===g.name},`${g.kind??"item"}:${g.name}`),e[12]=d,e[13]=c,e[14]=h?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=h?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=i.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:u,children:i.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function HL(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"p-1",children:[...Array(3)].map(KL)}),t[0]=e):e=t[0],e}function KL(t,e){return i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[i.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),i.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function mp(t){const e=M.c(18),{editor:s,char:n,pluginKey:r,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let h;e[0]!==c||e[1]!==n||e[2]!==s||e[3]!==d||e[4]!==r?(h={editor:s,char:n,pluginKey:r,allow:c,onOpenChange:d},e[0]=c,e[1]=n,e[2]=s,e[3]=d,e[4]=r,e[5]=h):h=e[5];const{state:u,dispatch:f}=av(h);let m;e[6]!==f||e[7]!==u?(m={state:u,dispatch:f},e[6]=f,e[7]=u,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(HL,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=i.jsx(zL,{children:i.jsx(k.Suspense,{fallback:p,children:i.jsx(UL,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let x;return e[15]!==m||e[16]!==g?(x=i.jsx(lv.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=x):x=e[17],x}function WL(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const qL=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],GL=({editor:t,virtualMcpId:e})=>{const s=bs(),{org:n}=Ee(),r=Xo(),o=n9(r),a=ut({connectionId:e,orgId:n.id,orgSlug:n.slug}),l=it.virtualMcpResources(e,n.id),[c,d]=k.useState("categories"),h=k.useRef(c);h.current=c;const u=k.useRef(null),f=k.useRef(!1),m=["at-mention",n.id,e??"default",c],p=async({item:v,range:_})=>{if(Ne("chat_picker_item_selected",{picker:"@",item_kind:v.kind,item_name:v.name}),v.kind!=="category"&&(f.current=!0),v.kind==="category")return d(v.name==="agents"?"agents":"resources"),!1;if(v.kind==="agent"&&v.agentId){ar(t,_,{id:v.agentId,name:v.name,metadata:{agentId:v.agentId,title:v.name},char:"@"}),d("categories");return}if(v.kind==="resource"&&v.uri&&a){try{const b=await em(a,v.uri);ar(t,_,{id:v.uri,name:v.uri,metadata:b.contents,char:"@"})}catch(b){console.error("[at-mention] Failed to fetch resource:",b),de.error("Failed to load resource. Please try again.")}d("categories");return}},g=async v=>{const{query:_}=v,b=h.current;if(b==="categories"){if(!_.trim())return qL;const w=_.toLowerCase(),S=r.filter(C=>C.status==="active"&&(!C.id||!Za(C.id))&&!o.has(C.id)&&C.id!==e&&(C.title.toLowerCase().includes(w)||C.description?.toLowerCase().includes(w))).map(C=>({name:C.title,title:C.title,description:C.description??void 0,icon:C.icon??null,kind:"agent",agentId:C.id})),j=await(async()=>{if(!a)return[];let C=s.getQueryData(l);return C||(C=await s.fetchQuery({queryKey:l,queryFn:()=>go(a),staleTime:6e4})),(C?.resources??[]).filter(V=>V.uri.toLowerCase().includes(w)||V.name?.toLowerCase().includes(w)||V.description?.toLowerCase().includes(w)).map(V=>({name:V.name??V.uri,title:V.name,description:V.description,kind:"resource",uri:V.uri}))})();return[...S,...j]}if(b==="agents"){let w=r.filter(S=>S.status==="active"&&(!S.id||!Za(S.id))&&!o.has(S.id)&&S.id!==e);if(_.trim()){const S=_.toLowerCase();w=w.filter(j=>j.title.toLowerCase().includes(S)||j.description?.toLowerCase().includes(S))}return w.map(S=>({name:S.title,title:S.title,description:S.description??void 0,icon:S.icon??null,kind:"agent",agentId:S.id}))}if(!a)return[];let y=s.getQueryData(l);y?s.fetchQuery({queryKey:l,queryFn:()=>go(a),staleTime:6e4}).catch(()=>{}):y=await s.fetchQuery({queryKey:l,queryFn:()=>go(a),staleTime:6e4});let L=y?.resources??[];if(_.trim()){const w=_.toLowerCase();L=L.filter(S=>S.uri.toLowerCase().includes(w)||S.name?.toLowerCase().includes(w)||S.description?.toLowerCase().includes(w))}return L.map(w=>({name:w.name??w.uri,title:w.name,description:w.description,kind:"resource",uri:w.uri}))},x=v=>{if(v)u.current=Date.now(),f.current=!1,Ne("chat_picker_opened",{picker:"@"});else{const _=u.current;Ne("chat_picker_closed",{picker:"@",outcome:f.current?"selected":"dismissed",duration_ms:_?Date.now()-_:null}),u.current=null,d("categories")}};return i.jsx(mp,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:g,onSelect:p,onOpenChange:x})};async function _h(t,e,s,n,r,o){try{const a=await Yo(s,n,o);ar(t,e,{id:n,name:yr(n,r),metadata:a.messages,char:"/",kind:"prompt",args:o})}catch(a){console.error("[slash] Failed to fetch prompt:",a),de.error("Failed to load prompt. Please try again.")}}async function YL(t,e,s,n){try{const r=await em(s,n);ar(t,e,{id:n,name:n,metadata:r.contents,char:"/",kind:"resource"})}catch(r){console.error("[slash] Failed to fetch resource:",r),de.error("Failed to load resource. Please try again.")}}async function JL(t,e,s,n){try{const{files:r,omittedPaths:o}=await Sb(s,n.volume,n.path),a={sandboxPath:n.sandboxPath,files:r,omittedPaths:o};ar(t,e,{id:n.id,name:n.name,metadata:a,char:"/",kind:"skill"})}catch(r){console.error("[slash] Failed to fetch skill:",r),de.error("Failed to load skill. Please try again.")}}const XL=({editor:t,virtualMcpId:e})=>{const s=bs(),{org:n}=Ee(),r=ut({connectionId:e,orgId:n.id,orgSlug:n.slug}),o=it.virtualMcpPrompts(e,n.id),a=it.virtualMcpResources(e,n.id),l=it.slashSkills(n.id),c=["slash-mention",n.id,e??"default"],[d,h]=k.useState(null),[u,f]=k.useState(null),m=Yx(t);m&&(m.onEditChip=async L=>{if(r)try{const S=(await yh(s,o,r)).find(j=>j.name===L.promptId);if(!S?.arguments||S.arguments.length===0)return;f({...L,prompt:S})}catch(w){console.error("[slash] Failed to load prompt for editing:",w),de.error("Failed to load prompt. Please try again.")}});const p=k.useRef(null),g=k.useRef(!1),x=async({item:L,range:w})=>{if(Ne("chat_picker_item_selected",{picker:"/",item_kind:L.kind,item_name:L.name}),g.current=!0,!!r)if(L.kind==="prompt"){if(L.arguments&&L.arguments.length>0){h({range:w,item:L});return}const S=mn(L._meta);await _h(t,w,r,L.name,S)}else L.kind==="skill"?L.skill&&await JL(t,w,n.slug,L.skill):L.uri&&await YL(t,w,r,L.uri)},v=async L=>{if(!d||!r)return;const{range:w,item:S}=d,j=mn(S._meta);await _h(t,w,r,S.name,j,L),h(null)},_=async L=>{if(!(!u||!r)){try{const w=await Yo(r,u.promptId,L),S=mn(u.prompt._meta);t.chain().focus().setNodeSelection(u.pos).deleteSelection().insertContentAt(u.pos,zd({id:u.promptId,name:yr(u.promptId,S),metadata:w.messages,char:"/",kind:"prompt",args:L})).run(),Ne("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:u.promptId})}catch(w){console.error("[slash] Failed to update prompt:",w),de.error("Failed to update prompt. Please try again.")}f(null)}},b=async L=>{const{query:w}=L;if(!r)return[];const[S,j,C]=await Promise.all([yh(s,o,r),ZL(s,a,r),QL(s,l,n.slug)]),V=w.trim().toLowerCase(),N=(S??[]).filter(E=>!V||E.name.toLowerCase().includes(V)||E.title?.toLowerCase().includes(V)||E.description?.toLowerCase().includes(V)).map(E=>({name:E.name,title:E.title,description:E.description,kind:"prompt",arguments:E.arguments,_meta:E._meta})),T=(j??[]).filter(E=>!V||E.uri.toLowerCase().includes(V)||E.name?.toLowerCase().includes(V)||E.description?.toLowerCase().includes(V)).map(E=>({name:E.name??E.uri,title:E.name,description:E.description,kind:"resource",uri:E.uri})),A=(C??[]).filter(E=>!V||E.name.toLowerCase().includes(V)||E.id.toLowerCase().includes(V)||E.description?.toLowerCase().includes(V)).map(E=>({name:E.name,title:E.name,description:E.description??void 0,kind:"skill",skill:E}));return[...N,...T,...A]},y=d?.item.kind==="prompt"?{name:d.item.name,title:d.item.title,arguments:d.item.arguments,description:d.item.description,_meta:d.item._meta}:null;return i.jsxs(i.Fragment,{children:[i.jsx(mp,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:c,queryFn:b,onSelect:x,onOpenChange:L=>{if(L)p.current=Date.now(),g.current=!1,Ne("chat_picker_opened",{picker:"/"});else{const w=p.current;Ne("chat_picker_closed",{picker:"/",outcome:g.current?"selected":"dismissed",duration_ms:w?Date.now()-w:null}),p.current=null}}}),i.jsx(No,{prompt:y,setPrompt:()=>h(null),onSubmit:v}),i.jsx(No,{prompt:u?.prompt??null,setPrompt:()=>f(null),onSubmit:_,defaultValues:u?.args},u?`edit-${u.promptId}-${u.pos}`:"edit-idle")]})};async function yh(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>j0(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>j0(s),staleTime:6e4}),n?.prompts??[]}async function QL(t,e,s){const n=t.getQueryData(e),r=()=>t.fetchQuery({queryKey:e,queryFn:()=>wb(s),staleTime:6e4});return n?(r().catch(()=>{}),n):r().catch(()=>[])}async function ZL(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>go(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>go(s),staleTime:6e4}),n?.resources??[]}function e7(t){return[cm.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),H8.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),Xx,bx]}function pp({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:n=!1,placeholder:r,onSubmit:o,children:a}){const l=k.useRef(o),c=k.useRef(e),d=k.useRef(n),h=k.useRef(r),u=vm({extensions:e7(h),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return k.useEffect(()=>{u?.setEditable(!s)},[u,s]),k.useEffect(()=>{l.current=o},[o]),k.useEffect(()=>{c.current=e},[e]),k.useEffect(()=>{d.current=n},[n]),k.useEffect(()=>{h.current=r},[r]),k.useEffect(()=>{if(!u||u.isDestroyed)return;const f=JSON.stringify(u.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&u.commands.setContent(t||{type:"doc",content:[]})},[u,t]),i.jsx(Jx.Provider,{value:{editor:u},children:a})}function gp(t){const e=M.c(27),{disabled:s,virtualMcpId:n,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,h=r===void 0?!1:r,{editor:u}=Fd();let f,m;if(e[0]!==u?(f=()=>({focus:()=>{u?.commands.focus()},clear:()=>{u?.commands.clearContent(!0)},appendText:j=>{if(!u)return;const C=u.state.doc.textContent.trim()==="";u.commands.focus("end"),C||u.commands.insertContent(" "),u.commands.insertContent(j)},syncVoiceText:(j,C)=>{if(u&&(u.commands.setContent(j||{type:"doc",content:[]}),C)){u.commands.focus("end");const V=u.state.doc.textContent.trim().length>0;u.commands.insertContent({type:"text",text:V?" "+C:C})}},restoreContent:j=>{u&&u.commands.setContent(j||{type:"doc",content:[]})}}),m=[u],e[0]=u,e[1]=f,e[2]=m):(f=e[1],m=e[2]),k.useImperativeHandle(l??null,f,m),!u)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let x;e[3]!==c||e[4]!==p||e[5]!==g?(x=te("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",c,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",p,g),e[3]=c,e[4]=p,e[5]=g,e[6]=x):x=e[6];let v;e[7]!==u||e[8]!==x?(v=i.jsx(bm,{editor:u,className:x}),e[7]=u,e[8]=x,e[9]=v):v=e[9];const _=n??null;let b;e[10]!==u||e[11]!==_?(b=i.jsx(k.Suspense,{fallback:null,children:i.jsx(XL,{editor:u,virtualMcpId:_})}),e[10]=u,e[11]=_,e[12]=b):b=e[12];const y=n??null;let L;e[13]!==u||e[14]!==y?(L=i.jsx(k.Suspense,{fallback:null,children:i.jsx(GL,{editor:u,virtualMcpId:y})}),e[13]=u,e[14]=y,e[15]=L):L=e[15];let w;e[16]!==d||e[17]!==u||e[18]!==a||e[19]!==o||e[20]!==h?(w=h&&o&&!d?i.jsx(M8,{editor:u,selectedModel:o,onUnsupportedFile:a}):null,e[16]=d,e[17]=u,e[18]=a,e[19]=o,e[20]=h,e[21]=w):w=e[21];let S;return e[22]!==b||e[23]!==L||e[24]!==w||e[25]!==v?(S=i.jsxs(i.Fragment,{children:[v,b,L,w]}),e[22]=b,e[23]=L,e[24]=w,e[25]=v,e[26]=S):S=e[26],S}function xp(t){const e=M.c(3),[s]=vr();let n;return e[0]!==s.enableSounds||e[1]!==t?(n=()=>{s.enableSounds&&Wb(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=n):n=e[2],n}const t7={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},s7=nv.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),n7=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function i7(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center -space-x-1.5",children:n7.map(r7)}),t[0]=e):e=t[0],e}function r7(t){return i.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function o7({disabled:t,onOpenConnections:e,virtualMcpId:s,selectedModel:n,isStreaming:r,onUnsupportedFile:o}){const[a,l]=k.useState(!1),c=xp(t7),{org:d}=Ee(),{editor:h}=Fd(),u=k.useRef(null),f=ql(n),m=()=>{!f||r||(l(!1),u.current?.click())},p=async H=>{const Z=H.target.files;if(!Z||Z.length===0||!h)return;const K=Array.from(Z),{from:Y}=h.state.selection;try{for(const F of K)await w9(h,n??null,F,Y,o)}finally{u.current&&(u.current.value="")}},g=ut({connectionId:s,orgId:d.id,orgSlug:d.slug}),x=it.virtualMcpPrompts(s,d.id),{data:v,isLoading:_}=Ut({queryKey:x,queryFn:()=>j0(g),staleTime:6e4,enabled:a&&!!g}),b=v?.prompts??[],[y,L]=k.useState(null),{chatMode:w,setChatMode:S}=Vs(),[j,C]=vr(),N=(no.find(H=>H.value===j.toolApprovalLevel)??no[0]).short,T=H=>{const Z=no.find(K=>K.value===H);if(Z){if(Z.value===j.toolApprovalLevel){l(!1);return}c(),Ne("chat_approval_level_changed",{from_level:j.toolApprovalLevel,to_level:Z.value,source:"tools_popover"}),C({...j,toolApprovalLevel:Z.value}),l(!1)}},A=w==="plan",E=()=>{c();const H=A?"default":"plan";Ne("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},R=()=>{e(),l(!1)},D=async(H,Z)=>{if(!h||!g)return;const K=mn(H._meta),Y={from:h.state.selection.from,to:h.state.selection.to};try{const F=await Yo(g,H.name,Z);ar(h,Y,{id:H.name,name:yr(H.name,K),metadata:F.messages,char:"/",kind:"prompt",args:Z})}catch{de.error("Failed to load prompt. Please try again.")}},P=async H=>{l(!1);const Z=!!(H.arguments&&H.arguments.length>0);if(Ne("chat_prompt_inserted",{prompt_name:H.name,with_arguments:Z}),Z){L(H);return}await D(H)},I=async H=>{y&&(await D(y,H),L(null))},O=()=>{c();const H=w==="gen-image"?"default":"gen-image";Ne("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},B=()=>{c();const H=w==="web-search"?"default":"web-search";Ne("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},z=()=>{c();const H=w==="deep-research"?"default":"deep-research";Ne("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},$=w==="gen-image",U=w==="web-search",W=w==="deep-research",X=i.jsx("input",{ref:u,type:"file",multiple:!0,accept:xb(n??null),className:"hidden",onChange:p,disabled:r});return i.jsxs(i.Fragment,{children:[X,i.jsxs(as,{open:a,onOpenChange:H=>{H&&!a&&Ne("chat_tools_popover_opened",{chat_mode:w}),l(H)},children:[i.jsx(ls,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"ghost",size:"default",disabled:t,title:"Tools","aria-label":"Tools",className:te("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[i.jsx(Vm,{size:14}),i.jsx("span",{className:te("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),children:"Tools"})]})}),i.jsxs(cs,{align:"start",className:"w-52 p-1.5 space-y-1",children:[f?i.jsxs(Ge,{onClick:m,disabled:r,children:[i.jsx(kt,{size:16}),i.jsx("span",{className:"flex-1",children:"Add file"})]}):i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsxs(Ge,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:H=>H.preventDefault(),children:[i.jsx(kt,{size:16}),i.jsx("span",{className:"flex-1",children:"Add file"})]})}),i.jsx(De,{side:"right",children:"The selected model does not support reading files or images."})]}),i.jsxs(Ge,{onClick:E,className:te(A&&"text-special"),children:[i.jsx(lr,{size:16,className:te(A&&"text-special")}),i.jsx("span",{className:"flex-1",children:"Plan mode"}),i.jsx("span",{className:te("text-xs text-muted-foreground",A&&"text-special font-medium"),children:s7})]}),i.jsxs(Ge,{onClick:O,className:te($&&"text-special"),children:[i.jsx(An,{size:16,className:te($&&"text-special")}),i.jsx("span",{className:"flex-1",children:"Create image"}),$&&i.jsx("span",{className:"text-xs text-special font-medium",children:"On"})]}),i.jsxs(Ge,{onClick:B,className:te(U&&"text-special"),children:[i.jsx(pn,{size:16,className:te(U&&"text-special")}),i.jsx("span",{className:"flex-1",children:"Web search"}),U&&i.jsx("span",{className:"text-xs text-special font-medium",children:"On"})]}),i.jsxs(Ge,{onClick:z,className:te(W&&"text-special"),children:[i.jsx(Nm,{size:16,className:te(W&&"text-special")}),i.jsx("span",{className:"flex-1",children:"Deep research"}),W&&i.jsx("span",{className:"text-xs text-special font-medium",children:"On"})]}),i.jsxs(To,{children:[i.jsxs(Eo,{className:"gap-2",children:[i.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),i.jsx("span",{className:"flex-1",children:"Prompts"})]}),i.jsx(Ro,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:_?i.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[i.jsx(Xe,{size:14,className:"animate-spin"}),"Loading prompts…"]}):b.length===0?i.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):b.map(H=>i.jsxs(Ge,{onClick:()=>P(H),className:"flex flex-col items-start gap-0.5",children:[i.jsx("span",{className:"font-medium text-sm capitalize",children:H.title||Bd(H.name,mn(H._meta))}),H.description&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:H.description})]},H.name))})]}),i.jsxs(To,{children:[i.jsxs(Eo,{className:"gap-2",children:[i.jsx(Hl,{size:16}),i.jsx("span",{className:"flex-1",children:"Approval"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:N})]}),i.jsx(Ro,{className:"w-48 p-1.5",children:i.jsx(N0,{value:j.toolApprovalLevel,onValueChange:T,children:no.map(H=>i.jsx(sa,{value:H.value,children:H.label},H.value))})})]}),i.jsxs(Ge,{onClick:R,children:[i.jsx(Hm,{size:16}),i.jsx("span",{className:"flex-1",children:"Connections"}),i.jsx(k.Suspense,{children:i.jsx(i7,{})})]})]})]}),i.jsx(No,{prompt:y,setPrompt:L,onSubmit:I})]})}const a7=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function l7(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center -space-x-1",children:a7.map(c7)}),t[0]=e):e=t[0],e}function c7(t){return i.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function d7(t){const e=M.c(6),{onClick:s}=t;let n,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=te("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=i.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=i.jsx(l7,{}),a=i.jsx(vn,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=n,e[1]=r,e[2]=o,e[3]=a):(n=e[0],r=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=i.jsxs("button",{type:"button",onClick:s,className:n,children:[r,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const oo=48;function u7(){const t=M.c(9),[e,s]=k.useState("idle"),[n,r]=k.useState(""),[o,a]=k.useState(""),[l,c]=k.useState(m7),d=k.useRef(null),h=k.useRef(null),u=k.useRef(null),f=k.useRef(null),m=k.useRef(0),p=k.useRef(!1),g=k.useRef(""),x=k.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let _;t[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),h.current?.close().catch(f7),f.current?.getTracks().forEach(h7),u.current=null,h.current=null,f.current=null},t[0]=_):_=t[0];const b=_;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const N=T=>{f.current=T;const A=new AudioContext;h.current=A;const E=A.createMediaStreamSource(T),R=A.createAnalyser();R.fftSize=128,R.smoothingTimeConstant=.8,E.connect(R),u.current=R;const D=new Uint8Array(R.frequencyBinCount),P=()=>{if(!u.current)return;u.current.getByteFrequencyData(D);const I=[];for(let O=0;O<oo;O++){const B=Math.floor(O/oo*D.length);I.push(Math.max(.04,(D[B]??0)/255))}c(I),m.current=requestAnimationFrame(P)};P()};y=async()=>{const T=window.SpeechRecognition||window.webkitSpeechRecognition;if(!T)return s("unsupported"),"unsupported";let A;try{A=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{return s("permission-denied"),"permission-denied"}r(""),a(""),x.current="",g.current="",p.current=!0,s("recording"),N(A);const E=new T;d.current=E,E.interimResults=!0,E.continuous=!0,E.lang=navigator.language||"en-US",E.onresult=R=>{let D="",P="";for(let I=R.resultIndex;I<R.results.length;I++){const O=R.results[I],B=O?.[0]?.transcript??"";O?.isFinal?P=P+B:D=D+B}P&&(g.current=g.current+P,r(g.current)),x.current=D,a(D)},E.onend=()=>{if(p.current)try{E.start()}catch{}};try{E.start()}catch{return p.current=!1,d.current=null,b(),s("idle"),"idle"}return"recording"},t[1]=y}else y=t[1];const L=y;let w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(oo).fill(.05)),a("");const N=(g.current+(x.current?" "+x.current:"")).trim();return r(""),g.current="",x.current="",N},t[2]=w):w=t[2];const S=w;let j;t[3]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),r(""),a(""),c(Array(oo).fill(.05)),g.current="",x.current=""},t[3]=j):j=t[3];const C=j;let V;return t[4]!==o||t[5]!==e||t[6]!==n||t[7]!==l?(V={status:e,transcript:n,interimTranscript:o,waveformData:l,isSupported:v,startRecording:L,stopRecording:S,cancelRecording:C},t[4]=o,t[5]=e,t[6]=n,t[7]=l,t[8]=V):V=t[8],V}function h7(t){return t.stop()}function f7(){}function m7(){return Array(oo).fill(.05)}function p7(t){const e=M.c(4),{data:s}=t;let n;e[0]!==s?(n=s.map(g7),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:n}),e[2]=n,e[3]=r):r=e[3],r}function g7(t,e){return i.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}function x7({messageCount:t,showConnectionsBanner:e}){return t>0||e}function v7(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function b7(t){const e=M.c(3),{message:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Od,{size:14,className:"shrink-0"}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n,i.jsx("span",{className:"text-sm",children:s})]}),e[1]=s,e[2]=r):r=e[2],r}function _7(t,e,s){const n=M.c(6),{editor:r}=Fd(),[o,a]=k.useState(!1),l=k.useRef(0);let c,d;return n[0]!==s||n[1]!==r||n[2]!==e||n[3]!==t?(c=()=>{const h=p=>{p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),l.current=l.current+1,a(!0))},u=p=>{p.preventDefault(),l.current=Math.max(0,l.current-1),l.current===0&&a(!1)},f=y7,m=p=>{if(p.preventDefault(),l.current=0,a(!1),s||!r||!t||!ql(t))return;const g=p.dataTransfer?.files;if(!g||g.length===0)return;const{from:x}=r.state.selection;for(const v of Array.from(g))w9(r,t,v,x,e)};return window.addEventListener("dragenter",h),window.addEventListener("dragleave",u),window.addEventListener("dragover",f),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",h),window.removeEventListener("dragleave",u),window.removeEventListener("dragover",f),window.removeEventListener("drop",m)}},d=[r,t,e,s],n[0]=s,n[1]=r,n[2]=e,n[3]=t,n[4]=c,n[5]=d):(c=n[4],d=n[5]),k.useEffect(c,d),o}function y7(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function L7(t){const e=M.c(11),{selectedModel:s,onUnsupportedFile:n,disabled:r}=t,o=_7(s,n,r);let a;e[0]!==s?(a=ql(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o?"opacity-100":"opacity-0 pointer-events-none",d=l?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let h;e[2]!==c||e[3]!==d?(h=te("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==s||e[6]!==l?(u=l?i.jsxs(i.Fragment,{children:[i.jsx(Pi,{size:24}),i.jsxs("span",{className:"text-sm font-medium",children:["Drop ",Wm(s)," here"]})]}):i.jsxs(i.Fragment,{children:[i.jsx(Od,{size:24}),i.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=l,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=i.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}function S7(){const t=M.c(6),e=yt(),{org:s,locator:n}=Ee(),{create:r}=Ul();let o;return t[0]!==r||t[1]!==n||t[2]!==e||t[3]!==s.id||t[4]!==s.slug?(o=async a=>{const{tiptapDoc:l,virtualMcp:c}=a,d=crypto.randomUUID(),h=c?.id??qo(s.id).id;Sm(sessionStorage,n,d,{tiptapDoc:l});try{await r({id:d,virtual_mcp_id:h})}catch{}const u={virtualmcpid:h,autosend:ov};e({to:"/$org/$taskId",params:{org:s.slug,taskId:d},search:u})},t[0]=r,t[1]=n,t[2]=e,t[3]=s.id,t[4]=s.slug,t[5]=o):o=t[5],o}function w7({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=$d(),n=Ti(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,l=s?.stop??(()=>{}),c=n?.taskId??"",d=c||mv,h=S7(),{selectedModel:u,selectedVirtualMcp:f,isModelsLoading:m,tiptapDocRef:p,imageModel:g,webSearchModel:x,deepResearchModel:v,chatMode:_,setChatMode:b}=Vs(),{data:y}=Ai.useSession(),L=y?.user?.id,{org:w,locator:S}=Ee(),j=qo(w.id).id,C=fs(f?.id??j),V=xp(qb),[N,T]=k.useState(!1),{unsupportedFile:A,onUnsupportedFile:E,clearUnsupportedFile:R}=U8(),D=u7(),P=k.useRef(void 0),I=async()=>{P.current=$;const oe=await D.startRecording();Ne("chat_voice_started",{thread_id:c,outcome:oe==="recording"?"started":oe==="unsupported"?"unsupported":oe==="permission-denied"?"permission_denied":"unknown"})},O=()=>{Ne("chat_voice_confirmed",{thread_id:c});const oe=D.stopRecording();K.current?.syncVoiceText(P.current,oe),K.current?.focus()},B=()=>{Ne("chat_voice_cancelled",{thread_id:c}),D.cancelRecording(),K.current?.restoreContent(P.current)};k.useEffect(()=>{if(D.status!=="recording")return;const oe=(D.transcript+(D.interimTranscript?" "+D.interimTranscript:"")).trim();K.current?.syncVoiceText(P.current,oe)},[D.transcript,D.interimTranscript,D.status]);const z=n?.activeTask??null,[$,U]=k.useState(()=>$u(sessionStorage,S,d)??void 0),W=oe=>{U(oe),p.current=oe,fv(sessionStorage,S,d,oe,{onQuotaExceeded:({docSizeBytes:me})=>{Ne("chat_draft_quota_exceeded",{thread_id:c||null,doc_size_bytes:me}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},X=k.useRef(c);if(X.current!==c){X.current=c;const oe=$u(sessionStorage,S,d)??void 0;U(oe),p.current=oe}const Z=[...r].reverse().find(oe=>oe.role==="assistant")?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow,K=k.useRef(null),Y=_==="plan";k.useEffect(()=>{const oe=me=>{ym(me)&&me.code==="KeyL"&&(me.preventDefault(),me.shiftKey&&b(_==="plan"?"default":"plan"),K.current?.focus())};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[_,b]);const F=dm(r),J=[...r].reverse().find(oe=>oe.role==="assistant"&&oe.metadata?.usage)?.metadata?.usage?.contextTokens??0,ee=!m&&!uv($),q=v7({hasDraft:ee,isStreaming:o,isRunInProgress:a}),se=q==="send",ne=q==="stop",le=x7({messageCount:r.length,showConnectionsBanner:e}),G=oe=>{if(oe?.preventDefault(),q==="send"&&$){if(Ne("chat_message_sent",{thread_id:c||null,mode:_,model_id:u?.modelId??null,model_provider:u?.providerId??null,virtual_mcp_id:f?.id??null,submission:oe?"button_or_enter":"programmatic"}),s){if(s.isSendInFlight()){de.info("Still sending your previous message — try again in a moment");return}s.sendMessage($)}else h({tiptapDoc:$,virtualMcp:f});hv(sessionStorage,S,d),W(void 0)}else q==="stop"&&(Ne("chat_message_stopped",{thread_id:c}),l())};return L&&z?.created_by&&z.created_by!==L?i.jsx(b7,{message:"Read only - you're viewing someone else's chat"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col w-full justify-end",children:i.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&i.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),s&&n&&i.jsx(Ql,{}),s&&n&&c?i.jsx(ly,{taskId:c}):null,i.jsx(pp,{tiptapDoc:$,setTiptapDoc:W,disabled:D.status==="recording",enterToSubmit:!0,onSubmit:G,children:i.jsxs("form",{onSubmit:G,className:te("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[i.jsx(L7,{selectedModel:u,onUnsupportedFile:E,disabled:D.status==="recording"}),i.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:i.jsx(gp,{ref:K,disabled:D.status==="recording",virtualMcpId:f?.id??j,showFileUploader:!0,selectedModel:u,onUnsupportedFile:E})}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:D.status==="recording"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[i.jsx(p7,{data:D.waveformData.slice(0,28)}),i.jsx("button",{type:"button",onClick:B,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:i.jsx(js,{size:16})}),i.jsx("button",{type:"button",onClick:O,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:i.jsx(Ot,{size:16})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[i.jsx(o7,{disabled:!1,onOpenConnections:()=>{Ne("connections_dialog_opened",{source:"tools_popover",mode:"add"}),T(!0)},virtualMcpId:f?.id??j,selectedModel:u,isStreaming:o,onUnsupportedFile:E}),Y&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ne("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Plan mode","aria-label":"Plan mode",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group min-w-0 shrink animate-in fade-in duration-200",children:[i.jsx(lr,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100",children:"Plan mode"}),i.jsx(js,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="gen-image"&&g&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ne("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Create image","aria-label":"Create image",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[i.jsx(An,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Create image"}),i.jsx(js,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="web-search"&&x&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ne("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Web search","aria-label":"Web search",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[i.jsx(pn,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Web search"}),i.jsx(js,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="deep-research"&&v&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ne("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Deep research","aria-label":"Deep research",className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[i.jsx(Nm,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Deep research"}),i.jsx(js,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),Z&&J>0&&i.jsx(_x,{usage:F,totalTokens:J,contextWindow:Z,onOpenContextPanel:t})]}),i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[le&&i.jsx(ep,{virtualMcp:C,currentBranch:n?.currentBranch??null}),i.jsx(O8,{}),D.isSupported&&i.jsx(re,{type:"button",onClick:I,disabled:!1,variant:"ghost",size:"icon",className:te("size-8 rounded-lg transition-colors",D.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:D.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input","aria-label":D.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:i.jsx(kv,{size:18})}),i.jsx(re,{type:ne?"button":"submit",onClick:oe=>{ne&&(oe.preventDefault(),oe.stopPropagation(),l())},variant:se||ne?"default":"ghost",size:"icon",disabled:!se&&!ne,className:te("size-8 rounded-lg transition-all",!se&&!ne&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:q==="stop"?o?"Stop generating":"Cancel run":"Send message (Enter)","aria-label":q==="stop"?o?"Stop generating":"Cancel run":"Send message",children:ne?i.jsx(Vv,{size:20}):i.jsx(Md,{size:20})})]})]})})]})},c),e&&i.jsx(d7,{onClick:()=>{Ne("connections_banner_clicked",{source:"home_chat_input"}),Ne("connections_dialog_opened",{source:"home_banner",mode:"add"}),T(!0)}})]})}),i.jsx(i9,{mode:"browse",open:N,onOpenChange:T,defaultTab:"all"}),i.jsx(z8,{info:A,onClose:R})]})}function j7(){const t=M.c(7),e=yt(),s=$d()?.messages??[],n=Ti()?.taskId??null;let r;t[0]!==s?(r=s.some(k7),t[0]=s,t[1]=r):r=t[1];const o=r,a=k.useRef(null);let l,c;t[2]!==e||t[3]!==o||t[4]!==n?(l=()=>{!o||!n||a.current===n||(a.current=n,e({to:".",search:C7,replace:!0}))},c=[o,n,e],t[2]=e,t[3]=o,t[4]=n,t[5]=l,t[6]=c):(l=t[5],c=t[6]),k.useEffect(l,c)}function C7(t){return{...t,main:"preview"}}function k7(t){return t.parts?.some(V7)}function V7(t){const e=t;return e.type==="tool-load_repo"&&e.state==="output-available"&&e.output?.success===!0}const N7={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function vp(t){return`deco-credits-empty-dismissed:${t}`}function A7(t){try{return localStorage.getItem(vp(t))==="1"}catch{return!1}}function T7(){const t=M.c(47),{org:e}=Ee(),s=yt(),{decoKeyId:n}=s9(),r=Ms(),[o,a]=k.useState(!0),[l,c]=k.useState(""),[d,h]=k.useState(!1),[u,f]=k.useState("usd"),m=u==="brl"?"R$":"$";let p;t[0]!==e.id?(p=()=>{Ne("credits_empty_state_dismissed",{organization_id:e.id}),a(!1);try{localStorage.setItem(vp(e.id),"1")}catch{}},t[0]=e.id,t[1]=p):p=t[1];const g=p;let x,v;t[2]!==o||t[3]!==e.id?(x=()=>{o&&Ne("credits_empty_state_shown",{organization_id:e.id})},v=[o,e.id],t[2]=o,t[3]=e.id,t[4]=x,t[5]=v):(x=t[4],v=t[5]),k.useEffect(x,v);let _;t[6]!==u||t[7]!==r?(_=async z=>{const{url:$}=await r.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:z,currency:u});return $},t[6]=u,t[7]=r,t[8]=_):_=t[8];let b;t[9]!==g?(b=z=>{z&&window.open(z,"_blank","noopener,noreferrer"),g()},t[9]=g,t[10]=b):b=t[10];let y;t[11]!==_||t[12]!==b?(y={mutationFn:_,onSuccess:b,onError:R7},t[11]=_,t[12]=b,t[13]=y):y=t[13];const{mutate:L,isPending:w}=Gs(y),S=parseFloat(l),j=!isNaN(S)&&S>=1;if(!o)return null;let C;t[14]!==g?(C=z=>!z&&g(),t[14]=g,t[15]=C):C=t[15];let V;t[16]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-warning/8 to-transparent pointer-events-none rounded-t-lg"}),t[16]=V):V=t[16];let N;t[17]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-warning/10 border border-warning/20 mx-auto",children:i.jsx(Am,{size:20,className:"text-warning"})}),t[17]=N):N=t[17];let T;t[18]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[V,i.jsxs(us,{className:"relative gap-3",children:[N,i.jsxs("div",{className:"text-center",children:[i.jsx(hs,{className:"text-lg font-semibold",children:"This workspace has no credits"}),i.jsx(si,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[18]=T):T=t[18];let A;t[19]!==u||t[20]!==m||t[21]!==l||t[22]!==S||t[23]!==n||t[24]!==j||t[25]!==w||t[26]!==d||t[27]!==L?(A=n&&i.jsxs("div",{className:"px-6 pb-5",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(t9,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:z=>{z&&f(z)},children:[i.jsx(Ao,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(Ao,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:N7[u].map(z=>{const{dollars:$,label:U}=z;return i.jsxs("button",{type:"button",disabled:w,onClick:()=>{Ne("credits_topup_clicked",{amount_cents:$*100,currency:u,tier_label:U,source:"empty_state"}),L($*100)},className:te("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,$]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:U})]},$)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(tt,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:z=>c(z.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(re,{className:"h-10",disabled:!j||w,onClick:()=>{Ne("credits_topup_clicked",{amount_cents:Math.round(S*100),currency:u,tier_label:"custom",source:"empty_state"}),L(Math.round(S*100))},children:w?"Opening...":"Add"})]}):i.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[19]=u,t[20]=m,t[21]=l,t[22]=S,t[23]=n,t[24]=j,t[25]=w,t[26]=d,t[27]=L,t[28]=A):A=t[28];let E;t[29]!==g||t[30]!==s||t[31]!==e.slug?(E=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),g()},t[29]=g,t[30]=s,t[31]=e.slug,t[32]=E):E=t[32];let R;t[33]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(Sr,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[33]=R):R=t[33];let D;t[34]!==E?(D=i.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:E,children:["Use your own provider",R]}),t[34]=E,t[35]=D):D=t[35];let P;t[36]!==g?(P=i.jsx(re,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:g,children:"Skip for now"}),t[36]=g,t[37]=P):P=t[37];let I;t[38]!==D||t[39]!==P?(I=i.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[D,P]}),t[38]=D,t[39]=P,t[40]=I):I=t[40];let O;t[41]!==A||t[42]!==I?(O=i.jsxs(Zt,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:E7,children:[T,A,I]}),t[41]=A,t[42]=I,t[43]=O):O=t[43];let B;return t[44]!==O||t[45]!==C?(B=i.jsx(es,{open:!0,onOpenChange:C,children:O}),t[44]=O,t[45]=C,t[46]=B):B=t[46],B}function E7(t){return t.preventDefault()}function R7(t){de.error(`Top-up failed: ${t.message}`)}function P7(t){const e=M.c(6),{balanceDollars:s}=t;let n;e[0]!==s?(n=s.toFixed(2),e[0]=s,e[1]=n):n=e[1];const r=n;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=te("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-success/10 border border-success/20","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=i.jsx(Am,{size:13,className:"text-success"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==r?(l=i.jsxs("div",{className:o,children:[a,i.jsxs("span",{className:"text-xs font-medium text-success tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=l):l=e[5],l}function I7(){const t=M.c(8),{org:e}=Ee(),s=yt();let n;t[0]!==s||t[1]!==e.slug?(n=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=n):n=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=te("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-warning/10 border border-warning/20","hover:bg-warning/15","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=i.jsx(Sn,{size:13,className:"text-warning"}),a=i.jsx("span",{className:"text-xs font-medium text-warning",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let l;return t[6]!==n?(l=i.jsxs("button",{type:"button",onClick:n,className:r,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function D7(t){const e=M.c(11),{className:s}=t;let n;e[0]!==s?(n=te("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=n):n=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex items-center gap-3",children:[r,i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),i.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),i.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:i.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[i.jsx(xa,{align:"right",width:"w-3/4"}),i.jsx(xa,{align:"left",width:"w-full",lines:3}),i.jsx(xa,{align:"right",width:"w-2/3"}),i.jsx(xa,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:i.jsx("div",{className:"relative flex-1",children:i.jsxs("div",{className:"space-y-2 p-2",children:[i.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),i.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("div",{className:"flex items-center gap-1",children:i.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx("div",{className:"px-4 py-4",children:i.jsx("div",{className:"mx-auto w-full max-w-2xl",children:i.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,i.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),i.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=h):h=e[8];let u;return e[9]!==n?(u=i.jsxs("div",{className:n,children:[a,l,h]}),e[9]=n,e[10]=u):u=e[10],u}function xa(t){const e=M.c(22),{align:s,width:n,lines:r}=t,o=n===void 0?"w-full":n,a=r===void 0?1:r,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=te("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let h;e[2]!==d?(h=te("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=u):u=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=te("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=i.jsx("div",{className:"space-y-2",children:p.map((b,y)=>i.jsx("div",{className:te("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==g||e[14]!==m?(x=i.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==h?(v=i.jsxs("div",{className:h,children:[u,x]}),e[16]=x,e[17]=h,e[18]=v):v=e[18];let _;return e[19]!==v||e[20]!==c?(_=i.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=_):_=e[21],_}function O7(t){const e=M.c(7),{scrollRef:s,sentinelRef:n,hasMoreOlder:r,isFetchingOlder:o,fetchOlderMessages:a}=t;let l,c;e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n?(l=()=>{const d=n.current,h=s.current;if(!d||!h||!r)return;const u=new IntersectionObserver(async f=>{if(!f[0]?.isIntersecting||o||!r)return;const p=h.scrollHeight,g=h.scrollTop;await a(),requestAnimationFrame(()=>{const x=h.scrollHeight;h.scrollTop=g+(x-p)})},{root:h,rootMargin:"200px 0px 0px 0px"});return u.observe(d),()=>u.disconnect()},c=[s,n,r,o,a],e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=l,e[6]=c):(l=e[5],c=e[6]),k.useEffect(l,c)}function M7(t){const e=M.c(5),{className:s,children:n}=t;let r;e[0]!==s?(r=te("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==n||e[3]!==r?(o=i.jsx("div",{className:r,children:n}),e[2]=n,e[3]=r,e[4]=o):o=e[4],o}function $7(t){const e=M.c(5),{children:s,className:n}=t;let r;e[0]!==n?(r=te("flex-1 min-h-0 overflow-y-auto isolate",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=i.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function B7(t){const e=M.c(2),{children:s}=t;let n;return e[0]!==s?(n=i.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:s}),e[0]=s,e[1]=n):n=e[1],n}function z7(){const{messages:t,status:e,hasMoreOlder:s,isFetchingOlder:n,fetchOlderMessages:r}=Ys(),{taskId:o}=Qt();j7();const a=am(o??""),l=ux(a),c=l.size===0?t:t.filter(v=>!l.has(v.id)),d=yx(c),h=d.at(-1),f=d_()*X6+16,m=k.useRef(null),p=k.useRef(null);O7({scrollRef:m,sentinelRef:p,hasMoreOlder:s,isFetchingOlder:n,fetchOlderMessages:r});const g=Lx({initial:!1}),x=v=>{m.current=v,g.scrollRef(v)};return i.jsx(Sx,{messages:t,children:i.jsxs("div",{className:"relative h-full w-full min-w-0",children:[i.jsx("div",{ref:x,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:f},children:i.jsxs("div",{ref:g.contentRef,className:"overflow-x-clip",children:[i.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[i.jsx("div",{ref:p,"aria-hidden":!0,className:"h-px"}),n&&i.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:"Loading older messages…"}),d.slice(0,-1).map((v,_)=>i.jsx(Du,{pair:v,isLastPair:!1,status:_===d.length-1?e:void 0},`pair-${v.user?.id??v.assistant?.id}`))]}),h&&i.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:i.jsx(Du,{pair:h,isLastPair:!0,status:e},`pair-${h.user?.id??h.assistant?.id}`)})]})}),!g.isAtBottom&&i.jsx(re,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Jump to latest",className:"absolute left-1/2 z-50 -translate-x-1/2 rounded-full shadow-md animate-in fade-in duration-200 dark:bg-background dark:hover:bg-accent",style:{bottom:f+8},onClick:()=>{g.scrollToBottom()},children:i.jsx(rx,{size:14})})]})})}function F7(t){const e=M.c(5),{children:s,className:n}=t;let r;e[0]!==n?(r=te("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=i.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const bt=Object.assign(M7,{Main:$7,Messages:z7,EmptyState:B7,Footer:F7,Input:w7,Provider:dx,ActiveTaskProvider:cx,Skeleton:D7,IceBreakers:J6,NoAiProviderEmptyState:vb,CreditsEmptyState:T7,CreditsEyebrow:P7,NoCreditsEyebrow:I7,CreditsExhaustedBanner:O2});function U7(){const t=Zm(),{pendingAgentOption:e}=Vs(),s=tc();if(Ti()?.isThreadLocked)return!1;const r=e==="claude-code-desktop"&&s.claudeCode||e==="codex-desktop"&&s.codex;return t.length===0&&!r}function Kr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function zc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function H7(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function K7(t){const e=M.c(4),{items:s}=t;let n;e[0]!==s?(n=s.map(W7),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:n}),e[2]=n,e[3]=r):r=e[3],r}function W7(t){return i.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[i.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),i.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function q7(t){const e=M.c(30),{userTokens:s,assistantTokens:n,otherTokens:r}=t,o=s+n+r,a=o>0?s/o*100:0,l=o>0?n/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&i.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==l?(h=l>0&&i.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==c?(u=c>0&&i.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==h||e[8]!==u?(f=i.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,h,u]}),e[6]=d,e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=i.jsxs("div",{className:"flex items-center gap-1.5",children:[m,i.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=x):x=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let _;e[18]!==v?(_=i.jsxs("div",{className:"flex items-center gap-1.5",children:[x,i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=_):_=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==_||e[24]!==b||e[25]!==g?(y=i.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,_,b]}),e[23]=_,e[24]=b,e[25]=g,e[26]=y):y=e[26];let L;return e[27]!==y||e[28]!==f?(L=i.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=L):L=e[29],L}function G7(t){const e=M.c(11),{agentId:s,isError:n}=t,r=fs(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=i.jsx(on,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const c=n?"text-destructive":"text-foreground";let d;e[3]!==c?(d=te("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=i.jsx("span",{className:d,children:o}),e[5]=o,e[6]=d,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=i.jsxs(i.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function Y7(t){const e=M.c(5),{isError:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(on,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=n):n=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=te("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=i.jsxs(i.Fragment,{children:[n,i.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function J7(t){const e=M.c(18),{part:s}=t,n=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=i.jsx(Y7,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==o?(c=i.jsx(G7,{agentId:n,isError:o}),e[2]=n,e[3]=o,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==c?(d=i.jsx(k.Suspense,{fallback:l,children:c}),e[5]=l,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground/50",children:"·"}),i.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=i.jsx("span",{className:"ml-auto shrink-0",children:r?i.jsx(Xe,{size:12,className:"animate-spin text-muted-foreground"}):o?i.jsx(lb,{size:12,className:"text-destructive"}):a?i.jsx(Sn,{size:12,className:"text-warning"}):i.jsx(Yl,{size:12,className:"text-success"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=i.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,h,u]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function X7(t){const e=M.c(55),{onClose:s,back:n,className:r}=t,[o,a]=k.useState(null),{messages:l}=Ys(),{activeTask:c}=Qt(),{selectedModel:d,selectedVirtualMcp:h}=Vs();let u,f,m,p,g,x,v,_;if(e[0]!==c||e[1]!==n||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==d||e[7]!==h?.title){_=Symbol.for("react.early_return_sentinel");e:{const L=dm(l),w=[...l].reverse().find(lS),S=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,C=S?.contextTokens??0,V=j&&j>0?(C/j*100).toFixed(1):null,N=l;let T;e[16]!==N?(T=N.filter(aS).reduce(oS,0),e[16]=N,e[17]=T):T=e[17];const A=T,E=l;let R;e[18]!==E?(R=E.filter(rS).reduce(iS,0),e[18]=E,e[19]=R):R=e[19];const D=R,P=Math.max(0,L.totalTokens-A-D),I=l[0],O=l.at(-1),B=I?.metadata?.created_at??c?.created_at,z=O?.metadata?.created_at??c?.updated_at,$=l.filter(nS),U=l.flatMap(tS),W=d?.modelId?H7(d.modelId):"—",X=h?.title??"Super Agent",H=[{label:"Session",value:c?.title??"New chat"},{label:"Messages",value:$.length},{label:"Agent",value:X},{label:"Model",value:W},{label:"Context Limit",value:j?Kr(j):"—"},{label:"Session Tokens (billed)",value:L.totalTokens>0?Kr(L.totalTokens):"0"},{label:"Usage",value:V!==null?`${V}%`:"—"},{label:"Input Tokens",value:L.inputTokens>0?Kr(L.inputTokens):"0"},{label:"Output Tokens",value:L.outputTokens>0?Kr(L.outputTokens):"0"},{label:"Reasoning Tokens",value:L.reasoningTokens>0?Kr(L.reasoningTokens):"0"},{label:"Cost",value:L.cost>0?`$${L.cost<.001?L.cost.toFixed(6):L.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:zc(B)},{label:"Last Activity",value:zc(z)}];if(!c&&$.length===0){let F;e[20]!==r?(F=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=F):F=e[21];let Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(Q=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=Q):Q=e[22];let J;e[23]!==n?(J=n?i.jsx(Bu,{size:14,className:"text-muted-foreground"}):i.jsx(Tn,{size:14,className:"text-muted-foreground"}),e[23]=n,e[24]=J):J=e[24];let ee;e[25]!==s||e[26]!==J?(ee=i.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[Q,i.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:J})]}),e[25]=s,e[26]=J,e[27]=ee):ee=e[27];let q;e[28]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=q):q=e[28];let se;e[29]!==F||e[30]!==ee?(se=i.jsxs("div",{className:F,children:[ee,q]}),e[29]=F,e[30]=ee,e[31]=se):se=e[31],_=se;break e}e[32]!==r?(x=te("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=x):x=e[33];let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=Z):Z=e[34];let K;e[35]!==n?(K=n?i.jsx(Bu,{size:14}):i.jsx(Tn,{size:14}),e[35]=n,e[36]=K):K=e[36],e[37]!==s||e[38]!==K?(v=i.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Z,i.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:K})]}),e[37]=s,e[38]=K,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=U.length>0&&i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),i.jsx("div",{className:"flex flex-col gap-1",children:U.map(eS)})]}),m=i.jsx(K7,{items:H});let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=Y):Y=e[40],e[41]!==D||e[42]!==P||e[43]!==A?(p=i.jsxs("div",{className:"flex flex-col gap-3",children:[Y,i.jsx(q7,{userTokens:A,assistantTokens:D,otherTokens:P})]}),e[41]=D,e[42]=P,e[43]=A,e[44]=p):p=e[44],g=$.length>0&&i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),i.jsx("div",{className:"flex flex-col gap-1",children:$.map(F=>{const Q=F.metadata?.created_at,J=o?.id===F.id;return i.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>a(J?null:F),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:te("shrink-0 font-medium",F.role==="user"?"text-chart-1":"text-chart-2"),children:F.role}),i.jsx("span",{className:"text-muted-foreground",children:"•"}),i.jsx("span",{className:"truncate text-muted-foreground font-mono",children:F.id})]}),Q&&i.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:zc(Q)})]}),J&&i.jsxs(i.Fragment,{children:[F.role==="assistant"&&(()=>{const ee=F.metadata?._request;if(!ee)return null;const q=ee.systemSections??[],se=Math.max(1,...q.map(Z7)),ne=q.reduce(Q7,0);return i.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-medium text-foreground",children:"Request"}),i.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[ee.activeTools??0," / ",ee.tools??0," ","tools active"]})]}),q.length>0&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",i.jsxs("span",{className:"tabular-nums",children:["~",Math.round(ne/4).toLocaleString()," ","tok"]})]}),q.map((le,G)=>{const oe=le.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${G}`,me=le.chars/se*100,ue=Math.round(le.chars/4);return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"font-mono text-foreground truncate",children:oe}),i.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",ue.toLocaleString()," tok"]})]}),i.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${me}%`}})})]},G)})]})]})})(),i.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(F,null,2)})]})]},F.id)})})]})}e[0]=c,e[1]=n,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=d,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=_}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],_=e[15];if(_!==Symbol.for("react.early_return_sentinel"))return _;let b;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(b=i.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=b):b=e[50];let y;return e[51]!==x||e[52]!==v||e[53]!==b?(y=i.jsxs("div",{className:x,children:[v,b]}),e[51]=x,e[52]=v,e[53]=b,e[54]=y):y=e[54],y}function Q7(t,e){return t+e.chars}function Z7(t){return t.chars}function eS(t,e){return i.jsx(J7,{part:t},e)}function tS(t){return(t.parts??[]).filter(sS)}function sS(t){return t.type==="tool-subtask"}function nS(t){return t.role!=="system"}function iS(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function rS(t){return t.role==="assistant"}function oS(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function aS(t){return t.role==="user"}function lS(t){return t.role==="assistant"&&t.metadata?.usage}function cS(t){const e=M.c(27),{onOpenContextPanel:s}=t,{org:n}=Ee(),{selectedVirtualMcp:r}=Vs(),{currentBranch:o}=Qt();let a;e[0]!==n.id?(a=qo(n.id),e[0]=n.id,e[1]=a):a=e[1];const c=r??a,d=fs(c.id),h=d??c,u=h.title??"Super Agent",f=h.icon??null,m=h.description??null;let p;e[2]!==f||e[3]!==u?(p=i.jsx(Yn,{icon:f,name:u,size:"lg"}),e[2]=f,e[3]=u,e[4]=p):p=e[4];let g;e[5]!==u?(g=i.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:u}),e[5]=u,e[6]=g):g=e[6];let x;e[7]!==m?(x=m?i.jsx("p",{className:"text-sm text-muted-foreground max-w-md text-balance",children:m}):null,e[7]=m,e[8]=x):x=e[8];let v;e[9]!==g||e[10]!==x?(v=i.jsxs("div",{className:"space-y-1.5",children:[g,x]}),e[9]=g,e[10]=x,e[11]=v):v=e[11];let _;e[12]!==p||e[13]!==v?(_=i.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center gap-4 px-6 text-center overflow-hidden",children:[p,v]}),e[12]=p,e[13]=v,e[14]=_):_=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(bt.IceBreakers,{className:"pb-3"}),e[15]=b):b=e[15];let y;e[16]!==o||e[17]!==d?(y=i.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom pb-1 flex justify-start gap-1",children:i.jsx(ep,{virtualMcp:d,currentBranch:o,showRuntimeLabel:!0})}),e[16]=o,e[17]=d,e[18]=y):y=e[18];let L;e[19]!==s?(L=i.jsx(bt.Input,{onOpenContextPanel:s}),e[19]=s,e[20]=L):L=e[20];let w;e[21]!==y||e[22]!==L?(w=i.jsxs(bt.Footer,{children:[b,y,L]}),e[21]=y,e[22]=L,e[23]=w):w=e[23];let S;return e[24]!==w||e[25]!==_?(S=i.jsxs(i.Fragment,{children:[_,w]}),e[24]=w,e[25]=_,e[26]=S):S=e[26],S}function Lh(t){const e=M.c(17),{outputs:s,collapsed:n,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=te(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=c):c=e[2];const d=n&&"-rotate-90";let h;e[3]!==d?(h=te("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=i.jsx(ts,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=i.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==s?(m=!n&&i.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(dS)}),e[10]=n,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=i.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function dS(t){return i.jsx(jx,{file:t},t.key)}function uS(){const t=M.c(13),e=Ti()?.taskId??null,s=wx();let n;t[0]!==s?(n={enabled:s},t[0]=s,t[1]=n):n=t[1];const{data:r}=um(e,n),[o,a]=k.useState(!1),[l,c]=k.useState(!0);if(!e||!r||r.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(fS),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==r?(h=i.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:i.jsx(Lh,{variant:"card",outputs:r,collapsed:o,onToggle:d})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(hS),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=i.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:i.jsx(Lh,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=i.jsxs(i.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function hS(t){return!t}function fS(t){return!t}function mS(){const t=M.c(27),{org:e}=Ee(),{isChatEmpty:s}=Ys(),{openTab:n}=Jo(),[r,o]=k.useState("chat"),a=s9();if(U7()){let y;return t[0]!==n?(y=i.jsx(bt,{className:"animate-in fade-in-0 duration-200",children:i.jsx(bt.Main,{className:"flex flex-col items-center",children:i.jsx(bt.EmptyState,{children:i.jsx(bt.NoAiProviderEmptyState,{onLocalRuntimePicked:()=>n("overview")})})})}),t[0]=n,t[1]=y):y=t[1],y}let c;t[2]!==a.hasDecoKey||t[3]!==a.hasOnlyDecoProvider||t[4]!==a.isLoading||t[5]!==a.isZeroBalance||t[6]!==s||t[7]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&s&&!A7(e.id),t[2]=a.hasDecoKey,t[3]=a.hasOnlyDecoProvider,t[4]=a.isLoading,t[5]=a.isZeroBalance,t[6]=s,t[7]=e,t[8]=c):c=t[8];const d=c;let h;t[9]!==d?(h=d&&i.jsx(bt.CreditsEmptyState,{}),t[9]=d,t[10]=h):h=t[10];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;t[11]!==u?(f=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[11]=u,t[12]=f):f=t[12];let m;t[13]!==s?(m=s?i.jsx(cS,{onOpenContextPanel:()=>o("context")}):i.jsxs(i.Fragment,{children:[i.jsxs(bt.Main,{className:"relative flex flex-col overflow-hidden @container",children:[i.jsx(uS,{}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(bt.Messages,{})})]}),i.jsx(bt.Footer,{children:i.jsx(bt.Input,{onOpenContextPanel:()=>o("context")})})]}),t[13]=s,t[14]=m):m=t[14];let p;t[15]!==f||t[16]!==m?(p=i.jsx("div",{className:f,children:m}),t[15]=f,t[16]=m,t[17]=p):p=t[17];const g=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let x;t[18]!==g?(x=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",g),t[18]=g,t[19]=x):x=t[19];let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx(X7,{back:!0,onClose:()=>o("chat")}),t[20]=v):v=t[20];let _;t[21]!==x?(_=i.jsx("div",{className:x,children:v}),t[21]=x,t[22]=_):_=t[22];let b;return t[23]!==h||t[24]!==p||t[25]!==_?(b=i.jsxs(bt,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,p,_]}),t[23]=h,t[24]=p,t[25]=_,t[26]=b):b=t[26],b}function bp(){const t=M.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(bt.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(vs,{fallback:e,children:i.jsx(k.Suspense,{fallback:i.jsx(bt.Skeleton,{}),children:i.jsx(mS,{})})}),t[1]=s):s=t[1],s}function Sh(t,e){return+(e.sidePanel!==null)+Number(e.mainOpen)<=1?!1:t==="side"?e.sidePanel!==null:e.mainOpen}function pS(t){return t.sidePanel!==null||t.mainOpen?t:{...t,sidePanel:"chat"}}function gS(t){const e=t.mainParamValue===0?"0":t.mainParamValue,s=t.entityMetadata?.defaultMainView??null,n=s==null||s.type==="chat",r=t.mainParamPresent?e!=="0":!n,o=n||t.entityMetadata?.chatDefaultOpen?"chat":null,a=t.sidePanelParamPresent?t.sidePanelParamValue===0?null:t.sidePanelParamValue??null:o;return pS({sidePanel:a,mainOpen:r})}function Fc(t,e){switch(t.type){case"toggleSidePanel":return e.sidePanel===t.sidePanel?Sh("side",e)?{sidepanel:0}:null:{sidepanel:t.sidePanel};case"toggleMain":return e.mainOpen?Sh("main",e)?{main:0}:null:{main:t.openMainValue};case"openSidePanel":return e.sidePanel===t.sidePanel?null:{sidepanel:t.sidePanel}}}function xS(t){return t.sidePanel!==null&&t.mainOpen?{side:33,main:67}:t.sidePanel!==null?{side:100,main:0}:t.mainOpen?{side:0,main:100}:{side:0,main:0}}function vS(t,e){return t==="main"?{sidepanel:0,main:e}:{sidepanel:t,main:0}}function bS(t,e){const s=yt(),n=_r({strict:!1}),r=zl({strict:!1}),{create:o}=Ul(),{locator:a}=Ee(),{virtualMcpId:l,orgSlug:c,isAgentRoute:d}=e,h=n.main===0?"0":n.main,{sidePanel:u,mainOpen:f}=gS({entityMetadata:t,mainParamPresent:n.main!==void 0,mainParamValue:h,sidePanelParamPresent:n.sidepanel!==void 0,sidePanelParamValue:n.sidepanel}),m={sidePanel:u,mainOpen:f},p=k.useRef(crypto.randomUUID()),g=r.taskId??p.current,x="/$org/$taskId",v=N=>({org:c,taskId:N}),_=d?{virtualmcpid:l}:{},b=(N,T)=>{s({to:x,params:v(g),search:A=>({...A,...N}),replace:T?.replace??!1})};return{taskId:g,sidePanel:u,mainOpen:f,mainParam:h,setTaskId:(N,T)=>{s({to:x,params:v(N),search:A=>{const E={};return T?E.virtualmcpid=T:d&&(E.virtualmcpid=l),E}})},toggleMain:()=>{const N=Fc({type:"toggleMain",openMainValue:il(t)},m);N&&b(N,{replace:!0})},toggleSidePanel:N=>{const T=Fc({type:"toggleSidePanel",sidePanel:N},m);T&&b(T,{replace:!0})},setMobileSurface:N=>{const T=h&&h!=="0"?h:il(t);b(vS(N,T),{replace:!0})},openSidePanel:N=>{const T=Fc({type:"openSidePanel",sidePanel:N},m);T&&b(T,{replace:!0})},createNewTask:async()=>{const N=crypto.randomUUID(),T=iv(c,a,g);try{await o({id:N,virtual_mcp_id:l,...T?{branch:T}:{}})}catch{}s({to:x,params:v(N),search:A=>({..._,sidepanel:"chat"})})},openTab:N=>{b({main:N==="0"?0:N},{replace:!0})}}}function wh(t,e){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function _S(t,e){const s=M.c(8);let n;s[0]!==e?(n=c=>wh(c,e),s[0]=e,s[1]=n):n=s[1];const[r,o]=q5(t,n);let a;s[2]!==e||s[3]!==r?(a=wh(r,e),s[2]=e,s[3]=r,s[4]=a):a=s[4];let l;return s[5]!==o||s[6]!==a?(l=[a,o],s[5]=o,s[6]=a,s[7]=l):l=s[7],l}const yS=33;function LS(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=G5.sidePanelWidth(),t[0]=e):e=t[0],_S(e,yS)}function Nr(t,e){const s=(t??"").trim().replace(/^[/\\]+|[/\\]+$/g,"");return s?`${s}/${e}`:e}function _p(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function SS(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&_p(s))return s}return null}function wS(t){const e=t.previewUrl??t.getFallbackPreviewUrl?.()??SS();if(e&&_p(e))return new URL("/.decofile",e).toString();const s=new URLSearchParams({path:"/.decofile"});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${s.toString()}`}async function yp(t,e){const s=`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/read`,n=await fetch(s,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:e,full:!0})});if(n.status===400)return null;if(!n.ok){const o=new Error(`Failed to read ${e}: ${n.status}`);throw o.status=n.status,o}const r=await n.json();if(typeof r.content!="string")return null;try{return JSON.parse(jb(r.content))}catch{return null}}function sc(t,e){const s=M.c(10),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0,o=fs(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==n?(a=it.decofile(n),s[0]=n,s[1]=a):a=s[1];let l;s[2]!==r||s[3]!==o||s[4]!==t?(l=async()=>{const h=()=>yp(t,Nr(o,".deco/blocks.gen.json"));if(r){const m=await fetch(wS(t),{cache:"no-store"}).catch(kS);if(m?.ok)return await m.json();const p=await h();if(p)return p;const g=new Error(`Failed to fetch decofile: ${m?.status??"network error"}`);throw g.status=m?.status??502,g}const u=await h();if(u)return u;const f=new Error("decofile unavailable (preview down, no committed snapshot)");throw f.status=502,f},s[2]=r,s[3]=o,s[4]=t,s[5]=l):l=s[5];const c=!!t;let d;return s[6]!==a||s[7]!==l||s[8]!==c?(d={queryKey:a,queryFn:l,enabled:c,staleTime:3e4,retry:CS,retryDelay:jS},s[6]=a,s[7]=l,s[8]=c,s[9]=d):d=s[9],Ut(d)}function jS(t){return l2(5e3,1e3,t,2,0)}function CS(t,e){return e.status!==502&&t<2}function kS(){return null}function nc(t,e){const s=M.c(13),n=e?.fetchEnabled??!0,r=t?.previewUrl,o=fs(t?.virtualMcpId)?.metadata?.runtime?.path??null;let a;s[0]!==t||s[1]!==r?(a=t?it.liveMeta(t.orgSlug,t.virtualMcpId,t.branch,r??""):it.liveMeta(""),s[0]=t,s[1]=r,s[2]=a):a=s[2];let l;s[3]!==n||s[4]!==o||s[5]!==t||s[6]!==r?(l=async()=>{const u=()=>yp(t,Nr(o,".deco/meta.gen.json"));if(n&&r){const p=new URL("/live/_meta",r).href,g=await fetch(p,{cache:"no-store"}).catch(AS);if(g?.ok)return await g.json();const x=await u();if(x)return x;const v=new Error(`Failed to fetch live meta: ${g?.status??"network error"}`);throw v.status=g?.status??502,v}const f=await u();if(f)return f;const m=new Error("live meta unavailable (preview down, no committed snapshot)");throw m.status=502,m},s[3]=n,s[4]=o,s[5]=t,s[6]=r,s[7]=l):l=s[7];const c=!!t,d=e?.refetchInterval;let h;return s[8]!==a||s[9]!==l||s[10]!==c||s[11]!==d?(h={queryKey:a,queryFn:l,enabled:c,refetchInterval:d,refetchIntervalInBackground:!1,staleTime:3e5,retry:NS,retryDelay:VS},s[8]=a,s[9]=l,s[10]=c,s[11]=d,s[12]=h):h=s[12],Ut(h)}function VS(t){return l2(5e3,1e3,t,2,0)}function NS(t,e){return e.status!==502&&t<3}function AS(){return null}function jh(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function vo(t){return t.includes("@")}function P0(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function Ch(t,e){if(t===e)return!0;const s=P0(t);return s?e===s||P0(e)===s:!1}function k9(t,e){const s=t.manifest?.blocks??{};for(const[n,r]of Object.entries(s))if(e in r)return n;return null}function Lp(t,e){const s=k9(t,e);return s!==null&&s.includes("sections")}function TS(t,e){const s=k9(t,e);return s!==null&&s.includes("apps")}function ES(t,e){const s=k9(t,e);return s!==null&&s.includes("matchers")}function bn(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function ic(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const V9="oklch(0.7278 0.151 289)",Sp="website/matchers/always.ts",Ar="website/matchers/never.ts",Mi="website/flags/multivariate.ts",Tr="website/flags/multivariate/section.ts";function mr(){return{__resolveType:Sp}}function Ct(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())||t}const RS=12,va=8,PS=40;function IS(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function DS(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const r=s.properties?.__resolveType?.enum;return Array.isArray(r)&&typeof r[0]=="string"}const OS="VideoWidget";function wp(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function N9(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function A9(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function jp(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function T9(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const n=N9(t)??A9(t);if(n){for(const l of jp(n.vendor,n.app))for(const c of Object.values(s))if(c[l])return c[l]}const r=wp(t);for(const l of Object.values(s))if(l[r])return l[r];const o=e.schema??{};return(o.$defs??o.definitions??{})[r]?{$ref:`#/definitions/${r}`}:{}}function Cp(t,e){if(TS(t,e))return!0;const s=N9(e)??A9(e);if(!s)return!1;const n=t.manifest?.blocks?.apps??{};if(jp(s.vendor,s.app).some(a=>a in n))return!0;const r=wp(e),o=t.schema?.$defs??t.schema?.definitions??{};return r in o}function kp(t){return t==="site/apps/site.ts"?!1:N9(t)!==null||A9(t)!==null}function _n(t,e){const s=e.schema??{},n=T9(t,e),r=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const b=v.slice(7);return o[b]??{}}const _=v.split("/").pop()??"";return r[_]??{}};let l;typeof n.$ref=="string"?l=a(n.$ref):Object.keys(n).length>0?l=n:l=s;const c=v=>typeof v.$ref=="string"?a(v.$ref):v,d=v=>{const b=c(v).properties?.type;if(b){if(typeof b.const=="string")return b.const;if(typeof b.default=="string")return b.default;if(Array.isArray(b.enum)&&typeof b.enum[0]=="string")return b.enum[0]}},h=(v,_)=>{const b=c(v);return typeof b.title=="string"&&!b.title.startsWith("#")?b.title:_},u=(v,_=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const b=v.$ref.split("/").pop()??"";return!b||_.has(b)?v:u(a(v.$ref),new Set([..._,b]))},f=v=>{const _=v.hide;return _===!0||_==="true"},m=(v,_=new Set,b=0)=>{if(b>RS)return{};if(typeof v.$ref=="string"){const L=v.$ref.split("/").pop()??"";return _.has(L)?{}:m(a(v.$ref),new Set([..._,L]),b+1)}let y={};if(v.properties&&typeof v.properties=="object"&&(y={...y,...v.properties}),Array.isArray(v.required)){const L=Array.isArray(y.__required)?y.__required:[];y.__required=[...L,...v.required]}for(const L of["allOf","anyOf","oneOf"]){const w=v[L];if(Array.isArray(w))for(const S of w)y={...y,...m(S,_,b+1)}}return y},p=(v,_=0,b=new Set)=>{let y=v,L;if(typeof v.$ref=="string"){y=a(v.$ref);const D=v.$ref.split("/").pop()??"";L=D,D===OS&&!y.format&&(y={...y,format:"video-uri"})}y=u(y);const w=L!==void 0&&b.has(L),S=L!==void 0?new Set([...b,L]):b,j=(D,P,I,O=!0)=>!w&&(!O||I<=PS)&&P<va?p(D,P,S):void 0;let C;{const D=y.anyOf??y.oneOf;if(Array.isArray(D)){const P=D.filter(O=>!(O.type==="null"||O.type===null)),I=O=>{if(typeof O.const=="string"||typeof O.const=="number")return O.const;if(Array.isArray(O.enum)&&O.enum.length===1&&(typeof O.enum[0]=="string"||typeof O.enum[0]=="number"))return O.enum[0]};P.length>0&&P.every(O=>I(O)!==void 0)&&(C=P.map(O=>I(O)))}}let V,N;if(y.type)V=Array.isArray(y.type)?String(y.type.find(D=>D!=="null")??y.type[0]):String(y.type);else if(y.anyOf||y.allOf||y.oneOf){const P=(y.anyOf??y.allOf??y.oneOf).filter(I=>!(I.type==="null"||I.type===null));if(P.length===0)V="null";else if(P.length===1){const I=P[0];N=I,V=I.type?Array.isArray(I.type)?String(I.type[0]):String(I.type):typeof I.$ref=="string"?"object":"string"}else{if(C)return{type:"string",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,enum:C};const I=P.filter(K=>{const Y=K.properties?.__resolveType?.enum;return Array.isArray(Y)&&typeof Y[0]=="string"}),O=P.find(IS),B=I.some(K=>{const Y=K.properties?.__resolveType?.enum;return Array.isArray(Y)&&Y[0]===Mi});if(O){if(!DS(O,a)&&P.length>1){const Y=p(O,_+1,S);return{...Y,type:"array",title:typeof y.title=="string"?y.title:Y.title,description:typeof y.description=="string"?y.description:Y.description}}if(B){const Y=p(O,_+1,S);return{...Y,type:"array",title:typeof y.title=="string"?y.title:Y.title,description:typeof y.description=="string"?y.description:Y.description}}}if(I.length>0){const K=I.map(q=>{const ne=q.properties?.__resolveType?.enum??[],le=String(ne[0]);return{resolveType:le,title:typeof q.title=="string"?q.title:Ct(le),description:typeof q.description=="string"?q.description:void 0,schema:j(q,_+1,P.length)}}),Y=[];for(const q of P){if(I.includes(q)||typeof q.$ref!="string")continue;const se=a(q.$ref);let ne;const le=se.properties?.__resolveType;if(Array.isArray(le?.enum)&&typeof le.enum[0]=="string"&&(ne=le.enum[0]),!ne&&Array.isArray(se.allOf))for(const G of se.allOf){const oe=G.properties?.__resolveType?.enum;if(Array.isArray(oe)&&typeof oe[0]=="string"){ne=oe[0];break}}ne&&Y.push({resolveType:ne,title:typeof se.title=="string"&&!se.title.startsWith("#")?se.title:Ct(ne),description:typeof se.description=="string"?se.description:void 0,schema:j(se,_+1,P.length)})}const F=new Set(K.map(q=>q.resolveType)),Q=[...K,...Y.filter(q=>!F.has(q.resolveType))],J=P.filter(q=>!I.includes(q)),ee=J.length===1?j(J[0],_+1,P.length):void 0;return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:Q,plainSchema:ee,hidden:f(y)||f(v)?!0:void 0}}const z=P.map(K=>d(K));if(P.length>1&&z.every(K=>typeof K=="string")){const K=P.map((Y,F)=>{const Q=c(Y),J=z[F];return{resolveType:J,title:h(Y,J),description:typeof Q.description=="string"?Q.description:void 0,discriminatorValue:J,schema:j(Q,_+1,P.length,!1)}});return{type:"block-ref",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:void 0,discriminatorKey:"type",anyOfRefs:K,hidden:f(y)||f(v)?!0:void 0}}const U=K=>{const Y=c(K);if(typeof Y.title=="string"&&jh(Y.title))return!0;const F=Y.properties?.__resolveType?.enum;if(Array.isArray(F)&&typeof F[0]=="string")return!0;if(Array.isArray(Y.allOf))for(const Q of Y.allOf){const J=Q.properties?.__resolveType?.enum;if(Array.isArray(J)&&typeof J[0]=="string")return!0}return!1},W=K=>{if(U(K))return!1;const Y=c(K);return Y.type==="object"||!!Y.properties},H=(Array.isArray(y.anyOf)||Array.isArray(y.oneOf))&&_<va&&P.every(W);if(P.every(K=>typeof K.$ref=="string")&&!H){const K=[];for(const Y of P){const F=a(Y.$ref);let Q,J;if(typeof F.title=="string"){const q=jh(F.title);q&&(Q=q.blockId,J=q.blockId)}if(!Q&&Array.isArray(F.allOf))for(const q of F.allOf){const le=((q.properties??{}).__resolveType??{}).enum;if(Array.isArray(le)&&typeof le[0]=="string"){Q=le[0];break}}if(!Q){const se=F.properties?.__resolveType?.enum;Array.isArray(se)&&typeof se[0]=="string"&&(Q=se[0])}Q||(Q=Y.$ref.split("/").pop()??"");const ee=d(Y);!ee&&!Q.includes("/")||K.push({resolveType:ee??Q,title:J??(typeof F.title=="string"&&!F.title.startsWith("#")?F.title:Ct(Q)),description:typeof F.description=="string"?F.description:void 0,discriminatorValue:ee,schema:j(F,_+1,P.length)})}return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:K,hidden:f(y)||f(v)?!0:void 0}}if(H){const K=F=>{if(typeof F.const=="string"||typeof F.const=="number"||typeof F.const=="boolean")return F.const;if(Array.isArray(F.enum)&&F.enum.length===1&&(typeof F.enum[0]=="string"||typeof F.enum[0]=="number"||typeof F.enum[0]=="boolean"))return F.enum[0]},Y=P.map((F,Q)=>{const J=c(F).properties??{},ee={};for(const[q,se]of Object.entries(J)){const ne=K(se);ne!==void 0&&(ee[q]=ne)}return{title:h(F,`Option ${Q+1}`),schema:p(F,_+1),discriminators:Object.keys(ee).length?ee:void 0}});return{type:"inline-union",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,inlineUnionBranches:Y,hidden:f(y)||f(v)?!0:void 0}}V="object"}}else typeof v.$ref=="string"&&(V="object");let T;if(_<va){const D=m(y),P=Object.entries(D).filter(([I])=>!I.startsWith("__")&&I!=="@type");if(P.length>0){T={};for(const[I,O]of P)T[I]=p(O,_+1,S)}}let A;if((V==="array"||y.type==="array")&&_<va){let D=y.items;D&&(typeof D.$ref=="string"&&(D=a(D.$ref)),A=p(D,_+1,S),typeof D.title=="string"&&D.title.includes("{{")&&(A.titleBy=D.title))}const E=D=>{const P=N?.[D];return typeof P=="string"?P:void 0},R=()=>{if("default"in v)return v.default;if("default"in y)return y.default;if(N&&"default"in N)return N.default};return{type:V??"string",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:E("title"),description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:E("description"),default:R(),enum:Array.isArray(y.enum)?y.enum:C??void 0,format:typeof y.format=="string"?y.format:E("format"),properties:T,items:A,hidden:f(y)||f(v)?!0:void 0,titleBy:typeof y.titleBy=="string"?y.titleBy:E("titleBy"),image:typeof y.image=="string"?y.image:E("image"),options:typeof y.options=="string"?y.options:E("options")}},g=m(l),x={};for(const[v,_]of Object.entries(g))v.startsWith("__")||v==="@type"||(x[v]=p(_,0));return Object.keys(x).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:x}}function MS(t,e){const s=e.schema??{},n=T9(t,e),r=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?r[n.$ref.split("/").pop()??""]??{}:n,a=o.properties??{};if(Object.keys(a).some(d=>!d.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const c=a.__resolveType;return!!c&&Array.isArray(c.enum)&&c.enum[0]===t}function $S(t){const e=n=>{switch(typeof n){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(n===null)return{type:"string"};if(Array.isArray(n))return{type:"array",items:e(n[0])};const r={};for(const[o,a]of Object.entries(n))o.startsWith("__")||(r[o]=e(a));return{type:"object",properties:r}}default:return{type:"string"}}},s={};for(const[n,r]of Object.entries(t))n.startsWith("__")||(s[n]=e(r));return Object.keys(s).length===0?null:{type:"object",properties:s}}function ri(t,e){const s=e.schema??{},n=T9(t,e),r=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?r[n.$ref.split("/").pop()??""]??{}:Object.keys(n).length>0?n:{...s,...n},a=o.icon,l=o.logo,c=o,d=u=>u===!0||u==="true",h=d(c.hide)||d(c.ignore)||d(c.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0,hidden:h||void 0}}function Wn(t){return t.replace(/\/+$/,"")||"/"}function BS(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function E9(t){const e=t.trim();return e?BS(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const Vp=/:([A-Za-z0-9_-]+)|\*/g;function Np(t){return t.replace(/\{([^{}]*)\}\?/g,"$1")}function _l(t){t=Np(t);const e=[];let s=0;for(const n of t.matchAll(Vp))n.index>s&&e.push({type:"text",text:t.slice(s,n.index)}),e.push({type:"param",name:n[1]??"*"}),s=n.index+n[0].length;return s<t.length&&e.push({type:"text",text:t.slice(s)}),e}function hi(t,e){return Np(t).replace(Vp,(s,n)=>{const r=e[n??"*"]?.trim();return r?n!==void 0?encodeURIComponent(r):r.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const zS=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],kh="website/sections/Rendering/Lazy.tsx";function ds(t){return zS.some(e=>t.endsWith(e))}const Ap=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],Tp=new Set(Ap),FS=new Set(["site/sections/Theme/Theme.tsx"]);function rc(t){return!!(FS.has(t)||ds(t)||t.toLowerCase().includes("preview"))}function I0(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const n of Object.keys(s))if(Tp.has(n))return n;return Ap[0]}function D0(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return D0(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...D0(s));return e}return[]}function US(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(r)){if(rc(o))continue;const a=ri(o,t);s.push({resolveType:o,title:a.title??Ct(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function HS(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(r))rc(o)||s.push({resolveType:o,title:Ct(o)});return s.sort((n,r)=>n.title.localeCompare(r.title))}function Ep(t,e){const s=[];for(const[n,r]of Object.entries(e)){if(n.includes("/")||ic(n)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(Tp.has(a)||typeof o.path!="string"&&(rc(a)||Lp(t,a)&&s.push({resolveType:n,title:n,description:typeof o.name=="string"?o.name:void 0,previewBlock:n,isSavedBlock:!0})))}return s}function KS(t,e){const s=bn(e.resolveType),n=s?{}:ri(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||n.title||Ct(e.resolveType),description:e.description??n.description,previewBlock:e.resolveType,isSavedBlock:s}}function GH(t,e){const s=I0(t),n=_n(s,t),r=D0(n?.properties?.sections),o=new Map,a=l=>{if(!rc(l.resolveType)){if(bn(l.resolveType)){ic(l.resolveType)||o.set(l.resolveType,l);return}Lp(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of US(t))a(l);for(const l of r)a(KS(t,l));for(const l of Ep(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function YH(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}const R9="website/loaders/redirect.ts",Rp=new Set([R9,"website/loaders/redirects.ts"]),WS={temporary:307,permanent:301},Vh=t=>typeof t=="string"?t:"",qS=t=>t==="permanent"?"permanent":"temporary";function Pp(t){const e=t&&typeof t.redirect=="object"&&t.redirect!==null&&!Array.isArray(t.redirect)?t.redirect:{};return{from:Vh(e.from),to:Vh(e.to),type:qS(e.type),discardQueryParameters:e.discardQueryParameters===!0}}function Ip(t){const e=[];for(const[s,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;const r=n;if(r.__resolveType!==R9)continue;const{from:o,to:a,type:l,discardQueryParameters:c}=Pp(r);e.push({key:s,from:o,to:a,type:l,discardQueryParameters:c})}return e}function JH(t){return Pp(t)}function GS(t){const e={from:t.from,to:t.to,type:t.type};return t.discardQueryParameters&&(e.discardQueryParameters=!0),{redirect:e,__resolveType:R9}}function YS(t){return(t.split(/[?#]/)[0]??"").replace(/^\/+/,"").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"redirect"}const JS=1e3;function XS(t,e){const s=YS(e);for(let n=0;n<JS;n++){const r=`redirects-${s}-${crypto.randomUUID()}`;if(!Object.hasOwn(t,r))return r}throw new Error("Could not generate a unique redirect block key")}function QS(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function ZS(t,e,s){const n=Wn;if(s){const o=t.find(a=>a.key===s);if(o)return o}const r=t.filter(o=>n(o.path)===n(e));return r.length===0?null:r.length===1?r[0]??null:[...r].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const Dp=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),ao="site",P9="site/apps/site.ts";function yl(t,e){return t===ao?!0:e.__resolveType===P9}function I9(t,e){return t?D9(t).length>0||Ip(t).length>0?!0:e?O9(t,e).length>0||O0(t,e)?!0:ew(t,e).length>0:!1:!1}function D9(t){const e=[];for(const[s,n]of Object.entries(t))if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;typeof r.__resolveType=="string"&&Dp.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:QS(s),path:r.path})}return e}function oc(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ll(t,e,s){const n=typeof e.__resolveType=="string"?e.__resolveType:"",r=n?ri(n,s):{};if(r.title)return r.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function O0(t,e){const s=t[ao];if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s,r=n.__resolveType;if(typeof r=="string"&&(yl(ao,n)||Cp(e,r)))return{key:ao,name:Ll(ao,n,e),resolveType:r}}for(const[n,r]of Object.entries(t)){if(n.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;if(!yl(n,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:P9;return{key:n,name:Ll(n,o,e),resolveType:a}}return null}function ew(t,e){const s=[];for(const[n,r]of Object.entries(t)){if(n.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(Dp.has(a)||typeof o.path!="string"&&(yl(n,o)||!Cp(e,a)&&!kp(a)||s.push({key:n,name:Ll(n,o,e),resolveType:a})))}return s.sort((n,r)=>n.name.localeCompare(r.name))}function O9(t,e){return Ep(e,t).map(s=>{const n=t[s.resolveType],r=typeof n.__resolveType=="string"?n.__resolveType:"";return{key:s.resolveType,name:s.description??oc(s.resolveType,n),resolveType:r}}).sort((s,n)=>s.name.localeCompare(n.name))}const tw={overview:Av,settings:Em,automations:Wd,preview:ii,code:Nv,content:Tm,git:Qs,files:Xn};function Nh(t){const e=Kl(t);if(e.type==="icon"){const s=Ri(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function ba(t){if(t.kind==="system")return{kind:"component",Component:tw[t.tabId]};const e=Nh(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const n=Nh(s.icon);return n||{kind:"fallback"}}const sw=[{id:"preview",title:"Preview"},{id:"code",title:"Code"}];function nw(t){return t?[...sw]:[]}function Op(t){return t.reportsOnly&&!t.onReportAgent&&(t.tabId==="preview"||t.tabId==="code")}function iw(t){const{org:e}=Ee(),s=Ms(),n=_m(),r=k.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=t?r.find(l=>l.id===t)??null:null,{data:a}=tm({queryKey:it.ensureTask(e.id,t),queryFn:async()=>{if(!t)return null;try{const{item:l}=await s.call("COLLECTION_THREADS_GET",{id:t});return l??null}catch{return null}},select:l=>l?.metadata??null,staleTime:3e4});return o?.metadata??a??null}function M9(t){const e=M.c(33),s=yt();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const r=_r(n),o=fs(t.virtualMcpId),a=iw(t.taskId),{org:l}=Ee(),{currentBranch:c}=Qt();let d;e[1]!==o?(d=ea(o),e[1]=o,e[2]=d):d=e[2];const h=d,u=h?.connectionId??"",f=h?.owner??"",m=h?.name??"",p=h?c:null;let g;e[3]!==l.id||e[4]!==l.slug||e[5]!==u||e[6]!==f||e[7]!==m||e[8]!==p?(g={orgId:l.id,orgSlug:l.slug,connectionId:u,owner:f,repo:m,branch:p},e[3]=l.id,e[4]=l.slug,e[5]=u,e[6]=f,e[7]=m,e[8]=p,e[9]=g):g=e[9];const x=L9(g),v=x.data?.state==="open",_=o?.metadata?.ui??null,b=_?.layout??null,y=b?.tabs??[],L=o?.id?Dx(o.id):null,w=a?.expanded_tools??[],S=Km(o),j=tn(o?.metadata)||tn(a),{granted:C}=u6("agents:manage"),V=Jl();let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N={includeVirtual:!0},e[10]=N):N=e[10];const T=En(N),A=$s(),{vmEntry:E,previewUrl:R}=Vr(),D=A.lifecycle.phase==="running";let P;e[11]!==R||e[12]!==E?.sandboxProviderKind?(P=E?.sandboxProviderKind==="user-desktop"&&R?`${R.replace(/\/+$/,"")}/api/mcp`:void 0,e[11]=R,e[12]=E?.sandboxProviderKind,e[13]=P):P=e[13];const I=P,O=Ox({connectionId:L??void 0,orgId:l.id,orgSlug:l.slug,mcpUrl:I}),B=O,z=!!O&&D;let $;e[14]!==z||e[15]!==B?($={client:B,enabled:z},e[14]=z,e[15]=B,e[16]=$):$=e[16];const{data:U}=r9($),W=L&&D?(U?.tools??[]).filter(aw).map(ge=>({connectionId:L,toolName:ge.name,label:yi(ge.name),icon:null})):[],X=W[0],H=X?W:_?.pinnedViews??[],Z=X&&L?{type:"ext-apps",id:L,toolName:X.toolName}:b?.defaultMainView??null,K=j&&o?.id&&c?{orgSlug:l.slug,virtualMcpId:o.id,branch:c,previewUrl:R}:null;let Y;e[17]!==D?(Y={fetchEnabled:D},e[17]=D,e[18]=Y):Y=e[18];const{data:F}=sc(K,Y);let Q;e[19]!==D?(Q={fetchEnabled:D},e[19]=D,e[20]=Q):Q=e[20];const{data:J}=nc(K,Q),ee=I9(F,J),{activeTab:q,mainOpen:se}=Yb({mainParam:r.main,metadata:Z||b?{defaultMainView:Z,tabs:y.map(ow)}:null}),ne=S&&(v||x.isPending&&q==="git"),le=Z||b?{defaultMainView:Z,tabs:y.map(rw)}:null,G=q==="git"&&!ne&&!x.isPending?il(le):q==="content"&&!ee?il(le):q,oe=q==="git"&&!ne&&!x.isPending?!1:se,me=e2(G),ue=[];(Z?.type==="overview"||V)&&ue.push({id:"overview",title:"Overview"}),ue.push(...nw(j||V));const ye=[];j&&ee&&ye.push({id:"content",title:"Content"}),ne&&ye.push({id:"git",title:"Review changes"}),V||(ye.push({id:"automations",title:"Automations"}),C&&ye.push({id:"settings",title:"Settings"}));const Le=new Map;for(const ge of w){const Ke=Ba(ge.appId,ge.toolName);Le.set(Ke,{id:Ke,title:ge.toolName,appId:ge.appId,iconKey:ge.toolName})}for(const ge of H){const Ke=Ba(ge.connectionId,ge.toolName);Le.set(Ke,{id:Ke,title:ge.label||ge.toolName,appId:ge.connectionId,iconKey:ge.toolName,iconUrl:ge.icon??null})}if(V){const ge=Mx.COMMERCE_DISCOVERY(l.id),Ke=Ba(ge,Ou);Le.has(Ke)||Le.set(Ke,{id:Ke,title:"Report",appId:ge,iconKey:Ou,iconUrl:$x})}const Ce=t2(G),ze=Ce?Ce.key.split("/").pop()??Ce.key:null,Te=ze?[{id:G,title:ze,kind:"file",icon:{kind:"component",Component:ge=>k.createElement(dr,{filename:ze,...ge})}}]:[],Se=s2(G),be=Se?[{id:G,title:(Se.path.split("/").pop()??Se.path).replace(/\.html$/i,""),kind:"file",icon:{kind:"component",Component:ge=>k.createElement(Se.path.startsWith("pages/")?ii:jr,ge)}}]:[],Re=n2(G),Ve=Re?Re.path.split("/").pop()??Re.path:null,he=Ve?[{id:G,title:Ve,kind:"file",icon:{kind:"component",Component:ge=>k.createElement(dr,{filename:Ve,...ge})}}]:[];let Pe;e[21]!==T?(Pe=ge=>({id:ge.id,title:ge.title,kind:"agent",icon:ba({tabId:ge.id,kind:"agent",appId:ge.view.appId,connections:T})}),e[21]=T,e[22]=Pe):Pe=e[22];const Me=[...ue.map(ge=>({id:ge.id,title:ge.title,kind:"system",icon:ba({tabId:ge.id,kind:"system",connections:T})})),...Te,...be,...he,...y.map(Pe),...Array.from(Le.values()).map(ge=>({id:ge.id,title:ge.title,kind:"expanded",icon:ba({tabId:ge.iconKey,kind:"expanded",appId:ge.appId,iconUrl:ge.iconUrl,connections:T})})),...ye.map(ge=>({id:ge.id,title:ge.title,kind:"system",icon:ba({tabId:ge.id,kind:"system",connections:T})}))],xe=t.virtualMcpId;let Ae;e[23]!==l.id?(Ae=el(l.id),e[23]=l.id,e[24]=Ae):Ae=e[24];const pe=xe===Ae;let ke;return e[25]!==G||e[26]!==oe||e[27]!==s||e[28]!==pe||e[29]!==l.id||e[30]!==l.slug||e[31]!==V?(ke=ge=>{if(Op({reportsOnly:V,onReportAgent:pe,tabId:ge})){s({to:"/$org/$taskId",params:{org:l.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:el(l.id),main:ge}});return}const Ke=Jb({clickedId:ge,activeTab:G,mainOpen:oe});s({to:".",search:gt=>({...gt,main:Ke}),replace:!0})},e[25]=G,e[26]=oe,e[27]=s,e[28]=pe,e[29]=l.id,e[30]=l.slug,e[31]=V,e[32]=ke):ke=e[32],{activeTab:G,mainOpen:oe,setActiveTab:ke,systemTabs:[...ue,...ye],layoutTabs:y,expandedTools:w,automationTabParsed:me,tabs:Me}}function rw(t){return{id:t.id}}function ow(t){return{id:t.id}}function aw(t){return!!Xl(t._meta)}function Mp(t){const{managerAgentId:e,managerName:s,kind:n,id:r,instructions:o}=t,a=` to improve the instructions of ${n} "${r}". Here are its current instructions.
10
+ <current_instructions>${o}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function lw(t){const e=M.c(9),s=Ms();let n;e[0]!==t?(n=it.user(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==s||e[3]!==t?(r=async()=>{const{user:l}=await s.call("USER_GET",{id:t});return l},e[2]=s,e[3]=t,e[4]=r):r=e[4];const o=!!t;let a;return e[5]!==n||e[6]!==r||e[7]!==o?(a={queryKey:n,queryFn:r,staleTime:3e5,retry:1,enabled:o},e[5]=n,e[6]=r,e[7]=o,e[8]=a):a=e[8],Ut(a)}function $p(t){const e=M.c(36),{id:s,size:n,showEmail:r,avatarOnly:o,className:a}=t,l=n===void 0?"xs":n,c=r===void 0?!1:r,d=o===void 0?!1:o,{data:h,isLoading:u,isError:f}=lw(s);if(u){let _;e[0]!==a?(_=te("flex items-center gap-2",a),e[0]=a,e[1]=_):_=e[1];let b;e[2]!==l?(b=i.jsx(Ji.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=b):b=e[3];let y;e[4]!==d||e[5]!==c?(y=!d&&i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),c&&i.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=d,e[5]=c,e[6]=y):y=e[6];let L;return e[7]!==_||e[8]!==b||e[9]!==y?(L=i.jsxs("div",{className:_,children:[b,y]}),e[7]=_,e[8]=b,e[9]=y,e[10]=L):L=e[10],L}if(f||!h){let _;e[11]!==a?(_=te("flex items-center gap-2",a),e[11]=a,e[12]=_):_=e[12];let b;e[13]!==l?(b=i.jsx(Ji,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=b):b=e[14];let y;e[15]!==d?(y=!d&&i.jsx("div",{className:"flex flex-col",children:i.jsx("div",{className:"text-sm text-muted-foreground",children:"Unknown User"})}),e[15]=d,e[16]=y):y=e[16];let L;return e[17]!==_||e[18]!==b||e[19]!==y?(L=i.jsxs("div",{className:_,children:[b,y]}),e[17]=_,e[18]=b,e[19]=y,e[20]=L):L=e[20],L}let m;e[21]!==a?(m=te("flex items-center gap-2",a),e[21]=a,e[22]=m):m=e[22];const p=h.image??void 0;let g;e[23]!==l||e[24]!==p||e[25]!==h.name?(g=i.jsx(Ji,{shape:"circle",size:l,url:p,fallback:h.name}),e[23]=l,e[24]=p,e[25]=h.name,e[26]=g):g=e[26];let x;e[27]!==d||e[28]!==c||e[29]!==h.email||e[30]!==h.name?(x=!d&&i.jsxs("div",{className:"flex flex-col",children:[i.jsx("div",{className:"text-sm font-medium",children:h.name}),c&&i.jsx("div",{className:"text-xs text-muted-foreground",children:h.email})]}),e[27]=d,e[28]=c,e[29]=h.email,e[30]=h.name,e[31]=x):x=e[31];let v;return e[32]!==m||e[33]!==g||e[34]!==x?(v=i.jsxs("div",{className:m,children:[g,x]}),e[32]=m,e[33]=g,e[34]=x,e[35]=v):v=e[35],v}function cw(t){const e=M.c(95),{value:s,onChange:n,onColorChange:r,name:o,size:a,className:l,avatarClassName:c,showHoverOverlay:d,disabled:h}=t,u=a===void 0?"lg":a,f=d===void 0?!0:d,m=h===void 0?!1:h,[p,g]=k.useState(!1),[x,v]=k.useState("icons"),[_,b]=k.useState(""),[y,L]=k.useState("blue");let w;e[0]!==s?(w=Kl(s),e[0]=s,e[1]=w):w=e[1];const S=w,j=S.type==="icon"||S.type==="url"&&S.color?S.color:y;let C;e[2]!==n||e[3]!==j?(C=Ve=>{n(Pc(Ve,j))},e[2]=n,e[3]=j,e[4]=C):C=e[4];const V=C;let N;e[5]!==n||e[6]!==r||e[7]!==S.name||e[8]!==S.type||e[9]!==S.url?(N=Ve=>{L(Ve),r?.(Ve),S.type==="icon"?n(Pc(S.name,Ve)):S.type==="url"&&n(zu(S.url,Ve))},e[5]=n,e[6]=r,e[7]=S.name,e[8]=S.type,e[9]=S.url,e[10]=N):N=e[10];const T=N;let A;e[11]!==n||e[12]!==j?(A=Ve=>{n(zu(Ve,j)),g(!1)},e[11]=n,e[12]=j,e[13]=A):A=e[13];const E=A;let R;e[14]!==n||e[15]!==j?(R=()=>{const Ve=qd(),he=Ve[Math.floor(Math.random()*Ve.length)];n(Pc(he,j))},e[14]=n,e[15]=j,e[16]=R):R=e[16];const D=R;let P,I,O,B,z,$,U,W,X,H;if(e[17]!==l||e[18]!==m||e[19]!==p||e[20]!==u){const Ve={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};I=Ns,W=m?!1:p,X=g,P=As,U=!0,H="button",O="icon-picker-trigger",B="Change icon",z=m,$=te("relative group overflow-hidden",m?"cursor-default opacity-50":"cursor-pointer",Ve[u],l),e[17]=l,e[18]=m,e[19]=p,e[20]=u,e[21]=P,e[22]=I,e[23]=O,e[24]=B,e[25]=z,e[26]=$,e[27]=U,e[28]=W,e[29]=X,e[30]=H}else P=e[21],I=e[22],O=e[23],B=e[24],z=e[25],$=e[26],U=e[27],W=e[28],X=e[29],H=e[30];let Z;e[31]!==c||e[32]!==o||e[33]!==u||e[34]!==s?(Z=i.jsx(Yn,{icon:s,name:o,size:u,className:c}),e[31]=c,e[32]=o,e[33]=u,e[34]=s,e[35]=Z):Z=e[35];let K;e[36]!==m||e[37]!==f?(K=f&&!m&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:i.jsx(Tm,{size:16,className:"text-white"})}),e[36]=m,e[37]=f,e[38]=K):K=e[38];let Y;e[39]!==O||e[40]!==B||e[41]!==z||e[42]!==$||e[43]!==Z||e[44]!==K||e[45]!==H?(Y=i.jsxs("button",{type:H,"data-testid":O,"aria-label":B,disabled:z,className:$,children:[Z,K]}),e[39]=O,e[40]=B,e[41]=z,e[42]=$,e[43]=Z,e[44]=K,e[45]=H,e[46]=Y):Y=e[46];let F;e[47]!==P||e[48]!==U||e[49]!==Y?(F=i.jsx(P,{asChild:U,children:Y}),e[47]=P,e[48]=U,e[49]=Y,e[50]=F):F=e[50];let Q;e[51]!==o||e[52]!==s?(Q=i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(Yn,{icon:s,name:o,size:"xl"})}),e[51]=o,e[52]=s,e[53]=Q):Q=e[53];let J;e[54]!==x?(J=Ve=>{if(Ve.key!=="ArrowLeft"&&Ve.key!=="ArrowRight")return;Ve.preventDefault();const he=x==="icons"?"upload":"icons";v(he),document.getElementById(`icon-picker-tab-${he}`)?.focus()},e[54]=x,e[55]=J):J=e[55];const ee=x==="icons",q=x==="icons"?0:-1;let se;e[56]===Symbol.for("react.memo_cache_sentinel")?(se=()=>v("icons"),e[56]=se):se=e[56];const ne=x==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let le;e[57]!==ne?(le=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ne),e[57]=ne,e[58]=le):le=e[58];let G;e[59]!==ee||e[60]!==q||e[61]!==le?(G=i.jsx("button",{id:"icon-picker-tab-icons",type:"button",role:"tab","aria-selected":ee,"aria-controls":"icon-picker-panel-icons",tabIndex:q,onClick:se,className:le,children:"Icons"}),e[59]=ee,e[60]=q,e[61]=le,e[62]=G):G=e[62];const oe=x==="upload",me=x==="upload"?0:-1;let ue;e[63]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>v("upload"),e[63]=ue):ue=e[63];const ye=x==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let Le;e[64]!==ye?(Le=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ye),e[64]=ye,e[65]=Le):Le=e[65];let Ce;e[66]!==oe||e[67]!==me||e[68]!==Le?(Ce=i.jsx("button",{id:"icon-picker-tab-upload",type:"button",role:"tab","aria-selected":oe,"aria-controls":"icon-picker-panel-upload",tabIndex:me,onClick:ue,className:Le,children:"Upload"}),e[66]=oe,e[67]=me,e[68]=Le,e[69]=Ce):Ce=e[69];let ze;e[70]===Symbol.for("react.memo_cache_sentinel")?(ze=i.jsx("div",{className:"flex-1"}),e[70]=ze):ze=e[70];let Te;e[71]!==J||e[72]!==G||e[73]!==Ce?(Te=i.jsxs("div",{role:"tablist","aria-label":"Icon source",className:"flex items-center border-b border-border px-3",onKeyDown:J,children:[G,Ce,ze]}),e[71]=J,e[72]=G,e[73]=Ce,e[74]=Te):Te=e[74];let Se;e[75]!==T||e[76]!==D||e[77]!==V||e[78]!==E||e[79]!==S.name||e[80]!==S.type||e[81]!==_||e[82]!==j||e[83]!==x?(Se=x==="icons"?i.jsx("div",{id:"icon-picker-panel-icons",role:"tabpanel","aria-labelledby":"icon-picker-tab-icons",children:i.jsx(fw,{search:_,onSearchChange:b,selectedColor:j,onColorChange:T,onSelectIcon:V,onRandom:D,currentIconName:S.type==="icon"?S.name:null})}):i.jsx("div",{id:"icon-picker-panel-upload",role:"tabpanel","aria-labelledby":"icon-picker-tab-upload",children:i.jsx(mw,{onUpload:E})}),e[75]=T,e[76]=D,e[77]=V,e[78]=E,e[79]=S.name,e[80]=S.type,e[81]=_,e[82]=j,e[83]=x,e[84]=Se):Se=e[84];let be;e[85]!==Q||e[86]!==Te||e[87]!==Se?(be=i.jsx(Ts,{align:"start",className:"w-80 p-0",onOpenAutoFocus:dw,children:i.jsxs("div",{className:"flex flex-col",children:[Q,Te,Se]})}),e[85]=Q,e[86]=Te,e[87]=Se,e[88]=be):be=e[88];let Re;return e[89]!==I||e[90]!==W||e[91]!==X||e[92]!==F||e[93]!==be?(Re=i.jsxs(I,{open:W,onOpenChange:X,children:[F,be]}),e[89]=I,e[90]=W,e[91]=X,e[92]=F,e[93]=be,e[94]=Re):Re=e[94],Re}function dw(t){return t.preventDefault()}function uw(t){const e=M.c(27),{selectedColor:s,onColorChange:n}=t,[r,o]=k.useState(!1);let a,l,c,d,h,u,f;if(e[0]!==r||e[1]!==s){const _=Rm(s);l=Ns,u=r,f=o,a=As,h=!0,c="button",d=te("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",_.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=c,e[5]=d,e[6]=h,e[7]=u,e[8]=f}else a=e[2],l=e[3],c=e[4],d=e[5],h=e[6],u=e[7],f=e[8];let m;e[9]!==c||e[10]!==d?(m=i.jsx("button",{type:c,className:d,title:"Change color","aria-label":"Change color"}),e[9]=c,e[10]=d,e[11]=m):m=e[11];let p;e[12]!==a||e[13]!==h||e[14]!==m?(p=i.jsx(a,{asChild:h,children:m}),e[12]=a,e[13]=h,e[14]=m,e[15]=p):p=e[15];let g;e[16]!==n||e[17]!==s?(g=Ev.map(_=>i.jsx("button",{type:"button",onClick:()=>{n(_.name),o(!1)},className:te("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",_.dot,s===_.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:_.name,"aria-label":_.name},_.name)),e[16]=n,e[17]=s,e[18]=g):g=e[18];let x;e[19]!==g?(x=i.jsx(Ts,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:hw,children:i.jsx("div",{className:"grid grid-cols-4 gap-1",children:g})}),e[19]=g,e[20]=x):x=e[20];let v;return e[21]!==l||e[22]!==u||e[23]!==f||e[24]!==p||e[25]!==x?(v=i.jsxs(l,{open:u,onOpenChange:f,children:[p,x]}),e[21]=l,e[22]=u,e[23]=f,e[24]=p,e[25]=x,e[26]=v):v=e[26],v}function hw(t){return t.preventDefault()}function fw(t){const e=M.c(44),{search:s,onSearchChange:n,selectedColor:r,onColorChange:o,onSelectIcon:a,onRandom:l,currentIconName:c}=t;let d,h,u,f,m,p,g;if(e[0]!==c||e[1]!==o||e[2]!==l||e[3]!==n||e[4]!==a||e[5]!==s||e[6]!==r){const y=qd(),L=Rm(r);h=Pm(y,s),p="flex flex-col";let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(Po,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=w):w=e[14];let S;e[15]!==n?(S=T=>n(T.target.value),e[15]=n,e[16]=S):S=e[16];let j;e[17]!==s||e[18]!==S?(j=i.jsxs("div",{className:"relative flex-1",children:[w,i.jsx(tt,{value:s,onChange:S,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=S,e[19]=j):j=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(Tv,{size:14,className:"text-muted-foreground"}),e[20]=C):C=e[20];let V;e[21]!==l?(V=i.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon","aria-label":"Random icon",children:C}),e[21]=l,e[22]=V):V=e[22];let N;e[23]!==o||e[24]!==r?(N=i.jsx(uw,{selectedColor:r,onColorChange:o}),e[23]=o,e[24]=r,e[25]=N):N=e[25],e[26]!==V||e[27]!==N||e[28]!==j?(g=i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[j,V,N]}),e[26]=V,e[27]=N,e[28]=j,e[29]=g):g=e[29],d=ti,m="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",f=h.map(T=>{const A=Ri(T);return A?i.jsx("button",{type:"button",onClick:()=>a(T),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",c===T?te(L.bg,L.text):te(L.text,"hover:bg-accent")),title:T,"aria-label":C0(T),children:i.jsx(A,{size:18})},T):null}),e[0]=c,e[1]=o,e[2]=l,e[3]=n,e[4]=a,e[5]=s,e[6]=r,e[7]=d,e[8]=h,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else d=e[7],h=e[8],u=e[9],f=e[10],m=e[11],p=e[12],g=e[13];let x;e[30]!==u||e[31]!==f?(x=i.jsx("div",{className:u,children:f}),e[30]=u,e[31]=f,e[32]=x):x=e[32];let v;e[33]!==h.length?(v=h.length===0&&i.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=h.length,e[34]=v):v=e[34];let _;e[35]!==d||e[36]!==m||e[37]!==x||e[38]!==v?(_=i.jsxs(d,{className:m,children:[x,v]}),e[35]=d,e[36]=m,e[37]=x,e[38]=v,e[39]=_):_=e[39];let b;return e[40]!==p||e[41]!==g||e[42]!==_?(b=i.jsxs("div",{className:p,children:[g,_]}),e[40]=p,e[41]=g,e[42]=_,e[43]=b):b=e[43],b}function mw(t){const e=M.c(27),{onUpload:s}=t,n=k.useRef(null);let r;e[0]!==s?(r=w=>{const S=w.target.files?.[0];if(!S)return;if(S.size>2097152){de.error("Image must be smaller than 2MB"),w.target.value="";return}const j=new FileReader;j.onerror=()=>{de.error("Failed to read image file"),n.current&&(n.current.value="")},j.onloadend=()=>{j.readyState===FileReader.DONE&&j.result&&s(j.result),n.current&&(n.current.value="")},j.readAsDataURL(S)},e[0]=s,e[1]=r):r=e[1];const o=r,[a,l]=k.useState("");let c;e[2]!==s||e[3]!==a?(c=()=>{const w=a.trim();w&&(s(w),l(""))},e[2]=s,e[3]=a,e[4]=c):c=e[4];const d=c;let h;e[5]!==o?(h=i.jsx("input",{type:"file",ref:n,className:"hidden",accept:"image/*",onChange:o}),e[5]=o,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>n.current?.click(),e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsxs("button",{type:"button",onClick:u,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[i.jsx(Pi,{size:20}),i.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),i.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=w=>l(w.target.value),e[10]=p):p=e[10];let g;e[11]!==d?(g=w=>{w.key==="Enter"&&(w.preventDefault(),d())},e[11]=d,e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==g?(x=i.jsx(tt,{value:a,onChange:p,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:g}),e[13]=a,e[14]=g,e[15]=x):x=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const _=!v;let b;e[18]!==d||e[19]!==_?(b=i.jsx(re,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:d,disabled:_,children:"Apply"}),e[18]=d,e[19]=_,e[20]=b):b=e[20];let y;e[21]!==b||e[22]!==x?(y=i.jsxs("div",{className:"flex items-center gap-1.5",children:[x,b]}),e[21]=b,e[22]=x,e[23]=y):y=e[23];let L;return e[24]!==y||e[25]!==h?(L=i.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[h,f,m,y]}),e[24]=y,e[25]=h,e[26]=L):L=e[26],L}const pw=25*1024*1024,Uc="home",Hc="knowledge";function Ah(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function li(t){return t.split("/").pop()??t}function gw(t){const e=M.c(52),{form:s}=t,{upload:n}=Cb(Uc),r=kb(),o=k.useRef(null),[a,l]=k.useState(!1),[c,d]=k.useState(""),[h,u]=k.useState(!1);let f;e[0]!==a?(f={enabled:a},e[0]=a,e[1]=f):f=e[1];const{data:m}=Vb(60,f),p=m===void 0?[]:m;let g;e[2]!==a?(g={enabled:a},e[2]=a,e[3]=g):g=e[3];const{data:x}=Nb(g),v=x===void 0?[]:x;let _;e[4]!==s?(_=()=>s.getValues("metadata.knowledge")??[],e[4]=s,e[5]=_):_=e[5];const[b,y]=k.useState(_);let L;e[6]!==s?(L=G=>{y(G),s.setValue("metadata.knowledge",G,{shouldDirty:!0})},e[6]=s,e[7]=L):L=e[7];const w=L;let S;e[8]!==r||e[9]!==b||e[10]!==w||e[11]!==n?(S=async G=>{if(!G||G.length===0)return;const oe=Array.from(G).filter(yw);if(oe.length!==0){try{await n.mutateAsync({dir:Hc,files:oe})}catch(me){const ue=me;de.error(ue instanceof Error?ue.message:"Failed to upload file.");return}w([...b,...oe.map(me=>({id:crypto.randomUUID(),name:me.name,volume:Uc,path:`${Hc}/${me.name}`,url:r(Uc,`${Hc}/${me.name}`),contentType:me.type||null,size:me.size,addedAt:new Date().toISOString()}))])}},e[8]=r,e[9]=b,e[10]=w,e[11]=n,e[12]=S):S=e[12];const j=S;let C;e[13]!==r||e[14]!==b||e[15]!==w?(C=G=>{b.some(oe=>oe.volume===G.volume&&oe.path===G.path)||(w([...b,{id:crypto.randomUUID(),name:li(G.path),volume:G.volume,path:G.path,url:r(G.volume,G.path),contentType:null,size:G.size??null,addedAt:new Date().toISOString()}]),l(!1))},e[13]=r,e[14]=b,e[15]=w,e[16]=C):C=e[16];const V=C;let N;e[17]!==r||e[18]!==b||e[19]!==w?(N=G=>{b.some(oe=>oe.volume===G.volume&&oe.path===G.path)||(w([...b,{id:crypto.randomUUID(),name:li(G.path),kind:"skill",volume:G.volume,path:G.path,url:r(G.volume,G.path),contentType:null,size:null,addedAt:new Date().toISOString()}]),l(!1))},e[17]=r,e[18]=b,e[19]=w,e[20]=N):N=e[20];const T=N;let A;e[21]!==b||e[22]!==w?(A=G=>{w(b.filter(oe=>oe.id!==G))},e[21]=b,e[22]=w,e[23]=A):A=e[23];const E=A;let R;e[24]===Symbol.for("react.memo_cache_sentinel")?(R=G=>{l(G),G&&d("")},e[24]=R):R=e[24];const D=R;let P;e[25]!==b?(P=new Set(b.map(_w)),e[25]=b,e[26]=P):P=e[26];const I=P,O=c.toLowerCase();let B;e[27]!==I?(B=G=>!I.has(`${G.volume}/${G.path}`),e[27]=I,e[28]=B):B=e[28];const z=p.filter(bw).filter(B).filter(G=>li(G.path).toLowerCase().includes(O)).slice(0,5);let $;e[29]!==I?($=G=>!I.has(`${G.volume}/${G.path}`),e[29]=I,e[30]=$):$=e[30];const U=v.filter($).filter(G=>li(G.path).toLowerCase().includes(O)).slice(0,5),W=G=>i.jsxs(as,{open:a,onOpenChange:D,children:[i.jsx(ls,{asChild:!0,children:G}),i.jsxs(cs,{align:"end",className:"w-56",children:[i.jsxs(Ge,{onSelect:()=>{o.current?.click()},children:[i.jsx(Rv,{size:16}),"Upload file"]}),i.jsxs(To,{children:[i.jsxs(Eo,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[i.jsx(Xn,{size:16}),"Select file or folder"]}),i.jsxs(Ro,{className:"w-72 p-0",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[i.jsx(Po,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("input",{value:c,onChange:oe=>d(oe.target.value),onKeyDown:vw,placeholder:"Search files...",className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:z.length===0?i.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:"No files found."}):z.map(oe=>i.jsxs(Ge,{onSelect:()=>V(oe),children:[i.jsx(dr,{filename:li(oe.path),className:"h-5 w-4 shrink-0"}),i.jsx("span",{className:"flex-1 truncate",children:li(oe.path)}),oe.size!=null&&i.jsx("span",{className:"text-xs text-muted-foreground",children:Ah(oe.size)})]},`${oe.volume}/${oe.path}`))})]})]}),i.jsxs(To,{children:[i.jsxs(Eo,{className:"gap-2 [&_svg:not([class*='text-'])]:text-muted-foreground",children:[i.jsx(Kn,{size:16}),"Select skill"]}),i.jsxs(Ro,{className:"w-72 p-0",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b px-3",children:[i.jsx(Po,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("input",{value:c,onChange:oe=>d(oe.target.value),onKeyDown:xw,placeholder:"Search skills...",className:"h-10 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:U.length===0?i.jsx("p",{className:"px-2 py-3 text-center text-sm text-muted-foreground",children:"No skills found."}):U.map(oe=>i.jsxs(Ge,{onSelect:()=>T(oe),children:[i.jsx(Kn,{size:16,className:"shrink-0"}),i.jsx("span",{className:"flex-1 truncate",children:li(oe.path)})]},`${oe.volume}/${oe.path}`))})]})]})]})]}),X="flex flex-col gap-3";let H;e[31]===Symbol.for("react.memo_cache_sentinel")?(H=i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Files and skills"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Attach files and skills the agent can always reference."})]}),e[31]=H):H=e[31];const Z=b.length>0&&W(i.jsxs(re,{variant:"outline",size:"sm",disabled:n.isPending,children:[n.isPending?i.jsx(or,{size:"xs"}):i.jsx(kt,{size:14}),"Add"]}));let K;e[32]!==Z?(K=i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[H,Z]}),e[32]=Z,e[33]=K):K=e[33];let Y;e[34]!==j?(Y=i.jsx("input",{ref:o,type:"file",multiple:!0,className:"hidden",onChange:G=>{j(G.target.files),G.target.value=""}}),e[34]=j,e[35]=Y):Y=e[35];let F,Q;e[36]===Symbol.for("react.memo_cache_sentinel")?(F=G=>{G.preventDefault(),u(!0)},Q=()=>u(!1),e[36]=F,e[37]=Q):(F=e[36],Q=e[37]);let J;e[38]!==j?(J=G=>{G.preventDefault(),u(!1),j(G.dataTransfer.files)},e[38]=j,e[39]=J):J=e[39];const ee=h&&"outline outline-2 outline-dashed outline-primary";let q;e[40]!==ee?(q=te("flex flex-col gap-2 rounded-lg",ee),e[40]=ee,e[41]=q):q=e[41];const se=b.length===0?W(i.jsxs("button",{type:"button",className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[i.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:i.jsx(kt,{size:16})}),i.jsx("span",{className:"text-sm text-muted-foreground flex-1",children:"No files or skills yet. Add one or drag and drop here."})]})):b.map(G=>i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-card",children:[G.kind==="skill"?i.jsx("div",{className:"flex items-center justify-center h-8 w-6.5 shrink-0 rounded-md bg-muted text-muted-foreground",children:i.jsx(Kn,{size:16})}):i.jsx(dr,{filename:G.name,className:"h-8 w-6.5 shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium truncate",children:G.name}),i.jsx("p",{className:"text-xs text-muted-foreground",children:G.kind==="skill"?"Skill":G.size!=null?Ah(G.size):"File"})]}),i.jsx(re,{variant:"ghost",size:"icon",onClick:()=>E(G.id),"aria-label":`Remove ${G.name}`,children:i.jsx(ks,{size:16})})]},G.id));let ne;e[42]!==F||e[43]!==Q||e[44]!==J||e[45]!==q||e[46]!==se?(ne=i.jsx("div",{onDragOver:F,onDragLeave:Q,onDrop:J,className:q,children:se}),e[42]=F,e[43]=Q,e[44]=J,e[45]=q,e[46]=se,e[47]=ne):ne=e[47];let le;return e[48]!==K||e[49]!==Y||e[50]!==ne?(le=i.jsxs("section",{className:X,children:[K,Y,ne]}),e[48]=K,e[49]=Y,e[50]=ne,e[51]=le):le=e[51],le}function xw(t){return t.stopPropagation()}function vw(t){return t.stopPropagation()}function bw(t){return t.kind!=="dir"}function _w(t){return`${t.volume}/${t.path}`}function yw(t){return t.size<=pw}function Lw(t){return t==null?"all":t.length===0?"self":"selected"}function Sw(t){const e=M.c(65),{form:s,currentAgentId:n}=t,{org:r}=Ee(),o=Xo(),[a,l]=k.useState(!1);let c;e[0]!==s?(c=s.getValues("metadata.subAgents")??null,e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==d?(h=()=>Lw(d),e[2]=d,e[3]=h):h=e[3];const[u,f]=k.useState(h);let m;e[4]!==d?(m=d??[],e[4]=d,e[5]=m):m=e[5];const[p,g]=k.useState(m);let x,v,_,b,y,L;if(e[6]!==o||e[7]!==n||e[8]!==s||e[9]!==u||e[10]!==r||e[11]!==p){let C;e[18]!==n||e[19]!==r?(C=Z=>Z.id!==n&&Z.id!==r.id&&Z.status==="active",e[18]=n,e[19]=r,e[20]=C):C=e[20],x=o.filter(C);let V;e[21]!==p?(V=Z=>p.includes(Z.id),e[21]=p,e[22]=V):V=e[22];const N=x.filter(V);let T;e[23]!==s?(T=(Z,K)=>s.setValue("metadata.subAgents",Z==="all"?null:Z==="self"?[]:K,{shouldDirty:!0}),e[23]=s,e[24]=T):T=e[24];const A=T;let E;e[25]!==A||e[26]!==p?(E=Z=>{f(Z),A(Z,p)},e[25]=A,e[26]=p,e[27]=E):E=e[27];const R=E;let D;e[28]!==A||e[29]!==p?(D=Z=>{const K=p.includes(Z)?p.filter(Y=>Y!==Z):[...p,Z];g(K),A("selected",K)},e[28]=A,e[29]=p,e[30]=D):D=e[30],v=D,y="flex flex-col gap-3";let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sub-agents"}),e[31]=P):P=e[31];let I;e[32]!==u?(I=u==="all"&&i.jsx("p",{className:"text-sm text-muted-foreground",children:"Can delegate to any agent in the organization."}),e[32]=u,e[33]=I):I=e[33];let O;e[34]!==u?(O=u==="self"&&i.jsx("p",{className:"text-sm text-muted-foreground",children:"Can only delegate to a fresh copy of itself, no other agents."}),e[34]=u,e[35]=O):O=e[35];let B;e[36]!==I||e[37]!==O?(B=i.jsxs("div",{className:"flex flex-col gap-1",children:[P,I,O]}),e[36]=I,e[37]=O,e[38]=B):B=e[38];const z=u==="selected"&&N.length>0&&i.jsxs(re,{variant:"outline",size:"sm",onClick:()=>l(!0),children:[i.jsx(kt,{size:14}),"Add sub-agent"]});let $;e[39]!==R?($=Z=>R(Z),e[39]=R,e[40]=$):$=e[40];let U;e[41]===Symbol.for("react.memo_cache_sentinel")?(U=i.jsx(Xt,{size:"sm",className:"w-auto",children:i.jsx(rs,{})}),e[41]=U):U=e[41];let W;e[42]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsxs(Yt,{align:"end",children:[i.jsx(pt,{value:"all",children:"Any agent"}),i.jsx(pt,{value:"selected",children:"Specific agents"}),i.jsx(pt,{value:"self",children:"Only itself"})]}),e[42]=W):W=e[42];let X;e[43]!==u||e[44]!==$?(X=i.jsxs(Jt,{value:u,onValueChange:$,children:[U,W]}),e[43]=u,e[44]=$,e[45]=X):X=e[45];let H;e[46]!==z||e[47]!==X?(H=i.jsxs("div",{className:"flex items-center gap-2",children:[z,X]}),e[46]=z,e[47]=X,e[48]=H):H=e[48],e[49]!==B||e[50]!==H?(L=i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[B,H]}),e[49]=B,e[50]=H,e[51]=L):L=e[51],_="flex flex-col gap-2",b=u==="selected"&&(N.length>0?N.map(Z=>i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 rounded-xl border bg-background",children:[i.jsx(on,{icon:Z.icon,name:Z.title,size:"sm",className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium truncate",children:Z.title}),Z.description&&i.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Z.description})]}),i.jsx(re,{variant:"ghost",size:"icon",onClick:()=>v(Z.id),children:i.jsx(Tn,{size:16})})]},Z.id)):i.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[i.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:i.jsx(kt,{size:16})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"No sub-agents selected yet. Add one — until then this agent can only delegate to itself."})]})),e[6]=o,e[7]=n,e[8]=s,e[9]=u,e[10]=r,e[11]=p,e[12]=x,e[13]=v,e[14]=_,e[15]=b,e[16]=y,e[17]=L}else x=e[12],v=e[13],_=e[14],b=e[15],y=e[16],L=e[17];let w;e[52]!==_||e[53]!==b?(w=i.jsx("div",{className:_,children:b}),e[52]=_,e[53]=b,e[54]=w):w=e[54];let S;e[55]!==x||e[56]!==v||e[57]!==a||e[58]!==p?(S=i.jsx(ww,{open:a,onOpenChange:l,candidates:x,selectedIds:p,onToggle:v}),e[55]=x,e[56]=v,e[57]=a,e[58]=p,e[59]=S):S=e[59];let j;return e[60]!==y||e[61]!==L||e[62]!==w||e[63]!==S?(j=i.jsxs("section",{className:y,children:[L,w,S]}),e[60]=y,e[61]=L,e[62]=w,e[63]=S,e[64]=j):j=e[64],j}function ww(t){const e=M.c(32),{open:s,onOpenChange:n,candidates:r,selectedIds:o,onToggle:a}=t,[l,c]=k.useState("");let d,h,u,f,m,p,g,x,v;if(e[0]!==r||e[1]!==n||e[2]!==a||e[3]!==s||e[4]!==l||e[5]!==o){const L=l.toLowerCase(),w=r.filter(S=>S.title.toLowerCase().includes(L)||S.description?.toLowerCase().includes(L));h=es,x=s,v=n,d=Zt,m="max-w-md",e[15]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(us,{children:i.jsx(hs,{children:"Sub-agents"})}),e[15]=p):p=e[15],e[16]!==l?(g=i.jsx(d9,{value:l,onChange:c,placeholder:"Search agents...",className:"w-full"}),e[16]=l,e[17]=g):g=e[17],u="flex flex-col gap-1 max-h-80 overflow-y-auto",f=w.length===0?i.jsx("p",{className:"text-sm text-muted-foreground px-1 py-4 text-center",children:"No agents found."}):w.map(S=>i.jsxs("button",{type:"button",onClick:()=>a(S.id),className:"flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-accent/50 transition-colors cursor-pointer w-full text-left",children:[i.jsx(kr,{checked:o.includes(S.id),className:"pointer-events-none",tabIndex:-1}),i.jsx(on,{icon:S.icon,name:S.title,size:"sm",className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium truncate",children:S.title}),S.description&&i.jsx("p",{className:"text-xs text-muted-foreground truncate",children:S.description})]})]},S.id)),e[0]=r,e[1]=n,e[2]=a,e[3]=s,e[4]=l,e[5]=o,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v}else d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14];let _;e[18]!==u||e[19]!==f?(_=i.jsx("div",{className:u,children:f}),e[18]=u,e[19]=f,e[20]=_):_=e[20];let b;e[21]!==d||e[22]!==m||e[23]!==p||e[24]!==g||e[25]!==_?(b=i.jsxs(d,{className:m,children:[p,g,_]}),e[21]=d,e[22]=m,e[23]=p,e[24]=g,e[25]=_,e[26]=b):b=e[26];let y;return e[27]!==h||e[28]!==x||e[29]!==v||e[30]!==b?(y=i.jsx(h,{open:x,onOpenChange:v,children:b}),e[27]=h,e[28]=x,e[29]=v,e[30]=b,e[31]=y):y=e[31],y}function lo(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center justify-center h-32",children:i.jsx(Xe,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function _a(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?i.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:i.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[i.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:i.jsx(br,{className:"h-6 w-6 text-destructive"})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),i.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function Bp(t){const e=M.c(23),{item:s,isSelected:n,onToggle:r,disabled:o}=t,a=o?"cursor-not-allowed opacity-50":"cursor-pointer",l=n?"bg-accent/25":"hover:bg-muted/50";let c;e[0]!==a||e[1]!==l?(c=te("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=c):c=e[2];let d;e[3]!==s.name?(d=i.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=d):d=e[4];let h;e[5]!==s.tags?(h=s.tags&&i.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=h):h=e[6];let u;e[7]!==d||e[8]!==h?(u=i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d,h]}),e[7]=d,e[8]=h,e[9]=u):u=e[9];let f;e[10]!==s.description?(f=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let m;e[12]!==u||e[13]!==f?(m=i.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=m):m=e[14];let p;e[15]!==o||e[16]!==n||e[17]!==r?(p=i.jsx(kr,{checked:n,onCheckedChange:r,disabled:o,className:"mt-0.5"}),e[15]=o,e[16]=n,e[17]=r,e[18]=p):p=e[18];let g;return e[19]!==c||e[20]!==m||e[21]!==p?(g=i.jsxs("label",{className:c,children:[m,p]}),e[19]=c,e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function $9(t){const e=M.c(13),{items:s,selections:n,onToggle:r,emptyMessage:o,disabled:a}=t;let l,c,d;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r||e[4]!==n){d=Symbol.for("react.early_return_sentinel");e:{const u=s.map(jw);if(s.length===0){let f;e[8]!==o?(f=i.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:i.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:o})}),e[8]=o,e[9]=f):f=e[9],d=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",c=s.map(f=>i.jsx(Bp,{item:f,isSelected:n===null||n?.includes(f.id),onToggle:()=>r(f.id,u),disabled:a},f.id))}e[0]=a,e[1]=o,e[2]=s,e[3]=r,e[4]=n,e[5]=l,e[6]=c,e[7]=d}else l=e[5],c=e[6],d=e[7];if(d!==Symbol.for("react.early_return_sentinel"))return d;let h;return e[10]!==l||e[11]!==c?(h=i.jsx("div",{className:l,children:c}),e[10]=l,e[11]=c,e[12]=h):h=e[12],h}function jw(t){return t.id}function Cw(t){const e=M.c(18),{connectionId:s,toolSelections:n,onToggleTool:r}=t,{org:o}=Ee();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=ut(a);let c;e[4]!==l?(c={client:l},e[4]=l,e[5]=c):c=e[5];const{data:d}=Ym(c),h=d.tools;let u,f,m;if(e[6]!==d.tools||e[7]!==r||e[8]!==n){m=Symbol.for("react.early_return_sentinel");e:{const g=h.map(Vw);let x;e[12]!==n?(x=b=>n===null||n.includes(b.name),e[12]=n,e[13]=x):x=e[13];const _=d.tools.filter(x).map(kw);if(_.length===0){let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:i.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:"No active tools selected"})}),e[14]=b):b=e[14],m=b;break e}u="flex-1 overflow-auto px-4 py-3 space-y-1",f=_.map(b=>i.jsx(Bp,{item:b,isSelected:!0,onToggle:()=>r(b.id,g)},b.id))}e[6]=d.tools,e[7]=r,e[8]=n,e[9]=u,e[10]=f,e[11]=m}else u=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;let p;return e[15]!==u||e[16]!==f?(p=i.jsx("div",{className:u,children:f}),e[15]=u,e[16]=f,e[17]=p):p=e[17],p}function kw(t){return{id:t.name,name:t.name,description:t.description,tags:i.jsx(u2,{annotations:t.annotations,_meta:t._meta})}}function Vw(t){return t.name}function Nw(t){const e=M.c(13),{connectionId:s,selections:n,onToggle:r,disabled:o}=t,{org:a}=Ee();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ut(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Ym(d);let u;e[6]!==h.tools?(u=h.tools.map(Aw),e[6]=h.tools,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==n?(m=i.jsx($9,{items:f,selections:n,onToggle:r,emptyMessage:"No tools available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=n,e[12]=m):m=e[12],m}function Aw(t){return{id:t.name,name:t.name,description:t.description,tags:i.jsx(u2,{annotations:t.annotations,_meta:t._meta})}}function Tw(t){const e=M.c(13),{connectionId:s,selections:n,onToggle:r,disabled:o}=t,{org:a}=Ee();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ut(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=Y5(d);let u;e[6]!==h.resources?(u=h.resources.map(Ew),e[6]=h.resources,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==n?(m=i.jsx($9,{items:f,selections:n,onToggle:r,emptyMessage:"No resources available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=n,e[12]=m):m=e[12],m}function Ew(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Rw(t){const e=M.c(13),{connectionId:s,selections:n,onToggle:r,disabled:o}=t,{org:a}=Ee();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const c=ut(l);let d;e[4]!==c?(d={client:c},e[4]=c,e[5]=d):d=e[5];const{data:h}=xm(d);let u;e[6]!==h.prompts?(u=h.prompts.map(Pw),e[6]=h.prompts,e[7]=u):u=e[7];const f=u;let m;return e[8]!==o||e[9]!==f||e[10]!==r||e[11]!==n?(m=i.jsx($9,{items:f,selections:n,onToggle:r,emptyMessage:"No prompts available",disabled:o}),e[8]=o,e[9]=f,e[10]=r,e[11]=n,e[12]=m):m=e[12],m}function Pw(t){return{id:t.name,name:t.name,description:t.description}}function Iw(t){const e=M.c(61),{currentConnection:s,activeTab:n,selectedId:r,formData:o,toggleTool:a,toggleResource:l,togglePrompt:c,toggleAllTools:d,toggleAllResources:h,toggleAllPrompts:u,onTabChange:f}=t,m=o[r],p=n==="tools"?m?.tools===null:n==="resources"?m?.resources===null:n==="prompts"?m?.prompts===null:!1,g=n!=="active";let x;e[0]!==n||e[1]!==r||e[2]!==u||e[3]!==h||e[4]!==d?(x=()=>{n==="tools"?d(r):n==="resources"?h(r):n==="prompts"&&u(r)},e[0]=n,e[1]=r,e[2]=u,e[3]=h,e[4]=d,e[5]=x):x=e[5];const v=x;let _;e[6]!==s.icon||e[7]!==s.title?(_=i.jsx(on,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=_):_=e[8];let b;e[9]!==s.title?(b=i.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let y;e[11]!==s.description?(y=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=y):y=e[12];let L;e[13]!==b||e[14]!==y?(L=i.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[13]=b,e[14]=y,e[15]=L):L=e[15];let w;e[16]!==_||e[17]!==L?(w=i.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:i.jsxs("div",{className:"flex items-center gap-3",children:[_,L]})}),e[16]=_,e[17]=L,e[18]=w):w=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=[{id:"tools",label:"Tools"},{id:"active",label:"Active"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=S):S=e[19];let j;e[20]!==f?(j=I=>f(I),e[20]=f,e[21]=j):j=e[21];let C;e[22]!==n||e[23]!==j?(C=i.jsx(d2,{tabs:S,activeTab:n,onTabChange:j}),e[22]=n,e[23]=j,e[24]=C):C=e[24];let V;e[25]!==v||e[26]!==p||e[27]!==g?(V=g&&i.jsx("button",{type:"button",onClick:v,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:p?"Deselect all":"Select all"}),e[25]=v,e[26]=p,e[27]=g,e[28]=V):V=e[28];let N;e[29]!==V||e[30]!==C?(N=i.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[C,V]}),e[29]=V,e[30]=C,e[31]=N):N=e[31];let T;e[32]!==n||e[33]!==o||e[34]!==r||e[35]!==a?(T=n==="active"&&i.jsx(vs,{fallback:_a("Tools not supported by this server"),children:i.jsx(k.Suspense,{fallback:i.jsx(lo,{}),children:i.jsx(Cw,{connectionId:r,toolSelections:o[r]?o[r].tools:[],onToggleTool:(I,O)=>a(r,I,O)})})}),e[32]=n,e[33]=o,e[34]=r,e[35]=a,e[36]=T):T=e[36];let A;e[37]!==n||e[38]!==o||e[39]!==r||e[40]!==a?(A=n==="tools"&&i.jsx(vs,{fallback:_a("Tools not supported by this server"),children:i.jsx(k.Suspense,{fallback:i.jsx(lo,{}),children:i.jsx(Nw,{connectionId:r,selections:o[r]?o[r].tools:[],onToggle:(I,O)=>a(r,I,O)})})}),e[37]=n,e[38]=o,e[39]=r,e[40]=a,e[41]=A):A=e[41];let E;e[42]!==n||e[43]!==o||e[44]!==r||e[45]!==l?(E=n==="resources"&&i.jsx(vs,{fallback:_a("Resources not supported by this server"),children:i.jsx(k.Suspense,{fallback:i.jsx(lo,{}),children:i.jsx(Tw,{connectionId:r,selections:o[r]?o[r].resources:[],onToggle:(I,O)=>l(r,I,O)})})}),e[42]=n,e[43]=o,e[44]=r,e[45]=l,e[46]=E):E=e[46];let R;e[47]!==n||e[48]!==o||e[49]!==r||e[50]!==c?(R=n==="prompts"&&i.jsx(vs,{fallback:_a("Prompts not supported by this server"),children:i.jsx(k.Suspense,{fallback:i.jsx(lo,{}),children:i.jsx(Rw,{connectionId:r,selections:o[r]?o[r].prompts:[],onToggle:(I,O)=>c(r,I,O)})})}),e[47]=n,e[48]=o,e[49]=r,e[50]=c,e[51]=R):R=e[51];let D;e[52]!==T||e[53]!==A||e[54]!==E||e[55]!==R?(D=i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,A,E,R]}),e[52]=T,e[53]=A,e[54]=E,e[55]=R,e[56]=D):D=e[56];let P;return e[57]!==N||e[58]!==D||e[59]!==w?(P=i.jsxs(i.Fragment,{children:[w,N,D]}),e[57]=N,e[58]=D,e[59]=w,e[60]=P):P=e[60],P}function Dw(t){const e=M.c(11),{connectionId:s,onAuthenticate:n,children:r}=t;let o;e[0]!==s?(o={connectionId:s},e[0]=s,e[1]=o):o=e[1];const a=h2(o);if(a.supportsOAuth&&!a.isAuthenticated){let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:i.jsx(Pv,{size:22,className:"text-muted-foreground"})}),e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),i.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=h):h=e[3];let u;e[4]!==s||e[5]!==n?(u=n&&i.jsx(re,{variant:"outline",size:"sm",onClick:()=>n(s),children:"Authorize"}),e[4]=s,e[5]=n,e[6]=u):u=e[6];let f;return e[7]!==u?(f=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[d,h,u]}),e[7]=u,e[8]=f):f=e[8],f}let c;return e[9]!==r?(c=i.jsx(i.Fragment,{children:r}),e[9]=r,e[10]=c):c=e[10],c}function Ow(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Th(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Eh(t,e,s,n){const r=t[e]??{tools:null,resources:null,prompts:null};return{...t,[e]:{...r,[s]:n}}}function Mw(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function $w(t){const e=M.c(49),{open:s,onOpenChange:n,selectedId:r,form:o,connections:a,onAuthenticate:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activeTab:"tools"},e[0]=c):c=e[0];const[d,h]=k.useReducer(Mw,c),u=a9(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let m;e[3]!==f?(m=Ow(f),e[3]=f,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==p?(g=($,U,W,X)=>{const H=p[$]?.[U];let Z;H===null?Z=X.filter(K=>K!==W):H?.includes(W)?Z=H.filter(K=>K!==W):(Z=[...H??[],W],Z.length===X.length&&(Z=null)),o.setValue("connections",Th(Eh(p,$,U,Z)),{shouldDirty:!0,shouldTouch:!0})},e[5]=o,e[6]=p,e[7]=g):g=e[7];const x=g;let v;e[8]!==o||e[9]!==p?(v=($,U)=>{const X=p[$]?.[U]===null?[]:null;o.setValue("connections",Th(Eh(p,$,U,X)),{shouldDirty:!0,shouldTouch:!0})},e[8]=o,e[9]=p,e[10]=v):v=e[10];const _=v;let b;e[11]!==x?(b=($,U,W)=>x($,"tools",U,W),e[11]=x,e[12]=b):b=e[12];const y=b;let L;e[13]!==x?(L=($,U,W)=>x($,"resources",U,W),e[13]=x,e[14]=L):L=e[14];const w=L;let S;e[15]!==x?(S=($,U,W)=>x($,"prompts",U,W),e[15]=x,e[16]=S):S=e[16];const j=S;let C;e[17]!==_?(C=$=>_($,"tools"),e[17]=_,e[18]=C):C=e[18];const V=C;let N;e[19]!==_?(N=$=>_($,"resources"),e[19]=_,e[20]=N):N=e[20];const T=N;let A;e[21]!==_?(A=$=>_($,"prompts"),e[21]=_,e[22]=A):A=e[22];const E=A;if(!r||!u)return null;let R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(lo,{}),e[23]=R):R=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=$=>h({type:"SET_ACTIVE_TAB",payload:$}),e[24]=D):D=e[24];let P;e[25]!==u||e[26]!==d.activeTab||e[27]!==p||e[28]!==r||e[29]!==E||e[30]!==T||e[31]!==V||e[32]!==j||e[33]!==w||e[34]!==y?(P=i.jsx(Iw,{currentConnection:u,activeTab:d.activeTab,selectedId:r,formData:p,toggleTool:y,toggleResource:w,togglePrompt:j,toggleAllTools:V,toggleAllResources:T,toggleAllPrompts:E,onTabChange:D},r),e[25]=u,e[26]=d.activeTab,e[27]=p,e[28]=r,e[29]=E,e[30]=T,e[31]=V,e[32]=j,e[33]=w,e[34]=y,e[35]=P):P=e[35];let I;e[36]!==l||e[37]!==r||e[38]!==P?(I=i.jsx(k.Suspense,{fallback:R,children:i.jsx(Dw,{connectionId:r,onAuthenticate:l,children:P})}),e[36]=l,e[37]=r,e[38]=P,e[39]=I):I=e[39];let O;e[40]!==n?(O=i.jsx(Ei,{className:"px-6 py-4 border-t border-border shrink-0",children:i.jsx(re,{variant:"outline",onClick:()=>n(!1),children:"Done"})}),e[40]=n,e[41]=O):O=e[41];let B;e[42]!==I||e[43]!==O?(B=i.jsxs(Zt,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[I,O]}),e[42]=I,e[43]=O,e[44]=B):B=e[44];let z;return e[45]!==n||e[46]!==s||e[47]!==B?(z=i.jsx(es,{open:s,onOpenChange:n,children:B}),e[45]=n,e[46]=s,e[47]=B,e[48]=z):z=e[48],z}const Rh="__new_instance__";function Bw(t){const e=M.c(23),{connection_id:s,usedConnectionIds:n,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}=t,d=a9(s),{org:h}=Ee();if(!d)return null;let u;e[0]!==d?(u=g6(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]!==s?(m=i.jsx(Uw,{connection_id:s}),e[2]=s,e[3]=m):m=e[3];let p;e[4]!==d.app_name||e[5]!==d.connection_type||e[6]!==d.description||e[7]!==d.icon||e[8]!==d.status||e[9]!==d.title||e[10]!==s||e[11]!==a||e[12]!==c||e[13]!==r||e[14]!==o||e[15]!==l||e[16]!==h.slug||e[17]!==f||e[18]!==n?(p=i.jsx(Fw,{connection_id:s,connectionTitle:d.title,connectionDescription:d.description,connectionIcon:d.icon,connectionType:d.connection_type,connectionStatus:d.status,slug:f,orgSlug:h.slug,appName:d.app_name,usedConnectionIds:n,onOpenSettings:r,onRemove:o,onAuthenticate:a,onSwitchInstance:l,onNewInstance:c}),e[4]=d.app_name,e[5]=d.connection_type,e[6]=d.description,e[7]=d.icon,e[8]=d.status,e[9]=d.title,e[10]=s,e[11]=a,e[12]=c,e[13]=r,e[14]=o,e[15]=l,e[16]=h.slug,e[17]=f,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==m||e[21]!==p?(g=i.jsx(k.Suspense,{fallback:m,children:p}),e[20]=m,e[21]=p,e[22]=g):g=e[22],g}function zw(t){const e=M.c(23),{appName:s,connectionId:n,usedConnectionIds:r,onSwitchInstance:o,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const c=En(l);if(c.length<=1)return null;let d;e[2]!==n||e[3]!==a||e[4]!==o?(d=g=>{g===Rh?a?.():o(n,g)},e[2]=n,e[3]=a,e[4]=o,e[5]=d):d=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Xt,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:i.jsx(rs,{})}),e[6]=h):h=e[6];let u;if(e[7]!==n||e[8]!==c||e[9]!==r){let g;e[11]!==n||e[12]!==r?(g=x=>i.jsx(pt,{value:x.id,className:"text-xs",disabled:x.id!==n&&r.has(x.id),children:x.title},x.id),e[11]=n,e[12]=r,e[13]=g):g=e[13],u=c.map(g),e[7]=n,e[8]=c,e[9]=r,e[10]=u}else u=e[10];let f;e[14]!==a?(f=a&&i.jsx(pt,{value:Rh,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let m;e[16]!==u||e[17]!==f?(m=i.jsxs(Yt,{children:[u,f]}),e[16]=u,e[17]=f,e[18]=m):m=e[18];let p;return e[19]!==n||e[20]!==d||e[21]!==m?(p=i.jsxs(Jt,{value:n,onValueChange:d,children:[h,m]}),e[19]=n,e[20]=d,e[21]=m,e[22]=p):p=e[22],p}function Fw({connection_id:t,connectionTitle:e,connectionDescription:s,connectionIcon:n,connectionType:r,connectionStatus:o,slug:a,orgSlug:l,appName:c,usedConnectionIds:d,onOpenSettings:h,onRemove:u,onAuthenticate:f,onSwitchInstance:m,onNewInstance:p}){const g=h2({connectionId:t}),x=a2(),_=!(r==="VIRTUAL")&&g.supportsOAuth&&!g.isAuthenticated,b=o!=="active",y=async L=>{try{await x.update.mutateAsync({id:t,data:{status:L}}),de.success(L==="active"?"Connection enabled":"Connection disabled")}catch{de.error("Failed to update connection")}};return i.jsxs("div",{className:te("rounded-xl border overflow-hidden transition-colors",_||b?"border-destructive/50 bg-destructive/5":"border-border bg-card"),children:[i.jsxs(sm,{to:"/$org/settings/connections/$appSlug",params:{org:l,appSlug:a},className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[i.jsx(on,{icon:n,name:e,size:"sm",className:"shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm font-medium truncate",children:e}),_?i.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):b?i.jsx("span",{className:"text-xs text-destructive font-medium",children:o==="error"?"Disabled (error)":"Disabled"}):s&&i.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]}),_?i.jsx(re,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:L=>{L.preventDefault(),L.stopPropagation(),f(t)},children:"Authorize"}):b?i.jsxs(re,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 shrink-0",onClick:L=>{L.preventDefault(),L.stopPropagation(),y("active")},children:[i.jsx(Iv,{size:13}),"Enable"]}):i.jsxs(Oe,{delayDuration:0,children:[i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:i.jsx(ob,{size:16})})}),i.jsx(De,{side:"bottom",children:"Connection settings"})]})]}),i.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[c&&i.jsx(zw,{appName:c,connectionId:t,usedConnectionIds:d,onSwitchInstance:m,onNewInstance:p}),i.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[i.jsxs(Oe,{delayDuration:0,children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,"aria-label":"Configure resources",children:i.jsx(Vm,{size:13})})}),i.jsx(De,{side:"bottom",children:"Configure resources"})]}),!b&&i.jsxs(Oe,{delayDuration:0,children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>y("inactive"),"aria-label":"Disable connection",children:i.jsx(Dv,{size:13})})}),i.jsx(De,{side:"bottom",children:"Disable"})]}),i.jsxs(Oe,{delayDuration:0,children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:u,"aria-label":"Remove connection",children:i.jsx(Tn,{size:13})})}),i.jsx(De,{side:"bottom",children:"Remove"})]})]})]})]})}function Uw(t){const e=M.c(17),{connection_id:s}=t,n=a9(s);if(!n){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(zp,{}),e[0]=u):u=e[0],u}let r;e[1]!==n.icon||e[2]!==n.title?(r=i.jsx(on,{icon:n.icon,name:n.title,size:"sm",className:"shrink-0"}),e[1]=n.icon,e[2]=n.title,e[3]=r):r=e[3];let o;e[4]!==n.title?(o=i.jsx("p",{className:"text-sm font-medium truncate",children:n.title}),e[4]=n.title,e[5]=o):o=e[5];let a;e[6]!==n.description?(a=n.description&&i.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e[6]=n.description,e[7]=a):a=e[7];let l;e[8]!==o||e[9]!==a?(l=i.jsxs("div",{className:"flex-1 min-w-0",children:[o,a]}),e[8]=o,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==r||e[12]!==l?(c=i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=c):c=e[13];let d;e[14]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:i.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=d):d=e[14];let h;return e[15]!==c?(h=i.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[c,d]}),e[15]=c,e[16]=h):h=e[16],h}function zp(){const t=M.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),i.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let n;return t[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,i.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:i.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=n):n=t[2],n}function Hw(t){const e=M.c(5),{value:s}=t;let n;if(e[0]!==s){n=Symbol.for("react.early_return_sentinel");e:{const o=Kl(s);if(o.type==="icon"){const a=Ri(o.name);if(a){let l;e[2]!==a?(l=i.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],n=l;break e}}}e[0]=s,e[1]=n}else n=e[1];if(n!==Symbol.for("react.early_return_sentinel"))return n;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(x6,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function Kw(t){const e=M.c(66),{value:s,onChange:n,className:r,disabled:o}=t,[a,l]=k.useState(!1),[c,d]=k.useState("");let h;e[0]!==s?(h=Kl(s),e[0]=s,e[1]=h):h=e[1];const u=h,f=u.type==="icon"?u.name:null;let m,p,g,x,v,_,b,y,L,w,S,j,C,V,N;if(e[2]!==r||e[3]!==f||e[4]!==o||e[5]!==n||e[6]!==a||e[7]!==c||e[8]!==s){const I=qd();x=Pm(I,c),g=Ns,v=o?!1:a,_=l;const O=o?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let B;e[24]!==r||e[25]!==O?(B=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=B):B=e[26];let z;e[27]!==s?(z=i.jsx(Hw,{value:s}),e[27]=s,e[28]=z):z=e[28],e[29]!==o||e[30]!==B||e[31]!==z?(b=i.jsx(As,{asChild:!0,children:i.jsx("button",{type:"button",disabled:o,"aria-label":"Change icon",className:B,children:z})}),e[29]=o,e[30]=B,e[31]=z,e[32]=b):b=e[32],p=Ts,C="start",V="w-64 p-0",N=Ww,S="flex flex-col";let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=i.jsx(Po,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=$):$=e[33];let U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=X=>d(X.target.value),e[34]=U):U=e[34],e[35]!==c?(j=i.jsx("div",{className:"px-2 py-2",children:i.jsxs("div",{className:"relative",children:[$,i.jsx(tt,{value:c,onChange:U,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=c,e[36]=j):j=e[36],m=ti,w="h-48",y="grid grid-cols-8 gap-0.5 px-2 pb-2";let W;e[37]!==f||e[38]!==n?(W=X=>{const H=Ri(X);return H?i.jsx("button",{type:"button",onClick:()=>{n(`icon://${X}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===X?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:C0(X),"aria-label":C0(X),children:i.jsx(H,{size:16})},X):null},e[37]=f,e[38]=n,e[39]=W):W=e[39],L=x.map(W),e[2]=r,e[3]=f,e[4]=o,e[5]=n,e[6]=a,e[7]=c,e[8]=s,e[9]=m,e[10]=p,e[11]=g,e[12]=x,e[13]=v,e[14]=_,e[15]=b,e[16]=y,e[17]=L,e[18]=w,e[19]=S,e[20]=j,e[21]=C,e[22]=V,e[23]=N}else m=e[9],p=e[10],g=e[11],x=e[12],v=e[13],_=e[14],b=e[15],y=e[16],L=e[17],w=e[18],S=e[19],j=e[20],C=e[21],V=e[22],N=e[23];let T;e[40]!==y||e[41]!==L?(T=i.jsx("div",{className:y,children:L}),e[40]=y,e[41]=L,e[42]=T):T=e[42];let A;e[43]!==x.length?(A=x.length===0&&i.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=x.length,e[44]=A):A=e[44];let E;e[45]!==m||e[46]!==T||e[47]!==A||e[48]!==w?(E=i.jsxs(m,{className:w,children:[T,A]}),e[45]=m,e[46]=T,e[47]=A,e[48]=w,e[49]=E):E=e[49];let R;e[50]!==E||e[51]!==S||e[52]!==j?(R=i.jsxs("div",{className:S,children:[j,E]}),e[50]=E,e[51]=S,e[52]=j,e[53]=R):R=e[53];let D;e[54]!==p||e[55]!==R||e[56]!==C||e[57]!==V||e[58]!==N?(D=i.jsx(p,{align:C,className:V,onOpenAutoFocus:N,children:R}),e[54]=p,e[55]=R,e[56]=C,e[57]=V,e[58]=N,e[59]=D):D=e[59];let P;return e[60]!==g||e[61]!==v||e[62]!==_||e[63]!==b||e[64]!==D?(P=i.jsxs(g,{open:v,onOpenChange:_,children:[b,D]}),e[60]=g,e[61]=v,e[62]=_,e[63]=b,e[64]=D,e[65]=P):P=e[65],P}function Ww(t){return t.preventDefault()}function qw({virtualMcpId:t,form:e,flushAndSave:s}){const n=Ms(),r=fs(t),o=(r?.connections??[]).map(T=>T.connection_id).sort(),{data:a}=Ut({queryKey:it.projectConnectionDetails(t,o),enabled:o.length>0,queryFn:async()=>await Promise.all(o.map(async A=>{try{const{item:E}=await n.call("COLLECTION_CONNECTIONS_GET",{id:A}),R=(E?.tools??[]).flatMap(D=>{const P=Xl(D._meta);return P?[{name:D.name,title:D.title,description:D.description,resourceUri:P}]:[]});return{fetchOk:!0,id:A,title:E?.title??A,icon:E?.icon??null,uiTools:R}}catch{return{fetchOk:!1,id:A,title:A,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(T=>T.uiTools.length>0),c=new Set(Xb),d=e.watch("metadata.ui.pinnedViews")??[],h=e.watch("metadata.ui.layout")??null,u=h?.defaultMainView??null,f=h?.chatDefaultOpen??!1,m=!u||u.type==="chat"?"chat":u.type==="instructions"||u.type==="connections"||u.type==="layout"?"settings":c.has(u.type)?u.type:`${u.type}:${u.id??""}:${u.toolName??""}`,p=T=>{const[A,E,R]=T.split(":");return A?A==="chat"?{type:A}:c.has(A)?{type:A}:A==="ext-apps"&&E?{type:"ext-apps",id:E,toolName:R||void 0}:null:null},g=T=>{e.setValue("metadata.ui.pinnedViews",T,{shouldDirty:!0})},x=T=>{e.setValue("metadata.ui.layout",{...h,...T},{shouldDirty:!0})},v=k.useRef(!1);if(a&&a.length>0&&!v.current){v.current=!0;const T=new Set((a??[]).filter(R=>R.fetchOk).map(R=>R.id)),A=new Set(l.flatMap(R=>R.uiTools.map(D=>`${R.id}:${D.name}`))),E=d.filter(R=>!T.has(R.connectionId)||A.has(`${R.connectionId}:${R.toolName}`));E.length!==d.length&&(g(E),u?.type==="ext-apps"&&!E.some(R=>R.connectionId===u.id&&R.toolName===u.toolName)&&x({defaultMainView:{type:"chat"}}))}const _=(T,A)=>{if(d.some(R=>R.connectionId===T&&R.toolName===A)){const R=d.filter(P=>!(P.connectionId===T&&P.toolName===A));g(R);const D=`ext-apps:${T}:${A}`;m===D&&x({defaultMainView:{type:"chat"}})}else{const R=l.find(D=>D.id===T)?.uiTools.find(D=>D.name===A)?.title;g([...d,{connectionId:T,toolName:A,label:R??yi(A),icon:null}])}s()},b=(T,A,E)=>{g(d.map(R=>R.connectionId===T&&R.toolName===A?{...R,label:E}:R))},y=()=>{s()},L=(T,A,E)=>{g(d.map(R=>R.connectionId===T&&R.toolName===A?{...R,icon:E}:R)),s()},w=T=>{x({defaultMainView:p(T)}),s()},S=o.length===0,j=a&&l.length===0,C=tn(r?.metadata),V=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];C&&V.push({value:"preview",label:"Preview"});for(const T of d)V.push({value:`ext-apps:${T.connectionId}:${T.toolName}`,label:T.label||T.toolName});const N=l.length>0||S||j;return i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("div",{className:"flex items-center justify-between gap-3",children:i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),i.jsxs(c9,{className:"p-6 gap-5",children:[i.jsxs(ml,{className:"p-0 space-y-5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"space-y-0.5 min-w-0",children:[i.jsx(rt,{className:"font-normal text-foreground",children:"Main view"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),i.jsxs(Jt,{value:m,onValueChange:w,children:[i.jsx(Xt,{className:"w-44 h-8 text-sm capitalize shrink-0",children:i.jsx(rs,{})}),i.jsx(Yt,{children:V.map(T=>i.jsx(pt,{value:T.value,className:"capitalize",children:T.label},T.value))})]})]}),i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"space-y-0.5 min-w-0",children:[i.jsx(rt,{className:"font-normal text-foreground",children:"Show chat"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Display Chat in the side panel alongside the main view."})]}),i.jsxs(Oe,{delayDuration:0,children:[i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"shrink-0",children:i.jsx(hr,{checked:m==="chat"?!0:f,disabled:m==="chat",onCheckedChange:T=>{x({chatDefaultOpen:T}),s()}})})}),m==="chat"&&i.jsx(De,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),N&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"border-t border-border -mx-6"}),i.jsxs(ml,{className:"p-0 space-y-3",children:[i.jsx("div",{className:"flex items-center justify-between gap-4",children:i.jsxs("div",{className:"space-y-0.5 min-w-0",children:[i.jsx(rt,{className:"font-normal text-foreground",children:"Pinned views"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),S&&i.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),j&&!S&&i.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&i.jsx("div",{className:"space-y-4 pt-1",children:l.map((T,A)=>i.jsxs("div",{children:[A>0&&i.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),i.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[i.jsx(on,{icon:T.icon,name:T.title,size:"xs",className:"shrink-0"}),i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:T.title})]}),i.jsx("div",{className:"space-y-1.5",children:T.uiTools.map(E=>{const R=d.some(P=>P.connectionId===T.id&&P.toolName===E.name),D=d.find(P=>P.connectionId===T.id&&P.toolName===E.name);return i.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",R?"bg-accent/40 border-border":"bg-transparent border-border"),children:[i.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[i.jsx(Kw,{value:D?.icon??null,onChange:P=>L(T.id,E.name,P),disabled:!R}),i.jsx(tt,{value:R&&D?D.label:E.title??yi(E.name),onChange:P=>b(T.id,E.name,P.target.value),onBlur:y,className:"h-7 text-sm w-40",disabled:!R,readOnly:!R})]}),i.jsx(hr,{checked:R,onCheckedChange:()=>_(T.id,E.name)})]},E.name)})})]},T.id))})]})]})]})]})}const Kc={tools:null,resources:null,prompts:null},Gw=J5.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Yw(t){const s=new TextEncoder().encode(t),n=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(n)}function Jw(t){const e=M.c(11),{url:s,agentId:n}=t,[r,o]=k.useState(!1);let a;e[0]!==n||e[1]!==s?(a=async()=>{Ne("agent_connect_action",{agent_id:n,action:"copy_url"}),await navigator.clipboard.writeText(s),o(!0),de.success("Agent URL copied to clipboard"),setTimeout(()=>o(!1),2e3)},e[0]=n,e[1]=s,e[2]=a):a=e[2];const l=a;let c;e[3]!==r?(c=r?i.jsx(Ot,{size:20,className:"text-success"}):i.jsx(Ds,{size:20}),e[3]=r,e[4]=c):c=e[4];const d=r?"Copied!":"Copy URL";let h;e[5]!==d?(h=i.jsx("span",{className:"text-xs font-medium",children:d}),e[5]=d,e[6]=h):h=e[6];let u;return e[7]!==l||e[8]!==c||e[9]!==h?(u=i.jsxs(re,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,h]}),e[7]=l,e[8]=c,e[9]=h,e[10]=u):u=e[10],u}function Xw(t){const e=M.c(8),{url:s,serverName:n,agentId:r}=t;let o;e[0]!==r||e[1]!==n||e[2]!==s?(o=()=>{Ne("agent_connect_action",{agent_id:r,action:"install_cursor"});const h=f2(n),f=Yw(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(h)}&config=${encodeURIComponent(f)}`;window.open(m,"_blank"),de.success("Opening Cursor...")},e[0]=r,e[1]=n,e[2]=s,e[3]=o):o=e[3];const a=o;let l,c;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),c=i.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=c):(l=e[4],c=e[5]);let d;return e[6]!==a?(d=i.jsxs(re,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,c]}),e[6]=a,e[7]=d):d=e[7],d}function Qw(t){const e=M.c(12),{url:s,serverName:n,agentId:r}=t,[o,a]=k.useState(!1);let l;e[0]!==r||e[1]!==n||e[2]!==s?(l=async()=>{Ne("agent_connect_action",{agent_id:r,action:"install_claude_code"});const m=f2(n),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),x=`claude mcp add-json "${m}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(x),a(!0),de.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=n,e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==o?(d=o?i.jsx(Ot,{size:20,className:"text-success"}):i.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=o,e[5]=d):d=e[5];const h=o?"Copied!":"Install on Claude Code";let u;e[6]!==h?(u=i.jsx("span",{className:"text-xs font-medium",children:h}),e[6]=h,e[7]=u):u=e[7];let f;return e[8]!==c||e[9]!==d||e[10]!==u?(f=i.jsxs(re,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,u]}),e[8]=c,e[9]=d,e[10]=u,e[11]=f):f=e[11],f}function Zw({virtualMcp:t}){const e=Ms(),[s,n]=k.useState(null),[r,o]=k.useState(!1),[a,l]=k.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,h=s?`bunx @decocms/typegen@latest --mcp ${c} --key ${s} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,u=async()=>{o(!0);try{const{key:m}=await e.call("API_KEY_CREATE",{name:`typegen-${d}`,permissions:{[c]:["*"]}});if(!m)throw new Error("No key in response");n(m),Ne("agent_typegen_key_generated",{agent_id:c})}catch{Ne("agent_typegen_key_failed",{agent_id:c}),de.error("Failed to generate API key")}finally{o(!1)}},f=async()=>{Ne("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!s}),await navigator.clipboard.writeText(h),l(!0),de.success("Command copied to clipboard"),setTimeout(()=>l(!1),2e3)};return i.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",i.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!s&&i.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:u,disabled:r,children:[r?i.jsx(Xe,{size:14,className:"animate-spin"}):i.jsx(u9,{size:14}),i.jsx("span",{children:r?"Generating…":"Generate API key"})]})]}),s&&i.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:"Store this key securely — it won't be shown again."}),i.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),i.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:h}),i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:f,children:a?i.jsx(Ot,{size:12,className:"text-success"}):i.jsx(Ds,{size:12})})]})}),i.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),i.jsx(ej,{apiKey:s,agentId:c})]})}function ej(t){const e=M.c(21),{apiKey:s,agentId:n}=t,[r,o]=k.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",c=`MESH_BASE_URL=${a}`,d=`${l}
11
+ ${c}`;let h;e[0]!==n||e[1]!==s||e[2]!==d?(h=async()=>{Ne("agent_connect_action",{agent_id:n,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(d),o(!0),setTimeout(()=>o(!1),2e3)},e[0]=n,e[1]=s,e[2]=d,e[3]=h):h=e[3];const u=h,f=!s;let m;e[4]!==f?(m=te({"opacity-50":f}),e[4]=f,e[5]=m):m=e[5];let p;e[6]!==l||e[7]!==m?(p=i.jsx("span",{className:m,children:l}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let g,x;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("br",{}),x=i.jsx("span",{children:c}),e[9]=g,e[10]=x):(g=e[9],x=e[10]);let v;e[11]!==p?(v=i.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[p,g,x]}),e[11]=p,e[12]=v):v=e[12];let _;e[13]!==r?(_=r?i.jsx(Ot,{size:12,className:"text-success"}):i.jsx(Ds,{size:12}),e[13]=r,e[14]=_):_=e[14];let b;e[15]!==u||e[16]!==_?(b=i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:_}),e[15]=u,e[16]=_,e[17]=b):b=e[17];let y;return e[18]!==v||e[19]!==b?(y=i.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:i.jsxs("div",{className:"flex items-start gap-2",children:[v,b]})}),e[18]=v,e[19]=b,e[20]=y):y=e[20],y}function tj(t){const e=M.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(k.Suspense,{fallback:n,children:i.jsx(Zw,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}const sj={self:["COLLECTION_THREADS_CREATE","COLLECTION_THREADS_GET","COLLECTION_THREAD_MESSAGES_LIST","COLLECTION_THREADS_LIST"]},nj=3600*24*90;function ij({virtualMcp:t}){const e=Ms(),{org:s}=Ee(),[n,r]=k.useState(null),[o,a]=k.useState(!1),[l,c]=k.useState(!1),d=t.id,h=t.title||`agent-${d.slice(0,8)}`,f=[`MESH_BASE_URL=${window.location.origin}`,`MESH_ORG=${s.slug}`,`MESH_AGENT_ID=${d}`,`MESH_API_KEY=${n??"<api-key>"}`].join(`
12
+ `),m=async()=>{a(!0);try{const{key:g}=await e.call("API_KEY_CREATE",{name:`chat-bridge-${h}`,permissions:sj,expiresIn:nj});if(!g)throw new Error("No key in response");r(g),Ne("agent_chat_bridge_key_generated",{agent_id:d})}catch{Ne("agent_chat_bridge_key_failed",{agent_id:d}),de.error("Failed to create API key")}finally{a(!1)}},p=async()=>{Ne("agent_connect_action",{agent_id:d,action:"chat_bridge_copy_env",has_api_key:!!n}),await navigator.clipboard.writeText(f),c(!0),de.success("Connection details copied to clipboard"),setTimeout(()=>c(!1),2e3)};return i.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3",children:[i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Call from your app"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Create a scoped API key to start a thread, run this agent, and stream results from an external system (e.g. a chatbot webhook)."})]}),!n&&i.jsxs(re,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:o,children:[o?i.jsx(Xe,{size:14,className:"animate-spin"}):i.jsx(u9,{size:14}),i.jsx("span",{children:o?"Creating…":"Create API key"})]})]}),n&&i.jsx("p",{className:"rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs text-warning",children:"Store this key securely — it won't be shown again."}),i.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Connection details"}),i.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("code",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:f}),i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:p,children:l?i.jsx(Ot,{size:12,className:"text-success"}):i.jsx(Ds,{size:12})})]})})]})}function rj(t){const e=M.c(3),{virtualMcp:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(k.Suspense,{fallback:n,children:i.jsx(ij,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function oj(t){const e=M.c(41),{open:s,onOpenChange:n,virtualMcp:r}=t,{org:o}=Ee(),a=`/api/${o.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const c=l;let d;e[2]!==r.id||e[3]!==r.title?(d=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=d):d=e[4];const h=d,u=Lr();let f;e[5]!==r.id||e[6]!==c.href?(f=i.jsx(Jw,{url:c.href,agentId:r.id}),e[5]=r.id,e[6]=c.href,e[7]=f):f=e[7];let m,p;e[8]!==h||e[9]!==r.id||e[10]!==c.href?(m=i.jsx(Xw,{url:c.href,serverName:h,agentId:r.id}),p=i.jsx(Qw,{url:c.href,serverName:h,agentId:r.id}),e[8]=h,e[9]=r.id,e[10]=c.href,e[11]=m,e[12]=p):(m=e[11],p=e[12]);let g;e[13]!==f||e[14]!==m||e[15]!==p?(g=i.jsx("div",{className:"flex flex-col gap-3 pt-2",children:i.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,m,p]})}),e[13]=f,e[14]=m,e[15]=p,e[16]=g):g=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("div",{className:"border-t border-border"}),e[17]=x):x=e[17];let v;e[18]!==r?(v=i.jsx(tj,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("div",{className:"border-t border-border"}),e[20]=_):_=e[20];let b;e[21]!==r?(b=i.jsx(rj,{virtualMcp:r}),e[21]=r,e[22]=b):b=e[22];let y;e[23]!==b||e[24]!==g||e[25]!==v?(y=i.jsxs("div",{className:"flex flex-col gap-6",children:[g,x,v,_,b]}),e[23]=b,e[24]=g,e[25]=v,e[26]=y):y=e[26];const L=y;if(u){let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(fm,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[27]=C):C=e[27];let V;e[28]!==L?(V=i.jsx(mm,{children:i.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,L]})}),e[28]=L,e[29]=V):V=e[29];let N;return e[30]!==n||e[31]!==s||e[32]!==V?(N=i.jsx(pm,{open:s,onOpenChange:n,children:V}),e[30]=n,e[31]=s,e[32]=V,e[33]=N):N=e[33],N}let w;e[34]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(us,{children:i.jsx(hs,{children:"Connect"})}),e[34]=w):w=e[34];let S;e[35]!==L?(S=i.jsxs(Zt,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[w,L]}),e[35]=L,e[36]=S):S=e[36];let j;return e[37]!==n||e[38]!==s||e[39]!==S?(j=i.jsx(es,{open:s,onOpenChange:n,children:S}),e[37]=n,e[38]=s,e[39]=S,e[40]=j):j=e[40],j}function aj(t){const e=M.c(43),{virtualMcp:s}=t,n=Xo(),r=Ud(),[o,a]=k.useState(!1);let l,c,d,h,u,f,m,p,g;if(e[0]!==r||e[1]!==n||e[2]!==s.id||e[3]!==s.metadata){g=Symbol.for("react.early_return_sentinel");e:{const L=n9(n);if(Za(s.id)||tn(s.metadata)||L.has(s.id)){g=null;break e}let w;e[13]!==n||e[14]!==s.id?(w=(n??[]).find(R=>R.metadata?.liveAgentId===s.id)??null,e[13]=n,e[14]=s.id,e[15]=w):w=e[15];const S=w,j=S?.id??null;let C;e[16]!==r.update?(C=(R,D)=>r.update.mutateAsync({id:R,data:{metadata:{liveAgentId:D}}}).catch(cj),e[16]=r.update,e[17]=C):C=e[17];const V=C;let N;e[18]!==V||e[19]!==s.id?(N=R=>{V(R,s.id)},e[18]=V,e[19]=s.id,e[20]=N):N=e[20],d=N;let T;e[21]!==j||e[22]!==V?(T=()=>{j&&V(j,null)},e[21]=j,e[22]=V,e[23]=T):T=e[23];const A=T,E=(n??[]).filter(R=>R.id!==s.id&&tn(R.metadata)&&!L.has(R.id));m="flex flex-col gap-3",e[24]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Development agent"}),e[24]=p):p=e[24],c=c9,f="p-6 gap-4",l=ml,h="p-0 space-y-4",u=j?i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[i.jsx("span",{className:"text-sm text-foreground truncate",children:S?S.title:j}),i.jsx("span",{className:"text-xs text-muted-foreground",children:"Linked dev agent — its sandbox dev server powers the Develop/Live toggle in the header."})]}),i.jsx(re,{variant:"outline",size:"sm",className:"shrink-0",onClick:A,children:"Unlink"})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Link a GitHub-backed dev agent. Its sandbox dev server powers a Develop/Live toggle so you can develop and test this agent's MCP app."}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsxs(re,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>a(!0),children:[i.jsx(Io,{className:"size-4"}),"Import from GitHub"]}),E.length>0?i.jsxs(Jt,{onValueChange:d,children:[i.jsx(Xt,{size:"sm",className:"w-56",children:i.jsx(rs,{placeholder:"Or link an existing dev agent…"})}),i.jsx(Yt,{children:E.map(lj)})]}):null]})]})}e[0]=r,e[1]=n,e[2]=s.id,e[3]=s.metadata,e[4]=l,e[5]=c,e[6]=d,e[7]=h,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g}else l=e[4],c=e[5],d=e[6],h=e[7],u=e[8],f=e[9],m=e[10],p=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let x;e[25]!==l||e[26]!==h||e[27]!==u?(x=i.jsx(l,{className:h,children:u}),e[25]=l,e[26]=h,e[27]=u,e[28]=x):x=e[28];let v;e[29]!==c||e[30]!==f||e[31]!==x?(v=i.jsx(c,{className:f,children:x}),e[29]=c,e[30]=f,e[31]=x,e[32]=v):v=e[32];let _;e[33]!==d?(_=L=>{const{virtualMcpId:w}=L;a(!1),d(w)},e[33]=d,e[34]=_):_=e[34];let b;e[35]!==o||e[36]!==_?(b=i.jsx(m2,{open:o,onOpenChange:a,title:"Import a dev agent from GitHub",onImportComplete:_}),e[35]=o,e[36]=_,e[37]=b):b=e[37];let y;return e[38]!==b||e[39]!==m||e[40]!==p||e[41]!==v?(y=i.jsxs("div",{className:m,children:[p,v,b]}),e[38]=b,e[39]=m,e[40]=p,e[41]=v,e[42]=y):y=e[42],y}function lj(t){return i.jsx(pt,{value:t.id,children:t.title},t.id)}function cj(){}const dj=/^[A-Za-z_][A-Za-z0-9_]*$/;function uj(t){const e={},s=t.split(/\r?\n/);for(let n=0;n<s.length;n++){let r=(s[n]??"").trim();if(!r||r.startsWith("#"))continue;r.startsWith("export ")&&(r=r.slice(7).trim());const o=r.indexOf("=");if(o<0)throw new Error(`Line ${n+1}: missing '='`);const a=r.slice(0,o).trim();if(!dj.test(a))throw new Error(`Line ${n+1}: invalid key "${a}"`);let l=r.slice(o+1).trim();l.length>=2&&(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[a]=l}return e}const hj=/^[A-Za-z0-9_.-]+$/;function fj(t){const e=M.c(14),{control:s,form:n,virtualMcpId:r,orgSlug:o}=t;let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"flex items-baseline justify-between gap-2",children:i.jsx(rt,{className:"font-normal text-foreground",children:"Environment variables"})}),l=i.jsx("p",{className:"text-xs text-muted-foreground",children:"Injected into the sandbox on every start. Reference an org/user secret to keep values out of metadata; literals are stored inline."}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let c;e[2]!==s||e[3]!==n||e[4]!==o||e[5]!==r?(c=i.jsx(pj,{control:s,form:n,virtualMcpId:r,orgSlug:o}),e[2]=s,e[3]=n,e[4]=o,e[5]=r,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Et,{className:"h-9 w-full"}),e[7]=d):d=e[7];let h;e[8]!==s||e[9]!==n?(h=i.jsx(vs,{fallback:mj,children:i.jsx(k.Suspense,{fallback:d,children:i.jsx(xj,{control:s,form:n})})}),e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==c||e[12]!==h?(u=i.jsxs("div",{className:"space-y-2",children:[a,l,c,h]}),e[11]=c,e[12]=h,e[13]=u):u=e[13],u}function mj(t){const{error:e}=t;return i.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:e?.message??"Failed to load secrets"})}function pj(t){const e=M.c(24),{control:s,form:n,virtualMcpId:r,orgSlug:o}=t,l=Ai.useSession().data?.user?.id,c="metadata.runtime.env",d="metadata.sandboxMap";let h;e[0]!==n?(h=()=>JSON.stringify(Ph(n.getValues(c))),e[0]=n,e[1]=h):h=e[1];const[u,f]=k.useState(h);let m;e[2]!==s?(m={control:s,name:c},e[2]=s,e[3]=m):m=e[3];const p=nm(m);let g;e[4]!==p?(g=JSON.stringify(Ph(p)),e[4]=p,e[5]=g):g=e[5];const x=g,v=x!==u;let _;e[6]!==n?(_=n.getValues(d),e[6]=n,e[7]=_):_=e[7];const b=_;let y;e[8]!==b||e[9]!==l?(y=l?Object.keys(b?.[l]??{}):[],e[8]=b,e[9]=l,e[10]=y):y=e[10];const L=y,w=L.length>0,[S,j]=k.useState(!1);if(!v||!w)return null;let C;e[11]!==x||e[12]!==o||e[13]!==L||e[14]!==r?(C=async()=>{j(!0);const R=await Promise.allSettled(L.map(async P=>{const I=`/api/${encodeURIComponent(o)}/sandbox/${encodeURIComponent(r)}/${encodeURIComponent(P)}/setup/start`,O=await fetch(I,{method:"POST"});if(!O.ok){const B=await O.text().catch(()=>O.statusText);throw new Error(B||O.statusText)}}));j(!1);const D=R.filter(gj).length;D===0?(f(x),de.success(L.length===1?"Restarted dev with new env":`Restarted ${L.length} branches with new env`)):de.error(`Failed to restart ${D} of ${L.length} branch(es)`)},e[11]=x,e[12]=o,e[13]=L,e[14]=r,e[15]=C):C=e[15];const V=C;let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-warning",children:[i.jsx(br,{className:"size-3.5 shrink-0"}),i.jsx("span",{className:"truncate",children:"Your sandbox is running. Restart the dev script to apply the new env."})]}),e[16]=N):N=e[16];let T;e[17]!==S?(T=S?i.jsx(Xe,{className:"size-3.5 animate-spin"}):i.jsx(ir,{className:"size-3.5"}),e[17]=S,e[18]=T):T=e[18];const A=S?"Restarting…":"Restart dev";let E;return e[19]!==V||e[20]!==S||e[21]!==T||e[22]!==A?(E=i.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-warning/20 bg-warning/10 px-3 py-2 text-xs",children:[N,i.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:V,disabled:S,className:"shrink-0",children:[T,A]})]}),e[19]=V,e[20]=S,e[21]=T,e[22]=A,e[23]=E):E=e[23],E}function gj(t){return t.status==="rejected"}function xj(t){const e=M.c(48),{control:s,form:n}=t,r="metadata.runtime.env";let o;e[0]!==s?(o={control:s,name:r},e[0]=s,e[1]=o):o=e[1];const a=X5(o),{fields:l,append:c,remove:d}=a;let h;e[2]!==n?(h=(R,D)=>{n.setValue(`${r}.${R}`,D,{shouldDirty:!0,shouldTouch:!0})},e[2]=n,e[3]=h):h=e[3];const u=h,f=b6();let m;if(e[4]!==f){m=new Map;for(const R of f)m.set(R.id,R);e[4]=f,e[5]=m}else m=e[5];const[p,g]=k.useState(null);let x;e[6]!==c?(x=()=>{c({key:"",kind:"literal",value:""})},e[6]=c,e[7]=x):x=e[7];const v=x;let _;e[8]!==c||e[9]!==n?(_=async()=>{let R;try{R=await navigator.clipboard.readText()}catch{de.error("Couldn't read clipboard");return}if(!R.trim()){de.error("Clipboard is empty");return}let D;try{D=uj(R)}catch($){const U=$;de.error(U.message);return}const P=Object.entries(D);if(P.length===0){de.error("Nothing to add");return}const I=n.getValues(r)??[],O=new Set;for(const $ of I){const U=($.key??"").trim();U&&O.add(U)}let B=0,z=0;for(const[$,U]of P){if(O.has($)){z++;continue}c({key:$,kind:"literal",value:U}),O.add($),B++}B===0&&z>0?de.message(`All ${z} key${z===1?"":"s"} already exist`):de.success(z>0?`Added ${B} var${B===1?"":"s"} (${z} already existed)`:`Added ${B} var${B===1?"":"s"}`)},e[8]=c,e[9]=n,e[10]=_):_=e[10];const b=_;let y;if(e[11]!==s||e[12]!==l||e[13]!==n||e[14]!==d||e[15]!==m||e[16]!==f||e[17]!==u){let R;e[19]!==s||e[20]!==n||e[21]!==d||e[22]!==m||e[23]!==f||e[24]!==u?(R=(D,P)=>i.jsx("li",{className:"rounded-md border border-border bg-background",children:i.jsx(vj,{index:P,control:s,form:n,onUpdateEntry:u,fieldPath:r,secrets:f,secretById:m,onSaveAsSecret:(I,O)=>g({kind:"save-literal",index:P,presetKey:I,presetValue:O}),onCreateNewSecret:I=>g({kind:"create-new",index:P,presetKey:I}),onRemove:()=>d(P)})},D.id),e[19]=s,e[20]=n,e[21]=d,e[22]=m,e[23]=f,e[24]=u,e[25]=R):R=e[25],y=l.map(R),e[11]=s,e[12]=l,e[13]=n,e[14]=d,e[15]=m,e[16]=f,e[17]=u,e[18]=y}else y=e[18];let L;e[26]!==y?(L=i.jsx("ul",{className:"space-y-2",children:y}),e[26]=y,e[27]=L):L=e[27];let w;e[28]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(kt,{className:"size-3.5"}),e[28]=w):w=e[28];let S;e[29]!==v?(S=i.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:v,className:"flex-1",children:[w,"Add env var"]}),e[29]=v,e[30]=S):S=e[30];let j;e[31]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Cm,{className:"size-3.5"}),e[31]=j):j=e[31];let C;e[32]!==b?(C=i.jsx(Ie,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:b,"aria-label":"Paste .env",children:[j,"Paste .env"]})}),e[32]=b,e[33]=C):C=e[33];let V;e[34]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(De,{children:"Read a .env blob from the clipboard. Each pair is staged as a literal — save individual rows as secrets after."}),e[34]=V):V=e[34];let N;e[35]!==C?(N=i.jsxs(Oe,{children:[C,V]}),e[35]=C,e[36]=N):N=e[36];let T;e[37]!==N||e[38]!==S?(T=i.jsxs("div",{className:"flex items-center gap-2",children:[S,N]}),e[37]=N,e[38]=S,e[39]=T):T=e[39];let A;e[40]!==p||e[41]!==n||e[42]!==u?(A=p!==null?i.jsx(yj,{mode:p,onClose:()=>g(null),onSaved:R=>{const D=n.getValues(`${r}.${p.index}.key`)?.trim()??"";u(p.index,{key:D,kind:"secret",secretId:R}),g(null)}}):null,e[40]=p,e[41]=n,e[42]=u,e[43]=A):A=e[43];let E;return e[44]!==T||e[45]!==A||e[46]!==L?(E=i.jsxs("div",{className:"space-y-2",children:[L,T,A]}),e[44]=T,e[45]=A,e[46]=L,e[47]=E):E=e[47],E}function vj(t){const e=M.c(55),{index:s,control:n,form:r,onUpdateEntry:o,fieldPath:a,secrets:l,secretById:c,onSaveAsSecret:d,onCreateNewSecret:h,onRemove:u}=t,f=`${a}.${s}.key`,m=`${a}.${s}.value`,p=`${a}.${s}.secretId`,g=`${a}.${s}.kind`;let x;e[0]!==n||e[1]!==g?(x={control:n,name:g},e[0]=n,e[1]=g,e[2]=x):x=e[2];const _=nm(x)==="secret"?"secret":"literal";let b;e[3]!==r||e[4]!==s||e[5]!==f||e[6]!==d||e[7]!==o||e[8]!==m?(b=B=>{const z=r.getValues(f)?.trim()??"";if(B==="literal"){o(s,{key:z,kind:"literal",value:""});return}const $=r.getValues(m)??"";if($.length>0){d(z,$);return}o(s,{key:z,kind:"secret",secretId:""})},e[3]=r,e[4]=s,e[5]=f,e[6]=d,e[7]=o,e[8]=m,e[9]=b):b=e[9];const y=b;let L;e[10]!==s?(L=B=>{const{field:z}=B,$=(z.value??"").trim(),U=$.length>0&&!Fl.test($);return i.jsxs("div",{className:"space-y-1",children:[i.jsx(tt,{...z,value:z.value??"",placeholder:"KEY",spellCheck:!1,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",className:te("font-mono",U&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":U,"aria-label":`Env var ${s+1} key`,onBlur:W=>{const X=W.target.value.trim();z.onChange(X),z.onBlur()}}),U?i.jsx("p",{className:"text-[11px] text-destructive",children:"Letters, digits, underscores. Must start with a letter or underscore."}):null]})},e[10]=s,e[11]=L):L=e[11];let w;e[12]!==n||e[13]!==f||e[14]!==L?(w=i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx(ws,{control:n,name:f,render:L})}),e[12]=n,e[13]=f,e[14]=L,e[15]=w):w=e[15];let S;e[16]!==y?(S=B=>y(B),e[16]=y,e[17]=S):S=e[17];let j;e[18]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Xt,{className:"h-9 w-[110px]",children:i.jsx(rs,{})}),e[18]=j):j=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(pt,{value:"literal",children:i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx(u9,{className:"size-3.5"}),"Literal"]})}),e[19]=C):C=e[19];let V;e[20]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsxs(Yt,{children:[C,i.jsx(pt,{value:"secret",children:i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx(Od,{className:"size-3.5"}),"Secret"]})})]}),e[20]=V):V=e[20];let N;e[21]!==_||e[22]!==S?(N=i.jsx("div",{className:"shrink-0",children:i.jsxs(Jt,{value:_,onValueChange:S,children:[j,V]})}),e[21]=_,e[22]=S,e[23]=N):N=e[23];let T;e[24]!==n||e[25]!==r||e[26]!==s||e[27]!==f||e[28]!==_||e[29]!==h||e[30]!==c||e[31]!==p||e[32]!==l||e[33]!==m?(T=i.jsx("div",{className:"flex flex-[2] min-w-0 items-center gap-1",children:_==="literal"?i.jsx(ws,{control:n,name:m,render:B=>{const{field:z}=B;return i.jsx(tt,{...z,value:z.value??"",type:"password",placeholder:"value",spellCheck:!1,autoComplete:"off",className:"font-mono","aria-label":`Env var ${s+1} value`,onBlur:$=>{z.onChange($.target.value),z.onBlur()}})}}):i.jsxs(i.Fragment,{children:[i.jsx(ws,{control:n,name:p,render:B=>{const{field:z}=B;return i.jsxs(Jt,{value:z.value||"",onValueChange:$=>z.onChange($),children:[i.jsx(Xt,{className:te("h-9 w-full",!z.value&&"text-muted-foreground"),children:i.jsx(rs,{placeholder:"Pick a secret…",children:i.jsx(_j,{field:z,secretById:c})})}),i.jsx(Yt,{children:l.length===0?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No secrets yet. Use the “+” to create one."}):l.map(bj)})]})}}),i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Create new secret",onClick:()=>{const B=r.getValues(f)?.trim()??"";h(B)},children:i.jsx(kt,{className:"size-3.5"})})}),i.jsx(De,{children:"Create new secret"})]})]})}),e[24]=n,e[25]=r,e[26]=s,e[27]=f,e[28]=_,e[29]=h,e[30]=c,e[31]=p,e[32]=l,e[33]=m,e[34]=T):T=e[34];let A;e[35]!==r||e[36]!==f||e[37]!==_||e[38]!==d||e[39]!==m?(A=_==="literal"?i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Save value as secret",onClick:()=>{const B=r.getValues(f)?.trim()??"",z=r.getValues(m)??"";d(B,z)},children:i.jsx(Gd,{className:"size-3.5"})})}),i.jsx(De,{children:"Save value as secret"})]}):null,e[35]=r,e[36]=f,e[37]=_,e[38]=d,e[39]=m,e[40]=A):A=e[40];let E;e[41]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(ks,{className:"size-3.5"}),e[41]=E):E=e[41];let R;e[42]!==u?(R=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove env var",onClick:u,children:E})}),e[42]=u,e[43]=R):R=e[43];let D;e[44]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx(De,{children:"Remove"}),e[44]=D):D=e[44];let P;e[45]!==R?(P=i.jsxs(Oe,{children:[R,D]}),e[45]=R,e[46]=P):P=e[46];let I;e[47]!==A||e[48]!==P?(I=i.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[A,P]}),e[47]=A,e[48]=P,e[49]=I):I=e[49];let O;return e[50]!==T||e[51]!==I||e[52]!==w||e[53]!==N?(O=i.jsxs("div",{className:"flex flex-col gap-2 p-2 sm:flex-row sm:items-center",children:[w,N,T,I]}),e[50]=T,e[51]=I,e[52]=w,e[53]=N,e[54]=O):O=e[54],O}function bj(t){return i.jsx(pt,{value:t.id,children:i.jsxs("span",{className:"inline-flex items-center gap-2",children:[i.jsx(Fp,{scope:t.scope}),i.jsx("span",{className:"font-mono",children:t.name})]})},t.id)}function _j(t){const e=M.c(12),{field:s,secretById:n}=t,r=s.value||"";if(!r)return null;let o;e[0]!==r||e[1]!==n?(o=n.get(r),e[0]=r,e[1]=n,e[2]=o):o=e[2];const a=o;if(!a){let h;return e[3]!==r?(h=i.jsxs("span",{className:"text-destructive",children:["Missing secret (",r,")"]}),e[3]=r,e[4]=h):h=e[4],h}let l;e[5]!==a.scope?(l=i.jsx(Fp,{scope:a.scope}),e[5]=a.scope,e[6]=l):l=e[6];let c;e[7]!==a.name?(c=i.jsx("span",{className:"truncate font-mono",children:a.name}),e[7]=a.name,e[8]=c):c=e[8];let d;return e[9]!==l||e[10]!==c?(d=i.jsxs("span",{className:"inline-flex items-center gap-1.5 truncate",children:[l,c]}),e[9]=l,e[10]=c,e[11]=d):d=e[11],d}function Fp(t){const e=M.c(2),{scope:s}=t,n=s==="user"?v6:h9;let r;return e[0]!==n?(r=i.jsx(n,{className:"size-3 text-muted-foreground"}),e[0]=n,e[1]=r):r=e[1],r}function yj({mode:t,onClose:e,onSaved:s}){const n=t.kind==="save-literal"?t.presetValue:"",r=t.presetKey,[o,a]=k.useState(()=>Lj(r)),[l,c]=k.useState("organization"),[d,h]=k.useState(n),[u,f]=k.useState(""),m=_6(),p=o.trim(),g=d.length>0&&p.length>0&&hj.test(p),x=async b=>{if(b.preventDefault(),!!g)try{const y=await m.mutateAsync({scope:l,name:p,value:d,description:u.trim()||void 0});de.success(`Saved secret "${y.name}"`),s(y.id)}catch(y){de.error(y instanceof Error?y.message:"Failed to save")}},v=t.kind==="save-literal"?"Save value as secret":"Create new secret",_=t.kind==="save-literal"?"Move this value into the encrypted vault. The env var will then reference the secret by id — its value never leaves the server.":"Stored encrypted in the credential vault. The env var will reference the new secret by id.";return i.jsx(es,{open:!0,onOpenChange:b=>{b||e()},children:i.jsxs(Zt,{className:"sm:max-w-md",children:[i.jsxs(us,{children:[i.jsx(hs,{children:v}),i.jsx(si,{children:_})]}),i.jsxs("form",{onSubmit:x,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(rt,{htmlFor:"save-secret-scope",children:"Scope"}),i.jsxs(Jt,{value:l,onValueChange:b=>c(b),children:[i.jsx(Xt,{id:"save-secret-scope",children:i.jsx(rs,{})}),i.jsxs(Yt,{children:[i.jsx(pt,{value:"organization",children:"Organization — visible to all members"}),i.jsx(pt,{value:"user",children:"Private — only visible to me"})]})]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(rt,{htmlFor:"save-secret-name",children:"Name"}),i.jsx(tt,{id:"save-secret-name",value:o,onChange:b=>a(b.target.value),placeholder:"STRIPE_API_KEY",autoComplete:"off",required:!0}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters, digits, underscore, dot, hyphen. Independent of the env var key."})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(rt,{htmlFor:"save-secret-value",children:"Value"}),i.jsx(tt,{id:"save-secret-value",type:"password",value:d,onChange:b=>h(b.target.value),placeholder:"secret value",autoComplete:"new-password",required:!0})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(rt,{htmlFor:"save-secret-description",children:"Description (optional)"}),i.jsx(ur,{id:"save-secret-description",value:u,onChange:b=>f(b.target.value),rows:2,placeholder:"What is this secret used for?"})]}),i.jsxs(Ei,{children:[i.jsx(re,{type:"button",variant:"outline",onClick:e,disabled:m.isPending,children:"Cancel"}),i.jsx(re,{type:"submit",disabled:!g||m.isPending,children:m.isPending?"Saving…":"Save secret"})]})]})]})})}function Ph(t){if(!Array.isArray(t))return[];const e=[];for(const s of t){if(!s||typeof s!="object")continue;const n=s,r=(n.key??"").trim();if(!(!r||!Fl.test(r))){if(n.kind==="literal"){e.push({key:r,kind:"literal",value:n.value??""});continue}n.kind==="secret"&&n.secretId&&e.push({key:r,kind:"secret",secretId:n.secretId})}}return e}function Lj(t){const e=t.trim();return e&&Fl.test(e)?e:""}function Sj(t){const e=M.c(12),{repo:s,className:n}=t;let r;e[0]!==n?(r=te("space-y-2",n),e[0]=n,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(rt,{children:"Repository"}),e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Io,{size:20,className:"shrink-0 text-foreground/60"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=i.jsx(Ie,{asChild:!0,children:i.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-4 py-3",tabIndex:0,children:[a,i.jsx("div",{className:"min-w-0 flex-1",children:s?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"truncate text-sm font-medium",children:[s.owner,"/",s.name]}),i.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.url})]}):i.jsx("div",{className:"text-sm text-muted-foreground",children:"No repository connected"})})]})}),e[4]=s,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(De,{children:"The connected GitHub repository for this agent. Manage in Connections."}),e[6]=c):c=e[6];let d;e[7]!==l?(d=i.jsxs(Oe,{children:[l,c]}),e[7]=l,e[8]=d):d=e[8];let h;return e[9]!==r||e[10]!==d?(h=i.jsxs("div",{className:r,children:[o,d]}),e[9]=r,e[10]=d,e[11]=h):h=e[11],h}const wj={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}};function jj(t){const e=t.trim();if(e==="")return{ok:!0,value:null};if(!/^\d+$/.test(e))return{ok:!1};const s=Number(e);return s<1||s>65535?{ok:!1}:{ok:!0,value:String(s)}}const Cj=Object.keys(wj),Wc="__none__";function kj(t){const e=M.c(20),{control:s}=t,n=k.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(rt,{htmlFor:"runtime-pm",children:"Package manager"}),e[0]=r):r=e[0];let o;e[1]!==s?(o=i.jsxs("div",{className:"space-y-2",children:[r,i.jsx(ws,{control:s,name:"metadata.runtime.selected",render:Nj})]}),e[1]=s,e[2]=o):o=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(rt,{htmlFor:"runtime-path",children:"Package path"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=i.jsx(ws,{control:s,name:"metadata.runtime.path",render:Vj}),e[4]=s,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("p",{className:"text-xs text-muted-foreground",children:"Path (relative to repo root) to the directory containing package.json. Leave blank for the repo root."}),e[6]=c):c=e[6];let d;e[7]!==l?(d=i.jsxs("div",{className:"space-y-2",children:[a,l,c]}),e[7]=l,e[8]=d):d=e[8];let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(rt,{htmlFor:"runtime-port",children:"Dev server port"}),e[9]=h):h=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=x=>{const{field:v}=x;return i.jsx(tt,{ref:n,id:"runtime-port",inputMode:"numeric",placeholder:"Auto",defaultValue:v.value??"",onBlur:_=>{const b=jj(_.target.value);b.ok?v.onChange(b.value):n.current&&(n.current.value=v.value??"")}})},e[10]=u):u=e[10];let f;e[11]!==s?(f=i.jsx(ws,{control:s,name:"metadata.runtime.port",render:u}),e[11]=s,e[12]=f):f=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to let the runner pick."}),e[13]=m):m=e[13];let p;e[14]!==f?(p=i.jsxs("div",{className:"space-y-2",children:[h,f,m]}),e[14]=f,e[15]=p):p=e[15];let g;return e[16]!==p||e[17]!==o||e[18]!==d?(g=i.jsxs("div",{className:"space-y-5",children:[o,d,p]}),e[16]=p,e[17]=o,e[18]=d,e[19]=g):g=e[19],g}function Vj(t){const{field:e}=t;return i.jsx(tt,{id:"runtime-path",placeholder:".",defaultValue:e.value??"",onBlur:s=>{const n=s.target.value.trim();e.onChange(n===""?null:n)}})}function Nj(t){const{field:e}=t;return i.jsxs(Jt,{value:e.value??Wc,onValueChange:s=>e.onChange(s===Wc?null:s),children:[i.jsx(Xt,{id:"runtime-pm",children:i.jsx(rs,{placeholder:"Auto-detect"})}),i.jsxs(Yt,{children:[i.jsx(pt,{value:Wc,children:"Auto-detect"}),Cj.map(Aj)]})]})}function Aj(t){return i.jsx(pt,{value:t,children:t},t)}function Tj(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Ej(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},n=new Set(s.fields);for(const r of e.fields)n.add(r);return{...s,fields:n,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function Rj(t){const e=t.metadata?.runtime?.env;if(!e||e.length===0)return t;const s=e.filter(n=>{if(!n||typeof n!="object")return!1;const r=(n.key??"").trim();return!r||!Fl.test(r)?!1:n.kind==="literal"?!0:n.kind==="secret"?!!n.secretId:!1});return s.length===e.length?t:{...t,metadata:{...t.metadata,runtime:{...t.metadata?.runtime??{},env:s}}}}async function Pj(t,e){const s=t?.idToken??null;if(s){const r=Ih(s);if(r)return r}const n=t?.userinfoEndpoint??null;if(n)try{const r=await fetch(n,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const o=await r.json(),a=typeof o.email=="string"?o.email:typeof o.upn=="string"?o.upn:typeof o.preferred_username=="string"?o.preferred_username:null;if(a)return a}}catch{}return Ih(e)}function Ih(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Ij({virtualMcp:t,hideOwnTitle:e}){const{org:s}=Ee(),n=Ud(),{data:r}=rv([t.id]),o=r?.get(t.id)?.last_used_at,a=a2(),l=bs(),c=Ms(),d=Dd({resolver:J1(Gw),defaultValues:t}),h=d.watch("connections"),u=Km(t),f=ea(t),m=f?{owner:f.owner,name:f.name,url:f.url}:null,[p,g]=k.useReducer(Tj,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[x,v]=k.useState(!1),[_,b]=k.useState(!1),{createNewTask:y,openSidePanel:L}=Jo(),{sendMessage:w}=Ys(),S=async()=>{if(_)return;const F=d.getValues("metadata.instructions");if(F?.trim()){b(!0);try{A(),Ne("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:F.length}),L("chat"),await w({tiptapDoc:Mp({managerAgentId:gm.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:F})})}finally{b(!1)}}},j=()=>{A(),Ne("agent_test_clicked",{agent_id:t.id}),y()},[C,V]=k.useReducer(Ej,null),N=()=>{C!==null&&(Ne("agent_updated",{agent_id:t.id,fields:Array.from(C.fields),instructions_length:C.instructionsLength,save_count:C.saveCount,edit_duration_ms:Date.now()-C.start}),V({type:"reset"}))},{schedule:T,flush:A}=pl({delayMs:3e4,save:async()=>N()}),E=async()=>{const F=Object.keys(d.control._formState.dirtyFields);if(F.length===0)return;const Q=F.includes("metadata"),J=d.getValues();d.reset(J,{keepValues:!0});const ee=Rj(J);await n.update.mutateAsync({id:t.id,data:ee}),V({type:"accumulate",now:Date.now(),fields:F,instructionsLength:Q?J.metadata?.instructions?.length??0:null}),T()},{schedule:R,flush:D}=pl({save:E});k.useEffect(()=>{const F=d.watch(()=>R());return()=>F.unsubscribe()},[]);const P=()=>{Ne("connections_dialog_opened",{source:"agent_settings",mode:"add"}),g({type:"SET_ADD_DIALOG_OPEN",payload:!0})},I=async F=>{const Q=d.getValues("connections");if(Q.some(q=>q.connection_id===F))return;d.setValue("connections",[...Q,{connection_id:F,selected_tools:Kc.tools,selected_resources:Kc.resources,selected_prompts:Kc.prompts}],{shouldDirty:!0}),g({type:"SET_ADD_DIALOG_OPEN",payload:!1});const J=new URL(`/api/${s.slug}/mcp/${F}`,window.location.origin),ee=await Ku({url:J.href,token:null,orgId:s.id});ee.supportsOAuth&&!ee.isAuthenticated&&await U(F)},O=F=>{const J=d.getValues("connections").filter(ee=>ee.connection_id!==F);d.setValue("connections",J,{shouldDirty:!0})},B=(F,Q)=>{const J=d.getValues("connections");if(J.some(ee=>ee.connection_id===Q)){de.error("This instance is already added to the agent");return}d.setValue("connections",J.map(ee=>ee.connection_id===F?{...ee,connection_id:Q}:ee),{shouldDirty:!0})},z=async F=>{if(d.getValues("connections").find(J=>J.connection_id===F))try{const{item:J}=await c.call("COLLECTION_CONNECTIONS_GET",{id:F});if(!J)return;const ee=J.title.replace(/\s*\(.*?\)\s*$/,""),q=m6("conn"),se=`${ee} (${Date.now().toString(36).slice(-4)})`;await a.create.mutateAsync({id:q,title:se,description:J.description??null,connection_type:J.connection_type,connection_url:J.connection_url??null,connection_token:null,icon:J.icon??null,app_name:J.app_name??null,app_id:J.app_id??null,connection_headers:J.connection_headers??null});const ne=new URL(`/api/${s.slug}/mcp/${q}`,window.location.origin),le=await Ku({url:ne.href,token:null,orgId:s.id});if(le.supportsOAuth&&!le.isAuthenticated){const G=await U(q);if(!G){await a.delete.mutateAsync(q);return}await a.update.mutateAsync({id:q,data:{title:`${ee} (${G})`}})}B(F,q),de.success("New instance created")}catch(J){console.error("Failed to create instance:",J),de.error("Failed to create instance")}},$=F=>{g({type:"OPEN_SETTINGS",payload:F})},U=async F=>{const{token:Q,tokenInfo:J,error:ee}=await p6({connectionId:F,orgSlug:s.slug,scope:"offline_access"});if(ee||!Q)return de.error(`Authentication failed: ${ee}`),null;if(J)try{const se=await fetch(`/api/${s.slug}/connections/${F}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:J.accessToken,refreshToken:J.refreshToken,expiresIn:J.expiresIn,scope:J.scope,clientId:J.clientId,clientSecret:J.clientSecret,tokenEndpoint:J.tokenEndpoint})});if(!se.ok)console.error("Failed to save OAuth token:",await se.text()),await a.update.mutateAsync({id:F,data:{connection_token:Q}});else try{await a.update.mutateAsync({id:F,data:{}})}catch(ne){console.warn("Failed to refresh connection tools after OAuth:",ne)}}catch(se){console.error("Error saving OAuth token:",se),await a.update.mutateAsync({id:F,data:{connection_token:Q}})}else await a.update.mutateAsync({id:F,data:{connection_token:Q}});const q=new URL(`/api/${s.slug}/mcp/${F}`,window.location.origin);return await l.invalidateQueries({queryKey:it.isMCPAuthenticated(q.href,null)}),de.success("Authentication successful"),Pj(J,Q)},W=()=>{const F=d.getValues("metadata.instructions")??"",Q=`<role>
13
+ Define who this agent is and what it specializes in.
14
+ Example: You are a support triage agent for B2B merchants.
15
+ </role>
16
+
17
+ <capabilities>
18
+ List what this agent can do using its connected tools.
19
+ - Investigate issues using connected data sources.
20
+ - Summarize findings and recommend next steps.
21
+ </capabilities>
22
+
23
+ <constraints>
24
+ Set clear boundaries on what the agent must not do.
25
+ - Do not perform destructive actions without confirmation.
26
+ - Escalate to a human when the request is outside your expertise.
27
+ </constraints>
28
+
29
+ <workflows>
30
+ Define step-by-step how the agent should handle requests.
31
+
32
+ ## Default workflow
33
+ 1. Read the user's request and gather context.
34
+ 2. Use the appropriate tools to investigate or act.
35
+ 3. Summarize the result and propose next steps.
36
+ 4. Ask for confirmation before making any changes.
37
+ </workflows>`,J=F.trim()?`${F}
38
+
39
+ ${Q}`:Q;d.setValue("metadata.instructions",J,{shouldDirty:!0})},X=new Set(h.map(F=>F.connection_id)),H=yt(),[Z,K]=k.useState(!1),Y=async()=>{A();try{await n.delete.mutateAsync(t.id),Ne("agent_deleted",{agent_id:t.id,source:"agent_detail"}),de.success(`Deleted "${t.title}"`),H({to:"/$org",params:{org:s.slug}})}catch{}};return i.jsxs(Zs,{children:[i.jsx(Zs.Content,{children:i.jsx(Zs.Body,{children:i.jsxs("div",{className:"flex flex-col gap-10",children:[!e&&i.jsx(Zs.Title,{actions:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(re,{variant:"outline",size:"sm",onClick:j,children:[i.jsx(Si,{size:14,className:"size-[14px]!"}),"Test Agent"]}),i.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",onClick:()=>K(!0),children:i.jsx(ks,{size:14})})]}),children:"Settings"}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ws,{name:"icon",control:d.control,render:({field:F})=>i.jsx(cw,{value:F.value??null,onChange:Q=>{F.onChange(Q),D()},onColorChange:Q=>{d.setValue("metadata.ui.themeColor",Q,{shouldDirty:!0}),D()},name:d.watch("title")||"Agent",size:"md",className:"shrink-0",avatarClassName:"[&_svg]:w-1/2 [&_svg]:h-1/2"})}),i.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[i.jsx(ws,{name:"title",control:d.control,render:({field:F})=>i.jsx("input",{...F,type:"text",value:F.value??"",onChange:Q=>{F.onChange(Q)},onBlur:()=>{F.onBlur(),D()},disabled:u,placeholder:"Agent name",className:"text-lg font-medium leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})}),i.jsx(ws,{name:"description",control:d.control,render:({field:F})=>i.jsx("input",{...F,type:"text",value:F.value??"",onChange:Q=>{F.onChange(Q)},onBlur:()=>{F.onBlur(),D()},disabled:u,placeholder:"Add a description...",className:"text-sm text-muted-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-full truncate disabled:hover:bg-transparent disabled:focus:bg-transparent disabled:opacity-50"})})]}),i.jsxs(re,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{Ne("agent_connect_modal_opened",{agent_id:t.id}),g({type:"SET_SHARE_DIALOG_OPEN",payload:!0})},children:[i.jsxs("span",{className:"flex items-center -space-x-1.5 mr-0.5",children:[i.jsx("span",{className:"inline-flex items-center justify-center size-4 rounded-full bg-black ring-1 ring-white/20 shrink-0",children:i.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"size-2.5 brightness-0 invert"})}),i.jsx("span",{className:"relative z-10 inline-flex items-center justify-center size-4 rounded-full ring-1 ring-background shrink-0",style:{backgroundColor:"#D97757"},children:i.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude",className:"size-2.5 brightness-0 invert"})})]}),"Connect"]})]}),i.jsxs("div",{className:"flex items-center gap-2 -mt-6 text-sm text-muted-foreground",children:[i.jsx($p,{id:t.created_by,size:"2xs",className:"text-sm text-muted-foreground"}),i.jsx("span",{className:"text-muted-foreground/50",children:"·"}),i.jsxs("span",{children:["Created"," ",new Date(t.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),i.jsx("span",{className:"text-muted-foreground/50",children:"·"}),i.jsx("span",{children:o?`Last used ${y6(new Date(o),{addSuffix:!0})}`:"Never used"})]}),i.jsxs("section",{className:"flex flex-col gap-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Connections"}),h.length>0&&i.jsxs(re,{variant:"outline",size:"sm",onClick:P,children:[i.jsx(kt,{size:14}),"Add connection"]})]}),i.jsx("div",{className:"flex flex-col gap-2",children:h.length===0?i.jsxs("button",{type:"button",onClick:P,className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-dashed border-border hover:bg-accent/50 transition-colors w-full text-left cursor-pointer",children:[i.jsx("div",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/75 border border-dashed border-border shrink-0",children:i.jsx(kt,{size:16})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"No connections yet. Add one to get started."})]}):h.map(F=>i.jsx(vs,{fallback:()=>null,children:i.jsx(k.Suspense,{fallback:i.jsx(zp,{}),children:i.jsx(Bw,{connection_id:F.connection_id,usedConnectionIds:X,onOpenSettings:()=>$(F.connection_id),onRemove:()=>O(F.connection_id),onAuthenticate:U,onSwitchInstance:B,onNewInstance:()=>z(F.connection_id)})})},F.connection_id))})]}),i.jsxs("section",{className:"flex flex-col gap-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Instructions"}),i.jsxs("div",{className:"flex items-center gap-2",children:[!d.watch("metadata.instructions")?.trim()&&i.jsx(re,{variant:"outline",size:"sm",onClick:W,children:"+ Prompt template"}),i.jsxs(re,{variant:"outline",size:"sm",disabled:_||!d.watch("metadata.instructions")?.trim(),onClick:S,children:[i.jsx(Kn,{size:13}),"Improve"]})]})]}),i.jsx(ws,{name:"metadata.instructions",control:d.control,render:({field:F})=>i.jsxs("div",{className:"relative rounded-xl card-shadow bg-card focus-within:ring-1 focus-within:ring-ring",children:[i.jsx(ur,{...F,value:F.value??"",onChange:Q=>{F.onChange(Q)},onBlur:()=>{F.onBlur(),D()},placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"min-h-[200px] max-h-[360px] overflow-auto resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed border-0 shadow-none px-4 py-3 pr-11 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent",style:{boxShadow:"none"}}),i.jsxs(Oe,{delayDuration:0,children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-7 w-7 text-muted-foreground",onClick:()=>v(!0),"aria-label":"Open fullscreen editor",children:i.jsx(Im,{size:14})})}),i.jsx(De,{side:"left",children:"Fullscreen"})]})]})})]}),i.jsx(gw,{form:d}),i.jsx(vs,{fallback:()=>null,children:i.jsx(k.Suspense,{fallback:i.jsxs("section",{className:"flex flex-col gap-3",children:[i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sub-agents"}),i.jsx("div",{className:"h-16 rounded-lg border border-dashed border-border animate-pulse"})]}),children:i.jsx(Sw,{form:d,currentAgentId:t.id})})}),i.jsx(qw,{virtualMcpId:t.id,form:d,flushAndSave:D}),i.jsx(aj,{virtualMcp:t}),i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("div",{className:"flex items-center justify-between gap-3",children:i.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Sandbox"})}),i.jsx(c9,{className:"p-6 gap-5",children:i.jsxs(ml,{className:"p-0 space-y-5",children:[i.jsx(Sj,{repo:m}),i.jsx(kj,{control:d.control}),i.jsx(fj,{control:d.control,form:d,virtualMcpId:t.id,orgSlug:s.slug})]})})]}),i.jsxs("section",{className:"flex items-center justify-between border-t border-border pt-6",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-medium",children:"Delete agent"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Permanently delete this agent and all its data."})]}),i.jsxs(re,{variant:"outline",size:"sm",className:"text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive shrink-0",onClick:()=>K(!0),children:[i.jsx(ks,{size:14}),"Delete agent"]})]})]})})}),i.jsx(ol,{open:Z,onOpenChange:K,children:i.jsxs(al,{children:[i.jsxs(ll,{children:[i.jsx(cl,{children:"Delete Agent?"}),i.jsxs(dl,{children:["This action cannot be undone. This will permanently delete"," ",i.jsx("span",{className:"font-medium text-foreground",children:t.title}),"."]})]}),i.jsxs(ul,{children:[i.jsx(hl,{children:"Cancel"}),i.jsx(fl,{onClick:Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),i.jsx(i9,{open:p.addDialogOpen,onOpenChange:F=>g({type:"SET_ADD_DIALOG_OPEN",payload:F}),agentId:t.id,addedConnectionIds:X,onAdd:I}),i.jsx($w,{open:p.settingsDialogOpen,onOpenChange:F=>{F||g({type:"CLOSE_SETTINGS"})},selectedId:p.settingsConnectionId,form:d,connections:h,onAuthenticate:U}),i.jsx(oj,{open:p.shareDialogOpen,onOpenChange:F=>g({type:"SET_SHARE_DIALOG_OPEN",payload:F}),virtualMcp:t}),i.jsx(es,{open:x,onOpenChange:v,children:i.jsxs(Zt,{className:"w-[90vw] sm:max-w-6xl h-[85vh] flex flex-col p-0 gap-0",children:[i.jsx(us,{className:"px-6 pt-6 pb-3 border-b border-border shrink-0",children:i.jsx(hs,{children:"Instructions"})}),i.jsx("div",{className:"flex-1 min-h-0 p-6",children:i.jsx(ws,{name:"metadata.instructions",control:d.control,render:({field:F})=>i.jsx(ur,{...F,value:F.value??"",onChange:Q=>{F.onChange(Q)},onBlur:()=>{F.onBlur(),D()},disabled:u,placeholder:"Define how this agent should behave, what tone to use, any constraints or guidelines...",className:"w-full h-full resize-none text-base text-muted-foreground placeholder:text-muted-foreground/40 leading-relaxed rounded-xl card-shadow px-4 py-3 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 bg-card border-0",style:{boxShadow:"none"}})})})]})})]})}function Dj(t){const e=M.c(9),{virtualMcpId:s,hideOwnTitle:n}=t,r=yt(),{org:o}=Ee(),a=fs(s);if(!a){let d;return e[0]!==r||e[1]!==o.slug?(d=i.jsx("div",{className:"flex h-full w-full bg-background",children:i.jsx(Li,{title:"Space not found",description:"This space may have been deleted or you may not have access.",actions:i.jsx(re,{variant:"outline",onClick:()=>r({to:"/$org",params:{org:o.slug}}),children:"Back to spaces"})})}),e[0]=r,e[1]=o.slug,e[2]=d):d=e[2],d}let l;e[3]!==a?(l=ea(a)?.connectionId??"",e[3]=a,e[4]=l):l=e[4];let c;return e[5]!==n||e[6]!==l||e[7]!==a?(c=i.jsx(Ij,{virtualMcp:a,hideOwnTitle:n},l),e[5]=n,e[6]=l,e[7]=a,e[8]=c):c=e[8],c}function Dh(t){const e=M.c(2),{virtualMcpId:s}=t;let n;return e[0]!==s?(n=i.jsx(Dj,{virtualMcpId:s,hideOwnTitle:!0}),e[0]=s,e[1]=n):n=e[1],n}const pr=1,Up=`home-board.layout.v${pr}`;function Hp(t){return`home-board.layout.v${pr}.${t}`}const Kp={version:pr,tiles:{},hidden:[],shown:[]};function M0(t){return!t||t.version!==pr?Kp:{version:pr,tiles:t.tiles??{},hidden:Array.isArray(t.hidden)?t.hidden:[],shown:Array.isArray(t.shown)?t.shown:[]}}function Oj(t){return Object.keys(t.tiles).length>0||t.hidden.length>0||(t.shown?.length??0)>0}function Mj(t){try{const e=localStorage.getItem(Hp(t));return e?M0(JSON.parse(e)):void 0}catch{return}}function Oh(t,e){try{localStorage.setItem(Hp(t),JSON.stringify(e))}catch{}}async function Mh(t,e){if(!(await fetch(`/api/${t}/kv/${Up}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw new Error("Failed to save board layout")}function $j(t){const e=M.c(24),s=bs();let n;e[0]!==t?(n=it.boardLayout(t),e[0]=t,e[1]=n):n=e[1];const r=n;let o;e[2]!==t?(o=Mj(t),e[2]=t,e[3]=o):o=e[3];const a=o;let l;e[4]!==a||e[5]!==t?(l=async()=>{const v=await fetch(`/api/${t}/kv/${Up}`);if(v.status===404)return a&&Oj(a)?(await Mh(t,a),a):Kp;if(!v.ok)throw new Error("Failed to load board layout");const _=await v.json(),b=M0(_.value);return Oh(t,b),b},e[4]=a,e[5]=t,e[6]=l):l=e[6];let c;e[7]!==a||e[8]!==r||e[9]!==l?(c={queryKey:r,queryFn:l,initialData:a,staleTime:0,refetchOnWindowFocus:!1},e[7]=a,e[8]=r,e[9]=l,e[10]=c):c=e[10];const{data:d,isLoading:h}=Ut(c);let u;e[11]!==t?(u={mutationFn:v=>Mh(t,v)},e[11]=t,e[12]=u):u=e[12];const f=Gs(u);let m;e[13]!==f||e[14]!==t||e[15]!==s||e[16]!==r?(m=v=>{Oh(t,v),s.setQueryData(r,v),f.mutate(v)},e[13]=f,e[14]=t,e[15]=s,e[16]=r,e[17]=m):m=e[17];const p=m;let g;e[18]!==d?(g=M0(d),e[18]=d,e[19]=g):g=e[19];let x;return e[20]!==h||e[21]!==p||e[22]!==g?(x={layout:g,isLoading:h,save:p},e[20]=h,e[21]=p,e[22]=g,e[23]=x):x=e[23],x}const Wp=k.createContext(null);function Bj(t){const e=M.c(24),{children:s}=t,{org:n}=Ee(),r=$j(n.slug),[o,a]=k.useState(!1),[l,c]=k.useState(null);let d;e[0]!==r.layout?(d=()=>{c(r.layout),a(!0)},e[0]=r.layout,e[1]=d):d=e[1];const h=d;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c(null),a(!1)},e[2]=u):u=e[2];const f=u;let m;e[3]!==l||e[4]!==r?(m=()=>{l&&r.save(l),c(null),a(!1)},e[3]=l,e[4]=r,e[5]=m):m=e[5];const p=m,g=o&&l!==null,x=g?l:r.layout;let v;e[6]!==l||e[7]!==g||e[8]!==r.layout?(v=g?JSON.stringify(l)!==JSON.stringify(r.layout):!1,e[6]=l,e[7]=g,e[8]=r.layout,e[9]=v):v=e[9];const _=v;let b;e[10]!==o||e[11]!==r?(b=S=>{o?c(S):r.save(S)},e[10]=o,e[11]=r,e[12]=b):b=e[12];const y=b;let L;e[13]!==y||e[14]!==h||e[15]!==_||e[16]!==o||e[17]!==x||e[18]!==p||e[19]!==r.isLoading?(L={isEditMode:o,enter:h,cancel:f,save:p,hasChanges:_,layout:x,isLayoutLoading:r.isLoading,commitLayout:y},e[13]=y,e[14]=h,e[15]=_,e[16]=o,e[17]=x,e[18]=p,e[19]=r.isLoading,e[20]=L):L=e[20];let w;return e[21]!==s||e[22]!==L?(w=i.jsx(Wp.Provider,{value:L,children:s}),e[21]=s,e[22]=L,e[23]=w):w=e[23],w}function B9(){const t=k.useContext(Wp);if(!t)throw new Error("useHomeEdit must be used within a HomeEditProvider");return t}function zj(t){const e=M.c(30),{generating:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=te("pointer-events-none absolute -bottom-14 left-6 hidden h-48 w-36 -rotate-6 rounded-xl border border-border bg-background shadow-lg sm:block","transition-transform duration-500 ease-out group-hover:-translate-y-2 group-hover:-rotate-3"),e[0]=n):n=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",className:"stroke-muted"}),e[1]=r):r=e[1];const o=s?"75.4":"22",a=s?"stroke-muted":"stroke-success";let l;e[2]!==a?(l=te("transition-[stroke-dashoffset] duration-1000 ease-out",a),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o||e[5]!==l?(c=i.jsxs("svg",{viewBox:"0 0 32 32",className:"size-9 shrink-0 -rotate-90",children:[r,i.jsx("circle",{cx:"16",cy:"16",r:"12",fill:"none",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"75.4",strokeDashoffset:o,className:l})]}),e[4]=o,e[5]=l,e[6]=c):c=e[6];const d=s&&"animate-pulse";let h;e[7]!==d?(h=te("h-1.5 w-full rounded-full bg-muted",d),e[7]=d,e[8]=h):h=e[8];let u;e[9]!==h?(u=i.jsx("div",{className:h}),e[9]=h,e[10]=u):u=e[10];const f=s&&"animate-pulse";let m;e[11]!==f?(m=te("h-1.5 w-2/3 rounded-full bg-muted",f),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==m?(p=i.jsx("div",{className:m}),e[13]=m,e[14]=p):p=e[14];let g;e[15]!==p||e[16]!==u?(g=i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[u,p]}),e[15]=p,e[16]=u,e[17]=g):g=e[17];let x;e[18]!==g||e[19]!==c?(x=i.jsxs("div",{className:"flex items-center gap-2.5",children:[c,g]}),e[18]=g,e[19]=c,e[20]=x):x=e[20];let v;e[21]===Symbol.for("react.memo_cache_sentinel")?(v=[7,10,5,9,6,8],e[21]=v):v=e[21];let _;e[22]!==s?(_=i.jsx("div",{className:"flex h-10 items-end gap-1.5",children:v.map((L,w)=>i.jsx("div",{style:{height:`${L*4}px`},className:te("flex-1 rounded-sm",s?"animate-pulse bg-muted":w%2===0?"bg-success/70":"bg-success/30")},`bar-${w}`))}),e[22]=s,e[23]=_):_=e[23];let b;e[24]!==s?(b=i.jsx("div",{className:"flex flex-col gap-1.5",children:["w-full","w-5/6","w-full","w-2/3","w-full"].map((L,w)=>i.jsx("div",{className:te("h-1.5 rounded-full bg-muted",L,s&&"animate-pulse")},`line-${w}`))}),e[24]=s,e[25]=b):b=e[25];let y;return e[26]!==x||e[27]!==_||e[28]!==b?(y=i.jsx("div",{"aria-hidden":!0,className:n,children:i.jsxs("div",{className:"flex h-full flex-col gap-3 p-4",children:[x,_,b]})}),e[26]=x,e[27]=_,e[28]=b,e[29]=y):y=e[29],y}function Fj(t){const e=M.c(25),{status:s,host:n,onOpen:r}=t,o=s==="generating",a=n??"sua loja";let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=te("group relative block w-full cursor-pointer overflow-hidden rounded-3xl border border-border bg-card card-shadow text-left","transition-colors duration-300 hover:bg-accent/30","animate-in fade-in slide-in-from-bottom-2 duration-500"),e[0]=l):l=e[0];const c=o?"bg-warning/15":"bg-success/15";let d;e[1]!==c?(d=te("absolute -bottom-24 -left-10 size-64 rounded-full blur-3xl transition-colors duration-700",c),e[1]=c,e[2]=d):d=e[2];let h;e[3]!==d?(h=i.jsx("div",{"aria-hidden":!0,className:d}),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o?(u=i.jsx(zj,{generating:o}),e[5]=o,e[6]=u):u=e[6];const f=o?"Gerando seu diagnóstico":"Seu relatório está pronto";let m;e[7]!==f?(m=i.jsx("span",{className:"text-base font-medium leading-6 text-foreground sm:text-lg",children:f}),e[7]=f,e[8]=m):m=e[8];const p=o?`Analisando ${a}. Isso leva alguns minutos.`:`Veja a análise completa de ${a}.`;let g;e[9]!==p?(g=i.jsx("span",{className:"truncate text-sm text-muted-foreground",children:p}),e[9]=p,e[10]=g):g=e[10];let x;e[11]!==m||e[12]!==g?(x=i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[m,g]}),e[11]=m,e[12]=g,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=te("flex size-11 shrink-0 items-center justify-center rounded-full border border-border bg-background","transition-transform duration-300 group-hover:translate-x-1"),e[14]=v):v=e[14];let _;e[15]!==o?(_=i.jsx("div",{className:v,children:o?i.jsxs("span",{className:"relative flex size-2.5",children:[i.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-warning opacity-60"}),i.jsx("span",{className:"relative inline-flex size-2.5 rounded-full bg-warning"})]}):i.jsx(Sr,{size:18,className:"text-foreground","aria-hidden":!0})}),e[15]=o,e[16]=_):_=e[16];let b;e[17]!==x||e[18]!==_?(b=i.jsxs("div",{className:"relative flex min-h-28 items-center gap-4 px-5 py-5 sm:h-36 sm:gap-6 sm:pr-6 sm:pl-52",children:[x,_]}),e[17]=x,e[18]=_,e[19]=b):b=e[19];let y;return e[20]!==r||e[21]!==b||e[22]!==h||e[23]!==u?(y=i.jsxs("button",{type:"button",onClick:r,className:l,children:[h,u,b]}),e[20]=r,e[21]=b,e[22]=h,e[23]=u,e[24]=y):y=e[24],y}function Uj(){const t=M.c(13),{org:e}=Ee(),s=yt(),{diagnostic:n,isSuccess:r,host:o,connectionId:a}=pv();let l;t[0]!==n||t[1]!==r?(l=r?gv(n):"none",t[0]=n,t[1]=r,t[2]=l):l=t[2];const c=l;if(c==="none")return null;let d;t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==e||t[7]!==c?(d=()=>{Ne("home_report_banner_clicked",{organization_id:e.id,status:c,domain:o??void 0}),s(xv(e,a))},t[3]=a,t[4]=o,t[5]=s,t[6]=e,t[7]=c,t[8]=d):d=t[8];const h=d;let u;return t[9]!==o||t[10]!==h||t[11]!==c?(u=i.jsx(Fj,{status:c,host:o,onOpen:h}),t[9]=o,t[10]=h,t[11]=c,t[12]=u):u=t[12],u}function Hj(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(vs,{fallback:null,children:i.jsx(Uj,{})}),t[0]=e):e=t[0],e}function Kj({agentId:t}){const{org:e,locator:s}=Ee(),n=ut({connectionId:t,orgId:e.id,orgSlug:e.slug}),{create:r}=Ul(),{setTaskId:o}=Jo(),[a,l]=k.useState(null),[c,d]=k.useState(!1),h=k.useRef(!1),u=async(x,v)=>{if(!n){de.error("MCP client not available");return}if(!h.current){h.current=!0,d(!0);try{const _=await Yo(n,x.name,v),b={type:"doc",content:[{type:"paragraph",content:[zd({id:x.name,name:yr(x.name,mn(x._meta)),metadata:_.messages,char:"/",kind:"prompt",args:v}),{type:"text",text:" "}]}]},y=crypto.randomUUID();Sm(sessionStorage,s,y,{tiptapDoc:b}),await r({id:y,virtual_mcp_id:t}),o(y,t,{autosend:!0})}catch(_){console.error("[start-thread-from-prompt] failed",_),de.error("Failed to start chat. Please try again.")}finally{h.current=!1,d(!1)}}},f=async x=>{if(!h.current){if(x.arguments&&x.arguments.length>0){l(x);return}await u(x)}},m=async x=>{if(!a)return;const v=a;l(null),await u(v,x)};return{start:f,startBlank:async x=>{if(!h.current){h.current=!0,d(!0);try{const v=crypto.randomUUID();await r({id:v,virtual_mcp_id:t}),o(v,t,x?.main?{main:x.main}:void 0)}catch(v){console.error("[start-thread-from-prompt] startBlank failed",v),de.error("Failed to start chat. Please try again.")}finally{h.current=!1,d(!1)}}},dialog:i.jsx(No,{prompt:a,setPrompt:x=>l(x),onSubmit:m}),dialogPrompt:a,starting:c}}function Wj(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return k.useMemo(()=>n=>{e.forEach(r=>r(n))},e)}const ac=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Er(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function z9(t){return"nodeType"in t}function _s(t){var e,s;return t?Er(t)?t:z9(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function F9(t){const{Document:e}=_s(t);return t instanceof e}function aa(t){return Er(t)?!1:t instanceof _s(t).HTMLElement}function qp(t){return t instanceof _s(t).SVGElement}function Rr(t){return t?Er(t)?t.document:z9(t)?F9(t)?t:aa(t)||qp(t)?t.ownerDocument:document:document:document}const sn=ac?k.useLayoutEffect:k.useEffect;function lc(t){const e=k.useRef(t);return sn(()=>{e.current=t}),k.useCallback(function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}function qj(){const t=k.useRef(null),e=k.useCallback((n,r)=>{t.current=setInterval(n,r)},[]),s=k.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Mo(t,e){e===void 0&&(e=[t]);const s=k.useRef(t);return sn(()=>{s.current!==t&&(s.current=t)},e),s}function la(t,e){const s=k.useRef();return k.useMemo(()=>{const n=t(s.current);return s.current=n,n},[...e])}function Sl(t){const e=lc(t),s=k.useRef(null),n=k.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,n]}function wl(t){const e=k.useRef();return k.useEffect(()=>{e.current=t},[t]),e.current}let qc={};function ca(t,e){return k.useMemo(()=>{if(e)return e;const s=qc[t]==null?0:qc[t]+1;return qc[t]=s,t+"-"+s},[t,e])}function Gp(t){return function(e){for(var s=arguments.length,n=new Array(s>1?s-1:0),r=1;r<s;r++)n[r-1]=arguments[r];return n.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const h=o[c];h!=null&&(o[c]=h+t*d)}return o},{...e})}}const Zi=Gp(1),$o=Gp(-1);function Gj(t){return"clientX"in t&&"clientY"in t}function cc(t){if(!t)return!1;const{KeyboardEvent:e}=_s(t.target);return e&&t instanceof e}function Yj(t){if(!t)return!1;const{TouchEvent:e}=_s(t.target);return e&&t instanceof e}function jl(t){if(Yj(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return Gj(t)?{x:t.clientX,y:t.clientY}:null}const yn=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[yn.Translate.toString(t),yn.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}}),$h="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Jj(t){return t.matches($h)?t:t.querySelector($h)}const Xj={display:"none"};function Qj(t){let{id:e,value:s}=t;return et.createElement("div",{id:e,style:Xj},s)}function Zj(t){let{id:e,announcement:s,ariaLiveType:n="assertive"}=t;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return et.createElement("div",{id:e,style:r,role:"status","aria-live":n,"aria-atomic":!0},s)}function eC(){const[t,e]=k.useState("");return{announce:k.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Yp=k.createContext(null);function tC(t){const e=k.useContext(Yp);k.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function sC(){const[t]=k.useState(()=>new Set),e=k.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[k.useCallback(n=>{let{type:r,event:o}=n;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const nC={draggable:`
40
+ To pick up a draggable item, press the space bar.
41
+ While dragging, use the arrow keys to move the item.
42
+ Press space again to drop the item in its new position, or press escape to cancel.
43
+ `},iC={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was moved over droppable area "+s.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was dropped over droppable area "+s.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function rC(t){let{announcements:e=iC,container:s,hiddenTextDescribedById:n,screenReaderInstructions:r=nC}=t;const{announce:o,announcement:a}=eC(),l=ca("DndLiveRegion"),[c,d]=k.useState(!1);if(k.useEffect(()=>{d(!0)},[]),tC(k.useMemo(()=>({onDragStart(u){let{active:f}=u;o(e.onDragStart({active:f}))},onDragMove(u){let{active:f,over:m}=u;e.onDragMove&&o(e.onDragMove({active:f,over:m}))},onDragOver(u){let{active:f,over:m}=u;o(e.onDragOver({active:f,over:m}))},onDragEnd(u){let{active:f,over:m}=u;o(e.onDragEnd({active:f,over:m}))},onDragCancel(u){let{active:f,over:m}=u;o(e.onDragCancel({active:f,over:m}))}}),[o,e])),!c)return null;const h=et.createElement(et.Fragment,null,et.createElement(Qj,{id:n,value:r.draggable}),et.createElement(Zj,{id:l,announcement:a}));return s?qi.createPortal(h,s):h}var Bt;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Bt||(Bt={}));function Cl(){}function Zn(t,e){return k.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function dc(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return k.useMemo(()=>[...e].filter(n=>n!=null),[...e])}const nn=Object.freeze({x:0,y:0});function Jp(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function oC(t,e){const s=jl(t);if(!s)return"0 0";const n={x:(s.x-e.left)/e.width*100,y:(s.y-e.top)/e.height*100};return n.x+"% "+n.y+"%"}function Xp(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return s-n}function aC(t,e){let{data:{value:s}}=t,{data:{value:n}}=e;return n-s}function Bh(t){let{left:e,top:s,height:n,width:r}=t;return[{x:e,y:s},{x:e+r,y:s},{x:e,y:s+n},{x:e+r,y:s+n}]}function Qp(t,e){if(!t||t.length===0)return null;const[s]=t;return s[e]}function zh(t,e,s){return e===void 0&&(e=t.left),s===void 0&&(s=t.top),{x:e+t.width*.5,y:s+t.height*.5}}const U9=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const r=zh(e,e.left,e.top),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=Jp(zh(c),r);o.push({id:l,data:{droppableContainer:a,value:d}})}}return o.sort(Xp)},lC=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const r=Bh(e),o=[];for(const a of n){const{id:l}=a,c=s.get(l);if(c){const d=Bh(c),h=r.reduce((f,m,p)=>f+Jp(d[p],m),0),u=Number((h/4).toFixed(4));o.push({id:l,data:{droppableContainer:a,value:u}})}}return o.sort(Xp)};function cC(t,e){const s=Math.max(e.top,t.top),n=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),a=r-n,l=o-s;if(n<r&&s<o){const c=e.width*e.height,d=t.width*t.height,h=a*l,u=h/(c+d-h);return Number(u.toFixed(4))}return 0}const dC=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:n}=t;const r=[];for(const o of n){const{id:a}=o,l=s.get(a);if(l){const c=cC(l,e);c>0&&r.push({id:a,data:{droppableContainer:o,value:c}})}}return r.sort(aC)};function uC(t,e,s){return{...t,scaleX:e&&s?e.width/s.width:1,scaleY:e&&s?e.height/s.height:1}}function Zp(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:nn}function hC(t){return function(s){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((a,l)=>({...a,top:a.top+t*l.y,bottom:a.bottom+t*l.y,left:a.left+t*l.x,right:a.right+t*l.x}),{...s})}}const fC=hC(1);function e3(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function mC(t,e,s){const n=e3(e);if(!n)return t;const{scaleX:r,scaleY:o,x:a,y:l}=n,c=t.left-a-(1-r)*parseFloat(s),d=t.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=r?t.width/r:t.width,u=o?t.height/o:t.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}const pC={ignoreTransform:!1};function Pr(t,e){e===void 0&&(e=pC);let s=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:h}=_s(t).getComputedStyle(t);d&&(s=mC(s,d,h))}const{top:n,left:r,width:o,height:a,bottom:l,right:c}=s;return{top:n,left:r,width:o,height:a,bottom:l,right:c}}function Fh(t){return Pr(t,{ignoreTransform:!0})}function gC(t){const e=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:e,bottom:s,width:e,height:s}}function xC(t,e){return e===void 0&&(e=_s(t).getComputedStyle(t)),e.position==="fixed"}function vC(t,e){e===void 0&&(e=_s(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const o=e[r];return typeof o=="string"?s.test(o):!1})}function uc(t,e){const s=[];function n(r){if(e!=null&&s.length>=e||!r)return s;if(F9(r)&&r.scrollingElement!=null&&!s.includes(r.scrollingElement))return s.push(r.scrollingElement),s;if(!aa(r)||qp(r)||s.includes(r))return s;const o=_s(t).getComputedStyle(r);return r!==t&&vC(r,o)&&s.push(r),xC(r,o)?s:n(r.parentNode)}return t?n(t):s}function t3(t){const[e]=uc(t,1);return e??null}function Gc(t){return!ac||!t?null:Er(t)?t:z9(t)?F9(t)||t===Rr(t).scrollingElement?window:aa(t)?t:null:null}function s3(t){return Er(t)?t.scrollX:t.scrollLeft}function n3(t){return Er(t)?t.scrollY:t.scrollTop}function $0(t){return{x:s3(t),y:n3(t)}}var Kt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Kt||(Kt={}));function i3(t){return!ac||!t?!1:t===document.scrollingElement}function r3(t){const e={x:0,y:0},s=i3(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},r=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,a=t.scrollTop>=n.y,l=t.scrollLeft>=n.x;return{isTop:r,isLeft:o,isBottom:a,isRight:l,maxScroll:n,minScroll:e}}const bC={x:.2,y:.2};function _C(t,e,s,n,r){let{top:o,left:a,right:l,bottom:c}=s;n===void 0&&(n=10),r===void 0&&(r=bC);const{isTop:d,isBottom:h,isLeft:u,isRight:f}=r3(t),m={x:0,y:0},p={x:0,y:0},g={height:e.height*r.y,width:e.width*r.x};return!d&&o<=e.top+g.height?(m.y=Kt.Backward,p.y=n*Math.abs((e.top+g.height-o)/g.height)):!h&&c>=e.bottom-g.height&&(m.y=Kt.Forward,p.y=n*Math.abs((e.bottom-g.height-c)/g.height)),!f&&l>=e.right-g.width?(m.x=Kt.Forward,p.x=n*Math.abs((e.right-g.width-l)/g.width)):!u&&a<=e.left+g.width&&(m.x=Kt.Backward,p.x=n*Math.abs((e.left+g.width-a)/g.width)),{direction:m,speed:p}}function yC(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:a}=window;return{top:0,left:0,right:o,bottom:a,width:o,height:a}}const{top:e,left:s,right:n,bottom:r}=t.getBoundingClientRect();return{top:e,left:s,right:n,bottom:r,width:t.clientWidth,height:t.clientHeight}}function o3(t){return t.reduce((e,s)=>Zi(e,$0(s)),nn)}function LC(t){return t.reduce((e,s)=>e+s3(s),0)}function SC(t){return t.reduce((e,s)=>e+n3(s),0)}function a3(t,e){if(e===void 0&&(e=Pr),!t)return;const{top:s,left:n,bottom:r,right:o}=e(t);t3(t)&&(r<=0||o<=0||s>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const wC=[["x",["left","right"],LC],["y",["top","bottom"],SC]];class H9{constructor(e,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=uc(s),r=o3(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,a,l]of wC)for(const c of a)Object.defineProperty(this,c,{get:()=>{const d=l(n),h=r[o]-d;return this.rect[c]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class bo{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...s)})},this.target=e}add(e,s,n){var r;(r=this.target)==null||r.addEventListener(e,s,n),this.listeners.push([e,s,n])}}function jC(t){const{EventTarget:e}=_s(t);return t instanceof e?t:Rr(t)}function Yc(t,e){const s=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(s**2+n**2)>e:"x"in e&&"y"in e?s>e.x&&n>e.y:"x"in e?s>e.x:"y"in e?n>e.y:!1}var Hs;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Hs||(Hs={}));function Uh(t){t.preventDefault()}function CC(t){t.stopPropagation()}var st;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(st||(st={}));const l3={start:[st.Space,st.Enter],cancel:[st.Esc],end:[st.Space,st.Enter,st.Tab]},kC=(t,e)=>{let{currentCoordinates:s}=e;switch(t.code){case st.Right:return{...s,x:s.x+25};case st.Left:return{...s,x:s.x-25};case st.Down:return{...s,y:s.y+25};case st.Up:return{...s,y:s.y-25}}};class Ir{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:s}}=e;this.props=e,this.listeners=new bo(Rr(s)),this.windowListeners=new bo(_s(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Hs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:s}=this.props,n=e.node.current;n&&a3(n),s(nn)}handleKeyDown(e){if(cc(e)){const{active:s,context:n,options:r}=this.props,{keyboardCodes:o=l3,coordinateGetter:a=kC,scrollBehavior:l="smooth"}=r,{code:c}=e;if(o.end.includes(c)){this.handleEnd(e);return}if(o.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:d}=n.current,h=d?{x:d.left,y:d.top}:nn;this.referenceCoordinates||(this.referenceCoordinates=h);const u=a(e,{active:s,context:n.current,currentCoordinates:h});if(u){const f=$o(u,h),m={x:0,y:0},{scrollableAncestors:p}=n.current;for(const g of p){const x=e.code,{isTop:v,isRight:_,isLeft:b,isBottom:y,maxScroll:L,minScroll:w}=r3(g),S=yC(g),j={x:Math.min(x===st.Right?S.right-S.width/2:S.right,Math.max(x===st.Right?S.left:S.left+S.width/2,u.x)),y:Math.min(x===st.Down?S.bottom-S.height/2:S.bottom,Math.max(x===st.Down?S.top:S.top+S.height/2,u.y))},C=x===st.Right&&!_||x===st.Left&&!b,V=x===st.Down&&!y||x===st.Up&&!v;if(C&&j.x!==u.x){const N=g.scrollLeft+f.x,T=x===st.Right&&N<=L.x||x===st.Left&&N>=w.x;if(T&&!f.y){g.scrollTo({left:N,behavior:l});return}T?m.x=g.scrollLeft-N:m.x=x===st.Right?g.scrollLeft-L.x:g.scrollLeft-w.x,m.x&&g.scrollBy({left:-m.x,behavior:l});break}else if(V&&j.y!==u.y){const N=g.scrollTop+f.y,T=x===st.Down&&N<=L.y||x===st.Up&&N>=w.y;if(T&&!f.x){g.scrollTo({top:N,behavior:l});return}T?m.y=g.scrollTop-N:m.y=x===st.Down?g.scrollTop-L.y:g.scrollTop-w.y,m.y&&g.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Zi($o(u,this.referenceCoordinates),m))}}}handleMove(e,s){const{onMove:n}=this.props;e.preventDefault(),n(s)}handleEnd(e){const{onEnd:s}=this.props;e.preventDefault(),this.detach(),s()}handleCancel(e){const{onCancel:s}=this.props;e.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ir.activators=[{eventName:"onKeyDown",handler:(t,e,s)=>{let{keyboardCodes:n=l3,onActivation:r}=e,{active:o}=s;const{code:a}=t.nativeEvent;if(n.start.includes(a)){const l=o.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),r?.({event:t.nativeEvent}),!0)}return!1}}];function Hh(t){return!!(t&&"distance"in t)}function Kh(t){return!!(t&&"delay"in t)}class K9{constructor(e,s,n){var r;n===void 0&&(n=jC(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=s;const{event:o}=e,{target:a}=o;this.props=e,this.events=s,this.document=Rr(a),this.documentListeners=new bo(this.document),this.listeners=new bo(n),this.windowListeners=new bo(_s(a)),this.initialCoordinates=(r=jl(o))!=null?r:nn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:s,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Hs.Resize,this.handleCancel),this.windowListeners.add(Hs.DragStart,Uh),this.windowListeners.add(Hs.VisibilityChange,this.handleCancel),this.windowListeners.add(Hs.ContextMenu,Uh),this.documentListeners.add(Hs.Keydown,this.handleKeydown),s){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Kh(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Hh(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,s){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:e}=this,{onStart:s}=this.props;e&&(this.activated=!0,this.documentListeners.add(Hs.Click,CC,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Hs.SelectionChange,this.removeTextSelection),s(e))}handleMove(e){var s;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:a,options:{activationConstraint:l}}=o;if(!r)return;const c=(s=jl(e))!=null?s:nn,d=$o(r,c);if(!n&&l){if(Hh(l)){if(l.tolerance!=null&&Yc(d,l.tolerance))return this.handleCancel();if(Yc(d,l.distance))return this.handleStart()}if(Kh(l)&&Yc(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleCancel(){const{onAbort:e,onCancel:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleKeydown(e){e.code===st.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const VC={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Dr extends K9{constructor(e){const{event:s}=e,n=Rr(s.target);super(e,VC,n)}}Dr.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return!s.isPrimary||s.button!==0?!1:(n?.({event:s}),!0)}}];const NC={move:{name:"mousemove"},end:{name:"mouseup"}};var B0;(function(t){t[t.RightClick=2]="RightClick"})(B0||(B0={}));class AC extends K9{constructor(e){super(e,NC,Rr(e.event.target))}}AC.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;return s.button===B0.RightClick?!1:(n?.({event:s}),!0)}}];const Jc={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class TC extends K9{constructor(e){super(e,Jc)}static setup(){return window.addEventListener(Jc.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Jc.move.name,e)};function e(){}}}TC.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:n}=e;const{touches:r}=s;return r.length>1?!1:(n?.({event:s}),!0)}}];var _o;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(_o||(_o={}));var kl;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(kl||(kl={}));function EC(t){let{acceleration:e,activator:s=_o.Pointer,canScroll:n,draggingRect:r,enabled:o,interval:a=5,order:l=kl.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:h,delta:u,threshold:f}=t;const m=PC({delta:u,disabled:!o}),[p,g]=qj(),x=k.useRef({x:0,y:0}),v=k.useRef({x:0,y:0}),_=k.useMemo(()=>{switch(s){case _o.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case _o.DraggableRect:return r}},[s,r,c]),b=k.useRef(null),y=k.useCallback(()=>{const w=b.current;if(!w)return;const S=x.current.x*v.current.x,j=x.current.y*v.current.y;w.scrollBy(S,j)},[]),L=k.useMemo(()=>l===kl.TreeOrder?[...d].reverse():d,[l,d]);k.useEffect(()=>{if(!o||!d.length||!_){g();return}for(const w of L){if(n?.(w)===!1)continue;const S=d.indexOf(w),j=h[S];if(!j)continue;const{direction:C,speed:V}=_C(w,j,_,e,f);for(const N of["x","y"])m[N][C[N]]||(V[N]=0,C[N]=0);if(V.x>0||V.y>0){g(),b.current=w,p(y,a),x.current=V,v.current=C;return}}x.current={x:0,y:0},v.current={x:0,y:0},g()},[e,y,n,g,o,a,JSON.stringify(_),JSON.stringify(m),p,d,L,h,JSON.stringify(f)])}const RC={x:{[Kt.Backward]:!1,[Kt.Forward]:!1},y:{[Kt.Backward]:!1,[Kt.Forward]:!1}};function PC(t){let{delta:e,disabled:s}=t;const n=wl(e);return la(r=>{if(s||!n||!r)return RC;const o={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[Kt.Backward]:r.x[Kt.Backward]||o.x===-1,[Kt.Forward]:r.x[Kt.Forward]||o.x===1},y:{[Kt.Backward]:r.y[Kt.Backward]||o.y===-1,[Kt.Forward]:r.y[Kt.Forward]||o.y===1}}},[s,e,n])}function IC(t,e){const s=e!=null?t.get(e):void 0,n=s?s.node.current:null;return la(r=>{var o;return e==null?null:(o=n??r)!=null?o:null},[n,e])}function DC(t,e){return k.useMemo(()=>t.reduce((s,n)=>{const{sensor:r}=n,o=r.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,n)}));return[...s,...o]},[]),[t,e])}var Bo;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Bo||(Bo={}));var z0;(function(t){t.Optimized="optimized"})(z0||(z0={}));const Wh=new Map;function OC(t,e){let{dragging:s,dependencies:n,config:r}=e;const[o,a]=k.useState(null),{frequency:l,measure:c,strategy:d}=r,h=k.useRef(t),u=x(),f=Mo(u),m=k.useCallback(function(v){v===void 0&&(v=[]),!f.current&&a(_=>_===null?v:_.concat(v.filter(b=>!_.includes(b))))},[f]),p=k.useRef(null),g=la(v=>{if(u&&!s)return Wh;if(!v||v===Wh||h.current!==t||o!=null){const _=new Map;for(let b of t){if(!b)continue;if(o&&o.length>0&&!o.includes(b.id)&&b.rect.current){_.set(b.id,b.rect.current);continue}const y=b.node.current,L=y?new H9(c(y),y):null;b.rect.current=L,L&&_.set(b.id,L)}return _}return v},[t,o,s,u,c]);return k.useEffect(()=>{h.current=t},[t]),k.useEffect(()=>{u||m()},[s,u]),k.useEffect(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),k.useEffect(()=>{u||typeof l!="number"||p.current!==null||(p.current=setTimeout(()=>{m(),p.current=null},l))},[l,u,m,...n]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:o!=null};function x(){switch(d){case Bo.Always:return!1;case Bo.BeforeDragging:return s;default:return!s}}}function W9(t,e){return la(s=>t?s||(typeof e=="function"?e(t):t):null,[e,t])}function MC(t,e){return W9(t,e)}function $C(t){let{callback:e,disabled:s}=t;const n=lc(e),r=k.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,s]);return k.useEffect(()=>()=>r?.disconnect(),[r]),r}function hc(t){let{callback:e,disabled:s}=t;const n=lc(e),r=k.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[s]);return k.useEffect(()=>()=>r?.disconnect(),[r]),r}function BC(t){return new H9(Pr(t),t)}function qh(t,e,s){e===void 0&&(e=BC);const[n,r]=k.useState(null);function o(){r(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??s)!=null?d:null}const h=e(t);return JSON.stringify(c)===JSON.stringify(h)?c:h})}const a=$C({callback(c){if(t)for(const d of c){const{type:h,target:u}=d;if(h==="childList"&&u instanceof HTMLElement&&u.contains(t)){o();break}}}}),l=hc({callback:o});return sn(()=>{o(),t?(l?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),a?.disconnect())},[t]),n}function zC(t){const e=W9(t);return Zp(t,e)}const Gh=[];function FC(t){const e=k.useRef(t),s=la(n=>t?n&&n!==Gh&&t&&e.current&&t.parentNode===e.current.parentNode?n:uc(t):Gh,[t]);return k.useEffect(()=>{e.current=t},[t]),s}function UC(t){const[e,s]=k.useState(null),n=k.useRef(t),r=k.useCallback(o=>{const a=Gc(o.target);a&&s(l=>l?(l.set(a,$0(a)),new Map(l)):null)},[]);return k.useEffect(()=>{const o=n.current;if(t!==o){a(o);const l=t.map(c=>{const d=Gc(c);return d?(d.addEventListener("scroll",r,{passive:!0}),[d,$0(d)]):null}).filter(c=>c!=null);s(l.length?new Map(l):null),n.current=t}return()=>{a(t),a(o)};function a(l){l.forEach(c=>{const d=Gc(c);d?.removeEventListener("scroll",r)})}},[r,t]),k.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,a)=>Zi(o,a),nn):o3(t):nn,[t,e])}function Yh(t,e){e===void 0&&(e=[]);const s=k.useRef(null);return k.useEffect(()=>{s.current=null},e),k.useEffect(()=>{const n=t!==nn;n&&!s.current&&(s.current=t),!n&&s.current&&(s.current=null)},[t]),s.current?$o(t,s.current):nn}function HC(t){k.useEffect(()=>{if(!ac)return;const e=t.map(s=>{let{sensor:n}=s;return n.setup==null?void 0:n.setup()});return()=>{for(const s of e)s?.()}},t.map(e=>{let{sensor:s}=e;return s}))}function KC(t,e){return k.useMemo(()=>t.reduce((s,n)=>{let{eventName:r,handler:o}=n;return s[r]=a=>{o(a,e)},s},{}),[t,e])}function c3(t){return k.useMemo(()=>t?gC(t):null,[t])}const Jh=[];function WC(t,e){e===void 0&&(e=Pr);const[s]=t,n=c3(s?_s(s):null),[r,o]=k.useState(Jh);function a(){o(()=>t.length?t.map(c=>i3(c)?n:new H9(e(c),c)):Jh)}const l=hc({callback:a});return sn(()=>{l?.disconnect(),a(),t.forEach(c=>l?.observe(c))},[t]),r}function d3(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return aa(e)?e:t}function qC(t){let{measure:e}=t;const[s,n]=k.useState(null),r=k.useCallback(d=>{for(const{target:h}of d)if(aa(h)){n(u=>{const f=e(h);return u?{...u,width:f.width,height:f.height}:f});break}},[e]),o=hc({callback:r}),a=k.useCallback(d=>{const h=d3(d);o?.disconnect(),h&&o?.observe(h),n(h?e(h):null)},[e,o]),[l,c]=Sl(a);return k.useMemo(()=>({nodeRef:l,rect:s,setRef:c}),[s,l,c])}const GC=[{sensor:Dr,options:{}},{sensor:Ir,options:{}}],YC={current:{}},Ua={draggable:{measure:Fh},droppable:{measure:Fh,strategy:Bo.WhileDragging,frequency:z0.Optimized},dragOverlay:{measure:Pr}};class yo extends Map{get(e){var s;return e!=null&&(s=super.get(e))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:s}=e;return!s})}getNodeFor(e){var s,n;return(s=(n=this.get(e))==null?void 0:n.node.current)!=null?s:void 0}}const JC={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new yo,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Cl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ua,measureDroppableContainers:Cl,windowRect:null,measuringScheduled:!1},u3={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Cl,draggableNodes:new Map,over:null,measureDroppableContainers:Cl},da=k.createContext(u3),h3=k.createContext(JC);function XC(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new yo}}}function QC(t,e){switch(e.type){case Bt.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Bt.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Bt.DragEnd:case Bt.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Bt.RegisterDroppable:{const{element:s}=e,{id:n}=s,r=new yo(t.droppable.containers);return r.set(n,s),{...t,droppable:{...t.droppable,containers:r}}}case Bt.SetDroppableDisabled:{const{id:s,key:n,disabled:r}=e,o=t.droppable.containers.get(s);if(!o||n!==o.key)return t;const a=new yo(t.droppable.containers);return a.set(s,{...o,disabled:r}),{...t,droppable:{...t.droppable,containers:a}}}case Bt.UnregisterDroppable:{const{id:s,key:n}=e,r=t.droppable.containers.get(s);if(!r||n!==r.key)return t;const o=new yo(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function ZC(t){let{disabled:e}=t;const{active:s,activatorEvent:n,draggableNodes:r}=k.useContext(da),o=wl(n),a=wl(s?.id);return k.useEffect(()=>{if(!e&&!n&&o&&a!=null){if(!cc(o)||document.activeElement===o.target)return;const l=r.get(a);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[c.current,d.current]){if(!h)continue;const u=Jj(h);if(u){u.focus();break}}})}},[n,e,r,a,o]),null}function f3(t,e){let{transform:s,...n}=e;return t!=null&&t.length?t.reduce((r,o)=>o({transform:r,...n}),s):s}function ek(t){return k.useMemo(()=>({draggable:{...Ua.draggable,...t?.draggable},droppable:{...Ua.droppable,...t?.droppable},dragOverlay:{...Ua.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function tk(t){let{activeNode:e,measure:s,initialRect:n,config:r=!0}=t;const o=k.useRef(!1),{x:a,y:l}=typeof r=="boolean"?{x:r,y:r}:r;sn(()=>{if(!a&&!l||!e){o.current=!1;return}if(o.current||!n)return;const d=e?.node.current;if(!d||d.isConnected===!1)return;const h=s(d),u=Zp(h,n);if(a||(u.x=0),l||(u.y=0),o.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const f=t3(d);f&&f.scrollBy({top:u.y,left:u.x})}},[e,a,l,n,s])}const fc=k.createContext({...nn,scaleX:1,scaleY:1});var zn;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(zn||(zn={}));const mc=k.memo(function(e){var s,n,r,o;let{id:a,accessibility:l,autoScroll:c=!0,children:d,sensors:h=GC,collisionDetection:u=dC,measuring:f,modifiers:m,...p}=e;const g=k.useReducer(QC,void 0,XC),[x,v]=g,[_,b]=sC(),[y,L]=k.useState(zn.Uninitialized),w=y===zn.Initialized,{draggable:{active:S,nodes:j,translate:C},droppable:{containers:V}}=x,N=S!=null?j.get(S):null,T=k.useRef({initial:null,translated:null}),A=k.useMemo(()=>{var nt;return S!=null?{id:S,data:(nt=N?.data)!=null?nt:YC,rect:T}:null},[S,N]),E=k.useRef(null),[R,D]=k.useState(null),[P,I]=k.useState(null),O=Mo(p,Object.values(p)),B=ca("DndDescribedBy",a),z=k.useMemo(()=>V.getEnabled(),[V]),$=ek(f),{droppableRects:U,measureDroppableContainers:W,measuringScheduled:X}=OC(z,{dragging:w,dependencies:[C.x,C.y],config:$.droppable}),H=IC(j,S),Z=k.useMemo(()=>P?jl(P):null,[P]),K=gt(),Y=MC(H,$.draggable.measure);tk({activeNode:S!=null?j.get(S):null,config:K.layoutShiftCompensation,initialRect:Y,measure:$.draggable.measure});const F=qh(H,$.draggable.measure,Y),Q=qh(H?H.parentElement:null),J=k.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ee=V.getNodeFor((s=J.current.over)==null?void 0:s.id),q=qC({measure:$.dragOverlay.measure}),se=(n=q.nodeRef.current)!=null?n:H,ne=w?(r=q.rect)!=null?r:F:null,le=!!(q.nodeRef.current&&q.rect),G=zC(le?null:F),oe=c3(se?_s(se):null),me=FC(w?ee??H:null),ue=WC(me),ye=f3(m,{transform:{x:C.x-G.x,y:C.y-G.y,scaleX:1,scaleY:1},activatorEvent:P,active:A,activeNodeRect:F,containerNodeRect:Q,draggingNodeRect:ne,over:J.current.over,overlayNodeRect:q.rect,scrollableAncestors:me,scrollableAncestorRects:ue,windowRect:oe}),Le=Z?Zi(Z,C):null,Ce=UC(me),ze=Yh(Ce),Te=Yh(Ce,[F]),Se=Zi(ye,ze),be=ne?fC(ne,ye):null,Re=A&&be?u({active:A,collisionRect:be,droppableRects:U,droppableContainers:z,pointerCoordinates:Le}):null,Ve=Qp(Re,"id"),[he,Pe]=k.useState(null),Me=le?ye:Zi(ye,Te),xe=uC(Me,(o=he?.rect)!=null?o:null,F),Ae=k.useRef(null),pe=k.useCallback((nt,lt)=>{let{sensor:qe,options:Rt}=lt;if(E.current==null)return;const ct=j.get(E.current);if(!ct)return;const Ye=nt.nativeEvent,ot=new qe({active:E.current,activeNode:ct,event:Ye,options:Rt,context:J,onAbort(ae){if(!j.get(ae))return;const{onDragAbort:Ze}=O.current,mt={id:ae};Ze?.(mt),_({type:"onDragAbort",event:mt})},onPending(ae,Fe,Ze,mt){if(!j.get(ae))return;const{onDragPending:ms}=O.current,Be={id:ae,constraint:Fe,initialCoordinates:Ze,offset:mt};ms?.(Be),_({type:"onDragPending",event:Be})},onStart(ae){const Fe=E.current;if(Fe==null)return;const Ze=j.get(Fe);if(!Ze)return;const{onDragStart:mt}=O.current,Nt={activatorEvent:Ye,active:{id:Fe,data:Ze.data,rect:T}};qi.unstable_batchedUpdates(()=>{mt?.(Nt),L(zn.Initializing),v({type:Bt.DragStart,initialCoordinates:ae,active:Fe}),_({type:"onDragStart",event:Nt}),D(Ae.current),I(Ye)})},onMove(ae){v({type:Bt.DragMove,coordinates:ae})},onEnd:ht(Bt.DragEnd),onCancel:ht(Bt.DragCancel)});Ae.current=ot;function ht(ae){return async function(){const{active:Ze,collisions:mt,over:Nt,scrollAdjustedTranslate:ms}=J.current;let Be=null;if(Ze&&ms){const{cancelDrop:Pt}=O.current;Be={activatorEvent:Ye,active:Ze,collisions:mt,delta:ms,over:Nt},ae===Bt.DragEnd&&typeof Pt=="function"&&await Promise.resolve(Pt(Be))&&(ae=Bt.DragCancel)}E.current=null,qi.unstable_batchedUpdates(()=>{v({type:ae}),L(zn.Uninitialized),Pe(null),D(null),I(null),Ae.current=null;const Pt=ae===Bt.DragEnd?"onDragEnd":"onDragCancel";if(Be){const Bs=O.current[Pt];Bs?.(Be),_({type:Pt,event:Be})}})}}},[j]),ke=k.useCallback((nt,lt)=>(qe,Rt)=>{const ct=qe.nativeEvent,Ye=j.get(Rt);if(E.current!==null||!Ye||ct.dndKit||ct.defaultPrevented)return;const ot={active:Ye};nt(qe,lt.options,ot)===!0&&(ct.dndKit={capturedBy:lt.sensor},E.current=Rt,pe(qe,lt))},[j,pe]),$e=DC(h,ke);HC(h),sn(()=>{F&&y===zn.Initializing&&L(zn.Initialized)},[F,y]),k.useEffect(()=>{const{onDragMove:nt}=O.current,{active:lt,activatorEvent:qe,collisions:Rt,over:ct}=J.current;if(!lt||!qe)return;const Ye={active:lt,activatorEvent:qe,collisions:Rt,delta:{x:Se.x,y:Se.y},over:ct};qi.unstable_batchedUpdates(()=>{nt?.(Ye),_({type:"onDragMove",event:Ye})})},[Se.x,Se.y]),k.useEffect(()=>{const{active:nt,activatorEvent:lt,collisions:qe,droppableContainers:Rt,scrollAdjustedTranslate:ct}=J.current;if(!nt||E.current==null||!lt||!ct)return;const{onDragOver:Ye}=O.current,ot=Rt.get(Ve),ht=ot&&ot.rect.current?{id:ot.id,rect:ot.rect.current,data:ot.data,disabled:ot.disabled}:null,ae={active:nt,activatorEvent:lt,collisions:qe,delta:{x:ct.x,y:ct.y},over:ht};qi.unstable_batchedUpdates(()=>{Pe(ht),Ye?.(ae),_({type:"onDragOver",event:ae})})},[Ve]),sn(()=>{J.current={activatorEvent:P,active:A,activeNode:H,collisionRect:be,collisions:Re,droppableRects:U,draggableNodes:j,draggingNode:se,draggingNodeRect:ne,droppableContainers:V,over:he,scrollableAncestors:me,scrollAdjustedTranslate:Se},T.current={initial:ne,translated:be}},[A,H,Re,be,j,se,ne,U,V,he,me,Se]),EC({...K,delta:C,draggingRect:be,pointerCoordinates:Le,scrollableAncestors:me,scrollableAncestorRects:ue});const ge=k.useMemo(()=>({active:A,activeNode:H,activeNodeRect:F,activatorEvent:P,collisions:Re,containerNodeRect:Q,dragOverlay:q,draggableNodes:j,droppableContainers:V,droppableRects:U,over:he,measureDroppableContainers:W,scrollableAncestors:me,scrollableAncestorRects:ue,measuringConfiguration:$,measuringScheduled:X,windowRect:oe}),[A,H,F,P,Re,Q,q,j,V,U,he,W,me,ue,$,X,oe]),Ke=k.useMemo(()=>({activatorEvent:P,activators:$e,active:A,activeNodeRect:F,ariaDescribedById:{draggable:B},dispatch:v,draggableNodes:j,over:he,measureDroppableContainers:W}),[P,$e,A,F,v,B,j,he,W]);return et.createElement(Yp.Provider,{value:b},et.createElement(da.Provider,{value:Ke},et.createElement(h3.Provider,{value:ge},et.createElement(fc.Provider,{value:xe},d)),et.createElement(ZC,{disabled:l?.restoreFocus===!1})),et.createElement(rC,{...l,hiddenTextDescribedById:B}));function gt(){const nt=R?.autoScrollEnabled===!1,lt=typeof c=="object"?c.enabled===!1:c===!1,qe=w&&!nt&&!lt;return typeof c=="object"?{...c,enabled:qe}:{enabled:qe}}}),sk=k.createContext(null),Xh="button",nk="Draggable";function m3(t){let{id:e,data:s,disabled:n=!1,attributes:r}=t;const o=ca(nk),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:f}=k.useContext(da),{role:m=Xh,roleDescription:p="draggable",tabIndex:g=0}=r??{},x=c?.id===e,v=k.useContext(x?fc:sk),[_,b]=Sl(),[y,L]=Sl(),w=KC(a,e),S=Mo(s);sn(()=>(u.set(e,{id:e,key:o,node:_,activatorNode:y,data:S}),()=>{const C=u.get(e);C&&C.key===o&&u.delete(e)}),[u,e]);const j=k.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":n,"aria-pressed":x&&m===Xh?!0:void 0,"aria-roledescription":p,"aria-describedby":h.draggable}),[n,m,g,x,p,h.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:j,isDragging:x,listeners:n?void 0:w,node:_,over:f,setNodeRef:b,setActivatorNodeRef:L,transform:v}}function p3(){return k.useContext(h3)}const ik="Droppable",rk={timeout:25};function ok(t){let{data:e,disabled:s=!1,id:n,resizeObserverConfig:r}=t;const o=ca(ik),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=k.useContext(da),h=k.useRef({disabled:s}),u=k.useRef(!1),f=k.useRef(null),m=k.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:x}={...rk,...r},v=Mo(g??n),_=k.useCallback(()=>{if(!u.current){u.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{d(Array.isArray(v.current)?v.current:[v.current]),m.current=null},x)},[x]),b=hc({callback:_,disabled:p||!a}),y=k.useCallback((j,C)=>{b&&(C&&(b.unobserve(C),u.current=!1),j&&b.observe(j))},[b]),[L,w]=Sl(y),S=Mo(e);return k.useEffect(()=>{!b||!L.current||(b.disconnect(),u.current=!1,b.observe(L.current))},[L,b]),k.useEffect(()=>(l({type:Bt.RegisterDroppable,element:{id:n,key:o,disabled:s,node:L,rect:f,data:S}}),()=>l({type:Bt.UnregisterDroppable,key:o,id:n})),[n]),k.useEffect(()=>{s!==h.current.disabled&&(l({type:Bt.SetDroppableDisabled,id:n,key:o,disabled:s}),h.current.disabled=s)},[n,o,s,l]),{active:a,rect:f,isOver:c?.id===n,node:L,over:c,setNodeRef:w}}function ak(t){let{animation:e,children:s}=t;const[n,r]=k.useState(null),[o,a]=k.useState(null),l=wl(s);return!s&&!n&&l&&r(l),sn(()=>{if(!o)return;const c=n?.key,d=n?.props.id;if(c==null||d==null){r(null);return}Promise.resolve(e(d,o)).then(()=>{r(null)})},[e,n,o]),et.createElement(et.Fragment,null,s,n?k.cloneElement(n,{ref:a}):null)}const lk={x:0,y:0,scaleX:1,scaleY:1};function ck(t){let{children:e}=t;return et.createElement(da.Provider,{value:u3},et.createElement(fc.Provider,{value:lk},e))}const dk={position:"fixed",touchAction:"none"},uk=t=>cc(t)?"transform 250ms ease":void 0,hk=k.forwardRef((t,e)=>{let{as:s,activatorEvent:n,adjustScale:r,children:o,className:a,rect:l,style:c,transform:d,transition:h=uk}=t;if(!l)return null;const u=r?d:{...d,scaleX:1,scaleY:1},f={...dk,width:l.width,height:l.height,top:l.top,left:l.left,transform:yn.Transform.toString(u),transformOrigin:r&&n?oC(n,l):void 0,transition:typeof h=="function"?h(n):h,...c};return et.createElement(s,{className:a,style:f,ref:e},o)}),fk=t=>e=>{let{active:s,dragOverlay:n}=e;const r={},{styles:o,className:a}=t;if(o!=null&&o.active)for(const[l,c]of Object.entries(o.active))c!==void 0&&(r[l]=s.node.style.getPropertyValue(l),s.node.style.setProperty(l,c));if(o!=null&&o.dragOverlay)for(const[l,c]of Object.entries(o.dragOverlay))c!==void 0&&n.node.style.setProperty(l,c);return a!=null&&a.active&&s.node.classList.add(a.active),a!=null&&a.dragOverlay&&n.node.classList.add(a.dragOverlay),function(){for(const[c,d]of Object.entries(r))s.node.style.setProperty(c,d);a!=null&&a.active&&s.node.classList.remove(a.active)}},mk=t=>{let{transform:{initial:e,final:s}}=t;return[{transform:yn.Transform.toString(e)},{transform:yn.Transform.toString(s)}]},pk={duration:250,easing:"ease",keyframes:mk,sideEffects:fk({styles:{active:{opacity:"0"}}})};function gk(t){let{config:e,draggableNodes:s,droppableContainers:n,measuringConfiguration:r}=t;return lc((o,a)=>{if(e===null)return;const l=s.get(o);if(!l)return;const c=l.node.current;if(!c)return;const d=d3(a);if(!d)return;const{transform:h}=_s(a).getComputedStyle(a),u=e3(h);if(!u)return;const f=typeof e=="function"?e:xk(e);return a3(c,r.draggable.measure),f({active:{id:o,data:l.data,node:c,rect:r.draggable.measure(c)},draggableNodes:s,dragOverlay:{node:a,rect:r.dragOverlay.measure(d)},droppableContainers:n,measuringConfiguration:r,transform:u})})}function xk(t){const{duration:e,easing:s,sideEffects:n,keyframes:r}={...pk,...t};return o=>{let{active:a,dragOverlay:l,transform:c,...d}=o;if(!e)return;const h={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},u={scaleX:c.scaleX!==1?a.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?a.rect.height*c.scaleY/l.rect.height:1},f={x:c.x-h.x,y:c.y-h.y,...u},m=r({...d,active:a,dragOverlay:l,transform:{initial:c,final:f}}),[p]=m,g=m[m.length-1];if(JSON.stringify(p)===JSON.stringify(g))return;const x=n?.({active:a,dragOverlay:l,...d}),v=l.node.animate(m,{duration:e,easing:s,fill:"forwards"});return new Promise(_=>{v.onfinish=()=>{x?.(),_()}})}}let Qh=0;function vk(t){return k.useMemo(()=>{if(t!=null)return Qh++,Qh},[t])}const q9=et.memo(t=>{let{adjustScale:e=!1,children:s,dropAnimation:n,style:r,transition:o,modifiers:a,wrapperElement:l="div",className:c,zIndex:d=999}=t;const{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggableNodes:p,droppableContainers:g,dragOverlay:x,over:v,measuringConfiguration:_,scrollableAncestors:b,scrollableAncestorRects:y,windowRect:L}=p3(),w=k.useContext(fc),S=vk(u?.id),j=f3(a,{activatorEvent:h,active:u,activeNodeRect:f,containerNodeRect:m,draggingNodeRect:x.rect,over:v,overlayNodeRect:x.rect,scrollableAncestors:b,scrollableAncestorRects:y,transform:w,windowRect:L}),C=W9(f),V=gk({config:n,draggableNodes:p,droppableContainers:g,measuringConfiguration:_}),N=C?x.setRef:void 0;return et.createElement(ck,null,et.createElement(ak,{animation:V},u&&S?et.createElement(hk,{key:S,id:u.id,ref:N,as:l,activatorEvent:h,adjustScale:e,className:c,transition:o,rect:C,style:{zIndex:d,...r},transform:j},s):null))}),rn=6,Cn=100,Zh=12,bk=5,_k={w:3,h:2};class F0 extends k.Component{state={hasError:!1};static getDerivedStateFromError(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error"}}componentDidCatch(e,s){console.error("[home-tiles] tile crashed:",e,s.componentStack)}render(){return this.state.hasError?i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center",children:[i.jsx("span",{className:"flex size-8 items-center justify-center rounded-md bg-destructive/10 text-destructive",children:i.jsx(br,{size:16})}),i.jsx("p",{className:"text-sm font-medium text-foreground",children:"This tile crashed"}),i.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:this.state.message??"Something went wrong rendering this tile."})]}):this.props.children}}function yk(t){const e=M.c(72),{tiles:s,isEditMode:n,renderTile:r,onMove:o,onResize:a,onRemove:l}=t,c=Lr(),d=k.useRef(null),[h,u]=k.useState(null),[f,m]=k.useState(null);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={activationConstraint:{distance:4}},e[0]=p):p=e[0];const g=dc(Zn(Dr,p),Zn(Ir)),x=s.reduce(Lk,0),v=n?Math.max(x+2,4):Math.max(x,1);let _;e[1]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{const O=d.current?.getBoundingClientRect();return O?{cellWidth:O.width/rn,cellHeight:Cn}:null},e[1]=_):_=e[1];const b=_;let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=O=>{u(String(O.active.id)),m(b())},e[2]=y):y=e[2];const L=y;let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=O=>{const B=String(O.active.id),z=f??b();if(u(null),m(null),!z||z.cellWidth<=0)return;const $=s.find(X=>X.id===B);if(!$)return;const U=Math.round(O.delta.x/z.cellWidth),W=Math.round(O.delta.y/z.cellHeight);U===0&&W===0||o(B,{x:$.x+U,y:$.y+W})},e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6];const S=w;if(c){let O;if(e[7]!==r||e[8]!==s){let z;e[10]!==r?(z=$=>i.jsx("div",{className:"group bg-card card-shadow rounded-2xl overflow-hidden",style:{minHeight:Cn},children:i.jsx(F0,{children:r($)})},$.id),e[10]=r,e[11]=z):z=e[11],O=s.map(z),e[7]=r,e[8]=s,e[9]=O}else O=e[9];let B;return e[12]!==O?(B=i.jsx("div",{className:"flex flex-col gap-3 px-4 pb-8",children:O}),e[12]=O,e[13]=B):B=e[13],B}let j,C,V,N,T,A,E,R,D;if(e[14]!==h||e[15]!==f||e[16]!==n||e[17]!==S||e[18]!==l||e[19]!==a||e[20]!==r||e[21]!==g||e[22]!==s||e[23]!==v){const O=h?s.find(Z=>Z.id===h):null;C=mc,R=g,D=L,V=S;const B=v*Cn,z=n?Cn*4:Cn;let $;e[33]!==B||e[34]!==z?($={height:B,minHeight:z},e[33]=B,e[34]=z,e[35]=$):$=e[35];let U;e[36]!==n||e[37]!==s||e[38]!==v?(U=n&&i.jsx(Sk,{rows:v,tiles:s}),e[36]=n,e[37]=s,e[38]=v,e[39]=U):U=e[39];let W;if(e[40]!==h||e[41]!==n||e[42]!==l||e[43]!==a||e[44]!==r||e[45]!==s){let Z;e[47]!==h||e[48]!==n||e[49]!==l||e[50]!==a||e[51]!==r?(Z=K=>i.jsx(jk,{tile:K,isEditMode:n,isDragging:h===K.id,onResize:a,onRemove:l,children:r(K)},K.id),e[47]=h,e[48]=n,e[49]=l,e[50]=a,e[51]=r,e[52]=Z):Z=e[52],W=s.map(Z),e[40]=h,e[41]=n,e[42]=l,e[43]=a,e[44]=r,e[45]=s,e[46]=W}else W=e[46];e[53]!==$||e[54]!==U||e[55]!==W?(N=i.jsxs("div",{ref:d,className:"relative w-full",style:$,children:[U,W]}),e[53]=$,e[54]=U,e[55]=W,e[56]=N):N=e[56],j=q9,T=null;const X=O&&f?O.w*f.cellWidth-Zh:void 0,H=O&&f?O.h*f.cellHeight-Zh:void 0;e[57]!==X||e[58]!==H?(A={width:X,height:H},e[57]=X,e[58]=H,e[59]=A):A=e[59],E=O&&i.jsx("div",{className:"bg-card card-shadow rounded-2xl shadow-2xl ring-2 ring-primary/40 h-full overflow-hidden opacity-95",children:i.jsx(F0,{children:r(O)})}),e[14]=h,e[15]=f,e[16]=n,e[17]=S,e[18]=l,e[19]=a,e[20]=r,e[21]=g,e[22]=s,e[23]=v,e[24]=j,e[25]=C,e[26]=V,e[27]=N,e[28]=T,e[29]=A,e[30]=E,e[31]=R,e[32]=D}else j=e[24],C=e[25],V=e[26],N=e[27],T=e[28],A=e[29],E=e[30],R=e[31],D=e[32];let P;e[60]!==j||e[61]!==T||e[62]!==A||e[63]!==E?(P=i.jsx(j,{dropAnimation:T,style:A,children:E}),e[60]=j,e[61]=T,e[62]=A,e[63]=E,e[64]=P):P=e[64];let I;return e[65]!==C||e[66]!==V||e[67]!==N||e[68]!==P||e[69]!==R||e[70]!==D?(I=i.jsxs(C,{sensors:R,onDragStart:D,onDragEnd:V,children:[N,P]}),e[65]=C,e[66]=V,e[67]=N,e[68]=P,e[69]=R,e[70]=D,e[71]=I):I=e[71],I}function Lk(t,e){return Math.max(t,e.y+e.h)}function Sk(t){const e=M.c(7),{rows:s,tiles:n}=t;let r;e[0]!==n?(r=(c,d)=>n.some(h=>c>=h.x&&c<h.x+h.w&&d>=h.y&&d<h.y+h.h),e[0]=n,e[1]=r):r=e[1];const o=r;let a;if(e[2]!==o||e[3]!==s){a=[];for(let c=0;c<s;c++)for(let d=0;d<rn;d++)o(d,c)||a.push({x:d,y:c});e[2]=o,e[3]=s,e[4]=a}else a=e[4];let l;return e[5]!==a?(l=i.jsx("div",{className:"absolute inset-0 pointer-events-none",children:a.map(wk)}),e[5]=a,e[6]=l):l=e[6],l}function wk(t){return i.jsx("div",{className:"absolute p-1",style:{left:`${t.x/rn*100}%`,top:t.y*Cn,width:`${1/rn*100}%`,height:Cn},children:i.jsx("div",{className:"h-full w-full rounded-2xl border border-dashed border-border/60"})},`${t.x}-${t.y}`)}function jk(t){const e=M.c(31),{tile:s,isEditMode:n,isDragging:r,onResize:o,onRemove:a,children:l}=t,c=!n;let d;e[0]!==c||e[1]!==s.id?(d={id:s.id,disabled:c},e[0]=c,e[1]=s.id,e[2]=d):d=e[2];const{setNodeRef:h,attributes:u,listeners:f,isDragging:m}=m3(d),p=`${s.x/rn*100}%`,g=`${s.w/rn*100}%`,x=s.y*Cn,v=s.h*Cn,_=m||r,b=!_&&"transition-[left,top,width,height,opacity] duration-200 ease-out",y=_&&"opacity-30";let L;e[3]!==b||e[4]!==y?(L=te("absolute p-1 will-change-[left,top,width,height,opacity]",b,y),e[3]=b,e[4]=y,e[5]=L):L=e[5];let w;e[6]!==v||e[7]!==p||e[8]!==x||e[9]!==g?(w={left:p,top:x,width:g,height:v},e[6]=v,e[7]=p,e[8]=x,e[9]=g,e[10]=w):w=e[10];const S=n&&"outline outline-1 outline-transparent hover:outline-primary/40";let j;e[11]!==S?(j=te("group relative h-full bg-card card-shadow rounded-2xl overflow-hidden",S),e[11]=S,e[12]=j):j=e[12];let C;e[13]!==u||e[14]!==n||e[15]!==f||e[16]!==a||e[17]!==o||e[18]!==s?(C=n&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",...u,...f,className:"absolute top-2 left-2 z-10 flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted cursor-grab active:cursor-grabbing","aria-label":"Drag tile",children:i.jsx(na,{size:16})}),i.jsx("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-1",children:i.jsx(Ck,{tile:s,onResize:o,onRemove:a})})]}),e[13]=u,e[14]=n,e[15]=f,e[16]=a,e[17]=o,e[18]=s,e[19]=C):C=e[19];let V;e[20]!==l?(V=i.jsx("div",{className:"h-full overflow-hidden",children:i.jsx(F0,{children:l})}),e[20]=l,e[21]=V):V=e[21];let N;e[22]!==V||e[23]!==j||e[24]!==C?(N=i.jsxs("div",{className:j,children:[C,V]}),e[22]=V,e[23]=j,e[24]=C,e[25]=N):N=e[25];let T;return e[26]!==h||e[27]!==N||e[28]!==L||e[29]!==w?(T=i.jsx("div",{ref:h,className:L,style:w,children:N}),e[26]=h,e[27]=N,e[28]=L,e[29]=w,e[30]=T):T=e[30],T}function Ck(t){const e=M.c(20),{tile:s,onResize:n,onRemove:r}=t,[o,a]=k.useState(!1);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(ls,{asChild:!0,children:i.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-md bg-background/90 border border-border text-muted-foreground hover:text-foreground hover:bg-muted","aria-label":"Tile options",children:i.jsx(ni,{size:16})})}),e[0]=l):l=e[0];let c;e[1]!==n||e[2]!==s.id?(c=x=>{n(s.id,x),a(!1)},e[1]=n,e[2]=s.id,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==s?(d=i.jsx(kk,{tile:s,onPick:c}),e[4]=c,e[5]=s,e[6]=d):d=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Xi,{}),e[7]=h):h=e[7];let u;e[8]!==r||e[9]!==s.id?(u=()=>r(s.id),e[8]=r,e[9]=s.id,e[10]=u):u=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(ks,{size:14,className:"mr-2"}),e[11]=f):f=e[11];let m;e[12]!==u?(m=i.jsxs(Ge,{onSelect:u,className:"text-destructive focus:text-destructive",children:[f,"Remove tile"]}),e[12]=u,e[13]=m):m=e[13];let p;e[14]!==d||e[15]!==m?(p=i.jsxs(cs,{align:"end",className:"w-auto",children:[d,h,m]}),e[14]=d,e[15]=m,e[16]=p):p=e[16];let g;return e[17]!==o||e[18]!==p?(g=i.jsxs(as,{open:o,onOpenChange:a,children:[l,p]}),e[17]=o,e[18]=p,e[19]=g):g=e[19],g}function kk(t){const e=M.c(19),{tile:s,onPick:n}=t,r=s.minW??1,o=s.minH??1,[a,l]=k.useState(null);let c;e[0]!==a||e[1]!==s.h||e[2]!==s.w?(c=a??{w:s.w,h:s.h},e[0]=a,e[1]=s.h,e[2]=s.w,e[3]=c):c=e[3];const d=c;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx("span",{className:"text-xs text-muted-foreground",children:"Size"}),e[4]=h):h=e[4];let u;e[5]!==d.h||e[6]!==d.w?(u=i.jsxs("div",{className:"mb-2 flex items-center justify-between gap-4",children:[h,i.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[d.w," × ",d.h]})]}),e[5]=d.h,e[6]=d.w,e[7]=u):u=e[7];let f,m;e[8]===Symbol.for("react.memo_cache_sentinel")?(f={gridTemplateColumns:`repeat(${rn}, 1.25rem)`},m=()=>l(null),e[8]=f,e[9]=m):(f=e[8],m=e[9]);let p;e[10]!==d.h||e[11]!==d.w||e[12]!==o||e[13]!==r||e[14]!==n?(p=i.jsx("div",{className:"grid w-max gap-1",style:f,onPointerLeave:m,children:Array.from({length:bk},(x,v)=>Array.from({length:rn},(_,b)=>{const y=b+1,L=v+1,w=y<r||L<o,S=y<=d.w&&L<=d.h;return i.jsx("button",{type:"button",disabled:w,"aria-label":`${y} by ${L}`,onPointerEnter:()=>l({w:y,h:L}),onClick:()=>n({w:y,h:L}),className:te("size-5 rounded-sm border transition-colors",S?"border-primary bg-primary/30":"border-border bg-muted",w?"cursor-not-allowed opacity-40":"cursor-pointer hover:border-primary/60")},`${y}x${L}`)}))}),e[10]=d.h,e[11]=d.w,e[12]=o,e[13]=r,e[14]=n,e[15]=p):p=e[15];let g;return e[16]!==u||e[17]!==p?(g=i.jsxs("div",{className:"px-2 py-1.5",children:[u,p]}),e[16]=u,e[17]=p,e[18]=g):g=e[18],g}function Vk(t,e,s){return t.some(n=>e>=n.x&&e<n.x+n.w&&s>=n.y&&s<n.y+n.h)}function U0(t,e,s){for(let n=0;n<100;n++)for(let r=0;r<=rn-e;r++){let o=!0;for(let a=0;a<s&&o;a++)for(let l=0;l<e&&o;l++)Vk(t,r+l,n+a)&&(o=!1);if(o)return{x:r,y:n}}return{x:0,y:0}}function Xc(t,e,s={w:1,h:1}){const n=Math.max(s.w,Math.min(rn,t)),r=Math.max(s.h,Math.min(6,e));return{w:n,h:r}}function Qc(t,e,s){const n=Math.max(0,Math.min(rn-s,t)),r=Math.max(0,e);return{x:n,y:r}}function Nk(t,e,s){const n=t.find(c=>c.id===e);if(!n)return t;const r=t.filter(c=>c.id!==e),o=r.find(c=>s.x>=c.x&&s.x<c.x+c.w&&s.y>=c.y&&s.y<c.y+c.h);if(o&&o.w===n.w&&o.h===n.h)return t.map(c=>c.id===e?{...c,x:o.x,y:o.y}:c.id===o.id?{...c,x:n.x,y:n.y}:c);const l=[{...n,x:s.x,y:s.y}];for(const c of r){const d=U0(l,c.w,c.h);l.push({...c,x:d.x,y:d.y})}return l}function Ak(t){const e=M.c(42),{layout:s,isLayoutLoading:n,commitLayout:r}=B9();let o;e[0]!==s.hidden?(o=new Set(s.hidden),e[0]=s.hidden,e[1]=o):o=e[1];const a=o;let l;e[2]!==s.shown?(l=s.shown??[],e[2]=s.shown,e[3]=l):l=e[3];let c;e[4]!==l?(c=new Set(l),e[4]=l,e[5]=c):c=e[5];const d=c;let h,u;if(e[6]!==t||e[7]!==a||e[8]!==s.tiles||e[9]!==d){u=[];let L;e[12]!==a||e[13]!==d?(L=S=>S.pinned?!0:S.defaultHidden?d.has(S.id)&&!a.has(S.id):!a.has(S.id),e[12]=a,e[13]=d,e[14]=L):L=e[14];const w=t.filter(L);h=new Map;for(const S of t)S.minSize&&h.set(S.id,S.minSize);for(const S of w){const j=s.tiles[S.id];if(!j)continue;const C=h.get(S.id),{w:V,h:N}=Xc(j.w,j.h,C),{x:T,y:A}=Qc(j.x,j.y,V);u.push({id:S.id,x:T,y:A,w:V,h:N,minW:C?.w,minH:C?.h})}for(const S of w){if(u.some(A=>A.id===S.id))continue;const j=S.defaultSize??_k,C=h.get(S.id),{w:V,h:N}=Xc(j.w,j.h,C),T=U0(u,V,N);u.push({id:S.id,x:T.x,y:T.y,w:V,h:N,minW:C?.w,minH:C?.h})}e[6]=t,e[7]=a,e[8]=s.tiles,e[9]=d,e[10]=h,e[11]=u}else h=e[10],u=e[11];let f;e[15]!==t?(f=new Set(t.map(Tk)),e[15]=t,e[16]=f):f=e[16];const m=f;let p;e[17]!==m||e[18]!==r||e[19]!==s?(p=(L,w)=>{const S={};for(const j of L)S[j.id]={x:j.x,y:j.y,w:j.w,h:j.h};r({version:pr,tiles:S,hidden:w.filter(j=>m.has(j)),shown:(s.shown??[]).filter(j=>m.has(j))})},e[17]=m,e[18]=r,e[19]=s,e[20]=p):p=e[20];const g=p;let x;e[21]!==u?(x={visible:u},e[21]=u,e[22]=x):x=e[22];let v;e[23]!==g||e[24]!==s||e[25]!==u?(v=(L,w)=>{const S=u.find(V=>V.id===L);if(!S)return;const j=Qc(w.x,w.y,S.w);if(j.x===S.x&&j.y===S.y)return;const C=Nk(u,L,j);g(C,s.hidden)},e[23]=g,e[24]=s,e[25]=u,e[26]=v):v=e[26];let _;e[27]!==g||e[28]!==s||e[29]!==h||e[30]!==u?(_=(L,w)=>{const S=u.find(E=>E.id===L);if(!S)return;const j=h.get(L),{w:C,h:V}=Xc(w.w,w.h,j);if(C===S.w&&V===S.h)return;const N={...S,w:C,h:V,x:Qc(S.x,S.y,C).x},T=u.filter(E=>E.id!==L),A=[N];for(const E of T){const R=U0(A,E.w,E.h);A.push({...E,x:R.x,y:R.y})}g(A,s.hidden)},e[27]=g,e[28]=s,e[29]=h,e[30]=u,e[31]=_):_=e[31];let b;e[32]!==g||e[33]!==s||e[34]!==u?(b=L=>{const w=u.filter(S=>S.id!==L);g(w,Array.from(new Set([...s.hidden,L])))},e[32]=g,e[33]=s,e[34]=u,e[35]=b):b=e[35];let y;return e[36]!==n||e[37]!==x||e[38]!==v||e[39]!==_||e[40]!==b?(y={snapshot:x,isLoading:n,moveTile:v,resizeTile:_,hideTile:b},e[36]=n,e[37]=x,e[38]=v,e[39]=_,e[40]=b,e[41]=y):y=e[41],y}function Tk(t){return t.id}const Ek=3,Rk=5;function Pk(t){const e=M.c(17),{org:s}=Ee();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Go,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const r=ut(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=ut(o);let l;e[7]!==t||e[8]!==s.id?(l=it.homeGithubRecentPrs(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==r?(c=async()=>{const{installations:h}=await x2(_=>r.callTool(_),t),u=h[0];if(!u)return{repos:[]};const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort($k).filter(Mk).slice(0,Ek);return x.length===0?{repos:[]}:{repos:(await Promise.all(x.map(async _=>{const[b,y]=_.full_name.split("/"),L=await a.callTool({name:"list_pull_requests",arguments:{owner:b,repo:y,state:"all",perPage:Rk}}),w=Zl(L).map(Ok).filter(Dk);return{repo:_.full_name,prs:w}}))).filter(Ik)}},e[10]=t,e[11]=a,e[12]=r,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:6e4,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Ut(d)}function Ik(t){return t.prs.length>0}function Dk(t){return t.number>0}function Ok(t){return{number:t.number??0,title:t.title??"",merged:t.merged_at!=null,state:t.state==="closed"?"closed":"open",htmlUrl:t.html_url??""}}function Mk(t){return t.full_name}function $k(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}const er=26,Bk=7;function zk(t){const e=M.c(17),{org:s}=Ee();let n;e[0]!==s.id||e[1]!==s.slug?(n={connectionId:Go,orgId:s.id,orgSlug:s.slug},e[0]=s.id,e[1]=s.slug,e[2]=n):n=e[2];const r=ut(n);let o;e[3]!==t||e[4]!==s.id||e[5]!==s.slug?(o={connectionId:t,orgId:s.id,orgSlug:s.slug},e[3]=t,e[4]=s.id,e[5]=s.slug,e[6]=o):o=e[6];const a=ut(o);let l;e[7]!==t||e[8]!==s.id?(l=it.homeGithubContributions(s.id,t),e[7]=t,e[8]=s.id,e[9]=l):l=e[9];let c;e[10]!==t||e[11]!==a||e[12]!==r?(c=async()=>{const{installations:h}=await x2(C=>r.callTool(C),t),u=h[0];if(!u)return Zc();const f=u.type==="User"?"user":"org",p=(await a.callTool({name:"search_repositories",arguments:{query:`${f}:${u.login}`,page:1,perPage:30}})).content?.[0]?.text,x=[...p?JSON.parse(p).items??[]:[]].sort(Fk)[0];if(!x?.full_name)return Zc();const[v,_]=x.full_name.split("/"),b=new Date(Date.now()-er*7*864e5),L=(await a.callTool({name:"list_commits",arguments:{owner:v,repo:_,since:b.toISOString(),perPage:100}})).content?.[0]?.text,w=L?JSON.parse(L):[],S=Zc(),j=Date.now();for(const C of w){const V=C.commit?.committer?.date??C.commit?.author?.date??"",N=new Date(V);if(isNaN(N.getTime()))continue;const T=Math.floor((j-N.getTime())/864e5);if(T<0||T>=er*7)continue;const A=er-1-Math.floor(T/7),E=N.getDay(),R=S[A];R&&(R[E]=(R[E]??0)+1)}return S},e[10]=t,e[11]=a,e[12]=r,e[13]=c):c=e[13];let d;return e[14]!==l||e[15]!==c?(d={queryKey:l,queryFn:c,staleTime:3e5,retry:!1},e[14]=l,e[15]=c,e[16]=d):d=e[16],Ut(d)}function Fk(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function Zc(){return Array.from({length:er},()=>Array.from({length:Bk},()=>0))}const g3="pageviews",x3="sessions",v3="orders",b3="coding",_3="revenue",y3="recent-conversations",G9=[{id:g3,title:"Pageviews",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:x3,title:"Sessions",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:v3,title:"Orders",defaultSize:{w:2,h:3},minSize:{w:1,h:2}},{id:_3,title:"Revenue",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:b3,title:"Coding",defaultSize:{w:3,h:3},minSize:{w:2,h:2}},{id:y3,title:"Recent conversations",defaultSize:{w:6,h:4},minSize:{w:2,h:2},defaultHidden:!0}];function L3(t){return`native:${t}`}function S3(t){const e=M.c(21),{points:s,metricLabel:n}=t,r=k.useId();let o;if(e[0]!==r){let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=/:/g,e[2]=_):_=e[2],o=r.replace(_,""),e[0]=r,e[1]=o}else o=e[1];const a=o;let l;e[3]!==n?(l={value:{label:n,color:"var(--success)"}},e[3]=n,e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={top:6,right:0,bottom:0,left:0},e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("line",{x1:0,y1:0,x2:0,y2:8,stroke:"var(--success)",strokeOpacity:.22,strokeWidth:4}),e[6]=d):d=e[6];let h;e[7]!==a?(h=i.jsx("defs",{children:i.jsx("pattern",{id:a,width:6,height:8,patternUnits:"userSpaceOnUse",children:d})}),e[7]=a,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(zx,{dataKey:"label",hide:!0}),e[9]=u):u=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Fx,{cursor:{stroke:"var(--border)"},content:i.jsx(Ux,{indicator:"line"})}),e[10]=f):f=e[10];const m=`url(#${a})`;let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p={r:4,fill:"var(--success)",stroke:"var(--background)",strokeWidth:2},e[11]=p):p=e[11];let g;e[12]!==m?(g=i.jsx(Hx,{type:"monotone",dataKey:"value",stroke:"var(--success)",strokeWidth:2,fill:m,fillOpacity:1,animationDuration:350,dot:!1,activeDot:p}),e[12]=m,e[13]=g):g=e[13];let x;e[14]!==s||e[15]!==g||e[16]!==h?(x=i.jsxs(Kx,{data:s,margin:c,children:[h,u,f,g]}),e[14]=s,e[15]=g,e[16]=h,e[17]=x):x=e[17];let v;return e[18]!==x||e[19]!==l?(v=i.jsx(Wx,{config:l,className:"h-full w-full",children:x}),e[18]=x,e[19]=l,e[20]=v):v=e[20],v}const w3={pageviews:{value:"12.2k",delta:"+1.9%",series:[9800,10100,9950,10600,10400,11e3,11200,11500,11900,12200]},sessions:{value:"3.2k",delta:"+25.6%",series:[2100,2250,2200,2500,2600,2750,2900,3e3,3100,3200]},orders:{value:"142",delta:"+8.4%",series:[96,102,99,110,108,118,124,131,137,142]},revenue:{value:"$8,240",delta:"+12.0%",series:[6100,6400,6250,6800,6700,7100,7400,7700,8e3,8240]}};function j3(t){return t.map((e,s)=>{const n=t.length-1-s;return{label:n===0?"Today":n===1?"Yesterday":`${n}d ago`,value:e}})}function C3(t){const e=M.c(8),{value:s,delta:n}=t;let r;e[0]!==s?(r=i.jsx("span",{className:"text-2xl font-medium tabular-nums text-foreground",children:s}),e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(g2,{className:"size-4"}),e[2]=o):o=e[2];let a;e[3]!==n?(a=i.jsxs("span",{className:"inline-flex items-center gap-1 text-sm font-medium tabular-nums text-success",children:[o,n]}),e[3]=n,e[4]=a):a=e[4];let l;return e[5]!==r||e[6]!==a?(l=i.jsxs("div",{className:"mt-3 flex items-center gap-2.5",children:[r,a]}),e[5]=r,e[6]=a,e[7]=l):l=e[7],l}function Uk(t,e){const s=(t*31+e*17+7)%100;return s<38?0:s<60?1+s%2:s<80?3+s%3:s<93?6+s%3:9+s%4}function Hk(t){return t===0?"bg-muted-foreground/15":t<=2?"bg-success/25":t<=5?"bg-success/45":t<=8?"bg-success/70":"bg-success"}function k3(t){const e=M.c(3),{grid:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={gridTemplateColumns:`repeat(${er}, 1fr)`},e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(_i,{delayDuration:0,children:i.jsx("div",{className:"grid w-full gap-1",style:n,children:Array.from({length:er},(o,a)=>i.jsx("div",{className:"flex flex-col gap-1",children:Array.from({length:5},(l,c)=>{const d=s?s[a]?.[c]??0:Uk(a,c);return i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx("div",{className:te("aspect-square rounded-[2px]",Hk(d))})}),i.jsx(De,{children:d===0?"No commits":`${d} commit${d===1?"":"s"}`})]},c)})},a))})}),e[1]=s,e[2]=r):r=e[2],r}function Y9(t){const e=M.c(8),{label:s,icon:n,onConnect:r,pending:o}=t;let a;e[0]!==n||e[1]!==o?(a=o?i.jsx(Xe,{className:"size-4 animate-spin"}):n,e[0]=n,e[1]=o,e[2]=a):a=e[2];let l;return e[3]!==s||e[4]!==r||e[5]!==o||e[6]!==a?(l=i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/30 backdrop-blur-[2px]",children:i.jsxs(re,{size:"sm",onClick:r,disabled:o,className:"gap-2 shadow-sm",children:[a,s]})}),e[3]=s,e[4]=r,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function V3(t){const e=M.c(3),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Yl,{className:"size-6 text-success/60"}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[n,i.jsxs("p",{className:"text-xs text-muted-foreground",children:[s," connected. Live data coming soon."]})]}),e[1]=s,e[2]=r):r=e[2],r}function ef(t){const e=M.c(18),{metricKey:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={slug:"google-analytics"},e[0]=n):n=e[0];const r=En(n).length>0,{connect:o,isConnecting:a}=wm("deco/google-analytics"),l=w3[s];if(r||!l){let p;return e[1]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(V3,{label:"Analytics"}),e[1]=p):p=e[1],p}let c;e[2]!==l.series?(c=j3(l.series),e[2]=l.series,e[3]=c):c=e[3];let d;e[4]!==s||e[5]!==c?(d=i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(S3,{points:c,metricLabel:s})}),e[4]=s,e[5]=c,e[6]=d):d=e[6];let h;e[7]!==l.delta||e[8]!==l.value?(h=i.jsx(C3,{value:l.value,delta:l.delta}),e[7]=l.delta,e[8]=l.value,e[9]=h):h=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(jm,{className:"size-4"}),e[10]=u):u=e[10];let f;e[11]!==o||e[12]!==a?(f=i.jsx(Y9,{label:"Connect Google Analytics",icon:u,onConnect:o,pending:a}),e[11]=o,e[12]=a,e[13]=f):f=e[13];let m;return e[14]!==d||e[15]!==h||e[16]!==f?(m=i.jsxs("div",{className:"relative flex h-full flex-col",children:[d,h,f]}),e[14]=d,e[15]=h,e[16]=f,e[17]=m):m=e[17],m}function tf({metricKey:t}){const e=En({slug:"vtex"}).length>0||En({slug:"shopify"}).length>0,[s,n]=k.useState(!1),r=w3[t];return e||!r?i.jsx(V3,{label:"Commerce"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"relative flex h-full flex-col",children:[i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(S3,{points:j3(r.series),metricLabel:t})}),i.jsx(C3,{value:r.value,delta:r.delta}),i.jsx(Y9,{label:"Connect commerce platform",icon:i.jsx(f9,{className:"size-4"}),onConnect:()=>n(!0)})]}),i.jsx(i9,{mode:"browse",open:s,onOpenChange:n,defaultTab:"all",initialSearch:"shopify vtex"})]})}function Kk(){const t=M.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={slug:"mcp-github"},t[0]=e):e=t[0];const s=En(e);let n;t[1]!==s?(n=S6(s),t[1]=s,t[2]=n):n=t[2];const r=n[0];let o;return t[3]!==r?(o=r?i.jsx(qk,{connectionId:r.id}):i.jsx(Wk,{}),t[3]=r,t[4]=o):o=t[4],o}function Wk(){const t=M.c(5),{connect:e,isConnecting:s}=wm("deco/mcp-github");let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i.jsx(k3,{})}),t[0]=n):n=t[0];let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(Io,{className:"size-4"}),t[1]=r):r=t[1];let o;return t[2]!==e||t[3]!==s?(o=i.jsxs("div",{className:"relative flex h-full flex-col",children:[n,i.jsx(Y9,{label:"Connect GitHub",icon:r,onConnect:e,pending:s})]}),t[2]=e,t[3]=s,t[4]=o):o=t[4],o}function qk(t){const e=M.c(8),{connectionId:s}=t,{data:n,isLoading:r}=Pk(s),{data:o}=zk(s);let a;e[0]!==o?(a=i.jsx(k3,{grid:o}),e[0]=o,e[1]=a):a=e[1];let l;e[2]!==n||e[3]!==r?(l=r?i.jsx("div",{className:"flex flex-col gap-1.5",children:Array.from({length:3},Yk)}):!n||n.repos.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:"No recent pull requests."}):i.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",children:n.repos.map(Gk)}),e[2]=n,e[3]=r,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex h-full flex-col gap-3 overflow-hidden",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function Gk(t){return i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsx("div",{className:"truncate text-xs text-muted-foreground",children:t.repo}),t.prs.map(e=>i.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md px-1.5 py-1.5 text-sm transition-colors hover:bg-accent/60",children:[i.jsx(Qs,{className:"size-4 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"truncate text-foreground",children:e.title}),i.jsxs("span",{className:te("ml-auto shrink-0 rounded-full px-1.5 py-0.5 text-xs font-medium",e.merged?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:["#",e.number]})]},`${t.repo}#${e.number}`))]},t.repo)}function Yk(t,e){return i.jsx("div",{className:"h-5 w-full animate-pulse rounded-md bg-muted/40"},`pr-skeleton-${e}`)}const Jk={completed:{label:"Completed",className:"text-success"},in_progress:{label:"Running",className:"text-foreground"},requires_action:{label:"Needs input",className:"text-foreground"},failed:{label:"Failed",className:"text-destructive"},expired:{label:"Expired",className:"text-muted-foreground"}};function Xk(){const t=M.c(10),{org:e,locator:s}=Ee(),n=Ms(),r=yt(),{data:o}=qm(),a=o?.data?.members??[],l=new Map(a.map(Qk));let c;t[0]!==s?(c=it.overviewThreads(s),t[0]=s,t[1]=c):c=t[1];let d;t[2]!==n?(d=async()=>(await n.call("COLLECTION_THREADS_LIST",{limit:12})).items??[],t[2]=n,t[3]=d):d=t[3];let h;t[4]!==c||t[5]!==d?(h={queryKey:c,queryFn:d,staleTime:3e4},t[4]=c,t[5]=d,t[6]=h):h=t[6];const{data:u}=tm(h);if(u.length===0){let g;return t[7]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-center",children:[i.jsx(Yd,{className:"size-6 text-muted-foreground/50"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"No conversations yet. Start one and it'll show up here for your team."})]}),t[7]=g):g=t[7],g}const f="flex h-full flex-col gap-0.5 overflow-y-auto",m=u.map(g=>{const x=l.get(g.created_by),v=x?.user?.name??x?.user?.email?.split("@")[0]??"Someone",_=g.status?Jk[g.status]:void 0,b=g.updated_at?p2(new Date(g.updated_at)):null;return i.jsxs("button",{type:"button",onClick:()=>r({to:"/$org/$taskId",params:{org:e.slug,taskId:g.id},search:g.virtual_mcp_id?{virtualmcpid:g.virtual_mcp_id}:{}}),className:"flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent/60",children:[i.jsx(Ji,{shape:"circle",size:"xs",url:x?.user?.image??void 0,fallback:v.slice(0,2).toUpperCase()}),i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:g.title||"Untitled conversation"}),i.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[v,b?` · ${b}`:""]})]}),_&&i.jsx("span",{className:te("shrink-0 text-xs",_.className),children:_.label})]},g.id)});let p;return t[8]!==m?(p=i.jsx("div",{className:f,children:m}),t[8]=m,t[9]=p):p=t[9],p}function Qk(t){return[t.userId,t]}function Zk(t){const e=M.c(6),{nativeId:s}=t;switch(s){case g3:{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(ef,{metricKey:"pageviews"}),e[0]=n):n=e[0],n}case x3:{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(ef,{metricKey:"sessions"}),e[1]=n):n=e[1],n}case v3:{let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(tf,{metricKey:"orders"}),e[2]=n):n=e[2],n}case _3:{let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(tf,{metricKey:"revenue"}),e[3]=n):n=e[3],n}case b3:{let n;return e[4]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Kk,{}),e[4]=n):n=e[4],n}case y3:{let n;return e[5]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(k.Suspense,{fallback:i.jsx("div",{className:"h-full animate-pulse bg-muted/30"}),children:i.jsx(Xk,{})}),e[5]=n):n=e[5],n}default:return null}}function eV(t){const e=M.c(9),{nativeId:s}=t;let n;e[0]!==s?(n=G9.find(d=>d.id===s),e[0]=s,e[1]=n):n=e[1];const o=n?.title??"Tile";let a;e[2]!==o?(a=i.jsx("span",{className:"shrink-0 text-xs font-medium text-muted-foreground",children:o}),e[2]=o,e[3]=a):a=e[3];let l;e[4]!==s?(l=i.jsx("div",{className:"relative mt-2 min-h-0 flex-1",children:i.jsx(Zk,{nativeId:s})}),e[4]=s,e[5]=l):l=e[5];let c;return e[6]!==a||e[7]!==l?(c=i.jsxs("div",{className:"flex h-full flex-col overflow-hidden p-4",children:[a,l]}),e[6]=a,e[7]=l,e[8]=c):c=e[8],c}const tV={w:3,h:4},sV={w:1,h:2},nV={w:2,h:1};function iV(t){return`prompt:${t.agentId}:${t.promptName||"blank"}`}function rV(t){return t.tileId?`tile:${t.tileId}`:`tile:${t.agentId}:${t.resourceUri}`}function oV(t){return t.promptName?t.agentName:t.description}function aV(t){return{name:t.promptName,title:t.title,description:t.description,arguments:t.arguments,_meta:t._meta}}function N3(t){const e=M.c(14),{org:s}=Ee();let n;e[0]!==s.id||e[1]!==s.slug||e[2]!==t.connectionId?(n=Bx({connectionId:t.connectionId,orgId:s.id,orgSlug:s.slug}),e[0]=s.id,e[1]=s.slug,e[2]=t.connectionId,e[3]=n):n=e[3];const{data:r}=Ut(n),o=!!r&&!t.toolName;let a;e[4]!==r||e[5]!==o?(a={client:r,enabled:o},e[4]=r,e[5]=o,e[6]=a):a=e[6];const{data:l}=r9(a);let c;e[7]!==t.resourceUri||e[8]!==t.toolName||e[9]!==l?.tools?(c=t.toolName??l?.tools.find(u=>Xl(u._meta)===t.resourceUri)?.name,e[7]=t.resourceUri,e[8]=t.toolName,e[9]=l?.tools,e[10]=c):c=e[10];const d=c;let h;return e[11]!==t.connectionId||e[12]!==d?(h=d?Ba(t.connectionId,d):void 0,e[11]=t.connectionId,e[12]=d,e[13]=h):h=e[13],h}function J9(t){const e=M.c(10);let s;e[0]!==t?(s={agentId:t},e[0]=t,e[1]=s):s=e[1];const{start:n,startBlank:r,dialog:o,starting:a}=Kj(s);let l;e[2]!==n||e[3]!==r?(l=h=>{if(!h.promptName){r();return}n(aV(h))},e[2]=n,e[3]=r,e[4]=l):l=e[4];const c=l;let d;return e[5]!==o||e[6]!==c||e[7]!==r||e[8]!==a?(d={open:c,startBlank:r,dialog:o,starting:a},e[5]=o,e[6]=c,e[7]=r,e[8]=a,e[9]=d):d=e[9],d}function lV(t){const e=M.c(32),{entry:s,isEditMode:n}=t,{open:r,dialog:o,starting:a}=J9(s.agentId);let l;e[0]!==s||e[1]!==r?(l=()=>r(s),e[0]=s,e[1]=r,e[2]=l):l=e[2];const c=a||n,d=!n&&"cursor-pointer transition-colors hover:bg-accent/40",h=n&&"cursor-default pl-12",u=a&&"opacity-60";let f;e[3]!==d||e[4]!==h||e[5]!==u?(f=te("group/tile relative flex h-full w-full items-center gap-3 px-4 py-3 text-left bg-card",d,h,u),e[3]=d,e[4]=h,e[5]=u,e[6]=f):f=e[6];let m;e[7]!==s.agentIcon||e[8]!==s.agentName?(m=i.jsx(Yn,{icon:s.agentIcon,name:s.agentName,size:"sm+"}),e[7]=s.agentIcon,e[8]=s.agentName,e[9]=m):m=e[9];let p;e[10]!==s.title?(p=i.jsx("div",{className:"line-clamp-2 text-sm font-medium text-foreground leading-snug",children:s.title}),e[10]=s.title,e[11]=p):p=e[11];let g;e[12]!==s?(g=oV(s),e[12]=s,e[13]=g):g=e[13];let x;e[14]!==g?(x=i.jsx("div",{className:"truncate text-xs text-muted-foreground mt-0.5",children:g}),e[14]=g,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==p?(v=i.jsxs("div",{className:"min-w-0 flex-1",children:[p,x]}),e[16]=x,e[17]=p,e[18]=v):v=e[18];let _;e[19]!==n?(_=!n&&i.jsx(Sr,{size:16,className:"shrink-0 text-muted-foreground opacity-0 -translate-x-1 transition-all duration-200 group-hover/tile:opacity-100 group-hover/tile:translate-x-0","aria-hidden":!0}),e[19]=n,e[20]=_):_=e[20];let b;e[21]!==a||e[22]!==l||e[23]!==v||e[24]!==_||e[25]!==c||e[26]!==f||e[27]!==m?(b=i.jsxs("button",{type:"button",onClick:l,disabled:c,"aria-busy":a,className:f,children:[m,v,_]}),e[21]=a,e[22]=l,e[23]=v,e[24]=_,e[25]=c,e[26]=f,e[27]=m,e[28]=b):b=e[28];let y;return e[29]!==o||e[30]!==b?(y=i.jsxs(i.Fragment,{children:[b,o]}),e[29]=o,e[30]=b,e[31]=y):y=e[31],y}function cV(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"mt-4 grid w-full grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:3},dV)}),t[0]=e):e=t[0],e}function dV(t,e){return i.jsxs("div",{className:"flex w-full items-center gap-3 rounded-2xl bg-card card-shadow px-3 py-2.5",children:[i.jsx(Et,{className:"size-10 rounded-xl"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(Et,{className:"h-3 w-2/3"}),i.jsx(Et,{className:"h-2.5 w-1/3"})]})]},`chip-skeleton-${e}`)}function uV(t){const e=M.c(17),{tile:s,prompts:n,isEditMode:r,tileWidth:o}=t,{org:a}=Ee(),{open:l,startBlank:c,dialog:d,starting:h}=J9(s.agentId),u=n.filter(hV),f=N3(s),m="relative flex h-full w-full flex-col p-3";let p;e[0]!==r||e[1]!==f||e[2]!==c||e[3]!==h?(p=!r&&i.jsx("button",{type:"button",onClick:()=>{c(f?{main:f}:void 0)},disabled:h,"aria-busy":h,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:"Open chat"}),e[0]=r,e[1]=f,e[2]=c,e[3]=h,e[4]=p):p=e[4];const g="flex min-h-0 flex-1 gap-3 overflow-hidden";let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(mV,{}),e[5]=x):x=e[5];let v;e[6]!==a.id||e[7]!==a.slug||e[8]!==s?(v=i.jsx("div",{className:"min-h-0 flex-1 overflow-hidden rounded-lg border border-border",children:i.jsx(k.Suspense,{fallback:x,children:i.jsx(fV,{tile:s,orgId:a.id,orgSlug:a.slug})})}),e[6]=a.id,e[7]=a.slug,e[8]=s,e[9]=v):v=e[9];const _=u.length>0&&!r&&o>=2&&i.jsx("div",{className:"flex w-44 shrink-0 flex-col gap-2 overflow-hidden",children:u.map(L=>i.jsx("button",{type:"button",onClick:()=>l(L),disabled:h,className:"shrink-0 rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:i.jsx("span",{className:"line-clamp-2",children:L.title})},L.promptName))});let b;e[10]!==v||e[11]!==_?(b=i.jsxs("div",{className:g,children:[v,_]}),e[10]=v,e[11]=_,e[12]=b):b=e[12];let y;return e[13]!==d||e[14]!==p||e[15]!==b?(y=i.jsxs("div",{className:m,children:[p,b,d]}),e[13]=d,e[14]=p,e[15]=b,e[16]=y):y=e[16],y}function hV(t){return!!t.promptName}function fV(t){const e=M.c(13),{tile:s,orgId:n,orgSlug:r}=t;let o;e[0]!==n||e[1]!==r||e[2]!==s.connectionId?(o={connectionId:s.connectionId,orgId:n,orgSlug:r},e[0]=n,e[1]=r,e[2]=s.connectionId,e[3]=o):o=e[3];const a=ut(o),l=s.minHeight??200,c=s.maxHeight??4e3;let d;return e[4]!==a||e[5]!==n||e[6]!==r||e[7]!==l||e[8]!==c||e[9]!==s.connectionId||e[10]!==s.resourceUri||e[11]!==s.toolInput?(d=i.jsx(c6,{resourceURI:s.resourceUri,orgId:n,orgSlug:r,connectionId:s.connectionId,client:a,toolInput:s.toolInput,displayMode:"fullscreen",minHeight:l,maxHeight:c,className:"h-full"}),e[4]=a,e[5]=n,e[6]=r,e[7]=l,e[8]=c,e[9]=s.connectionId,e[10]=s.resourceUri,e[11]=s.toolInput,e[12]=d):d=e[12],d}function mV(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex h-full w-full flex-col gap-2 p-4",children:[i.jsx(Et,{className:"h-3 w-2/3"}),i.jsx(Et,{className:"h-3 w-1/2"}),i.jsx(Et,{className:"mt-1 h-full w-full rounded-md"})]}),t[0]=e):e=t[0],e}function pV(t){const e=M.c(14),{icon:s,name:n}=t;let r;e[0]!==s||e[1]!==n?(r=i.jsx(Yn,{icon:s,name:n,size:"sm+"}),e[0]=s,e[1]=n,e[2]=r):r=e[2];let o;e[3]!==n?(o=i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:n}),e[3]=n,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"truncate text-xs text-muted-foreground",children:"Loading tile…"}),e[5]=a):a=e[5];let l;e[6]!==o?(l=i.jsxs("div",{className:"min-w-0 flex-1",children:[o,a]}),e[6]=o,e[7]=l):l=e[7];let c;e[8]!==r||e[9]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2.5",children:[r,l]}),e[8]=r,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"flex flex-1 flex-col gap-2 pt-1",children:[i.jsx(Et,{className:"h-3 w-3/4"}),i.jsx(Et,{className:"h-3 w-1/2"}),i.jsx(Et,{className:"h-3 w-2/3"})]}),e[11]=d):d=e[11];let h;return e[12]!==c?(h=i.jsxs("div",{className:"flex h-full w-full flex-col gap-3 p-5 opacity-60",children:[c,d]}),e[12]=c,e[13]=h):h=e[13],h}function gV(t){const e=M.c(10),{tile:s,prompts:n,isEditMode:r}=t,{open:o,startBlank:a,dialog:l,starting:c}=J9(s.agentId),d=n.filter(xV),h=N3(s),u="flex h-full w-full flex-col gap-3 p-4";let f;e[0]!==h||e[1]!==a?(f=()=>{a(h?{main:h}:void 0)},e[0]=h,e[1]=a,e[2]=f):f=e[2];const m=c||r;let p;e[3]!==f||e[4]!==m?(p=i.jsx("button",{type:"button",onClick:f,disabled:m,className:"mb-1 self-start rounded-md px-2 py-1 text-[10px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:"Open chat"}),e[3]=f,e[4]=m,e[5]=p):p=e[5];const g=d.length>0&&!r&&i.jsx("div",{className:"grid grid-cols-1 gap-2 overflow-hidden sm:grid-cols-2",children:d.map(v=>i.jsx("button",{type:"button",onClick:()=>!r&&o(v),disabled:c,className:"rounded-lg border border-border bg-background px-2.5 py-2 text-left text-xs leading-snug text-foreground transition-colors hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-progress disabled:opacity-60",children:i.jsx("span",{className:"line-clamp-2",children:v.title})},v.promptName))});let x;return e[6]!==l||e[7]!==p||e[8]!==g?(x=i.jsxs("div",{className:u,children:[p,g,l]}),e[6]=l,e[7]=p,e[8]=g,e[9]=x):x=e[9],x}function xV(t){return!!t.promptName}function vV({isEditMode:t}){const{org:e}=Ee(),{isLoading:s,prompts:n,tiles:r}=Lm(e.slug),o=n.filter(S=>!Mu(S.agentId)),a=r.filter(S=>!Mu(S.agentId)),l=r2()?.ids??[],c=new Set(l),d=o2(),h=Ms(),u=bs(),f=new Set(a.map(S=>S.agentId)),m=new Map;for(const S of o){const j=m.get(S.agentId);j?j.push(S):m.set(S.agentId,[S])}const p=o.filter(S=>!f.has(S.agentId)),g=[...a.map(S=>({kind:"tile",id:rV(S),data:S})),...p.map(S=>({kind:"prompt",id:iV(S),data:S})),...G9.map(S=>({kind:"native",id:L3(S.id),data:S}))],x=new Map(g.map(S=>[S.id,S])),v=Ak(g.map(S=>S.kind==="native"?{id:S.id,defaultSize:S.data.defaultSize,minSize:S.data.minSize,defaultHidden:S.data.defaultHidden}:{id:S.id,defaultSize:S.kind==="tile"?tV:nV,minSize:S.kind==="tile"?sV:void 0,pinned:c.has(S.data.agentId)})),_=S=>{d.apply(j=>j.filter(C=>C!==S)).catch(()=>de.error("Couldn't remove from home — please try again."))},b=async S=>{if(a.filter(C=>C.agentId===S.agentId).length<=1){_(S.agentId);return}try{const V=(await h.call("COLLECTION_VIRTUAL_MCP_GET",{id:S.agentId})).item;if(!V)throw new Error("Agent not found");const N=rr(V.metadata?.ui),T=S.tileId?N.filter(A=>A.tileId!==S.tileId):N.filter(A=>A.connectionId!==S.connectionId||A.resourceUri!==S.resourceUri);await h.call("COLLECTION_VIRTUAL_MCP_UPDATE",{id:S.agentId,data:{metadata:{...V.metadata??{},ui:{...V.metadata?.ui??{},homeTile:null,homeTiles:T}}}}),u.invalidateQueries({queryKey:it.homeNextActions(e.slug)})}catch{de.error("Couldn't remove tile — please try again.")}},y=S=>{const j=x.get(S);if(j){if(j.kind==="native"){v.hideTile(S);return}if(!c.has(j.data.agentId)){v.hideTile(S);return}j.kind==="tile"?b(j.data):_(j.data.agentId)}},L=S=>{const j=x.get(S.id);if(!j)return null;if(j.kind==="native")return i.jsx(eV,{nativeId:j.data.id});if(j.kind==="tile"){const C=m.get(j.data.agentId)??[];return i.jsx(vs,{fallback:i.jsx(gV,{tile:j.data,prompts:C,isEditMode:t}),children:i.jsx(k.Suspense,{fallback:i.jsx(pV,{icon:j.data.agentIcon,name:j.data.agentName}),children:i.jsx(uV,{tile:j.data,prompts:C,isEditMode:t,tileWidth:S.w})})})}return i.jsx(lV,{entry:j.data,isEditMode:t})};return s||v.isLoading?i.jsx(cV,{}):v.snapshot.visible.length===0&&!t?null:i.jsx("div",{className:"mt-4 flex w-full max-w-7xl flex-col gap-4",children:i.jsx(yk,{tiles:v.snapshot.visible,isEditMode:t,renderTile:L,onMove:v.moveTile,onResize:v.resizeTile,onRemove:y})})}function gr(t,e,s){const n=t.slice();return n.splice(s<0?n.length+s:s,0,n.splice(e,1)[0]),n}function bV(t,e){return t.reduce((s,n,r)=>{const o=e.get(n);return o&&(s[r]=o),s},Array(t.length))}function ya(t){return t!==null&&t>=0}function _V(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}function yV(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const A3=t=>{let{rects:e,activeIndex:s,overIndex:n,index:r}=t;const o=gr(e,n,s),a=e[r],l=o[r];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},La={scaleX:1,scaleY:1},X9=t=>{var e;let{activeIndex:s,activeNodeRect:n,index:r,rects:o,overIndex:a}=t;const l=(e=o[s])!=null?e:n;if(!l)return null;if(r===s){const d=o[a];return d?{x:0,y:s<a?d.top+d.height-(l.top+l.height):d.top-l.top,...La}:null}const c=LV(o,r,s);return r>s&&r<=a?{x:0,y:-l.height-c,...La}:r<s&&r>=a?{x:0,y:l.height+c,...La}:{x:0,y:0,...La}};function LV(t,e,s){const n=t[e],r=t[e-1],o=t[e+1];return n?s<e?r?n.top-(r.top+r.height):o?o.top-(n.top+n.height):0:o?o.top-(n.top+n.height):r?n.top-(r.top+r.height):0:0}const T3="Sortable",E3=et.createContext({activeIndex:-1,containerId:T3,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:A3,disabled:{draggable:!1,droppable:!1}});function Q9(t){let{children:e,id:s,items:n,strategy:r=A3,disabled:o=!1}=t;const{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=p3(),u=ca(T3,s),f=l.rect!==null,m=k.useMemo(()=>n.map(w=>typeof w=="object"&&"id"in w?w.id:w),[n]),p=a!=null,g=a?m.indexOf(a.id):-1,x=d?m.indexOf(d.id):-1,v=k.useRef(m),_=!_V(m,v.current),b=x!==-1&&g===-1||_,y=yV(o);sn(()=>{_&&p&&h(m)},[_,m,p,h]),k.useEffect(()=>{v.current=m},[m]);const L=k.useMemo(()=>({activeIndex:g,containerId:u,disabled:y,disableTransforms:b,items:m,overIndex:x,useDragOverlay:f,sortedRects:bV(m,c),strategy:r}),[g,u,y.draggable,y.droppable,b,m,x,c,f,r]);return et.createElement(E3.Provider,{value:L},e)}const SV=t=>{let{id:e,items:s,activeIndex:n,overIndex:r}=t;return gr(s,n,r).indexOf(e)},wV=t=>{let{containerId:e,isSorting:s,wasDragging:n,index:r,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=t;return!d||!n||l!==o&&r===a?!1:s?!0:a!==r&&e===c},jV={duration:200,easing:"ease"},R3="transform",CV=yn.Transition.toString({property:R3,duration:0,easing:"linear"}),kV={roleDescription:"sortable"};function VV(t){let{disabled:e,index:s,node:n,rect:r}=t;const[o,a]=k.useState(null),l=k.useRef(s);return sn(()=>{if(!e&&s!==l.current&&n.current){const c=r.current;if(c){const d=Pr(n.current,{ignoreTransform:!0}),h={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(h.x||h.y)&&a(h)}}s!==l.current&&(l.current=s)},[e,s,n,r]),k.useEffect(()=>{o&&a(null)},[o]),o}function Z9(t){let{animateLayoutChanges:e=wV,attributes:s,disabled:n,data:r,getNewIndex:o=SV,id:a,strategy:l,resizeObserverConfig:c,transition:d=jV}=t;const{items:h,containerId:u,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:x,useDragOverlay:v,strategy:_}=k.useContext(E3),b=NV(n,m),y=h.indexOf(a),L=k.useMemo(()=>({sortable:{containerId:u,index:y,items:h},...r}),[u,r,y,h]),w=k.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:S,node:j,isOver:C,setNodeRef:V}=ok({id:a,data:L,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...c}}),{active:N,activatorEvent:T,activeNodeRect:A,attributes:E,setNodeRef:R,listeners:D,isDragging:P,over:I,setActivatorNodeRef:O,transform:B}=m3({id:a,data:L,attributes:{...kV,...s},disabled:b.draggable}),z=Wj(V,R),$=!!N,U=$&&!p&&ya(f)&&ya(x),W=!v&&P,X=W&&U?B:null,Z=U?X??(l??_)({rects:g,activeNodeRect:A,activeIndex:f,overIndex:x,index:y}):null,K=ya(f)&&ya(x)?o({id:a,items:h,activeIndex:f,overIndex:x}):y,Y=N?.id,F=k.useRef({activeId:Y,items:h,newIndex:K,containerId:u}),Q=h!==F.current.items,J=e({active:N,containerId:u,isDragging:P,isSorting:$,id:a,index:y,items:h,newIndex:F.current.newIndex,previousItems:F.current.items,previousContainerId:F.current.containerId,transition:d,wasDragging:F.current.activeId!=null}),ee=VV({disabled:!J,index:y,node:j,rect:S});return k.useEffect(()=>{$&&F.current.newIndex!==K&&(F.current.newIndex=K),u!==F.current.containerId&&(F.current.containerId=u),h!==F.current.items&&(F.current.items=h)},[$,K,u,h]),k.useEffect(()=>{if(Y===F.current.activeId)return;if(Y!=null&&F.current.activeId==null){F.current.activeId=Y;return}const se=setTimeout(()=>{F.current.activeId=Y},50);return()=>clearTimeout(se)},[Y]),{active:N,activeIndex:f,attributes:E,data:L,rect:S,index:y,newIndex:K,items:h,isOver:C,isSorting:$,isDragging:P,listeners:D,node:j,overIndex:x,over:I,setNodeRef:z,setActivatorNodeRef:O,setDroppableNodeRef:V,setDraggableNodeRef:R,transform:ee??Z,transition:q()};function q(){if(ee||Q&&F.current.newIndex===y)return CV;if(!(W&&!cc(T)||!d)&&($||J))return yn.Transition.toString({...d,property:R3})}}function NV(t,e){var s,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(s=t?.draggable)!=null?s:e.draggable,droppable:(n=t?.droppable)!=null?n:e.droppable}}function Vl(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const AV=[st.Down,st.Right,st.Up,st.Left],eu=(t,e)=>{let{context:{active:s,collisionRect:n,droppableRects:r,droppableContainers:o,over:a,scrollableAncestors:l}}=e;if(AV.includes(t.code)){if(t.preventDefault(),!s||!n)return;const c=[];o.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;const f=r.get(u.id);if(f)switch(t.code){case st.Down:n.top<f.top&&c.push(u);break;case st.Up:n.top>f.top&&c.push(u);break;case st.Left:n.left>f.left&&c.push(u);break;case st.Right:n.left<f.left&&c.push(u);break}});const d=lC({collisionRect:n,droppableRects:r,droppableContainers:c});let h=Qp(d,"id");if(h===a?.id&&d.length>1&&(h=d[1].id),h!=null){const u=o.get(s.id),f=o.get(h),m=f?r.get(f.id):null,p=f?.node.current;if(p&&m&&u&&f){const x=uc(p).some((w,S)=>l[S]!==w),v=P3(u,f),_=TV(u,f),b=x||!v?{x:0,y:0}:{x:_?n.width-m.width:0,y:_?n.height-m.height:0},y={x:m.left,y:m.top};return b.x&&b.y?y:$o(y,b)}}}};function P3(t,e){return!Vl(t)||!Vl(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function TV(t,e){return!Vl(t)||!Vl(e)||!P3(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function tu(t){const e=M.c(11),{isPinned:s,submitting:n,onClick:r,label:o}=t,a=s?"text-muted-foreground hover:bg-destructive/10 hover:text-destructive":"bg-foreground text-background hover:opacity-90";let l;e[0]!==a?(l=te("inline-flex size-7 shrink-0 items-center justify-center rounded-md text-xs transition-colors disabled:opacity-50 disabled:cursor-progress",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==s||e[3]!==n?(c=n?i.jsx(Xe,{size:12,className:"animate-spin"}):s?i.jsx(Dm,{size:14}):i.jsx(kt,{size:14}),e[2]=s,e[3]=n,e[4]=c):c=e[4];let d;return e[5]!==o||e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==c?(d=i.jsx("button",{type:"button",onClick:r,disabled:n,"aria-label":o,title:o,className:l,children:c}),e[5]=o,e[6]=r,e[7]=n,e[8]=l,e[9]=c,e[10]=d):d=e[10],d}function EV(t){const e=M.c(32),{agent:s,home:n,curated:r}=t,{org:o}=Ee();let a;e[0]!==s.id||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s.id,orgId:o.id,orgSlug:o.slug},e[0]=s.id,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const l=ut(a);let c;e[4]!==s.id||e[5]!==o.id?(c=it.agentPrompts(o.id,s.id),e[4]=s.id,e[5]=o.id,e[6]=c):c=e[6];let d;e[7]!==l?(d=async()=>{const{prompts:L}=await l.listPrompts();return L.map(DV)},e[7]=l,e[8]=d):d=e[8];let h;e[9]!==c||e[10]!==d?(h={queryKey:c,queryFn:d,staleTime:3e4,retry:!1},e[9]=c,e[10]=d,e[11]=h):h=e[11];const{data:u,isLoading:f,error:m}=Ut(h),p=Lm(o.slug);let g,x;if(e[12]!==s.id||e[13]!==u||e[14]!==p.prompts){let L;e[17]!==s.id?(L=S=>S.agentId===s.id&&S.promptName,e[17]=s.id,e[18]=L):L=e[18],g=p.prompts.filter(L).map(IV);let w;e[19]!==u?(w=u??[],e[19]=u,e[20]=w):w=e[20],x=[...w];for(const S of g)x.some(j=>j.name===S.name)||x.push(S);e[12]=s.id,e[13]=u,e[14]=p.prompts,e[15]=g,e[16]=x}else g=e[15],x=e[16];if(f&&g.length===0){let L;return e[21]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx(Et,{className:"h-7 w-full"}),i.jsx(Et,{className:"h-7 w-2/3"})]}),e[21]=L):L=e[21],L}if(m&&g.length===0)return console.error("[home-tiles] listPrompts failed for agent",s.id,m),null;if(x.length===0)return null;let v;e[22]!==r||e[23]!==x?(v=r??x.map(PV),e[22]=r,e[23]=x,e[24]=v):v=e[24];let _;e[25]!==v?(_=new Set(v),e[25]=v,e[26]=_):_=e[26];const b=_;let y;return e[27]!==s||e[28]!==n||e[29]!==x||e[30]!==b?(y=i.jsx("div",{className:"flex flex-col gap-0.5",children:x.map(L=>i.jsx(OV,{agent:s,home:n,prompt:L,allPromptNames:x.map(RV),isPinned:b.has(L.name)},L.name))}),e[27]=s,e[28]=n,e[29]=x,e[30]=b,e[31]=y):y=e[31],y}function RV(t){return t.name}function PV(t){return t.name}function IV(t){return{name:t.promptName,title:t.title,description:t.description}}function DV(t){return{name:t.name,title:t.title,description:t.description}}function OV({agent:t,home:e,prompt:s,allPromptNames:n,isPinned:r}){const[o,a]=k.useState(!1),l=async()=>{if(!r&&!e.isOnHome(t.id)&&e.atLimit){de.error(`Home is full (${ua}) — remove an agent first`);return}a(!0);try{const c=t.metadata?.ui?.homePrompts;let d;Array.isArray(c)?d=r?c.filter(u=>u!==s.name):[...c,s.name]:d=r?n.filter(u=>u!==s.name):n;const h={...t.metadata??{},ui:{...t.metadata?.ui??{},homePrompts:d}};await e.saveAgentMetadata(t,h)}catch(c){console.error("[home-tiles] failed to toggle prompt",c),de.error("Couldn't update home — please try again.")}finally{a(!1)}};return i.jsxs("div",{className:"flex items-center gap-2.5 rounded-md px-2 py-1 hover:bg-accent/40",children:[i.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:s.title??yi(s.name)}),i.jsx(tu,{isPinned:r,submitting:o,onClick:l,label:r?"Remove from home":"Add to home"})]})}function su(t){const e=M.c(7),{title:s,hint:n}=t;let r;e[0]!==s?(r=i.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:s}),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==n?(o=n&&i.jsx("span",{className:"text-xs text-muted-foreground",children:n}),e[2]=n,e[3]=o):o=e[3];let a;return e[4]!==r||e[5]!==o?(a=i.jsxs("div",{className:"flex items-center justify-between px-1",children:[r,o]}),e[4]=r,e[5]=o,e[6]=a):a=e[6],a}const MV={tasks:Yl,coding:Qs,analytics:jm,sales:f9,"recent-conversations":Yd};function $V(){const t=M.c(14),{layout:e,commitLayout:s}=B9();let n;t[0]!==e.hidden?(n=new Set(e.hidden),t[0]=e.hidden,t[1]=n):n=t[1];const r=n;let o;t[2]!==e.shown?(o=e.shown??[],t[2]=e.shown,t[3]=o):o=t[3];let a;t[4]!==o?(a=new Set(o),t[4]=o,t[5]=a):a=t[5];const l=a;let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(su,{title:"Built-in tiles"}),t[6]=c):c=t[6];let d;t[7]!==s||t[8]!==r||t[9]!==e||t[10]!==l?(d=G9.map(u=>{const f=L3(u.id),m=u.defaultHidden?l.has(f)&&!r.has(f):!r.has(f),p=MV[u.id]??Yd,g=()=>{if(u.defaultHidden){s({...e,hidden:e.hidden.filter(x=>x!==f),shown:m?(e.shown??[]).filter(x=>x!==f):[...e.shown??[],f]});return}s({...e,hidden:m?[...e.hidden,f]:e.hidden.filter(x=>x!==f)})};return i.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5",children:[i.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:i.jsx(p,{size:16})}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:u.title}),i.jsxs(re,{type:"button",size:"sm",variant:m?"outline":"special",className:"h-8 gap-1.5",onClick:g,children:[m?i.jsx(Dm,{size:14}):i.jsx(kt,{size:14}),m?"Remove":"Add"]})]},u.id)}),t[7]=s,t[8]=r,t[9]=e,t[10]=l,t[11]=d):d=t[11];let h;return t[12]!==d?(h=i.jsxs("div",{className:"flex flex-col gap-1.5",children:[c,d]}),t[12]=d,t[13]=h):h=t[13],h}function BV(t,e,s){const n={};for(const[r,o]of Object.entries(t)){const a=e[r]?.type;if((a==="object"||a==="array")&&typeof o=="string"){if(!o.trim())continue;try{n[r]=JSON.parse(o)}catch{return null}}else if((a==="number"||a==="integer")&&(typeof o=="string"||typeof o=="number")){if(typeof o=="string"&&!o.trim())continue;const l=typeof o=="string"?Number(o):o;if(!Number.isFinite(l)||a==="integer"&&!Number.isInteger(l))return null;n[r]=l}else if(typeof o=="string"){if(!o.trim())continue;n[r]=o}else o!=null&&(n[r]=o)}return s?.some(r=>!(r in n))?null:n}function zV(t,e){if(!t||!e)return{};const s={};for(const[n,r]of Object.entries(t)){const o=e[n]?.type;(o==="object"||o==="array")&&r!=null&&typeof r!="string"?s[n]=JSON.stringify(r,null,2):s[n]=r}return s}function FV(t){if(!t)return"";const e=Object.entries(t).filter(([,s])=>s!=null&&s!=="");return e.length===0?"":e.slice(0,3).map(([s,n])=>{const r=typeof n=="object"?JSON.stringify(n):String(n);return`${s}=${r.length>20?`${r.slice(0,20)}…`:r}`}).join(", ")}function UV(t){const e=M.c(11),{properties:s,required:n,values:r,onChange:o}=t;let a;e[0]!==n?(a=n??[],e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=new Set(a),e[2]=a,e[3]=l):l=e[3];const c=l;let d;e[4]!==s?(d=Object.entries(s),e[4]=s,e[5]=d):d=e[5];let h;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==r?(h=i.jsx("div",{className:"flex flex-col gap-2",children:d.map(u=>{const[f,m]=u;return i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("label",{className:"text-xs font-medium leading-none flex items-center gap-1",children:[f,c.has(f)&&i.jsx("span",{className:"text-destructive text-[10px]",children:"*"})]}),i.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:m.type})]}),m.description&&i.jsx("p",{className:"text-[10px] text-muted-foreground leading-snug",children:m.description}),i.jsx(HV,{type:m.type,fieldKey:f,value:r[f],onChange:p=>o(f,p)})]},f)})}),e[6]=o,e[7]=c,e[8]=d,e[9]=r,e[10]=h):h=e[10],h}function HV(t){const e=M.c(19),{type:s,fieldKey:n,value:r,onChange:o}=t;if(s==="object"||s==="array"){const h=r??"";let u;e[0]!==o?(u=p=>o(p.target.value),e[0]=o,e[1]=u):u=e[1];const f=`Enter ${n} as JSON…`;let m;return e[2]!==h||e[3]!==u||e[4]!==f?(m=i.jsx(ur,{className:"font-mono text-xs h-16",value:h,onChange:u,placeholder:f,rows:2}),e[2]=h,e[3]=u,e[4]=f,e[5]=m):m=e[5],m}if(s==="boolean"){const h=r!=null?String(r):"";let u;e[6]!==o?(u=g=>o(g==="true"),e[6]=o,e[7]=u):u=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Xt,{className:"h-7 text-xs",children:i.jsx(rs,{placeholder:"Select…"})}),e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsxs(Yt,{children:[i.jsx(pt,{value:"true",children:"true"}),i.jsx(pt,{value:"false",children:"false"})]}),e[9]=m):m=e[9];let p;return e[10]!==h||e[11]!==u?(p=i.jsxs(Jt,{value:h,onValueChange:u,children:[f,m]}),e[10]=h,e[11]=u,e[12]=p):p=e[12],p}const a=r??"";let l;e[13]!==o?(l=h=>o(h.target.value),e[13]=o,e[14]=l):l=e[14];const c=`Enter ${n}…`;let d;return e[15]!==a||e[16]!==l||e[17]!==c?(d=i.jsx(tt,{className:"h-7 text-xs",value:a,onChange:l,placeholder:c}),e[15]=a,e[16]=l,e[17]=c,e[18]=d):d=e[18],d}const ua=8;function KV(t){const e=M.c(16),{open:s,onOpenChange:n}=t,[r,o]=k.useState("");let a,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(w6,{children:"Manage home"}),l=i.jsx(j6,{children:"Add agents to the home board and pin their interactive UIs or prompts."}),e[0]=a,e[1]=l):(a=e[0],l=e[1]);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Jd,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none","aria-hidden":!0}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g=>o(g.target.value),e[3]=d):d=e[3];let h;e[4]!==r?(h=i.jsxs(C6,{className:"px-5 py-4 border-b border-border",children:[a,l,i.jsxs("div",{className:"relative mt-3",children:[c,i.jsx(tt,{value:r,onChange:d,placeholder:"Search agents…",className:"pl-8 h-8 text-sm"})]})]}),e[4]=r,e[5]=h):h=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(mN,{}),e[6]=u):u=e[6];let f;e[7]!==r?(f=i.jsx(ti,{className:"flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"p-3 flex flex-col gap-4",children:i.jsx(k.Suspense,{fallback:u,children:i.jsx(qV,{search:r})})})}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==h||e[10]!==f?(m=i.jsxs(k6,{side:"right",className:"w-full sm:max-w-md p-0 flex flex-col",children:[h,f]}),e[9]=h,e[10]=f,e[11]=m):m=e[11];let p;return e[12]!==n||e[13]!==s||e[14]!==m?(p=i.jsx(V6,{open:s,onOpenChange:n,children:m}),e[12]=n,e[13]=s,e[14]=m,e[15]=p):p=e[15],p}function WV(t){const e=M.c(32),{org:s}=Ee(),n=r2();let r;e[0]!==n?.ids?(r=n?.ids??[],e[0]=n?.ids,e[1]=r):r=e[1];const o=r,a=o2(),l=Ud(),c=bs();let d;e[2]!==s||e[3]!==c?(d=()=>c.refetchQueries({queryKey:it.homeNextActions(s.slug),type:"active"}),e[2]=s,e[3]=c,e[4]=d):d=e[4];const h=d;let u;e[5]!==o?(u=C=>o.includes(C),e[5]=o,e[6]=u):u=e[6];const f=u;let m;e[7]!==o||e[8]!==t?(m=t?o.filter(C=>t.has(C)).length:o.length,e[7]=o,e[8]=t,e[9]=m):m=e[9];const g=m>=ua;let x;e[10]!==g||e[11]!==f||e[12]!==a?(x=C=>f(C)||g?Promise.resolve():a.apply(V=>V.includes(C)?null:[...V,C]),e[10]=g,e[11]=f,e[12]=a,e[13]=x):x=e[13];const v=x;let _;e[14]!==a?(_=C=>a.apply(V=>V.filter(N=>N!==C)),e[14]=a,e[15]=_):_=e[15];const b=_;let y;e[16]!==a?(y=C=>a.apply(()=>C),e[16]=a,e[17]=y):y=e[17];const L=y;let w;e[18]!==l||e[19]!==g||e[20]!==f||e[21]!==h||e[22]!==a?(w=async(C,V)=>{await l.update.mutateAsync({id:C.id,data:{metadata:V}}),!f(C.id)&&!g&&await a.apply(N=>N.includes(C.id)?null:[...N,C.id]),await h()},e[18]=l,e[19]=g,e[20]=f,e[21]=h,e[22]=a,e[23]=w):w=e[23];const S=w;let j;return e[24]!==v||e[25]!==g||e[26]!==o||e[27]!==f||e[28]!==b||e[29]!==L||e[30]!==S?(j={homeIds:o,isOnHome:f,atLimit:g,addAgent:v,removeAgent:b,reorder:L,saveAgentMetadata:S},e[24]=v,e[25]=g,e[26]=o,e[27]=f,e[28]=b,e[29]=L,e[30]=S,e[31]=j):j=e[31],j}function qV(t){const e=M.c(24),{search:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={pageSize:1e3},e[0]=n):n=e[0];const r=Xo(n);let o;e[1]!==r?(o=new Set(r.map(QV)),e[1]=r,e[2]=o):o=e[2];const a=WV(o);let l,c,d;if(e[3]!==r||e[4]!==a||e[5]!==s){const x=new Map(r.map(XV));l=s.trim().toLowerCase();const v=y=>!l||y.title?.toLowerCase().includes(l);c=a.homeIds.map(y=>x.get(y)).filter(JV).filter(v);const _=n9(r);let b;e[9]!==a?(b=y=>!a.isOnHome(y.id),e[9]=a,e[10]=b):b=e[10],d=r.filter(YV).filter(y=>!_.has(y.id)).filter(b).filter(v).sort(GV),e[3]=r,e[4]=a,e[5]=s,e[6]=l,e[7]=c,e[8]=d}else l=e[6],c=e[7],d=e[8];const h=d;let u;e[11]!==a||e[12]!==c?(u=i.jsx(ZV,{home:a,agents:c}),e[11]=a,e[12]=c,e[13]=u):u=e[13];let f;e[14]!==l?(f=!l&&i.jsx($V,{}),e[14]=l,e[15]=f):f=e[15];const m=!!l;let p;e[16]!==h||e[17]!==a||e[18]!==m?(p=i.jsx(sN,{home:a,agents:h,hasSearch:m}),e[16]=h,e[17]=a,e[18]=m,e[19]=p):p=e[19];let g;return e[20]!==u||e[21]!==f||e[22]!==p?(g=i.jsxs(i.Fragment,{children:[u,f,p]}),e[20]=u,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}function GV(t,e){return(t.title??"").localeCompare(e.title??"")}function YV(t){return t.id&&!Za(t.id)}function JV(t){return!!t}function XV(t){return[t.id,t]}function QV(t){return t.id}function ZV(t){const e=M.c(14),{home:s,agents:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={activationConstraint:{distance:5}},e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={coordinateGetter:eu},e[1]=o):o=e[1];const a=dc(Zn(Dr,r),Zn(Ir,o));let l;e[2]!==s?(l=m=>{const{active:p,over:g}=m;if(!g||p.id===g.id)return;const x=s.homeIds,v=x.indexOf(p.id),_=x.indexOf(g.id);v===-1||_===-1||s.reorder(gr([...x],v,_)).catch(tN)},e[2]=s,e[3]=l):l=e[3];const c=l,d=`${s.homeIds.length}/${ua}`;let h;e[4]!==d?(h=i.jsx(su,{title:"On home",hint:d}),e[4]=d,e[5]=h):h=e[5];let u;e[6]!==n||e[7]!==c||e[8]!==s||e[9]!==a?(u=n.length===0?i.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:"No agents on the home yet."}):i.jsx(mc,{sensors:a,collisionDetection:U9,onDragEnd:c,children:i.jsx(Q9,{items:n.map(eN),strategy:X9,children:i.jsx("div",{className:"flex flex-col gap-1",children:n.map(m=>i.jsx(iN,{agent:m,home:s},m.id))})})}),e[6]=n,e[7]=c,e[8]=s,e[9]=a,e[10]=u):u=e[10];let f;return e[11]!==h||e[12]!==u?(f=i.jsxs("div",{className:"flex flex-col gap-1.5",children:[h,u]}),e[11]=h,e[12]=u,e[13]=f):f=e[13],f}function eN(t){return t.id}function tN(){return de.error("Couldn't reorder home — please try again.")}function sN(t){const e=M.c(6),{home:s,agents:n,hasSearch:r}=t,[o,a]=k.useState(20);let l;if(e[0]!==n||e[1]!==r||e[2]!==s||e[3]!==o){const c=n.slice(0,o);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(su,{title:"Add to home"}),e[5]=d):d=e[5],l=i.jsxs("div",{className:"flex flex-col gap-1.5",children:[d,n.length===0?i.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:r?"No agents match.":"Every agent is on the home."}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col gap-1",children:c.map(h=>i.jsx(aN,{agent:h,home:s},h.id))}),n.length>o&&i.jsxs("button",{type:"button",onClick:()=>a(nN),className:"mt-1 self-center rounded-md px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent/40 hover:text-foreground",children:["Load more (",n.length-o,")"]})]})]}),e[0]=n,e[1]=r,e[2]=s,e[3]=o,e[4]=l}else l=e[4];return l}function nN(t){return t+20}function I3(t){const e=rr(t.metadata?.ui).filter(o=>!!o.resourceUri).length,s=t.metadata?.ui?.homePrompts,n=Array.isArray(s)?s.length:null,r=[];return e>0&&r.push(`${e} tile${e===1?"":"s"}`),n!==null&&n>0&&r.push(`${n} prompt${n===1?"":"s"}`),n===0&&r.push("prompts off"),r.join(" · ")}function iN(t){const e=M.c(59),{agent:s,home:n}=t,[r,o]=k.useState(!1);let a;e[0]!==s.id?(a={id:s.id},e[0]=s.id,e[1]=a):a=e[1];const{attributes:l,listeners:c,setNodeRef:d,transform:h,transition:u,isDragging:f}=Z9(a),m=I3(s)||"Quick access",p=`home-agent-expansion-${s.id}`;let g;e[2]!==h?(g=yn.Transform.toString(h),e[2]=h,e[3]=g):g=e[3];const x=f?.5:void 0,v=f?100:void 0;let _;e[4]!==g||e[5]!==x||e[6]!==v||e[7]!==u?(_={transform:g,transition:u,opacity:x,zIndex:v},e[4]=g,e[5]=x,e[6]=v,e[7]=u,e[8]=_):_=e[8];const b=_,y=f&&"shadow-lg";let L;e[9]!==y?(L=te("rounded-lg border border-border bg-card",y),e[9]=y,e[10]=L):L=e[10];const w=`Drag to reorder ${s.title??s.id}`;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(na,{size:14}),e[11]=S):S=e[11];let j;e[12]!==l||e[13]!==c||e[14]!==w?(j=i.jsx("button",{type:"button",...l,...c,className:"shrink-0 text-muted-foreground hover:text-foreground cursor-grab active:cursor-grabbing outline-none focus-visible:ring-2 focus-visible:ring-ring rounded","aria-label":w,children:S}),e[12]=l,e[13]=c,e[14]=w,e[15]=j):j=e[15];let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=()=>o(oN),e[16]=C):C=e[16];const V=s.title??s.id;let N;e[17]!==s.icon||e[18]!==V?(N=i.jsx(Yn,{icon:s.icon,name:V,size:"sm"}),e[17]=s.icon,e[18]=V,e[19]=N):N=e[19];const T=s.title??s.id;let A;e[20]!==T?(A=i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:T}),e[20]=T,e[21]=A):A=e[21];let E;e[22]!==m?(E=i.jsx("div",{className:"truncate text-xs text-muted-foreground",children:m}),e[22]=m,e[23]=E):E=e[23];let R;e[24]!==A||e[25]!==E?(R=i.jsxs("div",{className:"min-w-0 flex-1",children:[A,E]}),e[24]=A,e[25]=E,e[26]=R):R=e[26];const D=r&&"rotate-180";let P;e[27]!==D?(P=te("shrink-0 text-muted-foreground transition-transform",D),e[27]=D,e[28]=P):P=e[28];let I;e[29]!==P?(I=i.jsx(ts,{size:16,className:P}),e[29]=P,e[30]=I):I=e[30];let O;e[31]!==r||e[32]!==p||e[33]!==N||e[34]!==R||e[35]!==I?(O=i.jsxs("button",{type:"button",onClick:C,className:"flex min-w-0 flex-1 items-center gap-2.5 text-left outline-none","aria-expanded":r,"aria-controls":p,children:[N,R,I]}),e[31]=r,e[32]=p,e[33]=N,e[34]=R,e[35]=I,e[36]=O):O=e[36];let B;e[37]!==s.id||e[38]!==n?(B=()=>n.removeAgent(s.id).catch(rN),e[37]=s.id,e[38]=n,e[39]=B):B=e[39];const z=`Remove ${s.title??s.id} from home`;let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=i.jsx(js,{size:14}),e[40]=$):$=e[40];let U;e[41]!==B||e[42]!==z?(U=i.jsx("button",{type:"button",onClick:B,"aria-label":z,title:"Remove from home",className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive",children:$}),e[41]=B,e[42]=z,e[43]=U):U=e[43];let W;e[44]!==j||e[45]!==O||e[46]!==U?(W=i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-2.5",children:[j,O,U]}),e[44]=j,e[45]=O,e[46]=U,e[47]=W):W=e[47];let X;e[48]!==s||e[49]!==r||e[50]!==p||e[51]!==n?(X=r&&i.jsx(D3,{id:p,agent:s,home:n}),e[48]=s,e[49]=r,e[50]=p,e[51]=n,e[52]=X):X=e[52];let H;return e[53]!==d||e[54]!==b||e[55]!==W||e[56]!==X||e[57]!==L?(H=i.jsxs("div",{ref:d,style:b,className:L,children:[W,X]}),e[53]=d,e[54]=b,e[55]=W,e[56]=X,e[57]=L,e[58]=H):H=e[58],H}function rN(){return de.error("Couldn't remove from home — please try again.")}function oN(t){return!t}function aN({agent:t,home:e}){const[s,n]=k.useState(!1),[r,o]=k.useState(!1),a=I3(t),l=`available-agent-expansion-${t.id}`,c=async()=>{if(!e.atLimit){o(!0);try{await e.addAgent(t.id)}catch{de.error("Couldn't add to home — please try again.")}finally{o(!1)}}};return i.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[i.jsxs("button",{type:"button",onClick:()=>n(d=>!d),className:"flex min-w-0 flex-1 items-center gap-3 text-left outline-none","aria-expanded":s,"aria-controls":l,children:[i.jsx(Yn,{icon:t.icon,name:t.title??t.id,size:"sm"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t.title??t.id}),a&&i.jsx("div",{className:"truncate text-xs text-muted-foreground",children:a})]}),i.jsx(ts,{size:16,className:te("shrink-0 text-muted-foreground transition-transform",s&&"rotate-180")})]}),i.jsx("button",{type:"button",onClick:c,disabled:r||e.atLimit,"aria-label":"Add to home",title:e.atLimit?`Home is full (${ua}) — remove an agent first`:"Add to home",className:"shrink-0 inline-flex size-7 items-center justify-center rounded-md bg-foreground text-background text-xs hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",children:r?i.jsx(Xe,{size:12,className:"animate-spin"}):i.jsx(kt,{size:14})})]}),s&&i.jsx(D3,{id:l,agent:t,home:e})]})}function D3(t){const e=M.c(18),{id:s,agent:n,home:r}=t,o=n.metadata?.ui;let a;e[0]!==o?(a=rr(o),e[0]=o,e[1]=a):a=e[1];const l=a;let c;e[2]!==n.connections?(c=(n.connections??[]).map(lN).sort(),e[2]=n.connections,e[3]=c):c=e[3];const d=c,h=n.metadata?.ui?.homePrompts;let u;e[4]!==n||e[5]!==d||e[6]!==r||e[7]!==l?(u=i.jsx(dN,{agent:n,home:r,connectionIds:d,pinnedTiles:l}),e[4]=n,e[5]=d,e[6]=r,e[7]=l,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(cN,{}),e[9]=f):f=e[9];const m=h??null;let p;e[10]!==n||e[11]!==r||e[12]!==m?(p=i.jsx(k.Suspense,{fallback:f,children:i.jsx(EV,{agent:n,home:r,curated:m})}),e[10]=n,e[11]=r,e[12]=m,e[13]=p):p=e[13];let g;return e[14]!==s||e[15]!==u||e[16]!==p?(g=i.jsxs("div",{id:s,className:"border-t border-border px-3 py-2 flex flex-col gap-3",children:[u,p]}),e[14]=s,e[15]=u,e[16]=p,e[17]=g):g=e[17],g}function lN(t){return t.connection_id}function cN(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[i.jsx(Et,{className:"h-8 w-full"}),i.jsx(Et,{className:"h-8 w-2/3"})]}),t[0]=e):e=t[0],e}function dN({agent:t,home:e,connectionIds:s,pinnedTiles:n}){const r=Ms(),{data:o,isLoading:a}=Ut({queryKey:it.projectConnectionDetails(t.id,s),enabled:s.length>0,queryFn:async()=>(await Promise.all(s.map(async u=>{try{const{item:f}=await r.call("COLLECTION_CONNECTIONS_GET",{id:u}),m=(f?.tools??[]).flatMap(p=>{const g=Xl(p._meta);return g?[{name:p.name,description:p.description,resourceUri:g,inputSchema:p.inputSchema}]:[]});return{id:u,title:f?.title??u,icon:f?.icon??null,uiTools:m}}catch{return{id:u,title:u,icon:null,uiTools:[]}}}))).filter(u=>u.uiTools.length>0)});if(s.length===0)return null;if(a)return i.jsxs("div",{className:"flex flex-col gap-1 py-0.5",children:[i.jsx(Et,{className:"h-7 w-full"}),i.jsx(Et,{className:"h-7 w-2/3"})]});if(!o||o.length===0)return null;const l=new Map;for(const h of o)for(const u of h.uiTools)l.set(`${h.id}:${u.name}`,{conn:h,tool:u});const c=h=>{if(h.toolName&&h.connectionId)return l.get(`${h.connectionId}:${h.toolName}`);for(const[,u]of l)if(u.conn.id===h.connectionId&&u.tool.resourceUri===h.resourceUri)return u},d=n.some(h=>!!c(h));return i.jsxs("div",{className:"flex flex-col gap-2",children:[d&&i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:"Pinned tiles"}),n.map(h=>{const u=c(h);return u?i.jsx(uN,{agent:t,home:e,connection:u.conn,tool:u.tool,tile:h},h.tileId??`${h.connectionId}:${h.resourceUri}:${h.toolName}`):null})]}),i.jsxs("div",{className:"flex flex-col gap-0.5",children:[i.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground px-2",children:"Add tile"}),o.map(h=>h.uiTools.map(u=>i.jsx(fN,{agent:t,home:e,connection:h,tool:u},`add:${h.id}:${u.name}`)))]})]})}function H0(t,e){return{...t.metadata??{},ui:{...t.metadata?.ui??{},homeTile:null,homeTiles:e}}}async function K0(t,e){try{await e()}catch(s){console.error(`[home-tiles] failed to ${t} tile`,s),de.error("Couldn't update home — please try again.")}}function O3(t,e,s){if(!e||Object.keys(e).length===0)return{};const n=BV(t,e,s);if(!n){de.error("Invalid value in one of the fields — please fix it.");return}return Object.keys(n).length>0?{toolInput:n}:{}}function M3(t){const e=M.c(20),{properties:s,required:n,values:r,onChange:o,onCancel:a,onSubmit:l,submitting:c,submitLabel:d}=t;let h;e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r?(h=i.jsx(UV,{properties:s,required:n,values:r,onChange:o}),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=h):h=e[4];let u;e[5]!==a?(u=i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:a,children:"Cancel"}),e[5]=a,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==c?(f=c?i.jsx(Xe,{size:12,className:"animate-spin"}):d,e[7]=d,e[8]=c,e[9]=f):f=e[9];let m;e[10]!==l||e[11]!==c||e[12]!==f?(m=i.jsx(re,{size:"sm",className:"h-7 text-xs",disabled:c,onClick:l,children:f}),e[10]=l,e[11]=c,e[12]=f,e[13]=m):m=e[13];let p;e[14]!==u||e[15]!==m?(p=i.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16];let g;return e[17]!==h||e[18]!==p?(g=i.jsxs("div",{className:"px-3 pb-2 pt-1 flex flex-col gap-2",children:[h,p]}),e[17]=h,e[18]=p,e[19]=g):g=e[19],g}function uN(t){const e=M.c(50),{agent:s,home:n,connection:r,tool:o,tile:a}=t,[l,c]=k.useState(!1),[d,h]=k.useState(!1);let u;e[0]!==o.inputSchema?(u=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=u):u=e[1];const f=u;let m;e[2]!==a.toolInput||e[3]!==o.inputSchema?.properties?(m=()=>zV(a.toolInput,o.inputSchema?.properties),e[2]=a.toolInput,e[3]=o.inputSchema?.properties,e[4]=m):m=e[4];const[p,g]=k.useState(m);let x;e[5]!==s||e[6]!==n||e[7]!==a?(x=async()=>{c(!0),await K0("remove",async()=>{const D=rr(s.metadata?.ui),P=a.tileId?D.filter(I=>I.tileId!==a.tileId):D.filter(I=>I!==a);await n.saveAgentMetadata(s,H0(s,P)),h(!1)}),c(!1)},e[5]=s,e[6]=n,e[7]=a,e[8]=x):x=e[8];const v=x;let _;e[9]!==s||e[10]!==p||e[11]!==n||e[12]!==a||e[13]!==o.inputSchema?.properties||e[14]!==o.inputSchema?.required?(_=async()=>{const D=O3(p,o.inputSchema?.properties,o.inputSchema?.required);if(!D)return;const{toolInput:P}=D;c(!0),await K0("save",async()=>{const O=rr(s.metadata?.ui).map(B=>(a.tileId?B.tileId===a.tileId:B===a)?{...B,toolInput:P}:B);await n.saveAgentMetadata(s,H0(s,O)),h(!1)}),c(!1)},e[9]=s,e[10]=p,e[11]=n,e[12]=a,e[13]=o.inputSchema?.properties,e[14]=o.inputSchema?.required,e[15]=_):_=e[15];const b=_;let y;e[16]!==a.toolInput?(y=FV(a.toolInput),e[16]=a.toolInput,e[17]=y):y=e[17];const L=y;let w;e[18]!==r.icon||e[19]!==r.title?(w=i.jsx(on,{icon:r.icon,name:r.title,size:"xs"}),e[18]=r.icon,e[19]=r.title,e[20]=w):w=e[20];let S;e[21]!==o.name?(S=yi(o.name),e[21]=o.name,e[22]=S):S=e[22];let j;e[23]!==S?(j=i.jsx("div",{className:"truncate text-sm text-foreground",children:S}),e[23]=S,e[24]=j):j=e[24];let C;e[25]!==L?(C=L&&i.jsx("div",{className:"truncate text-[10px] text-muted-foreground font-mono",children:L}),e[25]=L,e[26]=C):C=e[26];let V;e[27]!==j||e[28]!==C?(V=i.jsxs("div",{className:"min-w-0 flex-1",children:[j,C]}),e[27]=j,e[28]=C,e[29]=V):V=e[29];let N;e[30]!==f?(N=f&&i.jsx("button",{type:"button",onClick:()=>h(hN),"aria-label":"Configure tile props",title:"Configure tile props",className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/60",children:i.jsx(Om,{size:14})}),e[30]=f,e[31]=N):N=e[31];let T;e[32]!==v||e[33]!==l?(T=i.jsx(tu,{isPinned:!0,submitting:l,onClick:v,label:"Remove from home"}),e[32]=v,e[33]=l,e[34]=T):T=e[34];let A;e[35]!==V||e[36]!==N||e[37]!==T||e[38]!==w?(A=i.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[w,V,N,T]}),e[35]=V,e[36]=N,e[37]=T,e[38]=w,e[39]=A):A=e[39];let E;e[40]!==p||e[41]!==b||e[42]!==f||e[43]!==d||e[44]!==l||e[45]!==o.inputSchema?(E=d&&f&&o.inputSchema?.properties&&i.jsx(M3,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:p,onChange:(D,P)=>g(I=>({...I,[D]:P})),onCancel:()=>h(!1),onSubmit:b,submitting:l,submitLabel:"Save"}),e[40]=p,e[41]=b,e[42]=f,e[43]=d,e[44]=l,e[45]=o.inputSchema,e[46]=E):E=e[46];let R;return e[47]!==A||e[48]!==E?(R=i.jsxs("div",{className:"flex flex-col rounded-md bg-accent/20",children:[A,E]}),e[47]=A,e[48]=E,e[49]=R):R=e[49],R}function hN(t){return!t}function fN(t){const e=M.c(39),{agent:s,home:n,connection:r,tool:o}=t,[a,l]=k.useState(!1),[c,d]=k.useState(!1);let h;e[0]!==o.inputSchema?(h=o.inputSchema?.properties&&Object.keys(o.inputSchema.properties).length>0,e[0]=o.inputSchema,e[1]=h):h=e[1];const u=h;let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={},e[2]=f):f=e[2];const[m,p]=k.useState(f);let g,x;e[3]!==s||e[4]!==r.id||e[5]!==m||e[6]!==u||e[7]!==n||e[8]!==c||e[9]!==o.inputSchema?.properties||e[10]!==o.inputSchema?.required||e[11]!==o.name||e[12]!==o.resourceUri?(g=async()=>{if(u&&!c){d(!0);return}if(!n.isOnHome(s.id)&&n.atLimit){de.error(`Home is full (${ua}) — remove an agent first`);return}await x()},x=async()=>{const j=O3(m,o.inputSchema?.properties,o.inputSchema?.required);if(!j)return;const{toolInput:C}=j;l(!0),await K0("add",async()=>{const N=[...rr(s.metadata?.ui),{tileId:crypto.randomUUID(),connectionId:r.id,resourceUri:o.resourceUri,toolName:o.name,...C?{toolInput:C}:{}}];await n.saveAgentMetadata(s,H0(s,N)),d(!1),p({})}),l(!1)},e[3]=s,e[4]=r.id,e[5]=m,e[6]=u,e[7]=n,e[8]=c,e[9]=o.inputSchema?.properties,e[10]=o.inputSchema?.required,e[11]=o.name,e[12]=o.resourceUri,e[13]=g,e[14]=x):(g=e[13],x=e[14]);let v;e[15]!==r.icon||e[16]!==r.title?(v=i.jsx(on,{icon:r.icon,name:r.title,size:"xs"}),e[15]=r.icon,e[16]=r.title,e[17]=v):v=e[17];let _;e[18]!==o.name?(_=yi(o.name),e[18]=o.name,e[19]=_):_=e[19];let b;e[20]!==_?(b=i.jsx("div",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:_}),e[20]=_,e[21]=b):b=e[21];let y;e[22]!==g||e[23]!==a?(y=i.jsx(tu,{isPinned:!1,submitting:a,onClick:g,label:"Add to home"}),e[22]=g,e[23]=a,e[24]=y):y=e[24];let L;e[25]!==v||e[26]!==b||e[27]!==y?(L=i.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-1",children:[v,b,y]}),e[25]=v,e[26]=b,e[27]=y,e[28]=L):L=e[28];let w;e[29]!==m||e[30]!==u||e[31]!==x||e[32]!==c||e[33]!==a||e[34]!==o.inputSchema?(w=c&&u&&o.inputSchema?.properties&&i.jsx(M3,{properties:o.inputSchema.properties,required:o.inputSchema.required,values:m,onChange:(j,C)=>p(V=>({...V,[j]:C})),onCancel:()=>{d(!1),p({})},onSubmit:x,submitting:a,submitLabel:"Pin"}),e[29]=m,e[30]=u,e[31]=x,e[32]=c,e[33]=a,e[34]=o.inputSchema,e[35]=w):w=e[35];let S;return e[36]!==L||e[37]!==w?(S=i.jsxs("div",{className:"flex flex-col rounded-md hover:bg-accent/40",children:[L,w]}),e[36]=L,e[37]=w,e[38]=S):S=e[38],S}function mN(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex flex-col gap-2 p-2",children:Array.from({length:4},pN)}),t[0]=e):e=t[0],e}function pN(t,e){return i.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-2.5",children:[i.jsx(Et,{className:"size-8 rounded-md"}),i.jsxs("div",{className:"flex-1 space-y-1.5",children:[i.jsx(Et,{className:"h-3 w-1/2"}),i.jsx(Et,{className:"h-2.5 w-1/3"})]})]},e)}const gN=[{id:"all",label:"All"},{id:"in_progress",label:"In progress"},{id:"in_review",label:"In review"},{id:"done",label:"Done"}],xN=4;function vN(t){const e=M.c(64),{task:s,assignee:n,onOpen:r}=t,o=yv[s.status],a=o.icon,l=Lv[s.priority];let c,d,h,u,f,m,p,g,x,v,_,b,y,L;if(e[0]!==a||e[1]!==n?.user?.email||e[2]!==n?.user?.image||e[3]!==n?.user?.name||e[4]!==r||e[5]!==o.iconClassName||e[6]!==s.dueDate||e[7]!==s.title||e[8]!==s.updatedAt){const E=n?.user?.name??n?.user?.email?.split("@")[0]??null;let R;e[23]!==s.updatedAt?(R=p2(new Date(s.updatedAt)),e[23]=s.updatedAt,e[24]=R):R=e[24],L=R;let D;e[25]!==s.dueDate?(D=s.dueDate?{label:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(s.dueDate)),overdue:new Date(s.dueDate).getTime()<Date.now()}:null,e[25]=s.dueDate,e[26]=D):D=e[26],d=D,_="button",b=r,y="flex w-full items-center gap-3 rounded-2xl bg-card px-4 py-3.5 text-left card-shadow transition-colors hover:bg-accent/60";let P;e[27]!==o.iconClassName?(P=te("size-4 shrink-0",o.iconClassName),e[27]=o.iconClassName,e[28]=P):P=e[28],e[29]!==a||e[30]!==P?(u=i.jsx(a,{className:P}),e[29]=a,e[30]=P,e[31]=u):u=e[31],e[32]!==s.title?(f=i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:s.title}),e[32]=s.title,e[33]=f):f=e[33],v="flex shrink-0 items-center gap-3 text-xs text-muted-foreground",x="hidden @2xl:inline-flex",c=Ji,h="circle",m="2xs",p=n?.user?.image??void 0,g=(E??"?").slice(0,2).toUpperCase(),e[0]=a,e[1]=n?.user?.email,e[2]=n?.user?.image,e[3]=n?.user?.name,e[4]=r,e[5]=o.iconClassName,e[6]=s.dueDate,e[7]=s.title,e[8]=s.updatedAt,e[9]=c,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=m,e[15]=p,e[16]=g,e[17]=x,e[18]=v,e[19]=_,e[20]=b,e[21]=y,e[22]=L}else c=e[9],d=e[10],h=e[11],u=e[12],f=e[13],m=e[14],p=e[15],g=e[16],x=e[17],v=e[18],_=e[19],b=e[20],y=e[21],L=e[22];let w;e[34]!==c||e[35]!==h||e[36]!==m||e[37]!==p||e[38]!==g?(w=i.jsx(c,{shape:h,size:m,url:p,fallback:g}),e[34]=c,e[35]=h,e[36]=m,e[37]=p,e[38]=g,e[39]=w):w=e[39];let S;e[40]!==w||e[41]!==x?(S=i.jsx("span",{className:x,children:w}),e[40]=w,e[41]=x,e[42]=S):S=e[42];let j;e[43]!==l.flagClassName?(j=te("size-3.5 shrink-0",l.flagClassName),e[43]=l.flagClassName,e[44]=j):j=e[44];let C;e[45]!==j?(C=i.jsx(m9,{className:j}),e[45]=j,e[46]=C):C=e[46];let V;e[47]!==d?(V=d&&i.jsxs("span",{className:te("hidden items-center gap-1 @xl:inline-flex",d.overdue?"text-red-600":""),children:[i.jsx(Xd,{className:"size-3"}),d.label]}),e[47]=d,e[48]=V):V=e[48];let N;e[49]!==L?(N=i.jsx("span",{className:"hidden @xl:inline",children:L}),e[49]=L,e[50]=N):N=e[50];let T;e[51]!==S||e[52]!==C||e[53]!==V||e[54]!==N||e[55]!==v?(T=i.jsxs("div",{className:v,children:[S,C,V,N]}),e[51]=S,e[52]=C,e[53]=V,e[54]=N,e[55]=v,e[56]=T):T=e[56];let A;return e[57]!==u||e[58]!==f||e[59]!==T||e[60]!==_||e[61]!==b||e[62]!==y?(A=i.jsxs("button",{type:_,onClick:b,className:y,children:[u,f,T]}),e[57]=u,e[58]=f,e[59]=T,e[60]=_,e[61]=b,e[62]=y,e[63]=A):A=e[63],A}function bN(t){const e=t.filter(d=>d.status!=="done");if(e.length===0)return"You're all caught up. Nothing needs your attention right now.";const s=e.filter(d=>d.status==="in_progress").length,n=e.filter(d=>d.status==="in_review").length,r=e.filter(d=>d.priority==="urgent"||d.priority==="high").length,o=e.filter(d=>d.dueDate&&new Date(d.dueDate).getTime()<Date.now()).length,a=[];s>0&&a.push(`${s} in progress`),n>0&&a.push(`${n} need${n===1?"s":""} review`);let l=`You have ${e.length} active task${e.length===1?"":"s"}`;a.length>0&&(l+=` — ${a.join(", ")}`),l+=".";const c=[];return r>0&&c.push(`${r} ${r===1?"is":"are"} high priority.`),o>0&&c.push(`${o} task${o===1?" is":"s are"} overdue.`),c.length>0?`${l} ${c.join(" ")}`:l}function _N(t){const e=M.c(39),{afterSummary:s}=t,n=yt(),{items:r,error:o}=vv(),a=bv(),{data:l}=qm();let c;if(e[0]!==l?.data?.members){const C=l?.data?.members??[];c=new Map(C.map(SN)),e[0]=l?.data?.members,e[1]=c}else c=e[1];const d=c,[h,u]=k.useState("all"),[f,m]=k.useState(!1);let p,g,x,v,_,b;if(e[2]!==s||e[3]!==o||e[4]!==r||e[5]!==d||e[6]!==n||e[7]!==h){const C=o?[]:r,V=[...C].sort(LN),N=bN(C),T=h==="all"?V:V.filter(I=>I.status===h);let A;e[14]!==n?(A=()=>n({to:".",search:yN}),e[14]=n,e[15]=A):A=e[15];const E=A;v="flex flex-col gap-10";let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(Sv,{size:24,className:"mt-0.5"}),e[16]=R):R=e[16],_=i.jsxs("div",{className:"flex items-start gap-4 animate-in fade-in slide-in-from-top-1 duration-300",children:[R,i.jsx("p",{className:"max-w-3xl text-lg font-medium leading-snug text-foreground",children:N})]}),b=s,p="flex flex-col gap-4";let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx("h2",{className:"text-base font-medium text-foreground",children:"Tasks"}),e[17]=D):D=e[17];let P;e[18]!==h?(P=gN.map(I=>i.jsx("button",{type:"button",onClick:()=>u(I.id),className:te("rounded-md px-2.5 py-1 text-xs font-medium transition-colors",h===I.id?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:I.label},I.id)),e[18]=h,e[19]=P):P=e[19],e[20]!==P?(g=i.jsxs("div",{className:"flex items-center gap-3",children:[D,i.jsx("div",{className:"flex items-center gap-1",children:P})]}),e[20]=P,e[21]=g):g=e[21],x=T.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl bg-card px-4 py-10 text-center card-shadow",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:h==="all"?"No tasks yet. Create one to get started.":`Nothing ${h==="in_progress"?"in progress":h==="in_review"?"in review":"done"} right now.`}),h==="all"&&i.jsxs(re,{variant:"outline",size:"sm",onClick:()=>m(!0),className:"gap-2",children:[i.jsx(kt,{className:"size-4"}),"Create new task"]})]}):i.jsxs("div",{className:"flex flex-col gap-2",children:[T.slice(0,xN).map(I=>i.jsx(vN,{task:I,assignee:I.assigneeId?d.get(I.assigneeId):void 0,onOpen:E},I.id)),i.jsxs("button",{type:"button",onClick:E,className:"flex w-full items-center justify-center gap-1.5 rounded-2xl bg-card px-4 py-3 text-sm font-medium text-muted-foreground card-shadow transition-colors hover:bg-accent/60 hover:text-foreground",children:["See all tasks",i.jsx(g2,{className:"size-3.5"})]})]}),e[2]=s,e[3]=o,e[4]=r,e[5]=d,e[6]=n,e[7]=h,e[8]=p,e[9]=g,e[10]=x,e[11]=v,e[12]=_,e[13]=b}else p=e[8],g=e[9],x=e[10],v=e[11],_=e[12],b=e[13];let y;e[22]!==p||e[23]!==g||e[24]!==x?(y=i.jsxs("section",{className:p,children:[g,x]}),e[22]=p,e[23]=g,e[24]=x,e[25]=y):y=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=()=>m(!1),e[26]=L):L=e[26];let w;e[27]!==a.create?(w=C=>{a.create.mutate(C),m(!1)},e[27]=a.create,e[28]=w):w=e[28];let S;e[29]!==a.create.isPending||e[30]!==f||e[31]!==w?(S=i.jsx(_v,{open:f,onClose:L,isSaving:a.create.isPending,onSubmit:w}),e[29]=a.create.isPending,e[30]=f,e[31]=w,e[32]=S):S=e[32];let j;return e[33]!==S||e[34]!==v||e[35]!==_||e[36]!==b||e[37]!==y?(j=i.jsxs("div",{className:v,children:[_,b,y,S]}),e[33]=S,e[34]=v,e[35]=_,e[36]=b,e[37]=y,e[38]=j):j=e[38],j}function yN(t){return{...t,main:"board"}}function LN(t,e){return(e.updatedAt??"").localeCompare(t.updatedAt??"")}function SN(t){return[t.userId,t]}function wN(t){const e=M.c(17),{isEditMode:s,hasChanges:n,onEnter:r,onSave:o,onCancel:a,onAddTile:l}=t;if(!s){let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Em,{size:14}),e[0]=x):x=e[0];let v;return e[1]!==r?(v=i.jsxs(re,{type:"button",size:"sm",variant:"ghost",onClick:r,className:"h-8 gap-1.5 text-muted-foreground",children:[x,"Customize"]}),e[1]=r,e[2]=v):v=e[2],v}let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(kt,{size:14}),e[3]=c):c=e[3];let d;e[4]!==l?(d=i.jsxs(re,{type:"button",size:"sm",variant:"ghost",onClick:l,className:"h-8 gap-1.5",children:[c,"Add tile"]}),e[4]=l,e[5]=d):d=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(js,{size:14}),e[6]=h):h=e[6];let u;e[7]!==a?(u=i.jsxs(re,{type:"button",size:"sm",variant:"ghost",onClick:a,className:"h-8 gap-1.5",children:[h,"Cancel"]}),e[7]=a,e[8]=u):u=e[8];const f=!n;let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Ot,{size:14}),e[9]=m):m=e[9];let p;e[10]!==o||e[11]!==f?(p=i.jsxs(re,{type:"button",size:"sm",onClick:o,disabled:f,className:"h-8 gap-1.5",children:[m,"Save"]}),e[10]=o,e[11]=f,e[12]=p):p=e[12];let g;return e[13]!==d||e[14]!==u||e[15]!==p?(g=i.jsxs("div",{className:"flex items-center gap-1",children:[d,u,p]}),e[13]=d,e[14]=u,e[15]=p,e[16]=g):g=e[16],g}function jN(){const t=M.c(18),{isEditMode:e,enter:s,save:n,cancel:r,hasChanges:o}=B9(),[a,l]=k.useState(!1),c=Jl();let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(_N,{afterSummary:i.jsx(Hj,{})}),t[0]=d):d=t[0];let h;t[1]!==r||t[2]!==s||t[3]!==o||t[4]!==e||t[5]!==c||t[6]!==n?(h=!c&&i.jsx("div",{className:"flex justify-end",children:i.jsx(wN,{isEditMode:e,hasChanges:o,onEnter:s,onSave:n,onCancel:r,onAddTile:()=>l(!0)})}),t[1]=r,t[2]=s,t[3]=o,t[4]=e,t[5]=c,t[6]=n,t[7]=h):h=t[7];let u;t[8]!==e?(u=i.jsx(vV,{isEditMode:e}),t[8]=e,t[9]=u):u=t[9];let f;t[10]!==h||t[11]!==u?(f=i.jsxs("div",{className:"@container mx-auto flex max-w-5xl flex-col gap-10 px-6 py-8",children:[d,i.jsxs("div",{className:"flex flex-col gap-4",children:[h,u]})]}),t[10]=h,t[11]=u,t[12]=f):f=t[12];let m;t[13]!==a?(m=i.jsx(KV,{open:a,onOpenChange:l}),t[13]=a,t[14]=m):m=t[14];let p;return t[15]!==f||t[16]!==m?(p=i.jsxs("div",{className:"h-full overflow-y-auto",children:[f,m]}),t[15]=f,t[16]=m,t[17]=p):p=t[17],p}function CN(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(Bj,{children:i.jsx(jN,{})}),t[0]=e):e=t[0],e}const kN=10,sf=100,VN=30;function NN(t){const e=t;if(e.isError)return null;const s=e.content?.find(r=>r.type==="resource"),n=s?.resource?.text??s?.text;if(!n)return null;try{const r=JSON.parse(n);return typeof r=="string"?r:r&&typeof r=="object"&&"content"in r&&typeof r.content=="string"?r.content:JSON.stringify(r,null,2)}catch{return n}}async function Sa(t,e,s){try{const n=await t.callTool({name:"get_file_contents",arguments:{owner:e.owner,repo:e.repo,path:e.path,...s}});return NN(n)}catch{return null}}function AN(t){const e=Oi(t);return Array.isArray(e)?e.map(s=>{const n=Number(s.additions??0),r=Number(s.changes??n),o=Number(s.deletions??Math.max(0,r-n));return{filename:String(s.filename??""),status:s.status??"modified",additions:n,deletions:o,blobUrl:typeof s.blob_url=="string"?s.blob_url:null,previousFilename:typeof s.previous_filename=="string"?s.previous_filename:null}}):[]}async function TN(t,e,s){if(t.length===0)return;let n=0;async function r(){for(;n<t.length;){const o=n++;await s(t[o])}}await Promise.all(Array.from({length:Math.min(e,t.length)},()=>r()))}async function EN(t,e){const s=[];for(let n=1;n<=VN;n++){const r=await t.callTool({name:"pull_request_read",arguments:{method:"get_files",owner:e.owner,repo:e.repo,pullNumber:e.pullNumber,page:n,perPage:sf}}),o=AN(r);if(s.push(...o),o.length<sf)break}return s}async function nf(t,e){const n=(await EN(t,e)).filter(a=>a.filename.length>0),r={},o=e.mergeBaseSha?{sha:e.mergeBaseSha}:{ref:e.base};return await TN(n,kN,async a=>{const l=a.filename;if(a.status==="added"){r[l]={from:null,to:await Sa(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})};return}if(a.status==="removed"){r[l]={from:await Sa(t,{owner:e.owner,repo:e.repo,path:l},o),to:null};return}const c=a.previousFilename??l,[d,h]=await Promise.all([Sa(t,{owner:e.owner,repo:e.repo,path:c},o),Sa(t,{owner:e.owner,repo:e.repo,path:l},{sha:e.headSha})]);r[l]={from:d,to:h}}),{diffs:r}}function $3(t){return t?Object.keys(t.diffs).length:0}function Or(t,e,s,n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/git/${n}`}class B3 extends Error{constructor(e,s){super(e),this.status=s,this.name="SandboxGitError"}status}function z3(t){return t instanceof B3&&(t.status===503||t.status===410||t.status===404)}async function Mr(t){const e=await t.json();if(!t.ok)throw new B3(typeof e.error=="string"?e.error:`Request failed (${t.status})`,t.status);return e}function $r(t,e){return fetch(t,{cache:"no-store",...e})}async function Ha(t,e,s){const n=await $r(Or(t,e,s,"status"));return Mr(n)}async function tr(t,e,s,n){const r=n?.base||n?.headSha?{...n.base?{base:n.base}:{},...n.headSha?{headSha:n.headSha}:{}}:void 0,o=await $r(Or(t,e,s,"diff"),{method:"POST",headers:r?{"content-type":"application/json"}:void 0,body:r?JSON.stringify(r):void 0});return Mr(o)}function RN(t){const e={};for(const[s,n]of Object.entries(t.diffs))F3(s)||U3(s)||(e[s]=n);return{...t,diffs:e}}async function rf(t,e,s,n){const r=n?{status:n.status,diff:RN(n.diff)}:{},o=await $r(Or(t,e,s,"suggest-commit"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r)});return Mr(o)}async function of(t,e,s,n){const r=await $r(Or(t,e,s,"publish"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({message:n})});await Mr(r)}async function PN(t,e,s,n){const r=await $r(Or(t,e,s,"rebase"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({base:n})});await Mr(r)}function F3(t){return t==="blocks.gen.json"||t.endsWith("/blocks.gen.json")}function U3(t){return t==="static/tailwind.css"||t.endsWith("/static/tailwind.css")}function IN(t){return t===".deco"||t.endsWith("/.deco")||t.startsWith(".deco/")||t.includes("/.deco/")}function DN(t){if(!t)return!1;const e=Object.keys(t.diffs);return e.length===0?!1:e.every(s=>IN(s)||F3(s)||U3(s))}const ON="Code changes can't be published directly — use Submit for review";async function af(t,e,s,n){const r=await $r(Or(t,e,s,"discard"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({filepaths:n})});await Mr(r)}const MN="current";function $N(t){return t?.[MN]??null}function XH(t,e,s){return["sandbox-git-status",t,e,s]}function H3(t){return t?t.modified.length+t.created.length+t.deleted.length+t.not_added.length+t.renamed.length:0}function pc(t){return t?H3(t)>0||t.staged.length>0||t.conflicted.length>0:!1}function K3(t){return t?pc(t)||t.ahead>0||(t.unpushed??0)>0?!0:t.unpushed===void 0&&(t.aheadOfBase??0)>0&&t.tracking==null:!1}function BN(t,e){return t?K3(t)||e!=null&&Object.keys(e.diffs).length>0:!1}function zN(t,e){return pc(t)?!1:e.openPrFromCommits||!e.commitToOpenPr&&(t?.aheadOfBase??0)>0}function W3(t,e){return{diffs:{...t?.diffs??{},...e?.diffs??{}},...t?.mergeBaseSha?{mergeBaseSha:t.mergeBaseSha}:{}}}function q3(t){return DN(t)?{allowed:!0,reason:null}:{allowed:!1,reason:ON}}function FN(t,e,s,n,r,o,a){return["pr-diff",t,e,s,n,r,o,a]}function UN(t){const e=M.c(26),{orgSlug:s,orgId:n,virtualMcpId:r,branch:o,base:a,headSha:l,pullNumber:c,connectionId:d,owner:h,repo:u,enabled:f}=t,m=f===void 0?!0:f;let p;e[0]!==d||e[1]!==n||e[2]!==s?(p={connectionId:d,orgId:n,orgSlug:s},e[0]=d,e[1]=n,e[2]=s,e[3]=p):p=e[3];const g=ut(p);let x;e[4]!==a||e[5]!==o||e[6]!==d||e[7]!==l||e[8]!==s||e[9]!==c||e[10]!==r?(x=FN(s,r,o,a,l,c,d),e[4]=a,e[5]=o,e[6]=d,e[7]=l,e[8]=s,e[9]=c,e[10]=r,e[11]=x):x=e[11];let v;e[12]!==a||e[13]!==o||e[14]!==g||e[15]!==l||e[16]!==s||e[17]!==h||e[18]!==c||e[19]!==u||e[20]!==r?(v=async()=>{try{const y=await tr(s,r,o,{base:a,headSha:l});return $3(y)>0?y:nf(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l,mergeBaseSha:y.mergeBaseSha})}catch{return nf(g,{owner:h,repo:u,pullNumber:c,base:a,headSha:l})}},e[12]=a,e[13]=o,e[14]=g,e[15]=l,e[16]=s,e[17]=h,e[18]=c,e[19]=u,e[20]=r,e[21]=v):v=e[21];const _=m&&!!o&&!!l&&!!d;let b;return e[22]!==x||e[23]!==v||e[24]!==_?(b={queryKey:x,queryFn:v,enabled:_,refetchInterval:3e4,staleTime:1e4},e[22]=x,e[23]=v,e[24]=_,e[25]=b):b=e[25],Ut(b)}h6.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});function HN(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function G3(t){const e=M.c(9),{diff:s,emptyMessage:n,rowClassName:r,onDiscardFile:o}=t,a=n===void 0?"No file changes in the working tree":n,l=r===void 0?"px-6":r,[c,d]=k.useState(null),[h,u]=k.useState(null);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=HN(),e[0]=f):f=e[0];const m=f;if(!s||Object.keys(s.diffs).length===0){let g;return e[1]!==a?(g=i.jsx("div",{className:"flex items-center justify-center py-10 text-sm text-muted-foreground",children:a}),e[1]=a,e[2]=g):g=e[2],g}let p;return e[3]!==s.diffs||e[4]!==h||e[5]!==c||e[6]!==o||e[7]!==l?(p=i.jsx("div",{className:"divide-y",children:Object.entries(s.diffs).map(g=>{const[x,v]=g,{from:_,to:b}=v,y=c===x,L=_===null,w=b===null,S=x.startsWith("/")?x.slice(1):x,j=S.lastIndexOf("/"),C=j>=0?S.slice(j+1):S,V=j>=0?S.slice(0,j):null,N=Ab(x),T=L?"bg-success":w?"bg-destructive":"bg-warning";return i.jsxs("div",{children:[i.jsxs("div",{className:te("flex items-center gap-3 py-3 hover:bg-muted/30",l),children:[i.jsx("button",{type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-transform hover:text-foreground",onClick:()=>d(y?null:x),children:i.jsx(vn,{className:te("h-3.5 w-3.5 transition-transform",y&&"rotate-90")})}),i.jsx("div",{className:te("h-2.5 w-2.5 shrink-0 rounded-full",T)}),i.jsx(i2,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:C}),V&&i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:V}),o?i.jsxs(as,{children:[i.jsx(ls,{asChild:!0,children:i.jsx("button",{type:"button",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground",children:i.jsx(ni,{className:"h-3.5 w-3.5"})})}),i.jsx(cs,{align:"end",children:i.jsx(Ge,{className:"text-destructive focus:text-destructive",onSelect:()=>u(x),children:"Discard changes"})})]}):null]}),h===x&&o?i.jsxs("div",{className:te("flex items-center justify-between gap-3 border-t bg-destructive/5 py-2.5",l),children:[i.jsxs("span",{className:"text-xs text-destructive",children:["Discard all changes to"," ",i.jsx("span",{className:"font-medium",children:C}),"? This cannot be undone."]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(null),children:"Cancel"}),i.jsx(re,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:()=>{u(null),o(x)},children:"Discard"})]})]}):null,y&&i.jsx("div",{className:"border-t",children:i.jsx(f6,{original:_??"",modified:b??"",language:N,theme:m,height:"380px",options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12}})})]},x)})}),e[3]=s.diffs,e[4]=h,e[5]=c,e[6]=o,e[7]=l,e[8]=p):p=e[8],p}function KN(t){const e=M.c(4),{diffQuery:s}=t;if(s.isLoading){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[i.jsx(Xe,{className:"h-4 w-4 animate-spin"}),i.jsx("span",{className:"text-sm",children:"Loading changes…"})]}),e[0]=r):r=e[0],r}if(s.isError){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"py-10 text-sm text-destructive",children:"Couldn't load PR changes."}),e[1]=r):r=e[1],r}let n;return e[2]!==s.data?(n=i.jsx(G3,{diff:s.data,rowClassName:"px-0",emptyMessage:"No committed changes in this pull request"}),e[2]=s.data,e[3]=n):n=e[3],n}const $i="The user clicked this action deliberately — execute directly. Do not call user_ask unless you hit an actual problem outside the scope of this intent (missing auth, unresolvable conflict, a check with multiple plausible fixes).";function WN(t){return`Reopen PR #${t.prNumber}. ${$i}`}function qN(t){return`Rebase \`${t.branch}\` on the latest base and force-push with --force-with-lease. ${$i}`}function GN(t){return`Re-run the \`${t.checkName}\` check on PR #${t.prNumber}. If an empty commit is needed to retrigger CI, create and push one. ${$i}`}function YN(t){const e=(t.failingChecks??[]).map(s=>`\`${s}\``).join(", ");return`PR #${t.prNumber} has failing checks: ${e}. For each: read the logs, diagnose the root cause, apply the smallest fix that makes it pass, commit, and push. ${$i}`}function JN(t){return`Mark PR #${t.prNumber} ready for review. ${$i}`}function XN(t){return`Read the unresolved review threads on PR #${t.prNumber}. For each thread: understand the reviewer's ask, apply the needed changes, commit, push, reply explaining what changed, and resolve the thread. If a comment is a question that doesn't need a code change, reply with the answer and resolve. ${$i}`}function QN(t){return`Review PR #${t.prNumber}. Read the full diff, analyze every changed file for correctness, security, code quality, and alignment with the repo's patterns. Post specific line-level review comments on concerns, then submit an overall review (approve / request changes / comment) with a concise summary. Do not modify the code — this is a read-and-comment pass. ${$i}`}function ZN(t){const e=M.c(24),{pr:s,connectionId:n,owner:r,repo:o}=t,{org:a}=Ee(),l=Ys();let c;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(c={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:r,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=c):c=e[6];const d=K2(c);let h;e[7]!==l||e[8]!==s.number?(h=x=>l.sendMessage({parts:[{type:"text",text:GN({prNumber:s.number,checkName:x})}]}),e[7]=l,e[8]=s.number,e[9]=h):h=e[9];const u=h;if(d.isLoading){let x;return e[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading checks…"}),e[10]=x):x=e[10],x}if(d.isError){let x;return e[11]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("div",{className:"text-sm text-destructive",children:"Couldn't load check runs."}),e[11]=x):x=e[11],x}let f;e[12]!==d.data?(f=d.data??[],e[12]=d.data,e[13]=f):f=e[13];const m=f;if(m.length===0){let x;return e[14]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("div",{className:"text-sm text-muted-foreground",children:"No check runs on the PR head commit."}),e[14]=x):x=e[14],x}let p;if(e[15]!==l||e[16]!==m||e[17]!==u){let x;e[19]!==l||e[20]!==u?(x=v=>i.jsxs("li",{className:"flex items-center justify-between gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted",children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(eA,{check:v}),i.jsx("span",{className:"truncate",children:v.name}),v.durationMs!=null&&i.jsx("span",{className:"text-xs text-muted-foreground",children:tA(v.durationMs)})]}),i.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[v.htmlUrl&&i.jsx("a",{href:v.htmlUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-7 items-center justify-center rounded px-2 text-xs text-muted-foreground hover:bg-background",title:"View run",children:i.jsx(Rn,{className:"h-3.5 w-3.5"})}),v.conclusion==="failure"&&i.jsx(re,{size:"sm",variant:"ghost",disabled:l.isStreaming,onClick:()=>u(v.name),children:"Re-run"})]})]},v.id),e[19]=l,e[20]=u,e[21]=x):x=e[21],p=m.map(x),e[15]=l,e[16]=m,e[17]=u,e[18]=p}else p=e[18];let g;return e[22]!==p?(g=i.jsx("ul",{className:"flex flex-col gap-0.5",children:p}),e[22]=p,e[23]=g):g=e[23],g}function eA(t){const e=M.c(5),{check:s}=t;if(s.status!=="completed"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-muted-foreground","aria-label":"In progress",children:"○"}),e[0]=o):o=e[0],o}if(s.conclusion==="success"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-success","aria-label":"Success",children:"✓"}),e[1]=o):o=e[1],o}if(s.conclusion==="failure"){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-destructive","aria-label":"Failure",children:"✗"}),e[2]=o):o=e[2],o}const n=s.conclusion??"—";let r;return e[3]!==n?(r=i.jsx("span",{className:"text-muted-foreground","aria-label":n,children:"—"}),e[3]=n,e[4]=r):r=e[4],r}function tA(t){const e=Math.round(t/1e3);return e<60?`${e}s`:`${Math.round(e/60)}m`}var an="Accordion",sA=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[nu,nA,iA]=Q5(an),[gc]=Z5(an,[iA,hm]),iu=hm(),Y3=et.forwardRef((t,e)=>{const{type:s,...n}=t,r=n,o=n;return i.jsx(nu.Provider,{scope:t.__scopeAccordion,children:s==="multiple"?i.jsx(lA,{...o,ref:e}):i.jsx(aA,{...r,ref:e})})});Y3.displayName=an;var[J3,rA]=gc(an),[X3,oA]=gc(an,{collapsible:!1}),aA=et.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:r=()=>{},collapsible:o=!1,...a}=t,[l,c]=rm({prop:s,defaultProp:n??"",onChange:r,caller:an});return i.jsx(J3,{scope:t.__scopeAccordion,value:et.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:et.useCallback(()=>o&&c(""),[o,c]),children:i.jsx(X3,{scope:t.__scopeAccordion,collapsible:o,children:i.jsx(Q3,{...a,ref:e})})})}),lA=et.forwardRef((t,e)=>{const{value:s,defaultValue:n,onValueChange:r=()=>{},...o}=t,[a,l]=rm({prop:s,defaultProp:n??[],onChange:r,caller:an}),c=et.useCallback(h=>l((u=[])=>[...u,h]),[l]),d=et.useCallback(h=>l((u=[])=>u.filter(f=>f!==h)),[l]);return i.jsx(J3,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:d,children:i.jsx(X3,{scope:t.__scopeAccordion,collapsible:!0,children:i.jsx(Q3,{...o,ref:e})})})}),[cA,xc]=gc(an),Q3=et.forwardRef((t,e)=>{const{__scopeAccordion:s,disabled:n,dir:r,orientation:o="vertical",...a}=t,l=et.useRef(null),c=ex(l,e),d=nA(s),u=tx(r)==="ltr",f=sx(t.onKeyDown,m=>{if(!sA.includes(m.key))return;const p=m.target,g=d().filter(j=>!j.ref.current?.disabled),x=g.findIndex(j=>j.ref.current===p),v=g.length;if(x===-1)return;m.preventDefault();let _=x;const b=0,y=v-1,L=()=>{_=x+1,_>y&&(_=b)},w=()=>{_=x-1,_<b&&(_=y)};switch(m.key){case"Home":_=b;break;case"End":_=y;break;case"ArrowRight":o==="horizontal"&&(u?L():w());break;case"ArrowDown":o==="vertical"&&L();break;case"ArrowLeft":o==="horizontal"&&(u?w():L());break;case"ArrowUp":o==="vertical"&&w();break}const S=_%v;g[S].ref.current?.focus()});return i.jsx(cA,{scope:s,disabled:n,direction:r,orientation:o,children:i.jsx(nu.Slot,{scope:s,children:i.jsx(im.div,{...a,"data-orientation":o,ref:c,onKeyDown:n?void 0:f})})})}),Nl="AccordionItem",[dA,ru]=gc(Nl),Z3=et.forwardRef((t,e)=>{const{__scopeAccordion:s,value:n,...r}=t,o=xc(Nl,s),a=rA(Nl,s),l=iu(s),c=nx(),d=n&&a.value.includes(n)||!1,h=o.disabled||t.disabled;return i.jsx(dA,{scope:s,open:d,disabled:h,triggerId:c,children:i.jsx(kx,{"data-orientation":o.orientation,"data-state":rg(d),...l,...r,ref:e,disabled:h,open:d,onOpenChange:u=>{u?a.onItemOpen(n):a.onItemClose(n)}})})});Z3.displayName=Nl;var eg="AccordionHeader",tg=et.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,r=xc(an,s),o=ru(eg,s);return i.jsx(im.h3,{"data-orientation":r.orientation,"data-state":rg(o.open),"data-disabled":o.disabled?"":void 0,...n,ref:e})});tg.displayName=eg;var W0="AccordionTrigger",sg=et.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,r=xc(an,s),o=ru(W0,s),a=oA(W0,s),l=iu(s);return i.jsx(nu.ItemSlot,{scope:s,children:i.jsx(Cx,{"aria-disabled":o.open&&!a.collapsible||void 0,"data-orientation":r.orientation,id:o.triggerId,...l,...n,ref:e})})});sg.displayName=W0;var ng="AccordionContent",ig=et.forwardRef((t,e)=>{const{__scopeAccordion:s,...n}=t,r=xc(an,s),o=ru(ng,s),a=iu(s);return i.jsx(Vx,{role:"region","aria-labelledby":o.triggerId,"data-orientation":r.orientation,...a,...n,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});ig.displayName=ng;function rg(t){return t?"open":"closed"}var uA=Y3,hA=Z3,fA=tg,mA=sg,pA=ig;function gA(t){const e=M.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let n;return e[2]!==s?(n=i.jsx(uA,{"data-slot":"accordion",...s}),e[2]=s,e[3]=n):n=e[3],n}function xA(t){const e=M.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let r;e[3]!==s?(r=te("border-b last:border-b-0",s),e[3]=s,e[4]=r):r=e[4];let o;return e[5]!==n||e[6]!==r?(o=i.jsx(hA,{"data-slot":"accordion-item",className:r,...n}),e[5]=n,e[6]=r,e[7]=o):o=e[7],o}function vA(t){const e=M.c(11);let s,n,r;e[0]!==t?({className:n,children:s,...r}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=r):(s=e[1],n=e[2],r=e[3]);let o;e[4]!==n?(o=te("focus-visible:border-ring focus-visible:ring-ring/20 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[2px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(vn,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200"}),e[6]=a):a=e[6];let l;return e[7]!==s||e[8]!==r||e[9]!==o?(l=i.jsx(fA,{className:"flex",children:i.jsxs(mA,{"data-slot":"accordion-trigger",className:o,...r,children:[s,a]})}),e[7]=s,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function bA(t){const e=M.c(12);let s,n,r;e[0]!==t?({className:n,children:s,...r}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=r):(s=e[1],n=e[2],r=e[3]);let o;e[4]!==n?(o=te("pt-0 pb-4",n),e[4]=n,e[5]=o):o=e[5];let a;e[6]!==s||e[7]!==o?(a=i.jsx("div",{className:o,children:s}),e[6]=s,e[7]=o,e[8]=a):a=e[8];let l;return e[9]!==r||e[10]!==a?(l=i.jsx(pA,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...r,children:a}),e[9]=r,e[10]=a,e[11]=l):l=e[11],l}function _A(t){const e=M.c(10),{comments:s,isLoading:n,isError:r}=t;if(n||r||!s||s.length===0)return null;const o=s.length===1?"":"s";let a;e[0]!==s.length||e[1]!==o?(a=i.jsxs(vA,{className:"py-3 text-sm font-medium",children:[s.length," comment",o]}),e[0]=s.length,e[1]=o,e[2]=a):a=e[2];let l;e[3]!==s?(l=s.map(yA),e[3]=s,e[4]=l):l=e[4];let c;e[5]!==l?(c=i.jsx(bA,{className:"space-y-3 pb-3",children:l}),e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=i.jsx(gA,{type:"single",collapsible:!0,className:"border-t border-border",children:i.jsxs(xA,{value:"comments",className:"border-b-0",children:[a,c]})}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}function yA(t){return i.jsxs("div",{className:"rounded-md border border-border p-3",children:[i.jsxs("div",{className:"mb-1 text-xs text-muted-foreground",children:["@",t.author," · ",LA(t.createdAt)]}),i.jsx(l9,{id:`pr-comment-${t.id}`,text:fr(t.body)})]},t.id)}function LA(t){if(!t)return"";const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const s=Date.now()-e;if(s<0)return"just now";const n=Math.floor(s/864e5);if(n>0)return`${n}d ago`;const r=Math.floor(s/36e5);if(r>0)return`${r}h ago`;const o=Math.floor(s/6e4);return`${Math.max(1,o)}m ago`}function SA(t){const e=M.c(19),{pr:s,connectionId:n,owner:r,repo:o}=t,{org:a}=Ee();let l;e[0]!==n||e[1]!==a.id||e[2]!==a.slug||e[3]!==r||e[4]!==s.number||e[5]!==o?(l={orgId:a.id,orgSlug:a.slug,connectionId:n,owner:r,repo:o,prNumber:s.number},e[0]=n,e[1]=a.id,e[2]=a.slug,e[3]=r,e[4]=s.number,e[5]=o,e[6]=l):l=e[6];const c=Ky(l);let d;e[7]!==s.body||e[8]!==s.number?(d=s.body&&i.jsx("div",{className:"text-sm",children:i.jsx(l9,{id:`pr-body-${s.number}`,text:fr(s.body)})}),e[7]=s.body,e[8]=s.number,e[9]=d):d=e[9];let h;e[10]!==c.data?(h=c.data??[],e[10]=c.data,e[11]=h):h=e[11];let u;e[12]!==c.isError||e[13]!==c.isLoading||e[14]!==h?(u=i.jsx(_A,{comments:h,isLoading:c.isLoading,isError:c.isError}),e[12]=c.isError,e[13]=c.isLoading,e[14]=h,e[15]=u):u=e[15];let f;return e[16]!==d||e[17]!==u?(f=i.jsxs("div",{className:"space-y-8",children:[d,u]}),e[16]=d,e[17]=u,e[18]=f):f=e[18],f}function wA(t){const e=M.c(68),{pr:s,virtualMcpId:n,branch:r,connectionId:o,owner:a,repo:l}=t,{org:c}=Ee();let d;e[0]!==r||e[1]!==o||e[2]!==c.id||e[3]!==c.slug||e[4]!==a||e[5]!==s.base||e[6]!==s.headSha||e[7]!==s.number||e[8]!==l||e[9]!==n?(d={orgSlug:c.slug,orgId:c.id,virtualMcpId:n,branch:r,base:s.base,headSha:s.headSha,pullNumber:s.number,connectionId:o,owner:a,repo:l},e[0]=r,e[1]=o,e[2]=c.id,e[3]=c.slug,e[4]=a,e[5]=s.base,e[6]=s.headSha,e[7]=s.number,e[8]=l,e[9]=n,e[10]=d):d=e[10];const h=UN(d);let u;e[11]!==h.data?(u=h.data?$3(h.data):void 0,e[11]=h.data,e[12]=u):u=e[12];const f=u,[m,p]=k.useState("changes");let g;e[13]!==s.title?(g=fr(s.title),e[13]=s.title,e[14]=g):g=e[14];let x;e[15]!==g?(x=i.jsx("h1",{className:"text-lg font-semibold leading-tight",children:g}),e[15]=g,e[16]=x):x=e[16];const v=`Open PR #${s.number} on GitHub`;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(Rn,{className:"h-3.5 w-3.5"}),e[17]=_):_=e[17];let b;e[18]!==s.htmlUrl||e[19]!==s.number||e[20]!==v?(b=i.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":v,className:"inline-flex items-center gap-1 hover:text-foreground",children:["PR #",s.number,_]}),e[18]=s.htmlUrl,e[19]=s.number,e[20]=v,e[21]=b):b=e[21];let y;e[22]!==s.author?(y=s.author?i.jsxs(i.Fragment,{children:[i.jsx("span",{children:"·"}),i.jsxs("span",{children:["@",s.author]})]}):null,e[22]=s.author,e[23]=y):y=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("span",{children:"·"}),e[24]=L):L=e[24];let w;e[25]!==s.base?(w=i.jsx("span",{className:"font-mono text-xs",children:s.base}),e[25]=s.base,e[26]=w):w=e[26];let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx("span",{children:"←"}),e[27]=S):S=e[27];let j;e[28]!==s.head?(j=i.jsx("span",{className:"font-mono text-xs",children:s.head}),e[28]=s.head,e[29]=j):j=e[29];let C;e[30]!==w||e[31]!==j||e[32]!==b||e[33]!==y?(C=i.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 text-sm text-muted-foreground",children:[b,y,L,w,S,j]}),e[30]=w,e[31]=j,e[32]=b,e[33]=y,e[34]=C):C=e[34];let V;e[35]!==C||e[36]!==x?(V=i.jsx("div",{className:"shrink-0 space-y-3 pb-4",children:i.jsxs("div",{className:"space-y-1",children:[x,C]})}),e[35]=C,e[36]=x,e[37]=V):V=e[37];let N;e[38]===Symbol.for("react.memo_cache_sentinel")?(N=U=>p(U),e[38]=N):N=e[38];let T;e[39]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(gn,{value:"description",className:"px-3 text-xs",children:"Description"}),e[39]=T):T=e[39];const A=f!==void 0?` ${f}`:"";let E;e[40]!==A?(E=i.jsxs(gn,{value:"changes",className:"px-3 text-xs",children:["Changes",A]}),e[40]=A,e[41]=E):E=e[41];let R;e[42]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(gn,{value:"checks",className:"px-3 text-xs",children:"Checks"}),e[42]=R):R=e[42];let D;e[43]!==E?(D=i.jsxs(Zo,{className:"h-8 w-fit max-w-[600px] shrink-0",variant:"pill",children:[T,E,R]}),e[43]=E,e[44]=D):D=e[44];let P;e[45]!==o||e[46]!==a||e[47]!==s||e[48]!==l?(P=i.jsx(gi,{value:"description",className:"mt-0",children:i.jsx(SA,{pr:s,connectionId:o,owner:a,repo:l})}),e[45]=o,e[46]=a,e[47]=s,e[48]=l,e[49]=P):P=e[49];let I;e[50]!==h?(I=i.jsx(gi,{value:"changes",className:"mt-0",children:i.jsx(KN,{diffQuery:h})}),e[50]=h,e[51]=I):I=e[51];let O;e[52]!==o||e[53]!==a||e[54]!==s||e[55]!==l?(O=i.jsx(gi,{value:"checks",className:"mt-0",children:i.jsx(ZN,{pr:s,connectionId:o,owner:a,repo:l})}),e[52]=o,e[53]=a,e[54]=s,e[55]=l,e[56]=O):O=e[56];let B;e[57]!==P||e[58]!==I||e[59]!==O?(B=i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pt-5",children:[P,I,O]}),e[57]=P,e[58]=I,e[59]=O,e[60]=B):B=e[60];let z;e[61]!==m||e[62]!==D||e[63]!==B?(z=i.jsxs(wr,{value:m,onValueChange:N,className:"flex min-h-0 flex-1 flex-col",children:[D,B]}),e[61]=m,e[62]=D,e[63]=B,e[64]=z):z=e[64];let $;return e[65]!==V||e[66]!==z?($=i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[V,z]}),e[65]=V,e[66]=z,e[67]=$):$=e[67],$}function jA(t){const e=M.c(5),{pr:s}=t,n=`Open PR #${s.number} on GitHub`;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(Rn,{className:"h-4 w-4 text-muted-foreground"}),e[0]=r):r=e[0];let o;return e[1]!==s.htmlUrl||e[2]!==s.number||e[3]!==n?(o=i.jsx("div",{className:"flex h-12 items-center border-b border-border px-4 shrink-0",children:i.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noreferrer","aria-label":n,className:"inline-flex items-center gap-1.5 text-base font-medium text-foreground hover:underline",children:["PR #",s.number,r]})}),e[1]=s.htmlUrl,e[2]=s.number,e[3]=n,e[4]=o):o=e[4],o}function CA(t){const e=M.c(10),{virtualMcpId:s}=t,{org:n}=Ee(),r=fs(s),{currentBranch:o}=Qt(),a=r?.metadata?.githubRepo??null;if(!a?.connectionId){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"flex h-full items-center justify-center p-8 text-sm text-muted-foreground",children:"This virtualmcp is not linked to a GitHub repository."}),e[0]=c):c=e[0],c}if(!o){let c;return e[1]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-8 text-sm",children:[i.jsx(Qs,{className:"h-6 w-6 text-muted-foreground"}),i.jsx("div",{className:"text-muted-foreground",children:"No branch selected."}),i.jsx("div",{className:"text-xs text-muted-foreground",children:"Pick a branch from the header to see PR status."})]}),e[1]=c):c=e[1],c}let l;return e[2]!==o||e[3]!==a.connectionId||e[4]!==a.name||e[5]!==a.owner||e[6]!==n.id||e[7]!==n.slug||e[8]!==s?(l=i.jsx(kA,{orgId:n.id,orgSlug:n.slug,virtualMcpId:s,connectionId:a.connectionId,owner:a.owner,repo:a.name,branch:o}),e[2]=o,e[3]=a.connectionId,e[4]=a.name,e[5]=a.owner,e[6]=n.id,e[7]=n.slug,e[8]=s,e[9]=l):l=e[9],l}function kA(t){const e=M.c(47),{orgId:s,orgSlug:n,virtualMcpId:r,connectionId:o,owner:a,repo:l,branch:c}=t;let d;e[0]!==c||e[1]!==o||e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==l?(d={orgId:s,orgSlug:n,connectionId:o,owner:a,repo:l,branch:c},e[0]=c,e[1]=o,e[2]=s,e[3]=n,e[4]=a,e[5]=l,e[6]=d):d=e[6];const{data:h,isLoading:u,isError:f}=L9(d),m=VA;if(u){let b;return e[7]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading PR state…"}),e[7]=b):b=e[7],b}if(f){let b;return e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"p-4 text-sm text-destructive",children:"Couldn't load PR state. The GitHub connection may be broken."}),e[8]=b):b=e[8],b}const p=`https://github.com/${a}/${l}/tree/${c}`;if(h&&h.state==="closed"){let b;e[9]!==h?(b=i.jsx(jA,{pr:h}),e[9]=h,e[10]=b):b=e[10];const y=h.merged?"✓ Merged":"✗ Closed";let L;e[11]!==h.mergedAt?(L=h.mergedAt&&i.jsxs(i.Fragment,{children:[" · ",new Date(h.mergedAt).toLocaleDateString()]}),e[11]=h.mergedAt,e[12]=L):L=e[12];let w;e[13]!==h.author?(w=h.author&&i.jsxs(i.Fragment,{children:[" · by @",h.author]}),e[13]=h.author,e[14]=w):w=e[14];let S;e[15]!==h.base||e[16]!==y||e[17]!==L||e[18]!==w?(S=i.jsxs("div",{className:"text-sm text-success",children:[y," into ",h.base,L,w]}),e[15]=h.base,e[16]=y,e[17]=L,e[18]=w,e[19]=S):S=e[19];let j;e[20]!==h.title?(j=fr(h.title),e[20]=h.title,e[21]=j):j=e[21];let C;e[22]!==j?(C=i.jsx("h1",{className:"text-lg font-semibold",children:j}),e[22]=j,e[23]=C):C=e[23];let V;e[24]!==h.body||e[25]!==h.number?(V=h.body&&i.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-3 text-sm",children:i.jsx(l9,{id:`pr-body-${h.number}`,text:fr(h.body)})}),e[24]=h.body,e[25]=h.number,e[26]=V):V=e[26];let N;e[27]!==S||e[28]!==C||e[29]!==V?(N=i.jsxs("div",{className:"flex flex-col gap-4 p-4 overflow-auto",children:[S,C,V]}),e[27]=S,e[28]=C,e[29]=V,e[30]=N):N=e[30];let T;return e[31]!==b||e[32]!==N?(T=i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[b,N]}),e[31]=b,e[32]=N,e[33]=T):T=e[33],T}if(h&&h.state==="open"){let b;return e[34]!==c||e[35]!==o||e[36]!==a||e[37]!==h||e[38]!==l||e[39]!==r?(b=i.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:i.jsx("div",{className:"flex min-h-0 w-full flex-1 flex-col px-6 py-5",children:i.jsx(wA,{pr:h,virtualMcpId:r,branch:c,connectionId:o,owner:a,repo:l})})}),e[34]=c,e[35]=o,e[36]=a,e[37]=h,e[38]=l,e[39]=r,e[40]=b):b=e[40],b}let g;e[41]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx("div",{className:"rounded-md border border-border bg-muted/30 p-4 text-sm",children:`This branch doesn't have an open pull request. Click "Submit for review" in the header to open one; the agent will draft the title and summary from the current state of the branch.`}),e[41]=g):g=e[41];let x;e[42]!==p?(x=()=>m(p),e[42]=p,e[43]=x):x=e[43];let v;e[44]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx(Rn,{className:"mr-1.5 h-4 w-4"}),e[44]=v):v=e[44];let _;return e[45]!==x?(_=i.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[g,i.jsx("div",{className:"flex items-center gap-2",children:i.jsxs(re,{size:"sm",variant:"outline",onClick:x,children:[v,"Open branch on GitHub"]})})]}),e[45]=x,e[46]=_):_=e[46],_}function VA(t){window.open(t,"_blank","noopener,noreferrer")}const NA=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function AA(t){return t.includes("matchers")||t.includes("Match")}function og(t,e){const s=t.__resolveType;return typeof s!="string"||!s||NA.has(s)?!1:e?ES(e,s):AA(s)}function TA(t,e){const s=[];for(const[n,r]of Object.entries(e)){if(n.includes("/")||!bn(n)||ic(n)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;og(o,t)&&s.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((n,r)=>(n.name??n.blockKey).localeCompare(r.name??r.blockKey))}function Br(t,e,s){if(!t)return!1;const n=t.__resolveType;if(typeof n!="string"||!bn(n)||!Object.hasOwn(e,n))return!1;const r=e[n];return!r||typeof r!="object"||Array.isArray(r)?!1:og(r,s)}function EA(t,e,s){return Br(t,e,s)?t?.__resolveType??null:null}function ag(t,e,s){if(!t)return null;const n=t.__resolveType??"";if(!n)return null;if(Br(t,e,s)){const a=e[n]??{},l=a.__resolveType??n,{__resolveType:c,name:d,...h}=a;return{resolveType:l,data:h,blockKey:n}}const{__resolveType:r,...o}=t;return{resolveType:n,data:o}}function lg(t,e,s){const n=ag(t,e,s);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function QH(t,e,s){if(t)return Br(t,e,s)?lg(t,e,s):t}function RA(t,e,s,n){if(!t)return"Default";if(Br(t,e,n)){const r=t.__resolveType??"",o=e[r];return oc(r,o)}return s(t)}function ZH(t,e,s){return{__resolveType:t,...e,name:s}}function PA(t){return{__resolveType:t}}function eK(t,e,s){const n=ag(t,e,s);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}const lf="x-deco-matchers-override";function cg({pageKey:t,prefix:e,variants:s,selectedIndex:n,decofile:r,meta:o}){if(!t||n<0||n>=s.length)return[];const a=[];for(let l=0;l<=n;l++){const c=s[l];if(!c)continue;const d=c.rule,h=l===n?"1":"0",f=(Br(d,r,o)?EA(d,r,o):null)??`${t}@${e}.${l}.rule`;a.push(`${f}=${h}`)}return a}function tK(t,e,s,n){return!e.multivariate||e.variants.length<=1?[]:cg({pageKey:t,prefix:"sections.variants",variants:e.variants,selectedIndex:e.index,decofile:s,meta:n})}function sK({pageKey:t,page:e,sectionIndex:s,sectionLazy:n,mvObj:r,selectedVariantIndex:o,decofile:a,meta:l}){if(s<0)return[];const d=`${e.multivariate?`sections.variants.${e.index}.value`:"sections"}.${s}${n?".section":""}.variants`,h=Array.isArray(r.variants)?r.variants:[];return cg({pageKey:t,prefix:d,variants:h,selectedIndex:o,decofile:a,meta:l})}function IA(t,e){if(e.length===0)return t;const s=new URL(t,"http://local");s.searchParams.delete(lf);for(const n of e)s.searchParams.append(lf,n);return t.startsWith("http")?s.toString():`${s.pathname}${s.search}${s.hash}`}function dg(t){return btoa(encodeURIComponent(t))}function cf(t,e,s){const n=new URL(t).origin,r=new URL(`/live/previews/${encodeURIComponent(e)}`,n);return r.searchParams.set("path","/"),r.searchParams.set("pathTemplate","/"),r.searchParams.set("props",dg(JSON.stringify({path:"/",sections:[{__resolveType:s}]}))),r.searchParams.set("__cb",crypto.randomUUID()),r.toString()}function nK(t,e,s,n){const r=new URL(t).origin,o=new URL(`/live/previews/${encodeURIComponent(e)}`,r);o.searchParams.set("__d","");const a=[{__resolveType:"preview",block:s}];return n&&a.push(n),o.searchParams.set("props",dg(JSON.stringify({sections:a}))),o.toString()}const df={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function ou(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function ug(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:df.seoResolveType},__resolveType:df.resolveType}}const DA=700;function vc(t){const e=M.c(22),{orgSlug:s,virtualMcpId:n,branch:r}=t,o=bs(),a=fs(n)?.metadata?.runtime?.path??null;let l;e[0]!==r||e[1]!==s||e[2]!==a||e[3]!==n?(l=async f=>{const{blockKey:m,data:p}=f,g=Nr(a,Jm(m)),x=JSON.stringify(p,null,2),v=await fetch(`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:g,content:x})});if(!v.ok){const _=await v.json().catch(OA);throw new Error(_.error??`Write failed (${v.status})`)}return v.json()},e[0]=r,e[1]=s,e[2]=a,e[3]=n,e[4]=l):l=e[4];let c;e[5]!==r||e[6]!==s||e[7]!==o||e[8]!==n?(c=async f=>{const{blockKey:m,data:p}=f,g=`${s}/${n}/${r}`,x=it.decofile(g);await o.cancelQueries({queryKey:x});const v=o.getQueryData(x);return o.setQueryData(x,_=>({..._??{},[m]:p})),{previous:v,queryKey:x}},e[5]=r,e[6]=s,e[7]=o,e[8]=n,e[9]=c):c=e[9];let d;e[10]!==o?(d=(f,m,p)=>{p?.queryKey&&o.setQueryData(p.queryKey,p.previous)},e[10]=o,e[11]=d):d=e[11];let h;e[12]!==r||e[13]!==s||e[14]!==o||e[15]!==n?(h=(f,m)=>{const{blockKey:p,data:g}=m,x=`${s}/${n}/${r}`;o.setQueryData(it.decofile(x),v=>({...v??{},[p]:g}))},e[12]=r,e[13]=s,e[14]=o,e[15]=n,e[16]=h):h=e[16];let u;return e[17]!==l||e[18]!==c||e[19]!==d||e[20]!==h?(u={mutationFn:l,onMutate:c,onError:d,onSuccess:h},e[17]=l,e[18]=c,e[19]=d,e[20]=h,e[21]=u):u=e[21],Gs(u)}function OA(){return{}}function hg(t,e){const s=M.c(15),n=vc(t);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,s[0]=r):r=s[0];const o=k.useRef(r);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=k.useRef(a);let c;s[2]!==e||s[3]!==n?(c=v=>{const _=o.current.get(v);if(!_)return;const b=typeof _=="function"?_():_;o.current.delete(v),b&&n.mutate({blockKey:v,data:b},{onSuccess:()=>e?.onSaved?.(),onError:MA})},s[2]=e,s[3]=n,s[4]=c):c=s[4];const d=c;let h;s[5]!==d?(h=()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear();for(const v of[...o.current.keys()])d(v)},s[5]=d,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const v=l.current;return()=>{for(const _ of v.values())clearTimeout(_)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),k.useEffect(f,m);let p;s[9]!==d?(p=(v,_)=>{o.current.set(v,_);const b=l.current.get(v);b&&clearTimeout(b),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},DA))},s[9]=d,s[10]=p):p=s[10];const g=p;let x;return s[11]!==u||s[12]!==g||s[13]!==n.isPending?(x={save:g,flush:u,isPending:n.isPending},s[11]=u,s[12]=g,s[13]=n.isPending,s[14]=x):x=s[14],x}function MA(t){return de.error(`Save failed: ${t.message}`)}function $A(t){const e=M.c(5);let s;e[0]!==t?(s=t??{orgSlug:"",virtualMcpId:"",branch:""},e[0]=t,e[1]=s):s=e[1];const n=vc(s);let r;return e[2]!==t||e[3]!==n?(r={mutationFn:async o=>{const{name:a,path:l,template:c}=o;if(!t?.virtualMcpId||!t.branch)throw new Error("Sandbox not ready");const d=ou(a),h=c?{...c,name:a,path:l}:ug(a,l);return await n.mutateAsync({blockKey:d,data:h}),{key:d,name:a,path:l}}},e[2]=t,e[3]=n,e[4]=r):r=e[4],Gs(r)}const qn="__blank__";function fg(t){const e=M.c(44),{id:s,value:n,onChange:r,templates:o,disabled:a}=t,[l,c]=k.useState(!1);let d;if(e[0]!==o||e[1]!==n){let T;e[3]!==n?(T=A=>A.key===n,e[3]=n,e[4]=T):T=e[4],d=o.find(T),e[0]=o,e[1]=n,e[2]=d}else d=e[2];const h=d,u=h?.name??"Blank page";let f;e[5]!==u?(f=i.jsx("span",{className:"truncate",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==h?(m=h?.path?i.jsx("span",{className:"truncate text-muted-foreground",children:h.path}):null,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f,m]}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(g9,{className:"shrink-0 opacity-50"}),e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==p?(x=i.jsx(As,{asChild:!0,children:i.jsxs(re,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":l,disabled:a,className:"w-full justify-between font-normal",children:[p,g]})}),e[13]=a,e[14]=s,e[15]=l,e[16]=p,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v={width:"var(--radix-popover-trigger-width)"},e[18]=v):v=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(Ii,{placeholder:"Search pages…",className:"h-9"}),e[19]=_):_=e[19];let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Jn,{children:"No pages found."}),e[20]=b):b=e[20];let y;e[21]!==r?(y=()=>{r(qn),c(!1)},e[21]=r,e[22]=y):y=e[22];const L=n===qn?"opacity-100":"opacity-0";let w;e[23]!==L?(w=te("ml-auto",L),e[23]=L,e[24]=w):w=e[24];let S;e[25]!==w?(S=i.jsx(Ot,{className:w}),e[25]=w,e[26]=S):S=e[26];let j;e[27]!==y||e[28]!==S?(j=i.jsxs(Cs,{value:"Blank page",onSelect:y,children:["Blank page",S]}),e[27]=y,e[28]=S,e[29]=j):j=e[29];let C;if(e[30]!==r||e[31]!==o||e[32]!==n){let T;e[34]!==r||e[35]!==n?(T=A=>i.jsxs(Cs,{value:`${A.name} ${A.path}`,onSelect:()=>{r(A.key),c(!1)},children:[i.jsxs("div",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{className:"truncate",children:A.name}),i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:A.path})]}),i.jsx(Ot,{className:te("ml-auto",n===A.key?"opacity-100":"opacity-0")})]},A.key),e[34]=r,e[35]=n,e[36]=T):T=e[36],C=o.map(T),e[30]=r,e[31]=o,e[32]=n,e[33]=C}else C=e[33];let V;e[37]!==j||e[38]!==C?(V=i.jsx(Ts,{className:"p-0",style:v,children:i.jsxs(Cr,{children:[_,i.jsxs(Di,{onWheel:BA,children:[b,i.jsxs(Is,{children:[j,C]})]})]})}),e[37]=j,e[38]=C,e[39]=V):V=e[39];let N;return e[40]!==l||e[41]!==V||e[42]!==x?(N=i.jsxs(Ns,{open:l,onOpenChange:c,children:[x,V]}),e[40]=l,e[41]=V,e[42]=x,e[43]=N):N=e[43],N}function BA(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}function zA(t){const e=M.c(58),{open:s,onOpenChange:n,isPending:r,error:o,templates:a,onSubmit:l}=t,c=r===void 0?!1:r,[d,h]=k.useState("My New Page"),[u,f]=k.useState("/example-path"),[m,p]=k.useState(qn),[g,x]=k.useState(null),[v,_]=k.useState(s);s!==v&&(_(s),s&&(h("My New Page"),f("/example-path"),p(qn),x(null)));const b=!!a?.length;let y;e[0]!==c||e[1]!==n?(y=Z=>{!Z&&!c&&(x(null),n(!1))},e[0]=c,e[1]=n,e[2]=y):y=e[2];const L=y;let w;e[3]!==c||e[4]!==d||e[5]!==l||e[6]!==u||e[7]!==b||e[8]!==m?(w=async Z=>{Z.preventDefault();const K=d.trim(),Y=u.trim();if(!K||!Y||c)return;const F=E9(Y);if(F){x(F);return}x(null),await l({name:K,path:Y,templateKey:b&&m!==qn?m:null})},e[3]=c,e[4]=d,e[5]=l,e[6]=u,e[7]=b,e[8]=m,e[9]=w):w=e[9];const S=w,j=g??o;let C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(us,{children:i.jsx(hs,{children:"Create new page"})}),e[10]=C):C=e[10];let V;e[11]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx("label",{htmlFor:"new-page-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[11]=V):V=e[11];let N;e[12]===Symbol.for("react.memo_cache_sentinel")?(N=Z=>h(Z.target.value),e[12]=N):N=e[12];let T;e[13]!==c||e[14]!==d?(T=i.jsxs("div",{className:"space-y-1.5",children:[V,i.jsx(tt,{id:"new-page-name",value:d,onChange:N,placeholder:"My New Page",autoFocus:!0,disabled:c})]}),e[13]=c,e[14]=d,e[15]=T):T=e[15];let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx("label",{htmlFor:"new-page-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[16]=A):A=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=Z=>f(Z.target.value),e[17]=E):E=e[17];let R;e[18]!==c||e[19]!==u?(R=i.jsxs("div",{className:"space-y-1.5",children:[A,i.jsx(tt,{id:"new-page-path",value:u,onChange:E,placeholder:"/example-path",disabled:c})]}),e[18]=c,e[19]=u,e[20]=R):R=e[20];let D;e[21]!==c||e[22]!==b||e[23]!==m||e[24]!==a?(D=b&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"new-page-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),i.jsx(fg,{id:"new-page-template",value:m,onChange:p,templates:a??[],disabled:c})]}),e[21]=c,e[22]=b,e[23]=m,e[24]=a,e[25]=D):D=e[25];let P;e[26]!==j?(P=j&&i.jsx("p",{className:"text-xs text-destructive",children:j}),e[26]=j,e[27]=P):P=e[27];let I;e[28]!==R||e[29]!==D||e[30]!==P||e[31]!==T?(I=i.jsxs("div",{className:"space-y-4 py-4",children:[T,R,D,P]}),e[28]=R,e[29]=D,e[30]=P,e[31]=T,e[32]=I):I=e[32];let O;e[33]!==n?(O=()=>n(!1),e[33]=n,e[34]=O):O=e[34];let B;e[35]!==c||e[36]!==O?(B=i.jsx(re,{type:"button",variant:"outline",onClick:O,disabled:c,children:"Cancel"}),e[35]=c,e[36]=O,e[37]=B):B=e[37];let z;e[38]!==c||e[39]!==d||e[40]!==u?(z=!d.trim()||!u.trim()||c,e[38]=c,e[39]=d,e[40]=u,e[41]=z):z=e[41];let $;e[42]!==c?($=c?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{size:14,className:"animate-spin"}),"Creating…"]}):"Create",e[42]=c,e[43]=$):$=e[43];let U;e[44]!==z||e[45]!==$?(U=i.jsx(re,{type:"submit",disabled:z,children:$}),e[44]=z,e[45]=$,e[46]=U):U=e[46];let W;e[47]!==B||e[48]!==U?(W=i.jsxs(Ei,{children:[B,U]}),e[47]=B,e[48]=U,e[49]=W):W=e[49];let X;e[50]!==S||e[51]!==I||e[52]!==W?(X=i.jsx(Zt,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:S,children:[C,I,W]})}),e[50]=S,e[51]=I,e[52]=W,e[53]=X):X=e[53];let H;return e[54]!==L||e[55]!==s||e[56]!==X?(H=i.jsx(es,{open:s,onOpenChange:L,children:X}),e[54]=L,e[55]=s,e[56]=X,e[57]=H):H=e[57],H}const FA=en({tag:ns(),id:ns(),classes:ns(),text:ns(),html:ns(),manifestKey:ns().nullable(),componentName:ns().nullable(),parents:ns(),url:ns(),path:ns(),viewport:en({width:io(),height:io()}),position:en({x:io(),y:io()})}),UA=`(function() {
44
+ if (window.__visualEditorActive) return;
45
+ window.__visualEditorActive = true;
46
+
47
+ var cursorStyle = document.createElement("style");
48
+ cursorStyle.textContent = "* { cursor: default !important; }";
49
+ document.head.appendChild(cursorStyle);
50
+
51
+ var highlight = document.createElement("div");
52
+ highlight.style.cssText = "position:fixed;pointer-events:none;outline:2px solid #a855f7;background:rgba(168,85,247,0.08);border-radius:2px;z-index:2147483647;display:none;";
53
+ document.body.appendChild(highlight);
54
+
55
+ var badge = document.createElement("div");
56
+ badge.style.cssText = "position:fixed;pointer-events:none;background:#a855f7;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
57
+ document.body.appendChild(badge);
58
+
59
+ var lastTarget = null;
60
+ var rafPending = false;
61
+ var moveHandler = function(e) {
62
+ if (rafPending) return;
63
+ rafPending = true;
64
+ var target = e.target;
65
+ requestAnimationFrame(function() {
66
+ rafPending = false;
67
+ var el = target;
68
+ if (!el || el === highlight || el === badge) return;
69
+ if (el === lastTarget) return;
70
+ lastTarget = el;
71
+ var r = el.getBoundingClientRect();
72
+ highlight.style.display = "block";
73
+ highlight.style.top = r.top + "px";
74
+ highlight.style.left = r.left + "px";
75
+ highlight.style.width = r.width + "px";
76
+ highlight.style.height = r.height + "px";
77
+ var tag = el.tagName.toLowerCase();
78
+ var id = el.id ? "#" + el.id : "";
79
+ var cls = el.className && typeof el.className === "string"
80
+ ? "." + el.className.trim().split(/\\s+/).slice(0, 2).join(".")
81
+ : "";
82
+ badge.textContent = tag + id + cls;
83
+ badge.style.display = "block";
84
+ badge.style.top = Math.max(0, r.top - 20) + "px";
85
+ badge.style.left = r.left + "px";
86
+ });
87
+ };
88
+ document.addEventListener("mousemove", moveHandler, true);
89
+
90
+ var outHandler = function(e) {
91
+ if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
92
+ highlight.style.display = "none";
93
+ badge.style.display = "none";
94
+ lastTarget = null;
95
+ }
96
+ };
97
+ document.addEventListener("mouseout", outHandler, true);
98
+
99
+ var clickHandler = function(e) {
100
+ e.preventDefault();
101
+ e.stopImmediatePropagation();
102
+ var el = e.target;
103
+ if (!el || el === highlight || el === badge) return;
104
+
105
+ highlight.style.outline = "2px solid #a855f7";
106
+ highlight.style.background = "rgba(168,85,247,0.15)";
107
+ setTimeout(function() {
108
+ highlight.style.outline = "2px solid #a855f7";
109
+ highlight.style.background = "rgba(168,85,247,0.08)";
110
+ }, 400);
111
+
112
+ var tag = el.tagName.toLowerCase();
113
+ var id = el.id || "";
114
+ var classes = el.className && typeof el.className === "string" ? el.className.trim() : "";
115
+ var text = (el.textContent || "").trim().slice(0, 200);
116
+ var html = (el.outerHTML || "").slice(0, 800).replace(/\\svalue=("[^"]*"|'[^']*'|\\S+)/gi, "");
117
+
118
+ var closestSection = el.closest("section[data-manifest-key]");
119
+ var manifestKey = closestSection ? closestSection.getAttribute("data-manifest-key") : null;
120
+
121
+ var ancestor = el;
122
+ var componentName = null;
123
+ for (var i = 0; i < 10 && ancestor; i++) {
124
+ if (ancestor.dataset) componentName = ancestor.dataset.componentName || componentName;
125
+ ancestor = ancestor.parentElement;
126
+ }
127
+
128
+ var parents = [];
129
+ var p = el.parentElement;
130
+ for (var j = 0; j < 4 && p && p !== document.body; j++) {
131
+ var pTag = p.tagName ? p.tagName.toLowerCase() : "";
132
+ var pId = p.id ? "#" + p.id : "";
133
+ var pCls = p.className && typeof p.className === "string"
134
+ ? "." + p.className.trim().split(/\\s+/)[0]
135
+ : "";
136
+ parents.unshift(pTag + pId + pCls);
137
+ p = p.parentElement;
138
+ }
139
+
140
+ window.parent.postMessage({
141
+ type: "visual-editor::element-clicked",
142
+ payload: {
143
+ tag: tag, id: id, classes: classes, text: text, html: html,
144
+ manifestKey: manifestKey, componentName: componentName,
145
+ parents: parents.join(" > "),
146
+ url: window.location.href, path: window.location.pathname,
147
+ viewport: { width: window.innerWidth, height: window.innerHeight },
148
+ position: { x: Math.round(e.clientX), y: Math.round(e.clientY) }
149
+ }
150
+ }, "*");
151
+ };
152
+ document.addEventListener("click", clickHandler, true);
153
+
154
+ window.addEventListener("message", function(e) {
155
+ if (e.data && e.data.type === "visual-editor::deactivate") {
156
+ highlight.remove();
157
+ badge.remove();
158
+ cursorStyle.remove();
159
+ document.removeEventListener("mousemove", moveHandler, true);
160
+ document.removeEventListener("mouseout", outHandler, true);
161
+ document.removeEventListener("click", clickHandler, true);
162
+ window.__visualEditorActive = false;
163
+ }
164
+ });
165
+ })();`,HA=en({sectionIndex:io(),manifestKey:ns()}),KA=`(function() {
166
+ if (window.__cmsEditorActive) return;
167
+ window.__cmsEditorActive = true;
168
+
169
+ // Preserve scroll across variant-override navigations and save-reloads.
170
+ // Selecting a variant rebuilds the iframe src (new x-deco-matchers-override)
171
+ // or reloads it, which would otherwise jump to the top. We persist the scroll
172
+ // offset to sessionStorage (survives reload, same-origin) keyed by pathname
173
+ // (the override only changes the query, so the key is stable), then restore it
174
+ // on the next load — retried for ~1s so it outlasts re-hydration and lazy
175
+ // sections that grow the page after load. The recency guard avoids restoring a
176
+ // stale offset on a genuinely fresh visit.
177
+ var SCROLL_KEY = "__cms_preview_scroll:" + location.pathname;
178
+ var saveScroll = function() {
179
+ try {
180
+ sessionStorage.setItem(SCROLL_KEY, JSON.stringify({
181
+ x: window.scrollX, y: window.scrollY, t: Date.now()
182
+ }));
183
+ } catch (_) {}
184
+ };
185
+ var saveScrollPending = false;
186
+ window.addEventListener("scroll", function() {
187
+ if (saveScrollPending) return;
188
+ saveScrollPending = true;
189
+ requestAnimationFrame(function() { saveScrollPending = false; saveScroll(); });
190
+ }, { passive: true });
191
+ (function restoreScroll() {
192
+ var raw = null;
193
+ try { raw = sessionStorage.getItem(SCROLL_KEY); } catch (_) {}
194
+ if (!raw) return;
195
+ var saved = null;
196
+ try { saved = JSON.parse(raw); } catch (_) { return; }
197
+ if (!saved || (Date.now() - saved.t) > 10000) return;
198
+ if (!saved.x && !saved.y) return;
199
+ var attempts = 0;
200
+ var apply = function() {
201
+ attempts++;
202
+ window.scrollTo(saved.x || 0, saved.y || 0);
203
+ if (attempts < 8) setTimeout(apply, 120);
204
+ };
205
+ apply();
206
+ })();
207
+
208
+ var highlight = document.createElement("div");
209
+ highlight.style.cssText = "position:absolute;pointer-events:none;outline:2px solid #06b6d4;background:rgba(6,182,212,0.06);border-radius:2px;z-index:2147483647;display:none;";
210
+ document.body.appendChild(highlight);
211
+
212
+ var badge = document.createElement("div");
213
+ badge.style.cssText = "position:absolute;pointer-events:none;background:#06b6d4;color:white;font:11px/1 monospace;padding:2px 6px;border-radius:2px;z-index:2147483647;display:none;white-space:nowrap;max-width:240px;overflow:hidden;text-overflow:ellipsis;";
214
+ document.body.appendChild(badge);
215
+
216
+ var isTopLevelSection = function(el) {
217
+ return el && el.parentElement
218
+ ? !el.parentElement.closest("section[data-manifest-key]")
219
+ : true;
220
+ };
221
+
222
+ // All top-level page sections in DOM order (deco renders page sections as
223
+ // <section data-manifest-key>; nested islands/sections carry the attribute
224
+ // too, hence the top-level filter). This is the full DOM run, framework
225
+ // sections included — getAllSections() narrows it to the editable window.
226
+ var topLevelSections = function() {
227
+ return Array.from(document.querySelectorAll("section[data-manifest-key]"))
228
+ .filter(isTopLevelSection);
229
+ };
230
+
231
+ // Candidate manifest keys per editable section, sent by the editor. Each
232
+ // entry is an array of acceptable DOM keys: [] = wildcard (e.g. multivariate,
233
+ // whose rendered key we can't predict); null = renders NOTHING (hidden
234
+ // section — multivariate whose variants are all gated by never), so the
235
+ // alignment must not consume a DOM node for it; a Lazy lists both its loader
236
+ // key and the inner section's key, since the classic runtime keeps the Lazy
237
+ // wrapper at top level while TanStack renders the inner section directly.
238
+ var sectionCandidates = [];
239
+
240
+ // Best in-order assignment of editable sections to DOM sections, maximizing
241
+ // key matches (DP / LCS-style). deco injects framework sections (SEO, Theme,
242
+ // Session, …) that may lead, trail, OR interleave with the editable run; this
243
+ // skips whichever don't match, on any runtime — no hardcoded list. Hidden
244
+ // sections (null candidates) have no DOM node: only visible entries are
245
+ // aligned, then scattered back to their decofile positions (null-filled), so
246
+ // returned indexes still match the decofile array.
247
+ var computeAlignment = function(tops) {
248
+ var visible = [], k;
249
+ for (k = 0; k < sectionCandidates.length; k++) {
250
+ if (sectionCandidates[k] !== null) visible.push(k);
251
+ }
252
+ var N = visible.length, M = tops.length;
253
+ var res = new Array(sectionCandidates.length).fill(null);
254
+ if (!N) return res;
255
+ if (M < N) return tops.slice();
256
+ var domKeys = tops.map(function(s) { return s.getAttribute("data-manifest-key"); });
257
+ var match = function(i, j) {
258
+ var c = sectionCandidates[visible[i]];
259
+ if (!c || !c.length) return 1;
260
+ return c.indexOf(domKeys[j]) >= 0 ? 1 : 0;
261
+ };
262
+ var dp = [], bt = [], i, j;
263
+ for (i = 0; i <= N; i++) { dp.push(new Array(M + 1).fill(0)); bt.push(new Array(M + 1).fill(0)); }
264
+ for (i = 1; i <= N; i++) {
265
+ for (j = i; j <= M; j++) {
266
+ var assign = dp[i - 1][j - 1] + match(i - 1, j - 1);
267
+ var skip = dp[i][j - 1];
268
+ if (j - 1 >= i && skip >= assign) { dp[i][j] = skip; bt[i][j] = 0; }
269
+ else { dp[i][j] = assign; bt[i][j] = 1; }
270
+ }
271
+ }
272
+ i = N; j = M;
273
+ while (i > 0) {
274
+ if (bt[i][j] === 1) { res[visible[i - 1]] = tops[j - 1]; i--; j--; }
275
+ else { j--; }
276
+ }
277
+ return res;
278
+ };
279
+
280
+ // Editable sections, indexed to match the decofile array the panel uses.
281
+ // Recomputed from the live DOM each call (cheap, rAF-throttled) so it
282
+ // self-heals as client-rendered/lazy sections mount. Until the editor sends
283
+ // candidates, fall back to the full top-level run.
284
+ var getAllSections = function() {
285
+ var tops = topLevelSections();
286
+ return sectionCandidates.length ? computeAlignment(tops) : tops;
287
+ };
288
+
289
+ // Resolve to the OUTERMOST page-level section (clicking nested content still
290
+ // maps to the top-level section the panel indexes); null if it isn't in the
291
+ // aligned editable set (a framework section deco injected).
292
+ var findSection = function(el) {
293
+ var node = el;
294
+ var found = null;
295
+ while (node && node !== document.body) {
296
+ if (node.tagName === "SECTION" && node.hasAttribute && node.hasAttribute("data-manifest-key")) {
297
+ found = node;
298
+ }
299
+ node = node.parentElement;
300
+ }
301
+ if (!found) return null;
302
+ return getAllSections().indexOf(found) >= 0 ? found : null;
303
+ };
304
+
305
+ // Lazy sections async-render their real section inside a wrapper, so the
306
+ // wrapper's key is just the loader. Show the inner section's key instead
307
+ // (falling back to the wrapper while the content hasn't loaded yet).
308
+ var LAZY_KEY = "website/sections/Rendering/Lazy.tsx";
309
+ var displayKey = function(section) {
310
+ var key = section.getAttribute("data-manifest-key") || "section";
311
+ if (key === LAZY_KEY) {
312
+ var inner = section.querySelector("section[data-manifest-key]");
313
+ if (inner) return inner.getAttribute("data-manifest-key") || key;
314
+ }
315
+ return key;
316
+ };
317
+
318
+ // Per-section metadata sent by the editor, aligned by index with
319
+ // getAllSections(). labels: names the DOM can't carry (a global section or a
320
+ // global inside async rendering); kinds: section type that drives the color.
321
+ var sectionLabels = [];
322
+ var sectionKinds = [];
323
+ var labelFor = function(section) {
324
+ var idx = getAllSections().indexOf(section);
325
+ if (idx >= 0 && sectionLabels[idx]) return sectionLabels[idx];
326
+ return displayKey(section);
327
+ };
328
+ var kindFor = function(section) {
329
+ var idx = getAllSections().indexOf(section);
330
+ return (idx >= 0 && sectionKinds[idx]) || "normal";
331
+ };
332
+
333
+ // Highlight palette by section kind: global = light purple, variant = green,
334
+ // normal = blue.
335
+ var COLORS = {
336
+ normal: { solid: "#06b6d4", bg: "rgba(6,182,212,0.06)", active: "rgba(6,182,212,0.18)" },
337
+ global: { solid: "#c084fc", bg: "rgba(192,132,252,0.10)", active: "rgba(192,132,252,0.22)" },
338
+ variant: { solid: "#22c55e", bg: "rgba(34,197,94,0.08)", active: "rgba(34,197,94,0.20)" }
339
+ };
340
+ var applyColor = function(kind) {
341
+ var c = COLORS[kind] || COLORS.normal;
342
+ highlight.style.outline = "2px solid " + c.solid;
343
+ highlight.style.background = c.bg;
344
+ badge.style.background = c.solid;
345
+ };
346
+
347
+ var lastSection = null;
348
+ var lastLabel = "";
349
+ var lastKind = "normal";
350
+ var rafPending = false;
351
+
352
+ // Document-relative coordinates (rect + scroll) on absolutely-positioned
353
+ // nodes, so the browser scrolls the highlight together with the page
354
+ // natively — no per-frame JS repositioning, no scroll lag.
355
+ var positionHighlight = function(section) {
356
+ var r = section.getBoundingClientRect();
357
+ var top = r.top + window.scrollY;
358
+ var left = r.left + window.scrollX;
359
+ highlight.style.display = "block";
360
+ highlight.style.top = top + "px";
361
+ highlight.style.left = left + "px";
362
+ highlight.style.width = r.width + "px";
363
+ highlight.style.height = r.height + "px";
364
+ badge.textContent = lastLabel || displayKey(section);
365
+ badge.style.display = "block";
366
+ badge.style.top = Math.max(0, top - 20) + "px";
367
+ badge.style.left = left + "px";
368
+ };
369
+
370
+ var moveHandler = function(e) {
371
+ if (rafPending) return;
372
+ rafPending = true;
373
+ var target = e.target;
374
+ requestAnimationFrame(function() {
375
+ rafPending = false;
376
+ if (!target || target === highlight || target === badge) return;
377
+ var section = findSection(target);
378
+ if (section === lastSection) return;
379
+ lastSection = section;
380
+ if (!section) {
381
+ highlight.style.display = "none";
382
+ badge.style.display = "none";
383
+ return;
384
+ }
385
+ lastLabel = labelFor(section);
386
+ lastKind = kindFor(section);
387
+ applyColor(lastKind);
388
+ positionHighlight(section);
389
+ });
390
+ };
391
+ document.addEventListener("mousemove", moveHandler, true);
392
+
393
+ // Window scroll is handled natively by the absolute positioning above; this
394
+ // only re-syncs on resize and on scrolls inside nested scroll containers
395
+ // (capture=true catches those), where document coordinates do shift.
396
+ var reposition = function() {
397
+ if (!lastSection || highlight.style.display === "none") return;
398
+ if (rafPending) return;
399
+ rafPending = true;
400
+ requestAnimationFrame(function() {
401
+ rafPending = false;
402
+ if (lastSection && highlight.style.display !== "none") positionHighlight(lastSection);
403
+ });
404
+ };
405
+ window.addEventListener("scroll", reposition, { capture: true, passive: true });
406
+ window.addEventListener("resize", reposition, { passive: true });
407
+
408
+ var outHandler = function(e) {
409
+ if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
410
+ highlight.style.display = "none";
411
+ badge.style.display = "none";
412
+ lastSection = null;
413
+ }
414
+ };
415
+ document.addEventListener("mouseout", outHandler, true);
416
+
417
+ var clickHandler = function(e) {
418
+ e.preventDefault();
419
+ e.stopImmediatePropagation();
420
+ var target = e.target;
421
+ if (!target || target === highlight || target === badge) return;
422
+ var section = findSection(target);
423
+ if (!section) return;
424
+
425
+ var sections = getAllSections();
426
+ var sectionIndex = sections.indexOf(section);
427
+ var manifestKey = section.getAttribute("data-manifest-key") || "";
428
+
429
+ var c = COLORS[lastKind] || COLORS.normal;
430
+ highlight.style.outline = "2px solid " + c.solid;
431
+ highlight.style.background = c.active;
432
+ setTimeout(function() {
433
+ highlight.style.background = c.bg;
434
+ }, 400);
435
+
436
+ window.parent.postMessage({
437
+ type: "cms-editor::section-clicked",
438
+ payload: { sectionIndex: sectionIndex, manifestKey: manifestKey }
439
+ }, "*");
440
+ };
441
+ document.addEventListener("click", clickHandler, true);
442
+
443
+ window.addEventListener("message", function(e) {
444
+ if (e.data && e.data.type === "cms-editor::set-labels" && Array.isArray(e.data.labels)) {
445
+ sectionLabels = e.data.labels;
446
+ if (Array.isArray(e.data.kinds)) sectionKinds = e.data.kinds;
447
+ if (Array.isArray(e.data.keys)) sectionCandidates = e.data.keys;
448
+ if (lastSection) {
449
+ lastLabel = labelFor(lastSection);
450
+ lastKind = kindFor(lastSection);
451
+ applyColor(lastKind);
452
+ if (highlight.style.display !== "none") positionHighlight(lastSection);
453
+ }
454
+ return;
455
+ }
456
+ if (e.data && e.data.type === "cms-editor::deactivate") {
457
+ highlight.remove();
458
+ badge.remove();
459
+ document.removeEventListener("mousemove", moveHandler, true);
460
+ document.removeEventListener("mouseout", outHandler, true);
461
+ document.removeEventListener("click", clickHandler, true);
462
+ window.removeEventListener("scroll", reposition, { capture: true });
463
+ window.removeEventListener("resize", reposition);
464
+ window.__cmsEditorActive = false;
465
+ }
466
+ });
467
+ })();`;function mg(t,e){return t.map((s,n)=>{const r=s.__resolveType??"",o=ds(r);if(!o&&r!==""&&bn(r)&&r in e){const d=e[r],h=typeof d?.name=="string"&&d.name||r.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:r,label:h,isLazy:!1,isSavedBlock:!0}}const a=o?s.section:void 0,l=o?a?.__resolveType??"":r;if(l===Mi||l===Tr){const d=o?a:s,h=Array.isArray(d?.variants)?d.variants:[];if(h.length===1&&(h[0]?.rule?.__resolveType??"")===Ar){const m=h[0]?.value??{};let p=m.__resolveType??"";const g=ds(p);return g&&(p=m.section?.__resolveType??p),{index:n,resolveType:r,label:Ct(p)||`Section ${n+1}`,isHidden:!0,isLazy:g}}const u=h[0]?.value?.__resolveType,f=u?Ct(u):"Section";return{index:n,resolveType:r,label:`Variants of ${f}`,isMultivariate:!0,isLazy:o}}const c=o?s.section?.__resolveType??r:r;if(o&&c!==""&&bn(c)&&c in e){const d=e[c],h=typeof d?.name=="string"&&d.name||c.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())||`Section ${n+1}`;return{index:n,resolveType:r,label:h,isLazy:!0,isSavedBlock:!0}}return{index:n,resolveType:r,label:Ct(c)||`Section ${n+1}`,isLazy:o}})}const WA="website/sections/Rendering/Lazy.tsx";function q0(t,e){let s=t,n=typeof s?.__resolveType=="string"?s.__resolveType:"";for(let r=0;n&&r<5;r++){const o=e[n];if(o&&typeof o=="object"&&"__resolveType"in o){const a=o.__resolveType;if(typeof a=="string"&&a&&a!==n){s=o,n=a;continue}}break}if(!n)return[];if(n.includes("flags/multivariate")){const r=Array.isArray(s.variants)?s.variants:[];if(r.length===0||r.every(l=>l?.rule?.__resolveType===Ar))return null;const a=[];for(const l of r){const c=l?.value;if(c&&typeof c=="object")for(const d of q0(c,e)??[])a.includes(d)||a.push(d)}return a}if(n===WA){const r=s.section&&typeof s.section=="object"?q0(s.section,e):[];return r===null?null:r.length?[n,...r]:[n]}return[n]}function pg(t){const e=t.__resolveType??"";return ds(e)?t.section??t:t}function Al(t){const r=(ds(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==Ar?null:r?.value??null}function iK(t){const e=pg(t);return{__resolveType:Tr,variants:[{value:e,rule:{__resolveType:Ar}}]}}function rK(t){const e=t.__resolveType??"";if(!e)return null;if(ds(e))return t.section??null;const s=Al(t);return s?ds(s.__resolveType??"")?s:{__resolveType:kh,section:pg(s)}:{__resolveType:kh,section:t}}function wa(t){const e=t.__resolveType??"";if(!e)return null;if(ds(e)){const s=t.section,n=s?.__resolveType??"";return!n||!s?null:{resolveType:n,data:s}}return{resolveType:e,data:t}}function oK(t){const e=Al(t);if(e)return wa(e);if(ds(t.__resolveType??"")){const n=t.section;if(!n)return null;const r=Al(n);return wa(r||n)}return wa(t)}function aK(t){return Al(t)}const qA=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function au(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:qA.includes(e)||e.includes("always")}function GA(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(n=>au(n.rule));return s!==-1?s:e.length-1}function lK(t,e,s){const n=s.variants??[];if(n.length===0)return null;const r=GA(s),o=n[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function gg(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function cK(t,e){return Array.isArray(t.variants)?t.variants.map((s,n)=>({label:e(s.rule)||`Variant ${n+1}`,value:s.value??{},rule:s.rule})):[]}function dK(t,e){const s=t.__resolveType??"";if(!s)return null;if(ds(s)){const n=t.section??t,r=n.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...n},resolveType:r}}if(!s.includes("/")&&s in e){const n=e[s]??{};return{data:{...n},resolveType:n.__resolveType??s}}return{data:{...t},resolveType:s}}function YA(t,e){const s=t.__resolveType??"";return ds(s)?{...t,section:e}:e}function JA(t,e,s){return e.isLazy?{...t,section:s}:s}function uK(t,e,s){const n=[...t.variants??[]],r=n[e];if(!r)return t;const o=r.value??{};return n[e]={...r,value:YA(o,s)},{...t,variants:n}}function hK(t,e,s){const n=[...t.variants??[]];return n[e]?(n[e]={...n[e],rule:s},{...t,variants:n}):t}function fK(t,e){const s=[...t.variants??[]],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function mK(t,e,s){const n=[...t.variants??[]];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[r]=n.splice(e,1);return r?(n.splice(s,0,r),{...t,variants:n}):t}function pK(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function G0(t){return{rule:mr(),value:structuredClone(t)}}function xg(t,e){return{...e,__resolveType:Tr,variants:t}}function gK(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function XA(t,e){if(e.isHidden)return null;if(e.isMultivariate){const n=gg(t,e)?.variants??[],r=n[n.length-1]?.value;return r?structuredClone(r):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function QA(t,e,s){if(e.isMultivariate||e.isHidden)return null;const n=XA(t,e);if(!n)return null;const r=xg([G0(n),G0(n)]);return e.isLazy?{...t,section:r}:r}function xK(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const r=gg(t,e);if(!r)return null;const o=r.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=xg([...o,G0(a)],r);return{section:JA(t,e,l),newVariantIndex:o.length}}const n=QA(t,e);return n?{section:n,newVariantIndex:1}:null}const ZA=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function bc(t){return t.anyOfRefs?.some(e=>e.resolveType!==Mi?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function eT(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return e.__resolveType===Tr&&Array.isArray(e.variants)}function Tl(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===Mi}function tT(t){if(!Tl(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function sT(t,e){if(!Tl(t))return e;const s=structuredClone(t),n=[...s.variants??[]];return n.length===0?n.push({rule:mr(),value:e}):n[0]={...n[0],value:e},{...s,variants:n}}function nT(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&ZA.has(e.__resolveType)&&typeof e.path=="string"}function vg(t,e){const n=t[e]?.sections;if(!n||Array.isArray(n))return 1;const r=n;return Array.isArray(r.variants)?r.variants.length:1}function bg(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function vK(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.variants)){const r=n.variants,o=r.map(c=>RA(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return r.map((c,d)=>{const h=o[d]??`Variant ${d+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${d+1}`,sections:Array.isArray(c.value)?c.value:[],rule:c.rule}})}}return[]}function Wr(t){return{rule:mr(),value:t}}function sr(t,e){return{...e,__resolveType:Mi,variants:t}}function iT(t,e){const s=structuredClone(e);if(Array.isArray(t))return sr([Wr(t),Wr(s)]);if(t&&typeof t=="object"){const n=t;return Array.isArray(n.variants)?sr([...n.variants,Wr(s)],n):null}return sr([Wr([]),Wr(s)])}function bK(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function _K(t,e){const s=t[e];if(!s)return null;const n=[...t];return n.splice(e+1,0,structuredClone(s)),n}function yK(t,e){if(e.length===0)return sr([],t);if(e.length===1){const s=e[0],n=s?.rule;if(!au(n))return sr(e,t);if(Array.isArray(s?.value))return s.value}return sr(e,t)}function rT(t,e){for(const[s,n]of Object.entries(t)){if(!nT(n))continue;const r=n.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function LK(t,e,s){let n=0;return rT(t,r=>{if(!r)return;(r.__resolveType??"")===e&&Br(r,t,s)&&n++}),n}function zi(t){return t.replace(/[`*_]/g,"\\$&")}function oT(t,e){const s=[`The user selected an element on the live preview and asked: **"${zi(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${zi(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const n=`<${t.tag}${t.classes?` class="${zi(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${zi(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${zi(t.text)}"`),t.componentName&&s.push(`**Component name:** ${zi(t.componentName)}`);const r=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",r,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
468
+ `)}function aT(t,e,s=320,n=44,r=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/c>.68?Math.max(r,a-n-18):Math.min(a+18,c-n-r);return{leftPct:d/l*100,topPct:u/c*100}}function lT(t){const e=M.c(32),{element:s,onDismiss:n}=t,[r,o]=k.useState(""),a=k.useRef(null),{sendMessage:l}=Ys(),{openSidePanel:c}=Jo();let d;e[0]!==s||e[1]!==r||e[2]!==n||e[3]!==c||e[4]!==l?(d=()=>{if(!r.trim())return;const V=oT(s,r);c("chat"),l({parts:[{type:"text",text:V}]}),n()},e[0]=s,e[1]=r,e[2]=n,e[3]=c,e[4]=l,e[5]=d):d=e[5];const h=d;let u;e[6]!==s.position||e[7]!==s.viewport?(u=aT(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let x;e[12]!==h?(x=V=>{V.preventDefault(),h()},e[12]=h,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=V=>o(V.target.value),e[14]=v):v=e[14];let _;e[15]!==n?(_=V=>{V.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let b;e[17]!==r||e[18]!==_?(b=i.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:_,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==r?(y=r.trim(),e[20]=r,e[21]=y):y=e[21];const L=!y;let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[i.jsx("title",{children:"Send"}),i.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=w):w=e[22];let S;e[23]!==L?(S=i.jsx("button",{type:"submit",disabled:L,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:w}),e[23]=L,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==x||e[27]!==b?(j=i.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:x,children:[b,S]}),e[25]=S,e[26]=x,e[27]=b,e[28]=j):j=e[28];let C;return e[29]!==j||e[30]!==g?(C=i.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:j}),e[29]=j,e[30]=g,e[31]=C):C=e[31],C}const _g={claiming:{long:"Reserving sandbox",short:"Reserving sandbox"},"waiting-for-capacity":{long:"Waiting for cluster capacity",short:"Waiting for capacity"},"pulling-image":{long:"Downloading sandbox image",short:"Downloading image"},"starting-container":{long:"Starting your sandbox",short:"Starting container"},"warming-daemon":{long:"Connecting to your sandbox",short:"Connecting to sandbox"}},cT=["provision","cloning","install","dev"];function yg(t){switch(t.lifecycle.phase){case"cloning":case"checking-out":return{step:"cloning",status:"doing"};case"clone-failed":return{step:"cloning",status:"failed"};case"installing":return{step:"install",status:"doing"};case"install-failed":return{step:"install",status:"failed"};case"starting":return{step:"dev",status:"doing"};case"running":return{step:"dev",status:"done"};case"start-failed":return{step:"dev",status:"failed"};case"crashed":return{step:"dev",status:"failed"};case"idle":return t.claimPhase&&t.claimPhase.kind!=="ready"&&t.claimPhase.kind!=="failed"?{step:"provision",status:"doing"}:{step:"cloning",status:"doing"}}}function uf(t){switch(t){case"starting":return"Starting your sandbox";case"suspended":return"Sandbox is paused";case"errored":return"Couldn't start the sandbox"}}function dT(t){return cT.indexOf(t.step)}const hf=48,Lg=28,Sg=3,uT=(()=>{const t=[];let e=0;for(let s=0;s<hf;s++)s===Lg?t.push(null):(t.push(e/(hf-1)*Sg),e++);return t})(),hT={provision:"Reserving sandbox",cloning:"Cloning your repo",install:"Installing packages",dev:"Starting your preview"};function fT(t,e){return t.step==="provision"&&e!=null&&e.kind!=="ready"&&e.kind!=="failed"?_g[e.kind].long:hT[t.step]}const hn="bg-foreground/[0.05]",Ks="bg-foreground/[0.09]",mT=Array.from({length:35},()=>Math.random()*1.8),pT=Array.from({length:35},()=>Math.random()<.4);function gT(t){const e=M.c(30),{progress:s,claimPhase:n}=t;let r;e[0]!==s?(r=dT(s),e[0]=s,e[1]=r):r=e[1];const o=r;let a;e[2]!==n||e[3]!==s?(a=fT(s,n),e[2]=n,e[3]=s,e[4]=a):a=e[4];const l=a;let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Nx,{}),e[5]=c):c=e[5];const d=`${s.step}-${l}`;let h;e[6]!==l||e[7]!==d?(h=i.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-foreground/10 bg-background px-3.5 py-1.5 shadow-[0_4px_20px_-4px_rgb(0_0_0_/_0.12)]",children:[c,i.jsxs("span",{className:"animate-in fade-in text-[13px] font-medium text-foreground/85 duration-500",children:[l,"…"]},d)]}),e[6]=l,e[7]=d,e[8]=h):h=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(xT,{}),e[9]=u):u=e[9];let f;e[10]!==o?(f=i.jsx(ja,{phase:0,current:o,children:u}),e[10]=o,e[11]=f):f=e[11];let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(bT,{}),e[12]=m):m=e[12];let p;e[13]!==o?(p=i.jsx(ja,{phase:1,current:o,children:m}),e[13]=o,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(_T,{}),e[15]=g):g=e[15];let x;e[16]!==o?(x=i.jsx(ja,{phase:2,current:o,children:g}),e[16]=o,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx(LT,{}),e[18]=v):v=e[18];let _;e[19]!==o?(_=i.jsx(ja,{phase:3,current:o,children:v}),e[19]=o,e[20]=_):_=e[20];let b;e[21]!==x||e[22]!==_||e[23]!==f||e[24]!==p?(b=i.jsxs("div",{className:"relative aspect-[4/3] w-[min(78%,560px)]",children:[f,p,x,_]}),e[21]=x,e[22]=_,e[23]=f,e[24]=p,e[25]=b):b=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("style",{children:`
469
+ @keyframes vm-pulse-soft {
470
+ 0%, 100% { opacity: 0.25; }
471
+ 50% { opacity: 1; }
472
+ }
473
+ @keyframes vm-breathe {
474
+ 0%, 100% { opacity: 0.5; }
475
+ 50% { opacity: 1; }
476
+ }
477
+ @keyframes vm-rack-scan {
478
+ 0%, 100% { opacity: 0; }
479
+ 8% { opacity: 1; }
480
+ 22% { opacity: 0; }
481
+ }
482
+ `}),e[26]=y):y=e[26];let L;return e[27]!==b||e[28]!==h?(L=i.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,b,y]}),e[27]=b,e[28]=h,e[29]=L):L=e[29],L}function ja(t){const e=M.c(10),{phase:s,current:n,children:r}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=te("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==x?(v=i.jsx("div",{"aria-hidden":f,className:m,style:x,children:r}),e[6]=r,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function _c(t){const e=M.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:te("size-2.5 rounded-full",Ks)}),o=i.jsx("div",{className:te("size-2.5 rounded-full",Ks)}),a=i.jsx("div",{className:te("size-2.5 rounded-full",Ks)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&i.jsx("div",{className:te("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",hn)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=i.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function xT(){const t=M.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(_c,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"flex flex-1 px-8 py-5",children:i.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:uT.map(vT)})})]}),t[1]=s):s=t[1],s}function vT(t,e){if(e===Lg)return i.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return i.jsx("div",{className:te("relative rounded-md",Ks),children:i.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${Sg}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function bT(){const t=M.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(_c,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:te("w-[18%] rounded-md",hn),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[i.jsx("div",{className:te("rounded-md",hn),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),i.jsx("div",{className:te("rounded-md",hn),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function _T(){const t=M.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(_c,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:i.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:mT.map(yT)})})]}),t[1]=s):s=t[1],s}function yT(t,e){return i.jsx("div",{className:te("aspect-square rounded-md",pT[e]?"bg-chart-2/70":Ks),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function LT(){const t=M.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(_c,{showUrl:!0}),t[0]=e):e=t[0];let s,n,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=i.jsx("div",{className:te("h-1.5 w-[70%] rounded-sm",Ks)}),r=i.jsx("div",{className:te("h-1.5 w-[55%] rounded-sm",Ks)}),o=i.jsx("div",{className:te("h-1.5 w-[80%] rounded-sm",Ks)}),a=i.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",Ks)}),t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a):(s=t[1],n=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,r,o,a,i.jsx("div",{className:"mt-auto",children:i.jsx("div",{className:te("h-4 rounded-md",Ks)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:i.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[i.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),i.jsx("div",{className:te("h-1.5 w-[55%] rounded-sm",hn)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[i.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),i.jsx("div",{className:te("h-4 w-10 rounded-full",hn)}),i.jsx("div",{className:te("h-4 w-14 rounded-full",hn)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs("div",{className:te("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",hn),children:[i.jsx("div",{className:te("h-1.5 w-[50%] rounded-sm",Ks)}),i.jsx("div",{className:te("h-1 w-[75%] rounded-sm",Ks)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[i.jsx("div",{className:te("rounded-md",hn)}),i.jsx("div",{className:te("rounded-md",hn)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function nr(t){const e=M.c(25);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsx(gT,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}if(t.kind==="errored"){const l=t.error.code===X2.githubNotAuthenticated;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(br,{className:"size-12 text-destructive"}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("h3",{className:"text-lg font-medium",children:uf("errored")}),e[4]=d):d=e[4];const h=l?"This agent's GitHub repo isn't authenticated. Reconnect it in Connections, then retry.":t.error.message;let u;e[5]!==h?(u=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==t.connectionsHref?(f=l&&t.connectionsHref&&i.jsx(re,{asChild:!0,children:i.jsx("a",{href:t.connectionsHref,children:"Reconnect GitHub"})}),e[7]=l,e[8]=t.connectionsHref,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(ir,{className:"size-4"}),e[10]=m):m=e[10];let p;e[11]!==t.onRetry?(p=i.jsxs(re,{variant:"outline",onClick:t.onRetry,children:[m," Retry"]}),e[11]=t.onRetry,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=i.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let x;return e[16]!==u||e[17]!==g?(x=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[c,d,u,g]})}),e[16]=u,e[17]=g,e[18]=x):x=e[18],x}let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Ov,{className:"size-12 text-blue-500"}),e[19]=s):s=e[19];let n,r;e[20]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("h3",{className:"text-lg font-medium",children:uf("suspended")}),r=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[20]=n,e[21]=r):(n=e[20],r=e[21]);let o;e[22]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(Si,{className:"size-4"}),e[22]=o):o=e[22];let a;return e[23]!==t.onResume?(a=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,n,r,i.jsxs(re,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[23]=t.onResume,e[24]=a):a=e[24],a}function wg(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function ST(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[r,o]of Object.entries(e.params))typeof o=="string"&&(n[r]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function jg(t){try{return ST(localStorage.getItem(t))}catch{return null}}function wT(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function El(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(r=>encodeURIComponent(r).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const jT=/details?page|\bpdp\b/i,CT=/listingpage|\bplp\b/i;function kT(t,e,s){const n=new Set;for(const l of s)jT.test(l)&&n.add("product"),CT.test(l)&&n.add("category");const r=_l(Wn(t)),o=r[r.length-1],a=r[r.length-2];return o?.type==="text"&&o.text==="/p"&&a?.type==="param"&&a.name===e&&n.add("product"),e==="*"&&r.some(l=>l.type==="param"&&l.name==="*")&&n.add("category"),n}function VT(t,e){const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:t,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:t,props:{query:o,count:10}}),n}const Cg=new Set(["vtex","shopify","shopify-mcp","magento","wake","linx","linx-impulse","nuvemshop","vnda","wap","salesforce"]);function lu(t){return t.split("/")[0]??""}function NT(t){const e=new Set;for(const s of t){const n=lu(s);Cg.has(n)&&e.add(n)}return e}function AT(t,e){const s=lu(t);return!Cg.has(s)||e.size===0?!0:e.has(s)}const TT=[{kind:"product",test:t=>t==="vtex/loaders/intelligentSearch/productList.ts",clientFilter:!1,buildRequests:VT,optionsFromPayload:Ca},{kind:"product",test:t=>/magento\/.*products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>[{resolveType:t,props:{props:{search:e.trim(),pageSize:10,currentPage:1}}}],optionsFromPayload:Ca},{kind:"product",test:t=>/algolia\/.*products?\/(list|suggestions)(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>[{resolveType:t,props:{term:e.trim(),hitsPerPage:10}}],optionsFromPayload:Ca},{kind:"product",test:t=>/products?\/list(\.tsx?)?$/i.test(t),clientFilter:!1,buildRequests:(t,e)=>[{resolveType:t,props:{query:e.trim(),term:e.trim(),count:10,hitsPerPage:10}}],optionsFromPayload:Ca},{kind:"category",test:t=>t==="vtex/loaders/categories/tree.ts"||/categor(y|ies).*tree/i.test(t),clientFilter:!0,buildRequests:t=>[{resolveType:t,props:{}}],optionsFromPayload:$T}];function ET(t,e,s=new Set){const n=[...e],r=[];for(const o of["product","category"]){if(!t.has(o))continue;const a=[];for(const h of TT){if(h.kind!==o)continue;const u=n.find(f=>h.test(f)&&AT(f,s));u&&a.push({cand:h,resolveType:u})}const l=a.find(h=>s.has(lu(h.resolveType)))??a[0];if(!l)continue;const{cand:c,resolveType:d}=l;r.push({kind:o,id:`${o}:${d}`,resolveType:d,clientFilter:c.clientFilter,buildRequests:h=>c.buildRequests(d,h),optionsFromPayload:c.optionsFromPayload})}return r}function fi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function RT(t,e,s){const n=new Set,r=new Set,o=a=>{if(Array.isArray(a)){for(const d of a)o(d);return}const l=fi(a);if(!l)return;const c=l.__resolveType;if(typeof c=="string"){if(s(c))n.add(c);else if(c in e&&!r.has(c)){r.add(c);const d=fi(e[c])?.__resolveType;typeof d=="string"&&s(d)&&n.add(c),o(e[c])}}for(const d of Object.values(l))o(d)};return o(t),n}function PT(t){const e=new Set,s=[];for(const n of t)for(const r of n)e.has(r.value)||(e.add(r.value),s.push(r));return s}function kg(t){try{return decodeURIComponent(t)}catch{return t}}function IT(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function DT(t){const e=[];let s="^";for(const n of t)n.type==="text"?s+=IT(n.text):(e.push(n.name),s+=n.name==="*"?"(.+)":"([^/]+)");return{pattern:new RegExp(`${s}$`),order:e}}function OT(t,e,s){if(typeof t!="string"||!t)return null;let n;try{n=new URL(t,"https://placeholder.invalid").pathname}catch{return null}n=n.replace(/\/+$/,"");const r=_l(Wn(e)),{pattern:o,order:a}=DT(r),l=a.indexOf(s);if(l===-1)return null;const c=n.match(o);if(!c)return null;const d=c[l+1]?.replace(/^\/+|\/+$/g,"");return d?kg(d):null}function Ca(t,e){const s=fi(t),n=Array.isArray(t)?t:Array.isArray(s?.products)?s.products:Array.isArray(s?.list)?s.list:[],r=[],o=new Set;for(const a of n){const l=fi(a);if(!l)continue;const c=OT(l.url,e.template,e.paramName);if(!c||o.has(c))continue;o.add(c);const d=fi(l.isVariantOf),h=typeof d?.name=="string"&&d.name||typeof l.name=="string"&&l.name||c,u=Array.isArray(l.image)?fi(l.image[0]):null,f=typeof u?.url=="string"?u.url:void 0;r.push({value:c,label:h,image:f})}return r}function MT(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?kg(s):null}function $T(t){const e=[],s=new Set,n=(r,o)=>{const a=fi(r);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=MT(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const r of t)n(r,[]);return e}function BT(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const ff=3e4;function Vg(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function zT(t,e,s,n){const r=new URL(`/deco/invoke/${e}`,t);return r.searchParams.set("__cb",n.toString(36)),r.searchParams.set("__decoFBT","0"),r.searchParams.set("__d",`run-${n.toString(36)}`),r.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),r.href}async function FT(t,{resolveType:e,props:s}){let n;try{n=await fetch(Vg(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(ff)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${ff/1e3}s — the block may be slow or the preview unresponsive.`):l}const r=await n.text();let o=null,a=!1;try{o=r?JSON.parse(r):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:r||`Run failed (${n.status})`;throw new Error(l)}return a?o:r}function UT(t){const e=M.c(2);let s;return e[0]!==t?(s={mutationFn:n=>FT(t,n)},e[0]=t,e[1]=s):s=e[1],Gs(s)}const HT=1e4,Ng={product:{noun:"product",heading:"Products"},category:{noun:"category",heading:"Categories"}};async function KT(t,{resolveType:e,props:s}){const n=await fetch(Vg(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(HT)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}function Ag(t,e,s){return it.sandboxInvoke(`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`,`path-param-${e.id}:${e.clientFilter?"":s}`)}async function Tg(t,e,s,n){const r=e.buildRequests(s);if(r.length===0)return[];const o=await Promise.allSettled(r.map(l=>KT(t,l))),a=o.filter(l=>l.status==="fulfilled").map(l=>l.value);if(a.length===0){const l=o.find(c=>c.status==="rejected");throw l?l.reason:new Error("Failed to fetch options")}return PT(a.map(l=>e.optionsFromPayload(l,n)))}function WT(t){const e=M.c(29),{source:s,sandboxRef:n,template:r,paramName:o,open:a,search:l,debouncedSearch:c,showHeading:d,onSelect:h}=t;let u;e[0]!==c||e[1]!==n||e[2]!==s?(u=Ag(n,s,c),e[0]=c,e[1]=n,e[2]=s,e[3]=u):u=e[3];let f;e[4]!==c||e[5]!==o||e[6]!==n||e[7]!==s||e[8]!==r?(f=()=>Tg(n,s,c,{template:r,paramName:o}),e[4]=c,e[5]=o,e[6]=n,e[7]=s,e[8]=r,e[9]=f):f=e[9];let m;e[10]!==a||e[11]!==u||e[12]!==f?(m={queryKey:u,queryFn:f,enabled:a,staleTime:6e4,retry:1},e[10]=a,e[11]=u,e[12]=f,e[13]=m):m=e[13];const p=Ut(m),{noun:g,heading:x}=Ng[s.kind];let v;e[14]!==p.data||e[15]!==l||e[16]!==s.clientFilter?(v=s.clientFilter?BT(p.data??[],l):p.data??[],e[14]=p.data,e[15]=l,e[16]=s.clientFilter,e[17]=v):v=e[17];const _=v,b=p.isLoading?`Loading ${g}…`:p.isError?"Couldn't load — is the dev server running?":null;if(!b&&_.length===0)return null;const y=d?x:void 0;let L;e[18]!==h||e[19]!==_||e[20]!==o||e[21]!==s.id||e[22]!==s.kind||e[23]!==b||e[24]!==r?(L=b?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:b}):_.map(S=>i.jsxs(Cs,{value:`${s.id}:${S.value}`,className:"gap-3 py-2",onSelect:()=>h(S.value),children:[s.kind==="product"&&i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:S.image?i.jsx("img",{src:S.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):i.jsx(Jd,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm",children:S.label}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:hi(r,{[o]:S.value})})]})]},`${s.id}:${S.value}`)),e[18]=h,e[19]=_,e[20]=o,e[21]=s.id,e[22]=s.kind,e[23]=b,e[24]=r,e[25]=L):L=e[25];let w;return e[26]!==y||e[27]!==L?(w=i.jsx(Is,{heading:y,children:L}),e[26]=y,e[27]=L,e[28]=w):w=e[28],w}function qT(t){const e=M.c(70),{sources:s,template:n,paramName:r,value:o,sandboxRef:a,onCommit:l}=t,[c,d]=k.useState(!1),[h,u]=k.useState(""),[f,m]=k.useState(""),p=k.useRef(null),g=r==="*"?"path":`:${r}`;let x;e[0]!==s?(x=new Set(s.map(YT)),e[0]=s,e[1]=x):x=e[1];let v;e[2]!==x?(v=[...x],e[2]=x,e[3]=v):v=e[3];const b=`Search ${v.join(" or ")} or enter a value…`;let y;e[4]!==o?(y=Y=>{d(Y),p.current&&clearTimeout(p.current),u(Y?o:""),m(Y?o:"")},e[4]=o,e[5]=y):y=e[5];const L=y;let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w=Y=>{u(Y),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{m(Y)},300)},e[6]=w):w=e[6];const S=w;let j;e[7]!==L||e[8]!==l?(j=Y=>{l(Y),L(!1)},e[7]=L,e[8]=l,e[9]=j):j=e[9];const C=j;let V,N;e[10]!==r||e[11]!==h||e[12]!==n?(V=h.trim().replace(/^\/+|\/+$/g,""),N=hi(n,{[r]:V}),e[10]=r,e[11]=h,e[12]=n,e[13]=V,e[14]=N):(V=e[13],N=e[14]);const T=N,A=`Value for ${g} — click to pick`;let E;e[15]!==L?(E=Y=>{Y.stopPropagation(),L(!0)},e[15]=L,e[16]=E):E=e[16];const R=o||g;let D;e[17]!==A||e[18]!==E||e[19]!==R?(D=i.jsx("button",{type:"button",title:A,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:E,children:R}),e[17]=A,e[18]=E,e[19]=R,e[20]=D):D=e[20];let P;e[21]!==g?(P=i.jsx(us,{className:"sr-only",children:i.jsxs(hs,{children:["Pick a value for ",g]})}),e[21]=g,e[22]=P):P=e[22];let I;e[23]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(Jd,{size:16,className:"shrink-0 text-foreground"}),e[23]=I):I=e[23];let O;e[24]!==g?(O=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[I,i.jsxs("span",{className:"text-sm font-medium text-foreground",children:["Pick a value for"," ",i.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:g})]})]}),e[24]=g,e[25]=O):O=e[25];let B;e[26]!==b||e[27]!==h?(B=i.jsx(Ii,{autoFocus:!0,placeholder:b,value:h,onValueChange:S}),e[26]=b,e[27]=h,e[28]=B):B=e[28];let z;e[29]===Symbol.for("react.memo_cache_sentinel")?(z=i.jsx(Jn,{children:"No results."}),e[29]=z):z=e[29];let $;e[30]!==C||e[31]!==g||e[32]!==T||e[33]!==V?($=V&&i.jsx(Is,{children:i.jsxs(Cs,{value:`__raw__:${V}`,className:"gap-3 py-2",onSelect:()=>C(V),children:[i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:i.jsx(Sr,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsxs("span",{className:"block truncate text-sm",children:["Use “",V,"” as ",g]}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:T})]})]})}),e[30]=C,e[31]=g,e[32]=T,e[33]=V,e[34]=$):$=e[34];let U;if(e[35]!==C||e[36]!==f||e[37]!==c||e[38]!==r||e[39]!==a||e[40]!==h||e[41]!==s||e[42]!==n){let Y;e[44]!==C||e[45]!==f||e[46]!==c||e[47]!==r||e[48]!==a||e[49]!==h||e[50]!==s.length||e[51]!==n?(Y=F=>i.jsx(WT,{source:F,sandboxRef:a,template:n,paramName:r,open:c,search:h,debouncedSearch:f,showHeading:s.length>1,onSelect:C},F.id),e[44]=C,e[45]=f,e[46]=c,e[47]=r,e[48]=a,e[49]=h,e[50]=s.length,e[51]=n,e[52]=Y):Y=e[52],U=s.map(Y),e[35]=C,e[36]=f,e[37]=c,e[38]=r,e[39]=a,e[40]=h,e[41]=s,e[42]=n,e[43]=U}else U=e[43];let W;e[53]!==$||e[54]!==U?(W=i.jsxs(Di,{className:"max-h-none flex-1",children:[z,$,U]}),e[53]=$,e[54]=U,e[55]=W):W=e[55];let X;e[56]!==B||e[57]!==W?(X=i.jsxs(Cr,{shouldFilter:!1,className:"min-h-0 flex-1",children:[B,W]}),e[56]=B,e[57]=W,e[58]=X):X=e[58];let H;e[59]!==P||e[60]!==O||e[61]!==X?(H=i.jsxs(Zt,{className:"flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",onClick:GT,children:[P,O,X]}),e[59]=P,e[60]=O,e[61]=X,e[62]=H):H=e[62];let Z;e[63]!==L||e[64]!==c||e[65]!==H?(Z=i.jsx(es,{open:c,onOpenChange:L,children:H}),e[63]=L,e[64]=c,e[65]=H,e[66]=Z):Z=e[66];let K;return e[67]!==D||e[68]!==Z?(K=i.jsxs(i.Fragment,{children:[D,Z]}),e[67]=D,e[68]=Z,e[69]=K):K=e[69],K}function GT(t){return t.stopPropagation()}function YT(t){return Ng[t.kind].noun}function JT(t){const e=M.c(11),{source:s,template:n,paramName:r,sandboxRef:o,onFill:a}=t;let l;e[0]!==o||e[1]!==s?(l=Ag(o,s,""),e[0]=o,e[1]=s,e[2]=l):l=e[2];let c;e[3]!==r||e[4]!==o||e[5]!==s||e[6]!==n?(c=()=>Tg(o,s,"",{template:n,paramName:r}),e[3]=r,e[4]=o,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;e[8]!==l||e[9]!==c?(d={queryKey:l,queryFn:c,staleTime:6e4,retry:1},e[8]=l,e[9]=c,e[10]=d):d=e[10];const h=Ut(d),[u,f]=k.useState(!1);if(!u&&h.data&&h.data.length>0){f(!0);const m=h.data[0].value;queueMicrotask(()=>a(m))}return null}const XT={loaders:"loader",actions:"action"},Eg=new Set(["workflows"]);function Rg(t){return XT[t]}function QT(t,e,s){const n=t.manifest?.blocks??{};for(const[r,o]of Object.entries(n))if(r.includes(s)&&e in o)return!0;return!1}function ZT(t,e){const s=new Set,n=t.manifest?.blocks??{};for(const[r,o]of Object.entries(n))if(r.includes(e))for(const a of Object.keys(o))s.add(a);return s}function eE(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function Pg(t,e){const s=t.manifest?.blocks??{},n=[],r=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))r.add(l);for(const o of r){if(o.toLowerCase().includes("preview")||Rp.has(o)||Eg.has(cu(o))||eE(o,r))continue;const a=ri(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:Ct(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function mf(t,e){return Pg(t,e).length}function cu(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const tE={deco:"Deco",std:"Deco Standard",website:"Website"};function sE(t){return tE[t]??t}function Ig(t){const e=cu(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function nE(t,e,s){const n=[];for(const[r,o]of Object.entries(e)){if(r.includes("/")||ic(r)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(Rp.has(l)||Eg.has(cu(l))||QT(t,l,s)&&n.push({key:r,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:r}))}return n.sort((r,o)=>r.title.localeCompare(o.title))}function Dg(t){const e=M.c(12),{orgSlug:s,virtualMcpId:n,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==n?(l=it.sandboxRepoDir(s,n,r),e[0]=r,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],Ut(d).data??null}const iE={target:null,editSeoPageKey:null,variantOverride:null};function rE(t,e){switch(e.type){case"select":return{...t,target:e.target,variantOverride:null};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"variant-override":return{...t,variantOverride:e.params}}}const Og=k.createContext(null);function oE(t){const e=M.c(9),{children:s}=t,[n,r]=k.useReducer(rE,iE);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>r({type:"select",target:u}),a=u=>r({type:"edit-seo",target:u}),l=()=>r({type:"consume-edit-seo"}),c=u=>r({type:"variant-override",params:u}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,setVariantOverride:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=i.jsx(Og,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function du(){const t=k.use(Og);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}const aE=new Set(["clone-failed","install-failed","start-failed","crashed"]);function lE(t){const e=t.lifecyclePhase==="running"||t.lifecyclePhase==="crashed";return aE.has(t.lifecyclePhase)&&t.lifecyclePhase!=="crashed"?{kind:"error",source:"sandbox"}:e?[t.decofile,t.meta].some(r=>r.status==="error"&&!r.hasData&&r.errorStatus===404)?{kind:"empty"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?{kind:"error",source:"data"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}:{kind:"loading"}}const cE="https://github.com/decocms/blocks";function dE(){const t=M.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(Mv,{size:48,className:"text-muted-foreground"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(Li,{className:"h-full w-full",image:e,title:"Want to edit this website with easy-to-use forms?",description:"Set up rich content editing so anyone can update pages without touching code.",actions:i.jsx(re,{size:"sm",asChild:!0,children:i.jsxs("a",{href:cE,target:"_blank",rel:"noreferrer",children:["Set up content editing",i.jsx(Rn,{size:14})]})})}),t[1]=s):s=t[1],s}function uE(t){const e=M.c(6),{source:s,onRetry:n}=t,r=s==="sandbox"?"The project preview could not start. Retry to make Blocks available.":"Studio could not load this project's Blocks metadata.";let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(Sn,{size:48,className:"text-muted-foreground"}),e[0]=o):o=e[0];let a;e[1]!==n?(a=i.jsx(re,{variant:"outline",size:"sm",onClick:n,children:"Retry"}),e[1]=n,e[2]=a):a=e[2];let l;return e[3]!==r||e[4]!==a?(l=i.jsx(Li,{image:o,title:"Blocks unavailable",description:r,actions:a}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function ji(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:i.jsx(Xe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}const hE=k.lazy(()=>Os(()=>import("./sections-editor-Dpco23Fg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SectionsEditor})));function pf(t){if(t instanceof Error&&"status"in t&&typeof t.status=="number")return t.status}function gf(t){const e=M.c(47),{virtualMcpId:s,externalSelectedIndex:n}=t,r=n===void 0?null:n,{org:o}=Ee(),{currentBranch:a}=Qt(),l=$s(),c=Vr(),d=du(),h=l.lifecycle.phase==="running",u=c.previewUrl;let f;e[0]!==a||e[1]!==o||e[2]!==u||e[3]!==s?(f=a?{orgSlug:o.slug,virtualMcpId:s,branch:a,previewUrl:u}:null,e[0]=a,e[1]=o,e[2]=u,e[3]=s,e[4]=f):f=e[4];const m=f;let p;e[5]!==h?(p={fetchEnabled:h},e[5]=h,e[6]=p):p=e[6];const g=sc(m,p);let x;e[7]!==h?(x={fetchEnabled:h},e[7]=h,e[8]=x):x=e[8];const v=nc(m,x),_=g.data!==void 0;let b;e[9]!==g.data||e[10]!==g.error||e[11]!==g.status||e[12]!==v.data||e[13]!==v.error||e[14]!==v.status||e[15]!==l.lifecycle.phase||e[16]!==_?(b=lE({lifecyclePhase:l.lifecycle.phase,decofile:{status:g.status,hasData:_,errorStatus:pf(g.error)},meta:{status:v.status,hasData:v.data!==void 0,errorStatus:pf(v.error)},hasEditableContent:I9(g.data,v.data)}),e[9]=g.data,e[10]=g.error,e[11]=g.status,e[12]=v.data,e[13]=v.error,e[14]=v.status,e[15]=l.lifecycle.phase,e[16]=_,e[17]=b):b=e[17];const y=b;if(y.kind==="loading"){let I;return e[18]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(ji,{}),e[18]=I):I=e[18],I}if(y.kind==="empty"){let I;return e[19]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(dE,{}),e[19]=I):I=e[19],I}if(y.kind==="error"){let I;e[20]!==g||e[21]!==c||e[22]!==v||e[23]!==y.source?(I=()=>{if(y.source==="sandbox"){c.retry();return}Promise.all([g.refetch(),v.refetch()])},e[20]=g,e[21]=c,e[22]=v,e[23]=y.source,e[24]=I):I=e[24];const O=I;let B;return e[25]!==O||e[26]!==y.source?(B=i.jsx(uE,{source:y.source,onRetry:O}),e[25]=O,e[26]=y.source,e[27]=B):B=e[27],B}const L=d.state.target;let w;e[28]!==a||e[29]!==o.slug||e[30]!==L||e[31]!==s?(w=L||!a?null:jg(wg(o.slug,s,a)),e[28]=a,e[29]=o.slug,e[30]=L,e[31]=s,e[32]=w):w=e[32];const S=w;let j="/",C=null,V=null;L?.kind==="page"?(j=L.path,C=L.key):L?.kind==="section"?V=L.key:S&&(j=S.path,C=S.pageKey);const N=C?`page:${C}`:V?`section:${V}`:`path:${j}`;let T;e[33]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(Xe,{size:20,className:"animate-spin text-muted-foreground"})}),e[33]=T):T=e[33];const A=a??"",E=u??void 0,R=V?null:r,D=!!C&&d.state.editSeoPageKey===C;let P;return e[34]!==V||e[35]!==C||e[36]!==j||e[37]!==N||e[38]!==o.slug||e[39]!==E||e[40]!==R||e[41]!==D||e[42]!==A||e[43]!==s||e[44]!==d.consumeEditSeo||e[45]!==d.setVariantOverride?(P=i.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:i.jsx(k.Suspense,{fallback:T,children:i.jsx(hE,{orgSlug:o.slug,virtualMcpId:s,branch:A,previewReady:!0,previewUrl:E,currentPath:j,activePageBlockKey:C,activeGlobalBlockKey:V,externalSelectedIndex:R,initialEditSeo:D,onExitSeo:d.consumeEditSeo,onVariantPreviewOverride:d.setVariantOverride},N)})}),e[34]=V,e[35]=C,e[36]=j,e[37]=N,e[38]=o.slug,e[39]=E,e[40]=R,e[41]=D,e[42]=A,e[43]=s,e[44]=d.consumeEditSeo,e[45]=d.setVariantOverride,e[46]=P):P=e[46],P}function fE(t,e){return t===e?"preview":e}const mE="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",pE="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",gE=k.lazy(()=>Os(()=>import("./page-seo-sheet-mJW0tAP8.js"),__vite__mapDeps([156,1,2,61,31,62,48,52,50,51,17,3,53,54,55,56,57,58,59,60,63,64,65,66,67,5,16,19,4,6,7,8,9,10,11,12,13,14,15,18,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,104,105,107,108,109,110,111,112,113,114,115,116,103,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SeoSheet}))),xf=500,xE={mobile:375,tablet:768,desktop:null},e0=["desktop","mobile","tablet"],vf={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function vE(t){const e=M.c(24),{name:s,value:n,onCommit:r}=t,[o,a]=k.useState(n),[l,c]=k.useState(!1),d=k.useRef(!1),h=s==="*"?"path":`:${s}`,u=o||h;let f;e[0]!==u?(f=i.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:u}),e[0]=u,e[1]=f):f=e[1];const m=`Value for ${h}`;let p,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=w=>a(w.target.value),g=()=>c(!0),e[2]=p,e[3]=g):(p=e[2],g=e[3]);let x;e[4]!==n?(x=w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&(d.current=!0,a(n),w.currentTarget.blur())},e[4]=n,e[5]=x):x=e[5];let v;e[6]!==o||e[7]!==r||e[8]!==n?(v=()=>{if(c(!1),d.current){d.current=!1;return}const w=o.trim();a(w),w!==n&&r(w)},e[6]=o,e[7]=r,e[8]=n,e[9]=v):v=e[9];let _;e[10]!==o||e[11]!==h||e[12]!==m||e[13]!==x||e[14]!==v?(_=i.jsx("input",{type:"text",value:o,placeholder:h,title:m,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:bE,onChange:p,onFocus:g,onKeyDown:x,onBlur:v}),e[10]=o,e[11]=h,e[12]=m,e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;e[16]!==f||e[17]!==_?(b=i.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[f,_]}),e[16]=f,e[17]=_,e[18]=b):b=e[18];let y;e[19]!==l?(y=l&&i.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[i.jsx(Uv,{size:10}),"Enter to go"]}),e[19]=l,e[20]=y):y=e[20];let L;return e[21]!==b||e[22]!==y?(L=i.jsxs(i.Fragment,{children:[b,y]}),e[21]=b,e[22]=y,e[23]=L):L=e[23],L}function bE(t){return t.stopPropagation()}function _E(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function qr(t){if(!t)return null;try{return new URL(t,window.location.href).origin}catch{return null}}function bf(t,e){try{t.contentWindow?.location.reload()}catch{e&&(t.src=e)}}function yE({virtualMcpId:t}){const e=Lr(),s=yt(),{currentBranch:n}=Qt(),r=du(),o=ce=>{s({to:".",search:_e=>({..._e,main:ce}),replace:!0})},[a,l]=k.useState("preview"),[c,d]=k.useState("desktop"),[h,u]=k.useState(null),[f,m]=k.useState(null),p=k.useRef(null),g=k.useRef(null),[x,v]=k.useState(!1),[_,b]=k.useState(""),y=k.useRef(null),[L,w]=k.useState(!1),[S,j]=k.useState(),[C,V]=k.useState(null),[N,T]=k.useState(null),[A,E]=k.useState("/"),[R,D]=k.useState(null),[P,I]=k.useState({}),[O,B]=k.useState(!1),z=k.useRef(null),$=()=>{B(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>B(!1),15e3)},U=()=>{z.current&&(clearTimeout(z.current),z.current=null),B(!1)},[W,X]=k.useState(!1),{org:H}=Ee(),Z=$s(),K=Vr(),Y=K.vmEntry,F=K.previewUrl,Q=Z.lifecycle.phase,J=Q==="running",ee=Y?.sandboxProviderKind==="user-desktop",q=Dg({orgSlug:H.slug,virtualMcpId:t??"",branch:n??"",enabled:ee&&J&&!!t&&!!n}),se=ee?q:null,ne=t&&n?{orgSlug:H.slug,virtualMcpId:t,branch:n,previewUrl:F}:null,{data:le}=sc(ne,{fetchEnabled:J}),{data:G}=nc(ne,{fetchEnabled:J}),oe=t&&n?{orgSlug:H.slug,virtualMcpId:t,branch:n}:null,me=$A(oe),ue=le?D9(le).sort((ce,_e)=>ce.name.localeCompare(_e.name)):[],ye=le&&G?O9(le,G):[],Le=Wn,Ce=ue.filter(ce=>{if(!_)return!0;const _e=_.toLowerCase();return ce.name.toLowerCase().includes(_e)||ce.path.toLowerCase().includes(_e)}),ze=ye.filter(ce=>{if(!_)return!0;const _e=_.toLowerCase();return ce.name.toLowerCase().includes(_e)||ce.key.toLowerCase().includes(_e)||ce.resolveType.toLowerCase().includes(_e)}),Te=C?null:ZS(ue,A,R),Se=C?C.name:Te?.name,be=Te?.key??null,Re=Te?.path??null,Ve=(be?P[be]:void 0)??{},he=hi(A,Ve),Pe={};if(J&&F&&G&&le){const ce=ZT(G,"loaders"),_e=be?le[be]:void 0,at=RT(_e,le,ps=>ce.has(ps)),xt=NT(at);for(const ps of _l(A)){if(ps.type!=="param")continue;const Ur=kT(A,ps.name,at),Js=ET(Ur,ce,xt);Js.length>0&&(Pe[ps.name]=Js)}}const Me=t&&n?{orgSlug:H.slug,virtualMcpId:t,branch:n}:null,xe=le&&be?bg(le,be,0):[],Ae=le?mg(xe,le):[],pe=Ae.map(ce=>ce.isSavedBlock?ce.label:""),ke=Ae.map(ce=>ce.isSavedBlock?"global":ce.isMultivariate?"variant":"normal"),$e=xe.map(ce=>q0(ce,le??{})),ge=k.useRef(null),Ke=k.useRef(null),gt=Z.status.state==="paused",nt=Z.phase,lt=yg({claimPhase:nt,lifecycle:Z.lifecycle}),qe=K.previewState,Rt=K.userStopped,ct=qe.kind==="starting"||qe.kind==="iframe"&&lt.status==="doing",Ye=qe.kind==="iframe"?IA(_E(N??new URL(he,qe.previewUrl).href,c),r.state.variantOverride??[]):null,ot=t&&n?wg(H.slug,t,n):null,ht=ce=>{ot&&wT(ot,ce)},ae=r.state.target;k.useEffect(()=>{if(!(!ae||!F||!G))if(ae.kind==="page"){const ce=P[ae.key]??{};Ke.current=hi(ae.path,ce),V(null),T(null),D(ae.key),E(ae.path),ht({path:ae.path,pageKey:ae.key,params:ce})}else{const ce=ye.find(_e=>_e.key===ae.key);if(ce){Ke.current=null;const _e=I0(G);V(ce),T(cf(F,_e,ce.key))}}},[ae,F,G,P]),k.useEffect(()=>{!be||Re===null||ae?.kind==="page"&&ae.key===be&&ae.path===Re||r.selectTarget({kind:"page",key:be,path:Re})},[be,Re,ae]);const[Fe,Ze]=k.useState(null);if(qe.kind==="iframe"&&Fe!==qe.previewUrl){const ce=Fe!==null;Ze(qe.previewUrl);const _e=ot?jg(ot):null;if(_e){if(Ke.current=hi(_e.path,_e.params),E(_e.path),D(_e.pageKey),T(null),V(null),_e.pageKey&&Object.keys(_e.params).length>0){const at=_e.pageKey;I(xt=>({...xt,[at]:_e.params}))}}else ce&&(Ke.current=null,E("/"),T(null),D(null),V(null))}ge.current=Ye;const mt=!!t&&!!n&&!Z.notFound&&!Rt&&!gt&&(nt?.kind==="ready"||Q!=="idle"),Nt=qe.kind!=="iframe"&&a==="visual"?"preview":a;k.useEffect(()=>{const ce=qr(F);if(!ce)return;const _e=at=>{if(at.origin===ce){if(at.data?.type==="visual-editor::element-clicked"){const xt=FA.safeParse(at.data.payload);xt.success&&u(xt.data)}else if(at.data?.type==="cms-editor::section-clicked"){const xt=HA.safeParse(at.data.payload);xt.success&&m(xt.data.sectionIndex)}}};return window.addEventListener("message",_e),()=>window.removeEventListener("message",_e)},[F]),k.useEffect(()=>{if(!x)return;const ce=_e=>{y.current?.contains(_e.target)||(v(!1),b(""))};return document.addEventListener("pointerdown",ce),()=>document.removeEventListener("pointerdown",ce)},[x]);const ms=()=>{const ce=p.current?.contentWindow,_e=qr(F);!ce||!_e||ce.postMessage({type:"visual-editor::activate",script:UA},_e)},Be=()=>{const ce=p.current?.contentWindow,_e=qr(F);!ce||!_e||ce.postMessage({type:"visual-editor::deactivate"},_e)},Pt=()=>{const ce=p.current?.contentWindow,_e=qr(F);!ce||!_e||(ce.postMessage({type:"visual-editor::activate",script:KA},_e),ce.postMessage({type:"cms-editor::set-labels",labels:pe,kinds:ke,keys:$e},_e))},Bs=()=>{const ce=p.current?.contentWindow,_e=qr(F);!ce||!_e||ce.postMessage({type:"cms-editor::deactivate"},_e)},ie=ce=>{const _e=a;!e&&ce!==_e&&(ce==="blocks"?g.current?.resize(40):g.current?.collapse()),l(ce),u(null),m(null),_e==="visual"&&Be(),ce==="visual"&&ms(),_e==="blocks"&&ce!=="blocks"&&Bs(),ce==="blocks"&&Pt()},je=ce=>{ie(fE(a,ce))},Ue=()=>{if(!p.current||!Ye)return;const ce=p.current;ce.src=Ye},We=()=>{const ce=p.current;if(!ce)return;$();const _e=document.activeElement,at=ce.tabIndex;ce.tabIndex=-1,ce.style.pointerEvents="none",ce.blur(),bf(ce,ge.current);let xt;const ps=()=>{clearTimeout(xt),ce.tabIndex=at,ce.style.pointerEvents="",_e?.focus(),ce.removeEventListener("load",ps)};ce.addEventListener("load",ps),xt=setTimeout(ps,3e3)};u8(()=>{We()}),h8(()=>{$()});const ft=()=>{if(!p.current||!Ye)return;const ce=Ye.includes("?")?"&":"?";p.current.src=`${Ye}${ce}_r=${Date.now()}`},Lt=()=>{const ce=e0.indexOf(c);d(e0[(ce+1)%e0.length])},On=async()=>{let ce=null;try{ce=p.current?.contentWindow?.location?.href??null}catch{}const _e=ce??Ye??F;if(_e)try{await navigator.clipboard.writeText(_e),de.success("URL copied to clipboard")}catch{de.error("Failed to copy URL")}},ai=(()=>{if(!F)return"No server running";if(C)return C.name;try{const ce=new URL(F),_e=he==="/"?"":he;return`${ce.host}${_e}`}catch{return F}})(),Nc=ce=>{const _e=P[ce.key]??{},at=hi(ce.path,_e);(C||Le(at)!==Le(he))&&$(),Ke.current=at,V(null),T(null),m(null),D(ce.key),E(ce.path),ht({path:ce.path,pageKey:ce.key,params:_e}),r.selectTarget({kind:"page",key:ce.key,path:ce.path})},Ac=(ce,_e)=>{if(!be)return;const at=be,xt={...Ve,[ce]:_e};Ke.current=hi(A,xt),I(ps=>({...ps,[at]:xt})),ht({path:A,pageKey:at,params:xt})},k5=ce=>{if(!F||!G){de.error("Preview metadata not ready yet");return}$(),Ke.current=null;const _e=I0(G),at=cf(F,_e,ce.key);V(ce),T(at),m(null),r.selectTarget({kind:"section",key:ce.key})},V5=async({name:ce,path:_e,templateKey:at})=>{if(!t||!n)return;const xt=E9(_e);if(xt){j(xt);return}const ps=_e.trim().startsWith("/")?_e.trim():`/${_e.trim()}`;if(ue.some(Js=>Le(Js.path)===Le(ps))){j(`A page with path "${ps}" already exists.`);return}let Ur;if(at&&(Ur=le?.[at],!Ur)){j("Selected template no longer exists.");return}j(void 0);try{const Js=await me.mutateAsync({name:ce,path:ps,template:Ur});w(!1),de.success(`Page "${ce}" created`),await A6(xf),Nc({key:Js.key,name:Js.name,path:Js.path}),ie("blocks")}catch(Js){j(Js instanceof Error?Js.message:"Failed to create page")}},Tc=qe.kind==="iframe",Pu=Tc?i.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:i.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(A0,{onClick:()=>je("visual"),"aria-pressed":a==="visual","aria-label":"Visual editor",active:a==="visual",disabled:!Tc,children:i.jsx(Fu,{size:16})})}),i.jsx(De,{side:"top",children:"Visual editor"})]}),i.jsx("div",{className:"mx-0.5 h-5 w-px bg-border"}),i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(A0,{onClick:Lt,"aria-label":vf[c],disabled:!Tc,children:i.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[c==="mobile"&&i.jsx(Bv,{size:16}),c==="tablet"&&i.jsx(zv,{size:16}),c==="desktop"&&i.jsx(Fv,{size:16})]},c)})}),i.jsx(De,{side:"top",children:vf[c]})]})]})}):null;return i.jsxs("div",{className:"flex flex-col w-full h-full",children:[Me&&Object.entries(Pe).map(([ce,_e])=>(Ve[ce]??"")===""?i.jsx(JT,{source:_e[0],template:A,paramName:ce,sandboxRef:Me,onFill:at=>Ac(ce,at)},`${be}:${ce}`):null),mt&&qe.kind==="iframe"&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:qe.kind==="iframe"&&i.jsxs("div",{className:"flex h-full w-full items-center justify-between gap-2",children:[i.jsxs(re,{variant:"outline",size:"sm","data-testid":"preview-blocks-toggle",onClick:()=>je("blocks"),"aria-pressed":a==="blocks","aria-label":"Blocks editor",children:[i.jsx($v,{size:14}),"Blocks"]}),i.jsxs("div",{className:"flex w-full min-w-0 max-w-[500px] items-center gap-0.5",children:[i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:Ue,children:i.jsx(ir,{size:14})})}),i.jsx(De,{side:"bottom",children:"Refresh"})]}),i.jsxs("div",{ref:y,className:"relative min-w-0 flex-1",children:[i.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[i.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>v(ce=>!ce),children:[C&&i.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i.jsx(pn,{size:11}),"Global"]}),i.jsx("span",{className:te("text-[13px] font-medium text-foreground",Se==null?"min-w-0 flex-1 truncate":"shrink-0"),children:Se??ai}),!C&&Se!=null&&A&&i.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:_l(A).map((ce,_e)=>{if(ce.type==="text")return i.jsx("span",{className:te(_e===0?"min-w-0 truncate":"shrink-0"),children:ce.text},`text-${_e}`);const at=Pe[ce.name];return at&&Me?i.jsx(qT,{sources:at,template:A,paramName:ce.name,value:Ve[ce.name]??"",sandboxRef:Me,onCommit:xt=>Ac(ce.name,xt)},`${be}:${ce.name}`):i.jsx(vE,{name:ce.name,value:Ve[ce.name]??"",onCommit:xt=>Ac(ce.name,xt)},`${be}:${ce.name}`)})})]}),i.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>v(ce=>!ce),"aria-label":"Choose page",children:i.jsx(ts,{size:12,className:te("shrink-0 text-muted-foreground transition-transform",x&&"rotate-180")})})]}),x&&i.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[i.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[i.jsx(p9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{type:"text",value:_,onChange:ce=>b(ce.target.value),onKeyDown:ce=>{if(ce.key!=="Enter")return;const _e=_.trim();if(!_e)return;const at=Ce.find(xt=>Le(xt.path)===Le(_e));at&&(ce.preventDefault(),v(!1),b(""),Nc(at))},placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),i.jsx("div",{className:"p-1.5 border-b",children:i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:ce=>{ce.preventDefault(),v(!1),b(""),j(void 0),w(!0)},children:[i.jsx(kt,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),Ce.length===0&&ze.length===0?i.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:ue.length===0&&ye.length===0?"No pages found in this site.":"No results match your search."}):i.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[Ce.length>0&&i.jsx("div",{className:"p-1.5",children:Ce.map(ce=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:_e=>{_e.preventDefault(),v(!1),b(""),Nc(ce)},children:[i.jsx(kn,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ce.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ce.path})]},ce.key))}),ze.length>0&&i.jsxs("div",{className:te("p-1.5",Ce.length>0&&"border-t"),children:[i.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),ze.map(ce=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:_e=>{_e.preventDefault(),v(!1),b(""),k5(ce)},children:[i.jsx(pn,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:ce.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:ce.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},ce.key))]})]})]})]}),i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:()=>{const ce=Ye??qe.previewUrl;ce&&window.open(ce,"_blank","noopener")},children:i.jsx(Rn,{size:14})})}),i.jsx(De,{side:"bottom",children:"Open in new tab"})]})]}),i.jsx("div",{className:"flex shrink-0 items-center",children:i.jsxs(as,{children:[i.jsx(ls,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",children:i.jsx(ni,{size:14})})}),i.jsxs(cs,{align:"end",className:"w-44",children:[i.jsx(Ge,{onClick:ft,children:"Hard Reload"}),i.jsx(Ge,{onClick:On,children:"Copy Current URL"}),le&&G&&i.jsxs(i.Fragment,{children:[i.jsx(Xi,{}),be&&i.jsxs(Ge,{onClick:()=>{r.editSeo({kind:"page",key:be,path:A}),ie("blocks")},children:[i.jsx(tl,{size:14}),"Edit SEO"]}),be&&i.jsxs(Ge,{onClick:()=>{try{o(Qb(Tb(be)))}catch{de.error("Invalid page block key")}},children:[i.jsx(Qo,{size:14}),"View JSON"]}),i.jsxs(Ge,{onClick:()=>X(!0),children:[i.jsx(tl,{size:14}),"Site SEO"]})]}),se&&i.jsxs(i.Fragment,{children:[i.jsx(Xi,{}),i.jsxs(Ge,{onClick:()=>window.open(El("vscode",se)),children:[i.jsx("img",{src:mE,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),i.jsxs(Ge,{onClick:()=>window.open(El("cursor",se)),children:[i.jsx("img",{src:pE,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})})]})}),i.jsx("div",{className:"flex-1 overflow-hidden",children:e&&Nt==="blocks"?i.jsxs("div",{className:"relative h-full min-h-0 overflow-hidden",children:[i.jsx(gf,{virtualMcpId:t,externalSelectedIndex:f}),Pu]}):i.jsxs(Xm,{direction:"horizontal",children:[i.jsx(nl,{ref:g,id:"preview-blocks-editor",order:1,defaultSize:Nt==="blocks"?40:0,minSize:30,collapsible:!0,collapsedSize:0,className:te("overflow-hidden",Nt==="blocks"?"min-w-[320px]":"min-w-0"),children:Nt==="blocks"&&i.jsx(gf,{virtualMcpId:t,externalSelectedIndex:f})}),i.jsx(Qm,{withHandle:!0,className:te(Nt!=="blocks"&&"hidden")}),i.jsx(nl,{id:"preview-canvas",order:2,defaultSize:Nt==="blocks"?60:100,minSize:35,className:"min-w-0 overflow-hidden",children:i.jsxs("div",{className:te("h-full relative overflow-hidden",c!=="desktop"&&qe.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[O&&qe.kind==="iframe"&&i.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:i.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),ct&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(nr,{kind:"starting",progress:lt,claimPhase:nt})}),qe.kind==="suspended"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(nr,{kind:"suspended",onResume:K.resume})}),qe.kind==="errored"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(nr,{kind:"errored",error:qe.error,onRetry:K.retry,connectionsHref:`/${H.slug}/settings/connections`})}),Nt==="visual"&&!h&&i.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[i.jsx(Fu,{size:12}),"Click any element to ask the AI"]}),Nt==="visual"&&h&&i.jsx(lT,{element:h,onDismiss:()=>u(null)}),Pu,qe.kind==="iframe"&&Ye&&i.jsx("div",{className:te("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",c!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:c==="desktop"?"100%":`${xE[c]}px`},children:i.jsx("iframe",{ref:p,src:Ye,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{if(U(),Ne("vm_preview_loaded",{view_mode:a,vm_id:Y?.sandboxHandle??null}),!C)try{const ce=p.current?.contentWindow?.location?.pathname;if(!ce)return;const _e=Ke.current;if(_e!==null&&(Ke.current=null,Le(ce)!==Le(_e))||Le(ce)===Le(he))return;E(ce),ht({path:ce,pageKey:R,params:Ve})}catch{}a==="visual"&&ms(),a==="blocks"&&Pt()}},qe.previewUrl)})]})})]})}),i.jsx(zA,{open:L,onOpenChange:w,isPending:me.isPending,error:S,templates:ue,onSubmit:V5}),W&&le&&G&&i.jsx(k.Suspense,{fallback:null,children:i.jsx(gE,{open:W,onOpenChange:X,orgSlug:H.slug,virtualMcpId:t??"",branch:n??"",decofile:le,meta:G,onSaved:()=>{setTimeout(()=>{const ce=p.current;ce&&bf(ce,ge.current)},xf)},target:{kind:"site"}})})]})}function LE(t){const e=M.c(6),{virtualMcpId:s}=t,n=fs(s),{activeTask:r}=Qt(),[o,a]=k.useState(!1);if(!(tn(n?.metadata)||tn(r?.metadata))){let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("div",{className:"flex size-14 items-center justify-center rounded-full bg-muted",children:i.jsx(Io,{className:"size-7 text-foreground"})}),e[0]=d):d=e[0];let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Li,{className:"h-full",image:d,title:"No source to preview",description:"Connect a GitHub repository to build and preview your site here.",actions:i.jsxs(re,{onClick:()=>a(!0),children:[i.jsx(Io,{className:"size-4"}),"Connect GitHub"]})}),e[1]=h):h=e[1];let u;return e[2]!==o?(u=i.jsxs(i.Fragment,{children:[h,i.jsx(m2,{open:o,onOpenChange:a,mode:"agent"})]}),e[2]=o,e[3]=u):u=e[3],u}let c;return e[4]!==s?(c=i.jsx(yE,{virtualMcpId:s}),e[4]=s,e[5]=c):c=e[5],c}const SE="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",wE="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",jE=k.lazy(()=>Os(()=>import("./file-explorer-C83rSApL.js"),__vite__mapDeps([157,1,2,89,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,90,91,92,93,94,95,96,97,98,99,100,101,102,139,138,140,141,135,128,117,103,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,136,137,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.FileExplorer})));function CE(t){const e=M.c(17),{openPath:s}=t,n=oi(),{org:r}=Ee(),{currentBranch:o}=Qt(),a=n?.entity?.id??null,l=Vr(),c=$s(),d=l.vmEntry,h=c.lifecycle.phase==="running",u=d?.sandboxProviderKind==="user-desktop",f=a??"",m=o??"",p=u&&h&&!!a&&!!o;let g;e[0]!==r.slug||e[1]!==f||e[2]!==m||e[3]!==p?(g={orgSlug:r.slug,virtualMcpId:f,branch:m,enabled:p},e[0]=r.slug,e[1]=f,e[2]=m,e[3]=p,e[4]=g):g=e[4];const x=Dg(g),v=u?x:null;if(!a||!o){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No sandbox to browse."}),e[5]=w):w=e[5],w}let _;e[6]!==v?(_=v&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:i.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(El("vscode",v)),children:i.jsx("img",{src:SE,alt:"VSCode",width:14,height:14})})}),i.jsx(De,{side:"bottom",children:"Open in VSCode"})]}),i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(El("cursor",v)),children:i.jsx("img",{src:wE,alt:"Cursor",width:14,height:14})})}),i.jsx(De,{side:"bottom",children:"Open in Cursor"})]})]})}),e[6]=v,e[7]=_):_=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(Xe,{size:20,className:"animate-spin text-muted-foreground"})}),e[8]=b):b=e[8];let y;e[9]!==o||e[10]!==s||e[11]!==r.slug||e[12]!==a?(y=i.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:i.jsx(k.Suspense,{fallback:b,children:i.jsx(jE,{orgSlug:r.slug,virtualMcpId:a,branch:o,openPath:s})})}),e[9]=o,e[10]=s,e[11]=r.slug,e[12]=a,e[13]=y):y=e[13];let L;return e[14]!==_||e[15]!==y?(L=i.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,y]}),e[14]=_,e[15]=y,e[16]=L):L=e[16],L}function kE(t){return fs(t)?.metadata?.runtime?.path??null}function VE(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([n])=>!e.includes(n)));return Object.keys(s).length>0?{...t,properties:s}:t}function NE(t,e,s){return typeof t!="string"?null:VE(_n(t,e),s)}function Mg(t,e,s){if(!e||typeof t!="string")return!1;const n=NE(t,e,s);return!!n&&Object.keys(n.properties??{}).length>0}function AE({orgSlug:t,virtualMcpId:e,branch:s}){const n=bs(),r=fs(e)?.metadata?.runtime?.path??null;return Gs({mutationFn:async({blockKey:o})=>{const a=Nr(r,Jm(o)),l=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:a})});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error??`Delete failed (${l.status})`)}return l.json()},onMutate:async({blockKey:o})=>{const a=`${t}/${e}/${s}`,l=it.decofile(a);await n.cancelQueries({queryKey:l});const c=n.getQueryData(l);return n.setQueryData(l,d=>{if(!d)return d;const{[o]:h,...u}=d;return u}),{previous:c,queryKey:l}},onError:(o,a,l)=>{l?.queryKey&&n.setQueryData(l.queryKey,l.previous)},onSuccess:()=>{n.invalidateQueries({queryKey:it.liveMeta(t,e,s)})}})}function Fi(t){const e=M.c(6),{hasItems:s,emptyLabel:n,emptyHint:r}=t;let o;e[0]!==r||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":i.jsxs(i.Fragment,{children:[i.jsx("div",{children:n}),i.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function yc(t,e){return`${t}-${e}`}function $g(t,e){return`site/apps/${t}/${e}.ts`}function Bg(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function TE(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function EE(t){return t==="local"?"Custom":"Installed"}function zg(t,e,s){const n=new Set([yc(t,e),e].map(o=>o.toLowerCase())),r=$g(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(n.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function RE(t,e){const s=t.vendor.alias,n=t.name,r=zg(s,n,e);return{id:yc(s,n),app:n,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:$g(s,n),blockKey:r,installed:r!==null}}function PE(t,e,s){if(t===P9)return null;const n=Bg(t);if(!n)return null;const{vendor:r,app:o}=n,a=zg(r,o,s),l=ri(t,e);return{id:yc(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function IE(t,e,s){const n=e.__resolveType;if(typeof n!="string"||yl(t,e)||!kp(n))return null;const r=Bg(n)??TE(t);if(!r)return null;const o=ri(n,s),{vendor:a,app:l}=r;return{id:yc(a,l),app:l,vendor:a,title:o.title??Ll(t,e,s),description:o.description??"",category:EE(a),logo:o.logo??o.icon,resolveType:n,blockKey:t,installed:!0}}function DE(t,e,s){const n=new Map;for(const o of t){const a=RE(o,s);n.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=PE(o,e,s);!a||n.has(a.id)||n.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=IE(o,a,e);!l||n.has(l.id)||n.set(l.id,l)}return[...n.values()].sort(OE)}function OE(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function ME(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function $E(t,e,s){const n=M.c(12),r=s?.enabled??!0;let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=it.decoApps(),n[0]=o):o=n[0];let a;n[1]!==r?(a={queryKey:o,queryFn:ME,staleTime:3e5,retry:1,enabled:r},n[1]=r,n[2]=a):a=n[2];const l=Ut(a);let c;n[3]!==e||n[4]!==t||n[5]!==l.data?(c=t&&e?DE(l.data??[],t,e):[],n[3]=e,n[4]=t,n[5]=l.data,n[6]=c):c=n[6];const d=c,h=l.isLoading&&!l.isError;let u;return n[7]!==d||n[8]!==l.isError||n[9]!==l.refetch||n[10]!==h?(u={catalog:d,isLoading:h,isError:l.isError,refetch:l.refetch},n[7]=d,n[8]=l.isError,n[9]=l.refetch,n[10]=h,n[11]=u):u=n[11],u}function Fg(t){return(e,s)=>{Eb(e),t(e,s)}}function BE(t){const e=M.c(52),{active:s,counts:n,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:i.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let c;e[1]!==n.pages||e[2]!==o||e[3]!==l?(c=i.jsx(zs,{id:"pages",icon:kn,label:"Pages",count:n.pages,active:l,onSelect:o}),e[1]=n.pages,e[2]=o,e[3]=l,e[4]=c):c=e[4];const d=s==="sections";let h;e[5]!==n.sections||e[6]!==o||e[7]!==d?(h=i.jsx(zs,{id:"sections",icon:pn,label:"Sections",count:n.sections,active:d,onSelect:o}),e[5]=n.sections,e[6]=o,e[7]=d,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==n.apps||e[10]!==o||e[11]!==u?(f=i.jsx(zs,{id:"apps",icon:v2,label:"Apps",count:n.apps,active:u,onSelect:o}),e[9]=n.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="redirects";let p;e[13]!==n.redirects||e[14]!==o||e[15]!==m?(p=i.jsx(zs,{id:"redirects",icon:Mm,label:"Redirects",count:n.redirects,active:m,onSelect:o}),e[13]=n.redirects,e[14]=o,e[15]=m,e[16]=p):p=e[16];const g=s==="loaders";let x;e[17]!==n.loaders||e[18]!==o||e[19]!==g?(x=i.jsx(zs,{id:"loaders",icon:sl,label:"Loaders",count:n.loaders,active:g,onSelect:o}),e[17]=n.loaders,e[18]=o,e[19]=g,e[20]=x):x=e[20];const v=s==="actions";let _;e[21]!==n.actions||e[22]!==o||e[23]!==v?(_=i.jsx(zs,{id:"actions",icon:wi,label:"Actions",count:n.actions,active:v,onSelect:o}),e[21]=n.actions,e[22]=o,e[23]=v,e[24]=_):_=e[24];const b=s==="site";let y;e[25]!==o||e[26]!==b?(y=i.jsx(zs,{id:"site",icon:Om,label:"Site",active:b,onSelect:o}),e[25]=o,e[26]=b,e[27]=y):y=e[27];const L=s==="seo";let w;e[28]!==o||e[29]!==L?(w=i.jsx(zs,{id:"seo",icon:tl,label:"SEO",active:L,onSelect:o}),e[28]=o,e[29]=L,e[30]=w):w=e[30];const S=s==="calendar";let j;e[31]!==o||e[32]!==S?(j=i.jsx(zs,{id:"calendar",icon:Xd,label:"Calendar",active:S,onSelect:o}),e[31]=o,e[32]=S,e[33]=j):j=e[33];let C;e[34]!==s||e[35]!==n.authors||e[36]!==n.categories||e[37]!==n.posts||e[38]!==o||e[39]!==r?(C=r&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[i.jsx(lr,{size:13,className:"shrink-0"}),"Blog"]}),i.jsx(zs,{id:"posts",icon:cr,label:"Posts",count:n.posts,active:s==="posts",onSelect:o}),i.jsx(zs,{id:"authors",icon:h9,label:"Authors",count:n.authors,active:s==="authors",onSelect:o}),i.jsx(zs,{id:"categories",icon:$m,label:"Categories",count:n.categories,active:s==="categories",onSelect:o})]}),e[34]=s,e[35]=n.authors,e[36]=n.categories,e[37]=n.posts,e[38]=o,e[39]=r,e[40]=C):C=e[40];let V;return e[41]!==x||e[42]!==_||e[43]!==y||e[44]!==w||e[45]!==j||e[46]!==C||e[47]!==c||e[48]!==h||e[49]!==f||e[50]!==p?(V=i.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,i.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[c,h,f,p,x,_,y,w,j,C]})]}),e[41]=x,e[42]=_,e[43]=y,e[44]=w,e[45]=j,e[46]=C,e[47]=c,e[48]=h,e[49]=f,e[50]=p,e[51]=V):V=e[51],V}function zs(t){const e=M.c(18),{id:s,icon:n,label:r,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=te("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=i.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==r?(f=i.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&i.jsx("span",{className:te("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=i.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function zE(t){const e=M.c(12),{state:s,claimPhase:n,lifecycle:r,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==r?(l=yg({claimPhase:n,lifecycle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=i.jsx(nr,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=i.jsx(nr,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=i.jsx(nr,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function _f(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function FE(t,e){const s=Wn,n=e.replace(/-copy(?:-\d+)?$/,""),r=`${n}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function UE(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function HE(t){const e=ou(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function KE(t,e){return ug(t,e)}const WE=1e3;function qE(t,e){for(let s=0;s<WE;s++){const n=ou(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const GE={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},YE={create:"Create",duplicate:"Duplicate",rename:"Save"},JE={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function XE(t){const e=M.c(62),{open:s,mode:n,initialName:r,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,[m,p]=k.useState(r),[g,x]=k.useState(o),[v,_]=k.useState(qn),[b,y]=k.useState(null),[L,w]=k.useState(s);s!==L&&(w(s),s&&(p(r),x(o),_(qn),y(null)));const S=n==="create"&&!!c?.length;let j;e[0]!==f||e[1]!==u?(j=J=>{!J&&!f&&(y(null),u(!1))},e[0]=f,e[1]=u,e[2]=j):j=e[2];const C=j;let V;e[3]!==f||e[4]!==m||e[5]!==h||e[6]!==g||e[7]!==S||e[8]!==v||e[9]!==d?(V=async J=>{J.preventDefault();const ee=m.trim(),q=g.trim();if(!ee||!q||f)return;const se=E9(q);if(se){y(se);return}const ne=d?.({name:ee,path:q});if(ne){y(ne);return}y(null),await h({name:ee,path:q,templateKey:S&&v!==qn?v:null})},e[3]=f,e[4]=m,e[5]=h,e[6]=g,e[7]=S,e[8]=v,e[9]=d,e[10]=V):V=e[10];const N=V,T=b??l,A=GE[n];let E;e[11]!==A?(E=i.jsx(us,{children:i.jsx(hs,{children:A})}),e[11]=A,e[12]=E):E=e[12];let R;e[13]!==f||e[14]!==S||e[15]!==v||e[16]!==c?(R=S&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),i.jsx(fg,{id:"page-form-template",value:v,onChange:_,templates:c??[],disabled:f})]}),e[13]=f,e[14]=S,e[15]=v,e[16]=c,e[17]=R):R=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[18]=D):D=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=J=>p(J.target.value),e[19]=P):P=e[19];let I;e[20]!==f||e[21]!==m?(I=i.jsxs("div",{className:"space-y-1.5",children:[D,i.jsx(tt,{id:"page-form-name",value:m,onChange:P,placeholder:"My page",autoFocus:!0,disabled:f})]}),e[20]=f,e[21]=m,e[22]=I):I=e[22];let O;e[23]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[23]=O):O=e[23];let B;e[24]===Symbol.for("react.memo_cache_sentinel")?(B=J=>x(J.target.value),e[24]=B):B=e[24];let z;e[25]!==f||e[26]!==g?(z=i.jsxs("div",{className:"space-y-1.5",children:[O,i.jsx(tt,{id:"page-form-path",value:g,onChange:B,placeholder:"/example",disabled:f})]}),e[25]=f,e[26]=g,e[27]=z):z=e[27];let $;e[28]!==T?($=T&&i.jsx("p",{className:"text-xs text-destructive",children:T}),e[28]=T,e[29]=$):$=e[29];let U;e[30]!==z||e[31]!==$||e[32]!==R||e[33]!==I?(U=i.jsxs("div",{className:"space-y-4 py-4",children:[R,I,z,$]}),e[30]=z,e[31]=$,e[32]=R,e[33]=I,e[34]=U):U=e[34];let W;e[35]!==u?(W=()=>u(!1),e[35]=u,e[36]=W):W=e[36];let X;e[37]!==f||e[38]!==W?(X=i.jsx(re,{type:"button",variant:"outline",onClick:W,disabled:f,children:"Cancel"}),e[37]=f,e[38]=W,e[39]=X):X=e[39];let H;e[40]!==f||e[41]!==m||e[42]!==g?(H=!m.trim()||!g.trim()||f,e[40]=f,e[41]=m,e[42]=g,e[43]=H):H=e[43];let Z;e[44]!==f||e[45]!==n?(Z=f?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{size:14,className:"animate-spin"}),JE[n]]}):YE[n],e[44]=f,e[45]=n,e[46]=Z):Z=e[46];let K;e[47]!==H||e[48]!==Z?(K=i.jsx(re,{type:"submit",disabled:H,children:Z}),e[47]=H,e[48]=Z,e[49]=K):K=e[49];let Y;e[50]!==X||e[51]!==K?(Y=i.jsxs(Ei,{children:[X,K]}),e[50]=X,e[51]=K,e[52]=Y):Y=e[52];let F;e[53]!==N||e[54]!==U||e[55]!==Y||e[56]!==E?(F=i.jsx(Zt,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:N,children:[E,U,Y]})}),e[53]=N,e[54]=U,e[55]=Y,e[56]=E,e[57]=F):F=e[57];let Q;return e[58]!==C||e[59]!==s||e[60]!==F?(Q=i.jsx(es,{open:s,onOpenChange:C,children:F}),e[58]=C,e[59]=s,e[60]=F,e[61]=Q):Q=e[61],Q}function QE(t){const e=M.c(43),{open:s,blockKey:n,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,[d,h]=k.useState(r),[u,f]=k.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==c||e[1]!==l?(m=D=>{!D&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async D=>{D.preventDefault();const P=d.trim();!P||c||await a(P)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsxs(us,{children:[i.jsx(hs,{children:"Rename section"}),i.jsx(si,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=_):_=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=D=>h(D.target.value),e[9]=b):b=e[9];let y;e[10]!==c||e[11]!==d?(y=i.jsxs("div",{className:"space-y-1.5",children:[_,i.jsx(tt,{id:"section-rename-name",value:d,onChange:b,autoFocus:!0,disabled:c})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=L):L=e[13];let w;e[14]!==n?(w=i.jsxs("div",{className:"space-y-1.5",children:[L,i.jsx(tt,{value:n,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=n,e[15]=w):w=e[15];let S;e[16]!==y||e[17]!==w?(S=i.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=S):S=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let C;e[21]!==c||e[22]!==j?(C=i.jsx(re,{type:"button",variant:"outline",onClick:j,disabled:c,children:"Cancel"}),e[21]=c,e[22]=j,e[23]=C):C=e[23];let V;e[24]!==c||e[25]!==d?(V=!d.trim()||c,e[24]=c,e[25]=d,e[26]=V):V=e[26];let N;e[27]!==c?(N=c?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=c,e[28]=N):N=e[28];let T;e[29]!==V||e[30]!==N?(T=i.jsx(re,{type:"submit",disabled:V,children:N}),e[29]=V,e[30]=N,e[31]=T):T=e[31];let A;e[32]!==C||e[33]!==T?(A=i.jsxs(Ei,{children:[C,T]}),e[32]=C,e[33]=T,e[34]=A):A=e[34];let E;e[35]!==x||e[36]!==S||e[37]!==A?(E=i.jsx(Zt,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:x,children:[v,S,A]})}),e[35]=x,e[36]=S,e[37]=A,e[38]=E):E=e[38];let R;return e[39]!==p||e[40]!==s||e[41]!==E?(R=i.jsx(es,{open:s,onOpenChange:p,children:E}),e[39]=p,e[40]=s,e[41]=E,e[42]=R):R=e[42],R}function ZE(t){const e=M.c(7),{type:s}=t,n=WS[s];let r;e[0]!==n?(r=i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground",children:n})}),e[0]=n,e[1]=r):r=e[1];const o=s==="permanent"?"Permanent":"Temporary";let a;e[2]!==o?(a=i.jsx(De,{side:"left",children:o}),e[2]=o,e[3]=a):a=e[3];let l;return e[4]!==r||e[5]!==a?(l=i.jsxs(Oe,{children:[r,a]}),e[4]=r,e[5]=a,e[6]=l):l=e[6],l}const t0={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},uu=["posts","authors","categories"],Lo={posts:"post",authors:"author",categories:"category"};function So(t){return uu.includes(t)}const hu={posts:"post",authors:"author",categories:"category"},Ug={posts:t0.post,authors:t0.author,categories:t0.category},eR=Object.fromEntries(Object.entries(Ug).map(([t,e])=>[e,t]));function tR(t){return typeof t=="string"?eR[t]??null:null}function ei(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Tt(t){return typeof t=="string"?t:""}function sR(t,e){switch(t){case"posts":return{label:Tt(e.title)||"Untitled post",subtitle:Tt(e.slug)};case"authors":return{label:Tt(e.name)||"Unnamed author",subtitle:Tt(e.email)};case"categories":return{label:Tt(e.name)||"Unnamed category",subtitle:Tt(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function Hg(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const r=ei(n);if(!r)continue;const o=tR(r.__resolveType);if(!o)continue;const a=ei(r[hu[o]])??{},{label:l,subtitle:c}=sR(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of uu)e[s].sort((n,r)=>n.label.localeCompare(r.label));return e}function nR(t,e){return Hg(t)[e]}function zo(t,e){return nR(t,e).map(s=>({key:s.key,payload:Ka(ei(t[s.key])??void 0,e)}))}const yf=Object.freeze({});function Ka(t,e){return t?ei(t[hu[e]])??yf:yf}function ka(t,e,s){return{name:t,__resolveType:Ug[e],[hu[e]]:s}}function Kg(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function SK({records:t,selected:e,valueField:s,toRef:n}){const r=Array.isArray(e)?e:[],o=f=>typeof f=="string"?f:Tt(ei(f)?.[s]),a=f=>typeof f=="string"?f:Tt(ei(f)?.name),l=f=>{const m=o(f),p=m?t.find(({payload:x})=>Tt(x[s])===m):void 0;if(p)return p;const g=a(f);return g?t.find(({payload:x})=>Tt(x.name)===g):void 0},c=t.map(({key:f,payload:m})=>({value:f,label:Tt(m.name)||Tt(m[s])||f})),d=new Map,h=[];return r.forEach((f,m)=>{const p=l(f);if(p){h.includes(p.key)||h.push(p.key);return}const g=`unresolved:${m}`;d.set(g,f),h.push(g),c.push({value:g,label:a(f)||o(f)||"Unknown"})}),{options:c,selectedValues:h,refsForValues:f=>f.map(m=>{const p=t.find(g=>g.key===m);return p?n(p.payload):d.get(m)}).filter(m=>m!==void 0)}}function Ci(t){return Array.isArray(t)?t:[]}function Nn(t){if(typeof t=="string")return t;const e=ei(t);return e?Tt(e.slug):""}function iR(t){if(typeof t=="string")return t;const e=ei(t);return e?Tt(e.email):""}function rR(t){const e=[];return Tt(t.title).trim()||e.push("Title"),Tt(t.slug).trim()||e.push("Slug"),Ci(t.categories).map(Nn).filter(Boolean).length===0&&e.push("Category"),Tt(t.excerpt).trim()||e.push("Excerpt"),Tt(t.image).trim()||e.push("Cover image"),e}function Wg(t){return zo(t,"posts").map(({key:e,payload:s})=>({key:e,title:Tt(s.title)||"Untitled post",slug:Tt(s.slug),date:Tt(s.date),categorySlugs:Ci(s.categories).map(Nn).filter(Boolean),authorEmails:Ci(s.authors).map(iR).filter(Boolean),missing:rR(s)}))}function oR(t,e){const s=Ci(t.categories);return s.some(n=>Nn(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function aR(t,e){const s=Ci(t.categories);return s.length===1&&Nn(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function wK(t,e,s){const n=Ci(t.categories);if(!n.some(l=>Nn(l)===e))return t;const r=n.map(l=>{const c=Nn(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=r.filter(l=>{const c=Nn(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function lR(t,e){const s=Ci(t.categories);return s.some(n=>Nn(n)===e)?{...t,categories:s.filter(n=>Nn(n)!==e)}:t}function Lf(t){return{...t,dateModified:new Date().toISOString()}}function Y0(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function Sf(t,e){const s=`collections/blog/${e}/${Y0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function cR(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${Y0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",type:"Person",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${Y0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const dR={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},wf="Box";function uR(t){return t.startsWith("site/")?"site":"app"}function hR(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function Gr(...t){for(const e of t)if(e!==void 0)return e}function jK(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const r of Object.values(n))for(const o of Object.keys(r)){if(!pR(o)||e.has(o))continue;e.add(o);const a=ri(o,t),l=fR(o),c=dR[l],d=uR(o),h=(d==="site"?Gr(a.title,c?.title):Gr(c?.title,a.title))??l,u=d==="site"?Gr(a.description,c?.description):Gr(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&hR(f)?f:void 0,p=m!==void 0?c?.iconName??wf:Gr(f,c?.iconName)??wf;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function fR(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const mR=["blog/sections/blocks/","site/sections/Blog/Post/"];function pR(t){return mR.some(e=>t.startsWith(e))}function qg({orgSlug:t,virtualMcpId:e,branch:s}){return it.decofile(`${t}/${e}/${s}`)}function gR({orgSlug:t,virtualMcpId:e,branch:s}){return it.liveMeta(t,e,s)}function xR({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}async function Gg(t,e,s,n){const r=await fetch(xR(t,e),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!r.ok){const o=await r.json().catch(()=>({}));throw new Error(o.error??`${n} (${r.status})`)}return r.json()}function vR(t){const e=M.c(11),s=bs();let n;e[0]!==t?(n=l=>{const{blockKey:c,data:d}=l;return Gg(t,"write",{path:Nr(t.packagePath,Kg(c)),content:JSON.stringify(d,null,2)},"Write failed")},e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:c,data:d}=l,h=qg(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==o?(a={mutationFn:n,onMutate:r,onError:o},e[7]=n,e[8]=r,e[9]=o,e[10]=a):a=e[10],Gs(a)}function bR(t){const e=bs();return Gs({mutationFn:({blockKey:s})=>Gg(t,"unlink",{path:Nr(t.packagePath,Kg(s))},"Delete failed"),onMutate:async({blockKey:s})=>{const n=qg(t);await e.cancelQueries({queryKey:n});const r=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:n}},onError:(s,n,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)},onSuccess:()=>{e.invalidateQueries({queryKey:gR(t)})}})}function _R({open:t,onOpenChange:e,pageKey:s,decofile:n,onSave:r}){const o=n[s],a=o===void 0,l=a?"":JSON.stringify(o,null,2),[c,d]=k.useState(!1),[h,u]=k.useState(l),[f,m]=k.useState(!1),p=!r||a,g=h!==l,x=()=>{navigator.clipboard.writeText(h).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)})},v=async _=>{if(!r||f)return;let b;try{b=JSON.parse(_)}catch{de.error("Invalid JSON — fix the syntax before saving.");return}m(!0);try{await r(b),de.success("Page JSON saved."),e(!1)}catch(y){de.error(`Save failed: ${y instanceof Error?y.message:String(y)}`)}finally{m(!1)}};return i.jsx(es,{open:t,onOpenChange:e,children:i.jsxs(Zt,{className:"max-w-3xl p-0 gap-0",children:[i.jsxs(us,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[i.jsx(hs,{className:"text-sm font-semibold",children:"Page JSON"}),i.jsxs("div",{className:"flex items-center gap-2 mr-8",children:[i.jsxs(re,{variant:"ghost",size:"sm",onClick:x,className:"h-7 gap-1.5 text-xs",children:[c?i.jsx(Yl,{size:12}):i.jsx(Ds,{size:12}),c?"Copied":"Copy"]}),!p&&i.jsx(re,{size:"sm",onClick:()=>v(h),disabled:!g||f,className:"h-7 text-xs",children:f?"Saving…":"Save"})]})]}),a?i.jsx("div",{className:"p-4 text-xs font-mono text-foreground/60",children:"// Page not found."}):i.jsx("div",{className:"h-[70vh]",children:i.jsx(ia,{code:l,language:"json",readOnly:p,height:"100%",onChange:_=>u(_??""),onSave:_=>{v(_)}})})]})})}function Xs(t){const e=M.c(45),{icon:s,logoUrl:n,title:r,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,invalid:m,invalidReason:p,onToggleSelect:g,onClick:x,menu:v}=t,_=l==="global";let b;e[0]!==s||e[1]!==a||e[2]!==_||e[3]!==n||e[4]!==c?(b=c&&c>1?i.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(s,{size:16,className:"shrink-0 text-success"})}),i.jsxs(De,{side:"right",children:[c," variants"]})]})}):n?i.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):i.jsx("span",{className:te("flex size-8 shrink-0 items-center justify-center rounded-lg",_?"bg-global-section/15":"bg-muted"),children:i.jsx(s,{size:16,className:te("shrink-0",!_&&(a?"text-accent-foreground":"text-muted-foreground")),style:_?{color:V9}:void 0})}),e[0]=s,e[1]=a,e[2]=_,e[3]=n,e[4]=c,e[5]=b):b=e[5];const y=b,L=a?_?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":_?"hover:bg-global-section/10":"hover:bg-muted";let w;e[6]!==L?(w=te("group relative flex min-w-0 items-center rounded-md transition-colors",L),e[6]=L,e[7]=w):w=e[7];let S;e[8]!==g||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(S=h&&i.jsx("span",{className:te("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:yR,children:i.jsx(kr,{checked:f,onCheckedChange:()=>g?.(),"aria-label":`Select ${r}`})}),e[8]=g,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=S):S=e[13];const j=m&&!a&&"text-destructive";let C;e[14]!==j?(C=te("block truncate text-sm font-medium",j),e[14]=j,e[15]=C):C=e[15];let V;e[16]!==C||e[17]!==r?(V=i.jsx("span",{className:C,children:r}),e[16]=C,e[17]=r,e[18]=V):V=e[18];const N=a?"text-accent-foreground/70":"text-muted-foreground";let T;e[19]!==N?(T=te("block truncate text-xs",N),e[19]=N,e[20]=T):T=e[20];let A;e[21]!==o||e[22]!==T?(A=i.jsx("span",{className:T,children:o}),e[21]=o,e[22]=T,e[23]=A):A=e[23];let E;e[24]!==A||e[25]!==V?(E=i.jsxs("span",{className:"min-w-0 flex-1",children:[V,A]}),e[24]=A,e[25]=V,e[26]=E):E=e[26];let R;e[27]!==a||e[28]!==m||e[29]!==p?(R=m&&i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:te("flex shrink-0 items-center",a?"text-accent-foreground":"text-destructive"),children:i.jsx(Sn,{size:14})})}),p&&i.jsx(De,{side:"bottom",children:p})]}),e[27]=a,e[28]=m,e[29]=p,e[30]=R):R=e[30];let D;e[31]!==x||e[32]!==y||e[33]!==E||e[34]!==R||e[35]!==d?(D=i.jsxs("button",{type:"button",onClick:x,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[y,E,R,d]}),e[31]=x,e[32]=y,e[33]=E,e[34]=R,e[35]=d,e[36]=D):D=e[36];let P;e[37]!==a||e[38]!==v?(P=v&&i.jsx("div",{className:te("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:v}),e[37]=a,e[38]=v,e[39]=P):P=e[39];let I;return e[40]!==D||e[41]!==P||e[42]!==w||e[43]!==S?(I=i.jsxs("div",{className:w,children:[S,D,P]}),e[40]=D,e[41]=P,e[42]=w,e[43]=S,e[44]=I):I=e[44],I}function yR(t){return t.stopPropagation()}function Un(t){const e=M.c(10),{icon:s,title:n,description:r}=t;let o;e[0]!==s?(o=s&&i.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=i.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&i.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}var LR=Qx.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(s=>e.updateAttributes(s,{textAlign:t})).some(s=>s):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:s})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?s.unsetTextAlign():s.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),SR=LR;const wR=new Set(["http:","https:","mailto:","tel:","ftp:"]);function jR(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return wR.has(e.protocol)}catch{return!1}}function CR(t){const e=t.trim();return e?e.startsWith("/")||e.startsWith(".")||e.startsWith("#")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)?e:`https://${e}`:""}const kR="noopener noreferrer nofollow";function xs(t){const e=M.c(8),{active:s,label:n,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=te("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==s||e[3]!==o||e[4]!==n||e[5]!==r||e[6]!==l?(c=i.jsx("button",{type:"button","aria-label":n,"aria-pressed":s,onMouseDown:VR,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=n,e[5]=r,e[6]=l,e[7]=c):c=e[7],c}function VR(t){return t.preventDefault()}function jf(t){const e=M.c(7),{active:s,label:n,onSelect:r}=t,o=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let a;e[0]!==o?(a=te("flex-1 rounded px-2 py-1 text-xs transition-colors cursor-pointer",o),e[0]=o,e[1]=a):a=e[1];let l;return e[2]!==s||e[3]!==n||e[4]!==r||e[5]!==a?(l=i.jsx("button",{type:"button","aria-pressed":s,onMouseDown:NR,onClick:r,className:a,children:n}),e[2]=s,e[3]=n,e[4]=r,e[5]=a,e[6]=l):l=e[6],l}function NR(t){return t.preventDefault()}function AR(t){const e=M.c(32),{editor:s,active:n,open:r,onOpenChange:o}=t,[a,l]=k.useState(""),[c,d]=k.useState(!0),[h,u]=k.useState(!1);let f;e[0]!==n||e[1]!==s||e[2]!==o?(f=()=>{const C=s.getAttributes("link");l(typeof C.href=="string"?C.href:""),d(n?C.target==="_blank":!0),u(!1),o(!0)},e[0]=n,e[1]=s,e[2]=o,e[3]=f):f=e[3];const m=f;let p;e[4]!==s||e[5]!==o?(p=()=>{o(!1),s.chain().focus().run()},e[4]=s,e[5]=o,e[6]=p):p=e[6];const g=p;let x;e[7]!==a||e[8]!==s||e[9]!==c||e[10]!==o?(x=()=>{const C=CR(a);if(C===""){s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1);return}if(!jR(C)){u(!0);return}s.chain().focus().extendMarkRange("link").setLink({href:C,target:c?"_blank":null,rel:c?kR:null}).run(),o(!1)},e[7]=a,e[8]=s,e[9]=c,e[10]=o,e[11]=x):x=e[11];const v=x;let _;e[12]!==s||e[13]!==o?(_=()=>{s.chain().focus().extendMarkRange("link").unsetLink().run(),o(!1)},e[12]=s,e[13]=o,e[14]=_):_=e[14];const b=_,y=r?g:m;let L;e[15]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(Hm,{size:14}),e[15]=L):L=e[15];let w;e[16]!==n||e[17]!==y?(w=i.jsx(xs,{active:n,label:"Link",onClick:y,children:L}),e[16]=n,e[17]=y,e[18]=w):w=e[18];let S;e[19]!==n||e[20]!==v||e[21]!==g||e[22]!==a||e[23]!==h||e[24]!==c||e[25]!==o||e[26]!==r||e[27]!==b?(S=r&&i.jsxs("div",{className:"absolute left-0 top-full z-20 mt-1.5 flex w-64 flex-col gap-1 rounded-md border bg-popover p-1 shadow-md",onBlur:C=>{C.currentTarget.contains(C.relatedTarget)||o(!1)},children:[i.jsxs("div",{className:"flex items-center gap-0.5",children:[i.jsx("input",{autoFocus:!0,type:"text","aria-label":"Link URL","aria-invalid":h,placeholder:"Paste or type a link…",value:a,onChange:C=>{l(C.target.value),u(!1)},onKeyDown:C=>{C.key==="Enter"?(C.preventDefault(),v()):C.key==="Escape"&&(C.preventDefault(),g())},className:te("h-7 flex-1 rounded bg-transparent px-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none",h&&"text-destructive")}),i.jsx(xs,{active:!1,label:"Apply link",onClick:v,children:i.jsx(Ot,{size:14})}),n&&i.jsx(xs,{active:!1,label:"Remove link",onClick:b,children:i.jsx(ks,{size:14})})]}),i.jsxs("div",{className:"flex items-center gap-0.5 rounded bg-muted/40 p-0.5",children:[i.jsx(jf,{active:!c,label:"Same tab",onSelect:()=>d(!1)}),i.jsx(jf,{active:c,label:"New tab",onSelect:()=>d(!0)})]})]}),e[19]=n,e[20]=v,e[21]=g,e[22]=a,e[23]=h,e[24]=c,e[25]=o,e[26]=r,e[27]=b,e[28]=S):S=e[28];let j;return e[29]!==w||e[30]!==S?(j=i.jsxs("div",{className:"relative",children:[w,S]}),e[29]=w,e[30]=S,e[31]=j):j=e[31],j}function TR({schema:t,value:e,onChange:s,path:n,label:r}){const o=typeof e=="string"?e:"",a=k.useRef(s);a.current=s;const[l,c]=k.useState(!1),d=vm({extensions:[cm.configure({heading:{levels:[1,2,3]},link:{HTMLAttributes:{}}}),SR.configure({types:["heading","paragraph"]})],content:o||"",editorProps:{attributes:{class:te("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:u})=>{const f=u.getHTML();a.current(f==="<p></p>"?"":f)}}),h=Zx({editor:d,selector:({editor:u})=>({bold:u?.isActive("bold")??!1,italic:u?.isActive("italic")??!1,underline:u?.isActive("underline")??!1,strike:u?.isActive("strike")??!1,h1:u?.isActive("heading",{level:1})??!1,h2:u?.isActive("heading",{level:2})??!1,bulletList:u?.isActive("bulletList")??!1,orderedList:u?.isActive("orderedList")??!1,link:u?.isActive("link")??!1,alignLeft:u?.isActive({textAlign:"left"})??!1,alignCenter:u?.isActive({textAlign:"center"})??!1,alignRight:u?.isActive({textAlign:"right"})??!1,alignJustify:u?.isActive({textAlign:"justify"})??!1})});return d?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(rt,{htmlFor:n,children:r}),t.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),i.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[i.jsx(xs,{active:h.bold,label:"Bold",onClick:()=>d.chain().focus().toggleBold().run(),children:i.jsx(Hv,{size:14})}),i.jsx(xs,{active:h.italic,label:"Italic",onClick:()=>d.chain().focus().toggleItalic().run(),children:i.jsx(Kv,{size:14})}),i.jsx(xs,{active:h.underline,label:"Underline",onClick:()=>d.chain().focus().toggleUnderline().run(),children:i.jsx(Wv,{size:14})}),i.jsx(xs,{active:h.strike,label:"Strikethrough",onClick:()=>d.chain().focus().toggleStrike().run(),children:i.jsx(qv,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(xs,{active:h.h1,label:"Heading 1",onClick:()=>d.chain().focus().toggleHeading({level:1}).run(),children:i.jsx(Gv,{size:14})}),i.jsx(xs,{active:h.h2,label:"Heading 2",onClick:()=>d.chain().focus().toggleHeading({level:2}).run(),children:i.jsx(Yv,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(xs,{active:h.bulletList,label:"Bullet list",onClick:()=>d.chain().focus().toggleBulletList().run(),children:i.jsx(T6,{size:14})}),i.jsx(xs,{active:h.orderedList,label:"Ordered list",onClick:()=>d.chain().focus().toggleOrderedList().run(),children:i.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(AR,{editor:d,active:h.link,open:l,onOpenChange:c}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(xs,{active:h.alignLeft,label:"Align left",onClick:()=>d.chain().focus().setTextAlign("left").run(),children:i.jsx(N6,{size:14})}),i.jsx(xs,{active:h.alignCenter,label:"Align center",onClick:()=>d.chain().focus().setTextAlign("center").run(),children:i.jsx(Jv,{size:14})}),i.jsx(xs,{active:h.alignRight,label:"Align right",onClick:()=>d.chain().focus().setTextAlign("right").run(),children:i.jsx(Xv,{size:14})}),i.jsx(xs,{active:h.alignJustify,label:"Justify",onClick:()=>d.chain().focus().setTextAlign("justify").run(),children:i.jsx(Qv,{size:14})})]}),i.jsx(bm,{editor:d})]})]}):null}const Gi=t=>String(t).padStart(2,"0"),ER="1900-01-01",RR="2099-12-31",PR="1900-01-01T00:00",IR="2099-12-31T23:59";function DR(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${Gi(s.getUTCMonth()+1)}-${Gi(s.getUTCDate())}`}function OR(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function MR(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Gi(e.getMonth()+1)}-${Gi(e.getDate())}T${Gi(e.getHours())}:${Gi(e.getMinutes())}`}function $R(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function BR(t){const e=M.c(29),{id:s,withTime:n,value:r,onChange:o}=t,[a,l]=k.useState(!1);let c;e[0]!==r||e[1]!==n?(c=n?MR(r):DR(r),e[0]=r,e[1]=n,e[2]=c):c=e[2];const d=c;let h;e[3]!==o||e[4]!==n?(h=C=>{o(n?$R(C.target.value):OR(C.target.value))},e[3]=o,e[4]=n,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const C=r?new Date(r):null;f=C&&!Number.isNaN(C.getTime())?C:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==n?(p=C=>{C&&(n&&m?C.setHours(m.getHours(),m.getMinutes(),0,0):C.setHours(0,0,0,0),o(C.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=n,e[11]=p):p=e[11];const g=p,x=n?"datetime-local":"date",v=n?PR:ER,_=n?IR:RR;let b;e[12]!==u||e[13]!==s||e[14]!==d||e[15]!==x||e[16]!==v||e[17]!==_?(b=i.jsx(tt,{id:s,type:x,min:v,max:_,value:d,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=d,e[15]=x,e[16]=v,e[17]=_,e[18]=b):b=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(As,{asChild:!0,children:i.jsx(re,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:i.jsx(Xd,{className:"h-4 w-4"})})}),e[19]=y):y=e[19];const L=m??void 0;let w;e[20]!==g||e[21]!==L?(w=i.jsx(Ts,{className:"w-auto p-0",align:"end",children:i.jsx(ev,{mode:"single",selected:L,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=L,e[22]=w):w=e[22];let S;e[23]!==a||e[24]!==w?(S=i.jsxs(Ns,{open:a,onOpenChange:l,children:[y,w]}),e[23]=a,e[24]=w,e[25]=S):S=e[25];let j;return e[26]!==S||e[27]!==b?(j=i.jsxs("div",{className:"flex gap-1",children:[b,S]}),e[26]=S,e[27]=b,e[28]=j):j=e[28],j}function Va(t){const e=M.c(8),{htmlFor:s,label:n,description:r}=t;let o;e[0]!==s||e[1]!==n?(o=i.jsx(rt,{htmlFor:s,children:n}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function Na(t){const e=M.c(67),{schema:s,value:n,onChange:r,path:o,label:a}=t,l=typeof n=="string"?n:"",c=s.format;if(c==="rich-text"||c==="rich-text-inline"||c==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n?(g=i.jsx(TR,{schema:s,value:n,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=g):g=e[5],g}if(c==="textarea"||c==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=i.jsx(Va,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let x;e[10]!==r?(x=b=>r(b.target.value),e[10]=r,e[11]=x):x=e[11];let v;e[12]!==o||e[13]!==l||e[14]!==x?(v=i.jsx(ur,{id:o,value:l,onChange:x,rows:4}),e[12]=o,e[13]=l,e[14]=x,e[15]=v):v=e[15];let _;return e[16]!==g||e[17]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[g,v]}),e[16]=g,e[17]=v,e[18]=_):_=e[18],_}if(c==="date"||c==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=i.jsx(Va,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const x=c==="date-time";let v;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==x?(v=i.jsx(BR,{id:o,withTime:x,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=x,e[27]=v):v=e[27];let _;return e[28]!==g||e[29]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[g,v]}),e[28]=g,e[29]=v,e[30]=_):_=e[30],_}if(c==="color-input"||c==="color"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=i.jsx(Va,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const x=l||"#000000";let v;e[35]!==r?(v=S=>r(S.target.value),e[35]=r,e[36]=v):v=e[36];let _;e[37]!==x||e[38]!==v?(_=i.jsx("input",{type:"color",value:x,onChange:v,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=x,e[38]=v,e[39]=_):_=e[39];let b;e[40]!==r?(b=S=>r(S.target.value),e[40]=r,e[41]=b):b=e[41];let y;e[42]!==o||e[43]!==l||e[44]!==b?(y=i.jsx(tt,{id:o,value:l,onChange:b,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=b,e[45]=y):y=e[45];let L;e[46]!==_||e[47]!==y?(L=i.jsxs("div",{className:"flex items-center gap-2",children:[_,y]}),e[46]=_,e[47]=y,e[48]=L):L=e[48];let w;return e[49]!==g||e[50]!==L?(w=i.jsxs("div",{className:"space-y-2",children:[g,L]}),e[49]=g,e[50]=L,e[51]=w):w=e[51],w}let d;e[52]!==a||e[53]!==o||e[54]!==s.description?(d=i.jsx(Va,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=d):d=e[55];const h=c==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=i.jsx(tt,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==d||e[65]!==m?(p=i.jsxs("div",{className:"space-y-2",children:[d,m]}),e[64]=d,e[65]=m,e[66]=p):p=e[66],p}const zR=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function FR(t){const e=M.c(18),{schema:s,value:n,onChange:r,path:o,label:a}=t,l=typeof n=="number"?String(n):"",[c,d]=k.useState(l),[h,u]=k.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=i.jsx(rt,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=f):f=e[2];let m;e[3]!==s.description?(m=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=m):m=e[4];let p;e[5]!==f||e[6]!==m?(p=i.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[5]=f,e[6]=m,e[7]=p):p=e[7];const g=s.type==="integer"?"numeric":"decimal";let x;e[8]!==r?(x=b=>{const y=b.target.value;if(y!==""&&!zR.test(y))return;d(y);const L=Number(y);r(y===""||Number.isNaN(L)?void 0:L)},e[8]=r,e[9]=x):x=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==x?(v=i.jsx(tt,{id:o,type:"text",inputMode:g,value:c,onChange:x,className:"h-10"}),e[10]=o,e[11]=c,e[12]=g,e[13]=x,e[14]=v):v=e[14];let _;return e[15]!==p||e[16]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=_):_=e[17],_}function UR(t){const e=M.c(17),{value:s,onChange:n,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==r?(c=i.jsx(rt,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=d):d=e[4];let h;e[5]!==c||e[6]!==d?(h=i.jsxs("div",{className:"space-y-0.5",children:[c,d]}),e[5]=c,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==n?(u=p=>n(p),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=i.jsx(hr,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const fu="__enum_empty__";function mu(t){return t===""?fu:String(t)}function HR(t,e){if(t===fu)return"";const s=e.find(n=>mu(n)===t);return s!==void 0?s:t}function KR(t,e){return t==null?e.some(s=>s==="")?fu:void 0:mu(t)}function WR(t){return t===""?"":String(t)}function qR(t){const e=M.c(28),{schema:s,value:n,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const c=l;let d;e[2]!==c||e[3]!==n?(d=KR(n,c),e[2]=c,e[3]=n,e[4]=d):d=e[4];const h=d;let u;e[5]!==a||e[6]!==o?(u=i.jsx(rt,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=i.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==c?(p=y=>r(HR(y,c)),e[13]=r,e[14]=c,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(Xt,{className:"h-10",children:i.jsx(rs,{placeholder:"Select..."})}),e[16]=g):g=e[16];let x;e[17]!==c?(x=c.map(GR),e[17]=c,e[18]=x):x=e[18];let v;e[19]!==x?(v=i.jsx(Yt,{children:x}),e[19]=x,e[20]=v):v=e[20];let _;e[21]!==h||e[22]!==p||e[23]!==v?(_=i.jsxs(Jt,{value:h,onValueChange:p,children:[g,v]}),e[21]=h,e[22]=p,e[23]=v,e[24]=_):_=e[24];let b;return e[25]!==_||e[26]!==m?(b=i.jsxs("div",{className:"space-y-2",children:[m,_]}),e[25]=_,e[26]=m,e[27]=b):b=e[27],b}function GR(t){const e=mu(t);return i.jsx(pt,{value:e,children:WR(t)},e)}function Yg(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return Array.isArray(e.variants)?e:null}function wo(t){return Yg(t)?.variants?.[0]?.rule?.__resolveType===Ar}function Cf(t){return{__resolveType:Mi,variants:[{value:t,rule:{__resolveType:Ar}}]}}function Jg(t){return wo(t)?Yg(t)?.variants?.[0]?.value:t}function co(t){return wo(t)?Jg(t):t}function pu(t){const e=t.__resolveType;if(typeof e!="string")return null;if(ds(e)){const n=t.section?.__resolveType;return typeof n=="string"?n:e}return e}function YR(t){return t.includes("flags/multivariate")}function JR(t){return Ct(t)}function XR(t,e){const s=[...t],n=new Set(s.map(o=>o.resolveType)),r=(o,a)=>{!o||n.has(o)||(n.add(o),s.push({resolveType:o,title:a??JR(o)}))};if(e.savedBlockKey&&r(e.savedBlockKey,e.savedBlockKey),e.editorValue&&typeof e.editorValue=="object"&&!Array.isArray(e.editorValue)){const o=pu(e.editorValue);o?.includes("/")&&r(o)}return s}function QR(t,e,s){const n=e[0]?.resolveType??"";if(s)return s;if(!t||typeof t!="object"||Array.isArray(t))return n;const r=t,o=r.__resolveType;if(typeof o=="string"){if(bn(o)){const u=e.find(f=>f.resolveType===o);return u?u.resolveType:o}const d=e.find(u=>Ch(u.resolveType,o));if(d)return d.resolveType;const h=e.find(u=>u.resolveType===o);if(h)return h.resolveType;if(o.includes("/"))return o}const a=typeof r.type=="string"?r.type:void 0;if(a){const d=e.find(h=>h.discriminatorValue===a||h.resolveType===a||Ch(h.resolveType,a));if(d)return d.resolveType}let l=n,c=-1;for(const d of e){if(!d.schema?.properties)continue;const u=Object.keys(d.schema.properties).filter(f=>!f.startsWith("__")&&f!=="@type"&&f!=="action"&&f!=="alt").filter(f=>r[f]!==void 0).length;u>0&&u>c&&(c=u,l=d.resolveType)}return c>0,l}function kf(t,e,s){if(!t||typeof t!="object"||Array.isArray(t))return s??null;const n=pu(t);if(!n)return s??null;if(!e)return n.includes("/")?null:s??null;const r=_n(n,e);return r||(n.includes("/")?null:s??null)}function ZR(t,e){if(!t?.properties||!e)return t??null;if(!(e in t.properties))return t;const s={...t.properties};return delete s[e],{...t,properties:s}}function Xg(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;if(typeof e.__resolveType!="string"||!ds(e.__resolveType))return null;const s=e.section;return!s||typeof s!="object"||Array.isArray(s)?null:s}function eP(t,e){if(e)return!0;if(!t||typeof t!="object"||Array.isArray(t))return!1;const s=t,n=pu(s);return n&&YR(n)?Array.isArray(s.variants)&&s.variants.length>0:Object.keys(s).some(r=>!r.startsWith("__")&&r!=="@type")}function gu(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";const e=t;if(Array.isArray(e.variants)){const s=e.variants,n=s.find(o=>o.rule?.__resolveType?.includes("always"));if(typeof n?.value=="string")return n.value;const r=s.find(o=>typeof o.value=="string");if(r)return r.value}return typeof e.src=="string"?e.src:typeof e.url=="string"?e.url:typeof e.value=="string"?e.value:""}function tP(t){if(t?.trim())try{const e=new URL(t);return e.protocol!=="https:"?void 0:e.href}catch{return}}function sP(t){if(Array.isArray(t.variants)){const e=t.variants,s=e.find(r=>r.rule?.__resolveType?.includes("always"));if(typeof s?.value=="string")return s.value;const n=e.find(r=>typeof r.value=="string");if(n)return n.value}if(typeof t.src=="string")return t.src;if(typeof t.url=="string")return t.url;if(typeof t.value=="string")return t.value}function Qg(t){if(typeof t=="string"||t==null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Qg);const e=t;return e.__resolveType?sP(e)??t:Zg(e)}function Zg(t){const e={};for(const[s,n]of Object.entries(t))e[s]=Qg(n);return e}function nP(t,e){return e.split(".").reduce((s,n)=>{if(!(s==null||typeof s!="object"))return s[n]},t)}function e4(t){return t==null?"":Array.isArray(t)?t.map(e4).filter(Boolean).join(","):typeof t=="object"?"":String(t)}function xu(t,e){if(!t.includes("{"))return;const s=Zg(e);return t.replace(/\{\{\{([^}]+)\}\}\}|\{\{([^}]+)\}\}/g,(r,o,a)=>{const l=(o??a??"").trim();return e4(nP(s,l))}).trim()||void 0}function iP(t){return t.replace(/<[^>]*>/g,"").trim()}function rP(t,e){if(e.includes("{"))return xu(e,t);const s=t[e];if(typeof s=="string"&&s)return s;if(Array.isArray(s)){const n=s.map(r=>r==null?"":String(r)).filter(Boolean).join(",");if(n)return n}}function mi(t,e,s){if(typeof t=="string")return t.trim()?t:`Item ${e+1}`;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=co(t);const r=Xg(n);if(r&&(n=r),s?.titleBy){const a=rP(n,s.titleBy);if(a)return a}for(const a of["name","label","title","alt","text","href","id","key"]){const l=n[a];if(typeof l=="string"&&l.trim()){const c=s?.properties?.[a]?.format;if(c==="rich-text"||c==="html"){const d=iP(l);if(d)return d;continue}return l}if(Array.isArray(l)){const c=l.map(d=>d==null?"":String(d)).filter(Boolean).join(",");if(c)return c}}const o=n.__resolveType;if(typeof o=="string"&&o)return Ct(o);if(s?.title){const a=xu(s.title,n);if(a)return a;if(!s.title.includes("{"))return s.title}}return`Item ${e+1}`}function oP(t){if(!t)return;if(typeof t.image=="string"&&t.image.includes("{"))return t.image;const e=t.properties?.image;if(!e)return;if(e.format==="image-uri")return"{{{image}}}";const s=e.properties;return s?.mobile?"{{{image.mobile}}}":s?.desktop?"{{{image.desktop}}}":"{{{image}}}"}function Vf(t,e){if(!t||typeof t!="object"||Array.isArray(t))return;const s=oP(e);if(!s)return;const n=xu(s,t);if(!n)return;const r=gu(n)||n;return tP(r)}function t4(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").replace(/^\w/,e=>e.toUpperCase())}function ki(t){return t.normalize("NFC").trim()}function zt(t,e){return ki(t)===ki(e)}function Nf(t,e){return ki(t).replace(/\s+/g,"").toLowerCase()===ki(e).replace(/\s+/g,"").toLowerCase()}function aP(t,e,s){return(s?.hasSiblingDrillDownFields??!1)||zt(e,t)||s?.arrayKey!=null&&zt(e,s.arrayKey)}function Aa(t,e,s,n){const r=ki(s);if(t.some(a=>zt(a,r)||zt(a,s)))return t;const o=[...t];return aP(e,s,n)&&!o.some(a=>zt(a,e))&&o.push(e),o.push(s),o}function lP(t,e){return t.slice(0,t.length-e.length)}function cP(t,e,s){if(s.length===0)return s;const n=jo(t,e),r=s[0];return zt(r,n)||zt(r,t)?s.slice(1):s}function jo(t,e){return e.title??t4(t)}function CK(t,e){return e<=0?[]:t.slice(0,e)}function Af(t,e){const s=ki(e);return t.findIndex(n=>ki(n)===s)}function J0(t,e){return t.type==="array"&&t.items||bc(t)?!0:Array.isArray(e)}function dP(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Fo(t,e,s,n){if(n.length===0)return null;const r=n[0];for(const a of t){const l=e[a];if(!l||!J0(l,s[a]))continue;const c=jo(a,l);if(zt(r,c)||zt(r,a)||n.some(d=>zt(d,c)||zt(d,a)))return a}for(const a of t){const l=e[a];if(!l||!J0(l,s[a]))continue;const c=s[a];if(!Array.isArray(c))continue;const d=l.items;for(let h=0;h<c.length;h++){const u=mi(c[h],h,d);if(zt(u,r))return a}}for(const a of t){const l=e[a];if(l?.type!=="object"||!l.properties)continue;const c=Object.keys(l.properties),d=dP(s[a]),h=jo(a,l);if(Fo(c,l.properties,d,n)||(zt(r,h)||zt(r,a))&&Fo(c,l.properties,d,n.slice(1)))return a}let o=null;for(const a of t){const l=e[a];if(l?.type!=="block-ref")continue;const c=jo(a,l);if(!(r!==c&&r!==a)){if(n.length>1){const d=s[a];if(d&&typeof d=="object"&&!Array.isArray(d)){const h=n[1];if(Object.keys(d).some(f=>!f.startsWith("__")&&(Nf(t4(f),h)||Nf(f,h))))return a}}o||(o=a)}}return o||null}function uP(t,e,s,n){return Fo(t,e,s,n)}function hP(t,e,s,n,r){if(r.length===0||!s.properties)return!1;const o=Object.keys(s.properties);if(Fo(o,s.properties,n,r))return!0;const a=r[0];return!zt(a,e)&&!zt(a,t)?!1:r.length>1||Fo(o,s.properties,n,r.slice(1))!==null}function Tf(t,e,s,n){return n!=null&&n>=0&&n<t.length&&zt(mi(t[n],n,e),s)?n:t.findIndex((r,o)=>zt(mi(r,o,e),s))}function fP(t,e,s,n,r){if(e.length===0)return null;for(let a=0;a<e.length;a++){const l=e[a],c=Tf(s,n,l,r);if(c>=0)return{index:c,innerPath:e.slice(a+1)}}const o=e.findIndex(a=>zt(a,t));if(o>=0&&e.length>o+1){const a=e[o+1],l=Tf(s,n,a,r);if(l>=0)return{index:l,innerPath:e.slice(o+2)}}return null}function s0(t){return t.includes("/sections/")||t.includes("multivariate/section")||t===Tr}function mP(t){if(t.type==="block-ref"&&t.anyOfRefs?.length)return t.anyOfRefs.some(s=>s0(s.resolveType));if(t.anyOfRefs?.length)return t.anyOfRefs.some(s=>s0(s.resolveType));const e=t.properties?.__resolveType;return e?.type==="block-ref"&&e.anyOfRefs?.length?e.anyOfRefs.some(s=>s0(s.resolveType)):!1}function pP(t,e){if(e==="global"||e==="sections"||bc(t))return!0;const s=t.type==="array"?t.items:void 0;return s?mP(s):!1}function Ef(t){return Array.from({length:t},(e,s)=>({id:crypto.randomUUID(),index:s}))}function s4(t){return t.map((e,s)=>({...e,index:s}))}function gP(t,e){if(e===t.length)return t;if(e<t.length)return s4(t.slice(0,e));const s=Array.from({length:e-t.length},(n,r)=>({id:crypto.randomUUID(),index:t.length+r}));return[...t,...s]}function xP(t,e){const s=t.findIndex(o=>o.index===e),n=t.map(o=>o.index>e?{...o,index:o.index+1}:o),r={id:crypto.randomUUID(),index:e+1};return s===-1?[...n,r]:[...n.slice(0,s+1),r,...n.slice(s+1)]}function vP(t,e){return t.filter(s=>s.index!==e).map(s=>s.index>e?{...s,index:s.index-1}:s)}function bP(t){const e=M.c(8),{labelText:s,imageSrc:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(na,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[0]=r):r=e[0];let o;e[1]!==n?(o=n&&i.jsx("img",{src:n,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[1]=n,e[2]=o):o=e[2];let a;e[3]!==s?(a=i.jsx("span",{className:"min-w-0 truncate",children:s}),e[3]=s,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=i.jsxs(i.Fragment,{children:[r,i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-sm",children:[o,a]})]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function _P(t){const e=M.c(50),{sortableId:s,labelText:n,imageSrc:r,hidden:o,onToggleHidden:a,onOpen:l,onDuplicate:c,onRemove:d}=t;let h;e[0]!==s?(h={id:s,animateLayoutChanges:wP},e[0]=s,e[1]=h):h=e[1];const{attributes:u,listeners:f,setNodeRef:m,transform:p,isDragging:g}=Z9(h);let x;e[2]!==p?(x=yn.Transform.toString(p?{...p,x:0}:null),e[2]=p,e[3]=x):x=e[3];const v=g?0:void 0;let _;e[4]!==x||e[5]!==v?(_={transform:x,opacity:v},e[4]=x,e[5]=v,e[6]=_):_=e[6];const b=_;let y;e[7]!==l?(y=U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),l())},e[7]=l,e[8]=y):y=e[8];const L=g?"cursor-grabbing":"cursor-pointer";let w;e[9]!==L?(w=te("group flex min-w-0 items-center gap-2.5 rounded-lg px-2 py-2.5 hover:bg-accent hover:text-accent-foreground touch-none",L),e[9]=L,e[10]=w):w=e[10];let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(na,{className:"size-3.5 shrink-0 text-muted-foreground/40"}),e[11]=S):S=e[11];let j;e[12]!==r?(j=r&&i.jsx("img",{src:r,alt:"",referrerPolicy:"no-referrer",className:"h-12 max-w-[100px] shrink-0 rounded object-cover"}),e[12]=r,e[13]=j):j=e[13];const C=o&&"line-through opacity-50";let V;e[14]!==C?(V=te("min-w-0 flex-1 truncate text-sm",C),e[14]=C,e[15]=V):V=e[15];let N;e[16]!==n||e[17]!==V?(N=i.jsx("span",{className:V,children:n}),e[16]=n,e[17]=V,e[18]=N):N=e[18];let T;e[19]!==o||e[20]!==a?(T=a&&i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":o?"Show item":"Hide item",className:te("size-6 shrink-0",o?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100"),onClick:U=>{U.stopPropagation(),a()},onPointerDown:SP,children:o?i.jsx(ab,{size:14}):i.jsx(c2,{size:14})})}),i.jsx(De,{side:"bottom",children:o?"Show item":"Hide item"})]}),e[19]=o,e[20]=a,e[21]=T):T=e[21];const A=`Open actions for ${n}`;let E;e[22]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(ni,{size:14}),e[22]=E):E=e[22];let R;e[23]!==A?(R=i.jsx(ls,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":A,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:LP,onPointerDown:yP,children:E})}),e[23]=A,e[24]=R):R=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx(Ds,{size:14}),e[25]=D):D=e[25];let P;e[26]!==c?(P=i.jsxs(Ge,{onClick:c,children:[D,"Duplicate"]}),e[26]=c,e[27]=P):P=e[27];let I;e[28]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(ks,{size:14}),e[28]=I):I=e[28];let O;e[29]!==d?(O=i.jsxs(Ge,{className:"text-destructive focus:text-destructive",onClick:d,children:[I,"Delete"]}),e[29]=d,e[30]=O):O=e[30];let B;e[31]!==P||e[32]!==O?(B=i.jsxs(cs,{align:"end",children:[P,O]}),e[31]=P,e[32]=O,e[33]=B):B=e[33];let z;e[34]!==R||e[35]!==B?(z=i.jsxs(as,{children:[R,B]}),e[34]=R,e[35]=B,e[36]=z):z=e[36];let $;return e[37]!==u||e[38]!==n||e[39]!==f||e[40]!==l||e[41]!==m||e[42]!==b||e[43]!==N||e[44]!==T||e[45]!==z||e[46]!==y||e[47]!==w||e[48]!==j?($=i.jsxs("div",{ref:m,style:b,...u,...f,role:"button",tabIndex:0,onClick:l,onKeyDown:y,className:w,title:n,children:[S,j,N,T,z]}),e[37]=u,e[38]=n,e[39]=f,e[40]=l,e[41]=m,e[42]=b,e[43]=N,e[44]=T,e[45]=z,e[46]=y,e[47]=w,e[48]=j,e[49]=$):$=e[49],$}function yP(t){return t.stopPropagation()}function LP(t){return t.stopPropagation()}function SP(t){return t.stopPropagation()}function wP(){return!1}function jP(t,e,s,n,r){if(e?.type==="object"&&e.properties&&Object.keys(e.properties).length>0||e?.type==="block-ref"&&e.anyOfRefs?.length)return e;if(t!=null&&typeof t=="object"&&!Array.isArray(t)){const o=t.__resolveType;if(typeof o=="string"&&s){const a=_n(o,s);if(a?.properties&&Object.keys(a.properties).length>0)return a}}if(s&&n&&r){const a=_n(n,s)?.properties?.[r]?.items;if(a?.properties&&Object.keys(a.properties).length>0)return{...a,titleBy:a.titleBy??e?.titleBy}}return e}function CP(t){const e=t.split(".").filter(s=>!/^\d+$/.test(s));return e[e.length-1]??t}function Ta(t){const e=M.c(24),{schema:s,value:n,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,hasSiblingDrillDownFields:d,meta:h,decofile:u,onSaveReferencedBlock:f,containerResolveType:m,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}=t,_=l===void 0?[]:l,b=Array.isArray(n)?n:[],y=s.items,L=CP(o),w={arrayKey:L,hasSiblingDrillDownFields:d},S=pP(s,L),j=!S&&y?.type==="object",[C,V]=k.useState(null),N=fP(a,_,b,y,C),T=N?.index??null;N===null?C!==null&&V(null):N.index!==C&&V(N.index);const[A,E]=k.useState(()=>Ef(b.length)),[R,D]=k.useState(null),[P,I]=k.useState(o),[O,B]=k.useState(b.length),z=k.useRef(!1);P!==o?(I(o),B(b.length),E(Ef(b.length)),V(null)):O!==b.length&&(B(b.length),E(pe=>gP(pe,b.length)));let $;e[0]!==y?($=(pe,ke)=>mi(co(pe),ke,y),e[0]=y,e[1]=$):$=e[1];const U=$,W=pe=>{if(z.current)return;const ke=U(b[pe],pe);V(pe),c?.(Aa(_,a,ke,w))},X=pe=>{const ke=[...b,pe];r(ke);const $e=ke.length-1;V($e);const ge=mi(pe,$e,y);c?.(Aa(_,a,ge,w))},H=()=>{const pe=y?.type,ke=y?.default!==void 0?y.default:pe==="object"?{}:pe==="block-ref"?(()=>{const gt=y?.anyOfRefs?.[0]?.resolveType;return typeof gt!="string"||vo(gt)?{}:{__resolveType:gt}})():pe==="number"||pe==="integer"?0:pe==="boolean"?!1:pe==="array"?[]:"",$e=[...b,ke];r($e);const ge=$e.length-1;V(ge);const Ke=mi(ke,ge,y);c?.(Aa(_,a,Ke,w))},Z=()=>{if(S){if(!p){de.error("Start the preview dev server to add sections.");return}if(x){x({append:X});return}de.error("Section picker is not available in this editor.");return}H()},K=pe=>{const ke=b[pe],$e=typeof structuredClone=="function"?structuredClone(ke):JSON.parse(JSON.stringify(ke??null)),ge=[...b.slice(0,pe+1),$e,...b.slice(pe+1)];r(ge),E(Ke=>xP(Ke,pe))},Y=pe=>{const ke=b[pe],$e=[...b];$e[pe]=wo(ke)?Jg(ke):Cf(ke),r($e)},F=pe=>{r(b.filter((ke,$e)=>$e!==pe)),E(ke=>vP(ke,pe))},Q=(pe,ke)=>{const $e=[...b];if($e[pe]=wo(b[pe])?Cf(ke):ke,r($e),pe===T&&T!==null){const ge=U(b[pe],pe),Ke=mi(ke,pe,y);if(ge!==Ke){const gt=Af(_,ge);if(gt>=0){const nt=[..._];nt[gt]=Ke,c?.(nt)}}}};let J;e[2]===Symbol.for("react.memo_cache_sentinel")?(J={activationConstraint:{distance:8}},e[2]=J):J=e[2];let ee;e[3]===Symbol.for("react.memo_cache_sentinel")?(ee={coordinateGetter:eu},e[3]=ee):ee=e[3];const q=dc(Zn(Dr,J),Zn(Ir,ee)),se=A.map(kP);let ne;e[4]===Symbol.for("react.memo_cache_sentinel")?(ne=pe=>{D(String(pe.active.id))},e[4]=ne):ne=e[4];const le=ne,G=pe=>{D(null);const{active:ke,over:$e}=pe;if(!$e||ke.id===$e.id)return;const ge=se.indexOf(String(ke.id)),Ke=se.indexOf(String($e.id));ge===-1||Ke===-1||(E(gt=>s4(gr([...gt],ge,Ke))),r(gr([...b],ge,Ke)),z.current=!0,requestAnimationFrame(()=>{z.current=!1}))};let oe;e[5]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>{D(null)},e[5]=oe):oe=e[5];const me=oe,ue=R?A.find(pe=>pe.id===R):null,ye=ue!=null?b[ue.index]:void 0,Le=ue!=null&&ye!==void 0?U(ye,ue.index):null,Ce=ue!=null&&ye!==void 0?Vf(co(ye),y):void 0;if(T!==null&&T<b.length){const pe=co(b[T]),ke=jP(pe,y,h,m,L),$e=()=>{const ge=U(pe,T),Ke=Aa(_,a,ge,w),gt=Af(Ke,ge);return gt>=0?Ke.slice(0,gt+1):Ke};return i.jsx("div",{className:"min-w-0",children:ke?.type==="object"&&ke.properties?i.jsx(Pn,{schema:ke,value:pe,onChange:ge=>Q(T,ge),basePath:`${o}.${T}`,breadcrumbPath:N?.innerPath??[],onBreadcrumbChange:ge=>{c?.([...$e(),...ge])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):ke?Uo({schema:ke,value:pe,onChange:ge=>Q(T,ge),path:`${o}.${T}`,label:ke.title&&!ke.title.includes("{{")?ke.title:U(pe,T),breadcrumbPath:N?.innerPath??[],onBreadcrumbChange:ge=>{c?.([...$e(),...ge])},meta:h,decofile:u,onSaveReferencedBlock:f,previewBaseUrl:p,onAddSectionItem:g,onRequestAddSection:x,sandbox:v}):null})}const ze="space-y-2";let Te;e[6]!==a?(Te=i.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[6]=a,e[7]=Te):Te=e[7];const Se=b.length>0&&i.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground",children:b.length});let be;e[8]!==Te||e[9]!==Se?(be=i.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[Te,Se]}),e[8]=Te,e[9]=Se,e[10]=be):be=e[10];let Re;e[11]!==s.description?(Re=s.description&&i.jsx("p",{className:"break-words text-xs leading-normal text-muted-foreground",children:s.description}),e[11]=s.description,e[12]=Re):Re=e[12];let Ve;e[13]!==be||e[14]!==Re?(Ve=i.jsxs("div",{className:"min-w-0 space-y-0.5",children:[be,Re]}),e[13]=be,e[14]=Re,e[15]=Ve):Ve=e[15];const he=b.length>0&&i.jsx("div",{className:te(R&&"cursor-grabbing"),children:i.jsxs(mc,{sensors:q,collisionDetection:U9,onDragStart:le,onDragEnd:G,onDragCancel:me,children:[i.jsx(Q9,{items:se,strategy:X9,children:i.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-border/50 p-1.5",children:A.map(pe=>{const ke=b[pe.index];if(ke===void 0)return null;const $e=U(ke,pe.index),ge=Vf(co(ke),y);return i.jsx(_P,{sortableId:pe.id,labelText:$e,imageSrc:ge,hidden:wo(ke),onToggleHidden:j?()=>Y(pe.index):void 0,onOpen:()=>W(pe.index),onDuplicate:()=>K(pe.index),onRemove:()=>F(pe.index)},pe.id)})})}),i.jsx(q9,{dropAnimation:null,children:Le?i.jsx("div",{className:"flex min-w-0 items-center gap-2.5 rounded-lg border border-border/60 bg-background px-2 py-2.5 shadow-lg ring-1 ring-border/60",children:i.jsx(bP,{labelText:Le,imageSrc:Ce})}):null})]})});let Pe;e[16]===Symbol.for("react.memo_cache_sentinel")?(Pe=i.jsx(kt,{size:14}),e[16]=Pe):Pe=e[16];const Me=S?"Add section":"Add item";let xe;e[17]!==Z||e[18]!==Me?(xe=i.jsxs("button",{type:"button",onClick:Z,className:"flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-border/60 py-2.5 text-sm text-muted-foreground transition-colors hover:border-border hover:bg-muted/30",children:[Pe,Me]}),e[17]=Z,e[18]=Me,e[19]=xe):xe=e[19];let Ae;return e[20]!==Ve||e[21]!==he||e[22]!==xe?(Ae=i.jsxs("div",{className:ze,children:[Ve,he,xe]}),e[20]=Ve,e[21]=he,e[22]=xe,e[23]=Ae):Ae=e[23],Ae}function kP(t){return t.id}function VP(t){const e=M.c(44),{schema:s,value:n,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g}=t;let x;e[0]!==l?(x=l===void 0?[]:l,e[0]=l,e[1]=x):x=e[1];const v=x,[_,b]=k.useState(!1);let y;e[2]!==n?(y=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},e[2]=n,e[3]=y):y=e[3];const L=y;if(!s.properties)return null;let w;e[4]!==o?(w=o.split(".").pop()??o,e[4]=o,e[5]=w):w=e[5];const S=w;let j;e[6]!==v||e[7]!==S||e[8]!==a||e[9]!==L||e[10]!==s?(j=hP(S,a,s,L,v),e[6]=v,e[7]=S,e[8]=a,e[9]=L,e[10]=s,e[11]=j):j=e[11];const V=_||j,N=`${o}-fields`;let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T=()=>b(NP),e[12]=T):T=e[12];let A;e[13]!==V?(A=i.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors group-hover:text-accent-foreground",children:V?i.jsx(ts,{size:16}):i.jsx(vn,{size:16})}),e[13]=V,e[14]=A):A=e[14];let E;e[15]!==a?(E=i.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:a}),e[15]=a,e[16]=E):E=e[16];let R;e[17]!==N||e[18]!==V||e[19]!==A||e[20]!==E?(R=i.jsxs("button",{type:"button","aria-expanded":V,"aria-controls":N,onClick:T,className:"group flex w-full min-w-0 items-center gap-2 rounded-md py-1.5 pr-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",children:[A,E]}),e[17]=N,e[18]=V,e[19]=A,e[20]=E,e[21]=R):R=e[21];let D;e[22]!==s.description?(D=s.description&&i.jsx("p",{className:"break-words pl-9 text-xs leading-normal text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=D):D=e[23];let P;e[24]!==v||e[25]!==N||e[26]!==h||e[27]!==V||e[28]!==d||e[29]!==L||e[30]!==m||e[31]!==c||e[32]!==r||e[33]!==p||e[34]!==u||e[35]!==o||e[36]!==f||e[37]!==g||e[38]!==s?(P=V&&i.jsx("div",{id:N,className:"ml-3 min-w-0 max-w-full overflow-hidden border-l border-border/80 pl-5",children:i.jsx(Pn,{schema:s,value:L,onChange:r,basePath:o,breadcrumbPath:v,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,previewBaseUrl:f,onAddSectionItem:m,onRequestAddSection:p,sandbox:g})}),e[24]=v,e[25]=N,e[26]=h,e[27]=V,e[28]=d,e[29]=L,e[30]=m,e[31]=c,e[32]=r,e[33]=p,e[34]=u,e[35]=o,e[36]=f,e[37]=g,e[38]=s,e[39]=P):P=e[39];let I;return e[40]!==D||e[41]!==P||e[42]!==R?(I=i.jsxs("div",{className:"min-w-0 space-y-2",children:[R,D,P]}),e[40]=D,e[41]=P,e[42]=R,e[43]=I):I=e[43],I}function NP(t){return!t}function kK(t,e,s,n,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[n]&&(l[n]={...l[n],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function VK(t){return structuredClone(t)}function NK(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function n4(t){const e=t.replace(/[^A-Za-z0-9_ -]/g,"").replace(/\s+/g," ").trim();return/^[A-Za-z]/.test(e)?e:e?`Block ${e}`:""}function vu(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_ -]*$/.test(s)?null:"Use letters, numbers, spaces, hyphens, or underscores. Must start with a letter.":"Block name is required."}function bu(t){const e=M.c(37),{open:s,onOpenChange:n,defaultBlockId:r,isPending:o,onSubmit:a}=t,l=r===void 0?"":r,c=o===void 0?!1:o,[d,h]=k.useState(l),[u,f]=k.useState(s);s!==u&&(f(s),s&&h(l));let m;e[0]!==c||e[1]!==n?(m=A=>{!A&&!c&&n(!1)},e[0]=c,e[1]=n,e[2]=m):m=e[2];const p=m;let g;e[3]!==d||e[4]!==c||e[5]!==a?(g=async A=>{A.preventDefault();const E=d.trim();!E||c||await a(E)},e[3]=d,e[4]=c,e[5]=a,e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsxs(us,{children:[i.jsx(hs,{children:"Save as global"}),i.jsx(si,{children:"Save this section as a global block so it can be reused on other pages."})]}),e[7]=v):v=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("label",{htmlFor:"block-id",className:"text-sm font-medium",children:"Block name"}),e[8]=_):_=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=A=>h(A.target.value),e[9]=b):b=e[9];let y;e[10]!==d||e[11]!==c?(y=i.jsxs("div",{className:"py-4 space-y-2",children:[_,i.jsx(tt,{id:"block-id",value:d,onChange:b,placeholder:"MyNewBlock",autoFocus:!0,disabled:c})]}),e[10]=d,e[11]=c,e[12]=y):y=e[12];let L;e[13]!==n?(L=()=>n(!1),e[13]=n,e[14]=L):L=e[14];let w;e[15]!==c||e[16]!==L?(w=i.jsx(re,{type:"button",variant:"outline",onClick:L,disabled:c,children:"Cancel"}),e[15]=c,e[16]=L,e[17]=w):w=e[17];let S;e[18]!==d||e[19]!==c?(S=!d.trim()||c,e[18]=d,e[19]=c,e[20]=S):S=e[20];let j;e[21]!==c?(j=c?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[21]=c,e[22]=j):j=e[22];let C;e[23]!==S||e[24]!==j?(C=i.jsx(re,{type:"submit",disabled:S,children:j}),e[23]=S,e[24]=j,e[25]=C):C=e[25];let V;e[26]!==w||e[27]!==C?(V=i.jsxs(Ei,{children:[w,C]}),e[26]=w,e[27]=C,e[28]=V):V=e[28];let N;e[29]!==x||e[30]!==V||e[31]!==y?(N=i.jsx(Zt,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:x,children:[v,y,V]})}),e[29]=x,e[30]=V,e[31]=y,e[32]=N):N=e[32];let T;return e[33]!==p||e[34]!==s||e[35]!==N?(T=i.jsx(es,{open:s,onOpenChange:p,children:N}),e[33]=p,e[34]=s,e[35]=N,e[36]=T):T=e[36],T}function i4(t){return t===Tr||t===Mi}function Lc(t,e){if(!Object.hasOwn(e,t))return null;const s=e[t]??{},n=s.__resolveType??t;return{data:{...s},resolveType:n}}function Rl(t,e){const s=t.__resolveType??"";if(!s)return null;if(ds(s)){const n=t.section??{};return r4(n,e)}if(i4(s)){const n=t.variants?.[0]?.value;return n?Rl(n,e):null}return!bn(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Lc(s,e)}function r4(t,e){const s=t.__resolveType??"";if(!s)return null;if(i4(s)){const n=t.variants?.[0]?.value;return n?Rl(n,e):null}return!bn(s)||!Object.hasOwn(e,s)?{data:{...t},resolveType:s}:Lc(s,e)}function AP(t,e){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t.__resolveType;if(typeof n!="string"||!bn(n)||!Object.hasOwn(e,n))return null;const r=Lc(n,e);return r?{blockKey:n,...r}:null}function TP(t,e,s){if(e.isMultivariate)return null;if(e.isSavedBlock){const n=e.isLazy?t.section?.__resolveType??t.__resolveType:t.__resolveType;return Lc(n,s)}if(e.isHidden){const o=(ds(t.__resolveType)?t.section:t)?.variants?.[0]?.value??t;return Rl(o,s)}if(e.isLazy||ds(t.__resolveType)){const n=t.section??{};return r4(n,s)}return Rl(t,s)}function EP(t){if(!t?.properties)return{};const e={};for(const[s,n]of Object.entries(t.properties))s.startsWith("__")||s==="@type"||(n.default!==void 0?e[s]=n.default:n.type==="boolean"?e[s]=!1:n.type==="string"?e[s]="":n.type==="number"||n.type==="integer"?e[s]=0:n.type==="object"&&(e[s]={}));return e}function RP(t){const e=M.c(3),{blockKey:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Ie,{asChild:!0,children:i.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i.jsx(ii,{size:11}),"Global"]})}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsxs(Oe,{children:[n,i.jsxs(De,{side:"top",className:"max-w-[260px]",children:["Edits the saved block “",s,"”. Changes apply everywhere this loader is referenced on your site."]})]}),e[1]=s,e[2]=r):r=e[2],r}function PP(t){const e=M.c(35),{path:s,open:n,onOpenChange:r,title:o,nested:a,nestedBlockRef:l,globalBlockKey:c,onDetach:d,onMakeGlobal:h}=t,u=`${s}-loader-config`,f=l&&"ml-1";let m;e[0]!==f?(m=te("rounded-lg border border-border/80 bg-muted/30",f),e[0]=f,e[1]=m):m=e[1];let p;e[2]!==r||e[3]!==n?(p=()=>r(!n),e[2]=r,e[3]=n,e[4]=p):p=e[4];let g;e[5]!==n?(g=i.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:n?i.jsx(ts,{size:16}):i.jsx(vn,{size:16})}),e[5]=n,e[6]=g):g=e[6];let x;e[7]!==o?(x=i.jsx("span",{className:"truncate text-xs font-medium tracking-wide text-muted-foreground uppercase",children:o}),e[7]=o,e[8]=x):x=e[8];let v;e[9]!==c?(v=c&&i.jsx(RP,{blockKey:c}),e[9]=c,e[10]=v):v=e[10];let _;e[11]!==x||e[12]!==v?(_=i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[x,v]}),e[11]=x,e[12]=v,e[13]=_):_=e[13];let b;e[14]!==u||e[15]!==n||e[16]!==p||e[17]!==g||e[18]!==_?(b=i.jsxs("button",{type:"button","aria-expanded":n,"aria-controls":u,onClick:p,className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-3 py-2.5 text-left",children:[g,_]}),e[14]=u,e[15]=n,e[16]=p,e[17]=g,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==c||e[21]!==d||e[22]!==h?(y=(d||h)&&i.jsxs(as,{children:[i.jsx(ls,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Loader actions",className:"h-7 w-7 shrink-0 text-muted-foreground",children:i.jsx(ni,{size:16})})}),i.jsxs(cs,{align:"end",className:"w-48",children:[c&&d&&i.jsxs(Ge,{onClick:d,children:[i.jsx(kn,{className:"h-4 w-4"}),"Detach"]}),!c&&h&&i.jsxs(Ge,{onClick:h,children:[i.jsx(ii,{className:"h-4 w-4"}),"Make global"]})]})]}),e[20]=c,e[21]=d,e[22]=h,e[23]=y):y=e[23];let L;e[24]!==b||e[25]!==y?(L=i.jsxs("div",{className:"group flex w-full min-w-0 items-center gap-1 rounded-lg pr-2 transition-colors hover:bg-accent/50",children:[b,y]}),e[24]=b,e[25]=y,e[26]=L):L=e[26];let w;e[27]!==u||e[28]!==a||e[29]!==n?(w=n&&i.jsx("div",{id:u,className:"border-t border-border/60 px-4 pb-4 pt-3",children:i.jsx("div",{className:"border-l border-border/80 pl-4",children:a})}),e[27]=u,e[28]=a,e[29]=n,e[30]=w):w=e[30];let S;return e[31]!==L||e[32]!==w||e[33]!==m?(S=i.jsxs("div",{className:m,children:[L,w]}),e[31]=L,e[32]=w,e[33]=m,e[34]=S):S=e[34],S}function Rf(t){const e=M.c(35),{schema:s,value:n,onChange:r,path:o,label:a,breadcrumbPath:l,onBreadcrumbChange:c,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}=t,m=(s.anyOfRefs??[]).filter(OP),p=h&&n?AP(n,h):null,g=p?.data??n,x=p?null:Xg(g),v=x??g,_=XR(m,{savedBlockKey:p?.blockKey,editorValue:g}),b=_.length>0?QR(g,_,p?.blockKey):_[0]?.resolveType??"",L=s.type==="block-ref"&&_.some(DP);let w;e[0]!==a||e[1]!==o?(w=a??(o.includes(".")?o.split(".")[0]:o),e[0]=a,e[1]=o,e[2]=w):w=e[2];const S=w;let j;e[3]!==l?(j=l??[],e[3]=l,e[4]=j):j=e[4];const C=j,V=L&&C[0]===S,N=V?C.slice(1):C,T=V?K=>{c?.([S,...K])}:c,[A,E]=k.useState(b),[R,D]=k.useState(b);R!==b&&(D(b),E(b));const[P,I]=k.useState(()=>eP(g,p?.blockKey)),[O,B]=k.useState(!1);if(_.length>0){const K=A||b;let Y;e[5]!==K?(Y=Se=>Se.resolveType===K,e[5]=K,e[6]=Y):Y=e[6];const F=_.find(Y),Q=kf(g,d,F?.schema),J=ZR(Q??F?.schema??null,s.discriminatorKey),ee=s.discriminatorKey,q=Se=>{E(Se);const be=_.find(xe=>xe.resolveType===Se),Re=kf(g,d,be?.schema),Ve=new Set(Object.keys((Re??be?.schema)?.properties??{})),he=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:{},Pe=Object.fromEntries(Object.entries(he).filter(xe=>{const[Ae]=xe;return Ve.has(Ae)})),Me={...EP(be?.schema),...Pe};if(ee){const xe=be?.discriminatorValue??Se;r({...Me,[ee]:xe});return}if(vo(Se)){r(Me);return}r({...Me,__resolveType:Se})};let se;e[7]!==K||e[8]!==ee||e[9]!==r?(se=Se=>{if(ee||!vo(K)||Se===null||typeof Se!="object"||Array.isArray(Se)){r(Se);return}const{__resolveType:be,...Re}=Se;r(Re)},e[7]=K,e[8]=ee,e[9]=r,e[10]=se):se=e[10];const ne=se,le=J?.properties?i.jsx(Pn,{schema:J,value:v,onChange:Se=>{if(p&&u){u(p.blockKey,Se);return}if(x){r({...g,section:Se});return}ne(Se)},basePath:o,breadcrumbPath:N,onBreadcrumbChange:T,meta:d,decofile:h,onSaveReferencedBlock:u,sandbox:f}):null;let G;e[11]!==o?(G=o.includes("."),e[11]=o,e[12]=G):G=e[12];const oe=G,me=p?()=>{const{name:Se,...be}=p.data;r(be)}:void 0,ue=!p&&!x&&!!u&&L&&!vo(K)&&K.includes("/"),ye=v&&typeof v=="object"&&!Array.isArray(v)?v:{},Le=Se=>{if(!u)return;const be=Se.trim(),Re=h?vu(be,h):null;if(Re){de.error(Re);return}u(be,{...ye,__resolveType:K,name:be}),r({__resolveType:be}),B(!1),de.success(`Saved global block "${be}"`)};let Ce;e[13]!==a||e[14]!==o?(Ce=i.jsx(rt,{htmlFor:o,children:a}),e[13]=a,e[14]=o,e[15]=Ce):Ce=e[15];let ze;e[16]===Symbol.for("react.memo_cache_sentinel")?(ze=i.jsx(Xt,{children:i.jsx(rs,{placeholder:"Select..."})}),e[16]=ze):ze=e[16];let Te;return e[17]!==s.description?(Te=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[17]=s.description,e[18]=Te):Te=e[18],i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[Ce,i.jsxs(Jt,{value:K||void 0,onValueChange:q,children:[ze,i.jsx(Yt,{children:_.map(IP)})]}),Te]}),le&&(L?i.jsx(PP,{path:o,open:P,onOpenChange:I,title:oe?"Configuration":"Loader configuration",nested:le,nestedBlockRef:oe,globalBlockKey:p?.blockKey,onDetach:me,onMakeGlobal:ue?()=>B(!0):void 0}):le),ue&&i.jsx(bu,{open:O,onOpenChange:B,defaultBlockId:n4(Ct(K)),onSubmit:Le})]})}if(s.anyOfRefs&&s.anyOfRefs.length>0)return null;let z;e[19]!==a||e[20]!==o?(z=i.jsx(rt,{htmlFor:o,children:a}),e[19]=a,e[20]=o,e[21]=z):z=e[21];const $=n!=null?String(n):"";let U;e[22]!==r?(U=K=>r(K.target.value),e[22]=r,e[23]=U):U=e[23];const W=s.description??"";let X;e[24]!==o||e[25]!==$||e[26]!==U||e[27]!==W?(X=i.jsx("input",{id:o,type:"text",value:$,onChange:U,className:"w-full rounded-md border bg-background px-3 py-1.5 text-sm",placeholder:W}),e[24]=o,e[25]=$,e[26]=U,e[27]=W,e[28]=X):X=e[28];let H;e[29]!==s.description?(H=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=H):H=e[30];let Z;return e[31]!==z||e[32]!==X||e[33]!==H?(Z=i.jsxs("div",{className:"space-y-1.5",children:[z,X,H]}),e[31]=z,e[32]=X,e[33]=H,e[34]=Z):Z=e[34],Z}function IP(t){const e=t.title&&!t.title.includes("/")?t.title:P0(t.resolveType)??Ct(t.resolveType);return i.jsx(pt,{value:t.resolveType,children:e},t.resolveType)}function DP(t){return t.resolveType.includes("/")&&!vo(t.resolveType)}function OP(t){return t.resolveType!==""}function MP(t){if(!Array.isArray(t))return[];const e=[];for(const s of t)if(typeof s=="string")e.push({value:s,label:s});else if(s&&typeof s=="object"&&"value"in s){const n=s;e.push({value:String(n.value),label:typeof n.label=="string"?n.label:String(n.value),image:typeof n.image=="string"?n.image:void 0})}return e}async function $P(t,e,s){const n={};s&&(n.term=s);const o=`${t.replace(/\/+$/,"")}/deco/invoke/${e}`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Failed to fetch dynamic options: ${a.status}`);const l=await a.json();return MP(l)}function Pf(t){const e=M.c(8),{path:s,label:n,description:r}=t;let o;e[0]!==n||e[1]!==s?(o=i.jsx(rt,{htmlFor:s,children:n}),e[0]=n,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function BP(t){const e=M.c(71),{schema:s,value:n,onChange:r,path:o,label:a,sandbox:l}=t,c=s.options,d=l?.previewUrl,[h,u]=k.useState(!1),[f,m]=k.useState(""),[p,g]=k.useState(""),x=k.useRef(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=K=>{m(K),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{g(K)},300)},e[0]=v):v=e[0];const _=v,b=l?`${l.orgSlug}/${l.virtualMcpId}/${l.branch}`:"";let y;e[1]!==p||e[2]!==c||e[3]!==b?(y=it.sandboxInvoke(b,`dynamic-options:${c??""}:${p}`),e[1]=p,e[2]=c,e[3]=b,e[4]=y):y=e[4];let L;e[5]!==p||e[6]!==c||e[7]!==d?(L=()=>$P(d,c,p||void 0),e[5]=p,e[6]=c,e[7]=d,e[8]=L):L=e[8];const w=!!d&&!!c&&h;let S;e[9]!==y||e[10]!==L||e[11]!==w?(S={queryKey:y,queryFn:L,enabled:w,staleTime:6e4,retry:1},e[9]=y,e[10]=L,e[11]=w,e[12]=S):S=e[12];const j=Ut(S);let C;e[13]!==j.data?(C=j.data??[],e[13]=j.data,e[14]=C):C=e[14];const V=C,N=typeof n=="string"?n:"";let T;if(e[15]!==N||e[16]!==V){let K;e[18]!==N?(K=Y=>Y.value===N,e[18]=N,e[19]=K):K=e[19],T=V.find(K),e[15]=N,e[16]=V,e[17]=T}else T=e[17];const A=T;if(!d||!c){let K;e[20]!==a||e[21]!==o||e[22]!==s.description?(K=i.jsx(Pf,{path:o,label:a,description:s.description}),e[20]=a,e[21]=o,e[22]=s.description,e[23]=K):K=e[23];let Y;e[24]!==r?(Y=J=>r(J.target.value),e[24]=r,e[25]=Y):Y=e[25];let F;e[26]!==N||e[27]!==o||e[28]!==Y?(F=i.jsx(tt,{id:o,type:"text",value:N,onChange:Y}),e[26]=N,e[27]=o,e[28]=Y,e[29]=F):F=e[29];let Q;return e[30]!==F||e[31]!==K?(Q=i.jsxs("div",{className:"space-y-2",children:[K,F]}),e[30]=F,e[31]=K,e[32]=Q):Q=e[32],Q}let E;e[33]!==a||e[34]!==o||e[35]!==s.description?(E=i.jsx(Pf,{path:o,label:a,description:s.description}),e[33]=a,e[34]=o,e[35]=s.description,e[36]=E):E=e[36];let R;e[37]!==N||e[38]!==A?(R=A?i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[A.image&&i.jsx("img",{src:A.image,alt:"",referrerPolicy:"no-referrer",className:"h-6 w-6 shrink-0 rounded object-cover"}),i.jsx("span",{className:"truncate",children:A.label??A.value})]}):N?i.jsx("span",{className:"truncate",children:N}):i.jsx("span",{className:"text-muted-foreground",children:"Select..."}),e[37]=N,e[38]=A,e[39]=R):R=e[39];let D;e[40]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx(g9,{className:"size-4 shrink-0 opacity-50"}),e[40]=D):D=e[40];let P;e[41]!==h||e[42]!==R?(P=i.jsx(As,{asChild:!0,children:i.jsxs(re,{variant:"outline",role:"combobox","aria-expanded":h,className:"h-10 w-full justify-between font-normal",children:[R,D]})}),e[41]=h,e[42]=R,e[43]=P):P=e[43];let I;e[44]===Symbol.for("react.memo_cache_sentinel")?(I={width:"var(--radix-popover-trigger-width)"},e[44]=I):I=e[44];let O;e[45]!==f?(O=i.jsx(Ii,{placeholder:"Search...",className:"h-9",value:f,onValueChange:_}),e[45]=f,e[46]=O):O=e[46];const B=j.isLoading?"Loading...":"No results found.";let z;e[47]!==B?(z=i.jsx(Jn,{children:B}),e[47]=B,e[48]=z):z=e[48];let $;if(e[49]!==N||e[50]!==r||e[51]!==V){let K;e[53]!==N||e[54]!==r?(K=Y=>i.jsxs(Cs,{value:Y.value,onSelect:()=>{r(Y.value===N?"":Y.value),u(!1)},children:[i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[Y.image&&i.jsx("img",{src:Y.image,alt:"",referrerPolicy:"no-referrer",className:"h-9 w-9 shrink-0 rounded object-cover"}),i.jsx("span",{className:"truncate",children:Y.label??Y.value})]}),i.jsx(Ot,{className:te("ml-auto size-4 shrink-0",N===Y.value?"opacity-100":"opacity-0")})]},Y.value),e[53]=N,e[54]=r,e[55]=K):K=e[55],$=V.map(K),e[49]=N,e[50]=r,e[51]=V,e[52]=$}else $=e[52];let U;e[56]!==$?(U=i.jsx(Is,{children:$}),e[56]=$,e[57]=U):U=e[57];let W;e[58]!==z||e[59]!==U?(W=i.jsxs(Di,{children:[z,U]}),e[58]=z,e[59]=U,e[60]=W):W=e[60];let X;e[61]!==O||e[62]!==W?(X=i.jsx(Ts,{className:"p-0",style:I,children:i.jsxs(Cr,{shouldFilter:!1,children:[O,W]})}),e[61]=O,e[62]=W,e[63]=X):X=e[63];let H;e[64]!==h||e[65]!==P||e[66]!==X?(H=i.jsxs(Ns,{open:h,onOpenChange:u,children:[P,X]}),e[64]=h,e[65]=P,e[66]=X,e[67]=H):H=e[67];let Z;return e[68]!==H||e[69]!==E?(Z=i.jsxs("div",{className:"space-y-2",children:[E,H]}),e[68]=H,e[69]=E,e[70]=Z):Z=e[70],Z}function zP(t){const e=M.c(17),{org:s}=Ee(),n=Ms();let r,o,a,l;e[0]!==s.id||e[1]!==t.configId||e[2]!==t.imageOnly||e[3]!==t.search?(o=t.search?.trim()||void 0,r=t.imageOnly??!1,l=Gm,a=it.filePickerObjects(s.id,t.configId,o,r),e[0]=s.id,e[1]=t.configId,e[2]=t.imageOnly,e[3]=t.search,e[4]=r,e[5]=o,e[6]=a,e[7]=l):(r=e[4],o=e[5],a=e[6],l=e[7]);const c=t.enabled!==!1&&!!t.configId;let d;e[8]!==r||e[9]!==t.configId||e[10]!==o||e[11]!==n?(d=async u=>{const{pageParam:f}=u;return await n.call("FILE_OBJECTS_LIST",{configId:t.configId,cursor:f??void 0,search:o,imageOnly:r||void 0})},e[8]=r,e[9]=t.configId,e[10]=o,e[11]=n,e[12]=d):d=e[12];let h;return e[13]!==a||e[14]!==c||e[15]!==d?(h={queryKey:a,enabled:c,staleTime:3e4,initialPageParam:null,queryFn:d,getNextPageParam:FP},e[13]=a,e[14]=c,e[15]=d,e[16]=h):h=e[16],l(h)}function FP(t){return t.nextCursor??void 0}function _u(){const t=M.c(2),{org:e}=Ee();let s;return t[0]!==e?(s={mutationFn:async n=>{const r=n.file.type||"application/octet-stream",o=await fetch(`/api/${encodeURIComponent(e.slug)}/file-configs/${encodeURIComponent(n.configId)}/upload?filename=${encodeURIComponent(n.file.name)}`,{method:"POST",headers:{"Content-Type":r},body:n.file});if(!o.ok){const a=await o.text().catch(UP);let l=`${o.status} ${o.statusText}`;try{const c=JSON.parse(a);c.message&&(l=c.message)}catch{a&&(l=a.slice(0,200))}throw new Error(`Upload failed: ${l}`)}return await o.json()}},t[0]=e,t[1]=s):s=t[1],Gs(s)}function UP(){return""}const Sc="file-picker:last-config-id";function o4(t){const e=M.c(19),s=t.mode==="image"?"Pick an image":"Pick a file";let n;e[0]!==s?(n=i.jsx(hs,{children:s}),e[0]=s,e[1]=n):n=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(si,{children:"Upload a new file or pick one previously uploaded to a configured bucket."}),e[2]=r):r=e[2];let o;e[3]!==n?(o=i.jsxs(us,{children:[n,r]}),e[3]=n,e[4]=o):o=e[4];let a;e[5]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Et,{className:"h-64 w-full"}),e[5]=a):a=e[5];let l;e[6]!==t?(l=u=>{t.onSelect(u),t.onOpenChange(!1)},e[6]=t,e[7]=l):l=e[7];let c;e[8]!==t.lockedConfigId||e[9]!==t.mode||e[10]!==l?(c=i.jsx(vs,{fallback:HP,children:i.jsx(k.Suspense,{fallback:a,children:i.jsx(WP,{mode:t.mode,lockedConfigId:t.lockedConfigId,onSelect:l})})}),e[8]=t.lockedConfigId,e[9]=t.mode,e[10]=l,e[11]=c):c=e[11];let d;e[12]!==o||e[13]!==c?(d=i.jsxs(Zt,{className:"sm:max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[o,c]}),e[12]=o,e[13]=c,e[14]=d):d=e[14];let h;return e[15]!==t.onOpenChange||e[16]!==t.open||e[17]!==d?(h=i.jsx(es,{open:t.open,onOpenChange:t.onOpenChange,children:d}),e[15]=t.onOpenChange,e[16]=t.open,e[17]=d,e[18]=h):h=e[18],h}function HP(t){const{error:e}=t;return i.jsx(KP,{error:e??new Error("Failed to load buckets")})}function KP(t){const e=M.c(3),{error:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Sn,{size:16}),e[0]=n):n=e[0];let r;return e[1]!==s.message?(r=i.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[n,i.jsx("span",{className:"text-sm font-medium",children:s.message})]}),e[1]=s.message,e[2]=r):r=e[2],r}function WP(t){const e=M.c(32),{mode:s,lockedConfigId:n,onSelect:r}=t,o=R6();if(o.length===0){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(YP,{}),e[0]=p):p=e[0],p}if(n){let p;if(e[1]!==o||e[2]!==n){let x;e[4]!==n?(x=v=>v.id===n,e[4]=n,e[5]=x):x=e[5],p=o.find(x),e[1]=o,e[2]=n,e[3]=p}else p=e[3];const g=p;if(g){let x;return e[6]!==g||e[7]!==s||e[8]!==r?(x=i.jsx(n0,{config:g,mode:s,onSelect:r}),e[6]=g,e[7]=s,e[8]=r,e[9]=x):x=e[9],x}}if(o.length===1){const p=o[0];let g;return e[10]!==p||e[11]!==s||e[12]!==r?(g=i.jsx(n0,{config:p,mode:s,onSelect:r}),e[10]=p,e[11]=s,e[12]=r,e[13]=g):g=e[13],g}let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a=typeof window<"u"?window.localStorage.getItem(Sc):null,e[14]=a):a=e[14];const l=a;let c;e[15]!==o?(c=o.find(p=>p.id===l)?.id??o[0].id,e[15]=o,e[16]=c):c=e[16];const d=c;let h;e[17]!==o?(h=o.map(qP),e[17]=o,e[18]=h):h=e[18];let u;e[19]!==h?(u=i.jsx(Zo,{className:"self-start",children:h}),e[19]=h,e[20]=u):u=e[20];let f;if(e[21]!==o||e[22]!==s||e[23]!==r){let p;e[25]!==s||e[26]!==r?(p=g=>i.jsx(gi,{value:g.id,className:"min-h-0 flex-1 overflow-hidden",children:i.jsx(n0,{config:g,mode:s,onSelect:r})},g.id),e[25]=s,e[26]=r,e[27]=p):p=e[27],f=o.map(p),e[21]=o,e[22]=s,e[23]=r,e[24]=f}else f=e[24];let m;return e[28]!==d||e[29]!==u||e[30]!==f?(m=i.jsxs(wr,{defaultValue:d,onValueChange:GP,className:"min-h-0 flex-1 flex flex-col",children:[u,f]}),e[28]=d,e[29]=u,e[30]=f,e[31]=m):m=e[31],m}function qP(t){return i.jsx(gn,{value:t.id,children:t.name},t.id)}function GP(t){typeof window<"u"&&window.localStorage.setItem(Sc,t)}function YP(){const t=M.c(4),{org:e}=Ee();let s,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:"size-12 rounded-full bg-muted flex items-center justify-center",children:i.jsx(Pi,{size:20,className:"text-muted-foreground"})}),n=i.jsxs("div",{children:[i.jsx("p",{className:"font-medium text-sm",children:"No bucket configured"}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:"Add an S3-compatible bucket in Settings before you can upload files."})]}),t[0]=s,t[1]=n):(s=t[0],n=t[1]);let r;return t[2]!==e.slug?(r=i.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 p-10 flex flex-col items-center justify-center text-center gap-3",children:[s,n,i.jsx(re,{asChild:!0,size:"sm",className:"mt-2",children:i.jsx(sm,{to:"/$org/settings/files",params:{org:e.slug},children:"Configure a bucket"})})]}),t[2]=e.slug,t[3]=r):r=t[3],r}function n0({config:t,mode:e,onSelect:s}){const[n,r]=k.useState(""),o=E6(n,300),a=zP({configId:t.id,search:o,imageOnly:e==="image"}),l=_u(),[c,d]=k.useState(!1),h=k.useRef(null),u=e==="image"?"image/*":void 0;async function f(w){if(!w)return;const S=Array.from(w);if(S.length===0)return;let j=null;const C=[];for(const V of S)try{const N=await l.mutateAsync({configId:t.id,file:V});j??=N.publicUrl}catch(N){C.push(`${V.name} (${N instanceof Error?N.message:"upload failed"})`)}await a.refetch(),C.length>0&&de.error(C.length===S.length?`Upload failed: ${C.join("; ")}`:`Some files failed: ${C.join("; ")}`),j&&s(j)}function m(w){w.preventDefault(),d(!0)}function p(){d(!1)}function g(w){w.preventDefault(),d(!1),f(w.dataTransfer.files)}const v=(a.data?.pages??[]).flatMap(w=>w.items),_=v.filter(w=>e==="image"?a4(w.key):!0),b=o.trim(),y=v.length>0||n.trim().length>0,L=n!==o||a.isFetching&&!a.isFetchingNextPage;return i.jsxs("div",{className:"flex flex-col gap-3 min-h-0 h-full",children:[i.jsxs("button",{type:"button",onClick:()=>h.current?.click(),onDragOver:m,onDragLeave:p,onDrop:g,className:te("rounded-xl border border-dashed border-border/60 p-6 flex flex-col items-center justify-center gap-2 text-center transition-colors",c&&"border-primary bg-primary/5",l.isPending&&"opacity-60 pointer-events-none"),children:[i.jsx(Pi,{size:18,className:"text-muted-foreground"}),i.jsx("p",{className:"text-sm font-medium",children:l.isPending?"Uploading…":"Drop files here or click to upload"}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Up to 100 MB."," ",e==="image"?"Images only (PNG, JPEG, WebP, GIF, SVG, AVIF).":"Common image, video, audio, and document types."]}),i.jsx("input",{ref:h,type:"file",accept:u,multiple:!0,className:"hidden",onChange:w=>{const S=Array.from(w.target.files??[]);w.target.value="",f(S)}})]}),y?i.jsx(d9,{value:n,onChange:r,isSearching:L,placeholder:e==="image"?"Search images…":"Search files…",className:"shrink-0"}):null,i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:[_.length===0?b?i.jsx(QP,{query:b}):e==="image"&&v.length>0?i.jsx(XP,{}):i.jsx(JP,{}):e==="image"?i.jsx(eI,{items:_,onSelect:s}):i.jsx(tI,{items:_,onSelect:s}),a.hasNextPage&&i.jsx("div",{className:"flex justify-center py-4",children:i.jsx(re,{type:"button",variant:"outline",size:"sm",disabled:a.isFetchingNextPage,onClick:()=>a.fetchNextPage(),children:a.isFetchingNextPage?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{size:14,className:"animate-spin"}),"Loading…"]}):"Load more"})})]})]})}function JP(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[i.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:i.jsx(An,{size:18,className:"text-muted-foreground"})}),i.jsx("p",{className:"text-sm font-medium",children:"No files in this bucket yet"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"Drop a file above to get started."})]}),t[0]=e):e=t[0],e}function XP(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[i.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:i.jsx(An,{size:18,className:"text-muted-foreground"})}),i.jsx("p",{className:"text-sm font-medium",children:"No images in this bucket yet"}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"The bucket has other files, but none match common image formats."})]}),t[0]=e):e=t[0],e}function QP(t){const e=M.c(6),{query:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:i.jsx(An,{size:18,className:"text-muted-foreground"})}),e[0]=n):n=e[0];let r;e[1]!==s?(r=i.jsxs("p",{className:"text-sm font-medium",children:['No matches for "',s,'"']}),e[1]=s,e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("p",{className:"text-xs text-muted-foreground",children:"Try a different search, or load more files below."}),e[3]=o):o=e[3];let a;return e[4]!==r?(a=i.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 py-8 text-center",children:[n,r,o]}),e[4]=r,e[5]=a):a=e[5],a}function a4(t){return/\.(png|jpe?g|gif|webp|svg|avif|bmp)$/i.test(t)}function ZP(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"file":t.slice(e+1).toLowerCase()}function eI(t){const e=M.c(7),{items:s,onSelect:n}=t;let r;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>i.jsx(l4,{item:l,variant:"image",onSelect:n},l.key),e[3]=n,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=n,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=i.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:r}),e[5]=r,e[6]=o):o=e[6],o}function tI(t){const e=M.c(7),{items:s,onSelect:n}=t;let r;if(e[0]!==s||e[1]!==n){let a;e[3]!==n?(a=l=>i.jsx("li",{children:i.jsx(l4,{item:l,variant:"row",onSelect:n})},l.key),e[3]=n,e[4]=a):a=e[4],r=s.map(a),e[0]=s,e[1]=n,e[2]=r}else r=e[2];let o;return e[5]!==r?(o=i.jsx("ul",{className:"divide-y divide-border/60 rounded-lg border border-border/60",children:r}),e[5]=r,e[6]=o):o=e[6],o}function l4(t){const e=M.c(58),{item:s,variant:n,onSelect:r}=t;let o;e[0]!==s.key?(o=ZP(s.key),e[0]=s.key,e[1]=o):o=e[1];const a=o;if(n==="image"){let b;e[2]!==s.publicUrl||e[3]!==r?(b=()=>r(s.publicUrl),e[2]=s.publicUrl,e[3]=r,e[4]=b):b=e[4];let y;e[5]!==s.key||e[6]!==s.publicUrl?(y=i.jsx("img",{src:s.publicUrl,alt:s.key,loading:"lazy",className:"h-full w-full object-cover",onError:sI}),e[5]=s.key,e[6]=s.publicUrl,e[7]=y):y=e[7];let L;e[8]!==s.key||e[9]!==b||e[10]!==y?(L=i.jsx("button",{type:"button",onClick:b,className:"block h-full w-full transition hover:ring-2 hover:ring-primary",title:s.key,children:y}),e[8]=s.key,e[9]=b,e[10]=y,e[11]=L):L=e[11];let w;e[12]!==a?(w=i.jsx("span",{className:"pointer-events-none absolute left-1.5 top-1.5 rounded bg-background/80 px-1.5 py-0.5 text-[10px] font-medium uppercase text-foreground opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:a}),e[12]=a,e[13]=w):w=e[13];let S;e[14]!==s||e[15]!==r?(S=i.jsx("div",{className:"absolute right-1.5 top-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:i.jsx(If,{item:s,onSelect:r})}),e[14]=s,e[15]=r,e[16]=S):S=e[16];let j;e[17]!==s.key?(j=Df(s.key),e[17]=s.key,e[18]=j):j=e[18];let C;e[19]!==j?(C=i.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 transition-opacity group-hover:opacity-100",children:i.jsx("p",{className:"truncate text-xs text-white",children:j})}),e[19]=j,e[20]=C):C=e[20];let V;return e[21]!==L||e[22]!==w||e[23]!==S||e[24]!==C?(V=i.jsxs("div",{className:"group relative aspect-square overflow-hidden rounded-lg border border-border/60 bg-muted",children:[L,w,S,C]}),e[21]=L,e[22]=w,e[23]=S,e[24]=C,e[25]=V):V=e[25],V}let l;e[26]!==s.publicUrl||e[27]!==r?(l=()=>r(s.publicUrl),e[26]=s.publicUrl,e[27]=r,e[28]=l):l=e[28];let c;e[29]!==s.key?(c=i.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:a4(s.key)?i.jsx(An,{size:16,className:"text-muted-foreground"}):i.jsx(cr,{size:16,className:"text-muted-foreground"})}),e[29]=s.key,e[30]=c):c=e[30];let d;e[31]!==s.key?(d=Df(s.key),e[31]=s.key,e[32]=d):d=e[32];let h;e[33]!==d?(h=i.jsx("p",{className:"truncate text-sm font-medium",children:d}),e[33]=d,e[34]=h):h=e[34];let u;e[35]!==s.key?(u=i.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:s.key}),e[35]=s.key,e[36]=u):u=e[36];let f;e[37]!==h||e[38]!==u?(f=i.jsxs("div",{className:"min-w-0 flex-1",children:[h,u]}),e[37]=h,e[38]=u,e[39]=f):f=e[39];let m;e[40]!==a?(m=i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:a}),e[40]=a,e[41]=m):m=e[41];let p;e[42]!==s.size?(p=oI(s.size),e[42]=s.size,e[43]=p):p=e[43];let g;e[44]!==p?(g=i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:p}),e[44]=p,e[45]=g):g=e[45];let x;e[46]!==g||e[47]!==l||e[48]!==c||e[49]!==f||e[50]!==m?(x=i.jsxs("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[c,f,m,g]}),e[46]=g,e[47]=l,e[48]=c,e[49]=f,e[50]=m,e[51]=x):x=e[51];let v;e[52]!==s||e[53]!==r?(v=i.jsx(If,{item:s,onSelect:r}),e[52]=s,e[53]=r,e[54]=v):v=e[54];let _;return e[55]!==x||e[56]!==v?(_=i.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2 transition hover:bg-muted/50",children:[x,v]}),e[55]=x,e[56]=v,e[57]=_):_=e[57],_}function sI(t){t.target.style.display="none"}function If(t){const e=M.c(22),{item:s,onSelect:n}=t,[r,o]=k.useState(!1);let a;e[0]!==s.publicUrl?(a=async function(b){b.preventDefault(),b.stopPropagation();try{await navigator.clipboard.writeText(s.publicUrl),o(!0),window.setTimeout(()=>o(!1),1500)}catch{de.error("Failed to copy URL")}},e[0]=s.publicUrl,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(ls,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"size-7 rounded-md bg-background/80 backdrop-blur-sm",onClick:rI,"aria-label":"Asset actions",children:i.jsx(b2,{size:14})})}),e[2]=c):c=e[2];let d;e[3]!==s.publicUrl||e[4]!==n?(d=()=>n(s.publicUrl),e[3]=s.publicUrl,e[4]=n,e[5]=d):d=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Ot,{size:14}),e[6]=h):h=e[6];let u;e[7]!==d?(u=i.jsxs(Ge,{onClick:d,children:[h,"Use this"]}),e[7]=d,e[8]=u):u=e[8];let f;e[9]!==r?(f=r?i.jsx(Ot,{size:14}):i.jsx(Ds,{size:14}),e[9]=r,e[10]=f):f=e[10];const m=r?"Copied":"Copy URL";let p;e[11]!==l||e[12]!==f||e[13]!==m?(p=i.jsxs(Ge,{onClick:l,children:[f,m]}),e[11]=l,e[12]=f,e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(Rn,{size:14}),e[15]=g):g=e[15];let x;e[16]!==s.publicUrl?(x=i.jsx(Ge,{asChild:!0,children:i.jsxs("a",{href:s.publicUrl,target:"_blank",rel:"noreferrer",onClick:nI,children:[g,"Open in new tab"]})}),e[16]=s.publicUrl,e[17]=x):x=e[17];let v;return e[18]!==x||e[19]!==u||e[20]!==p?(v=i.jsxs(as,{children:[c,i.jsxs(cs,{align:"end",onClick:iI,children:[u,p,x]})]}),e[18]=x,e[19]=u,e[20]=p,e[21]=v):v=e[21],v}function nI(t){return t.stopPropagation()}function iI(t){return t.stopPropagation()}function rI(t){return t.stopPropagation()}function Df(t){const e=t.split("/");return e[e.length-1]??t}function oI(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function c4(t,e){if(!e)return null;const s=e.toLowerCase();return t.find(n=>{const r=n.bucket.toLowerCase();return n.siteSlug?.toLowerCase()===s||r===s||r===`deco-assets-${s}`})??null}function d4(){const t=M.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:i.jsxs("span",{className:"flex items-center gap-1.5 rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:[i.jsx(Pi,{size:14}),"Click to replace"]})}),t[0]=e):e=t[0],e}function u4(t){try{const e=new URL(t).pathname;return decodeURIComponent(e.split("/").pop()??t)}catch{return t.split("/").pop()??t}}function h4(t){const e=t.lastIndexOf(".");return e<0||e===t.length-1?"":t.slice(e+1).toLowerCase()}const aI=["low","medium","high","original"];function f4(t){return t==="low"||t==="medium"||t==="high"||t==="original"}function m4(t,e){try{return new URL(t).searchParams.get(e)}catch{const s=lI(t);for(const n of s){const r=n.indexOf("=");if((r>=0?n.slice(0,r):n)===e)return r>=0?n.slice(r+1):""}return null}}function p4(t,e,s){const n=t.indexOf("#"),r=n>=0?t.slice(n):"",o=n>=0?t.slice(0,n):t,a=o.indexOf("?"),l=a>=0?o.slice(0,a):o,c=(a>=0?o.slice(a+1).split("&"):[]).filter(Boolean).filter(d=>{const h=d.indexOf("=");return(h>=0?d.slice(0,h):d)!==e});return s!==void 0&&c.push(`${e}=${s}`),`${l}${c.length?`?${c.join("&")}`:""}${r}`}function lI(t){const e=t.indexOf("#"),s=e>=0?t.slice(0,e):t,n=s.indexOf("?");return n<0?[]:s.slice(n+1).split("&").filter(Boolean)}function cI(t){if(!t)return;const e=m4(t,"quality");return f4(e)?e:void 0}function dI(t,e){return p4(t,"quality",e)}function uI(t){return t?m4(t,"muted")!=="false":!0}function hI(t,e){return p4(t,"muted",e?void 0:"false")}function g4(t){const e=M.c(22),{value:s,onChange:n,showMuted:r}=t,o=r===void 0?!1:r,a=k.useId();let l;e[0]!==s?(l=cI(s),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==s?(d=uI(s),e[2]=s,e[3]=d):d=e[3];const h=d;let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(As,{asChild:!0,children:i.jsx(re,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0","aria-label":"Media options",children:i.jsx(b2,{size:14})})}),e[4]=u):u=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(rt,{className:"text-xs text-muted-foreground",children:"Quality"}),e[5]=f):f=e[5];const m=c??"";let p;e[6]!==n||e[7]!==s?(p=b=>n(dI(s,f4(b)?b:void 0)),e[6]=n,e[7]=s,e[8]=p):p=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=aI.map(fI),e[9]=g):g=e[9];let x;e[10]!==m||e[11]!==p?(x=i.jsxs("div",{className:"flex flex-col gap-1.5",children:[f,i.jsx(t9,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:p,children:g})]}),e[10]=m,e[11]=p,e[12]=x):x=e[12];let v;e[13]!==h||e[14]!==a||e[15]!==n||e[16]!==o||e[17]!==s?(v=o&&i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx(rt,{htmlFor:a,className:"text-xs text-muted-foreground",children:"Muted"}),i.jsx(hr,{id:a,checked:h,onCheckedChange:b=>n(hI(s,b))})]}),e[13]=h,e[14]=a,e[15]=n,e[16]=o,e[17]=s,e[18]=v):v=e[18];let _;return e[19]!==v||e[20]!==x?(_=i.jsxs(Ns,{children:[u,i.jsx(Ts,{align:"end",className:"w-auto min-w-52 p-3",children:i.jsxs("div",{className:"flex flex-col gap-3",children:[x,v]})})]}),e[19]=v,e[20]=x,e[21]=_):_=e[21],_}function fI(t){return i.jsx(Ao,{value:t,className:"h-8 px-3 text-xs capitalize",children:t},t)}function Of(t){const e=M.c(2),{ext:s}=t;if(!s)return null;let n;return e[0]!==s?(n=i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1],n}function mI(t){const e=M.c(81),{schema:s,value:n,onChange:r,path:o,label:a,sandbox:l}=t,c=s.format==="video-uri",d=gu(n),[h,u]=k.useState(!1),[f,m]=k.useState(!1),p=d?u4(d):"",g=p?h4(p):"",x=_2(),v=_u();let _;e[0]!==x.data?.configs?(_=x.data?.configs??[],e[0]=x.data?.configs,e[1]=_):_=e[1];const b=l?.siteSlug;let y;e[2]!==_||e[3]!==b?(y=c4(_,b),e[2]=_,e[3]=b,e[4]=y):y=e[4];const L=y;let w;e[5]!==x.data?.configs||e[6]!==L?(w=function(){if(L)return L.id;const ne=x.data?.configs??[];if(ne.length===1)return ne[0].id;if(ne.length===0)return null;const le=typeof window<"u"?window.localStorage.getItem(Sc):null;return ne.some(G=>G.id===le)?le:null},e[5]=x.data?.configs,e[6]=L,e[7]=w):w=e[7];const S=w;let j;e[8]!==c||e[9]!==r||e[10]!==S||e[11]!==u||e[12]!==v?(j=async function(ne){if(!ne)return;let le=Array.from(ne);if(le.length===0)return;if(c&&(le=le.filter(pI),le.length===0)){de.error("Please drop a video file (mp4, webm, …).");return}const G=S();if(!G){u(!0);return}try{const oe=await v.mutateAsync({configId:G,file:le[0]});r(oe.publicUrl),le.length>1&&de.info(`Uploaded ${le[0].name}; extra files were ignored (single-select field).`)}catch(oe){const me=oe;de.error(me instanceof Error?me.message:"Upload failed")}},e[8]=c,e[9]=r,e[10]=S,e[11]=u,e[12]=v,e[13]=j):j=e[13];const C=j;let V;e[14]!==m?(V=function(ne){ne.preventDefault(),ne.dataTransfer.types.includes("Files")&&m(!0)},e[14]=m,e[15]=V):V=e[15];const N=V;let T;e[16]!==m?(T=function(ne){ne.currentTarget===ne.target&&m(!1)},e[16]=m,e[17]=T):T=e[17];const A=T;let E;e[18]!==C||e[19]!==m?(E=function(ne){ne.preventDefault(),m(!1),C(ne.dataTransfer.files)},e[18]=C,e[19]=m,e[20]=E):E=e[20];const R=E;let D;e[21]!==a||e[22]!==o?(D=i.jsx(rt,{htmlFor:o,className:"text-muted-foreground",children:a}),e[21]=a,e[22]=o,e[23]=D):D=e[23];let P;e[24]!==s.description?(P=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[24]=s.description,e[25]=P):P=e[25];let I;e[26]!==P||e[27]!==D?(I=i.jsxs("div",{className:"min-w-0 space-y-0.5",children:[D,P]}),e[26]=P,e[27]=D,e[28]=I):I=e[28];const O=f&&"border-primary ring-2 ring-primary/30",B=v.isPending&&"pointer-events-none opacity-60";let z;e[29]!==O||e[30]!==B?(z=te("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",O,B),e[29]=O,e[30]=B,e[31]=z):z=e[31];let $;e[32]!==g||e[33]!==p||e[34]!==c||e[35]!==u||e[36]!==d||e[37]!==v.isPending?($=d?c?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>u(!0),"aria-label":"Replace video",className:"relative block h-40 w-full cursor-pointer overflow-hidden bg-black",children:[i.jsx("video",{src:d,preload:"metadata",className:"h-full w-full object-contain"},d),i.jsx(d4,{})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[i.jsx(Uu,{size:14,className:"shrink-0 text-muted-foreground"}),i.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:p}),i.jsx(Of,{ext:g})]})]}):i.jsxs("button",{type:"button",onClick:()=>u(!0),"aria-label":"Replace file",className:"flex w-full cursor-pointer items-center gap-3 px-3 py-2.5 text-left hover:bg-muted/60",children:[i.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-md bg-background",children:i.jsx(cr,{size:18,className:"text-muted-foreground"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("p",{className:"truncate text-sm font-medium",children:p}),i.jsx("p",{className:"truncate text-xs text-muted-foreground",children:d})]}),i.jsx(Of,{ext:g})]}):i.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex w-full flex-col items-center justify-center gap-2 py-8 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[c?i.jsx(Uu,{size:20}):i.jsx(cr,{size:20}),i.jsx("span",{className:"text-sm font-medium",children:v.isPending?"Uploading…":c?"Drop a video here or click to browse":"Drop a file or click to browse"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:"Up to 100 MB"})]}),e[32]=g,e[33]=p,e[34]=c,e[35]=u,e[36]=d,e[37]=v.isPending,e[38]=$):$=e[38];let U;e[39]!==f?(U=f&&i.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:i.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[39]=f,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==N||e[43]!==R||e[44]!==z||e[45]!==$||e[46]!==U?(W=i.jsxs("div",{onDragOver:N,onDragLeave:A,onDrop:R,className:z,children:[$,U]}),e[41]=A,e[42]=N,e[43]=R,e[44]=z,e[45]=$,e[46]=U,e[47]=W):W=e[47];let X;e[48]!==r?(X=se=>r(se.target.value),e[48]=r,e[49]=X):X=e[49];let H;e[50]!==o||e[51]!==d||e[52]!==X?(H=i.jsx(tt,{id:o,type:"url",value:d,onChange:X,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[50]=o,e[51]=d,e[52]=X,e[53]=H):H=e[53];let Z;e[54]!==u||e[55]!==d?(Z=!d&&i.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:()=>u(!0),className:"h-9 shrink-0",children:[i.jsx(Pi,{size:14}),"Browse"]}),e[54]=u,e[55]=d,e[56]=Z):Z=e[56];let K;e[57]!==c||e[58]!==r||e[59]!==d?(K=c&&d&&i.jsx(g4,{value:d,onChange:r,showMuted:!0}),e[57]=c,e[58]=r,e[59]=d,e[60]=K):K=e[60];let Y;e[61]!==r||e[62]!==d?(Y=d&&i.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(""),className:"h-9 shrink-0","aria-label":"Remove file",children:i.jsx(ks,{size:14})}),e[61]=r,e[62]=d,e[63]=Y):Y=e[63];let F;e[64]!==H||e[65]!==Z||e[66]!==K||e[67]!==Y?(F=i.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[H,Z,K,Y]}),e[64]=H,e[65]=Z,e[66]=K,e[67]=Y,e[68]=F):F=e[68];let Q;e[69]!==r?(Q=se=>r(se),e[69]=r,e[70]=Q):Q=e[70];const J=L?.id??null;let ee;e[71]!==h||e[72]!==u||e[73]!==Q||e[74]!==J?(ee=i.jsx(o4,{open:h,onOpenChange:u,mode:"any",onSelect:Q,lockedConfigId:J}),e[71]=h,e[72]=u,e[73]=Q,e[74]=J,e[75]=ee):ee=e[75];let q;return e[76]!==I||e[77]!==W||e[78]!==F||e[79]!==ee?(q=i.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[I,W,F,ee]}),e[76]=I,e[77]=W,e[78]=F,e[79]=ee,e[80]=q):q=e[80],q}function pI(t){return t.type.startsWith("video/")}const gI=new Set(["image/png","image/jpeg","image/gif","image/webp","image/svg+xml","image/avif"]);function xI(t){const e=M.c(83),{schema:s,value:n,onChange:r,path:o,label:a,sandbox:l}=t,c=gu(n),[d,h]=k.useState(!1),[u,f]=k.useState(!1),[m,p]=k.useState(!1),[g,x]=k.useState(!1),v=c?u4(c):"",_=v?h4(v):"",b=_2(),y=_u();let L;e[0]!==b.data?.configs?(L=b.data?.configs??[],e[0]=b.data?.configs,e[1]=L):L=e[1];const w=l?.siteSlug;let S;e[2]!==L||e[3]!==w?(S=c4(L,w),e[2]=L,e[3]=w,e[4]=S):S=e[4];const j=S;let C;e[5]!==r||e[6]!==x||e[7]!==p?(C=function(me){p(!1),x(!1),r(me)},e[5]=r,e[6]=x,e[7]=p,e[8]=C):C=e[8];const V=C;let N;e[9]!==b.data?.configs||e[10]!==j?(N=function(){if(j)return j.id;const me=b.data?.configs??[];if(me.length===1)return me[0].id;if(me.length===0)return null;const ue=typeof window<"u"?window.localStorage.getItem(Sc):null;return me.some(ye=>ye.id===ue)?ue:null},e[9]=b.data?.configs,e[10]=j,e[11]=N):N=e[11];const T=N;let A;e[12]!==T||e[13]!==h||e[14]!==V||e[15]!==y?(A=async function(me){if(!me)return;const ue=Array.from(me).filter(vI);if(ue.length===0){de.error("Only image files are accepted here.");return}const ye=T();if(!ye){h(!0);return}try{const Le=await y.mutateAsync({configId:ye,file:ue[0]});V(Le.publicUrl),ue.length>1&&de.info(`Uploaded ${ue[0].name}; extra files were ignored (single-select field).`)}catch(Le){const Ce=Le;de.error(Ce instanceof Error?Ce.message:"Upload failed")}},e[12]=T,e[13]=h,e[14]=V,e[15]=y,e[16]=A):A=e[16];const E=A;let R;e[17]!==f?(R=function(me){me.preventDefault(),me.dataTransfer.types.includes("Files")&&f(!0)},e[17]=f,e[18]=R):R=e[18];const D=R;let P;e[19]!==f?(P=function(me){me.currentTarget===me.target&&f(!1)},e[19]=f,e[20]=P):P=e[20];const I=P;let O;e[21]!==E||e[22]!==f?(O=function(me){me.preventDefault(),f(!1),E(me.dataTransfer.files)},e[21]=E,e[22]=f,e[23]=O):O=e[23];const B=O;let z;e[24]!==a||e[25]!==o?(z=i.jsx(rt,{htmlFor:o,className:"text-muted-foreground",children:a}),e[24]=a,e[25]=o,e[26]=z):z=e[26];let $;e[27]!==s.description?($=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[27]=s.description,e[28]=$):$=e[28];let U;e[29]!==z||e[30]!==$?(U=i.jsxs("div",{className:"min-w-0 space-y-0.5",children:[z,$]}),e[29]=z,e[30]=$,e[31]=U):U=e[31];const W=u&&"border-primary ring-2 ring-primary/30",X=y.isPending&&"pointer-events-none opacity-60";let H;e[32]!==W||e[33]!==X?(H=te("group relative w-full overflow-hidden rounded-xl border border-border/60 bg-muted/30 transition",W,X),e[32]=W,e[33]=X,e[34]=H):H=e[34];let Z;e[35]!==_||e[36]!==v||e[37]!==g||e[38]!==m||e[39]!==a||e[40]!==x||e[41]!==p||e[42]!==h||e[43]!==c||e[44]!==y.isPending?(Z=c?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>h(!0),"aria-label":"Replace image",className:"relative block h-40 w-full cursor-pointer bg-[image:linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%),linear-gradient(45deg,rgba(0,0,0,0.04)_25%,transparent_25%,transparent_75%,rgba(0,0,0,0.04)_75%)] bg-[position:0_0,8px_8px] [background-size:16px_16px]",children:[!g&&i.jsx("img",{src:c,alt:a,className:te("h-full w-full object-contain transition-opacity",!m&&"opacity-0"),onLoad:()=>p(!0),onError:()=>x(!0)},c),g&&i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 text-muted-foreground",children:[i.jsx(An,{size:20}),i.jsx("p",{className:"text-xs",children:"Preview unavailable"})]}),!m&&!g&&i.jsx("div",{className:"absolute inset-0 animate-pulse bg-muted/60"}),i.jsx(d4,{})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 bg-background/50 px-3 py-2",children:[i.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",children:v}),_&&i.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium uppercase text-muted-foreground",children:_})]})]}):i.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex h-40 w-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground hover:bg-muted/60 hover:text-foreground",children:[i.jsx(An,{size:20}),i.jsx("span",{className:"text-sm font-medium",children:y.isPending?"Uploading…":"Drop an image or click to browse"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:"PNG, JPEG, WebP, GIF, SVG, AVIF — up to 100 MB"})]}),e[35]=_,e[36]=v,e[37]=g,e[38]=m,e[39]=a,e[40]=x,e[41]=p,e[42]=h,e[43]=c,e[44]=y.isPending,e[45]=Z):Z=e[45];let K;e[46]!==u?(K=u&&i.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-primary/10 backdrop-blur-[1px]",children:i.jsx("span",{className:"rounded-md bg-background px-3 py-1.5 text-xs font-medium shadow",children:"Drop to upload"})}),e[46]=u,e[47]=K):K=e[47];let Y;e[48]!==I||e[49]!==D||e[50]!==B||e[51]!==H||e[52]!==Z||e[53]!==K?(Y=i.jsxs("div",{onDragOver:D,onDragLeave:I,onDrop:B,className:H,children:[Z,K]}),e[48]=I,e[49]=D,e[50]=B,e[51]=H,e[52]=Z,e[53]=K,e[54]=Y):Y=e[54];let F;e[55]!==V?(F=oe=>V(oe.target.value),e[55]=V,e[56]=F):F=e[56];let Q;e[57]!==o||e[58]!==c||e[59]!==F?(Q=i.jsx(tt,{id:o,type:"url",value:c,onChange:F,placeholder:"https://...",className:"h-9 min-w-0 flex-1"}),e[57]=o,e[58]=c,e[59]=F,e[60]=Q):Q=e[60];let J;e[61]!==h||e[62]!==c?(J=!c&&i.jsxs(re,{type:"button",variant:"outline",size:"sm",onClick:()=>h(!0),className:"h-9 shrink-0",children:[i.jsx(Pi,{size:14}),"Browse"]}),e[61]=h,e[62]=c,e[63]=J):J=e[63];let ee;e[64]!==V||e[65]!==c?(ee=c&&i.jsxs(i.Fragment,{children:[i.jsx(g4,{value:c,onChange:V}),i.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(""),className:"h-9 shrink-0","aria-label":"Remove image",children:i.jsx(ks,{size:14})})]}),e[64]=V,e[65]=c,e[66]=ee):ee=e[66];let q;e[67]!==Q||e[68]!==J||e[69]!==ee?(q=i.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[Q,J,ee]}),e[67]=Q,e[68]=J,e[69]=ee,e[70]=q):q=e[70];let se;e[71]!==V?(se=oe=>V(oe),e[71]=V,e[72]=se):se=e[72];const ne=j?.id??null;let le;e[73]!==d||e[74]!==h||e[75]!==se||e[76]!==ne?(le=i.jsx(o4,{open:d,onOpenChange:h,mode:"image",onSelect:se,lockedConfigId:ne}),e[73]=d,e[74]=h,e[75]=se,e[76]=ne,e[77]=le):le=e[77];let G;return e[78]!==U||e[79]!==Y||e[80]!==q||e[81]!==le?(G=i.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[U,Y,q,le]}),e[78]=U,e[79]=Y,e[80]=q,e[81]=le,e[82]=G):G=e[82],G}function vI(t){return gI.has(t.type||"")}function x4(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function bI(t,e){if(e.length===0)return 0;const s=x4(t);for(let o=0;o<e.length;o++){const a=e[o].discriminators;if(a&&Object.keys(a).length>0&&Object.entries(a).every(([c,d])=>s[c]===d))return o}let n=0,r=-1;for(let o=0;o<e.length;o++){const a=e[o],l=new Set(Object.keys(a.discriminators??{})),d=a.propertyKeys.filter(h=>!l.has(h)).filter(h=>s[h]!==void 0&&s[h]!==null&&s[h]!=="").length;d>r&&(r=d,n=o)}return n}function _I(t,e){const s=x4(t),n=new Set(e);return Object.fromEntries(Object.entries(s).filter(([r])=>!n.has(r)))}const yI="0 0 1080 1080",LI="matrix(1 0 0 1 540 540)",yu=[{code:"AC",name:"Acre",gTransform:"matrix(1 0 0 1 -248.53 -95.16)",pathTransform:"translate(-57.47, -224.1)",d:"M 30.47 237.77 L 28.39 237.73 L 28.93 235.92 L 28.72 235.09 L 28.47 234.6 L 27.22 233.9 L 27.08 233.45 L 27.35 232.3 L 26.58 230.35 L 25.49 229.71 L 19.89 228.46 L 12.55 228.27 L 12.82 227.71 L 15.31 225.45 L 16.2 224.22 L 16.49 223.02 L 16.27 221.79 L 15.59 220.88 L 14.76 220.44 L 13.08 217.49 L 12.31 217.05 L 11.41 216.86 L 10.28 215.73 L 9.36 213.35 L 7.36 211.82 L 6.38 208.2 L 5.51 206.56 L 3.63 205.48 L 3.55 204.31 L 4.36 204.41 L 4.78 203.89 L 4.85 203.22 L 4.65 202.8 L 2.53 201.87 L 2.17 201.21 L 0 199.32 L 0.04 198.95 L 0.66 198.9 L 1.16 197.58 L 1.15 196.27 L 4.16 195.88 L 4.66 195.49 L 4.44 194.14 L 3.27 192.57 L 3.27 192.57 L 21.22 200.05 L 44.88 205.71 L 57.02 208.85 L 83.46 223.02 L 111.97 235.15 L 111.97 235.15 L 114.94 236.41 L 114.94 236.41 L 114.64 236.89 L 113.07 237.55 L 110.98 239.14 L 108.12 241.93 L 106.47 242.79 L 105.81 242.61 L 104.28 242.79 L 104.23 243.35 L 102.31 244.65 L 100.23 245.64 L 98.79 247.47 L 98.35 248.65 L 97.74 248.93 L 96.57 248.18 L 95.81 248.05 L 93.44 248.1 L 92.76 248.36 L 92.13 248.81 L 91.77 249.67 L 89.33 253.15 L 85.56 254.4 L 84.72 255.09 L 82.78 255.6 L 81.75 255.63 L 81.83 253.52 L 80.47 253.72 L 76.92 252.95 L 71.68 252.48 L 66.59 252.86 L 65.93 252.28 L 63.66 252.11 L 60.1 253.94 L 57.37 254.56 L 55.69 253.89 L 54.29 252.45 L 52.65 253.61 L 52.69 236.06 L 52.74 234.96 L 53.21 234.25 L 53.28 231.9 L 53.02 231.02 L 53.99 229.84 L 54.47 228.7 L 53.31 228.9 L 50.34 231.49 L 48.74 232.5 L 46.68 234.88 L 44.73 235.55 L 44.08 236.63 L 42.27 237.62 z"},{code:"AL",name:"Alagoas",gTransform:"matrix(1 0 0 1 276.36 -86.82)",pathTransform:"translate(-582.36, -232.44)",d:"M 561.91 230.3 L 561.71 229.57 L 560.29 228.79 L 559.84 228.88 L 558.82 228.59 L 558.28 227.19 L 558.28 227.19 L 559.6 226.12 L 560.24 225.03 L 562.41 224.27 L 564.79 220.98 L 564.88 220.29 L 565.7 219.69 L 566.7 220.91 L 568.37 221.21 L 569.45 221.09 L 572 223.11 L 573.9 225.23 L 575.68 226.28 L 577.59 226.76 L 580.09 226.11 L 583.23 226.4 L 584.4 226.29 L 586.26 225.23 L 587.42 225.28 L 589.23 224.17 L 591.41 221.88 L 591.53 221.43 L 593.08 220.19 L 595.08 219.95 L 597.32 220.8 L 599.88 219.51 L 601.35 219.32 L 603.27 220.13 L 606.17 220.4 L 606.44 220.61 L 606.44 220.61 L 603.66 225.57 L 599.11 230.7 L 595.53 234.28 L 592.49 238.86 L 589.16 241.74 L 588.16 243.77 L 586.84 245.56 L 586.84 245.56 L 586.24 244.25 L 582.65 242.02 L 582.19 241.99 L 580.53 241.2 L 578.77 239.75 L 577.47 237.3 L 572.05 234.23 L 568.37 233.28 z"},{code:"AM",name:"Amazonas",gTransform:"matrix(1 0 0 1 -166.8 -178.05)",pathTransform:"translate(-139.2, -141.22)",d:"M 165.82 47.29 L 166.54 48.07 L 167.29 48.41 L 167.9 48.42 L 169.03 48 L 169.66 48.11 L 169.72 49.07 L 170.93 50.24 L 171.9 50.61 L 172.78 50.4 L 174.14 50.51 L 176.09 51.46 L 176.58 52.12 L 175.67 55.44 L 174.96 56.94 L 177.69 60.68 L 179.35 65.44 L 179.54 67.7 L 180.41 68.82 L 180.46 69.27 L 178.84 70.73 L 179.2 72.32 L 179.86 73.9 L 179.09 76.94 L 178.52 77.9 L 178.81 82.88 L 179.69 85.05 L 180.91 85.89 L 181.49 86.79 L 182.62 91.12 L 182.56 91.7 L 181.42 93.02 L 179.58 92.69 L 179.44 93.83 L 184.45 98.25 L 184.97 98.29 L 186.93 99.6 L 188.41 101.25 L 189.45 103.29 L 189.98 103.36 L 191.32 102.94 L 193.68 103.98 L 193.24 101.87 L 193.99 99.58 L 194.24 97.85 L 193.87 96.05 L 194.69 93.08 L 195.71 91.82 L 196.99 91.13 L 199.08 90.42 L 199.63 89.53 L 201.23 89.47 L 204.06 90.4 L 205.93 92.44 L 206.85 94.95 L 208.67 95.18 L 209.92 94.72 L 211.33 93.31 L 213.36 92.76 L 213.78 92.37 L 213.8 91.84 L 212.66 90.43 L 212.43 89.7 L 212.54 89.04 L 213.69 86.4 L 213.76 85.27 L 215.42 82.24 L 217.75 78.98 L 217.72 78.3 L 236.21 78.37 L 236.21 78.37 L 236.61 83.23 L 236.18 84.68 L 236.36 86.95 L 236.6 87.63 L 238.3 88.48 L 238.48 88.89 L 238.13 89.58 L 238.08 91.69 L 239.91 93.68 L 240.27 93.87 L 240.97 93.69 L 242.81 94.92 L 243.36 96.75 L 243.4 97.68 L 243.7 98.13 L 248.34 101.9 L 252.92 104.44 L 253.55 105.34 L 254.9 106.43 L 256.78 107.1 L 259.15 108.41 L 261.41 109.06 L 262.77 109.21 L 264.09 110.03 L 264.17 110.64 L 265.44 111.98 L 268.14 113.42 L 269.24 115.59 L 271.11 116.38 L 271.96 115.77 L 273.34 115.42 L 273.53 115.9 L 273.4 116.68 L 275.21 118.35 L 245.31 182.59 L 244.53 183.9 L 243.08 185.03 L 242.5 186 L 242.47 187.13 L 243.29 189.46 L 243.67 190.03 L 244.74 190.61 L 246.32 192.17 L 246.96 193.43 L 247.11 195.39 L 247.68 195.96 L 247.68 195.96 L 246.5 197.16 L 246.3 197.77 L 246.24 198.53 L 246.58 199.37 L 246.31 200.38 L 245.11 202.2 L 244.25 202.84 L 243.83 203.69 L 243.93 204.54 L 244.59 205.91 L 245.05 207.85 L 243.67 212.07 L 242.49 217.29 L 241.28 218.02 L 193.43 218.34 L 193.43 218.34 L 193.47 217.64 L 193.11 217.26 L 191.72 216.98 L 189.8 218.06 L 189.26 219.8 L 188.58 219.99 L 185.34 218.51 L 184.66 215.63 L 184.04 215.43 L 183.06 215.56 L 182.6 215.35 L 181.35 212.08 L 178.81 211.1 L 177.48 209.83 L 176.68 207.92 L 176.23 207.43 L 174.08 206.3 L 163.29 206.36 L 161.91 208.92 L 160.19 209.42 L 160.28 210.59 L 160.02 210.81 L 157.54 211.34 L 156.35 212.93 L 156.3 213.6 L 157.2 214.3 L 157.37 214.75 L 157.01 215.77 L 156.2 216.92 L 154.14 218.13 L 154.03 219.94 L 154.27 221.4 L 150.4 220.94 L 148.27 221.32 L 147.07 222.39 L 145.28 222.29 L 144.44 221.74 L 143.98 221.72 L 142.23 222.98 L 141.7 223.82 L 141.96 225.57 L 139.42 228.73 L 138.74 228.81 L 138.06 228.28 L 137.42 226.02 L 137.04 225.93 L 135.2 226.95 L 133.9 228.16 L 132.53 228.55 L 131.76 228.42 L 130.68 228.92 L 130.27 229.45 L 130.14 230.17 L 128.92 230.96 L 128.55 230.98 L 126.24 228.65 L 125.52 228.28 L 122.65 228.61 L 118.69 228.35 L 118.85 229.64 L 118.7 230.2 L 117.15 232.01 L 115.23 232.59 L 111.97 235.15 L 111.97 235.15 L 83.46 223.02 L 57.02 208.85 L 44.88 205.71 L 21.22 200.05 L 3.27 192.57 L 3.27 192.57 L 3.2 191.92 L 3.9 189 L 5.12 187.6 L 10.04 184.13 L 12.3 183.89 L 12.77 183.59 L 13.75 182.03 L 13.83 181 L 12.09 176.51 L 12.47 175.32 L 13.65 173.13 L 14.93 171.81 L 15.85 170.56 L 16.27 169.58 L 16.57 167.84 L 16.28 166.52 L 16.95 164.48 L 17.26 162.17 L 17.99 161.42 L 21.65 159.79 L 23.84 158.56 L 24.99 157.52 L 25.43 156.12 L 26.21 155.75 L 27.62 155.64 L 29.27 154.71 L 32.81 151.98 L 35.23 151.55 L 36.74 151.84 L 40.93 150.62 L 42.43 149.85 L 44.25 149.49 L 47.58 149.87 L 48.88 148.28 L 49.51 146.83 L 50.6 146.22 L 52.74 146.42 L 53.38 146.96 L 54.7 146.72 L 55.8 145.98 L 57.51 146.1 L 57.82 146.63 L 57.8 147.81 L 59.41 149.1 L 62.24 149.18 L 62.82 148.78 L 63.28 148 L 63.17 147.61 L 64.34 142.69 L 71.04 105.52 L 72.2 102.6 L 71.21 97.64 L 71.33 97.38 L 70.03 96.33 L 68.55 93.58 L 68.51 93.09 L 69.16 91.7 L 68.64 89.92 L 68.27 89.52 L 66.57 88.93 L 63.54 86.58 L 61.6 84.3 L 61.8 72.79 L 65.69 72.53 L 67.44 71.36 L 70.94 70.44 L 73.62 72.2 L 74.84 72.31 L 76.11 71.88 L 75.62 70.19 L 75.92 68.47 L 74.55 66.37 L 73.98 65.83 L 72.83 65.23 L 71.32 65.76 L 68.53 65.15 L 64.96 65.24 L 64.9 55.34 L 65.86 55.38 L 67.18 54.8 L 69.46 54.2 L 72.3 55.07 L 91.33 55.13 L 90.87 54.47 L 90.08 54.33 L 89.7 53.13 L 90.65 51.2 L 92.08 51.6 L 92.69 53.12 L 93.56 54.44 L 94.22 54.79 L 95.05 54.8 L 96.66 54.19 L 98.6 52.1 L 98.92 51.26 L 100.18 50.02 L 102.73 48.63 L 104.02 49.09 L 105.19 51.67 L 106.81 53.66 L 107.55 54.96 L 108.21 56.74 L 108.44 58.29 L 107.95 61.92 L 108.15 63.68 L 111.35 62.93 L 119.66 69.99 L 120.45 70.27 L 122.95 70.48 L 125.25 69.48 L 126.95 67.78 L 129.06 66.62 L 131.25 66.51 L 131.81 66.8 L 132.58 67.88 L 132.56 68.85 L 131.45 70.55 L 131.82 71.53 L 132.4 71.8 L 133.73 71.08 L 134.29 70.17 L 134.52 68.88 L 135.52 67.72 L 135.99 67.49 L 136.99 67.67 L 137.54 67.49 L 137.95 66.83 L 138.41 64.52 L 138.92 64.15 L 140.43 63.79 L 143.36 62.02 L 144.33 62.57 L 145.26 62.28 L 146.86 61.24 L 147.88 59.63 L 149.99 58.42 L 152.02 58.97 L 154.38 57.32 L 154.93 56.5 L 155.37 53.84 L 155.34 52.55 L 156.11 51.63 L 157.14 51.21 L 158.88 51.19 L 160.22 50.8 L 162.28 49.2 L 163.24 48.83 L 165.52 48.53 z"},{code:"AP",name:"Amapá",gTransform:"matrix(1 0 0 1 32.29 -262.31)",pathTransform:"translate(-338.29, -56.97)",d:"M 344.98 99.7 L 344.04 99.64 L 343.27000000000004 99.98 L 341.97 100.10000000000001 L 339.18 99.42 L 337.73 98.39 L 337.3 96.89 L 335.43 95.5 L 335.32 94.2 L 335.53 93.51 L 335.21999999999997 91.93 L 334.89 91.46000000000001 L 333.94 91.27000000000001 L 333.53 90.33000000000001 L 333.60999999999996 87.9 L 330.67999999999995 84.62 L 329.9 84.98 L 329.08 84.79 L 327.58 81.31 L 327.71 79.73 L 327.12 77.92 L 326.5 77.36 L 325.83 75.85 L 325.64 73.74 L 326.07 70.6 L 325.9 70.27 L 323.33 69.53999999999999 L 321.31 67.27999999999999 L 320.55 64.44999999999999 L 320.74 63.72999999999999 L 321.42 63.49999999999999 L 320.93 62.31999999999999 L 320.25 62.349999999999994 L 317.41 59.69 L 316.47 59.83 L 316.09000000000003 60.25 L 314.76000000000005 60.39 L 313.9200000000001 60.12 L 313.12000000000006 59.14 L 311.9800000000001 58.3 L 310.7900000000001 58.18 L 310.30000000000007 56.9 L 309.63000000000005 56.1 L 307.70000000000005 55.050000000000004 L 306.41 54.56 L 303.02000000000004 54.190000000000005 L 301.94000000000005 54.480000000000004 L 300.77000000000004 54.46 L 300.46000000000004 53.92 L 300.22 52.480000000000004 L 300.47 47.940000000000005 L 301.09000000000003 46.64000000000001 L 300.72 44.34000000000001 L 300.1 43.77000000000001 L 300.1 43.77000000000001 L 300.45000000000005 43.56000000000001 L 301.44000000000005 43.86000000000001 L 301.43000000000006 44.67000000000001 L 301.14000000000004 44.85000000000001 L 301.48 45.82000000000001 L 302.95000000000005 45.760000000000005 L 303.77000000000004 45.99 L 304.12000000000006 46.89 L 304.96000000000004 47.6 L 307.21000000000004 48.38 L 310.50000000000006 49.13 L 313.26000000000005 47.35 L 313.61000000000007 46.59 L 315.3400000000001 45.42 L 316.1700000000001 45.13 L 316.86000000000007 46.07 L 319.57000000000005 47.01 L 320.65000000000003 46.89 L 322.37000000000006 45.88 L 322.49000000000007 45.46 L 322.81000000000006 45.49 L 324.27000000000004 46.79 L 324.07000000000005 47.66 L 326.44000000000005 47.489999999999995 L 326.95000000000005 47.989999999999995 L 327.90000000000003 48.16 L 328.52000000000004 48.15 L 329.43000000000006 47.67 L 331.1000000000001 46.17 L 332.88000000000005 45.07 L 334.63000000000005 42.77 L 335.00000000000006 41.77 L 334.80000000000007 41.230000000000004 L 337.93000000000006 34.730000000000004 L 338.0400000000001 32.910000000000004 L 339.1500000000001 31.610000000000003 L 339.8800000000001 31.42 L 343.48000000000013 25.630000000000003 L 343.71000000000015 24.480000000000004 L 344.5500000000001 23.280000000000005 L 346.34000000000015 21.730000000000004 L 346.97000000000014 20.070000000000004 L 349.08000000000015 18.930000000000003 L 349.5500000000002 18.01 L 350.5900000000002 17.430000000000003 L 351.1500000000002 18.890000000000004 L 352.0300000000002 20.250000000000004 L 350.3600000000002 15.450000000000003 L 350.2900000000002 14.160000000000004 L 350.4700000000002 13.830000000000004 L 353.8400000000002 16.250000000000004 L 354.9800000000002 17.460000000000004 L 355.8900000000002 18.680000000000003 L 356.4100000000002 19.870000000000005 L 356.44000000000017 21.450000000000003 L 356.88000000000017 21.76 L 357.20000000000016 21.28 L 357.58000000000015 21.18 L 357.79000000000013 21.58 L 358.0000000000001 29.47 L 358.66000000000014 33.339999999999996 L 361.3700000000001 39.38999999999999 L 364.03000000000014 48.32999999999999 L 367.35000000000014 53.32999999999999 L 368.3600000000001 53.67999999999999 L 371.6300000000001 53.599999999999994 L 374.4100000000001 54.53999999999999 L 375.7000000000001 55.38999999999999 L 376.4700000000001 58.03999999999999 L 376.31000000000006 61.36999999999999 L 375.02000000000004 62.32999999999999 L 373.29 62.75999999999999 L 372.91 63.08999999999999 L 374.70000000000005 62.93999999999999 L 375.74000000000007 62.51999999999999 L 376.02000000000004 62.749999999999986 L 376.14000000000004 63.33999999999999 L 375.97 64.07 L 370.94000000000005 68.13 L 369.77000000000004 70.22999999999999 L 367.62000000000006 71.63999999999999 L 365.68000000000006 75.35999999999999 L 362.77000000000004 78.85999999999999 L 362.07000000000005 79.31999999999998 L 361.13000000000005 79.22999999999998 L 359.68000000000006 79.74999999999997 L 357.6000000000001 82.72999999999998 L 357.6000000000001 82.72999999999998 L 356.2600000000001 82.79999999999997 L 355.5100000000001 83.69999999999997 L 355.5100000000001 83.69999999999997 L 354.0400000000001 85.37999999999998 L 353.07000000000005 87.59999999999998 L 351.95000000000005 89.46999999999998 L 351.11000000000007 90.11999999999999 L 348.1000000000001 93.57 L 347.74000000000007 95.97 L 347.9100000000001 97.77 L 345.9600000000001 99.58 L 344.98 99.7 z M 368.34 52.71 L 367.89 52.38 L 366.78999999999996 50.52 L 366.85999999999996 49.64 L 367.09 49.230000000000004 L 368.75 48.78 L 369.18 49.17 L 370.01 51.440000000000005 L 369.02 52.540000000000006 L 368.34 52.71 z M 370.83 70.32 L 370.43 70.07 L 370.35 69.36 L 371.46000000000004 68.26 L 372.34000000000003 68.11 L 373.59000000000003 68.35 L 374.05 68.24 L 374.49 67.6 L 374.54 68.19 L 373.57 69.63 L 372.58 70.13 L 370.83 70.32 z M 374.27 67.45 L 373.49 67.22 L 373.49 66.66 L 374.21000000000004 65.61999999999999 L 375.46000000000004 65.52 L 375.64000000000004 65.86999999999999 L 375.54 66.38 L 374.27 67.45 z M 367.08 49.03 L 366.32 48.53 L 366.58 47.7 L 367.46 47.53 L 368.32 47.85 L 368.33 48.58 L 367.08 49.03 z"},{code:"BA",name:"Bahia",gTransform:"matrix(1 0 0 1 193.52 -26.39)",pathTransform:"translate(-499.52, -292.87)",d:"M 527.5 365.33 L 527.14 364.5 L 527.8199999999999 363.15 L 527.81 362.62 L 527.28 361.58 L 523.15 358.53 L 523 358.02 L 523.22 356.51 L 522.65 355.28 L 522 355.52 L 521.8 355.96999999999997 L 521.4599999999999 356.15 L 521.2399999999999 355.9 L 521.7699999999999 351.5 L 522.5899999999999 348.2 L 523.41 347.32 L 525.88 347.56 L 526.9 346.85 L 526.9 346.43 L 526.34 345.41 L 526.5 342.76000000000005 L 531.46 338.54 L 532.9300000000001 335.46000000000004 L 532.5100000000001 334.29 L 531.7300000000001 333.27000000000004 L 530.8400000000001 333.21000000000004 L 530.1100000000001 332.83000000000004 L 527.2800000000001 330.36 L 525.1600000000001 330.38 L 522.97 329.78 L 520.7 328.7 L 517.97 328.14 L 515.99 328 L 514.67 328.99 L 513.1999999999999 329.49 L 510.5899999999999 329.04 L 510.0199999999999 329.25 L 509.5799999999999 325.29 L 503.05999999999995 319.09000000000003 L 502.67999999999995 318.91 L 498.28999999999996 320.14000000000004 L 496.76 318.90000000000003 L 496.25 319.11 L 495.32 318.89 L 492.78 317.66999999999996 L 490.60999999999996 316.04999999999995 L 489.62999999999994 316.22999999999996 L 485.2799999999999 312.59999999999997 L 484.1799999999999 312.05999999999995 L 481.4499999999999 311.30999999999995 L 479.6799999999999 311.55999999999995 L 477.7999999999999 312.4599999999999 L 476.9899999999999 313.5799999999999 L 476.3499999999999 313.75999999999993 L 471.0199999999999 312.2899999999999 L 470.4099999999999 311.7999999999999 L 470.1499999999999 310.2999999999999 L 470.2899999999999 309.4099999999999 L 471.5799999999999 306.6699999999999 L 470.7199999999999 306.2099999999999 L 468.43999999999994 305.68999999999994 L 466.25999999999993 305.6499999999999 L 465.05999999999995 305.1499999999999 L 463.2699999999999 305.06999999999994 L 459.43999999999994 306.6499999999999 L 455.17999999999995 309.6799999999999 L 454.53999999999996 310.7899999999999 L 451.16999999999996 312.6599999999999 L 449.15 313.0599999999999 L 448.2 314.2399999999999 L 446.39 315.7899999999999 L 444.96 316.3099999999999 L 443.96 316.1599999999999 L 442.10999999999996 318.7399999999999 L 441.06999999999994 319.5099999999999 L 438.93999999999994 319.1299999999999 L 438.2199999999999 319.2599999999999 L 437.5299999999999 320.2599999999999 L 436.18999999999994 321.1799999999999 L 435.78999999999996 320.9399999999999 L 437.21999999999997 317.5099999999999 L 436.71 315.09999999999985 L 436.71 315.09999999999985 L 438.19 313.1299999999998 L 438.44 312.35999999999984 L 438.21 311.08999999999986 L 437.53999999999996 309.36999999999983 L 437.64 308.6999999999998 L 438.34999999999997 307.2799999999998 L 438.29999999999995 306.8199999999998 L 435.09 304.1999999999998 L 433.4 300.73999999999984 L 432.78 297.21999999999986 L 432.83 295.66999999999985 L 434.03 291.83999999999986 L 435.61999999999995 290.8099999999999 L 435.84999999999997 290.4299999999999 L 435.90999999999997 289.4899999999999 L 434.28 288.6499999999999 L 434.16999999999996 288.31999999999994 L 434.65 285.79999999999995 L 436.08 284.73999999999995 L 436.06 284.36999999999995 L 433.34 281.90999999999997 L 433.34 281.90999999999997 L 433.29999999999995 280.97999999999996 L 434.65999999999997 278.59999999999997 L 434.61999999999995 277.53 L 434.44999999999993 277.10999999999996 L 432.98999999999995 276.61999999999995 L 432.04999999999995 275.96999999999997 L 431.69999999999993 274.71 L 431.75999999999993 271.78999999999996 L 431.94999999999993 270.93999999999994 L 433.8999999999999 269.2699999999999 L 435.0399999999999 268.8499999999999 L 435.9999999999999 268.1299999999999 L 435.70999999999987 267.4999999999999 L 435.1299999999999 266.9799999999999 L 434.20999999999987 266.6899999999999 L 433.1799999999999 266.8699999999999 L 432.82999999999987 266.5399999999999 L 432.7399999999999 266.0399999999999 L 433.1599999999999 265.0799999999999 L 435.19999999999993 264.25999999999993 L 435.75999999999993 263.80999999999995 L 435.7199999999999 263.04999999999995 L 433.8399999999999 262.06999999999994 L 430.25999999999993 261.3999999999999 L 428.3999999999999 259.43999999999994 L 428.1699999999999 258.5199999999999 L 428.6699999999999 257.3599999999999 L 429.6799999999999 256.6299999999999 L 431.1999999999999 253.1499999999999 L 432.09999999999985 252.53999999999988 L 433.10999999999984 252.26999999999987 L 433.45999999999987 251.88999999999987 L 432.16999999999985 250.08999999999986 L 432.35999999999984 249.71999999999986 L 435.5699999999998 247.09999999999985 L 439.3899999999998 245.07999999999984 L 439.9499999999998 244.60999999999984 L 440.16999999999985 243.62999999999985 L 440.85999999999984 242.97999999999985 L 440.85999999999984 242.97999999999985 L 443.1899999999998 242.95999999999984 L 444.6299999999998 244.29999999999984 L 445.28999999999985 245.33999999999983 L 445.8199999999998 247.54999999999984 L 447.5799999999998 250.03999999999985 L 451.7599999999998 251.89999999999986 L 453.55999999999983 251.37999999999985 L 455.66999999999985 251.55999999999986 L 455.99999999999983 251.34999999999985 L 456.74999999999983 249.89999999999986 L 457.8899999999998 249.52999999999986 L 458.55999999999983 248.65999999999985 L 459.72999999999985 247.76999999999987 L 461.9399999999998 247.01999999999987 L 463.2699999999998 247.18999999999986 L 464.74999999999983 247.71999999999986 L 466.09999999999985 247.29999999999987 L 469.0699999999999 244.87999999999988 L 472.01999999999987 239.82999999999987 L 472.7399999999999 238.96999999999986 L 472.9799999999999 238.04999999999987 L 473.2799999999999 235.48999999999987 L 473.1599999999999 234.32999999999987 L 470.9199999999999 229.89999999999986 L 470.9699999999999 228.96999999999986 L 474.2099999999999 227.31999999999985 L 476.1599999999999 227.29999999999984 L 477.6599999999999 227.75999999999985 L 478.06999999999994 228.68999999999986 L 478.38999999999993 228.86999999999986 L 480.50999999999993 228.43999999999986 L 481.8999999999999 227.89999999999986 L 483.2299999999999 228.27999999999986 L 484.9399999999999 229.26999999999987 L 484.8099999999999 229.91999999999987 L 484.9999999999999 230.20999999999987 L 485.8199999999999 230.48999999999987 L 488.8199999999999 230.37999999999985 L 490.2899999999999 229.73999999999987 L 491.9899999999999 229.63999999999987 L 492.8099999999999 228.41999999999987 L 494.3199999999999 227.07999999999987 L 497.0499999999999 226.73999999999987 L 497.8199999999999 226.37999999999985 L 498.6299999999999 225.39999999999986 L 500.7999999999999 225.40999999999985 L 501.4199999999999 226.03999999999985 L 501.7299999999999 226.08999999999986 L 503.5899999999999 224.27999999999986 L 503.4899999999999 221.87999999999985 L 505.4799999999999 221.49999999999986 L 506.2699999999999 221.67999999999986 L 507.31999999999994 221.01999999999987 L 508.81999999999994 218.70999999999987 L 509.2799999999999 217.55999999999986 L 509.2799999999999 217.55999999999986 L 510.1699999999999 217.95999999999987 L 511.3299999999999 217.68999999999986 L 513.53 217.97999999999985 L 516.35 219.36999999999983 L 516.7900000000001 219.87999999999982 L 516.7300000000001 222.60999999999981 L 517.4500000000002 224.5499999999998 L 519.6600000000002 225.4599999999998 L 519.9300000000002 227.4599999999998 L 519.0100000000002 229.13999999999982 L 520.8400000000003 229.75999999999982 L 521.8000000000003 229.53999999999982 L 522.6200000000003 228.61999999999983 L 525.4900000000004 227.73999999999984 L 526.2600000000003 224.15999999999983 L 526.7600000000003 223.28999999999982 L 527.5100000000003 223.12999999999982 L 528.2900000000003 223.65999999999983 L 528.9200000000003 223.70999999999984 L 531.3100000000003 222.68999999999983 L 532.4100000000003 221.44999999999982 L 532.5800000000003 220.85999999999981 L 532.3300000000003 219.4999999999998 L 532.6200000000002 219.2499999999998 L 534.8600000000002 218.7999999999998 L 535.6300000000002 216.7499999999998 L 537.2800000000002 216.3099999999998 L 539.8100000000002 214.8499999999998 L 540.4000000000002 214.7499999999998 L 541.8900000000002 215.3099999999998 L 542.7200000000003 216.7499999999998 L 544.0800000000003 217.5599999999998 L 546.4400000000003 218.3399999999998 L 549.4300000000003 218.7399999999998 L 551.0100000000003 219.88999999999982 L 551.5500000000003 221.53999999999982 L 551.9400000000003 221.80999999999983 L 552.3700000000002 221.65999999999983 L 552.6600000000002 219.90999999999983 L 553.0900000000001 219.46999999999983 L 554.0900000000001 219.45999999999984 L 554.5400000000002 219.77999999999983 L 554.5600000000002 220.40999999999983 L 553.9400000000002 221.28999999999982 L 554.3900000000002 222.11999999999983 L 554.8900000000002 222.48999999999984 L 556.9900000000002 223.34999999999985 L 557.0100000000002 224.28999999999985 L 558.2300000000002 227.33999999999986 L 558.2300000000002 227.33999999999986 L 558.7700000000002 228.73999999999987 L 559.7900000000002 229.02999999999986 L 560.2400000000002 228.93999999999986 L 561.6700000000002 229.72999999999985 L 561.8700000000002 230.44999999999985 L 561.8700000000002 230.44999999999985 L 561.2000000000003 231.60999999999984 L 561.4100000000003 233.74999999999983 L 562.6900000000003 236.24999999999983 L 564.6800000000003 238.19999999999982 L 565.4300000000003 239.34999999999982 L 565.3500000000003 242.46999999999983 L 564.6900000000003 244.08999999999983 L 564.6000000000003 244.96999999999983 L 565.3600000000002 247.71999999999983 L 565.0600000000003 248.29999999999984 L 564.3700000000002 248.84999999999985 L 561.8200000000003 249.84999999999985 L 560.6900000000003 249.09999999999985 L 558.9800000000002 249.08999999999986 L 558.6600000000002 249.38999999999987 L 558.0700000000002 250.96999999999989 L 558.0900000000001 251.7399999999999 L 559.0400000000002 253.3399999999999 L 560.1400000000002 253.9999999999999 L 560.6600000000002 255.4899999999999 L 562.0900000000001 256.9999999999999 L 562.2400000000001 257.3899999999999 L 562.1100000000001 258.8099999999999 L 561.7700000000001 259.1999999999999 L 561.8900000000001 259.6199999999999 L 562.4800000000001 260.1399999999999 L 564.4100000000001 261.0599999999999 L 564.8900000000001 261.76999999999987 L 565.4300000000001 262.10999999999984 L 566.98 262.74999999999983 L 569.87 261.86999999999983 L 569.87 261.86999999999983 L 570.51 261.84999999999985 L 570.87 262.2599999999999 L 566.79 271.08999999999986 L 562.9599999999999 276.27999999999986 L 561.93 278.60999999999984 L 556.9 284.34999999999985 L 554.4499999999999 285.60999999999984 L 553.5799999999999 285.59999999999985 L 553.8799999999999 284.16999999999985 L 554.2499999999999 284.01999999999987 L 554.3899999999999 282.91999999999985 L 553.9399999999998 280.98999999999984 L 552.0699999999998 280.73999999999984 L 551.6399999999999 279.4399999999998 L 550.9599999999999 278.6899999999998 L 550.5899999999999 279.28999999999985 L 550.1299999999999 281.61999999999983 L 549.6299999999999 282.48999999999984 L 549.0799999999999 282.86999999999983 L 548.52 282.5799999999998 L 548.03 280.8399999999998 L 548.14 280.5199999999998 L 548.4499999999999 280.3899999999998 L 548.42 279.99999999999983 L 547.55 281.28999999999985 L 548.4799999999999 282.97999999999985 L 548.9399999999999 283.20999999999987 L 549.31 283.0599999999999 L 550.4599999999999 283.3199999999999 L 549.9999999999999 285.1299999999999 L 548.7899999999998 286.27999999999986 L 548.5399999999998 288.09999999999985 L 547.2899999999998 289.0699999999999 L 546.9399999999998 289.7399999999999 L 546.7399999999998 290.57999999999987 L 546.9199999999997 291.4299999999999 L 545.5699999999997 291.0399999999999 L 545.3599999999997 291.4299999999999 L 544.9999999999997 293.9499999999999 L 545.3599999999997 293.22999999999985 L 546.1099999999997 293.4399999999998 L 546.3499999999997 293.97999999999985 L 546.1199999999997 294.3899999999999 L 546.1799999999996 295.0099999999999 L 546.4799999999996 295.3099999999999 L 546.8099999999996 296.3099999999999 L 545.7699999999996 298.8199999999999 L 546.3399999999997 302.2599999999999 L 545.7899999999997 302.7499999999999 L 545.2199999999997 302.52999999999986 L 545.0799999999997 303.65999999999985 L 545.6699999999997 304.11999999999983 L 546.8799999999998 302.3999999999998 L 546.4099999999997 300.1899999999998 L 547.2299999999998 299.5799999999998 L 547.4799999999998 300.11999999999983 L 547.4199999999998 301.8799999999998 L 546.4599999999998 304.48999999999984 L 545.7199999999998 309.91999999999985 L 545.2099999999998 311.72999999999985 L 545.4099999999999 314.1999999999999 L 546.1899999999998 317.0499999999999 L 546.3799999999999 321.5899999999999 L 547.2499999999999 327.99999999999994 L 548.2399999999999 331.41999999999996 L 546.0299999999999 338.08 L 544.6799999999998 344.72999999999996 L 544.2099999999998 345.73999999999995 L 544.0499999999998 348.59999999999997 L 542.9899999999999 352.32 L 542.8999999999999 354.65 L 543.2899999999998 359.07 L 544.1799999999998 360.78 L 541.9399999999998 363.76 L 540.1299999999999 364.43 L 539.1899999999998 365.07 L 536.4699999999998 368.96 L 535.9 371 L 535.9 371 L 527.81 365.86 L 527.5 365.33 z M 549.78 287.33 L 549.55 286.13 L 550.29 285.71999999999997 L 551.3499999999999 284.67999999999995 L 551.5099999999999 284.03999999999996 L 551.1399999999999 283.30999999999995 L 551.8999999999999 283.44999999999993 L 552.7199999999999 284.49999999999994 L 552.67 285.0299999999999 L 549.78 287.33 z M 547.25 294.18 L 546.62 294.15000000000003 L 546.63 293.48 L 546.89 293.12 L 546.09 292.9 L 545.6700000000001 292.5 L 545.8000000000001 291.43 L 547.6700000000001 291.28000000000003 L 547.83 291.48 L 547.94 292.61 L 547.25 294.18 z"},{code:"CE",name:"Ceará",gTransform:"matrix(1 0 0 1 235.04 -154.64)",pathTransform:"translate(-541.04, -164.62)",d:"M 573.79 156.85 L 568.9 158.44 L 566.29 160.45 L 562.99 167.14 L 562.15 168.26 L 561.28 168.83 L 560.63 170.5 L 560.78 171.24 L 559.38 173.68 L 557.92 175.19 L 557.35 176.29 L 556.32 176.55 L 555.54 176.04 L 555.03 176.11 L 554.19 176.99 L 552.78 179.24 L 552.44 181.21 L 553.08 181.38 L 553.74 181 L 553.74 181 L 553.66 181.54 L 552.82 182.69 L 551.79 185.69 L 552.31 187 L 551.65 188.31 L 550.56 188.94 L 550.39 189.32 L 550.27 190.25 L 550.51 190.66 L 551.09 190.95 L 551.44 191.67 L 551.42 193.33 L 552.66 194.22 L 553.35 194.3 L 553.69 195.49 L 552.08 198.98 L 550.89 200.1 L 551.06 200.35 L 551.06 200.35 L 549.47 200.84 L 548.4 201.67 L 546.86 203.96 L 545.21 204.01 L 544.58 202.37 L 543.8 201.8 L 542.44 201.32 L 541.43 200.25 L 540.97 199.26 L 539.14 198.43 L 536.29 196.53 L 533.21 196.11 L 531.92 196.21 L 529.78 197.01 L 528.15 197.2 L 527.26 196.96 L 522.33 196.76 L 522.33 196.76 L 522.39 195.44 L 521.71 194.76 L 521.63 193.79 L 522.77 190.68 L 524.27 188.43 L 524.28 187.74 L 523.51 186.58 L 520.95 186.11 L 519.64 185.46 L 518.63 182.79 L 517.58 177.59 L 516.82 175.02 L 517.06 174.57 L 516.12 166.41 L 516.01 166.03 L 515.09 165.34 L 515.89 164.76 L 516.48 163.18 L 515.88 160.19 L 514.88 158.18 L 515.36 156.58 L 514.57 152.71 L 515.31 151.35 L 515.33 150.59 L 513.97 149 L 513.53 147.27 L 510.38 140.85 L 508.58 136.13 L 508.29 134.84 L 508.47 133.38 L 510.05 131.41 L 511.14 129.56 L 511.25 128.76 L 511.25 128.76 L 511.44 128.62 L 511.4 128 L 511 127.34 L 511.65 126.53 L 518.39 126.31 L 521.28 125.88 L 523.35 125.22 L 530.75 126.01 L 532.87 127.13 L 534.81 128.63 L 538.93 130.81 L 540.39 131.33 L 545.21 134.33 L 546.42 134.53 L 548.64 136.82 L 551.63 138.93 L 554.2 139.65 L 556.64 142.56 L 557.86 143.17 L 560.82 146.98 L 564.98 150.06 L 566.44 152.06 L 567.48 153.05 L 568.98 153.87 L 570.13 153.9 L 572.5 154.82 L 573.29 155.49 z"},{code:"DF",name:"Distrito Federal",gTransform:"matrix(1 0 0 1 103.1 10.18)",pathTransform:"translate(-409.11, -329.45)",d:"M 416.71 333.87 L 402.02 333.85 L 401.5 330.59 L 402.42 328.76 L 402.8 325.03 L 414.75 325.04 L 416.58 327.02 L 416.64 329.23 L 416.05 330.42 L 415.84 332.86 z"},{code:"ES",name:"Espírito Santo",gTransform:"matrix(1 0 0 1 212.62 72.56)",pathTransform:"translate(-518.62, -391.82)",d:"M 501.63 411.37 L 501.34 411.23 L 501.78 408.89 L 502.35 407.59 L 501.76 404.47 L 501.92 404.05 L 503.64 401.99 L 508.79 402.02 L 509.34 401.7 L 510.31 398.46 L 511.42 397.19 L 512.3 394.9 L 512.54 393.18 L 512.8 392.74 L 514.04 391.88 L 515.75 389.79 L 516.29 386.82 L 516 384.39 L 514.73 381.58 L 513.63 380.31 L 513.11 380.22 L 512.66 380.51 L 511.9 380.23 L 511.41 379.52 L 511.84 378.97 L 513.32 378.88 L 514.12 379.23 L 515.09 379.26 L 516.04 379.02 L 516.36 378.6 L 516.19 376.88 L 514.88 376.53 L 514.67 376.12 L 514.97 374.58 L 515 372.66 L 514.48 372 L 513.15 371.33 L 512.85 370.63 L 514.02 368.7 L 516.19 367.39 L 516.5 367.37 L 517.55 368.11 L 518.68 368.22 L 518.7 367.41 L 517.03 365.14 L 518.37 365.27 L 520.55 364.98 L 521.39 364.37 L 522.47 364.05 L 524.05 363.97 L 526.59 364.78 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.5 365.33 L 527.8 365.86 L 535.9 371 L 535.9 371 L 534.97 374.35 L 534.66 377.21 L 534.78 380.8 L 535.5 386.95 L 535.19 389.42 L 533.7 392.6 L 530.95 393.99 L 530.4 394.59 L 528.73 397.92 L 527.75 401.72 L 526.98 403.19 L 526.15 402.51 L 525.27 402.38 L 524.98 403.66 L 526.33 404.18 L 524.39 408.42 L 520.94 412.26 L 520.7 411.99 L 518.84 412.65 L 518.04 413.88 L 517.98 415.27 L 517.56 416.52 L 515.97 418.54 L 515.68 419.67 L 515.68 419.67 L 514.06 418.61 L 511.07 418.98 L 506.73 417.97 L 504.23 416.84 L 503.56 412.13 z"},{code:"GO",name:"Goiás",gTransform:"matrix(1 0 0 1 75.37 14.13)",pathTransform:"translate(-381.37, -333.38)",d:"M 416.71 333.87 L 415.84 332.86 L 416.05 330.42 L 416.64 329.23 L 416.58 327.02 L 414.75 325.04 L 402.8 325.03 L 402.42 328.76 L 401.5 330.59 L 402.02 333.85 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.71 333.87 L 416.18 335.39 L 416.49 336.96 L 415.81 338.55 L 414.77 339.8 L 414.36 341.27 L 415.21 342.48 L 416.06 342.82 L 417.48 343.85 L 419.13 348.41 L 419.13 349.01 L 416.81 351.72 L 413.57 354.73 L 413.14 356.87 L 414.23 357.98 L 415.13 357.51 L 416.71 358.08 L 417.18 358.69 L 417.36 359.69 L 417.19 360.4 L 416.46 361.3 L 415.95 363.19 L 417.14 366.65 L 414.05 368.71 L 412.89 368.91 L 412.03 369.81 L 411.55 370.93 L 406.66 373.67 L 405.96 372.9 L 401.61 371.04 L 401.06 371.52 L 400.48 371.61 L 398.73 371.62 L 397.25 371.34 L 393.39 371.5 L 391.38 370.61 L 387.25 373.25 L 384.34 376.17 L 384.01 376.17 L 382.7 374.75 L 381.18 374.45 L 377.99 376.09 L 374.28 375.47 L 371.8 376.43 L 369.57 376.97 L 368.16 379.07 L 366.95 381.53 L 367.01 382.53 L 366.17 383.83 L 365.35 384.11 L 364.51 383.95 L 364.06 384.09 L 363.12 384.83 L 361.48 386.93 L 360.91 388.83 L 361.47 389.44 L 361.46 389.78 L 361.1 390.01 L 360.24 389.55 L 360.24 389.55 L 360 389.1 L 357.34 386.86 L 354.19 386.25 L 352.57 384.7 L 350.67 384.27 L 349.18 384.23 L 345.83 382.89 L 345.15 382.04 L 342.08 380.48 L 341.41 379.87 L 339.97 379.16 L 338.83 378.99 L 336.13 377.31 L 333.35 377.47 L 329.55 376.77 L 329.42 376.44 L 329.68 375.6 L 330.25 374.43 L 331.56 372.67 L 331.48 372.25 L 329.23 371.35 L 328.09 372.02 L 327.43 371.83 L 327.15 371.42 L 326.92 370.31 L 327.18 367.73 L 326.99 365.96 L 326.99 365.96 L 326.04 363.76 L 325.86 360.33 L 324.45 358.14 L 324.29 357.43 L 324.69 354.02 L 327.24 350.17 L 327.62 347.26 L 328.32 346.49 L 330.34 345.65 L 332.26 343.88 L 333.51 341.86 L 333.84 339.91 L 334.34 338.9 L 335.62 337.86 L 336.44 336.43 L 336.52 334.89 L 338.27 333.92 L 339.67 331.3 L 342.32 331.17 L 345.04 330.31 L 345.36 330.03 L 347.34 325.84 L 348.05 324.88 L 348.69 320.78 L 349.07 320.04 L 350.99 318.1 L 352.64 317.09 L 353.71 316.83 L 354.94 317.51 L 356.15 316.78 L 357.54 315.35 L 358.38 312.42 L 359.55 309.55 L 359.54 308.75 L 359.06 307.61 L 359.64 304.87 L 361.24 301.78 L 361.12 296.6 L 362.33 295.82 L 363.36 293.19 L 365.36 290.02 L 365.75 288.95 L 365.59 286.23 L 365.94 285.33 L 366.91 284.47 L 367.18 283.34 L 367.1 282.71 L 367.1 282.71 L 367.44 282.26 L 367.64 280.38 L 368.3 279.15 L 370.11 277.06 L 370.67 276.76 L 370.64 278.47 L 369.42 280.35 L 368.9 282.69 L 371.3 283.09 L 373.5 284.12 L 377.43 284.52 L 380.52 286.23 L 384.59 287.66 L 385.22 287.43 L 386.85 281.49 L 388.32 279.1 L 389.5 278.13 L 390.65 279.44 L 391.69 281.32 L 392.8 285.03 L 393.41 288.13 L 394.55 288.18 L 395.3 287.43 L 395.6 286.43 L 396.16 285.89 L 398.92 286.23 L 403.45 285.7 L 403.67 286.44 L 403.11 288 L 406.24 289.47 L 409.59 290.15 L 410.28 290.07 L 410.79 286.77 L 411.34 286.8 L 412.85 289.42 L 413.31 289.66 L 415.09 288.76 L 417.61 286.68 L 422.14 285.68 L 423.69 285.68 L 426.25 284.58 L 427.99 283.24 L 433.35 281.82 L 433.35 281.82 L 436.07 284.28 L 436.09 284.66 L 434.66 285.72 L 434.18 288.24 L 434.28 288.57 L 435.91 289.41 L 435.85 290.35 L 435.62 290.73 L 434.03 291.76 L 432.84 295.59 L 432.79 297.14 L 433.41 300.66 L 435.11 304.12 L 438.32 306.74 L 438.37 307.21 L 437.65 308.63 L 437.55 309.3 L 438.22 311.02 L 438.45 312.3 L 438.2 313.07 L 436.72 315.04 L 436.72 315.04 L 435.72 316.05 L 432.49 315.71 L 431.59 313.95 L 429.17 312.47 L 428 313.96 L 428.58 317.73 L 428.01 318.27 L 427.61 318.4 L 424.83 317.26 L 423.66 317.49 L 423.29 317.77 L 422.57 320.95 L 423.29 321.05 L 423.78 322.21 L 423.21 323.15 L 422.48 323.85 L 422.52 325.75 L 422.94 326.36 L 423.47 326.55 L 424.16 330.81 L 423.63 331.34 L 420.27 332.24 L 417.98 333.75 z"},{code:"MA",name:"Maranhão",gTransform:"matrix(1 0 0 1 142.22 -148.63)",pathTransform:"translate(-448.22, -170.64)",d:"M 458.57 128.92 L 458.53 129.25 L 456.48999999999995 131.4 L 456.05999999999995 131.57 L 456.0199999999999 133.01 L 457.98999999999995 131.31 L 458.66999999999996 130.1 L 460.78999999999996 128.51999999999998 L 461.67999999999995 127.37999999999998 L 462.7099999999999 121.04999999999998 L 463.8599999999999 120.34999999999998 L 464.9699999999999 120.22999999999998 L 466.63999999999993 119.30999999999997 L 467.2899999999999 119.17999999999998 L 467.7499999999999 119.29999999999998 L 467.82999999999987 120.92999999999998 L 467.6299999999999 121.37999999999998 L 466.20999999999987 123.24999999999999 L 462.9999999999999 124.99999999999999 L 462.9699999999999 125.71999999999998 L 463.69999999999993 125.83999999999999 L 464.1499999999999 125.02999999999999 L 465.2999999999999 124.71999999999998 L 465.5199999999999 125.54999999999998 L 464.92999999999995 126.05999999999999 L 465.17999999999995 126.35999999999999 L 469.38999999999993 121.38999999999999 L 470.24999999999994 121.71999999999998 L 472.8299999999999 120.78999999999998 L 476.86999999999995 121.21999999999998 L 476.40999999999997 118.80999999999999 L 477.02 118.57999999999998 L 479.44 118.65999999999998 L 481.21999999999997 119.03999999999998 L 483.84999999999997 120.08999999999997 L 484.89 120.19999999999997 L 487.03999999999996 121.57999999999997 L 488.43999999999994 121.60999999999997 L 489.69999999999993 122.90999999999997 L 491.5899999999999 124.22999999999996 L 494.0899999999999 124.80999999999996 L 495.24999999999994 124.61999999999996 L 495.80999999999995 125.37999999999997 L 496.1499999999999 125.42999999999996 L 497.7399999999999 125.33999999999996 L 500.1999999999999 125.99999999999996 L 500.45999999999987 125.09999999999995 L 499.78999999999985 124.62999999999995 L 501.45999999999987 124.24999999999996 L 502.02999999999986 124.35999999999996 L 501.9399999999999 124.77999999999996 L 501.9399999999999 124.77999999999996 L 501.4799999999999 126.20999999999997 L 501.7099999999999 126.92999999999996 L 502.3399999999999 127.46999999999997 L 501.9599999999999 128.99999999999997 L 500.1699999999999 131.26999999999998 L 496.0399999999999 135.23999999999998 L 492.7199999999999 135.7 L 491.9199999999999 135.54 L 488.9999999999999 138.94 L 489.0399999999999 140.74 L 488.1599999999999 142.57000000000002 L 486.2699999999999 144.42000000000002 L 485.44999999999993 146.4 L 484.80999999999995 146.57 L 484.03999999999996 147.62 L 484.4 149.54 L 485.63 150.37 L 486.01 151.65 L 485.73 153.11 L 484.59000000000003 155.98000000000002 L 486.17 158.79000000000002 L 486.72 161.77 L 486.61 164.20000000000002 L 486.40000000000003 164.75000000000003 L 482.3 169.17000000000002 L 482.13 171.65 L 482.25 173.76000000000002 L 482.76 176.06000000000003 L 484.53999999999996 178.10000000000002 L 486.15 179.01000000000002 L 486.32 179.51000000000002 L 486.45 180.35000000000002 L 486.06 182.55 L 485.77 182.99 L 485.65 184.20000000000002 L 485.15 185.66000000000003 L 483.94 186.97000000000003 L 481.65 187.26000000000002 L 481 186.98000000000002 L 480.17 187.02 L 477.74 187.88000000000002 L 476.22 187.99000000000004 L 473.72 186.17000000000004 L 472.71000000000004 185.96000000000004 L 471.25000000000006 186.15000000000003 L 470.24000000000007 186.75000000000003 L 469.12000000000006 187.01000000000002 L 468.89000000000004 186.71 L 468.05000000000007 186.95000000000002 L 467.55000000000007 187.17000000000002 L 465.6500000000001 189.08 L 465.6600000000001 189.54000000000002 L 465.0300000000001 190.41000000000003 L 463.0200000000001 192.41000000000003 L 460.6800000000001 193.32000000000002 L 457.8100000000001 195.88000000000002 L 456.48000000000013 196.41000000000003 L 455.4300000000001 196.45000000000002 L 453.73000000000013 197.98000000000002 L 452.65000000000015 198.34000000000003 L 450.04000000000013 198.66000000000003 L 447.3200000000001 199.42000000000002 L 445.1900000000001 201.37 L 444.2100000000001 204.34 L 443.8200000000001 207.31 L 443.1900000000001 209.63 L 441.7400000000001 212.37 L 441.4400000000001 212.59 L 441.10000000000014 213.41 L 440.97000000000014 214.93 L 439.77000000000015 217.41 L 438.07000000000016 218.81 L 437.34000000000015 220.81 L 438.0500000000001 222.75 L 438.52000000000015 225.93 L 440.25000000000017 228.99 L 440.21000000000015 229.51000000000002 L 439.45000000000016 230.91000000000003 L 439.32000000000016 237.27000000000004 L 438.1700000000002 239.72000000000003 L 437.9100000000002 240.78000000000003 L 437.8600000000002 242.70000000000002 L 437.8600000000002 242.70000000000002 L 436.5800000000002 242.04000000000002 L 435.9700000000002 241.22000000000003 L 435.1500000000002 240.77000000000004 L 434.1600000000002 240.48000000000005 L 432.3800000000002 240.68000000000004 L 431.67000000000024 240.50000000000003 L 430.3200000000002 238.50000000000003 L 429.3300000000002 235.64000000000001 L 427.2000000000002 234.02 L 427.06000000000023 232.37 L 428.7000000000002 230.56 L 428.62000000000023 230.03 L 424.74000000000024 228.08 L 424.12000000000023 227.03 L 424.06000000000023 225.37 L 423.31000000000023 223.78 L 422.37000000000023 223.09 L 420.29000000000025 222.81 L 420.09000000000026 222.39000000000001 L 420.35000000000025 221.68 L 422.98000000000025 219.14000000000001 L 422.61000000000024 217.83 L 423.34000000000026 215.15 L 424.03000000000026 213.72 L 424.60000000000025 213.17 L 425.9400000000002 212.63 L 429.3300000000002 212.28 L 428.9400000000002 210.93 L 429.5800000000002 207.68 L 429.5000000000002 205.92000000000002 L 427.7000000000002 204.71 L 423.43000000000023 205.65 L 421.28000000000026 206.99 L 419.0100000000003 203.97 L 418.10000000000025 203.12 L 415.10000000000025 198.97 L 414.22000000000025 199.04 L 413.3800000000003 197.6 L 413.9900000000003 196.41 L 413.8800000000003 195.53 L 413.6300000000003 195.19 L 412.2600000000003 194.95 L 411.84000000000026 195.22 L 409.91000000000025 193.89 L 410.09000000000026 193.17999999999998 L 411.85000000000025 192.51999999999998 L 413.60000000000025 190.48 L 413.85000000000025 188.89 L 413.5700000000003 187.89 L 413.8800000000003 185.52999999999997 L 415.65000000000026 179.36999999999998 L 415.66000000000025 178.93999999999997 L 414.98000000000025 177.79999999999998 L 414.7500000000002 176.71999999999997 L 414.9600000000002 172.99999999999997 L 414.3200000000002 171.49999999999997 L 413.8500000000002 168.00999999999996 L 413.0100000000002 166.97999999999996 L 409.61000000000024 165.53999999999996 L 408.3900000000002 165.51999999999995 L 408.11000000000024 165.19999999999996 L 408.03000000000026 164.16999999999996 L 407.4400000000003 163.47999999999996 L 405.7000000000003 163.18999999999997 L 404.7400000000003 163.70999999999998 L 403.3400000000003 163.61999999999998 L 400.56000000000034 162.10999999999999 L 399.70000000000033 162.04999999999998 L 397.74000000000035 162.57999999999998 L 395.12000000000035 164.42999999999998 L 394.5900000000004 165.06999999999996 L 394.5900000000004 165.06999999999996 L 394.10000000000036 164.98999999999995 L 408.81000000000034 153.15999999999994 L 411.16000000000037 153.38999999999993 L 412.3300000000004 152.46999999999994 L 413.8800000000004 150.29999999999995 L 414.3100000000004 149.14999999999995 L 415.8600000000004 147.97999999999996 L 416.4800000000004 145.09999999999997 L 417.6000000000004 144.63999999999996 L 420.0400000000004 142.31999999999996 L 420.51000000000045 141.10999999999996 L 420.80000000000047 139.20999999999995 L 422.4000000000005 134.51999999999995 L 424.36000000000047 132.97999999999996 L 425.8400000000005 131.21999999999997 L 426.67000000000047 129.76999999999998 L 427.13000000000045 128.48999999999998 L 426.95000000000044 126.66999999999999 L 427.74000000000046 125.85999999999999 L 426.70000000000044 124.27999999999999 L 430.38000000000045 121.18999999999998 L 430.25000000000045 119.54999999999998 L 430.75000000000045 117.16999999999999 L 432.49000000000046 115.6 L 432.8500000000005 114.89 L 433.75000000000045 111.87 L 433.83000000000044 110.26 L 433.40000000000043 109.73 L 432.4100000000004 109.89 L 432.14000000000044 109.4 L 432.19000000000045 108.78 L 433.33000000000044 108.63 L 433.90000000000043 107.89 L 434.6100000000004 103.5 L 434.4500000000004 102.12 L 434.9200000000004 101.09 L 435.6900000000004 100.64 L 435.6900000000004 100.64 L 436.3200000000004 100.64 L 436.5600000000004 100.4 L 436.5000000000004 99.86 L 436.8400000000004 99.11 L 437.42000000000036 98.58 L 438.76000000000033 99.56 L 439.2100000000003 101.4 L 440.4000000000003 101.52000000000001 L 441.1700000000003 100.16000000000001 L 441.7800000000003 103.09000000000002 L 442.7700000000003 103.13000000000002 L 443.06000000000034 102.64000000000003 L 443.13000000000034 101.70000000000003 L 443.98000000000036 101.66000000000003 L 445.67000000000036 102.19000000000003 L 446.17000000000036 102.88000000000002 L 444.74000000000035 104.58000000000003 L 445.41000000000037 105.28000000000003 L 445.43000000000035 105.83000000000003 L 446.6400000000003 103.79000000000002 L 447.13000000000034 102.25000000000001 L 447.5800000000003 102.25000000000001 L 447.9800000000003 103.27000000000001 L 447.9800000000003 103.85000000000001 L 447.1100000000003 104.77000000000001 L 446.8400000000003 105.76 L 446.9200000000003 108.47 L 447.1800000000003 108.8 L 447.6500000000003 108.92 L 448.2300000000003 108.78 L 449.1900000000003 107.85 L 448.72000000000025 106.85 L 448.86000000000024 106.25 L 450.18000000000023 104.82 L 451.23000000000025 104.57 L 453.36000000000024 105.16 L 454.86000000000024 104.05 L 454.91000000000025 104.97 L 454.55000000000024 105.17999999999999 L 453.42000000000024 106.71 L 454.0100000000002 107.28999999999999 L 454.11000000000024 106.91999999999999 L 455.36000000000024 106.32 L 455.9400000000002 107.11 L 455.80000000000024 108.32 L 457.43000000000023 110.07 L 458.29000000000025 109.63 L 459.87000000000023 110.3 L 460.6400000000002 112.7 L 460.5300000000002 113.65 L 458.3400000000002 116.38000000000001 L 457.9600000000002 117.27000000000001 L 458.06000000000023 117.93 L 458.66000000000025 116.9 L 460.41000000000025 115.22 L 461.24000000000024 115.19 L 462.11000000000024 116 L 462.6300000000002 117.89 L 462.36000000000024 119.12 L 461.3900000000002 119.31 L 460.36000000000024 120.22 L 459.2000000000002 121.71 L 459.2700000000002 122.47999999999999 L 458.1100000000002 124.82999999999998 L 457.4900000000002 128.35 L 457.70000000000016 128.69 L 458.57 128.92 z M 459.09 129.37 L 459.03 128.58 L 459.55999999999995 127.05000000000001 L 459.1499999999999 125.98000000000002 L 459.2799999999999 125.32000000000002 L 460.18999999999994 124.08000000000003 L 460.73999999999995 123.89000000000003 L 460.78999999999996 126.24000000000002 L 460.56999999999994 127.58000000000003 L 459.7699999999999 128.18000000000004 L 459.09 129.37 z M 452.79 103.61 L 452.35 103.15 L 452.27000000000004 102.55000000000001 L 453.07000000000005 101.43 L 453.91 101.4 L 454.59000000000003 101.82000000000001 L 454.69000000000005 102.16000000000001 L 454.50000000000006 102.52000000000001 L 452.79 103.61 z M 456.29 107.79 L 456 107.49000000000001 L 456.06 106.96000000000001 L 457.12 106.07000000000001 L 457.6 106.14 L 458.1 106.99 L 457.96000000000004 107.6 L 457.56000000000006 107.42999999999999 L 456.29 107.79 z M 442.13 102.98 L 441.92 102.93 L 442.87 99.35000000000001 L 443.17 99.44000000000001 L 443.2 99.67000000000002 L 442.78999999999996 102.73000000000002 L 442.13 102.98 z"},{code:"MG",name:"Minas Gerais",gTransform:"matrix(1 0 0 1 139.79 56.66)",pathTransform:"translate(-445.79, -375.93)",d:"M 527.5 365.33 L 526.59 364.78 L 524.05 363.97 L 522.47 364.05 L 521.39 364.37 L 520.55 364.98 L 518.37 365.27 L 517.03 365.14 L 518.7 367.41 L 518.68 368.22 L 517.55 368.11 L 516.5 367.37 L 516.19 367.39 L 514.02 368.7 L 512.85 370.63 L 513.15 371.33 L 514.48 372 L 515 372.66 L 514.97 374.58 L 514.67 376.12 L 514.88 376.53 L 516.19 376.88 L 516.36 378.6 L 516.04 379.02 L 515.09 379.26 L 514.12 379.23 L 513.32 378.88 L 511.84 378.97 L 511.41 379.52 L 511.9 380.23 L 512.66 380.51 L 513.11 380.22 L 513.63 380.31 L 514.73 381.58 L 516 384.39 L 516.29 386.82 L 515.75 389.79 L 514.04 391.88 L 512.8 392.74 L 512.54 393.18 L 512.3 394.9 L 511.42 397.19 L 510.31 398.46 L 509.34 401.7 L 508.79 402.02 L 503.64 401.99 L 501.92 404.05 L 501.76 404.47 L 502.35 407.59 L 501.78 408.89 L 501.34 411.23 L 501.63 411.37 L 501.63 411.37 L 499.1 413.72 L 497.86 413.99 L 497.3 414.49 L 498.04 415.19 L 495.68 421.24 L 493.78 424.95 L 493.69 425.7 L 495.13 425.83 L 495.42 426.44 L 495.21 426.96 L 492.68 427.94 L 483.17 432.47 L 481.8 432.67 L 481.82 432.21 L 481.33 432.04 L 478.8 431.77 L 478.23 431.83 L 476.61 432.77 L 475.36 432.93 L 472.16 433.01 L 471.8 432.69 L 471.29 432.77 L 467.19 434.55 L 466.14 435.32 L 464.43 436.09 L 463.93 435.81 L 461.34 435.98 L 458.43 437.32 L 456.01 438.06 L 455.33 438.55 L 455.33 438.55 L 454.08 439.28 L 451.88 439.5 L 449.95 440.52 L 448.72 441.76 L 446.93 442.43 L 444.55 442.68 L 442.21 442.6 L 442.2 442.11 L 442.55 441.62 L 442.46 441.27 L 441.27 441.6 L 441.09 443.9 L 441.33 444.13 L 441.28 444.97 L 440.53 445.95 L 439.23 446.27 L 438.66 445.84 L 435.05 446.84 L 434.86 446.31 L 432.85 446.55 L 431.73 446.3 L 429.7 442.99 L 430.92 442.28 L 430.4 440.57 L 428.6 439.74 L 426.81 438.51 L 426.1 436.9 L 426.63 435.34 L 426.82 431.89 L 426.56 428.95 L 428.42 426.23 L 429.12 424.05 L 429.17 422.78 L 428.94 422.41 L 425.24 421.09 L 424.24 421.14 L 423.96 421.5 L 423.18 421.81 L 421.57 421.86 L 421.6 421.01 L 420.77 419.02 L 419.47 417.23 L 419.1 415.02 L 418.79 414.4 L 418 413.66 L 418.19 411.72 L 419.71 409.69 L 419.77 409.13 L 419.37 407.58 L 417.49 406.37 L 416.91 405.76 L 417.2 403.39 L 417.77 402.38 L 417.57 401.34 L 414.3 397.99 L 413 398.28 L 412.15 398.92 L 410.5 398.14 L 408.12 398.25 L 407.81 398.86 L 408.01 399.32 L 407.57 400.31 L 404.79 400.99 L 403.68 400.56 L 402.17 399.11 L 401.16 400.36 L 392.98 401.04 L 392.52 401.52 L 392.04 402.71 L 392.31 405.25 L 391.9 405.69 L 390.71 405.17 L 390.7 402.39 L 390.45 401.43 L 390.09 401.04 L 389.53 400.99 L 389.27 401.18 L 388.86 402.31 L 388.19 403.25 L 387.65 403.57 L 387.03 403.55 L 385.82 401.45 L 385.49 400.03 L 385.63 399.12 L 383.95 398.33 L 381.77 396.91 L 379.78 397.5 L 378.16 397.28 L 376.49 397.63 L 372.2 396.67 L 369.65 396.59 L 367.92 395.04 L 367.17 394.9 L 365.67 395.51 L 364.24 397.2 L 362.32 397.57 L 360.17 398.68 L 358.95 399.81 L 358.95 399.81 L 359.26 397.19 L 358.67 393.98 L 359.66 389.8 L 360.24 389.55 L 360.24 389.55 L 361.1 390.01 L 361.46 389.78 L 361.47 389.44 L 360.91 388.83 L 361.48 386.93 L 363.12 384.83 L 364.06 384.09 L 364.51 383.95 L 365.35 384.11 L 366.17 383.83 L 367.01 382.53 L 366.95 381.53 L 368.16 379.07 L 369.57 376.97 L 371.8 376.43 L 374.28 375.47 L 377.99 376.09 L 381.18 374.45 L 382.7 374.75 L 384.01 376.17 L 384.34 376.17 L 387.25 373.25 L 391.38 370.61 L 393.39 371.5 L 397.25 371.34 L 398.73 371.62 L 400.48 371.61 L 401.06 371.52 L 401.61 371.04 L 405.96 372.9 L 406.66 373.67 L 411.55 370.93 L 412.03 369.81 L 412.89 368.91 L 414.05 368.71 L 417.14 366.65 L 415.95 363.19 L 416.46 361.3 L 417.19 360.4 L 417.36 359.69 L 417.18 358.69 L 416.71 358.08 L 415.13 357.51 L 414.23 357.98 L 413.14 356.87 L 413.57 354.73 L 416.81 351.72 L 419.13 349.01 L 419.13 348.41 L 417.48 343.85 L 416.06 342.82 L 415.21 342.48 L 414.36 341.27 L 414.77 339.8 L 415.81 338.55 L 416.49 336.96 L 416.18 335.39 L 416.71 333.87 L 417.98 333.75 L 420.27 332.24 L 423.63 331.34 L 424.16 330.81 L 423.47 326.55 L 422.94 326.36 L 422.52 325.75 L 422.48 323.85 L 423.21 323.15 L 423.78 322.21 L 423.29 321.05 L 422.57 320.95 L 423.29 317.77 L 423.66 317.49 L 424.83 317.26 L 427.61 318.4 L 428.01 318.27 L 428.58 317.73 L 428 313.96 L 429.17 312.47 L 431.59 313.95 L 432.49 315.71 L 435.72 316.05 L 436.72 315.04 L 436.72 315.04 L 437.23 317.45 L 435.8 320.89 L 436.2 321.12 L 437.54 320.21 L 438.24 319.21 L 438.96 319.08 L 441.09 319.46 L 442.13 318.69 L 443.98 316.12 L 444.97 316.27 L 446.4 315.74 L 448.21 314.19 L 449.16 313.02 L 451.18 312.61 L 454.55 310.75 L 455.19 309.64 L 459.46 306.61 L 463.28 305.03 L 465.08 305.12 L 466.28 305.62 L 468.46 305.65 L 470.74 306.18 L 471.59 306.64 L 470.3 309.38 L 470.15 310.27 L 470.41 311.76 L 471.02 312.26 L 476.35 313.72 L 476.99 313.55 L 477.8 312.43 L 479.68 311.54 L 481.45 311.28 L 484.18 312.03 L 485.28 312.57 L 489.63 316.21 L 490.61 316.03 L 492.78 317.65 L 495.31 318.87 L 496.24 319.09 L 496.75 318.88 L 498.28 320.12 L 502.67 318.89 L 503.05 319.07 L 509.57 325.27 L 510.01 329.23 L 510.58 329.02 L 513.19 329.47 L 514.66 328.97 L 515.98 327.98 L 517.97 328.13 L 520.7 328.69 L 522.96 329.77 L 525.15 330.38 L 527.27 330.35 L 530.1 332.82 L 530.83 333.2 L 531.72 333.27 L 532.5 334.29 L 532.92 335.46 L 531.45 338.54 L 526.49 342.76 L 526.34 345.41 L 526.9 346.43 L 526.9 346.85 L 525.88 347.56 L 523.4 347.32 L 522.58 348.2 L 521.76 351.5 L 521.23 355.9 L 521.45 356.15 L 521.8 355.96 L 522 355.51 L 522.64 355.27 L 523.22 356.5 L 523 358.01 L 523.15 358.52 L 527.29 361.58 L 527.82 362.62 L 527.83 363.15 L 527.15 364.5 z"},{code:"MS",name:"Mato Grosso do Sul",gTransform:"matrix(1 0 0 1 -2.22 90.13)",pathTransform:"translate(-303.77, -409.4)",d:"M 358.95 399.81 L 358.55 402.27 L 358.27 402.67 L 356.77 403.45 L 355.45 403.49 L 354.98 403.71 L 353.76 404.74 L 351.77 407.42 L 351.04 408.07 L 350.03 408.37 L 349.41 410.05 L 349.25 412.98 L 346.66 416.62 L 345.7 417.14 L 345.47 417.52 L 345.78 419.45 L 345.7 420.4 L 344.49 422.74 L 342.49 425 L 342.84 425.85 L 342.56 427.06 L 341.12 428.09 L 340.72 429.3 L 338.99 430.99 L 337.73 433.43 L 335.78 435.3 L 328.22 439.83 L 326.96 440.97 L 326.22 442.51 L 325.38 443.59 L 325.38 443.59 L 319.97 445.86 L 318.86 446.68 L 317.93 449.01 L 317.95 450.16 L 316.5 453.72 L 315.83 454.4 L 314.17 455.41 L 313.06 455.73 L 312.73 456.08 L 311.16 464 L 310.8 464.82 L 308.42 466.38 L 308.42 466.38 L 305.87 464.05 L 302.46 462.16 L 298.47 464.13 L 297.79 464.88 L 296.13 465.37 L 293.55 465.8 L 291.19 465.34 L 290.18 464.69 L 289.71 460.42 L 289.39 459.72 L 288.49 458.77 L 288.26 456.3 L 288.77 454.96 L 288.13 454.17 L 288.04 453.73 L 288.04 450.86 L 287.15 448.89 L 286.55 446.15 L 286.5 445.43 L 287.09 444.07 L 287.11 442.46 L 285.54 441.37 L 285.16 440.57 L 285 438.41 L 283.35 436.59 L 281.18 436.33 L 279.67 436.64 L 277.84 436.35 L 275.38 434.39 L 274.82 432.9 L 273.28 433.23 L 271.11 435.97 L 270.11 435.37 L 268.39 436.18 L 267.31 436.34 L 265.57 435.65 L 263.01 435.16 L 259.55 435.39 L 255.89 434.68 L 255.41 433.77 L 253.42 433.64 L 252.53 434.16 L 250.03 433.28 L 250.94 426.01 L 250.51 423.63 L 251.11 422.21 L 252.09 420.75 L 252.69 414.72 L 252.03 412.39 L 251.98 410.66 L 251.22 409.7 L 250.79 409.61 L 250.3 410.26 L 249.66 407 L 248.87 405.13 L 247.66 403.11 L 247.31 401.28 L 251.34 398.98 L 252.1 398.1 L 247.9 394.24 L 253.28 382.82 L 254.4 382.76 L 254.12 380.63 L 253.38 380.5 L 256.61 370.17 L 257.27 369.01 L 254.18 363.16 L 254.21 361.25 L 254.21 361.25 L 254.91 361.45 L 255.93 362.55 L 258.08 364.07 L 263.7 362.1 L 265.75 360.1 L 267.77 357.15 L 267.86 355.98 L 269.26 354.53 L 271.85 354.56 L 273.41 354.34 L 274.18 354.68 L 275.84 354.17 L 277.19 352.92 L 279.21 352.43 L 280.48 352.63 L 281.24 353.78 L 284.03 355.03 L 286.65 355.5 L 287.3 355.85 L 287.57 356.71 L 288.35 357.73 L 291.38 358.89 L 292.64 360 L 293.88 360.57 L 298.4 359.94 L 299.66 359.14 L 300.15 358.29 L 301.58 357.68 L 304.02 357.75 L 305.61 358.79 L 305.91 360.16 L 306.15 360.41 L 307.14 360.45 L 309.27 359.57 L 310.28 359.63 L 315.9 353.62 L 317.24 353.49 L 316.01 360.1 L 314.21 360.8 L 312.55 363.63 L 312.36 364.09 L 312.51 364.62 L 313.81 364.73 L 315.55 366 L 320.17 366.27 L 320.74 365.7 L 323.4 365.62 L 324.27 365.7 L 325.44 366.27 L 326.99 365.96 L 326.99 365.96 L 327.18 367.73 L 326.92 370.31 L 327.15 371.42 L 327.43 371.83 L 328.09 372.02 L 329.23 371.35 L 331.48 372.25 L 331.56 372.67 L 330.25 374.43 L 329.68 375.6 L 329.42 376.44 L 329.55 376.77 L 333.35 377.47 L 336.13 377.31 L 338.83 378.99 L 339.97 379.16 L 341.41 379.87 L 342.08 380.48 L 345.15 382.04 L 345.83 382.89 L 349.18 384.23 L 350.67 384.27 L 352.57 384.7 L 354.19 386.25 L 357.34 386.86 L 360 389.1 L 360.24 389.55 L 360.24 389.55 L 359.66 389.8 L 358.67 393.98 L 359.26 397.19 z"},{code:"MT",name:"Mato Grosso",gTransform:"matrix(1 0 0 1 -23.8 -38.15)",pathTransform:"translate(-282.2, -281.12)",d:"M 206.96 296.05 L 208.43 294.62 L 212.54 292.05 L 213.06 289.6 L 214.49 285.82 L 215.42 284.74 L 217.06 284.21 L 217.49 283.8 L 218.07 282.96 L 218.59 280.71 L 220.25 278.7 L 220.81 276.46 L 220.88 274.75 L 220.3 273.26 L 220.34 271.21 L 218.81 267.87 L 217.91 267.9 L 217.33 267.39 L 216.9 264.14 L 217.04 262.82 L 218.4 261.74 L 219.8 259.99 L 219.97 259.24 L 218.56 255.65 L 217.49 255.22 L 216.38 255.11 L 212.88 255.2 L 211.66 254.09 L 211.9 253.53 L 194.74 253.48 L 195.64 244.48 L 194.14 241.73 L 193.87 239.97 L 193.9 239.17 L 194.9 235.65 L 194.52 233.72 L 195.46 232.05 L 194.63 229.78 L 194.48 228.39 L 194.22 227.78 L 193.44 227.31 L 193.38 226.96 L 194.67 221.97 L 195.43 220.55 L 194.83 219.31 L 193.43 218.34 L 193.43 218.34 L 241.28 218.02 L 242.49 217.29 L 243.67 212.07 L 245.05 207.85 L 244.59 205.91 L 243.93 204.54 L 243.83 203.69 L 244.25 202.84 L 245.11 202.2 L 246.31 200.38 L 246.58 199.37 L 246.24 198.53 L 246.3 197.77 L 246.5 197.16 L 247.68 195.96 L 247.68 195.96 L 248.85 197.04 L 251.3 201.1 L 251.7 202.86 L 253.07 206.82 L 254.39 208.75 L 255.16 210.37 L 254.93 212.81 L 255.41 215.21 L 256.14 217.41 L 257.67 218.52 L 260.67 221.27 L 264.05 222.97 L 264.28 223.91 L 264.24 225.01 L 264.47 225.5 L 265.42 225.9 L 266.24 225.73 L 267.87 226.18 L 268.41 226.9 L 268.61 227.98 L 268.96 228.3 L 270.33 227.85 L 274.02 229.34 L 308.06 231.76 L 371.03 235.24 L 371.03 235.24 L 370.38 236.26 L 369.82 238.15 L 368.72 239.4 L 368.28 242.54 L 367.85 243.39 L 367.48 243.66 L 365.54 248.95 L 365 251.92 L 364.96 254.87 L 363.08 260.86 L 363.14 261.72 L 364.53 263.06 L 364.37 263.93 L 363.55 264.82 L 363.5 265.32 L 364.6 267.57 L 364.13 270.88 L 364.14 272.45 L 364.66 273.03 L 365.1 276.08 L 364.36 278.84 L 365.34 282.18 L 366.3 282.69 L 367.1 282.71 L 367.1 282.71 L 367.18 283.34 L 366.91 284.47 L 365.94 285.33 L 365.59 286.23 L 365.75 288.95 L 365.36 290.02 L 363.36 293.19 L 362.33 295.82 L 361.12 296.6 L 361.24 301.78 L 359.64 304.87 L 359.06 307.61 L 359.54 308.75 L 359.55 309.55 L 358.38 312.42 L 357.54 315.35 L 356.15 316.78 L 354.94 317.51 L 353.71 316.83 L 352.64 317.09 L 350.99 318.1 L 349.07 320.04 L 348.69 320.78 L 348.05 324.88 L 347.34 325.84 L 345.36 330.03 L 345.04 330.31 L 342.32 331.17 L 339.67 331.3 L 338.27 333.92 L 336.52 334.89 L 336.44 336.43 L 335.62 337.86 L 334.34 338.9 L 333.84 339.91 L 333.51 341.86 L 332.26 343.88 L 330.34 345.65 L 328.32 346.49 L 327.62 347.26 L 327.24 350.17 L 324.69 354.02 L 324.29 357.43 L 324.45 358.14 L 325.86 360.33 L 326.04 363.76 L 326.99 365.96 L 326.99 365.96 L 325.44 366.27 L 324.27 365.7 L 323.4 365.62 L 320.74 365.7 L 320.17 366.27 L 315.55 366 L 313.81 364.73 L 312.51 364.62 L 312.36 364.09 L 312.55 363.63 L 314.21 360.8 L 316.01 360.1 L 317.24 353.49 L 315.9 353.62 L 310.28 359.63 L 309.27 359.57 L 307.14 360.45 L 306.15 360.41 L 305.91 360.16 L 305.61 358.79 L 304.02 357.75 L 301.58 357.68 L 300.15 358.29 L 299.66 359.14 L 298.4 359.94 L 293.88 360.57 L 292.64 360 L 291.38 358.89 L 288.35 357.73 L 287.57 356.71 L 287.3 355.85 L 286.65 355.5 L 284.03 355.03 L 281.24 353.78 L 280.48 352.63 L 279.21 352.43 L 277.19 352.92 L 275.84 354.17 L 274.18 354.68 L 273.41 354.34 L 271.85 354.56 L 269.26 354.53 L 267.86 355.98 L 267.77 357.15 L 265.75 360.1 L 263.7 362.1 L 258.08 364.07 L 255.93 362.55 L 254.91 361.45 L 254.21 361.25 L 254.21 361.25 L 253.55 360.58 L 253.23 359.78 L 253.77 359.07 L 251.33 356.92 L 250.05 357.55 L 249.53 357.5 L 248.36 356.82 L 247.91 356.12 L 245.89 354.71 L 244 353.95 L 243.7 353.63 L 243.4 352.51 L 243.17 349.58 L 242.56 347.81 L 242.37 344.15 L 243.25 342.51 L 244.39 341.42 L 244.73 339.64 L 244.68 337.75 L 243.72 337.81 L 243.32 338.41 L 242.94 338.57 L 216.08 337.49 L 215.03 324.84 L 209.66 318.71 L 214.54 318.65 L 214.19 311.1 L 211.55 305.78 L 211.06 303.81 L 211.32 302.75 L 211.93 302.2 L 212.58 300.92 L 211.14 297.99 L 208.03 296.95 z"},{code:"PA",name:"Pará",gTransform:"matrix(1 0 0 1 29.16 -180.48)",pathTransform:"translate(-335.15, -138.78)",d:"M 371.03 235.24 L 308.05999999999995 231.76000000000002 L 274.0199999999999 229.34000000000003 L 270.3299999999999 227.85000000000002 L 268.9599999999999 228.3 L 268.6099999999999 227.99 L 268.4099999999999 226.9 L 267.8599999999999 226.18 L 266.2299999999999 225.73000000000002 L 265.4099999999999 225.9 L 264.4599999999999 225.51000000000002 L 264.2299999999999 225.01000000000002 L 264.2699999999999 223.91000000000003 L 264.0399999999999 222.97000000000003 L 260.6599999999999 221.27000000000004 L 257.6599999999999 218.51000000000005 L 256.1199999999999 217.40000000000003 L 255.3999999999999 215.20000000000005 L 254.9199999999999 212.81000000000006 L 255.1499999999999 210.37000000000006 L 254.37999999999988 208.74000000000007 L 253.04999999999987 206.81000000000006 L 251.67999999999986 202.86000000000007 L 251.28999999999988 201.10000000000008 L 248.8399999999999 197.04000000000008 L 247.65999999999988 195.96000000000006 L 247.65999999999988 195.96000000000006 L 247.0899999999999 195.40000000000006 L 246.93999999999988 193.44000000000005 L 246.2999999999999 192.18000000000006 L 244.7099999999999 190.62000000000006 L 243.6399999999999 190.04000000000005 L 243.2699999999999 189.47000000000006 L 242.43999999999988 187.13000000000005 L 242.46999999999989 186.00000000000006 L 243.0499999999999 185.03000000000006 L 244.4999999999999 183.90000000000006 L 245.2799999999999 182.59000000000006 L 275.1799999999999 118.35000000000007 L 273.3699999999999 116.68000000000006 L 273.4999999999999 115.90000000000006 L 273.3099999999999 115.42000000000006 L 271.9199999999999 115.77000000000005 L 271.0699999999999 116.38000000000005 L 269.1999999999999 115.60000000000005 L 268.09999999999985 113.43000000000005 L 265.40999999999985 111.98000000000005 L 264.1399999999999 110.64000000000004 L 264.0599999999999 110.04000000000005 L 262.7399999999999 109.22000000000006 L 261.3699999999999 109.07000000000005 L 259.1199999999999 108.42000000000004 L 256.7399999999999 107.11000000000004 L 254.8599999999999 106.44000000000004 L 253.5099999999999 105.35000000000004 L 252.8799999999999 104.45000000000003 L 248.2999999999999 101.91000000000003 L 243.6599999999999 98.14000000000003 L 243.3599999999999 97.70000000000003 L 243.3199999999999 96.77000000000002 L 242.7699999999999 94.94000000000003 L 240.9299999999999 93.71000000000002 L 240.2299999999999 93.90000000000002 L 239.8699999999999 93.70000000000002 L 238.03999999999988 91.72000000000001 L 238.0899999999999 89.61000000000001 L 238.43999999999988 88.92000000000002 L 238.25999999999988 88.51000000000002 L 236.56999999999988 87.66000000000003 L 236.32999999999987 86.98000000000002 L 236.14999999999986 84.71000000000002 L 236.57999999999987 83.26000000000002 L 236.17999999999986 78.40000000000002 L 236.17999999999986 78.40000000000002 L 234.58999999999986 61.43000000000002 L 234.58999999999986 61.43000000000002 L 235.33999999999986 61.75000000000002 L 235.76999999999987 62.33000000000002 L 235.74999999999986 62.81000000000002 L 236.19999999999985 63.210000000000015 L 237.11999999999983 63.490000000000016 L 238.48999999999984 62.780000000000015 L 238.95999999999984 61.97000000000001 L 241.66999999999985 62.20000000000001 L 242.47999999999985 61.15000000000001 L 241.93999999999986 59.34000000000001 L 243.72999999999985 58.98000000000001 L 245.13999999999984 57.35000000000001 L 247.77999999999983 58.36000000000001 L 249.65999999999983 58.39000000000001 L 250.19999999999982 56.870000000000005 L 253.52999999999983 55.25000000000001 L 255.49999999999983 55.64000000000001 L 256.65999999999985 55.53000000000001 L 257.14999999999986 55.28000000000001 L 258.34999999999985 53.80000000000001 L 258.74999999999983 52.40000000000001 L 260.2099999999998 51.30000000000001 L 261.0699999999998 51.19000000000001 L 261.7199999999998 51.65000000000001 L 263.8299999999998 50.52000000000001 L 264.23999999999984 50.63000000000001 L 264.60999999999984 51.62000000000001 L 265.33999999999986 52.070000000000014 L 267.36999999999983 52.55000000000001 L 268.97999999999985 52.80000000000001 L 269.53999999999985 52.20000000000001 L 271.20999999999987 51.81000000000001 L 271.98999999999984 52.09000000000001 L 272.80999999999983 52.08000000000001 L 273.66999999999985 51.74000000000001 L 275.90999999999985 52.040000000000006 L 280.57999999999987 53.42000000000001 L 281.53999999999985 53.28000000000001 L 282.53999999999985 52.41000000000001 L 282.5099999999999 50.13000000000001 L 280.4399999999999 47.63000000000001 L 279.1999999999999 47.00000000000001 L 279.6899999999999 45.32000000000001 L 280.9999999999999 43.870000000000005 L 281.27999999999986 42.760000000000005 L 281.58999999999986 42.59 L 282.29999999999984 42.78 L 283.1299999999998 43.54 L 285.47999999999985 44.65 L 297.09999999999985 42.32 L 298.66999999999985 44.01 L 299.6899999999998 44.07 L 300.1299999999998 43.78 L 300.1299999999998 43.78 L 300.74999999999983 44.35 L 301.11999999999983 46.65 L 300.49999999999983 47.949999999999996 L 300.24999999999983 52.489999999999995 L 300.48999999999984 53.92999999999999 L 300.79999999999984 54.46999999999999 L 301.96999999999986 54.489999999999995 L 303.04999999999984 54.199999999999996 L 306.4399999999998 54.56999999999999 L 307.72999999999985 55.059999999999995 L 309.65999999999985 56.10999999999999 L 310.32999999999987 56.90999999999999 L 310.8199999999999 58.18999999999999 L 312.0099999999999 58.30999999999999 L 313.14999999999986 59.14999999999999 L 313.9499999999999 60.12999999999999 L 314.78999999999985 60.39999999999999 L 316.11999999999983 60.25999999999999 L 316.49999999999983 59.83999999999999 L 317.4399999999998 59.69999999999999 L 320.2799999999998 62.359999999999985 L 320.9599999999998 62.329999999999984 L 321.4499999999998 63.509999999999984 L 320.7699999999998 63.73999999999998 L 320.5799999999998 64.45999999999998 L 321.3399999999998 67.28999999999998 L 323.3599999999998 69.54999999999998 L 325.9299999999998 70.27999999999999 L 326.0999999999998 70.60999999999999 L 325.6699999999998 73.74999999999999 L 325.8599999999998 75.85999999999999 L 326.5299999999998 77.36999999999999 L 327.1499999999998 77.92999999999999 L 327.7399999999998 79.74 L 327.6099999999998 81.32 L 329.1099999999998 84.8 L 329.9299999999998 84.99 L 330.70999999999975 84.63 L 333.63999999999976 87.91 L 333.5599999999998 90.34 L 333.9699999999998 91.28 L 334.9199999999998 91.47 L 335.2499999999998 91.94 L 335.5599999999998 93.52 L 335.3499999999998 94.21 L 335.4599999999998 95.50999999999999 L 337.3299999999998 96.89999999999999 L 337.7599999999998 98.39999999999999 L 339.2099999999998 99.42999999999999 L 341.99999999999983 100.11 L 343.29999999999984 99.99 L 344.0699999999998 99.64999999999999 L 345.0099999999998 99.71 L 345.0099999999998 99.71 L 344.47999999999985 100.44999999999999 L 344.76999999999987 102.03999999999999 L 344.59999999999985 102.57 L 343.30999999999983 103.67999999999999 L 341.91999999999985 103.85 L 341.41999999999985 103.66999999999999 L 340.57999999999987 102.87999999999998 L 339.91999999999985 102.72999999999998 L 336.53999999999985 104.30999999999997 L 336.16999999999985 104.84999999999998 L 334.5699999999998 105.56999999999998 L 333.9399999999998 105.54999999999998 L 332.3899999999998 106.13999999999999 L 332.42999999999984 106.71999999999998 L 338.8899999999998 105.65999999999998 L 339.7699999999998 106.31999999999998 L 339.8999999999998 106.77999999999997 L 339.8999999999998 107.43999999999997 L 339.2799999999998 107.93999999999997 L 339.5799999999998 108.29999999999997 L 340.2099999999998 108.09999999999997 L 341.0699999999998 107.09999999999997 L 342.0899999999998 107.08999999999996 L 342.6199999999998 106.81999999999996 L 343.2199999999998 106.93999999999997 L 344.2899999999998 106.51999999999997 L 345.4299999999998 105.94999999999997 L 348.70999999999975 103.60999999999997 L 350.20999999999975 103.25999999999998 L 352.0499999999997 102.44999999999997 L 355.20999999999975 100.60999999999997 L 355.7499999999998 99.60999999999997 L 356.4199999999998 99.08999999999997 L 358.50999999999976 98.07999999999997 L 359.1699999999998 97.35999999999997 L 358.9199999999998 96.68999999999997 L 359.12999999999977 96.27999999999997 L 360.25999999999976 95.99999999999997 L 361.34999999999974 96.05999999999997 L 361.75999999999976 96.26999999999997 L 362.13999999999976 100.06999999999996 L 361.6199999999998 102.64999999999996 L 361.94999999999976 104.26999999999997 L 362.75999999999976 105.86999999999996 L 364.06999999999977 107.21999999999996 L 364.3699999999998 108.85999999999996 L 364.2499999999998 109.32999999999996 L 362.4099999999998 111.16999999999996 L 361.93999999999977 111.29999999999995 L 361.06999999999977 110.77999999999996 L 359.2499999999998 110.25999999999996 L 357.9899999999998 109.94999999999996 L 357.0599999999998 110.08999999999996 L 354.9299999999998 109.04999999999995 L 354.6699999999998 107.92999999999995 L 353.7899999999998 107.39999999999995 L 351.5099999999998 111.21999999999994 L 350.8999999999998 113.58999999999995 L 351.5799999999998 116.55999999999995 L 352.05999999999983 117.19999999999995 L 352.97999999999985 117.81999999999995 L 351.96999999999986 116.67999999999995 L 351.53999999999985 113.98999999999995 L 351.65999999999985 113.46999999999996 L 354.22999999999985 109.24999999999996 L 356.53999999999985 110.42999999999996 L 356.64999999999986 110.87999999999997 L 359.17999999999984 113.32999999999997 L 358.92999999999984 115.34999999999997 L 358.1899999999998 115.89999999999996 L 358.5899999999998 118.22999999999996 L 359.1099999999998 119.35999999999996 L 360.2299999999998 120.10999999999996 L 360.9699999999998 120.25999999999996 L 361.4899999999998 120.74999999999996 L 361.1499999999998 120.10999999999996 L 360.3799999999998 119.86999999999996 L 359.17999999999984 118.82999999999996 L 358.9599999999998 118.14999999999995 L 359.2999999999998 113.94999999999995 L 360.1199999999998 112.75999999999995 L 361.5499999999998 113.48999999999995 L 362.37999999999977 114.68999999999996 L 362.2899999999998 115.47999999999996 L 363.4899999999998 116.33999999999996 L 363.7399999999998 116.04999999999995 L 362.7399999999998 114.78999999999995 L 361.81999999999977 112.68999999999996 L 361.81999999999977 112.24999999999996 L 364.07999999999976 109.92999999999996 L 365.69999999999976 110.01999999999997 L 367.62999999999977 110.65999999999997 L 367.96999999999974 111.21999999999997 L 367.35999999999973 111.80999999999997 L 367.6799999999997 112.08999999999997 L 368.15999999999974 112.11999999999998 L 369.1899999999997 111.94999999999997 L 370.5199999999997 111.04999999999997 L 374.6099999999997 110.08999999999997 L 375.37999999999965 110.28999999999998 L 377.11999999999966 111.34999999999998 L 380.2899999999997 110.92999999999998 L 381.3599999999997 110.51999999999998 L 382.37999999999965 109.50999999999998 L 383.3599999999997 108.91999999999997 L 385.0999999999997 108.40999999999997 L 385.86999999999966 108.47999999999996 L 385.92999999999967 109.22999999999996 L 383.88999999999965 113.24999999999996 L 383.64999999999964 114.74999999999996 L 383.18999999999966 115.81999999999995 L 382.3599999999997 116.84999999999995 L 382.3499999999997 117.72999999999995 L 382.92999999999967 119.14999999999995 L 382.6099999999997 121.61999999999995 L 383.48999999999967 120.42999999999995 L 383.49999999999966 119.02999999999994 L 385.0399999999997 116.02999999999994 L 386.1699999999997 112.83999999999995 L 387.2899999999997 111.27999999999994 L 387.55999999999966 111.00999999999995 L 388.31999999999965 110.95999999999995 L 388.89999999999964 110.60999999999996 L 390.71999999999963 110.37999999999995 L 391.5999999999996 109.02999999999996 L 393.1099999999996 107.33999999999996 L 394.46999999999963 105.07999999999996 L 394.9899999999996 104.61999999999996 L 395.77999999999963 105.10999999999996 L 396.39999999999964 104.64999999999996 L 398.01999999999964 106.98999999999997 L 399.20999999999964 107.57999999999997 L 399.1599999999996 106.83999999999997 L 398.8099999999996 106.08999999999997 L 399.4299999999996 105.07999999999997 L 402.9399999999996 104.56999999999996 L 401.9099999999996 104.24999999999997 L 398.39999999999964 104.70999999999997 L 398.08999999999963 104.49999999999997 L 398.37999999999965 102.06999999999996 L 398.88999999999965 101.77999999999996 L 399.55999999999966 102.15999999999995 L 400.57999999999964 102.26999999999995 L 401.64999999999964 99.16999999999996 L 400.96999999999963 97.77999999999996 L 400.9999999999996 97.09999999999995 L 402.1699999999996 95.28999999999995 L 405.0099999999996 92.80999999999995 L 405.3699999999996 92.72999999999995 L 406.4799999999996 93.86999999999995 L 409.4099999999996 91.77999999999994 L 409.8699999999996 91.70999999999995 L 410.2699999999996 92.15999999999995 L 410.3699999999996 92.72999999999995 L 410.0499999999996 93.39999999999995 L 411.1199999999996 93.23999999999995 L 411.9299999999996 92.65999999999995 L 412.2899999999996 91.87999999999995 L 412.9199999999996 91.68999999999996 L 413.1999999999996 91.83999999999996 L 413.9399999999996 93.22999999999996 L 415.2699999999996 94.42999999999996 L 415.4699999999996 93.86999999999996 L 415.35999999999956 93.48999999999997 L 414.4 93 L 414.26 92.71 L 414.13 91.50999999999999 L 414.3 91.08999999999999 L 414.74 90.89999999999999 L 417.02 91.16 L 418.2 91.81 L 418.82 92.83 L 420.45 93.53999999999999 L 422.09999999999997 92.75999999999999 L 422.62999999999994 94.89999999999999 L 422.12999999999994 95.21 L 422.09999999999997 95.8 L 423.02 95.28 L 424.18 92.93 L 424.56 93.16000000000001 L 424.33 94.49000000000001 L 424.74 94.93 L 427.25 94.67 L 427.7 95.32000000000001 L 428.15999999999997 97.00000000000001 L 427.55999999999995 97.95000000000002 L 428.40999999999997 97.45000000000002 L 428.66999999999996 97.82000000000002 L 430.55999999999995 97.96000000000002 L 434.0899999999999 96.72000000000003 L 433.7799999999999 98.30000000000003 L 433.0299999999999 100.13000000000002 L 434.49999999999994 99.64000000000003 L 435.0899999999999 99.02000000000002 L 435.7199999999999 100.64000000000003 L 435.7199999999999 100.64000000000003 L 434.94999999999993 101.09000000000003 L 434.4799999999999 102.12000000000003 L 434.63999999999993 103.50000000000003 L 433.92999999999995 107.89000000000003 L 433.35999999999996 108.63000000000002 L 432.21999999999997 108.78000000000003 L 432.16999999999996 109.40000000000003 L 432.43999999999994 109.89000000000003 L 433.42999999999995 109.73000000000003 L 433.85999999999996 110.26000000000003 L 433.78 111.87000000000003 L 432.88 114.89000000000003 L 432.52 115.60000000000002 L 430.78 117.17000000000002 L 430.28 119.55000000000001 L 430.40999999999997 121.19000000000001 L 426.72999999999996 124.28000000000002 L 427.77 125.86000000000001 L 426.97999999999996 126.67000000000002 L 427.15999999999997 128.49 L 426.7 129.77 L 425.87 131.22 L 424.39 132.98 L 422.43 134.51999999999998 L 420.83 139.20999999999998 L 420.53999999999996 141.10999999999999 L 420.06999999999994 142.32 L 417.62999999999994 144.64 L 416.50999999999993 145.1 L 415.88999999999993 147.98 L 414.3399999999999 149.14999999999998 L 413.9099999999999 150.29999999999998 L 412.3599999999999 152.46999999999997 L 411.1899999999999 153.38999999999996 L 408.83999999999986 153.15999999999997 L 394.1299999999999 164.98999999999998 L 394.6199999999999 165.07 L 394.6199999999999 165.07 L 396.9099999999999 165.88 L 398.7799999999999 165.64 L 400.06999999999994 165.76 L 401.0899999999999 167.42 L 401.4799999999999 167.73 L 402.3499999999999 167.86999999999998 L 403.6099999999999 169.03999999999996 L 403.5699999999999 169.66999999999996 L 403.1999999999999 170.33999999999995 L 402.47999999999985 170.70999999999995 L 401.5099999999998 170.77999999999994 L 401.2199999999998 171.05999999999995 L 401.3099999999998 172.46999999999994 L 402.31999999999977 173.80999999999995 L 401.39999999999975 176.55999999999995 L 400.75999999999976 177.03999999999994 L 399.2999999999998 177.49999999999994 L 399.0499999999998 177.95999999999995 L 399.3399999999998 179.15999999999994 L 399.1499999999998 180.49999999999994 L 397.8499999999998 180.64999999999995 L 396.3399999999998 181.98999999999995 L 395.4899999999998 183.25999999999996 L 395.63999999999976 184.76999999999995 L 395.39999999999975 185.26999999999995 L 392.89999999999975 186.46999999999994 L 389.4899999999997 187.60999999999993 L 387.0199999999997 189.38999999999993 L 386.8299999999997 189.73999999999992 L 387.2599999999997 191.92999999999992 L 387.3199999999997 194.5999999999999 L 386.03999999999974 196.6999999999999 L 384.6299999999997 198.3799999999999 L 384.47999999999973 198.9499999999999 L 384.64999999999975 199.8299999999999 L 385.2399999999997 200.7899999999999 L 386.90999999999974 202.52999999999992 L 387.65999999999974 202.8499999999999 L 387.8099999999997 203.14999999999992 L 387.1499999999997 207.1899999999999 L 385.3899999999997 212.33999999999992 L 384.3099999999997 213.14999999999992 L 382.60999999999973 216.38999999999993 L 382.4299999999997 217.37999999999994 L 381.4899999999997 218.91999999999993 L 380.7499999999997 219.76999999999992 L 379.6999999999997 219.92999999999992 L 378.3299999999997 220.8499999999999 L 377.2999999999997 222.7699999999999 L 376.08999999999975 224.4499999999999 L 374.90999999999974 225.5399999999999 L 373.75999999999976 227.11999999999992 L 372.62999999999977 231.57999999999993 L 371.03 235.24 z M 392.19 104.93 L 387.67 106.89 L 384.28000000000003 107.41 L 382.26000000000005 107.1 L 381.61000000000007 108.22999999999999 L 379.7700000000001 109.41999999999999 L 379.05000000000007 108.80999999999999 L 378.44000000000005 107.27999999999999 L 378.21000000000004 107.55999999999999 L 378.63000000000005 108.78999999999999 L 378.2900000000001 109.6 L 377.5800000000001 110.00999999999999 L 373.8100000000001 108.36999999999999 L 373.0100000000001 109.08999999999999 L 368.8200000000001 110.35 L 365.6200000000001 109.78 L 364.8100000000001 109.17 L 364.5700000000001 107.32000000000001 L 364.3400000000001 106.91000000000001 L 363.2300000000001 105.89000000000001 L 362.1700000000001 104.29000000000002 L 361.9600000000001 102.51000000000002 L 362.4800000000001 99.76000000000002 L 363.1000000000001 99.38000000000002 L 364.86000000000007 99.74000000000002 L 365.7900000000001 98.99000000000002 L 365.87000000000006 98.43000000000002 L 364.57000000000005 98.86000000000003 L 363.35 98.73000000000003 L 362.41 98.02000000000004 L 362.23 96.97000000000004 L 362.57 91.89000000000004 L 363.3 91.13000000000004 L 363.65000000000003 91.88000000000004 L 365.41 92.48000000000003 L 365.96000000000004 92.42000000000003 L 365.50000000000006 92.00000000000003 L 364.2300000000001 91.78000000000003 L 363.3300000000001 89.62000000000003 L 363.6900000000001 87.94000000000003 L 364.5800000000001 85.97000000000003 L 365.9100000000001 84.64000000000003 L 366.87000000000006 84.07000000000004 L 368.21000000000004 83.58000000000004 L 369.53000000000003 83.45000000000005 L 372.99 83.97000000000004 L 380.2 85.74000000000004 L 383.9 85.28000000000004 L 384.01 84.98000000000005 L 385.15 84.36000000000004 L 387.31 83.99000000000004 L 390.2 84.28000000000004 L 393 85.10000000000004 L 399.48 85.95000000000003 L 400.11 86.42000000000003 L 400.06 87.65000000000003 L 399.36 88.39000000000003 L 398.68 89.89000000000003 L 398.32 92.54000000000003 L 397.46 95.84000000000003 L 396.16999999999996 96.52000000000004 L 395.81999999999994 97.21000000000004 L 396.04999999999995 98.40000000000003 L 394.06999999999994 100.98000000000003 L 392.67999999999995 104.48000000000003 L 392.19 104.93 z M 344.98 104.76 L 344.23 104.25 L 345.33000000000004 102 L 345.24000000000007 100.21 L 345.49000000000007 100 L 347.82000000000005 99.52 L 348.72 98.66 L 348.87 98.16 L 348.67 95.82 L 349.53000000000003 93.24 L 350.79 91.75 L 353.08000000000004 90.28 L 355.95000000000005 90.08 L 356.6700000000001 92.44 L 355.57000000000005 94.63 L 354.72 97.67 L 353.62 98.34 L 352.28000000000003 100.37 L 351.50000000000006 101.09 L 346.56000000000006 104.4 L 344.98 104.76 z M 373.46 81.86 L 372.43 81.61 L 369.98 81.69 L 369.19 81.53 L 368.9 81.27 L 368.52 80.17999999999999 L 368.53 78.94 L 370.03999999999996 78.52 L 371.92999999999995 78.56 L 374.11999999999995 77.27 L 378.92999999999995 76.67 L 379.69999999999993 76.93 L 380.37999999999994 77.61000000000001 L 380.19999999999993 78.63000000000001 L 377.63999999999993 80.02000000000001 L 375.85999999999996 82.50000000000001 L 374.76 83 L 373.46 81.86 z M 378.25 81.86 L 380.11 80.66 L 382.09000000000003 80.69 L 383.74 81.31 L 384.27 82.3 L 384.32 82.92 L 383.44 83.69 L 380.59 83.97 L 379.41999999999996 84.28999999999999 L 377.15999999999997 83.39999999999999 L 376.96 82.86999999999999 L 378.25 81.86 z M 361.27 86.25 L 360.77 85.99 L 360.15999999999997 86.03 L 358.61999999999995 85.34 L 358.8299999999999 84.18 L 359.4699999999999 83.26 L 361.38999999999993 82.86 L 363.74999999999994 81.96 L 365.06999999999994 82.03999999999999 L 365.86999999999995 82.72 L 365.9599999999999 82.85 L 364.0299999999999 84.46 L 362.9599999999999 84.8 L 361.27 86.25 z M 370.69 76.56 L 369.87 76.26 L 369.7 74.60000000000001 L 369.84999999999997 74.00000000000001 L 371.02 72.69000000000001 L 373.46999999999997 71.77000000000001 L 373.71999999999997 71.89000000000001 L 374.24999999999994 72.57000000000002 L 374.28999999999996 73.46000000000002 L 372.34 75.45000000000002 L 370.69 76.56 z M 356.86 96.78 L 356.72 96.37 L 356.91 95.44 L 357.95000000000005 92.63 L 360.54 90.94 L 361.26000000000005 90.66 L 361.95000000000005 90.8 L 361.79 92.59 L 360.23 93.03 L 358.61 95.22 L 356.86 96.78 z M 367.77 79.21 L 366.58 78.89999999999999 L 366.28 78.41999999999999 L 367.15999999999997 77.46 L 367.86999999999995 73.50999999999999 L 368.75999999999993 72.27999999999999 L 369.04999999999995 72.40999999999998 L 369.11999999999995 72.72999999999998 L 369.09999999999997 75.20999999999998 L 369.7 77.07999999999998 L 369.38 77.95999999999998 L 368.35 78.35999999999999 L 367.77 79.21 z M 352.96 89.4 L 352.69 89.21000000000001 L 352.81 88.60000000000001 L 353.36 88.24000000000001 L 354.55 86.53000000000002 L 355.31 84.99000000000001 L 356.04 84.33000000000001 L 357.49 83.79 L 357.29 85.28 L 356.89000000000004 86.28 L 355.17 87.94 L 352.96 89.4 z M 366.83 82.37 L 366.22999999999996 82.22 L 365.39 81.51 L 364.43 79.87 L 364.38 79.49000000000001 L 364.61 79.2 L 365.42 78.62 L 367.27000000000004 79.46000000000001 L 367.56000000000006 79.89000000000001 L 367.80000000000007 81.98000000000002 L 366.83 82.37 z M 361.45 112.93 L 360.8 112.82000000000001 L 359.92 112.30000000000001 L 359.23 112.76 L 358.48 112.48 L 356.8 110.74000000000001 L 356.8 110.13000000000001 L 358.08 110.12 L 361.14 111.44 L 361.45 112.93 z M 340.3 107.39 L 340.34000000000003 106.36 L 340.14000000000004 106.06 L 340.74000000000007 105.07000000000001 L 343.1000000000001 104.19000000000001 L 343.88000000000005 104.57000000000001 L 344.75000000000006 105.43 L 344.46000000000004 105.78 L 343.43000000000006 106.25 L 340.89000000000004 106.66 L 340.3 107.39 z M 353 100.7 L 352.82 100.67 L 352.83 100.32000000000001 L 353.37 99.38000000000001 L 355.16 97.76 L 355.58000000000004 96.52000000000001 L 355.63000000000005 95.22000000000001 L 355.87000000000006 94.92000000000002 L 356.19000000000005 95.36000000000001 L 356.19000000000005 96.87000000000002 L 355.30000000000007 99.60000000000002 L 354.68000000000006 100.25000000000003 L 353 100.7 z M 359.3 90.8 L 360.95 87.84 L 361.83 87.63000000000001 L 362.53999999999996 87.82000000000001 L 362.80999999999995 88.69000000000001 L 362.22999999999996 89.4 L 359.3 90.8 z M 390.72 109.77 L 389.88000000000005 109.42 L 389.5400000000001 108.36 L 390.5800000000001 106.64 L 391.6500000000001 106.31 L 391.8400000000001 106.41 L 391.8200000000001 107.14999999999999 L 391.0800000000001 109.38999999999999 L 390.72 109.77 z M 357.24 90.3 L 356.7 90.1 L 357.02 88.05999999999999 L 358.34999999999997 86.24999999999999 L 358.58 86.28999999999999 L 359.87 87.16999999999999 L 359.86 87.41999999999999 L 358.31 88.05999999999999 L 357.24 90.3 z M 359.47 95.33 L 360.19000000000005 95.36 L 359.7900000000001 95.81 L 358.8500000000001 96.12 L 358.74000000000007 97.24000000000001 L 357.95000000000005 97.95 L 356.26000000000005 98.79 L 356.1 98.61 L 356.37 97.78 L 356.84000000000003 97.15 L 358.57000000000005 95.48 L 359.47 95.33 z M 336.91 105.54 L 336.36 105.35000000000001 L 336.29 105.00000000000001 L 336.72 104.60000000000001 L 340.28000000000003 103.00000000000001 L 340.82000000000005 103.70000000000002 L 340.81000000000006 103.90000000000002 L 339.4100000000001 104.63000000000002 L 336.91 105.54 z M 400.44 100.76 L 399.41 100.57000000000001 L 398.59000000000003 99.78 L 399.46000000000004 98.53 L 400.8 98.52 L 400.99 99.71 L 400.89 100.3 L 400.44 100.76 z M 363.19 81.86 L 360.83 82.56 L 360.24 82.57000000000001 L 360.06 82.36000000000001 L 361.09 81.32000000000001 L 362.13 80.81 L 363.17 80.98 L 363.61 81.32000000000001 L 363.76 81.55000000000001 L 363.61 81.76 L 363.19 81.86 z M 357.92 90.45 L 357.84000000000003 89.69 L 358.09000000000003 89.19 L 360.57000000000005 87.73 L 359.6700000000001 89.73 L 358.86000000000007 90.36 L 357.92 90.45 z M 360.06 94.98 L 359.61 94.86 L 359.54 94.63 L 360.32 93.13 L 361.51 93.14999999999999 L 361.39 94.49999999999999 L 360.06 94.98 z M 388.1 110.81 L 387.82000000000005 110.58 L 388.72 108.98 L 389.40000000000003 108.58 L 389.63000000000005 109.33 L 390.14000000000004 109.7 L 389.88000000000005 110.22 L 389.45000000000005 110.56 L 388.82000000000005 110.38 L 388.1 110.81 z M 361.44 87.49 L 360.55 87.42 L 360.57 87.23 L 362.93 85.39 L 362.97 86.35 L 362.74 86.97999999999999 L 362.49 87.32 L 361.44 87.49 z M 428.9 97.71 L 428.52 97.17999999999999 L 428.71 96.41999999999999 L 429.72999999999996 95.50999999999999 L 429.97999999999996 95.66 L 430.21 97.41 L 428.9 97.71 z"},{code:"PB",name:"Paraíba",gTransform:"matrix(1 0 0 1 275.13 -126.21)",pathTransform:"translate(-581.13, -193.05)",d:"M 610.43 199.15 L 607.93 197.09 L 607.11 196.83 L 604.46 196.62 L 602.15 197.69 L 600.67 198.97 L 600.22 200.77 L 598.32 201.8 L 596.31 202.25 L 595.17 202.23 L 595.17 202.83 L 594.37 203.36 L 592.19 203.65 L 588.31 203.39 L 586.7 204.27 L 586.15 204.91 L 584.33 205.01 L 583.44 205.7 L 582.9 206.46 L 583.29 207.19 L 583.3 207.73 L 582.9 208.21 L 581.12 209.74 L 579.78 209.9 L 578.13 210.74 L 576.53 209.95 L 575.58 209.01 L 575.23 206.77 L 575.47 206.28 L 575.29 205.98 L 574.15 205.66 L 573.71 205.95 L 572.2 206.2 L 572.24 205.75 L 574.77 203.11 L 574.94 202.68 L 574.22 200.81 L 574.18 200.34 L 574.55 199.56 L 577.55 198.49 L 577.66 198.19 L 577.16 196.8 L 573.66 194.88 L 572.18 195.29 L 569.96 196.55 L 569.03 198.06 L 567.55 198.93 L 566.5 199.24 L 563.8 201.12 L 562.28 202.76 L 560.65 202.99 L 558.02 203.96 L 557.25 203.63 L 557.3 202.95 L 556.67 201.71 L 556.29 201.63 L 555.36 202.36 L 553.85 202.68 L 552.86 202.35 L 551.46 200.44 L 551.06 200.35 L 551.06 200.35 L 550.89 200.1 L 552.08 198.98 L 553.69 195.49 L 553.35 194.3 L 552.66 194.22 L 551.42 193.33 L 551.44 191.67 L 551.09 190.95 L 550.51 190.66 L 550.27 190.25 L 550.39 189.32 L 550.56 188.94 L 551.65 188.31 L 552.31 187 L 551.79 185.69 L 552.82 182.69 L 553.66 181.54 L 553.74 181 L 553.74 181 L 554.31 180.54 L 556.24 182.18 L 557.14 182.6 L 560.02 183.21 L 561.18 182.08 L 564.41 180.42 L 565.23 179.71 L 565.33 178.67 L 565.74 177.72 L 568.92 176.51 L 570.35 176.39 L 573.61 175.35 L 574.25 175.43 L 574.78 175.87 L 574.79 177.06 L 571.8 180.27 L 571.36 181.23 L 570.98 182.97 L 570.57 183.35 L 569.72 183.6 L 569.51 183.91 L 569.43 185.63 L 572.96 186.15 L 573.28 186.38 L 573.59 187.76 L 573.88 187.99 L 577.03 186.73 L 578.8 186.65 L 580.75 186.95 L 581.64 188.12 L 581.12 189.66 L 581.95 190.4 L 584.3 189.47 L 584.8 188.73 L 585.35 187.52 L 584.88 186.58 L 584.72 185.16 L 585.2 184.57 L 586.21 184.89 L 585.68 183.36 L 584.96 182.58 L 585.27 181.1 L 587.09 179.75 L 588.47 179.7 L 588.89 180.09 L 588.79 181.09 L 589.41 181.58 L 592.83 181.98 L 593.36 182.33 L 599.19 181.94 L 601.36 182.24 L 603.82 183.34 L 604.86 182.94 L 608.36 183.15 L 609.29 182.91 L 609.29 182.91 L 609.38 185.31 L 610.83 189.7 L 610.89 190.34 L 610.71 191.28 L 610.34 191.73 L 610.31 192.61 L 610.89 191.87 L 611.4 190.37 L 611.41 192.35 L 612 193.36 L 611.73 198.54 L 611.37 199.14 z"},{code:"PE",name:"Pernambuco",gTransform:"matrix(1 0 0 1 254.6 -106.99)",pathTransform:"translate(-560.6, -212.26)",d:"M 558.28 227.19 L 557.06 224.15 L 557.05 223.21 L 554.94 222.35 L 554.44 221.98 L 553.99 221.15 L 554.6 220.26 L 554.58 219.64 L 554.13 219.32 L 553.13 219.33 L 552.7 219.77 L 552.41 221.51 L 551.98 221.66 L 551.59 221.4 L 551.05 219.75 L 549.47 218.6 L 546.48 218.2 L 544.12 217.43 L 542.77 216.62 L 541.94 215.18 L 540.45 214.62 L 539.86 214.73 L 537.33 216.19 L 535.68 216.63 L 534.91 218.68 L 532.68 219.13 L 532.39 219.38 L 532.64 220.74 L 532.47 221.33 L 531.37 222.57 L 528.98 223.6 L 528.34 223.54 L 527.57 223.01 L 526.81 223.18 L 526.31 224.05 L 525.54 227.62 L 522.67 228.5 L 521.85 229.42 L 520.89 229.65 L 519.05 229.03 L 519.97 227.35 L 519.71 225.35 L 517.5 224.44 L 516.78 222.5 L 516.84 219.77 L 516.4 219.26 L 513.59 217.88 L 511.39 217.59 L 510.23 217.85 L 509.33 217.45 L 509.33 217.45 L 511.95 216.18 L 513.92 214.47 L 514.46 213.6 L 516.75 212.27 L 517.72 211.99 L 521.61 208.12 L 522.35 206.36 L 522.41 204.09 L 522.12 203.55 L 520.5 201.97 L 520.57 199.78 L 519.97 198.65 L 519.91 197.7 L 520.02 197.25 L 520.54 196.92 L 522.33 196.76 L 522.33 196.76 L 527.26 196.96 L 528.15 197.2 L 529.78 197.01 L 531.92 196.21 L 533.21 196.11 L 536.29 196.53 L 539.14 198.43 L 540.97 199.26 L 541.43 200.25 L 542.44 201.32 L 543.8 201.8 L 544.58 202.37 L 545.21 204.01 L 546.86 203.96 L 548.4 201.67 L 549.47 200.84 L 551.06 200.35 L 551.06 200.35 L 551.46 200.44 L 552.86 202.35 L 553.85 202.68 L 555.36 202.36 L 556.29 201.63 L 556.67 201.71 L 557.3 202.95 L 557.25 203.63 L 558.02 203.96 L 560.65 202.99 L 562.28 202.76 L 563.8 201.12 L 566.5 199.24 L 567.55 198.93 L 569.03 198.06 L 569.96 196.55 L 572.18 195.29 L 573.66 194.88 L 577.16 196.8 L 577.66 198.19 L 577.55 198.49 L 574.55 199.56 L 574.18 200.34 L 574.22 200.81 L 574.94 202.68 L 574.77 203.11 L 572.24 205.75 L 572.2 206.2 L 573.71 205.95 L 574.15 205.66 L 575.29 205.98 L 575.47 206.28 L 575.23 206.77 L 575.58 209.01 L 576.53 209.95 L 578.13 210.74 L 579.78 209.9 L 581.12 209.74 L 582.9 208.21 L 583.3 207.73 L 583.29 207.19 L 582.9 206.46 L 583.44 205.7 L 584.33 205.01 L 586.15 204.91 L 586.7 204.27 L 588.31 203.39 L 592.19 203.65 L 594.37 203.36 L 595.17 202.83 L 595.17 202.23 L 596.31 202.25 L 598.32 201.8 L 600.22 200.77 L 600.67 198.97 L 602.15 197.69 L 604.46 196.62 L 607.11 196.83 L 607.93 197.09 L 610.43 199.15 L 610.43 199.15 L 611.31 199.38 L 611.86 200.6 L 610.59 202.32 L 610.48 202.87 L 610.49 203.35 L 611.19 203.72 L 611.46 204.22 L 611.65 205.28 L 609.69 211.66 L 606.44 220.61 L 606.44 220.61 L 606.17 220.4 L 603.27 220.13 L 601.35 219.32 L 599.88 219.51 L 597.32 220.8 L 595.08 219.95 L 593.08 220.19 L 591.53 221.43 L 591.41 221.88 L 589.23 224.17 L 587.42 225.28 L 586.26 225.23 L 584.4 226.29 L 583.23 226.4 L 580.09 226.11 L 577.59 226.76 L 575.68 226.28 L 573.9 225.23 L 572 223.11 L 569.45 221.09 L 568.37 221.21 L 566.7 220.91 L 565.7 219.69 L 564.88 220.29 L 564.79 220.98 L 562.41 224.27 L 560.24 225.03 L 559.6 226.12 z"},{code:"PI",name:"Piauí",gTransform:"matrix(1 0 0 1 174.84 -130.97)",pathTransform:"translate(-480.85, -188.29)",d:"M 505.7 126.91 L 507.01 127.03 L 507.7 126.8 L 509.94 127.31 L 510.93 128.16 L 511.25 128.76 L 511.25 128.76 L 511.14 129.56 L 510.05 131.41 L 508.47 133.38 L 508.29 134.84 L 508.58 136.13 L 510.38 140.85 L 513.53 147.27 L 513.97 149 L 515.33 150.59 L 515.31 151.35 L 514.57 152.71 L 515.36 156.58 L 514.88 158.18 L 515.88 160.19 L 516.48 163.18 L 515.89 164.76 L 515.09 165.34 L 516.01 166.03 L 516.12 166.41 L 517.06 174.57 L 516.82 175.02 L 517.58 177.59 L 518.63 182.79 L 519.64 185.46 L 520.95 186.11 L 523.51 186.58 L 524.28 187.74 L 524.27 188.43 L 522.77 190.68 L 521.63 193.79 L 521.71 194.76 L 522.39 195.44 L 522.33 196.76 L 522.33 196.76 L 520.54 196.92 L 520.02 197.25 L 519.91 197.7 L 519.97 198.65 L 520.57 199.78 L 520.5 201.97 L 522.12 203.55 L 522.41 204.09 L 522.35 206.36 L 521.61 208.12 L 517.72 211.99 L 516.75 212.27 L 514.46 213.6 L 513.92 214.47 L 511.95 216.18 L 509.33 217.45 L 509.33 217.45 L 508.88 218.61 L 507.38 220.91 L 506.33 221.58 L 505.54 221.4 L 503.54 221.78 L 503.65 224.18 L 501.79 225.98 L 501.47 225.93 L 500.85 225.31 L 498.69 225.3 L 497.87 226.28 L 497.1 226.64 L 494.37 226.98 L 492.86 228.32 L 492.04 229.54 L 490.34 229.64 L 488.86 230.28 L 485.86 230.39 L 485.04 230.11 L 484.85 229.83 L 484.98 229.17 L 483.27 228.19 L 481.94 227.8 L 480.55 228.35 L 478.42 228.78 L 478.1 228.6 L 477.69 227.67 L 476.19 227.21 L 474.24 227.23 L 471 228.88 L 470.94 229.81 L 473.18 234.25 L 473.3 235.4 L 473.01 237.97 L 472.76 238.88 L 472.04 239.74 L 469.09 244.79 L 466.12 247.21 L 464.77 247.63 L 463.29 247.1 L 461.95 246.93 L 459.75 247.68 L 458.58 248.57 L 457.91 249.44 L 456.77 249.82 L 456.02 251.27 L 455.69 251.48 L 453.58 251.3 L 451.78 251.82 L 447.6 249.97 L 445.83 247.48 L 445.3 245.27 L 444.64 244.23 L 443.2 242.89 L 440.87 242.91 L 440.87 242.91 L 437.93 242.7 L 437.93 242.7 L 437.98 240.78 L 438.24 239.72 L 439.39 237.27 L 439.52 230.91 L 440.28 229.51 L 440.31 229 L 438.58 225.94 L 438.11 222.75 L 437.41 220.81 L 438.14 218.81 L 439.84 217.41 L 441.04 214.93 L 441.17 213.42 L 441.51 212.59 L 441.81 212.38 L 443.25 209.64 L 443.88 207.32 L 444.27 204.35 L 445.25 201.37 L 447.38 199.42 L 450.1 198.66 L 452.71 198.35 L 453.78 197.98 L 455.48 196.45 L 456.53 196.41 L 457.87 195.89 L 460.73 193.32 L 463.07 192.41 L 465.08 190.41 L 465.71 189.54 L 465.71 189.08 L 467.61 187.16 L 468.11 186.94 L 468.95 186.7 L 469.18 187 L 470.3 186.74 L 471.3 186.14 L 472.76 185.95 L 473.77 186.16 L 476.28 187.98 L 477.79 187.88 L 480.23 187.02 L 481.06 186.98 L 481.71 187.26 L 483.99 186.97 L 485.2 185.66 L 485.7 184.2 L 485.82 182.99 L 486.11 182.55 L 486.5 180.35 L 486.37 179.5 L 486.2 179 L 484.59 178.09 L 482.81 176.06 L 482.3 173.76 L 482.19 171.65 L 482.36 169.17 L 486.46 164.74 L 486.67 164.19 L 486.77 161.76 L 486.22 158.78 L 484.64 155.98 L 485.78 153.11 L 486.06 151.64 L 485.68 150.37 L 484.45 149.53 L 484.1 147.61 L 484.87 146.56 L 485.51 146.39 L 486.33 144.41 L 488.22 142.56 L 489.1 140.73 L 489.06 138.94 L 491.98 135.53 L 492.79 135.69 L 496.1 135.23 L 500.23 131.26 L 502.02 128.99 L 502.41 127.46 L 501.77 126.93 L 501.55 126.21 L 502.01 124.77 L 502.01 124.77 L 502.74 124.89 L 504.21 125.76 L 504.72 126.27 L 504.59 126.58 z"},{code:"PR",name:"Paraná",gTransform:"matrix(1 0 0 1 47.59 157)",pathTransform:"translate(-353.59, -476.27)",d:"M 396.75 499.4 L 391.51 499.37 L 391.18 499.81 L 389.44 500.05 L 388.68 499.98 L 388.57 499.59 L 387 500.16 L 385.65 501.59 L 382.3 503.72 L 380.86 503.56 L 379.63 502.94 L 376.5 500.34 L 375.47 499.95 L 374.71 499.94 L 371.87 500.67 L 369.54 500.84 L 368.73 500.81 L 367.31 500.05 L 366.2 500.19 L 364.67 500.84 L 364.08 502.31 L 363.35 503.18 L 361.48 504.16 L 357.91 503.75 L 355.91 504.9 L 355.19 505.67 L 354.5 507.26 L 355.35 510.25 L 354.48 511.11 L 353.56 511.13 L 352.81 511.51 L 352.64 512 L 351.31 510.11 L 347.06 510.24 L 343.3 509.81 L 341.72 508.63 L 341.56 508.22 L 340.53 507.59 L 336.27 507.23 L 330.98 505.55 L 328.64 506.12 L 325.95 506.09 L 323.93 504.68 L 323.61 504.17 L 322.55 503.93 L 322.02 503.92 L 321.31 504.29 L 317.68 504.27 L 317.68 504.27 L 317.46 503.06 L 314.93 498.88 L 314.95 496.29 L 313.96 493.41 L 310.54 491.04 L 309.45 492.17 L 307.33 492.06 L 306.23 492.49 L 305.16 493.39 L 303.7 492.31 L 302.88 492.37 L 302.6 490.17 L 303.26 488.6 L 304.33 487.33 L 305.55 485.15 L 305.61 484.81 L 305.12 484.06 L 305.14 482.82 L 306.04 479.18 L 307.3 476.16 L 307.05 473.86 L 308.33 471.48 L 308.12 470.46 L 307.28 469.58 L 306.97 467.98 L 307.63 466.92 L 308.42 466.38 L 308.42 466.38 L 310.8 464.82 L 311.16 464 L 312.73 456.08 L 313.06 455.73 L 314.17 455.41 L 315.83 454.4 L 316.5 453.72 L 317.95 450.16 L 317.93 449.01 L 318.86 446.68 L 319.97 445.86 L 325.38 443.59 L 325.38 443.59 L 328.64 441.3 L 332.47 441.95 L 336.48 441.84 L 339.75 442.13 L 340.96 441.51 L 341.31 440.91 L 342.04 440.54 L 343.21 440.83 L 344.69 441.61 L 347.21 442.07 L 349.85 443.16 L 351.16 443.29 L 352.23 442.75 L 354.81 442.74 L 355.59 443.74 L 357.34 444.58 L 360.85 445.38 L 361.48 445.89 L 362.19 447.21 L 363.92 447.28 L 364.34 446.94 L 365.99 447.09 L 366.65 447.63 L 371.96 447.76 L 374.93 446.91 L 376.06 448.46 L 379.65 451.29 L 380.54 453.05 L 380.55 455.79 L 380.16 456.37 L 380 457.18 L 380.38 459.02 L 381.68 460.53 L 381.6 462.29 L 381.24 462.85 L 382.73 465.85 L 383.94 467 L 384.61 467.28 L 385.11 467.96 L 385.06 468.85 L 385.98 470.82 L 386.58 471.11 L 386.83 471.55 L 386.58 472.6 L 385.31 474.73 L 385.63 476.77 L 386.23 477.15 L 387.24 477.36 L 389.62 477.24 L 393.04 476.71 L 393.54 477.1 L 395.12 476.91 L 396.71 477.04 L 398.32 478.3 L 398.18 478.71 L 397.29 479.36 L 396.6 482.66 L 396.95 483.44 L 398.02 483.97 L 398.67 483.12 L 399.77 480.36 L 400.53 480.19 L 402.67 480.77 L 402.27 482.72 L 403 486.02 L 404.42 486.6 L 404.58 487.92 L 404.58 487.92 L 403.23 488.94 L 402.62 490.42 L 402.07 490.3 L 402.34 488.36 L 403.78 487.41 L 402.37 487.69 L 401.48 488.18 L 400.61 488.16 L 400.27 487.77 L 399.7 487.6 L 399.16 487.97 L 398.88 488.9 L 399.4 489.7 L 398.67 490.66 L 398.37 490.76 L 395.89 490.23 L 395.1 489.69 L 394.65 489.81 L 394.47 490.71 L 394.81 491.08 L 396.42 491.64 L 397.82 491.39 L 399.95 491.99 L 400.22 492.47 L 399.25 493.15 L 397.71 495.93 L 396.47 496.7 L 394.05 497.27 L 393.85 497.72 L 396.8 497.52 L 396.95 498.71 z"},{code:"RJ",name:"Rio de Janeiro",gTransform:"matrix(1 0 0 1 179.27 113.69)",pathTransform:"translate(-485.28, -432.95)",d:"M 468.35 450.28 L 468.28000000000003 449.5 L 468.66 449.23 L 471.85 449.45000000000005 L 474.44 448.86000000000007 L 471.91 447.31000000000006 L 470.51000000000005 446.81000000000006 L 467.70000000000005 447.49000000000007 L 466.34000000000003 449.0900000000001 L 465.31000000000006 449.4100000000001 L 464.61000000000007 449.36000000000007 L 463.26000000000005 447.2100000000001 L 462.78000000000003 447.2100000000001 L 461.88000000000005 447.6300000000001 L 460.9200000000001 448.6900000000001 L 457.7700000000001 449.4900000000001 L 457.4300000000001 450.40000000000015 L 457.2400000000001 452.3000000000001 L 459.4300000000001 452.4300000000001 L 460.5000000000001 453.4400000000001 L 459.35000000000014 454.5200000000001 L 458.41000000000014 454.3500000000001 L 456.9900000000001 454.5200000000001 L 456.9900000000001 454.5200000000001 L 456.5100000000001 454.2600000000001 L 454.8800000000001 452.5300000000001 L 454.8300000000001 452.12000000000006 L 455.9200000000001 448.62000000000006 L 457.01000000000005 447.4700000000001 L 459.36000000000007 446.4600000000001 L 459.86000000000007 446.61000000000007 L 462.63000000000005 446.25000000000006 L 464.13000000000005 445.5400000000001 L 465.78000000000003 443.3900000000001 L 465.03000000000003 441.7500000000001 L 463.33000000000004 441.7400000000001 L 460.18000000000006 442.2700000000001 L 458.4100000000001 441.8800000000001 L 457.18000000000006 440.29000000000013 L 456.62000000000006 439.1200000000001 L 455.3500000000001 438.5800000000001 L 455.3500000000001 438.5800000000001 L 456.0300000000001 438.0900000000001 L 458.4500000000001 437.3500000000001 L 461.3600000000001 436.0100000000001 L 463.9400000000001 435.8400000000001 L 464.4400000000001 436.11000000000007 L 466.16000000000014 435.3400000000001 L 467.21000000000015 434.5700000000001 L 471.3000000000001 432.7800000000001 L 471.8200000000001 432.7100000000001 L 472.1800000000001 433.0200000000001 L 475.3800000000001 432.9500000000001 L 476.6300000000001 432.7800000000001 L 478.2600000000001 431.8400000000001 L 478.8300000000001 431.7800000000001 L 481.36000000000007 432.05000000000007 L 481.8500000000001 432.2200000000001 L 481.8300000000001 432.6900000000001 L 483.2100000000001 432.4900000000001 L 492.7200000000001 427.96000000000015 L 495.25000000000006 426.97000000000014 L 495.46000000000004 426.45000000000016 L 495.18000000000006 425.84000000000015 L 493.74000000000007 425.71000000000015 L 493.83000000000004 424.96000000000015 L 495.72 421.25000000000017 L 498.08000000000004 415.21000000000015 L 497.35 414.50000000000017 L 497.91 414.01000000000016 L 499.15000000000003 413.7400000000002 L 501.68 411.38000000000017 L 501.68 411.38000000000017 L 503.61 412.14000000000016 L 504.28000000000003 416.85000000000014 L 506.78000000000003 417.98000000000013 L 511.11 418.9900000000001 L 514.1 418.6200000000001 L 515.72 419.6800000000001 L 515.72 419.6800000000001 L 515.64 420.9500000000001 L 514.6999999999999 422.5600000000001 L 514.4799999999999 424.6900000000001 L 515.6199999999999 431.4700000000001 L 515.1199999999999 432.1500000000001 L 512.0399999999998 433.9000000000001 L 506.0699999999998 435.8400000000001 L 503.23999999999984 437.5600000000001 L 499.73999999999984 441.2500000000001 L 499.6299999999998 442.91000000000014 L 499.9399999999998 444.10000000000014 L 499.74999999999983 445.72000000000014 L 499.0199999999998 447.20000000000016 L 497.1999999999998 447.71000000000015 L 490.6499999999998 447.54000000000013 L 484.8599999999998 448.2400000000001 L 482.4699999999998 447.78000000000014 L 481.9799999999998 447.40000000000015 L 481.9199999999998 446.72000000000014 L 482.94999999999976 445.2400000000001 L 483.6199999999998 443.79000000000013 L 483.5299999999998 443.17000000000013 L 482.74999999999983 442.9900000000001 L 479.9599999999998 444.1400000000001 L 479.6999999999998 444.8300000000001 L 480.0099999999998 445.6200000000001 L 481.3899999999998 446.79000000000013 L 481.6399999999998 447.76000000000016 L 481.04999999999984 448.28000000000014 L 479.41999999999985 448.79000000000013 L 477.84999999999985 448.76000000000016 L 469.80999999999983 449.83000000000015 L 468.35 450.28 z M 463.24 452.27 L 462.57 451.29999999999995 L 464.68 449.74999999999994 L 466.54 450.68999999999994 L 466.97 451.38999999999993 L 464.51000000000005 451.88999999999993 L 464.1 451.5399999999999 L 463.63 451.5399999999999 L 463.24 452.27 z"},{code:"RN",name:"Rio Grande do Norte",gTransform:"matrix(1 0 0 1 274.86 -145.63)",pathTransform:"translate(-580.87, -173.63)",d:"M 609.29 182.91 L 608.36 183.15 L 604.86 182.94 L 603.82 183.34 L 601.36 182.24 L 599.19 181.94 L 593.36 182.33 L 592.83 181.98 L 589.41 181.58 L 588.79 181.09 L 588.89 180.09 L 588.47 179.7 L 587.09 179.75 L 585.27 181.1 L 584.96 182.58 L 585.68 183.36 L 586.21 184.89 L 585.2 184.57 L 584.72 185.16 L 584.88 186.58 L 585.35 187.52 L 584.8 188.73 L 584.3 189.47 L 581.95 190.4 L 581.12 189.66 L 581.64 188.12 L 580.75 186.95 L 578.8 186.65 L 577.03 186.73 L 573.88 187.99 L 573.59 187.76 L 573.28 186.38 L 572.96 186.15 L 569.43 185.63 L 569.51 183.91 L 569.72 183.6 L 570.57 183.35 L 570.98 182.97 L 571.36 181.23 L 571.8 180.27 L 574.79 177.06 L 574.78 175.87 L 574.25 175.43 L 573.61 175.35 L 570.35 176.39 L 568.92 176.51 L 565.74 177.72 L 565.33 178.67 L 565.23 179.71 L 564.41 180.42 L 561.18 182.08 L 560.02 183.21 L 557.14 182.6 L 556.24 182.18 L 554.31 180.54 L 553.74 181 L 553.74 181 L 553.08 181.38 L 552.44 181.21 L 552.78 179.24 L 554.19 176.99 L 555.03 176.11 L 555.54 176.04 L 556.32 176.55 L 557.35 176.29 L 557.92 175.19 L 559.38 173.68 L 560.78 171.24 L 560.63 170.5 L 561.28 168.83 L 562.15 168.26 L 562.99 167.14 L 566.29 160.45 L 568.9 158.44 L 573.79 156.85 L 573.79 156.85 L 574.26 157.61 L 575.12 158.36 L 578.25 158.35 L 579.47 158.76 L 581.16 160.51 L 582.48 161.01 L 585.81 160.69 L 588.69 161.21 L 591.23 160.97 L 593.56 160.24 L 598.06 161.16 L 599.33 161.2 L 601.28 162.06 L 602.3 162.88 L 602.94 163.82 L 605.25 168.56 L 605.75 170.35 L 605.71 171.1 L 607.19 176.48 L 607.4 178.16 L 608.12 178.7 L 609.08 181.39 z"},{code:"RO",name:"Rondônia",gTransform:"matrix(1 0 0 1 -139.57 -68.08)",pathTransform:"translate(-166.43, -251.18)",d:"M 187.32 290.95 L 186.03 289.5 L 185.59 287.62 L 184.03 287.1 L 183.17 287.42 L 181.36 287.5 L 177.29 285.69 L 177.28 285.29 L 176.62 284.68 L 175.35 285.27 L 173.37 283.59 L 171.85 282.62 L 170.99 281.16 L 170.71 279.77 L 169.67 279.38 L 167.9 280.5 L 166.68 280.47 L 165.27 279.67 L 164.4 278.34 L 161.27 276.76 L 159.31 276.59 L 158.17 277.13 L 157.27 277.98 L 155.84 277.81 L 155.53 277.51 L 153.39 277 L 150.33 276.72 L 149.57 276.29 L 148.39 275.1 L 148.09 273.13 L 146.51 272.64 L 144.62 271.67 L 143.8 269.95 L 143.51 269.75 L 140.79 269.47 L 140.41 269.12 L 139.57 265.41 L 138.69 264.52 L 138.21 265.68 L 137.55 265.36 L 137.28 264.72 L 137.9 263.19 L 137.06 261.67 L 135.7 261.28 L 134.44 257.81 L 134.27 256.15 L 135.82 253.24 L 135.61 251.58 L 134.45 249.61 L 133.7 247.45 L 133.64 245.16 L 134.26 244.66 L 134.64 243.29 L 135.68 242.24 L 136.04 240.77 L 135.8 239.28 L 135.38 238.39 L 135.29 236.86 L 135.83 235.21 L 134.66 233.03 L 133.64 232.65 L 132.55 233.63 L 132.49 234.14 L 131.65 235.1 L 131.08 235.1 L 128.9 234.08 L 123.72 234.16 L 118.11 235.94 L 116.42 235.93 L 114.94 236.41 L 114.94 236.41 L 111.97 235.15 L 111.97 235.15 L 115.23 232.59 L 117.15 232.01 L 118.7 230.2 L 118.85 229.64 L 118.69 228.35 L 122.65 228.61 L 125.52 228.28 L 126.24 228.65 L 128.55 230.98 L 128.92 230.96 L 130.14 230.17 L 130.27 229.45 L 130.68 228.92 L 131.76 228.42 L 132.53 228.55 L 133.9 228.16 L 135.2 226.95 L 137.04 225.93 L 137.42 226.02 L 138.06 228.28 L 138.74 228.81 L 139.42 228.73 L 141.96 225.57 L 141.7 223.82 L 142.23 222.98 L 143.98 221.72 L 144.44 221.74 L 145.28 222.29 L 147.07 222.39 L 148.27 221.32 L 150.4 220.94 L 154.27 221.4 L 154.03 219.94 L 154.14 218.13 L 156.2 216.92 L 157.01 215.77 L 157.37 214.75 L 157.2 214.3 L 156.3 213.6 L 156.35 212.93 L 157.54 211.34 L 160.02 210.81 L 160.28 210.59 L 160.19 209.42 L 161.91 208.92 L 163.29 206.36 L 174.08 206.3 L 176.23 207.43 L 176.68 207.92 L 177.48 209.83 L 178.81 211.1 L 181.35 212.08 L 182.6 215.35 L 183.06 215.56 L 184.04 215.43 L 184.66 215.63 L 185.34 218.51 L 188.58 219.99 L 189.26 219.8 L 189.8 218.06 L 191.72 216.98 L 193.11 217.26 L 193.47 217.64 L 193.43 218.34 L 193.43 218.34 L 194.83 219.31 L 195.43 220.55 L 194.67 221.97 L 193.38 226.96 L 193.44 227.31 L 194.22 227.78 L 194.48 228.39 L 194.63 229.78 L 195.46 232.05 L 194.52 233.72 L 194.9 235.65 L 193.9 239.17 L 193.87 239.97 L 194.14 241.73 L 195.64 244.48 L 194.74 253.48 L 211.9 253.53 L 211.66 254.09 L 212.88 255.2 L 216.38 255.11 L 217.49 255.22 L 218.56 255.65 L 219.97 259.24 L 219.8 259.99 L 218.4 261.74 L 217.04 262.82 L 216.9 264.14 L 217.33 267.39 L 217.91 267.9 L 218.81 267.87 L 220.34 271.21 L 220.3 273.26 L 220.88 274.75 L 220.81 276.46 L 220.25 278.7 L 218.59 280.71 L 218.07 282.96 L 217.49 283.8 L 217.06 284.21 L 215.42 284.74 L 214.49 285.82 L 213.06 289.6 L 212.54 292.05 L 208.43 294.62 L 206.96 296.05 L 206.96 296.05 L 206.22 296.01 L 203.63 294.46 L 202.36 293.03 L 195.28 293.99 L 193.96 293.56 L 193.71 293.26 L 190.33 293.92 L 189.85 293.76 L 189.33 292.41 z"},{code:"RR",name:"Roraima",gTransform:"matrix(1 0 0 1 -116.08 -267.27)",pathTransform:"translate(-189.92, -51.99)",d:"M 234.61 61.4 L 236.21 78.37 L 236.21 78.37 L 217.72 78.3 L 217.75 78.98 L 215.42 82.24 L 213.76 85.27 L 213.69 86.4 L 212.54 89.04 L 212.43 89.7 L 212.66 90.43 L 213.8 91.84 L 213.78 92.37 L 213.36 92.76 L 211.33 93.31 L 209.92 94.72 L 208.67 95.18 L 206.85 94.95 L 205.93 92.44 L 204.06 90.4 L 201.23 89.47 L 199.63 89.53 L 199.08 90.42 L 196.99 91.13 L 195.71 91.82 L 194.69 93.08 L 193.87 96.05 L 194.24 97.85 L 193.99 99.58 L 193.24 101.87 L 193.68 103.98 L 191.32 102.94 L 189.98 103.36 L 189.45 103.29 L 188.41 101.25 L 186.93 99.6 L 184.97 98.29 L 184.45 98.25 L 179.44 93.83 L 179.58 92.69 L 181.42 93.02 L 182.56 91.7 L 182.62 91.12 L 181.49 86.79 L 180.91 85.89 L 179.69 85.05 L 178.81 82.88 L 178.52 77.9 L 179.09 76.94 L 179.86 73.9 L 179.2 72.32 L 178.84 70.73 L 180.46 69.27 L 180.41 68.82 L 179.54 67.7 L 179.35 65.44 L 177.69 60.68 L 174.96 56.94 L 175.67 55.44 L 176.58 52.12 L 176.09 51.46 L 174.14 50.51 L 172.78 50.4 L 171.9 50.61 L 170.93 50.24 L 169.72 49.07 L 169.66 48.11 L 169.03 48 L 167.9 48.42 L 167.29 48.41 L 166.54 48.07 L 165.82 47.29 L 165.82 47.29 L 166.12 46.83 L 166.35 44.55 L 166.05 44.33 L 162.68 44.1 L 158.93 44.24 L 155.62 43.54 L 155.42 42.94 L 156.22 41.18 L 156.34 39.7 L 155.61 37.93 L 153.67 34.39 L 152.94 32.33 L 152.47 28.61 L 153.26 27.13 L 153.18 26.17 L 151.34 24.17 L 149.18 23.11 L 146.37 20.33 L 145.31 18.52 L 145.02 17.56 L 143.88 16.91 L 143.63 16.52 L 143.66 15.68 L 143.95 15.35 L 144.85 15.42 L 145.97 16.08 L 146.91 17.81 L 147.52 17.9 L 150.91 17.4 L 152.26 17.5 L 154.17 18.09 L 154.78 19.29 L 155.33 21.22 L 155.87 21.57 L 156.83 21.49 L 157.57 20.84 L 158.52 20.44 L 161.7 20.6 L 162.17 20.65 L 163.48 21.86 L 164.08 22.01 L 164.6 21.87 L 165.21 20.31 L 166.52 20.45 L 167.97 21.38 L 171.9 25.95 L 172.95 26.52 L 173.66 26.63 L 175.17 25.95 L 175.91 24.82 L 176.01 23.98 L 175.18 21.22 L 175.54 19.48 L 176 19.2 L 177.93 19.15 L 178.94 18.05 L 180.49 16.96 L 181.24 17.01 L 185.14 18.35 L 185.73 18.18 L 186.53 17.46 L 187.56 17.16 L 188.69 17.51 L 189.72 17.3 L 191.06 16.02 L 192.06 15.77 L 193.21 16 L 194.32 15.93 L 195 15.08 L 195.05 13.73 L 198.08 11.92 L 200.41 12.11 L 203.17 11.72 L 204.06 10.59 L 204.15 9.88 L 204.74 8.76 L 205.49 8.63 L 207.34 7.73 L 208.44 6.69 L 209.55 4.98 L 208.35 1.42 L 207.18 1.06 L 207.82 0.88 L 209.25 0.95 L 210.05 1.27 L 213.62 1.17 L 214.68 0.22 L 215.42 0 L 216.79 0.42 L 217.32 1.73 L 218.36 2.53 L 218.84 3.9 L 218.17 8.8 L 217.45 10.18 L 216.2 10.88 L 216.26 11.71 L 217.87 12.12 L 219.49 11.9 L 221.84 12.71 L 223.66 13.81 L 222.78 15.24 L 222.77 16.39 L 225.11 19.81 L 225.31 21.36 L 223.8 24.28 L 221.92 25.69 L 221.2 27.19 L 221.47 27.58 L 221.53 29.75 L 220.06 32.16 L 219.16 34.93 L 218.85 37.5 L 218.76 40.17 L 219.74 42.04 L 220.25 43.8 L 220.24 45.2 L 221.81 46.23 L 222.71 46.43 L 222.84 47.11 L 222.38 52.26 L 222.5 53 L 224.31 53.29 L 223.65 54.46 L 224.11 54.96 L 226.26 55.7 L 227.72 57.62 L 230.38 60.36 z"},{code:"RS",name:"Rio Grande do Sul",gTransform:"matrix(1 0 0 1 11.62 259.25)",pathTransform:"translate(-317.63, -578.5)",d:"M 321.99 638.52 L 321.63 638.53 L 319.69 637.42 L 319.49 636.96 L 320.01 632.69 L 319.55 628.44 L 319.7 627.37 L 320.33 626.13 L 323.17 623.75 L 324 622.19 L 326.3 619.63 L 324.84 617.98 L 323.77 617.36 L 321.52 616.76 L 319.2 614.51 L 317.99 612.89 L 317.89 611.3 L 317.46 610.12 L 316.23 608.09 L 314.17 605.85 L 313.5 605.26 L 311.11 604.05 L 309.66 604.26 L 307.76 602.75 L 306.24 601.12 L 304.99 600.34 L 304.85 598.64 L 302.95 596.48 L 299.63 596.02 L 298.71 595.55 L 296.98 593.89 L 295.22 594.02 L 293.05 592.64 L 291.14 588.93 L 290.03 587.44 L 287.5 585.32 L 286.8 585.4 L 286.13 587.19 L 283.54 589.43 L 280.87 589.55 L 280.97 586.69 L 281.37 585.41 L 280.98 584.41 L 277.33 580.12 L 274.96 578.35 L 272.78 576.29 L 271.03 574.18 L 268.34 571.97 L 266.44 571.83 L 264.29 572.04 L 263.15 573.4 L 263.09 574.36 L 262.06 575.33 L 260.95 575.35 L 260.37 574.87 L 257.21 575.01 L 256.56 574.53 L 256.4 573.62 L 255.91 573.4 L 256.76 573.18 L 257.8 572.46 L 260.32 569.69 L 260.43 567.85 L 261.03 566.6 L 261.85 566.15 L 263.14 566.08 L 263.78 565.82 L 264.7 564.82 L 270.15 558.34 L 270.78 556.92 L 270.95 555.81 L 271.77 554.74 L 272.97 553.89 L 274.34 553.48 L 276.3 549.26 L 276.4 548.65 L 276.71 548.28 L 278.35 547.42 L 279.98 545.62 L 280.83 544.47 L 281.34 543.18 L 282.68 541.08 L 283.61 540.79 L 285.18 540.97 L 285.73 541.76 L 286.2 540.48 L 285.99 539.9 L 284.64 539.08 L 284.59 538.72 L 284.94 538.39 L 286.02 538.01 L 286.84 537.05 L 289.63 536.1 L 290.68 535.03 L 290.78 534.11 L 291.6 533.2 L 293.81 532.05 L 296.28 531.65 L 298.05 529.84 L 298.2 528.78 L 299.52 526.42 L 299.85 526.38 L 299.9 526.74 L 300.19 526.94 L 301.52 526.77 L 303.96 525.64 L 306.64 525.05 L 307.85 524.48 L 309.95 522.13 L 310.45 522.14 L 311.12 521.75 L 312.13 520.4 L 314.44 519.67 L 314.74 520.05 L 314.74 520.05 L 318.26 520.44 L 321.52 519.29 L 322.08 518.48 L 323.43 519.06 L 323.28 519.98 L 326.36 519.95 L 327.99 520.94 L 330.55 520.57 L 332.47 521.72 L 335.05 521.31 L 336.59 521.49 L 339.39 521.33 L 341.65 522.25 L 344.13 523.65 L 345.13 526.09 L 346.72 526.28 L 346.81 525.8 L 348.62 525.45 L 354.18 528.99 L 355.55 530.54 L 356.26 530.51 L 357.82 531.49 L 360.85 534.98 L 362.49 537.19 L 362.97 538.67 L 365.14 541.33 L 366.31 541.88 L 373 542.94 L 375.11 542.54 L 378.46 542.88 L 379.34 545.22 L 377.26 546.8 L 375.99 547.21 L 375.26 549.07 L 375.48 551.26 L 375.1 552.82 L 374.58 554.12 L 373.4 554.32 L 372.11 556.01 L 372.08 557.42 L 373.88 558.59 L 374.15 558.39 L 373.87 557.42 L 373.88 556.46 L 375.37 555.64 L 376.95 556.28 L 377.68 557.19 L 378.85 558.04 L 379.3 558.01 L 379.3 558.01 L 377.9 559.74 L 374 566.78 L 369.79 578.38 L 363.49 588.86 L 358.05 595.52 L 351.54 601.48 L 345.45 605.16 L 342.35 609.47 L 342.17 609.04 L 342.82 607.46 L 343.16 605.28 L 341.98 603.57 L 342.08 603.15 L 343.01 602.98 L 344.02 603.38 L 344.58 603.96 L 345.6 604 L 348.18 602.59 L 349 601.91 L 351.85 598.2 L 352.6 597.51 L 353.05 597.7 L 354.07 597.51 L 355.12 596.67 L 356.05 595.4 L 356.42 593.92 L 356.6 592.99 L 356.37 590.89 L 356.57 589.52 L 358.14 589.45 L 358.88 589.75 L 359.15 590.58 L 359.5 590.32 L 359.21 588.92 L 359.72 586.85 L 360.2 586.28 L 362.94 584.69 L 363.67 583.61 L 364.14 580.86 L 363.93 578.58 L 364.49 577.9 L 364.99 578.7 L 365.36 578.73 L 365.79 578.31 L 366.26 575.23 L 366.16 574.79 L 365.21 573.57 L 364.54 573.54 L 364.28 574.23 L 364.45 574.62 L 364.31 575.19 L 363.96 575.39 L 362.45 575.37 L 360.44 575.77 L 360.1 577.38 L 359.57 577.43 L 358.76 576.99 L 358.86 575.28 L 358.04 574.39 L 357 574.72 L 356.4 574.24 L 355.67 572.98 L 355.27 571.53 L 355.39 570.96 L 354.75 570.27 L 354.14 572.98 L 354.58 575.23 L 355.83 577.34 L 355.26 578.15 L 354.52 580.69 L 354.9 583.72 L 354.72 584.49 L 354.24 584.12 L 354.5 583.88 L 354.47 583.17 L 354 581.89 L 353.55 581.5 L 353.02 582.16 L 352.99 583.53 L 351.58 586.8 L 351.53 588.69 L 351.75 589.21 L 351.03 589.91 L 349.42 590.55 L 348.81 592.13 L 344.72 593.7 L 344 594.23 L 343.47 595.82 L 343.37 598.09 L 342.4 600.36 L 340.04 601.66 L 339.93 603.42 L 340.41 604.25 L 340.66 605.27 L 339.71 605.83 L 339.46 607.34 L 339.89 607.94 L 340.57 607.8 L 341.87 608.43 L 342.02 609.34 L 339.89 610.99 L 337.57 615.51 L 335.64 622.39 L 333.63 626.88 L 331.95 629.4 L 324.16 636.93 z"},{code:"SC",name:"Santa Catarina",gTransform:"matrix(1 0 0 1 51.41 209.71)",pathTransform:"translate(-357.4, -528.97)",d:"M 379.3 558.01 L 378.85 558.04 L 377.68 557.1899999999999 L 376.95 556.27 L 375.36 555.64 L 373.88 556.46 L 373.87 557.4200000000001 L 374.15 558.3900000000001 L 373.88 558.5900000000001 L 372.08 557.4200000000002 L 372.12 556.0100000000002 L 373.4 554.3200000000002 L 374.58 554.1200000000001 L 375.10999999999996 552.8100000000002 L 375.47999999999996 551.2600000000002 L 375.25999999999993 549.0700000000002 L 375.98999999999995 547.2100000000002 L 377.25999999999993 546.7900000000002 L 379.3399999999999 545.2100000000002 L 378.4599999999999 542.8700000000001 L 375.1099999999999 542.5300000000001 L 372.9999999999999 542.9300000000001 L 366.3099999999999 541.8700000000001 L 365.14999999999986 541.3300000000002 L 362.97999999999985 538.6700000000002 L 362.48999999999984 537.1900000000002 L 360.85999999999984 534.9800000000001 L 357.82999999999987 531.4900000000001 L 356.2599999999999 530.5000000000001 L 355.5499999999999 530.5300000000001 L 354.1799999999999 528.9800000000001 L 348.6199999999999 525.4400000000002 L 346.8099999999999 525.7800000000002 L 346.7199999999999 526.2600000000002 L 345.1199999999999 526.0700000000002 L 344.1199999999999 523.6300000000001 L 341.64999999999986 522.2400000000001 L 339.3799999999999 521.3100000000002 L 336.58999999999986 521.4700000000001 L 335.04999999999984 521.2900000000002 L 332.45999999999987 521.7000000000002 L 330.54999999999984 520.5500000000002 L 327.97999999999985 520.9100000000002 L 326.34999999999985 519.9300000000002 L 323.26999999999987 519.9600000000002 L 323.41999999999985 519.0300000000002 L 322.0699999999998 518.4500000000002 L 321.5099999999998 519.2600000000001 L 318.24999999999983 520.4200000000001 L 314.72999999999985 520.0300000000001 L 314.72999999999985 520.0300000000001 L 316.17999999999984 517.1000000000001 L 316.90999999999985 515.0100000000001 L 316.32999999999987 511.7600000000001 L 316.7399999999999 508.5500000000001 L 316.6999999999999 506.0000000000001 L 317.65999999999985 504.2500000000001 L 317.65999999999985 504.2500000000001 L 321.28999999999985 504.2700000000001 L 321.99999999999983 503.8900000000001 L 322.5299999999998 503.9000000000001 L 323.5899999999998 504.1400000000001 L 323.8999999999998 504.6500000000001 L 325.9299999999998 506.0600000000001 L 328.6099999999998 506.0900000000001 L 330.94999999999976 505.5100000000001 L 336.2399999999998 507.1900000000001 L 340.4999999999998 507.5500000000001 L 341.51999999999975 508.1800000000001 L 341.68999999999977 508.59000000000015 L 343.25999999999976 509.77000000000015 L 347.02999999999975 510.19000000000017 L 351.27999999999975 510.0600000000002 L 352.60999999999973 511.96000000000015 L 352.78999999999974 511.46000000000015 L 353.52999999999975 511.08000000000015 L 354.44999999999976 511.0600000000002 L 355.31999999999977 510.20000000000016 L 354.46999999999974 507.21000000000015 L 355.15999999999974 505.63000000000017 L 355.87999999999977 504.8500000000002 L 357.87999999999977 503.7100000000002 L 361.44999999999976 504.1100000000002 L 363.31999999999977 503.14000000000016 L 364.0499999999998 502.27000000000015 L 364.63999999999976 500.79000000000013 L 366.16999999999973 500.14000000000016 L 367.27999999999975 500.00000000000017 L 368.69999999999976 500.76000000000016 L 369.50999999999976 500.79000000000013 L 371.83999999999975 500.6200000000001 L 374.6799999999997 499.8900000000001 L 375.4299999999997 499.9000000000001 L 376.46999999999974 500.30000000000007 L 379.58999999999975 502.9000000000001 L 380.81999999999977 503.5200000000001 L 382.25999999999976 503.6800000000001 L 385.6099999999998 501.5500000000001 L 386.9599999999998 500.1200000000001 L 388.5199999999998 499.5500000000001 L 388.6399999999998 499.9400000000001 L 389.3999999999998 500.0100000000001 L 391.1399999999998 499.7800000000001 L 391.4699999999998 499.3400000000001 L 396.7099999999998 499.37000000000006 L 396.7099999999998 499.37000000000006 L 396.3199999999998 500.69000000000005 L 396.8299999999998 502.34000000000003 L 396.7599999999998 502.73 L 395.2599999999998 503.87 L 394.2799999999998 503.39 L 393.4599999999998 500.86 L 393.4399999999998 501.98 L 394.0299999999998 504.70000000000005 L 395.7399999999998 506.36000000000007 L 396.2999999999998 507.31000000000006 L 395.2899999999998 509.6000000000001 L 395.12999999999977 511.9200000000001 L 395.2299999999998 512.35 L 395.9899999999998 513.08 L 396.2499999999998 518.94 L 396.5599999999998 519.49 L 396.9899999999998 519.69 L 397.75999999999976 519.1800000000001 L 398.1099999999998 519.9000000000001 L 398.2099999999998 520.7700000000001 L 397.7399999999998 520.83 L 397.3099999999998 520.5500000000001 L 396.1199999999998 521.1800000000001 L 395.7799999999998 525.0200000000001 L 396.3499999999998 527.6100000000001 L 395.7799999999998 528.3600000000001 L 396.0899999999998 530.2900000000001 L 396.99999999999983 532.1700000000001 L 396.1399999999998 534.5100000000001 L 395.61999999999983 538.5200000000001 L 393.90999999999985 543.2 L 393.5699999999999 543.1 L 393.20999999999987 542.34 L 393.41999999999985 541.37 L 392.49999999999983 540.19 L 392.23999999999984 540.5200000000001 L 392.41999999999985 542.95 L 393.57999999999987 543.7800000000001 L 392.65999999999985 545.44 L 391.01999999999987 546.09 L 386.8899999999999 549.13 L 384.08999999999986 551.6899999999999 L 380.33999999999986 556.13 L 379.3 558.01 z M 397.18 531.46 L 397.03000000000003 530.99 L 397.28000000000003 529.24 L 398.04 526.84 L 397.64000000000004 525.6600000000001 L 397.80000000000007 524.6400000000001 L 399.20000000000005 523.8800000000001 L 399.4200000000001 523.94 L 400.0800000000001 524.8800000000001 L 399.5400000000001 527.44 L 398.7200000000001 528.3000000000001 L 398.1300000000001 529.5200000000001 L 398.3300000000001 530.69 L 397.18 531.46 z M 396.73 507.09 L 394.86 505.07 L 397.41 502.63 L 397.66 502.67 L 398.31 503.72 L 397.45 505.04 L 396.73 507.09 z"},{code:"SE",name:"Sergipe",gTransform:"matrix(1 0 0 1 266.49 -72.82)",pathTransform:"translate(-572.49, -246.44)",d:"M 569.94 261.69 L 567.04 262.58 L 565.49 261.94 L 564.95 261.6 L 564.47 260.88 L 562.55 259.96 L 561.95 259.44 L 561.83 259.03 L 562.17 258.64 L 562.3 257.22 L 562.15 256.83 L 560.72 255.32 L 560.2 253.83 L 559.11 253.16 L 558.15 251.56 L 558.13 250.79 L 558.72 249.21 L 559.04 248.91 L 560.74 248.92 L 561.87 249.67 L 564.42 248.68 L 565.11 248.13 L 565.41 247.55 L 564.65 244.8 L 564.73 243.92 L 565.39 242.3 L 565.47 239.19 L 564.72 238.04 L 562.73 236.09 L 561.46 233.59 L 561.24 231.45 L 561.91 230.3 L 561.91 230.3 L 568.37 233.28 L 572.05 234.23 L 577.47 237.3 L 578.77 239.75 L 580.53 241.2 L 582.19 241.99 L 582.65 242.02 L 586.24 244.25 L 586.84 245.56 L 586.84 245.56 L 584.46 246.32 L 579.89 249.26 L 578.92 250.15 L 577.37 252.36 L 577.05 252.34 L 577.16 251.24 L 576.11 249.42 L 575.12 249.58 L 575.46 250.74 L 576.7 250.74 L 576.93 250.98 L 576.41 252.95 L 575.14 255.04 L 574.61 254.69 L 574.24 254.02 L 573.25 253.86 L 573.45 254.54 L 574.58 255.16 L 574.32 256.93 L 573.46 258.08 L 572.53 260.11 L 571.75 260.26 L 571.45 259.8 L 571.93 258.4 L 572.34 258.27 L 572.65 257.84 L 573.02 256.8 L 572.21 256.43 L 572.31 257.11 L 571.86 258.24 L 571.38 258.74 L 571.12 259.83 L 571.4 260.55 L 571.14 261.07 z"},{code:"SP",name:"São Paulo",gTransform:"matrix(1 0 0 1 89.6 122.15)",pathTransform:"translate(-395.6, -441.42)",d:"M 404.58 487.92 L 404.41999999999996 486.59000000000003 L 402.99999999999994 486.02000000000004 L 402.2699999999999 482.72 L 402.6699999999999 480.77000000000004 L 400.5299999999999 480.19000000000005 L 399.7699999999999 480.36000000000007 L 398.6699999999999 483.13000000000005 L 398.0099999999999 483.9800000000001 L 396.9499999999999 483.4500000000001 L 396.59999999999985 482.67000000000013 L 397.28999999999985 479.3700000000001 L 398.17999999999984 478.7100000000001 L 398.3199999999998 478.3100000000001 L 396.7099999999998 477.04000000000013 L 395.11999999999983 476.91000000000014 L 393.53999999999985 477.10000000000014 L 393.03999999999985 476.72000000000014 L 389.6299999999998 477.2500000000001 L 387.24999999999983 477.3700000000001 L 386.23999999999984 477.16000000000014 L 385.6399999999998 476.77000000000015 L 385.30999999999983 474.73000000000013 L 386.5899999999998 472.6100000000001 L 386.8399999999998 471.5600000000001 L 386.5899999999998 471.1200000000001 L 385.9899999999998 470.8200000000001 L 385.06999999999977 468.8500000000001 L 385.12999999999977 467.9600000000001 L 384.62999999999977 467.2800000000001 L 383.95999999999975 466.99000000000007 L 382.7499999999998 465.8500000000001 L 381.25999999999976 462.8400000000001 L 381.6199999999998 462.2900000000001 L 381.69999999999976 460.5300000000001 L 380.39999999999975 459.0100000000001 L 380.01999999999975 457.17000000000013 L 380.18999999999977 456.3600000000001 L 380.57999999999976 455.78000000000014 L 380.5599999999998 453.04000000000013 L 379.6699999999998 451.28000000000014 L 376.0799999999998 448.45000000000016 L 374.9499999999998 446.90000000000015 L 371.9799999999998 447.76000000000016 L 366.6699999999998 447.63000000000017 L 366.00999999999976 447.09000000000015 L 364.3599999999998 446.95000000000016 L 363.93999999999977 447.29000000000013 L 362.21999999999974 447.22000000000014 L 361.4999999999997 445.90000000000015 L 360.8699999999997 445.39000000000016 L 357.35999999999973 444.59000000000015 L 355.60999999999973 443.75000000000017 L 354.82999999999976 442.75000000000017 L 352.2499999999998 442.76000000000016 L 351.1799999999998 443.3000000000002 L 349.8599999999998 443.1700000000002 L 347.2199999999998 442.0800000000002 L 344.6899999999998 441.62000000000023 L 343.2099999999998 440.8300000000002 L 342.0399999999998 440.5400000000002 L 341.3099999999998 440.9100000000002 L 340.9699999999998 441.5100000000002 L 339.7599999999998 442.1300000000002 L 336.47999999999985 441.8400000000002 L 332.46999999999986 441.9500000000002 L 328.6399999999999 441.30000000000024 L 325.3899999999999 443.59000000000026 L 325.3899999999999 443.59000000000026 L 326.22999999999985 442.5100000000003 L 326.95999999999987 440.97000000000025 L 328.21999999999986 439.83000000000027 L 335.77999999999986 435.29000000000025 L 337.72999999999985 433.42000000000024 L 338.98999999999984 430.99000000000024 L 340.71999999999986 429.30000000000024 L 341.11999999999983 428.09000000000026 L 342.55999999999983 427.0600000000003 L 342.8399999999998 425.84000000000026 L 342.4899999999998 425.0000000000003 L 344.4899999999998 422.7400000000003 L 345.69999999999976 420.4000000000003 L 345.76999999999975 419.4600000000003 L 345.45999999999975 417.5300000000003 L 345.68999999999977 417.1400000000003 L 346.64999999999975 416.62000000000035 L 349.2499999999998 412.98000000000036 L 349.4099999999998 410.05000000000035 L 350.0299999999998 408.37000000000035 L 351.0399999999998 408.07000000000033 L 351.7699999999998 407.43000000000035 L 353.7599999999998 404.75000000000034 L 354.97999999999985 403.73000000000036 L 355.4499999999999 403.50000000000034 L 356.7599999999999 403.4600000000003 L 358.2599999999999 402.68000000000035 L 358.53999999999985 402.28000000000037 L 358.9399999999998 399.8200000000004 L 358.9399999999998 399.8200000000004 L 360.15999999999985 398.6900000000004 L 362.30999999999983 397.5800000000004 L 364.22999999999985 397.2100000000004 L 365.65999999999985 395.5200000000004 L 367.15999999999985 394.91000000000037 L 367.90999999999985 395.05000000000035 L 369.6399999999999 396.60000000000036 L 372.1899999999999 396.68000000000035 L 376.4799999999999 397.6400000000003 L 378.1499999999999 397.2800000000003 L 379.7699999999999 397.50000000000034 L 381.7699999999999 396.91000000000037 L 383.94999999999993 398.3300000000004 L 385.61999999999995 399.1200000000004 L 385.48999999999995 400.0400000000004 L 385.81999999999994 401.46000000000043 L 387.0299999999999 403.5500000000004 L 387.6599999999999 403.5800000000004 L 388.19999999999993 403.2600000000004 L 388.86999999999995 402.3200000000004 L 389.28 401.1900000000004 L 389.53999999999996 401.0000000000004 L 390.09 401.0500000000004 L 390.45 401.4400000000004 L 390.7 402.4000000000004 L 390.71 405.18000000000035 L 391.90999999999997 405.7100000000003 L 392.32 405.26000000000033 L 392.05 402.7200000000003 L 392.54 401.5300000000003 L 392.99 401.0500000000003 L 401.17 400.3800000000003 L 402.18 399.1300000000003 L 403.68 400.59000000000026 L 404.8 401.02000000000027 L 407.58 400.33000000000027 L 408.02 399.34000000000026 L 407.82 398.8800000000003 L 408.13 398.27000000000027 L 410.51 398.16000000000025 L 412.17 398.9400000000002 L 413.02000000000004 398.30000000000024 L 414.33000000000004 398.0100000000002 L 417.59000000000003 401.36000000000024 L 417.79 402.40000000000026 L 417.22 403.41000000000025 L 416.93 405.78000000000026 L 417.51 406.39000000000027 L 419.4 407.60000000000025 L 419.79999999999995 409.15000000000026 L 419.73999999999995 409.71000000000026 L 418.21999999999997 411.74000000000024 L 418.03999999999996 413.68000000000023 L 418.83 414.42000000000024 L 419.14 415.03000000000026 L 419.51 417.24000000000024 L 420.81 419.04000000000025 L 421.64 421.03000000000026 L 421.61 421.8800000000003 L 423.22 421.83000000000027 L 424 421.52000000000027 L 424.28 421.16000000000025 L 425.28 421.11000000000024 L 428.97999999999996 422.43000000000023 L 429.21 422.80000000000024 L 429.15999999999997 424.0700000000002 L 428.46 426.2500000000002 L 426.59999999999997 428.97000000000025 L 426.85999999999996 431.91000000000025 L 426.66999999999996 435.36000000000024 L 426.14 436.92000000000024 L 426.86 438.52000000000027 L 428.64 439.7600000000003 L 430.45 440.59000000000026 L 430.96 442.3100000000003 L 429.75 443.0100000000003 L 431.77 446.3200000000003 L 432.9 446.5700000000003 L 434.90999999999997 446.33000000000027 L 435.09 446.86000000000024 L 438.71 445.86000000000024 L 439.27 446.28000000000026 L 440.58 445.96000000000026 L 441.33 444.98000000000025 L 441.38 444.14000000000027 L 441.14 443.90000000000026 L 441.31 441.60000000000025 L 442.5 441.27000000000027 L 442.59 441.6200000000003 L 442.23999999999995 442.1100000000003 L 442.24999999999994 442.5900000000003 L 444.5899999999999 442.6700000000003 L 446.9799999999999 442.4200000000003 L 448.7699999999999 441.7500000000003 L 449.99999999999994 440.5100000000003 L 451.92999999999995 439.4900000000003 L 454.13999999999993 439.27000000000027 L 455.37999999999994 438.54000000000025 L 455.37999999999994 438.54000000000025 L 456.6499999999999 439.08000000000027 L 457.2099999999999 440.2500000000003 L 458.43999999999994 441.84000000000026 L 460.2099999999999 442.23000000000025 L 463.3599999999999 441.7000000000003 L 465.0599999999999 441.71000000000026 L 465.8099999999999 443.35000000000025 L 464.1599999999999 445.5000000000002 L 462.6599999999999 446.2100000000002 L 459.88999999999993 446.5700000000002 L 459.38999999999993 446.42000000000024 L 457.0399999999999 447.43000000000023 L 455.94999999999993 448.5800000000002 L 454.85999999999996 452.0800000000002 L 454.90999999999997 452.49000000000024 L 456.53999999999996 454.22000000000025 L 457.02 454.48000000000025 L 457.02 454.48000000000025 L 456.96 454.68000000000023 L 455.27 455.10000000000025 L 454.21 454.28000000000026 L 452.72999999999996 455.39000000000027 L 452.29999999999995 456.04000000000025 L 452.56999999999994 456.2600000000003 L 451.80999999999995 456.90000000000026 L 448.5899999999999 458.4500000000003 L 446.3399999999999 459.15000000000026 L 446.05999999999995 459.59000000000026 L 446.09999999999997 460.55000000000024 L 446.59999999999997 462.10000000000025 L 446.28 462.52000000000027 L 444.88 462.78000000000026 L 444.18 462.14000000000027 L 442.84000000000003 461.85000000000025 L 439.72 461.35000000000025 L 438.86 461.5000000000002 L 437.54 461.8400000000002 L 435.81 462.6600000000002 L 435.31 463.1700000000002 L 434.1 465.32000000000016 L 432.79 465.89000000000016 L 432.29 465.77000000000015 L 432.87 465.3000000000001 L 432.39 464.0800000000001 L 431.21999999999997 463.2300000000001 L 430.39 464.4600000000001 L 430.65 465.2100000000001 L 430.34999999999997 465.8200000000001 L 422.72999999999996 470.0600000000001 L 421.78 470.8800000000001 L 421.46999999999997 472.04000000000013 L 418.2 475.04000000000013 L 414.95 476.9900000000001 L 413.03 477.5200000000001 L 408.53 480.7300000000001 L 406.2 482.69000000000005 L 405.53 482.77000000000004 L 405.09 483.39000000000004 L 405.98999999999995 483.82000000000005 L 406.65 483.88000000000005 L 407.58 483.52000000000004 L 407.58 484.28000000000003 L 406.96 485.59000000000003 L 405.64 486.44000000000005 L 404.58 487.92 z M 448.89 464.91 L 447.34999999999997 464.26000000000005 L 446.18999999999994 464.44000000000005 L 445.69999999999993 464.06000000000006 L 445.79999999999995 463.2800000000001 L 446.74999999999994 462.6300000000001 L 447.8399999999999 460.7800000000001 L 448.55999999999995 461.0300000000001 L 449.21999999999997 461.68000000000006 L 449.34999999999997 464.5900000000001 L 448.89 464.91 z"},{code:"TO",name:"Tocantins",gTransform:"matrix(1 0 0 1 95.98 -93.17)",pathTransform:"translate(-401.98, -226.09)",d:"M 433.35 281.82 L 427.99 283.24 L 426.25 284.58 L 423.69 285.68 L 422.14 285.68 L 417.61 286.68 L 415.09 288.76 L 413.31 289.66 L 412.85 289.42 L 411.34 286.8 L 410.79 286.77 L 410.28 290.07 L 409.59 290.15 L 406.24 289.47 L 403.11 288 L 403.67 286.44 L 403.45 285.7 L 398.92 286.23 L 396.16 285.89 L 395.6 286.43 L 395.3 287.43 L 394.55 288.18 L 393.41 288.13 L 392.8 285.03 L 391.69 281.32 L 390.65 279.44 L 389.5 278.13 L 388.32 279.1 L 386.85 281.49 L 385.22 287.43 L 384.59 287.66 L 380.52 286.23 L 377.43 284.52 L 373.5 284.12 L 371.3 283.09 L 368.9 282.69 L 369.42 280.35 L 370.64 278.47 L 370.67 276.76 L 370.11 277.06 L 368.3 279.15 L 367.64 280.38 L 367.44 282.26 L 367.1 282.71 L 367.1 282.71 L 366.3 282.69 L 365.34 282.18 L 364.36 278.84 L 365.1 276.08 L 364.66 273.03 L 364.14 272.45 L 364.13 270.88 L 364.6 267.57 L 363.5 265.32 L 363.55 264.82 L 364.37 263.93 L 364.53 263.06 L 363.14 261.72 L 363.08 260.86 L 364.96 254.87 L 365 251.92 L 365.54 248.95 L 367.48 243.66 L 367.85 243.39 L 368.28 242.54 L 368.72 239.4 L 369.82 238.15 L 370.38 236.26 L 371.03 235.24 L 371.03 235.24 L 372.65 231.55 L 373.78 227.1 L 374.93 225.52 L 376.12 224.42 L 377.33 222.74 L 378.36 220.82 L 379.73 219.9 L 380.78 219.74 L 381.51 218.89 L 382.45 217.35 L 382.63 216.36 L 384.33 213.12 L 385.42 212.32 L 387.18 207.17 L 387.84 203.13 L 387.69 202.83 L 386.95 202.51 L 385.28 200.77 L 384.68 199.82 L 384.52 198.94 L 384.66 198.37 L 386.07 196.68 L 387.36 194.58 L 387.3 191.91 L 386.87 189.73 L 387.06 189.38 L 389.53 187.6 L 392.94 186.46 L 395.44 185.25 L 395.68 184.75 L 395.53 183.24 L 396.39 181.97 L 397.9 180.63 L 399.19 180.48 L 399.38 179.14 L 399.09 177.94 L 399.34 177.48 L 400.8 177.02 L 401.44 176.54 L 402.37 173.79 L 401.35 172.45 L 401.26 171.05 L 401.55 170.77 L 402.52 170.69 L 403.24 170.32 L 403.61 169.66 L 403.64 169.02 L 402.38 167.85 L 401.51 167.71 L 401.12 167.4 L 400.1 165.74 L 398.81 165.62 L 396.94 165.87 L 394.65 165.06 L 394.65 165.06 L 395.18 164.42 L 397.8 162.57 L 399.76 162.04 L 400.63 162.09 L 403.41 163.61 L 404.81 163.69 L 405.76 163.17 L 407.5 163.46 L 408.09 164.15 L 408.17 165.18 L 408.45 165.5 L 409.67 165.53 L 413.07 166.96 L 413.91 167.99 L 414.38 171.49 L 415.02 172.99 L 414.81 176.71 L 415.04 177.79 L 415.71 178.92 L 415.7 179.36 L 413.93 185.51 L 413.62 187.88 L 413.9 188.88 L 413.65 190.47 L 411.9 192.51 L 410.14 193.18 L 409.96 193.89 L 411.9 195.21 L 412.32 194.94 L 413.69 195.18 L 413.94 195.53 L 414.05 196.41 L 413.43 197.6 L 414.28 199.04 L 415.16 198.97 L 418.16 203.13 L 419.07 203.98 L 421.35 207 L 423.49 205.66 L 427.76 204.72 L 429.56 205.94 L 429.64 207.69 L 429 210.94 L 429.39 212.29 L 426 212.64 L 424.66 213.18 L 424.09 213.73 L 423.41 215.16 L 422.68 217.84 L 423.05 219.14 L 420.42 221.69 L 420.16 222.39 L 420.36 222.81 L 422.44 223.1 L 423.38 223.79 L 424.12 225.38 L 424.18 227.04 L 424.8 228.08 L 428.68 230.03 L 428.77 230.56 L 427.13 232.37 L 427.26 234.02 L 429.4 235.64 L 430.39 238.51 L 431.73 240.51 L 432.44 240.69 L 434.22 240.48 L 435.22 240.78 L 436.04 241.22 L 436.65 242.04 L 437.93 242.7 L 437.93 242.7 L 440.87 242.91 L 440.87 242.91 L 440.18 243.56 L 439.96 244.54 L 439.4 245.01 L 435.58 247.03 L 432.37 249.65 L 432.18 250.02 L 433.47 251.82 L 433.11 252.21 L 432.1 252.48 L 431.2 253.09 L 429.68 256.58 L 428.67 257.3 L 428.17 258.46 L 428.4 259.38 L 430.26 261.33 L 433.85 262 L 435.72 262.99 L 435.77 263.75 L 435.21 264.2 L 433.17 265.01 L 432.74 265.97 L 432.83 266.47 L 433.18 266.8 L 434.21 266.62 L 435.13 266.91 L 435.71 267.42 L 436 268.06 L 435.04 268.77 L 433.89 269.19 L 431.94 270.86 L 431.75 271.71 L 431.7 274.63 L 432.05 275.88 L 432.99 276.54 L 434.04 276.78 L 434.45 277.03 L 434.62 277.45 L 434.67 278.51 L 433.31 280.89 z"}];function SI({selected:t,onSelect:e}){const[s,n]=k.useState(yI),r=o=>{if(o)try{const a=o.getBBox();if(!a.width||!a.height)return;const l=Math.max(a.width,a.height)*.04,c=`${a.x-l} ${a.y-l} ${a.width+l*2} ${a.height+l*2}`;n(d=>d===c?d:c)}catch{}};return i.jsx("svg",{ref:r,viewBox:s,role:"group","aria-label":"Map of Brazil — select a state",className:"h-72 w-full rounded-md border border-border/60 bg-muted/20",children:i.jsx("g",{transform:LI,children:yu.map(o=>{const a=o.code===t;return i.jsx("g",{transform:o.gTransform,children:i.jsx("path",{d:o.d,transform:o.pathTransform,role:"button",tabIndex:0,"aria-label":o.name,"aria-pressed":a,onClick:()=>e(o.code),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),e(o.code))},className:te("cursor-pointer stroke-background outline-none transition-colors [stroke-width:1] [vector-effect:non-scaling-stroke]","hover:fill-primary/50 focus-visible:fill-primary/50",a?"fill-primary":"fill-muted-foreground/40")})},o.code)})})})}const wI=[{code:"AF",name:"Afghanistan"},{code:"AX",name:"Åland Islands"},{code:"AL",name:"Albania"},{code:"DZ",name:"Algeria"},{code:"AS",name:"American Samoa"},{code:"AD",name:"Andorra"},{code:"AO",name:"Angola"},{code:"AI",name:"Anguilla"},{code:"AQ",name:"Antarctica"},{code:"AG",name:"Antigua & Barbuda"},{code:"AR",name:"Argentina"},{code:"AM",name:"Armenia"},{code:"AW",name:"Aruba"},{code:"AU",name:"Australia"},{code:"AT",name:"Austria"},{code:"AZ",name:"Azerbaijan"},{code:"BS",name:"Bahamas"},{code:"BH",name:"Bahrain"},{code:"BD",name:"Bangladesh"},{code:"BB",name:"Barbados"},{code:"BY",name:"Belarus"},{code:"BE",name:"Belgium"},{code:"BZ",name:"Belize"},{code:"BJ",name:"Benin"},{code:"BM",name:"Bermuda"},{code:"BT",name:"Bhutan"},{code:"BO",name:"Bolivia"},{code:"BA",name:"Bosnia & Herzegovina"},{code:"BW",name:"Botswana"},{code:"BV",name:"Bouvet Island"},{code:"BR",name:"Brazil"},{code:"VG",name:"British Virgin Islands"},{code:"BN",name:"Brunei"},{code:"BG",name:"Bulgaria"},{code:"BF",name:"Burkina Faso"},{code:"BI",name:"Burundi"},{code:"KH",name:"Cambodia"},{code:"CM",name:"Cameroon"},{code:"CA",name:"Canada"},{code:"CV",name:"Cape Verde"},{code:"BQ",name:"Caribbean Netherlands"},{code:"KY",name:"Cayman Islands"},{code:"CF",name:"Central African Republic"},{code:"TD",name:"Chad"},{code:"IO",name:"Chagos Archipelago"},{code:"CL",name:"Chile"},{code:"CN",name:"China mainland"},{code:"CX",name:"Christmas Island"},{code:"CC",name:"Cocos (Keeling) Islands"},{code:"CO",name:"Colombia"},{code:"KM",name:"Comoros"},{code:"CG",name:"Congo - Brazzaville"},{code:"CD",name:"Congo - Kinshasa"},{code:"CK",name:"Cook Islands"},{code:"CR",name:"Costa Rica"},{code:"CI",name:"Côte d’Ivoire"},{code:"HR",name:"Croatia"},{code:"CU",name:"Cuba"},{code:"CW",name:"Curaçao"},{code:"CY",name:"Cyprus"},{code:"CZ",name:"Czechia"},{code:"DK",name:"Denmark"},{code:"DJ",name:"Djibouti"},{code:"DM",name:"Dominica"},{code:"DO",name:"Dominican Republic"},{code:"EC",name:"Ecuador"},{code:"EG",name:"Egypt"},{code:"SV",name:"El Salvador"},{code:"GQ",name:"Equatorial Guinea"},{code:"ER",name:"Eritrea"},{code:"EE",name:"Estonia"},{code:"SZ",name:"Eswatini"},{code:"ET",name:"Ethiopia"},{code:"FK",name:"Falkland Islands"},{code:"FO",name:"Faroe Islands"},{code:"FJ",name:"Fiji"},{code:"FI",name:"Finland"},{code:"FR",name:"France"},{code:"GF",name:"French Guiana"},{code:"PF",name:"French Polynesia"},{code:"TF",name:"French Southern Territories"},{code:"GA",name:"Gabon"},{code:"GM",name:"Gambia"},{code:"GE",name:"Georgia"},{code:"DE",name:"Germany"},{code:"GH",name:"Ghana"},{code:"GI",name:"Gibraltar"},{code:"GR",name:"Greece"},{code:"GL",name:"Greenland"},{code:"GD",name:"Grenada"},{code:"GP",name:"Guadeloupe"},{code:"GU",name:"Guam"},{code:"GT",name:"Guatemala"},{code:"GG",name:"Guernsey"},{code:"GN",name:"Guinea"},{code:"GW",name:"Guinea-Bissau"},{code:"GY",name:"Guyana"},{code:"HT",name:"Haiti"},{code:"HM",name:"Heard & McDonald Islands"},{code:"HN",name:"Honduras"},{code:"HK",name:"Hong Kong"},{code:"HU",name:"Hungary"},{code:"IS",name:"Iceland"},{code:"IN",name:"India"},{code:"ID",name:"Indonesia"},{code:"IR",name:"Iran"},{code:"IQ",name:"Iraq"},{code:"IE",name:"Ireland"},{code:"IM",name:"Isle of Man"},{code:"IL",name:"Israel"},{code:"IT",name:"Italy"},{code:"JM",name:"Jamaica"},{code:"JP",name:"Japan"},{code:"JE",name:"Jersey"},{code:"JO",name:"Jordan"},{code:"KZ",name:"Kazakhstan"},{code:"KE",name:"Kenya"},{code:"KI",name:"Kiribati"},{code:"KW",name:"Kuwait"},{code:"KG",name:"Kyrgyzstan"},{code:"LA",name:"Laos"},{code:"LV",name:"Latvia"},{code:"LB",name:"Lebanon"},{code:"LS",name:"Lesotho"},{code:"LR",name:"Liberia"},{code:"LY",name:"Libya"},{code:"LI",name:"Liechtenstein"},{code:"LT",name:"Lithuania"},{code:"LU",name:"Luxembourg"},{code:"MO",name:"Macao"},{code:"MG",name:"Madagascar"},{code:"MW",name:"Malawi"},{code:"MY",name:"Malaysia"},{code:"MV",name:"Maldives"},{code:"ML",name:"Mali"},{code:"MT",name:"Malta"},{code:"MH",name:"Marshall Islands"},{code:"MQ",name:"Martinique"},{code:"MR",name:"Mauritania"},{code:"MU",name:"Mauritius"},{code:"YT",name:"Mayotte"},{code:"MX",name:"Mexico"},{code:"FM",name:"Micronesia"},{code:"MD",name:"Moldova"},{code:"MC",name:"Monaco"},{code:"MN",name:"Mongolia"},{code:"ME",name:"Montenegro"},{code:"MS",name:"Montserrat"},{code:"MA",name:"Morocco"},{code:"MZ",name:"Mozambique"},{code:"MM",name:"Myanmar (Burma)"},{code:"NA",name:"Namibia"},{code:"NR",name:"Nauru"},{code:"NP",name:"Nepal"},{code:"NL",name:"Netherlands"},{code:"NC",name:"New Caledonia"},{code:"NZ",name:"New Zealand"},{code:"NI",name:"Nicaragua"},{code:"NE",name:"Niger"},{code:"NG",name:"Nigeria"},{code:"NU",name:"Niue"},{code:"NF",name:"Norfolk Island"},{code:"KP",name:"North Korea"},{code:"MK",name:"North Macedonia"},{code:"MP",name:"Northern Mariana Islands"},{code:"NO",name:"Norway"},{code:"OM",name:"Oman"},{code:"PK",name:"Pakistan"},{code:"PW",name:"Palau"},{code:"PS",name:"Palestinian Territories"},{code:"PA",name:"Panama"},{code:"PG",name:"Papua New Guinea"},{code:"PY",name:"Paraguay"},{code:"PE",name:"Peru"},{code:"PH",name:"Philippines"},{code:"PN",name:"Pitcairn Islands"},{code:"PL",name:"Poland"},{code:"PT",name:"Portugal"},{code:"PR",name:"Puerto Rico"},{code:"QA",name:"Qatar"},{code:"RE",name:"Réunion"},{code:"RO",name:"Romania"},{code:"RU",name:"Russia"},{code:"RW",name:"Rwanda"},{code:"WS",name:"Samoa"},{code:"SM",name:"San Marino"},{code:"ST",name:"São Tomé & Príncipe"},{code:"SA",name:"Saudi Arabia"},{code:"SN",name:"Senegal"},{code:"RS",name:"Serbia"},{code:"SC",name:"Seychelles"},{code:"SL",name:"Sierra Leone"},{code:"SG",name:"Singapore"},{code:"SX",name:"Sint Maarten"},{code:"SK",name:"Slovakia"},{code:"SI",name:"Slovenia"},{code:"GS",name:"So. Georgia & So. Sandwich Isl."},{code:"SB",name:"Solomon Islands"},{code:"SO",name:"Somalia"},{code:"ZA",name:"South Africa"},{code:"KR",name:"South Korea"},{code:"SS",name:"South Sudan"},{code:"ES",name:"Spain"},{code:"LK",name:"Sri Lanka"},{code:"BL",name:"St. Barthélemy"},{code:"SH",name:"St. Helena"},{code:"KN",name:"St. Kitts & Nevis"},{code:"LC",name:"St. Lucia"},{code:"MF",name:"St. Martin"},{code:"PM",name:"St. Pierre & Miquelon"},{code:"VC",name:"St. Vincent & Grenadines"},{code:"SD",name:"Sudan"},{code:"SR",name:"Suriname"},{code:"SJ",name:"Svalbard & Jan Mayen"},{code:"SE",name:"Sweden"},{code:"CH",name:"Switzerland"},{code:"SY",name:"Syria"},{code:"TW",name:"Taiwan"},{code:"TJ",name:"Tajikistan"},{code:"TZ",name:"Tanzania"},{code:"TH",name:"Thailand"},{code:"TL",name:"Timor-Leste"},{code:"TG",name:"Togo"},{code:"TK",name:"Tokelau"},{code:"TO",name:"Tonga"},{code:"T1",name:"Tor network (Cloudflare)"},{code:"TT",name:"Trinidad & Tobago"},{code:"TN",name:"Tunisia"},{code:"TR",name:"Türkiye"},{code:"TM",name:"Turkmenistan"},{code:"TC",name:"Turks & Caicos Islands"},{code:"TV",name:"Tuvalu"},{code:"UM",name:"U.S. Outlying Islands"},{code:"VI",name:"U.S. Virgin Islands"},{code:"UG",name:"Uganda"},{code:"UA",name:"Ukraine"},{code:"AE",name:"United Arab Emirates"},{code:"GB",name:"United Kingdom"},{code:"US",name:"United States"},{code:"XX",name:"Unknown (Cloudflare could not determine)"},{code:"UY",name:"Uruguay"},{code:"UZ",name:"Uzbekistan"},{code:"VU",name:"Vanuatu"},{code:"VA",name:"Vatican City"},{code:"VE",name:"Venezuela"},{code:"VN",name:"Vietnam"},{code:"WF",name:"Wallis & Futuna"},{code:"EH",name:"Western Sahara"},{code:"YE",name:"Yemen"},{code:"ZM",name:"Zambia"},{code:"ZW",name:"Zimbabwe"}],jI="BR";function CI(t){if(!t)return!1;const e=Object.keys(t).sort();return e.length===3&&e[0]==="city"&&e[1]==="country"&&e[2]==="regionCode"}function kI(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{city:typeof e.city=="string"?e.city:"",regionCode:typeof e.regionCode=="string"?e.regionCode:"",country:typeof e.country=="string"?e.country:""}}function VI(t,e){const s={...t,...e},n={};for(const r of["city","regionCode","country"])s[r]&&(n[r]=s[r]);return n}function Mf(t){const e=M.c(37),{id:s,options:n,value:r,placeholder:o,emptyMessage:a,onChange:l}=t,[c,d]=k.useState(!1);let h;if(e[0]!==n||e[1]!==r){let S;e[3]!==r?(S=j=>j.value===r,e[3]=r,e[4]=S):S=e[4],h=n.find(S),e[0]=n,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;e[5]!==o||e[6]!==u?(f=u?i.jsx("span",{className:"truncate",children:u.label}):i.jsx("span",{className:"text-muted-foreground",children:o}),e[5]=o,e[6]=u,e[7]=f):f=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(g9,{className:"size-4 shrink-0 opacity-50"}),e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==c||e[11]!==f?(p=i.jsx(As,{asChild:!0,children:i.jsxs(re,{id:s,variant:"outline",role:"combobox","aria-expanded":c,className:"h-10 w-full justify-between font-normal",children:[f,m]})}),e[9]=s,e[10]=c,e[11]=f,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g={width:"var(--radix-popover-trigger-width)"},e[13]=g):g=e[13];let x;e[14]!==o?(x=i.jsx(Ii,{placeholder:o,className:"h-9"}),e[14]=o,e[15]=x):x=e[15];let v;e[16]!==a?(v=i.jsx(Jn,{children:a}),e[16]=a,e[17]=v):v=e[17];let _;if(e[18]!==l||e[19]!==n||e[20]!==r){let S;e[22]!==l||e[23]!==r?(S=j=>i.jsxs(Cs,{value:`${j.label} ${j.value}`,onSelect:()=>{l(j.value===r?"":j.value),d(!1)},children:[i.jsx("span",{className:"truncate",children:j.label}),i.jsx(Ot,{className:te("ml-auto size-4 shrink-0",r===j.value?"opacity-100":"opacity-0")})]},j.value),e[22]=l,e[23]=r,e[24]=S):S=e[24],_=n.map(S),e[18]=l,e[19]=n,e[20]=r,e[21]=_}else _=e[21];let b;e[25]!==_?(b=i.jsx(Is,{children:_}),e[25]=_,e[26]=b):b=e[26];let y;e[27]!==v||e[28]!==b?(y=i.jsxs(Di,{children:[v,b]}),e[27]=v,e[28]=b,e[29]=y):y=e[29];let L;e[30]!==y||e[31]!==x?(L=i.jsx(Ts,{className:"p-0",style:g,children:i.jsxs(Cr,{children:[x,y]})}),e[30]=y,e[31]=x,e[32]=L):L=e[32];let w;return e[33]!==c||e[34]!==L||e[35]!==p?(w=i.jsxs(Ns,{open:c,onOpenChange:d,children:[p,L]}),e[33]=c,e[34]=L,e[35]=p,e[36]=w):w=e[36],w}const NI=wI.map(t=>({value:t.code,label:`${t.name} (${t.code})`})),AI=yu.map(t=>({value:t.code,label:`${t.name} (${t.code})`}));function v4(t){const e=M.c(49),{schema:s,value:n,onChange:r,path:o}=t;let a;e[0]!==n?(a=kI(n),e[0]=n,e[1]=a):a=e[1];const l=a,{city:c,regionCode:d,country:h}=l;let u;e[2]!==s.properties?(u=s.properties??{},e[2]=s.properties,e[3]=u):u=e[3];const f=u,m=f.country?.title??"Country",p=f.regionCode?.title??"Region",g=f.city?.title??"City";let x;e[4]!==l||e[5]!==r?(x=O=>{r(VI(l,O))},e[4]=l,e[5]=r,e[6]=x):x=e[6];const v=x,_=h===jI;let b;e[7]!==d?(b=yu.find(O=>O.code===d),e[7]=d,e[8]=b):b=e[8];const y=b,L=`${o}.country`,w=s.title??"Location";let S;e[9]!==L||e[10]!==w?(S=i.jsx(rt,{htmlFor:L,children:w}),e[9]=L,e[10]=w,e[11]=S):S=e[11];let j;e[12]!==s.description?(j=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[12]=s.description,e[13]=j):j=e[13];let C;e[14]!==S||e[15]!==j?(C=i.jsxs("div",{className:"space-y-0.5",children:[S,j]}),e[14]=S,e[15]=j,e[16]=C):C=e[16];const V=`${o}.country`;let N;e[17]!==m||e[18]!==V?(N=i.jsx(rt,{htmlFor:V,className:"text-xs",children:m}),e[17]=m,e[18]=V,e[19]=N):N=e[19];const T=`${o}.country`;let A;e[20]!==v?(A=O=>v({country:O,regionCode:"",city:""}),e[20]=v,e[21]=A):A=e[21];let E;e[22]!==h||e[23]!==T||e[24]!==A?(E=i.jsx(Mf,{id:T,options:NI,value:h,placeholder:"Select a country…",emptyMessage:"No country found.",onChange:A}),e[22]=h,e[23]=T,e[24]=A,e[25]=E):E=e[25];let R;e[26]!==N||e[27]!==E?(R=i.jsxs("div",{className:"space-y-1.5",children:[N,E]}),e[26]=N,e[27]=E,e[28]=R):R=e[28];let D;e[29]!==h||e[30]!==v||e[31]!==_||e[32]!==o||e[33]!==d||e[34]!==p?(D=h&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(rt,{htmlFor:`${o}.regionCode`,className:"text-xs",children:p}),_?i.jsxs("div",{className:"space-y-2",children:[i.jsx(SI,{selected:d,onSelect:O=>v({regionCode:O===d?"":O,city:""})}),i.jsx(Mf,{id:`${o}.regionCode`,options:AI,value:d,placeholder:"Select a state…",emptyMessage:"No state found.",onChange:O=>v({regionCode:O,city:""})})]}):i.jsxs(i.Fragment,{children:[i.jsx(tt,{id:`${o}.regionCode`,type:"text",value:d,placeholder:"e.g. SP",onChange:O=>v({regionCode:O.target.value})}),i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:"ISO 3166-2 subdivision code from cf-region-code."})]})]}),e[29]=h,e[30]=v,e[31]=_,e[32]=o,e[33]=d,e[34]=p,e[35]=D):D=e[35];let P;e[36]!==c||e[37]!==g||e[38]!==h||e[39]!==v||e[40]!==_||e[41]!==o||e[42]!==y?(P=h&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx(rt,{htmlFor:`${o}.city`,className:"text-xs",children:g}),i.jsx(tt,{id:`${o}.city`,type:"text",value:c,placeholder:_&&y?`e.g. a city in ${y.name}`:"e.g. Sao Paulo",onChange:O=>v({city:O.target.value})}),i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:"Matched exactly against cf-ipcity."})]}),e[36]=c,e[37]=g,e[38]=h,e[39]=v,e[40]=_,e[41]=o,e[42]=y,e[43]=P):P=e[43];let I;return e[44]!==R||e[45]!==D||e[46]!==P||e[47]!==C?(I=i.jsxs("div",{className:"space-y-4",children:[C,R,D,P]}),e[44]=R,e[45]=D,e[46]=P,e[47]=C,e[48]=I):I=e[48],I}function TI(t){const e=t.schema;if(!e?.properties)return null;const s=new Set(Object.keys(t.discriminators??{}));if(s.size===0)return e;const n={};for(const[r,o]of Object.entries(e.properties))s.has(r)||(n[r]=o);return{...e,properties:n}}function EI(t){const e=M.c(46),{schema:s,value:n,onChange:r,path:o,label:a}=t;let l,c;e[0]!==s.inlineUnionBranches||e[1]!==n?(l=s.inlineUnionBranches??[],c=bI(n,l.map(PI)),e[0]=s.inlineUnionBranches,e[1]=n,e[2]=l,e[3]=c):(l=e[2],c=e[3]);const d=c,[h,u]=k.useState(d),[f,m]=k.useState(d);f!==d&&(m(d),u(d));const p=Math.min(h,l.length-1),g=l[p];let x;e[4]!==l||e[5]!==r?(x=P=>{const I=Number(P);u(I),r({...l[I]?.discriminators??{}})},e[4]=l,e[5]=r,e[6]=x):x=e[6];const v=x;if(l.length===0)return null;let _;e[7]!==g?(_=g?TI(g):null,e[7]=g,e[8]=_):_=e[8];const b=_;let y;if(e[9]!==g?.schema?.properties||e[10]!==n){let P;e[12]!==g?.schema?.properties?(P=g?.schema?.properties??{},e[12]=g?.schema?.properties,e[13]=P):P=e[13],y=_I(n,Object.keys(P)),e[9]=g?.schema?.properties,e[10]=n,e[11]=y}else y=e[11];const L=y;let w;e[14]!==a||e[15]!==o?(w=i.jsx(rt,{htmlFor:o,children:a}),e[14]=a,e[15]=o,e[16]=w):w=e[16];const S=String(p);let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(rs,{placeholder:"Select..."}),e[17]=j):j=e[17];let C;e[18]!==o?(C=i.jsx(Xt,{id:o,children:j}),e[18]=o,e[19]=C):C=e[19];let V;e[20]!==l?(V=l.map(RI),e[20]=l,e[21]=V):V=e[21];let N;e[22]!==V?(N=i.jsx(Yt,{children:V}),e[22]=V,e[23]=N):N=e[23];let T;e[24]!==v||e[25]!==S||e[26]!==C||e[27]!==N?(T=i.jsxs(Jt,{value:S,onValueChange:v,children:[C,N]}),e[24]=v,e[25]=S,e[26]=C,e[27]=N,e[28]=T):T=e[28];let A;e[29]!==s.description?(A=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[29]=s.description,e[30]=A):A=e[30];let E;e[31]!==T||e[32]!==A||e[33]!==w?(E=i.jsxs("div",{className:"space-y-1.5",children:[w,T,A]}),e[31]=T,e[32]=A,e[33]=w,e[34]=E):E=e[34];let R;e[35]!==g||e[36]!==b||e[37]!==r||e[38]!==o||e[39]!==L||e[40]!==t||e[41]!==n?(R=g&&(CI(g.schema?.properties)?i.jsx(v4,{...t,schema:g.schema,onChange:P=>r({...L,...P,...g.discriminators??{}})}):b?i.jsx(Pn,{schema:b,value:n,onChange:P=>r({...P,...g.discriminators??{}}),basePath:o,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox,previewBaseUrl:t.previewBaseUrl,onAddSectionItem:t.onAddSectionItem,onRequestAddSection:t.onRequestAddSection}):null),e[35]=g,e[36]=b,e[37]=r,e[38]=o,e[39]=L,e[40]=t,e[41]=n,e[42]=R):R=e[42];let D;return e[43]!==E||e[44]!==R?(D=i.jsxs("div",{className:"space-y-3",children:[E,R]}),e[43]=E,e[44]=R,e[45]=D):D=e[45],D}function RI(t,e){return i.jsx(pt,{value:String(e),children:t.title},t.title)}function PI(t){return{discriminators:t.discriminators,propertyKeys:Object.keys(t.schema?.properties??{})}}const II={lat:-21.9,lng:-41.42},X0=1e5;let Ea=null;function DI(t){return Ea||(Ea=new Promise((e,s)=>{if(typeof window>"u"){s(new Error("Google Maps requires a browser environment"));return}const n=window;if(n.google?.maps){e(n.google.maps);return}const r=()=>{const l=window.google?.maps;l?e(l):s(new Error("Google Maps script loaded without google.maps"))},o=document.querySelector("script[data-google-maps-loader]");if(o){o.addEventListener("load",r),o.addEventListener("error",()=>s(new Error("Failed to load Google Maps")));return}const a=document.createElement("script");a.src=`https://maps.googleapis.com/maps/api/js?key=${t}&v=weekly&libraries=maps`,a.async=!0,a.defer=!0,a.dataset.googleMapsLoader="true",a.addEventListener("load",r),a.addEventListener("error",()=>s(new Error("Failed to load Google Maps"))),document.head.appendChild(a)}),Ea)}function OI(t){if(typeof t!="string"||!t)return null;const e=t.split(",").map(Number),[s,n,r]=e;return!Number.isFinite(s)||!Number.isFinite(n)?null:{lat:s,lng:n,radius:Number.isFinite(r)?r:X0}}function MI({schema:t,value:e,onChange:s,path:n,label:r}){const o=X1().googleMapsApiKey,a=k.useRef(s);a.current=s;const l=k.useRef(OI(e)),[c,d]=k.useState(null),h=k.useRef(null),u=f=>{if(!f||!o)return;const m={disposed:!1,circle:null,listeners:[]};return DI(o).then(p=>{if(m.disposed)return;const g=l.current,x=g?{lat:g.lat,lng:g.lng}:II,v=g?.radius??X0,_=new p.Map(f,{center:x,zoom:v?Math.round(Math.log2(768e4/v))+1:4,draggable:!0,streetViewControl:!1,mapTypeControl:!1}),b=new p.Circle({strokeColor:"#2E6ED9",strokeOpacity:.8,strokeWeight:2,fillColor:"#2E6ED9",fillOpacity:.35,editable:!0,draggable:!0,map:_,center:x,radius:v});m.circle=b;const y=()=>{const w=b.getCenter(),S=b.getRadius();w&&a.current(`${w.lat()},${w.lng()},${S}`)},L=w=>{w&&m.listeners.push(w)};L(_.addListener("click",w=>{w.latLng&&(b.setCenter({lat:w.latLng.lat(),lng:w.latLng.lng()}),b.getRadius()||b.setRadius(X0),y())})),L(b.addListener("radius_changed",y)),L(b.addListener("dragend",y))},p=>{m.disposed||d(p instanceof Error?p.message:"Failed to load map")}),()=>{m.disposed=!0;for(const p of m.listeners)try{p?.remove()}catch{}if(m.listeners=[],m.circle){try{m.circle.setMap(null)}catch{}m.circle=null}}};return h.current||(h.current=u),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(rt,{htmlFor:n,children:r}),t.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),o?c?i.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",children:c}):i.jsx("div",{ref:h.current,id:n,className:"h-72 w-full rounded-md border border-border/60"}):i.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["The map picker is unavailable — set"," ",i.jsx("code",{className:"font-mono",children:"GOOGLE_MAPS_API_KEY"})," on the server to enable it."]})]})}const $I="oklch(0.65 0.15 160)",BI="text-[oklch(0.45_0.15_160)] hover:bg-[oklch(0.65_0.15_160/0.12)] dark:text-[oklch(0.78_0.15_160)] dark:hover:bg-[oklch(0.65_0.15_160/0.15)]",b4="text-[oklch(0.45_0.15_160)] bg-[oklch(0.65_0.15_160/0.18)] dark:text-[oklch(0.78_0.15_160)] dark:bg-[oklch(0.65_0.15_160/0.2)]",AK="text-[oklch(0.45_0.15_160)] focus:bg-[oklch(0.65_0.15_160/0.12)] focus:text-[oklch(0.45_0.15_160)] dark:text-[oklch(0.78_0.15_160)] dark:focus:bg-[oklch(0.65_0.15_160/0.15)] dark:focus:text-[oklch(0.78_0.15_160)]";function $f(t){return t.map(e=>e.label).join(`
483
+ `)}function i0(t){return t.map(e=>({id:crypto.randomUUID(),index:e.index,label:e.label}))}function zI(t){return t.map((e,s)=>({...e,index:s}))}function _4(t){const e=M.c(18),{label:s,canDelete:n,dragging:r,onRename:o,onDuplicate:a,onDelete:l}=t,c=r?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==c?(d=te("h-4 w-4 shrink-0 text-muted-foreground/40 transition-opacity",c),e[0]=c,e[1]=d):d=e[1];let h;e[2]!==d?(h=i.jsx(na,{className:d}),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(kn,{className:"h-4 w-4 shrink-0",style:{color:$I}}),e[4]=u):u=e[4];let f;e[5]!==s?(f=i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s}),e[5]=s,e[6]=f):f=e[6];let m;e[7]!==n||e[8]!==r||e[9]!==s||e[10]!==l||e[11]!==a||e[12]!==o?(m=!r&&i.jsxs(as,{children:[i.jsx(ls,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":`Open actions for ${s}`,className:"size-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",onClick:UI,onPointerDown:FI,children:i.jsx(ni,{size:14})})}),i.jsxs(cs,{align:"end",children:[o&&i.jsxs(Ge,{onClick:g=>{g.stopPropagation(),o()},children:[i.jsx(o6,{size:14}),"Rename"]}),i.jsxs(Ge,{onClick:g=>{g.stopPropagation(),a?.()},children:[i.jsx(Ds,{size:14}),"Duplicate"]}),i.jsxs(Ge,{variant:"destructive",disabled:!n,onClick:g=>{g.stopPropagation(),l?.()},children:[i.jsx(ks,{size:14}),"Delete"]})]})]}),e[7]=n,e[8]=r,e[9]=s,e[10]=l,e[11]=a,e[12]=o,e[13]=m):m=e[13];let p;return e[14]!==h||e[15]!==f||e[16]!==m?(p=i.jsxs(i.Fragment,{children:[h,u,f,m]}),e[14]=h,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function FI(t){return t.stopPropagation()}function UI(t){return t.stopPropagation()}function HI(t){const e=M.c(27),{entry:s,selected:n,canDelete:r,onSelect:o,onRename:a,onDuplicate:l,onDelete:c}=t;let d;e[0]!==s.id?(d={id:s.id,animateLayoutChanges:KI},e[0]=s.id,e[1]=d):d=e[1];const{attributes:h,listeners:u,setNodeRef:f,transform:m,isDragging:p}=Z9(d);let g;e[2]!==m?(g=yn.Transform.toString(m?{...m,x:0}:null),e[2]=m,e[3]=g):g=e[3];const x=p?0:void 0;let v;e[4]!==g||e[5]!==x?(v={transform:g,opacity:x},e[4]=g,e[5]=x,e[6]=v):v=e[6];const _=v;let b;e[7]!==o?(b=C=>{C.target===C.currentTarget&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o())},e[7]=o,e[8]=b):b=e[8];const y=p?"cursor-grabbing":"cursor-grab",L=n?b4:BI;let w;e[9]!==y||e[10]!==L?(w=te("group flex select-none items-center gap-2 rounded-md px-2 py-2.5 transition-colors touch-none",y,L),e[9]=y,e[10]=L,e[11]=w):w=e[11];let S;e[12]!==r||e[13]!==s.label||e[14]!==c||e[15]!==l||e[16]!==a?(S=i.jsx(_4,{label:s.label,canDelete:r,onRename:a,onDuplicate:l,onDelete:c}),e[12]=r,e[13]=s.label,e[14]=c,e[15]=l,e[16]=a,e[17]=S):S=e[17];let j;return e[18]!==h||e[19]!==u||e[20]!==o||e[21]!==f||e[22]!==_||e[23]!==b||e[24]!==w||e[25]!==S?(j=i.jsx("div",{ref:f,style:_,...h,...u,onClick:o,onKeyDown:b,className:w,children:S}),e[18]=h,e[19]=u,e[20]=o,e[21]=f,e[22]=_,e[23]=b,e[24]=w,e[25]=S,e[26]=j):j=e[26],j}function KI(){return!1}function WI(t){const e=M.c(82),{listKey:s,variants:n,selectedIndex:r,onSelect:o,onRename:a,onDuplicate:l,onDelete:c,onRemoveAll:d,onReorder:h,onAdd:u}=t,f=n.length>1;let m;e[0]!==n?(m=()=>i0(n),e[0]=n,e[1]=m):m=e[1];const[p,g]=k.useState(m),[x,v]=k.useState(null),[_,b]=k.useState(s),[y,L]=k.useState(n.length);let w;e[2]!==n?(w=()=>$f(n),e[2]=n,e[3]=w):w=e[3];const[S,j]=k.useState(w),C=k.useRef(!1),V=$f(n);_!==s?(b(s),L(n.length),j(V),g(i0(n))):y!==n.length?(L(n.length),j(V),g(i0(n))):S!==V&&(j(V),g(ue=>n.map((ye,Le)=>({id:ue[Le]?.id??crypto.randomUUID(),index:ye.index,label:ye.label}))));let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N={activationConstraint:{distance:8}},e[4]=N):N=e[4];let T;e[5]===Symbol.for("react.memo_cache_sentinel")?(T={coordinateGetter:eu},e[5]=T):T=e[5];const A=dc(Zn(Dr,N),Zn(Ir,T));let E;e[6]!==p?(E=p.map(qI),e[6]=p,e[7]=E):E=e[7];const R=E;let D;e[8]!==p?(D=ue=>{const ye=String(ue.active.id);v(p.find(Le=>Le.id===ye)??null)},e[8]=p,e[9]=D):D=e[9];const P=D;let I;e[10]!==R||e[11]!==h?(I=ue=>{v(null);const{active:ye,over:Le}=ue;if(!Le||ye.id===Le.id)return;const Ce=R.indexOf(String(ye.id)),ze=R.indexOf(String(Le.id));Ce===-1||ze===-1||(g(Te=>zI(gr([...Te],Ce,ze))),C.current=!0,requestAnimationFrame(()=>{C.current=!1}),h(Ce,ze))},e[10]=R,e[11]=h,e[12]=I):I=e[12];const O=I;let B;e[13]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{v(null)},e[13]=B):B=e[13];const z=B;let $,U,W,X,H,Z,K,Y,F,Q,J,ee,q;if(e[14]!==f||e[15]!==p||e[16]!==R||e[17]!==O||e[18]!==P||e[19]!==u||e[20]!==c||e[21]!==l||e[22]!==d||e[23]!==a||e[24]!==o||e[25]!==r||e[26]!==A){const ue=he=>{C.current||o(he)};J="space-y-1 border-b p-2";let ye;e[40]===Symbol.for("react.memo_cache_sentinel")?(ye=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Variants"}),e[40]=ye):ye=e[40];let Le;e[41]===Symbol.for("react.memo_cache_sentinel")?(Le=i.jsx(kt,{size:14}),e[41]=Le):Le=e[41];let Ce;e[42]!==u?(Ce=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Add variant",className:"size-6",onClick:u,children:Le})}),e[42]=u,e[43]=Ce):Ce=e[43];let ze;e[44]===Symbol.for("react.memo_cache_sentinel")?(ze=i.jsx(De,{children:"Add variant"}),e[44]=ze):ze=e[44];let Te;e[45]!==Ce?(Te=i.jsxs(Oe,{children:[Ce,ze]}),e[45]=Ce,e[46]=Te):Te=e[46];let Se;e[47]===Symbol.for("react.memo_cache_sentinel")?(Se=i.jsx(ks,{size:14}),e[47]=Se):Se=e[47];let be;e[48]!==d?(be=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon","aria-label":"Remove all variants",className:"size-6 text-muted-foreground hover:text-destructive",onClick:d,children:Se})}),e[48]=d,e[49]=be):be=e[49];let Re;e[50]===Symbol.for("react.memo_cache_sentinel")?(Re=i.jsx(De,{children:"Remove all variants"}),e[50]=Re):Re=e[50];let Ve;e[51]!==be?(Ve=i.jsxs(Oe,{children:[be,Re]}),e[51]=be,e[52]=Ve):Ve=e[52],e[53]!==Te||e[54]!==Ve?(ee=i.jsxs("div",{className:"flex items-center justify-between",children:[ye,i.jsxs("div",{className:"flex items-center gap-0.5",children:[Te,Ve]})]}),e[53]=Te,e[54]=Ve,e[55]=ee):ee=e[55],U=mc,Z=A,K=U9,Y=P,F=O,Q=z,$=Q9,X=R,H=X9,q="space-y-0.5",W=p.map(he=>i.jsx(HI,{entry:he,selected:he.index===r,canDelete:f,onSelect:()=>ue(he.index),onRename:a?()=>a(he.index):void 0,onDuplicate:()=>l(he.index),onDelete:()=>c(he.index)},he.id)),e[14]=f,e[15]=p,e[16]=R,e[17]=O,e[18]=P,e[19]=u,e[20]=c,e[21]=l,e[22]=d,e[23]=a,e[24]=o,e[25]=r,e[26]=A,e[27]=$,e[28]=U,e[29]=W,e[30]=X,e[31]=H,e[32]=Z,e[33]=K,e[34]=Y,e[35]=F,e[36]=Q,e[37]=J,e[38]=ee,e[39]=q}else $=e[27],U=e[28],W=e[29],X=e[30],H=e[31],Z=e[32],K=e[33],Y=e[34],F=e[35],Q=e[36],J=e[37],ee=e[38],q=e[39];let se;e[56]!==W||e[57]!==q?(se=i.jsx("div",{className:q,children:W}),e[56]=W,e[57]=q,e[58]=se):se=e[58];let ne;e[59]!==$||e[60]!==X||e[61]!==H||e[62]!==se?(ne=i.jsx($,{items:X,strategy:H,children:se}),e[59]=$,e[60]=X,e[61]=H,e[62]=se,e[63]=ne):ne=e[63];let le;e[64]!==x||e[65]!==f?(le=x?i.jsx("div",{className:te("flex items-center gap-2 rounded-md px-2 py-2.5 shadow-lg ring-1 ring-border/60 cursor-grabbing",b4),children:i.jsx(_4,{label:x.label,canDelete:f,dragging:!0})}):null,e[64]=x,e[65]=f,e[66]=le):le=e[66];let G;e[67]!==le?(G=i.jsx(q9,{dropAnimation:null,children:le}),e[67]=le,e[68]=G):G=e[68];let oe;e[69]!==U||e[70]!==Z||e[71]!==K||e[72]!==Y||e[73]!==F||e[74]!==Q||e[75]!==ne||e[76]!==G?(oe=i.jsxs(U,{sensors:Z,collisionDetection:K,onDragStart:Y,onDragEnd:F,onDragCancel:Q,children:[ne,G]}),e[69]=U,e[70]=Z,e[71]=K,e[72]=Y,e[73]=F,e[74]=Q,e[75]=ne,e[76]=G,e[77]=oe):oe=e[77];let me;return e[78]!==J||e[79]!==ee||e[80]!==oe?(me=i.jsxs("div",{className:J,children:[ee,oe]}),e[78]=J,e[79]=ee,e[80]=oe,e[81]=me):me=e[81],me}function qI(t){return t.id}const GI=[[/always|matchalways/i,"Users03"],[/device|matchdevice/i,"Phone02"],[/date|matchdate/i,"Calendar"],[/random|matchrandom/i,"Shuffle01"],[/host|matchhost/i,"Globe02"],[/location|matchlocation/i,"MarkerPin01"],[/pathname/i,"Link03"],[/cron|matchcron/i,"Clock"],[/multi|matchmulti/i,"FilterLines"],[/never|matchnever/i,"EyeOff"],[/environment|matchenvironment/i,"Cloud01"],[/eq\.ts|\/eq$/i,"Brackets"],[/user|requser|isdecouser/i,"User01"],[/site|template/i,"LayoutAlt01"]],YI={"device-mobile":"Phone02","device-desktop":"Monitor01","device-tablet":"Tablet01","calendar-event":"Calendar","calendar-month":"Calendar",clock:"Clock","current-location":"MarkerPin01","map-2":"MarkerPin01","world-search":"Globe02",shuffle:"Shuffle01",filter:"FilterLines","eye-off":"EyeOff",flask:"Beaker02",link:"Link03","git-merge":"GitBranch01",users:"Users03",flag:"Flag01","cloud-storm":"Cloud01",campaign:"Announcement01",experiment:"Beaker02",language:"Globe02","hand-click":"CursorClick01"};function r0(t){return Ri(t)!==void 0}function Lu(t,e){if(e){if(r0(e))return e;const s=YI[e];if(s&&r0(s))return s}for(const[s,n]of GI)if(s.test(t)&&r0(n))return n;return"FilterLines"}function JI(t){return Ri(t)??P6}function o0(t){const e=M.c(11),{iconName:s,size:n,className:r}=t,o=n===void 0?"md":n;let a;e[0]!==s?(a=JI(s),e[0]=s,e[1]=a):a=e[1];const l=a,c=o==="sm"?"size-7":"size-9",d=o==="sm"?16:18;let h;e[2]!==c||e[3]!==r?(h=te("flex shrink-0 items-center justify-center rounded-full bg-muted",c,r),e[2]=c,e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==d?(u=i.jsx(l,{size:d,className:"text-muted-foreground"}),e[5]=l,e[6]=d,e[7]=u):u=e[7];let f;return e[8]!==h||e[9]!==u?(f=i.jsx("div",{className:h,children:u}),e[8]=h,e[9]=u,e[10]=f):f=e[10],f}const XI=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),QI=5,ZI=new Intl.DateTimeFormat("en",{dateStyle:"medium",timeStyle:"short"});function Bf(t){const{start:e,end:s}=t,n=typeof e=="string"?e:"",r=typeof s=="string"?s:"";if(!n&&!r)return null;const o=c=>{if(!c)return null;const d=new Date(c);return Number.isNaN(d.getTime())?null:ZI.format(d)},a=o(n),l=o(r);return a&&l?`${a} → ${l}`:a?`From ${a}`:l?`Until ${l}`:null}function wc(t,e=0){if(!t)return"Default";if(e>QI)return"...";const s=t.__resolveType??"";if(["website/matchers/always.ts","$live/matchers/MatchAlways.ts"].includes(s)||s==="")return"Default";switch(s){case"website/matchers/never.ts":return"Hidden";case"website/matchers/device.ts":case"$live/matchers/MatchDevice.ts":{const{mobile:r,tablet:o,desktop:a,devices:l=[]}=t,c=[...l];return r&&c.push("Mobile"),o&&c.push("Tablet"),a&&c.push("Desktop"),c.length>0?c.map(XI).join(" & "):Ct(s)}case"website/matchers/date.ts":case"$live/matchers/MatchDate.ts":return Bf(t)??Ct(s);case"website/matchers/random.ts":case"$live/matchers/MatchRandom.ts":{const{traffic:r}=t;return typeof r=="number"?`${Math.ceil(r*100)}% of sessions`:Ct(s)}case"website/matchers/host.ts":case"$live/matchers/MatchHost.ts":{const{includes:r,match:o}=t,a=[];return r&&a.push(r),o&&a.push(o),a.length>0?a.join(" - "):Ct(s)}case"website/matchers/pathname.ts":{const r=t.case,{type:o,pathname:a}=r??{};return o&&a?`Pathname ${o} ${a}`:Ct(s)}case"website/matchers/location.ts":case"$live/matchers/MatchLocation.ts":{const{includeLocations:r,excludeLocations:o}=t,a=d=>[d.city,d.regionCode,d.country].filter(Boolean).join(" - "),l=r?.[0];if(l){const d=(r?.length??0)-1;return`${a(l)}${d>0?` +${d}`:""}`}const c=o?.[0];if(c){const d=(o?.length??0)-1;return`Except ${a(c)}${d>0?` +${d}`:""}`}return"Any location"}case"website/matchers/multi.ts":case"$live/matchers/MatchMulti.ts":{const{matchers:r,op:o="AND"}=t;if(r&&r.length>0){const a=o==="OR"?"OR":"AND";return r.map(l=>wc(l,e+1)).join(` ${a} `)}return Ct(s)}default:{const r=Bf(t);return r||Ct(s)||"Default"}}}function TK(t,e){return TA(t,e).map(s=>{const n=e[s.blockKey]??{},r=lg(PA(s.blockKey),e,t);return{blockKey:s.blockKey,title:oc(s.blockKey,n),description:wc(r),iconName:Lu(s.matcherResolveType)}})}const y4="Users03";function eD(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("matchers"))for(const o of Object.keys(r)){if(o.includes("always"))continue;const a=ri(o,t);s.push({resolveType:o,title:a.title??Ct(o),description:a.description,iconName:Lu(o,a.icon)})}return s}function tD(t,e){if(!t)return y4;const s=e.find(n=>n.resolveType===t);return s?s.iconName:Lu(t)}function sD(t){const e=M.c(54),{currentRt:s,currentLabel:n,currentGlobalKey:r,matchers:o,globals:a,onSelect:l,onSelectGlobal:c}=t,d=a===void 0?[]:a,[h,u]=k.useState(!1),m=(r?d.find($=>$.blockKey===r):void 0)?.iconName??tD(s,o),p=Ri(m);let g;e[0]!==l||e[1]!==u?(g=$=>{l($),u(!1)},e[0]=l,e[1]=u,e[2]=g):g=e[2];const x=g;let v;e[3]!==c||e[4]!==u?(v=$=>{c?.($),u(!1)},e[3]=c,e[4]=u,e[5]=v):v=e[5];const _=v;let b;e[6]!==u?(b=()=>u(!0),e[6]=u,e[7]=b):b=e[7];let y;e[8]!==p?(y=p&&i.jsx(p,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[8]=p,e[9]=y):y=e[9];let L;e[10]!==n?(L=i.jsx("span",{className:"flex-1 truncate",children:n}),e[10]=n,e[11]=L):L=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(ts,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[12]=w):w=e[12];let S;e[13]!==b||e[14]!==y||e[15]!==L?(S=i.jsxs("button",{type:"button",onClick:b,className:"flex h-10 w-full items-center gap-2 rounded-md border border-input bg-transparent px-3 text-left text-sm shadow-xs transition-colors hover:bg-accent/40 cursor-pointer",children:[y,L,w]}),e[13]=b,e[14]=y,e[15]=L,e[16]=S):S=e[16];let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Ii,{placeholder:"Search rules..."}),e[17]=j):j=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=i.jsx(Jn,{children:"No rules found."}),e[18]=C):C=e[18];let V;e[19]!==x?(V=()=>x(""),e[19]=x,e[20]=V):V=e[20];const N=!s&&!r&&"bg-accent/60";let T;e[21]!==N?(T=te("gap-2.5",N),e[21]=N,e[22]=T):T=e[22];let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(o0,{iconName:y4,size:"sm"}),e[23]=A):A=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"text-sm",children:"Always"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:"Target all users"})]}),e[24]=E):E=e[24];let R;e[25]!==V||e[26]!==T?(R=i.jsxs(Cs,{value:"always Target all users",onSelect:V,className:T,children:[A,E]}),e[25]=V,e[26]=T,e[27]=R):R=e[27];let D;if(e[28]!==r||e[29]!==s||e[30]!==x||e[31]!==o){let $;e[33]!==r||e[34]!==s||e[35]!==x?($=U=>i.jsxs(Cs,{value:`${U.title} ${U.resolveType} ${U.description??""}`,onSelect:()=>x(U.resolveType),className:te("gap-2.5",!r&&s===U.resolveType&&"bg-accent/60"),children:[i.jsx(o0,{iconName:U.iconName,size:"sm"}),i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"text-sm",children:U.title}),U.description&&i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:U.description})]})]},U.resolveType),e[33]=r,e[34]=s,e[35]=x,e[36]=$):$=e[36],D=o.map($),e[28]=r,e[29]=s,e[30]=x,e[31]=o,e[32]=D}else D=e[32];let P;e[37]!==R||e[38]!==D?(P=i.jsxs(Is,{children:[R,D]}),e[37]=R,e[38]=D,e[39]=P):P=e[39];let I;e[40]!==r||e[41]!==d||e[42]!==_?(I=d.length>0&&i.jsx(Is,{heading:"Saved rules",children:d.map($=>i.jsxs(Cs,{value:`${$.title} ${$.blockKey} ${$.description??""}`,onSelect:()=>_($.blockKey),className:te("gap-2.5",r===$.blockKey&&"bg-accent/60"),children:[i.jsx(o0,{iconName:$.iconName,size:"sm"}),i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"truncate text-sm",children:$.title}),$.description&&i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:$.description})]})]},$.blockKey))}),e[40]=r,e[41]=d,e[42]=_,e[43]=I):I=e[43];let O;e[44]!==P||e[45]!==I?(O=i.jsxs(Di,{children:[C,P,I]}),e[44]=P,e[45]=I,e[46]=O):O=e[46];let B;e[47]!==h||e[48]!==u||e[49]!==O?(B=i.jsxs(Lb,{open:h,onOpenChange:u,title:"Choose a rule",description:"Pick how to target users for this variant",className:"sm:max-w-lg",children:[j,O]}),e[47]=h,e[48]=u,e[49]=O,e[50]=B):B=e[50];let z;return e[51]!==B||e[52]!==S?(z=i.jsxs(i.Fragment,{children:[S,B]}),e[51]=B,e[52]=S,e[53]=z):z=e[53],z}function nD(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.__resolveType=="string"&&Array.isArray(e.variants)}function iD(t,e){return{__resolveType:e,variants:[{rule:mr(),value:structuredClone(t)},{rule:mr(),value:structuredClone(t)}]}}function rD(t){const e=t.variants;if(e.length===0)return;const s=e.find(n=>au(n.rule));return s?s.value:e[e.length-1]?.value}function oD(t){const e=[...t.variants],s=e[e.length-1],n={rule:mr(),value:s?structuredClone(s.value):void 0};return{...t,variants:[...e,n]}}function aD(t,e){if(t.variants.length<=1)return null;const s=[...t.variants];return s.splice(e,1),{...t,variants:s}}function lD(t,e){const s=[...t.variants],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function cD(t,e,s){const n=[...t.variants];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[r]=n.splice(e,1);return r?(n.splice(s,0,r),{...t,variants:n}):t}function dD(t,e,s){const n=[...t.variants],r=n[e];return r?(n[e]={...r,value:s},{...t,variants:n}):t}function zf(t,e,s){const n=[...t.variants],r=n[e];return r?(n[e]={...r,rule:s},{...t,variants:n}):t}const Ff=new WeakMap,Uf=new Map;function uD(t){let e=Ff.get(t);return e||(e=eD(t),Ff.set(t,e)),e}function hD(t,e){let s=Uf.get(t);return s===void 0&&(s=_n(t,e),Uf.set(t,s)),s}function L4(t){const e=M.c(3),{multivariateResolveType:s,renderInnerField:n,...r}=t,{value:o,onChange:a,meta:l,path:c}=r,[d,h]=k.useState(0);if(!nD(o)){let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=i.jsx(m9,{size:14}),e[0]=P):P=e[0];let I;return e[1]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(De,{children:"Add variant"}),e[1]=I):I=e[1],i.jsxs("div",{className:"relative grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-2",children:[i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 size-6 text-muted-foreground hover:text-foreground","aria-label":"Add variant",onClick:()=>{a(iD(o,s)),h(0)},children:P})}),I]}),n(r)]})}const u=o,f=u.variants,m=Math.min(d,f.length-1),p=f.map(fD),g=f[m],x=g?.rule??{},v=x.__resolveType??"",_=g?.value,b=l?uD(l):[],y=v&&l?hD(v,l):null,{__resolveType:L,...w}=x,S=()=>{a(rD(u)),h(0)},j=()=>{const P=oD(u);a(P),h(P.variants.length-1)},C=P=>{const I=aD(u,P);I&&(a(I),m>=I.variants.length&&h(I.variants.length-1))},V=P=>{const I=lD(u,P);a(I),h(P+1)},N=(P,I)=>{const O=cD(u,P,I);a(O),m===P&&h(I)},T=P=>{a(zf(u,m,P?{__resolveType:P}:{__resolveType:Sp}))},A=P=>{const I=P,O=v?{...I,__resolveType:v}:{...I};a(zf(u,m,O))},E=P=>{a(dD(u,m,P))},R=`${c}-${u.__resolveType}`;let D;return e[2]===Symbol.for("react.memo_cache_sentinel")?(D=i.jsx(rt,{className:"text-xs text-muted-foreground",children:"Rule"}),e[2]=D):D=e[2],i.jsxs("div",{className:"grid w-full min-w-0 grid-cols-[minmax(0,1fr)] gap-0",children:[i.jsx(WI,{listKey:R,variants:p,selectedIndex:m,onSelect:h,onDuplicate:V,onDelete:C,onRemoveAll:S,onReorder:N,onAdd:j}),i.jsxs("div",{className:"space-y-4 px-2 pt-3",children:[i.jsxs("div",{className:"space-y-1.5",children:[D,i.jsx(sD,{currentRt:v,currentLabel:wc(x),matchers:b,onSelect:T}),y&&i.jsx("div",{className:"pt-1",children:i.jsx(Pn,{schema:y,value:w,onChange:A,basePath:""})})]}),n({...r,value:_,onChange:E})]})]})}function fD(t,e){return{index:e,label:wc(t.rule)||`Variant ${e+1}`}}const mD="website/loaders/secret.ts";function Co(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t.__resolveType;return typeof e=="string"&&(e.endsWith("/secret.ts")||e.includes("loaders/secret"))}function pD(){return{__resolveType:mD,name:"",encrypted:""}}function gD(t){const{value:e,...s}=t;return s}function a0(t){const e=M.c(45),{schema:s,value:n,onChange:r,label:o,path:a}=t;if(typeof n=="string"||n==null&&!Co(n)){const S=typeof n=="string"?n:"";let j;e[0]!==o||e[1]!==a?(j=i.jsx(rt,{htmlFor:a,className:"text-sm font-medium",children:o}),e[0]=o,e[1]=a,e[2]=j):j=e[2];let C;e[3]!==s.description?(C=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=C):C=e[4];let V;e[5]!==r?(V=A=>r(A.target.value),e[5]=r,e[6]=V):V=e[6];let N;e[7]!==a||e[8]!==S||e[9]!==V?(N=i.jsx(tt,{id:a,type:"password",value:S,autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:"Secret value",onChange:V,className:"h-10"}),e[7]=a,e[8]=S,e[9]=V,e[10]=N):N=e[10];let T;return e[11]!==j||e[12]!==C||e[13]!==N?(T=i.jsxs("div",{className:"space-y-2",children:[j,C,N]}),e[11]=j,e[12]=C,e[13]=N,e[14]=T):T=e[14],T}let l;e[15]!==n?(l=Co(n)?n:pD(),e[15]=n,e[16]=l):l=e[16];const c=l,d=typeof c.name=="string"?c.name:"",h=typeof c.encrypted=="string"&&c.encrypted,u=`${a}-name`;let f;e[17]!==o||e[18]!==u?(f=i.jsx(rt,{htmlFor:u,className:"text-sm font-medium",children:o}),e[17]=o,e[18]=u,e[19]=f):f=e[19];let m;e[20]!==s.description?(m=s.description&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}),e[20]=s.description,e[21]=m):m=e[21];const p=`${a}-name`;let g;e[22]!==c||e[23]!==r?(g=S=>r({...c,name:S.target.value}),e[22]=c,e[23]=r,e[24]=g):g=e[24];let x;e[25]!==d||e[26]!==p||e[27]!==g?(x=i.jsx(tt,{id:p,value:d,placeholder:"Secret name",onChange:g,className:"h-10"}),e[25]=d,e[26]=p,e[27]=g,e[28]=x):x=e[28];const v=`${a}-value`,_=h?"Leave blank to keep current value":"Secret value";let b;e[29]!==c||e[30]!==h||e[31]!==r?(b=S=>{const j=S.target.value;if(!j){r(h?gD(c):c);return}r({...c,value:j})},e[29]=c,e[30]=h,e[31]=r,e[32]=b):b=e[32];let y;e[33]!==b||e[34]!==v||e[35]!==_?(y=i.jsx(tt,{id:v,type:"password",autoComplete:"new-password",autoCorrect:"off",spellCheck:!1,placeholder:_,onChange:b,className:"h-10"}),e[33]=b,e[34]=v,e[35]=_,e[36]=y):y=e[36];let L;e[37]!==h?(L=h&&i.jsx("p",{className:"text-xs text-muted-foreground",children:"A secret value is stored."}),e[37]=h,e[38]=L):L=e[38];let w;return e[39]!==y||e[40]!==L||e[41]!==f||e[42]!==m||e[43]!==x?(w=i.jsxs("div",{className:"space-y-2",children:[f,m,x,y,L]}),e[39]=y,e[40]=L,e[41]=f,e[42]=m,e[43]=x,e[44]=w):w=e[44],w}function xD(t,e){const s=t.anyOfRefs;if(!s?.length)return;const n=e.find(d=>d!=null&&typeof d=="object"&&!Array.isArray(d)),r=n?Object.keys(n).filter(d=>!d.startsWith("__")):[],o=[],a=d=>{d?.type==="object"&&d.properties&&o.push(d)};for(const d of s){const h=d.schema;if(h&&(h.type==="array"&&a(h.items),h.properties))for(const u of Object.values(h.properties))u?.type==="array"&&a(u.items)}if(o.length===0)return;if(r.length===0)return o.length===1?o[0]:void 0;let l,c=-1;for(const d of o){const h=d.properties??{},u=r.filter(f=>f in h).length*2+(d.titleBy?1:0);u>c&&(c=u,l=d)}return c>=2?l:void 0}function vD(t){const e=t.length>0?t[0]:void 0;if(e==null||typeof e!="object"||Array.isArray(e))return;const s={};for(const[n,r]of Object.entries(e))n.startsWith("__")||(typeof r=="string"?s[n]={type:"string"}:typeof r=="number"?s[n]={type:"number"}:typeof r=="boolean"&&(s[n]={type:"boolean"}));return Object.keys(s).length>0?{type:"object",properties:s}:void 0}const bD=new Set(["__resolveType","@type"]);function _D(t){if(t.type!=="block-ref"||!t.anyOfRefs?.length||t.anyOfRefs.length!==1)return!1;const e=t.anyOfRefs[0].schema;return!!(e?.properties?.variants||!e&&t.plainSchema)}function yD(t){if(bc(t))for(const e of t.anyOfRefs??[]){const r=e.schema?.properties?.variants?.items?.properties?.value;if(r?.type==="array"&&r.items)return r.items}}function Hf(t){if(t.type==="array"&&t.items)return t;const e=t.items??yD(t);return e?{...t,type:"array",items:e}:null}function LD(t,e){if(e!==void 0)return e;switch(t){case"string":return"";case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return null}}function Uo(t){const{schema:e,value:s}=t;if(Tl(s)){const a=tT(s),l=Hf(e);if(a!==null&&l)return i.jsx(Ta,{...t,schema:l,value:a,onChange:c=>t.onChange(sT(s,c))},t.path)}if(Array.isArray(s)&&e.type==="block-ref"&&bc(e)){const a=Hf(e);if(a)return i.jsx(Ta,{...t,schema:a,value:s,onChange:t.onChange},t.path)}if(Array.isArray(s)&&!Tl(s)&&e.type==="block-ref"){const a=xD(e,s)??vD(s);if(a){const l={...e,type:"array",items:a};return i.jsx(Ta,{...t,schema:l,value:s,onChange:t.onChange},t.path)}}if(e.type==="block-ref"||s!==null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&e.anyOfRefs){if(_D(e)){const a=e.anyOfRefs[0],l=a.schema?.properties?.variants?.items?.properties?.value,c=l&&l.type!=="block-ref"?l:e.plainSchema??l?.plainSchema??{type:"string"},d=h=>Uo({...h,schema:c});return i.jsx(L4,{...t,multivariateResolveType:a.resolveType,renderInnerField:d},t.path)}return e.anyOfRefs?i.jsx(Rf,{...t},t.path):null}if(e.type==="inline-union")return i.jsx(EI,{...t},t.path);if(e.format==="image-uri")return i.jsx(xI,{...t},t.path);if(e.format==="file-uri"||e.format==="video-uri")return i.jsx(mI,{...t},t.path);if(e.format==="map")return i.jsx(MI,{...t},t.path);if(e.format==="dynamic-options"&&e.options)return i.jsx(BP,{...t},t.path);if(e.format==="location")return i.jsx(v4,{...t},t.path);if(e.enum&&e.enum.length>0)return i.jsx(qR,{...t},t.path);if(e.type==="anyOf")return i.jsx(Rf,{...t},t.path);if(Co(s)||e.format==="password"||s==null&&e.format==="password")return i.jsx(a0,{...t},t.path);const n=s??LD(e.type,e.default);if(n==null)return Co(s)?i.jsx(a0,{...t},t.path):null;if(Co(n))return i.jsx(a0,{...t,value:n},t.path);const r={...t,value:n},o=s==null?e.type??typeof n:Array.isArray(n)?"array":typeof n;if(o==="array"||Array.isArray(n))return i.jsx(Ta,{...r},t.path);switch(o){case"boolean":return i.jsx(UR,{...r},t.path);case"number":case"integer":return i.jsx(FR,{...r},t.path);case"string":{const a=e.format;return a==="color-input"||a==="color"?i.jsx(Na,{...r},t.path):a==="textarea"||a==="rich-text"||a==="html"?i.jsx(Na,{...r},t.path):i.jsx(Na,{...r},t.path)}case"object":return n!==null&&typeof n=="object"&&!Array.isArray(n)?i.jsx(VP,{...r},t.path):null;default:return i.jsx(Na,{...r},t.path)}}function SD(t,e){if(e&&(e.type==="block-ref"||e.anyOfRefs||e.properties))return Uo({...t,schema:e});const s=t.value;if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.__resolveType=="string"&&t.meta){const n=_n(s.__resolveType,t.meta);if(n)return i.jsx(Pn,{schema:n,value:s,onChange:t.onChange,basePath:t.path,breadcrumbPath:t.breadcrumbPath,onBreadcrumbChange:t.onBreadcrumbChange,meta:t.meta,decofile:t.decofile,onSaveReferencedBlock:t.onSaveReferencedBlock,sandbox:t.sandbox})}return Uo(e?{...t,schema:e}:t)}function Pn(t){const e=M.c(18),{schema:s,value:n,onChange:r,basePath:o,breadcrumbPath:a,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p}=t;let g,x;if(e[0]!==o||e[1]!==d||e[2]!==c||e[3]!==f||e[4]!==l||e[5]!==r||e[6]!==m||e[7]!==h||e[8]!==u||e[9]!==p||e[10]!==s||e[11]!==a||e[12]!==n){x=Symbol.for("react.early_return_sentinel");e:{const v=a===void 0?[]:a,_=s.properties;if(!_){x=null;break e}if(eT(n)&&_.variants){const E=_.variants.items?.properties?.value;let R;e[15]!==E?(R=D=>SD(D,E),e[15]=E,e[16]=R):R=e[16],x=i.jsx(L4,{schema:s,value:n,onChange:r,path:o,label:s.title??"",breadcrumbPath:v,onBreadcrumbChange:l,meta:c,decofile:d,onSaveReferencedBlock:h,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p,multivariateResolveType:n.__resolveType,renderInnerField:R},o);break e}const b=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},y=Object.keys(_).filter(E=>!bD.has(E)&&_[E]?.hidden!==!0);if(y.length===0){let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields on this section."}),e[17]=E):E=e[17],x=E;break e}const L=(E,R)=>{r({...b,[E]:R})},w=typeof b.__resolveType=="string"?b.__resolveType:void 0,S=y.filter(E=>{const R=_[E];return R!=null&&J0(R,b[E])}).length>1,j=v.length>0?uP(y,_,b,v):null,C=j?_[j]:null,V=j&&C?[j]:y,N=j&&C?cP(j,C,v):v,T=lP(v,N),A=T.length>0&&l?E=>l([...T,...E]):l;g=i.jsx("div",{className:"min-w-0 space-y-6",children:V.map(E=>{const R=_[E];if(!R)return null;const D=o?`${o}.${E}`:E,P=jo(E,R);return Uo({schema:R,value:b[E],onChange:I=>L(E,I),path:D,label:P,breadcrumbPath:N,onBreadcrumbChange:A,hasSiblingDrillDownFields:S,meta:c,decofile:d,onSaveReferencedBlock:h,containerResolveType:w,previewBaseUrl:u,onAddSectionItem:f,onRequestAddSection:m,sandbox:p})})})}e[0]=o,e[1]=d,e[2]=c,e[3]=f,e[4]=l,e[5]=r,e[6]=m,e[7]=h,e[8]=u,e[9]=p,e[10]=s,e[11]=a,e[12]=n,e[13]=g,e[14]=x}else g=e[13],x=e[14];return x!==Symbol.for("react.early_return_sentinel")?x:g}function wD(t){const e=M.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[i.jsx(Sn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[i.jsx(Xe,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[i.jsx(Ot,{size:13}),"Saved"]}),e[2]=r):r=e[2],r}function jD({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:r,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=oi(),p=m?.entity?.id===e?m.entity.metadata?.siteSlug??null:null,g=_n(l.resolveType,r),x=!g&&MS(l.resolveType,r),v=x?$S(c):null,_=g??v,[b,y]=k.useState(c),[L,w]=k.useState([]),[S,j]=k.useState(0),[C,V]=k.useState(!1),[N,T]=k.useState(null),[A,E]=k.useState(!1),[R,D]=k.useState(!1),[P,I]=k.useState(!1),O=N!==null,{save:B,flush:z,isPending:$}=hg({orgSlug:t,virtualMcpId:e,branch:s}),U=UT({orgSlug:t,virtualMcpId:e,branch:s});k.useEffect(()=>()=>{z()},[]);const W=Rg(a),X=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,H={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:p},Z=se=>{y(se),l.mode==="saved"&&B(l.blockKey,{__resolveType:l.resolveType,...se})},K=()=>{O?(T(null),V(!1),j(se=>se+1)):T(JSON.stringify(b,null,2))},Y=se=>{const ne=se??"";try{const le=JSON.parse(ne);if(le&&typeof le=="object"&&!Array.isArray(le)){V(!1),Z(le);return}V(!0)}catch{V(!0)}},F=async se=>{const ne=vu(se,o);if(ne){de.error(ne);return}await h(se,{__resolveType:l.resolveType,...b}),E(!1)},Q=()=>{D(!0),U.mutate({resolveType:l.resolveType,props:b})},J=()=>{n&&window.open(zT(n,l.resolveType,b,Date.now()),"_blank","noopener")},ee=[l.title,...L],q=se=>{w(L.slice(0,se)),j(ne=>ne+1)};return i.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&i.jsx(re,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":"Back to list",children:i.jsx(Wl,{size:14})}),i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:ee.map((se,ne)=>{const le=ne===ee.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[ne>0&&i.jsx(vn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>q(ne),title:se,className:te("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",le?"font-medium text-foreground":"text-muted-foreground"),children:se})]},`${se}-${ne}`)})}),l.mode==="saved"&&i.jsx(wD,{isPending:$,isError:!1}),i.jsxs(re,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:Q,disabled:U.isPending,"aria-label":`Run ${W}`,children:[U.isPending?i.jsx(Xe,{size:14,className:"animate-spin"}):i.jsx(Si,{size:14}),"Run"]}),l.mode==="available"&&i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>E(!0),"aria-label":`Save as global ${W}`,children:i.jsx(Gd,{size:14})})}),i.jsxs(De,{side:"bottom",children:["Save as global ",W]})]}),i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:O?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:K,"aria-label":O?"Close JSON editor":"Edit as JSON","aria-pressed":O,children:O?i.jsx(js,{size:14}):i.jsx(Qo,{size:14})})}),i.jsx(De,{side:"bottom",children:O?"Close JSON editor":"Edit as JSON"})]})]}),i.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?`Global ${W} — changes save automatically. Run to invoke it against the live preview.`:`${X} — edits stay local until you save this as a global ${W}. Run to invoke it against the live preview.`})]}),i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:te("relative min-h-0 flex-1",R&&P&&"hidden"),children:[i.jsx(ti,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsxs("div",{className:"mx-auto max-w-2xl",children:[v&&_===v&&i.jsxs("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:["This ",W," doesn't publish a props schema — fields below are inferred from its saved values. Use the JSON editor to add props not shown here."]}),_?i.jsx(Pn,{schema:_,value:b,onChange:se=>Z(se),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:r,decofile:o,onSaveReferencedBlock:u,sandbox:H},S):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:x?`This ${W} doesn't publish a props schema. Edit its props as JSON, then run it.`:`This ${W} takes no configurable input. Run it to see its output.`})]})})}),N!==null&&i.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[C&&i.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(ia,{language:"json",height:"100%",code:N,onChange:Y,onSave:se=>{Y(se),z()}})})]})]}),R&&i.jsx(CD,{singular:W,result:{isPending:U.isPending,error:U.error,data:U.data,hasRun:U.status!=="idle"},expanded:P,onToggleExpand:()=>I(se=>!se),onOpenInNewTab:n?J:void 0,onClose:()=>{D(!1),I(!1)}})]}),i.jsx(bu,{open:A,onOpenChange:E,defaultBlockId:"",isPending:d,onSubmit:F})]})}function CD(t){const e=M.c(37),{singular:s,result:n,expanded:r,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t;let c;e[0]!==n.data?(c=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=c):c=e[1];const d=c,h=r?"flex-1":"h-[45%] shrink-0";let u;e[2]!==h?(u=te("flex min-h-0 flex-col border-t",h),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),e[4]=f):f=e[4];let m;e[5]!==a||e[6]!==s?(m=a&&i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":"Open result in new tab",children:i.jsx(Rn,{size:14})})}),i.jsxs(De,{side:"bottom",children:["Open in new tab (re-runs the ",s,")"]})]}),e[5]=a,e[6]=s,e[7]=m):m=e[7];const p=r?"Collapse result":"Expand result";let g;e[8]!==r?(g=r?i.jsx(Zv,{size:14}):i.jsx(Im,{size:14}),e[8]=r,e[9]=g):g=e[9];let x;e[10]!==r||e[11]!==o||e[12]!==p||e[13]!==g?(x=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":p,"aria-pressed":r,children:g})}),e[10]=r,e[11]=o,e[12]=p,e[13]=g,e[14]=x):x=e[14];const v=r?"Collapse":"Expand";let _;e[15]!==v?(_=i.jsx(De,{side:"bottom",children:v}),e[15]=v,e[16]=_):_=e[16];let b;e[17]!==_||e[18]!==x?(b=i.jsxs(Oe,{children:[x,_]}),e[17]=_,e[18]=x,e[19]=b):b=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(js,{size:14}),e[20]=y):y=e[20];let L;e[21]!==l?(L=i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":"Close result",children:y}),e[21]=l,e[22]=L):L=e[22];let w;e[23]!==b||e[24]!==L||e[25]!==m?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[f,i.jsxs("div",{className:"flex items-center gap-0.5",children:[m,b,L]})]}),e[23]=b,e[24]=L,e[25]=m,e[26]=w):w=e[26];let S;e[27]!==n.error||e[28]!==n.hasRun||e[29]!==n.isPending||e[30]!==d||e[31]!==s?(S=i.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[i.jsx(Xe,{size:16,className:"animate-spin"}),"Running ",s,"…"]}):n.error?i.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[i.jsxs("p",{className:"text-xs font-medium text-destructive",children:["Failed to run ",s]}),i.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?i.jsx(ia,{language:"json",height:"100%",code:d,readOnly:!0}):i.jsxs("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:["Press Run to invoke this ",s,"."]})}),e[27]=n.error,e[28]=n.hasRun,e[29]=n.isPending,e[30]=d,e[31]=s,e[32]=S):S=e[32];let j;return e[33]!==w||e[34]!==S||e[35]!==u?(j=i.jsxs("div",{className:u,children:[w,S]}),e[33]=w,e[34]=S,e[35]=u,e[36]=j):j=e[36],j}const kD={loaders:sl,actions:wi},VD={loaders:"Loaders",actions:"Actions"},ND={analytics:L6,blog:lr,commerce:f9,site:a6,website:ii};function AD(t,e){return e===0?ND[t.toLowerCase()]??Xn:Xn}function Ra(t,e){return e===0?sE(t):t}function TD(t){const e=M.c(87),{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];const[h,u]=k.useState(d),[f,m]=k.useState(null),[p,g]=k.useState(""),[x,v]=k.useState($D),[_,b]=k.useState(c);_!==c&&(b(c),u([]),m(null),g(""),v(new Set));let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{v(W=>{const X=new Set(W);return X.has(U)?X.delete(U):X.add(U),X})},e[1]=y):y=e[1];const L=y;let w;e[2]!==r||e[3]!==s||e[4]!==n?(w={orgSlug:s,virtualMcpId:n,branch:r},e[2]=r,e[3]=s,e[4]=n,e[5]=w):w=e[5];const S=vc(w);let j;e[6]!==S?(j=Fg((U,W)=>S.mutate({blockKey:U,data:W})),e[6]=S,e[7]=j):j=e[7];const C=j;let V;e[8]!==c?(V=Rg(c),e[8]=c,e[9]=V):V=e[9];const N=V,T=kD[c];let A,E,R,D,P,I,O;if(e[10]!==T||e[11]!==r||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==x||e[16]!==s||e[17]!==h||e[18]!==o||e[19]!==S||e[20]!==C||e[21]!==p||e[22]!==f||e[23]!==N||e[24]!==n){R=Symbol.for("react.early_return_sentinel");e:{const U=[...nE(a,l,c).map(MD),...Pg(a,c).map(OD)],W=p.trim().toLowerCase(),X=W.length>0,H=X?U.filter(he=>he.title.toLowerCase().includes(W)||he.resolveType.toLowerCase().includes(W)):[],Z=new Map,K=[],Y=new Map;if(!X){for(const he of U){const Pe=he.folderPath;if(!(Pe.length<h.length)&&h.every((Me,xe)=>Pe[xe]===Me))if(Pe.length===h.length)if(he.savedKey!==void 0){const Me=Y.get(he.resolveType);Me?Me.push(he):Y.set(he.resolveType,[he])}else K.push(he);else{const Me=Pe[h.length],xe=Z.get(Me)??{count:0,savedCount:0};he.savedKey!==void 0?xe.savedCount=xe.savedCount+1:xe.count=xe.count+1,Z.set(Me,xe)}}K.sort(DD);for(const he of Y.values())he.sort(ID)}const F=[...Y.entries()].filter(he=>{const[Pe]=he;return!K.some(Me=>Me.resolveType===Pe)}).flatMap(PD).sort(RD);let Q;e[32]!==h?(Q=(he,Pe)=>Ra(he.name,h.length).localeCompare(Ra(Pe.name,h.length)),e[32]=h,e[33]=Q):Q=e[33];const J=[...Z.entries()].map(ED).sort(Q);let ee;e[34]===Symbol.for("react.memo_cache_sentinel")?(ee=he=>{m(he.savedKey!==void 0?{mode:"saved",key:he.savedKey}:{mode:"available",resolveType:he.resolveType,title:he.title})},e[34]=ee):ee=e[34];const q=ee;let se;e[35]!==S||e[36]!==N?(se=async(he,Pe)=>{await S.mutateAsync({blockKey:he,data:Pe}),de.success(`Saved ${N} "${he}"`),m({mode:"saved",key:he})},e[35]=S,e[36]=N,e[37]=se):se=e[37];const ne=se;let le;e[38]!==l||e[39]!==f?(le=BD(f,l),e[38]=l,e[39]=f,e[40]=le):le=e[40];const G=le;if(G){const he=`${G.mode}:${G.mode==="saved"?G.blockKey:G.resolveType}`;let Pe;e[41]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>m(null),e[41]=Pe):Pe=e[41];let Me;e[42]!==r||e[43]!==l||e[44]!==ne||e[45]!==c||e[46]!==a||e[47]!==s||e[48]!==o||e[49]!==S.isPending||e[50]!==C||e[51]!==he||e[52]!==G.editorTarget||e[53]!==G.initialValue||e[54]!==n?(Me=i.jsx(jD,{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c,target:G.editorTarget,initialValue:G.initialValue,isCreating:S.isPending,onCreate:ne,onSaveReferencedBlock:C,onBack:Pe},he),e[42]=r,e[43]=l,e[44]=ne,e[45]=c,e[46]=a,e[47]=s,e[48]=o,e[49]=S.isPending,e[50]=C,e[51]=he,e[52]=G.editorTarget,e[53]=G.initialValue,e[54]=n,e[55]=Me):Me=e[55],R=Me;break e}O="flex h-full w-full min-w-0 flex-col";let oe;e[56]===Symbol.for("react.memo_cache_sentinel")?(oe=()=>u([]),e[56]=oe):oe=e[56];const me=h.length===0?"font-medium text-foreground":"text-muted-foreground";let ue;e[57]!==me?(ue=te("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",me),e[57]=me,e[58]=ue):ue=e[58];const ye=VD[c];let Le;e[59]!==ue||e[60]!==ye?(Le=i.jsx("button",{type:"button",onClick:oe,className:ue,children:ye}),e[59]=ue,e[60]=ye,e[61]=Le):Le=e[61];let Ce;e[62]!==h?(Ce=h.map((he,Pe)=>{const Me=Pe===h.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[i.jsx(vn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>u(h.slice(0,Pe+1)),className:te("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",Me?"font-medium text-foreground":"text-muted-foreground"),children:Ra(he,Pe)})]},`${he}-${Pe}`)}),e[62]=h,e[63]=Ce):Ce=e[63];let ze;e[64]!==Le||e[65]!==Ce?(ze=i.jsxs("nav",{"aria-label":"Folder breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[Le,Ce]}),e[64]=Le,e[65]=Ce,e[66]=ze):ze=e[66];let Te;e[67]===Symbol.for("react.memo_cache_sentinel")?(Te=i.jsx(p9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[67]=Te):Te=e[67];let Se;e[68]===Symbol.for("react.memo_cache_sentinel")?(Se=he=>g(he.target.value),e[68]=Se):Se=e[68];const be=`Search all ${c}…`,Re=`Search all ${c}`;let Ve;e[69]!==p||e[70]!==be||e[71]!==Re?(Ve=i.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Te,i.jsx("input",{type:"text",value:p,onChange:Se,placeholder:be,"aria-label":Re,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[69]=p,e[70]=be,e[71]=Re,e[72]=Ve):Ve=e[72],e[73]!==ze||e[74]!==Ve?(E=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[ze,Ve]}),e[73]=ze,e[74]=Ve,e[75]=E):E=e[75],A=ti,I="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",D="mx-auto w-full max-w-4xl px-6 py-5",P=X?H.length===0?i.jsx(Un,{title:`No ${c} match "${p.trim()}"`,description:"Search covers every folder — try a different term."}):i.jsx("div",{className:"flex flex-col gap-1",children:H.map(he=>i.jsx(Xs,{icon:T,accent:he.savedKey!==void 0?"global":void 0,title:he.title,subtitle:he.resolveType,active:!1,onClick:()=>q(he)},he.savedKey??he.resolveType))}):J.length===0&&K.length===0&&F.length===0?i.jsx(Un,{title:`No ${c} here`,description:h.length===0?"Start the preview dev server so its manifest loads.":"This folder is empty."}):i.jsxs(i.Fragment,{children:[J.length>0&&i.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:J.map(he=>{const Pe=AD(he.name,h.length);return i.jsxs("button",{type:"button",onClick:()=>u([...h,he.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[i.jsx(Pe,{size:18,className:"shrink-0 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium",children:Ra(he.name,h.length)}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[he.count," ",he.count===1?N:c,he.savedCount>0&&i.jsxs(i.Fragment,{children:[" · ",he.savedCount," saved"]})]})]})]},he.name)})}),(K.length>0||F.length>0)&&i.jsxs("div",{className:te("flex flex-col gap-1",J.length>0&&"mt-4"),children:[K.map(he=>{const Pe=Y.get(he.resolveType)??[],Me=x.has(he.resolveType);return i.jsxs("div",{className:"flex flex-col",children:[i.jsx(Xs,{icon:T,title:he.title,subtitle:he.resolveType,active:!1,onClick:()=>q(he)}),Pe.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>L(he.resolveType),"aria-expanded":Me,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:V9},children:[Me?i.jsx(ts,{size:12,className:"shrink-0"}):i.jsx(vn,{size:12,className:"shrink-0"}),Me?"Hide saved":"See saved"," (",Pe.length,")"]}),Me&&i.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Pe.map(xe=>i.jsx(Xs,{icon:T,accent:"global",title:xe.title,subtitle:xe.resolveType,active:!1,onClick:()=>q(xe)},xe.savedKey))})]})]},he.resolveType)}),F.map(he=>i.jsx(Xs,{icon:T,accent:"global",title:he.title,subtitle:he.resolveType,active:!1,onClick:()=>q(he)},he.savedKey))]})]})}e[10]=T,e[11]=r,e[12]=l,e[13]=c,e[14]=a,e[15]=x,e[16]=s,e[17]=h,e[18]=o,e[19]=S,e[20]=C,e[21]=p,e[22]=f,e[23]=N,e[24]=n,e[25]=A,e[26]=E,e[27]=R,e[28]=D,e[29]=P,e[30]=I,e[31]=O}else A=e[25],E=e[26],R=e[27],D=e[28],P=e[29],I=e[30],O=e[31];if(R!==Symbol.for("react.early_return_sentinel"))return R;let B;e[76]!==D||e[77]!==P?(B=i.jsx("div",{className:D,children:P}),e[76]=D,e[77]=P,e[78]=B):B=e[78];let z;e[79]!==A||e[80]!==B||e[81]!==I?(z=i.jsx(A,{className:I,children:B}),e[79]=A,e[80]=B,e[81]=I,e[82]=z):z=e[82];let $;return e[83]!==E||e[84]!==z||e[85]!==O?($=i.jsxs("div",{className:O,children:[E,z]}),e[83]=E,e[84]=z,e[85]=O,e[86]=$):$=e[86],$}function ED(t){const[e,s]=t;return{name:e,...s}}function RD(t,e){return t.title.localeCompare(e.title)}function PD(t){const[,e]=t;return e}function ID(t,e){return t.title.localeCompare(e.title)}function DD(t,e){return t.title.localeCompare(e.title)}function OD(t){return{resolveType:t.resolveType,title:t.title,folderPath:Ig(t.resolveType)}}function MD(t){return{resolveType:t.resolveType,title:t.title,folderPath:Ig(t.resolveType),savedKey:t.key}}function $D(){return new Set}function BD(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:r,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}function zD(t){const e=M.c(60),{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,resolveType:c,title:d,defaultBlockId:h,isCreating:u,onCreate:f,onSaveReferencedBlock:m}=t,p=oi(),g=p?.entity?.id===n?p.entity.metadata?.siteSlug??null:null;let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];const[v,_]=k.useState(x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=[],e[1]=b):b=e[1];const[y,L]=k.useState(b),[w,S]=k.useState(0),[j,C]=k.useState(!1);let V;e[2]!==a||e[3]!==c?(V=_n(c,a),e[2]=a,e[3]=c,e[4]=V):V=e[4];const N=V;let T;e[5]!==c?(T=c.split("/").pop()?.replace(/\.tsx?$/,"")??c,e[5]=c,e[6]=T):T=e[6];const A=T,E=o??void 0;let R;e[7]!==g||e[8]!==r||e[9]!==s||e[10]!==E||e[11]!==n?(R={orgSlug:s,virtualMcpId:n,branch:r,previewUrl:E,siteSlug:g},e[7]=g,e[8]=r,e[9]=s,e[10]=E,e[11]=n,e[12]=R):R=e[12];const D=R;let P;e[13]!==y||e[14]!==d?(P=[d,...y],e[13]=y,e[14]=d,e[15]=P):P=e[15];const I=P;let O;e[16]!==y?(O=ne=>{L(y.slice(0,ne)),S(FD)},e[16]=y,e[17]=O):O=e[17];const B=O;let z;e[18]!==l||e[19]!==v||e[20]!==f?(z=async ne=>{const le=vu(ne,l);if(le){de.error(le);return}await f(ne,v),C(!1)},e[18]=l,e[19]=v,e[20]=f,e[21]=z):z=e[21];const $=z;let U;e[22]!==B||e[23]!==I?(U=i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:I.map((ne,le)=>{const G=le===I.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[le>0&&i.jsx(vn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>B(le),title:ne,className:te("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",G?"font-medium text-foreground":"text-muted-foreground"),children:ne})]},`${ne}-${le}`)})}),e[22]=B,e[23]=I,e[24]=U):U=e[24];let W;e[25]===Symbol.for("react.memo_cache_sentinel")?(W=()=>C(!0),e[25]=W):W=e[25];let X;e[26]===Symbol.for("react.memo_cache_sentinel")?(X=i.jsx(Gd,{size:14}),e[26]=X):X=e[26];let H;e[27]!==u?(H=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{size:"icon",className:"size-8 shrink-0",disabled:u,onClick:W,"aria-label":"Save as global section",children:X})}),e[27]=u,e[28]=H):H=e[28];let Z;e[29]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx(De,{side:"bottom",children:"Save as global section"}),e[29]=Z):Z=e[29];let K;e[30]!==H?(K=i.jsxs(Oe,{children:[H,Z]}),e[30]=H,e[31]=K):K=e[31];let Y;e[32]!==U||e[33]!==K?(Y=i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[U,K]}),e[32]=U,e[33]=K,e[34]=Y):Y=e[34];let F;e[35]!==A?(F=i.jsxs("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:[A," — edits stay local until you save this as a global section."]}),e[35]=A,e[36]=F):F=e[36];let Q;e[37]!==Y||e[38]!==F?(Q=i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[Y,F]}),e[37]=Y,e[38]=F,e[39]=Q):Q=e[39];let J;e[40]!==l||e[41]!==y||e[42]!==w||e[43]!==v||e[44]!==a||e[45]!==m||e[46]!==D||e[47]!==N?(J=i.jsx(ti,{className:"min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsx("div",{className:"mx-auto max-w-2xl",children:N?i.jsx(Pn,{schema:N,value:v,onChange:ne=>_(ne),basePath:"",breadcrumbPath:y,onBreadcrumbChange:L,meta:a,decofile:l,onSaveReferencedBlock:m,sandbox:D},w):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),e[40]=l,e[41]=y,e[42]=w,e[43]=v,e[44]=a,e[45]=m,e[46]=D,e[47]=N,e[48]=J):J=e[48];let ee;e[49]!==Q||e[50]!==J?(ee=i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[Q,J]}),e[49]=Q,e[50]=J,e[51]=ee):ee=e[51];let q;e[52]!==h||e[53]!==$||e[54]!==u||e[55]!==j?(q=i.jsx(bu,{open:j,onOpenChange:C,defaultBlockId:h,isPending:u,onSubmit:$}),e[52]=h,e[53]=$,e[54]=u,e[55]=j,e[56]=q):q=e[56];let se;return e[57]!==ee||e[58]!==q?(se=i.jsxs("div",{className:"flex h-full w-full min-w-0",children:[ee,q]}),e[57]=ee,e[58]=q,e[59]=se):se=e[59],se}function FD(t){return t+1}function UD(t,e){const s={__resolveType:t},n=mg([s],e)[0];return n?TP(s,n,e):null}function HD({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:r,decofile:o,blockKey:a,onSaveReferencedBlock:l}){const c=oi(),d=c?.entity?.id===e?c.entity.metadata?.siteSlug??null:null,[h]=k.useState(()=>UD(a,o)),[u,f]=k.useState(h?.data??{}),[m,p]=k.useState([]),[g,x]=k.useState(0),[v,_]=k.useState(!1),[b,y]=k.useState(null),L=b!==null,{save:w,flush:S}=hg({orgSlug:t,virtualMcpId:e,branch:s}),j=h?.resolveType?_n(h.resolveType,r):null,C=o[a],V=C?oc(a,C):a,N={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:d},T=P=>{f(P),w(a,P)},A=()=>{L?(y(null),_(!1),x(P=>P+1)):y(JSON.stringify(u,null,2))},E=P=>{const I=P??"";try{const O=JSON.parse(I);if(O&&typeof O=="object"&&!Array.isArray(O)){_(!1),T(O);return}_(!0)}catch{_(!0)}},R=[V,...m],D=P=>{p(m.slice(0,P)),x(I=>I+1)};return i.jsx("div",{className:"flex h-full w-full min-w-0",children:i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[i.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:V9},"aria-hidden":!0}),i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:R.map((P,I)=>{const O=I===R.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[I>0&&i.jsx(vn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>D(I),title:P,className:te("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",O?"font-medium text-foreground":"text-muted-foreground"),children:P})]},`${P}-${I}`)})}),i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:L?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:A,"aria-label":L?"Close JSON editor":"Edit as JSON","aria-pressed":L,children:L?i.jsx(js,{size:14}):i.jsx(Qo,{size:14})})}),i.jsx(De,{side:"bottom",children:L?"Close JSON editor":"Edit as JSON"})]})]}),i.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:"Global section — changes save automatically and apply everywhere it's used."})]}),i.jsxs("div",{className:"relative min-h-0 flex-1",children:[i.jsx(ti,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsx("div",{className:"mx-auto max-w-2xl",children:j?i.jsx(Pn,{schema:j,value:u,onChange:P=>T(P),basePath:"",breadcrumbPath:m,onBreadcrumbChange:p,meta:r,decofile:o,onSaveReferencedBlock:l,sandbox:N},g):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No editable fields for this section."})})})}),b!==null&&i.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[v&&i.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(ia,{language:"json",height:"100%",code:b,onChange:E,onSave:P=>{E(P),S()}})})]})]})]})})}function KD(t){const e=M.c(30),{selection:s,orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Un,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,x=s.title;let v;e[1]!==s.title?(v=n4(s.title),e[1]=s.title,e[2]=v):v=e[2];let _;e[3]!==h||e[4]!==s.resolveType?(_=(y,L)=>h(s.resolveType,y,L),e[3]=h,e[4]=s.resolveType,e[5]=_):_=e[5];let b;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==l||e[10]!==u||e[11]!==n||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==v||e[17]!==_||e[18]!==r?(b=i.jsx(zD,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:g,title:x,defaultBlockId:v,isCreating:d,onCreate:_,onSaveReferencedBlock:u},p),e[6]=o,e[7]=c,e[8]=d,e[9]=l,e[10]=u,e[11]=n,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=v,e[17]=_,e[18]=r,e[19]=b):b=e[19],b}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==c||e[22]!==l||e[23]!==u||e[24]!==n||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=i.jsx(HD,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=c,e[22]=l,e[23]=u,e[24]=n,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}const Kf="__all__",S4={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},WD={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},Wf=k.forwardRef(function(e,s){const n=M.c(20);let r,o,a,l,c;n[0]!==e?({icon:r,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(r=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=te("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==r?(u=i.jsx(r,{size:14,className:"shrink-0"}),n[9]=r,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(ts,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=i.jsxs(re,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function w4(t){const e=M.c(2),{count:s}=t;let n;return e[0]!==s?(n=i.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function qD(t){const e=M.c(60),{categories:s,authors:n,categoryFilter:r,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t;let h;if(e[0]!==s||e[1]!==r){let W;e[3]!==r?(W=X=>X.slug===r,e[3]=r,e[4]=W):W=e[4],h=s.find(W),e[0]=s,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;if(e[5]!==o||e[6]!==n){let W;e[8]!==o?(W=X=>X.email===o,e[8]=o,e[9]=W):W=e[9],f=n.find(W),e[5]=o,e[6]=n,e[7]=f}else f=e[7];const m=f,p=!!(r||o),g=u?.name??m?.name??"Filter",x=r?`cat:${r}`:o?`author:${o}`:Kf;let v;e[10]!==c||e[11]!==l?(v=()=>{l(null),c(null)},e[10]=c,e[11]=l,e[12]=v):v=e[12];const _=v;let b;e[13]!==_||e[14]!==c||e[15]!==l?(b=W=>{W.startsWith("cat:")?(c(null),l(W.slice(4))):W.startsWith("author:")?(l(null),c(W.slice(7))):_()},e[13]=_,e[14]=c,e[15]=l,e[16]=b):b=e[16];const y=b;let L;e[17]!==g||e[18]!==p?(L=i.jsx(ls,{asChild:!0,children:i.jsx(Wf,{icon:eb,active:p,value:g,className:"min-w-0 shrink"})}),e[17]=g,e[18]=p,e[19]=L):L=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(ro,{children:"Filter by"}),e[20]=w):w=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(sa,{value:Kf,children:"All posts"}),e[21]=S):S=e[21];let j;e[22]!==s.length?(j=s.length>0&&i.jsx(ro,{className:"text-muted-foreground/70",children:"Category"}),e[22]=s.length,e[23]=j):j=e[23];let C;e[24]!==s?(C=s.map(JD),e[24]=s,e[25]=C):C=e[25];let V;e[26]!==n.length?(V=n.length>0&&i.jsx(ro,{className:"text-muted-foreground/70",children:"Author"}),e[26]=n.length,e[27]=V):V=e[27];let N;e[28]!==n?(N=n.map(YD),e[28]=n,e[29]=N):N=e[29];let T;e[30]!==x||e[31]!==y||e[32]!==V||e[33]!==N||e[34]!==j||e[35]!==C?(T=i.jsxs(cs,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[w,i.jsxs(N0,{value:x,onValueChange:y,children:[S,j,C,V,N]})]}),e[30]=x,e[31]=y,e[32]=V,e[33]=N,e[34]=j,e[35]=C,e[36]=T):T=e[36];let A;e[37]!==T||e[38]!==L?(A=i.jsxs(as,{children:[L,T]}),e[37]=T,e[38]=L,e[39]=A):A=e[39];let E;e[40]!==_||e[41]!==p?(E=p&&i.jsx(XD,{label:"Clear filter",onClick:_}),e[40]=_,e[41]=p,e[42]=E):E=e[42];const R=WD[a];let D;e[43]!==R?(D=i.jsx(ls,{asChild:!0,children:i.jsx(Wf,{icon:tb,active:!0,value:R})}),e[43]=R,e[44]=D):D=e[44];let P;e[45]===Symbol.for("react.memo_cache_sentinel")?(P=i.jsx(ro,{children:"Sort by"}),e[45]=P):P=e[45];let I;e[46]!==d?(I=W=>d(W),e[46]=d,e[47]=I):I=e[47];let O;e[48]===Symbol.for("react.memo_cache_sentinel")?(O=Object.keys(S4),e[48]=O):O=e[48];let B;e[49]===Symbol.for("react.memo_cache_sentinel")?(B=O.map(GD),e[49]=B):B=e[49];let z;e[50]!==a||e[51]!==I?(z=i.jsxs(cs,{align:"end",className:"w-44",children:[P,i.jsx(N0,{value:a,onValueChange:I,children:B})]}),e[50]=a,e[51]=I,e[52]=z):z=e[52];let $;e[53]!==D||e[54]!==z?($=i.jsx("div",{className:"ml-auto shrink-0",children:i.jsxs(as,{children:[D,z]})}),e[53]=D,e[54]=z,e[55]=$):$=e[55];let U;return e[56]!==A||e[57]!==E||e[58]!==$?(U=i.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[A,E,$]}),e[56]=A,e[57]=E,e[58]=$,e[59]=U):U=e[59],U}function GD(t){return i.jsx(sa,{value:t,children:S4[t]},t)}function YD(t){return i.jsxs(sa,{value:`author:${t.email}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(w4,{count:t.count})]},`author:${t.email}`)}function JD(t){return i.jsxs(sa,{value:`cat:${t.slug}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(w4,{count:t.count})]},`cat:${t.slug}`)}function XD(t){const e=M.c(4),{label:s,onClick:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(js,{size:12}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==n?(o=i.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:r}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function QD(t){const e=M.c(12),{checked:s,disabled:n,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==n||e[4]!==o||e[5]!==a?(l=i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:ZD,children:i.jsx(kr,{checked:s,disabled:n,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a,e[6]=l):l=e[6];const c=s?"Deselect all":"Select all";let d;e[7]!==c?(d=i.jsx(De,{side:"bottom",children:c}),e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==l||e[10]!==d?(h=i.jsxs(Oe,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=h):h=e[11],h}function ZD(t){return t.stopPropagation()}function eO(t){const e=M.c(25),{count:s,allSelected:n,onToggleSelectAll:r,onDelete:o,onExit:a}=t;let l;e[0]!==n||e[1]!==r?(l=i.jsx(QD,{checked:n,onToggle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;e[3]!==s?(c=i.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];const d=s===0;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(ks,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==d?(u=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:d,onClick:o,"aria-label":"Delete selected posts",children:h})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(De,{side:"bottom",children:"Delete selected"}),e[9]=f):f=e[9];let m;e[10]!==u?(m=i.jsxs(Oe,{children:[u,f]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(js,{size:14}),e[12]=p):p=e[12];let g;e[13]!==a?(g=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":"Exit selection",children:p})}),e[13]=a,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(De,{side:"bottom",children:"Exit selection"}),e[15]=x):x=e[15];let v;e[16]!==g?(v=i.jsxs(Oe,{children:[g,x]}),e[16]=g,e[17]=v):v=e[17];let _;e[18]!==v||e[19]!==m?(_=i.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,v]}),e[18]=v,e[19]=m,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==_||e[23]!==c?(b=i.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[l,c,_]}),e[21]=l,e[22]=_,e[23]=c,e[24]=b):b=e[24],b}function Yr(t){const e=M.c(20),{onDuplicate:s,onRename:n,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(ls,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:tO,children:i.jsx(ni,{size:14})})}),e[0]=c):c=e[0];let d;e[1]!==n?(d=n&&i.jsxs(Ge,{onClick:n,children:[i.jsx(x9,{size:14}),"Rename"]}),e[1]=n,e[2]=d):d=e[2];let h;e[3]!==s?(h=s&&i.jsxs(Ge,{onClick:s,children:[i.jsx(Ds,{size:14}),"Duplicate"]}),e[3]=s,e[4]=h):h=e[4];let u;e[5]!==r?(u=r&&i.jsxs(i.Fragment,{children:[i.jsx(Xi,{}),i.jsxs(Ge,{onClick:r,className:"cursor-pointer text-success focus:text-success",children:[i.jsx(m9,{size:14}),"Add variant"]})]}),e[5]=r,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==a?(f=(o||a)&&i.jsxs(i.Fragment,{children:[i.jsx(Xi,{}),o&&i.jsxs(Ge,{onClick:o,children:[i.jsx(tl,{size:14}),"Edit SEO"]}),a&&i.jsxs(Ge,{onClick:a,children:[i.jsx(Qo,{size:14}),"View JSON"]})]}),e[7]=o,e[8]=a,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Xi,{}),e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(ks,{size:14}),e[11]=p):p=e[11];let g;e[12]!==l?(g=i.jsxs(Ge,{onClick:l,className:"text-destructive focus:text-destructive",children:[p,"Delete"]}),e[12]=l,e[13]=g):g=e[13];let x;return e[14]!==d||e[15]!==h||e[16]!==u||e[17]!==f||e[18]!==g?(x=i.jsxs(as,{children:[c,i.jsxs(cs,{align:"end",className:"w-44",children:[d,h,u,f,m,g]})]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f,e[18]=g,e[19]=x):x=e[19],x}function tO(t){return t.stopPropagation()}function sO(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function nO(t){const e=new Map;for(const s of t){const n=sO(s.resolveType),r=e.get(n);r?r.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function qf(t){const e=M.c(8),{icon:s,label:n,className:r}=t;let o;e[0]!==r?(o=te("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=i.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}const Gf=k.lazy(()=>Os(()=>import("./app-editor-C5o42oU3.js"),__vite__mapDeps([158,1,2,18,50,51,52,17,3,53,54,55,56,57,58,59,60,61,31,62,48,63,64,65,66,67,5,16,19,4,6,7,8,9,10,11,12,13,14,15,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,106,107,108,109,110,111,112,113,114,115,116,103,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.AppEditor}))),iO=k.lazy(()=>Os(()=>import("./post-editor-CEMsCtDO.js"),__vite__mapDeps([159,1,2,5,32,4,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,102,101,160,131,134,118,119,76,117,121,128,52,161,91,50,51,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,77,78,79,80,81,82,83,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,162,163,107,108,109,110,111,112,113,114,115,116,103,120,122,123,124,125,126,127,129,130,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.PostEditor}))),rO=k.lazy(()=>Os(()=>import("./record-editor-BEQrV1d8.js"),__vite__mapDeps([164,1,2,102,101,51,52,17,3,128,162,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,163,82,83,78,57,58,79,80,81,69,59,56,84,85,77,86,87,50,53,54,55,60,61,62,63,64,65,66,67,68,70,71,72,73,74,75,76,88,89,90,91,92,93,94,95,96,97,98,99,100,107,108,109,110,111,112,113,114,115,116,103,117,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.RecordEditor}))),oO=k.lazy(()=>Os(()=>import("./category-editor-omUhw8hw.js"),__vite__mapDeps([165,1,2,10,14,32,4,5,6,7,8,9,11,12,13,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,139,102,101,161,118,119,76,117,91,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,77,78,79,80,81,82,83,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,162,163,107,108,109,110,111,112,113,114,115,116,103,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,140,141,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.CategoryEditor}))),aO=k.lazy(()=>Os(()=>import("./bulk-category-panel-CgSvwA00.js"),__vite__mapDeps([166,1,2,14,48,101,167,19,51,52,17,3])).then(t=>({default:t.BulkCategoryPanel}))),lO=k.lazy(()=>Os(()=>import("./sections-editor-Dpco23Fg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SectionsEditor}))),cO=k.lazy(()=>Os(()=>import("./seo-editor-pHkOR1VP.js"),__vite__mapDeps([168,1,2,18,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,104,105,107,108,109,110,111,112,113,114,115,116,103,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155])).then(t=>({default:t.SeoEditor}))),dO=k.lazy(()=>Os(()=>import("./variant-calendar-Bhk3fwgs.js"),__vite__mapDeps([169,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,3,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,101,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,102,105,170])).then(t=>({default:t.VariantCalendar}))),uO=k.lazy(()=>Os(()=>import("./redirect-editor-Bh-8Ulfx.js"),__vite__mapDeps([171,1,2,134,17,102,101,51,52,3,163,7,82,83,78,57,58,79,80,81,69,59,56,84,85,77,86,87,50,53,54,55,60,61,31,62,48,63,64,65,66,67,5,16,19,4,6,8,9,10,11,12,13,14,15,18,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49,68,70,71,72,73,74,75,76,88,89,90,91,92,93,94,95,96,97,98,99,100,107,108,109,110,111,112,113,114,115,116,103,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.RedirectEditor})));function l0(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function hO(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function fO(t){const e=M.c(21),{mode:s}=t,n=s===void 0?"content":s,r=oi(),{data:o}=Ai.useSession(),{currentBranch:a}=Qt(),{org:l}=Ee(),c=r?.entity?.id??null,d=o?.user?.id,h=r?.entity?.metadata,u=d&&a?Bl(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(mO)??f[0])?.previewUrl??null,g=$s(),x=r?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:Go,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const _=ut(v),b=S9(_);let y;e[3]!==a||e[4]!==b||e[5]!==c?(y=()=>{if(!c)return;const V={virtualMcpId:c};a&&(V.branch=a),b.mutate(V)},e[3]=a,e[4]=b,e[5]=c,e[6]=y):y=e[6];const L=y,w=!!c&&!!a&&xl.isStopped(c,a),S=J2({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:b.isError&&b.error?Q2(b.error.message):null});if(S.kind!=="iframe"){const V=`/${l.slug}/settings/connections`;let N;return e[7]!==S||e[8]!==V||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(N=i.jsx(zE,{state:S,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:V}),e[7]=S,e[8]=V,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=N):N=e[12],N}if(!c||!a){let V;return e[13]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(Un,{title:"Waiting for sandbox context…"}),e[13]=V):V=e[13],V}const j=g.lifecycle.phase==="running";let C;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==j||e[19]!==c?(C=i.jsx(gO,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n,devServerReady:j}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=j,e[19]=c,e[20]=C):C=e[20],C}function mO(t){return t.sandboxProviderKind!=="user-desktop"}const Yf=2e3,pO=15;function Jf(t,e,s,n){return typeof e!="string"||s&&(Mg(e,s,n)||t.state.dataUpdateCount>=pO)?!1:Yf}function gO({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:r,devServerReady:o}){const a=du(),l={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},c=kE(e),{data:d,isLoading:h}=sc(l,{fetchEnabled:o}),[u,f]=k.useState("pages"),[m,p]=k.useState(()=>r==="blocks"?l0(a.state.target):null),[g,x]=k.useState(()=>r==="blocks"?a.state.editSeoPageKey:null),v=hO(a.state.target),[_,b]=k.useState(v);if(r==="blocks"&&_!==v){b(v);const ie=l0(a.state.target);p(ie),(ie?.collection==="pages"||ie?.collection==="sections")&&f(ie.collection)}const[y,L]=k.useState(a.state.editSeoPageKey);if(r==="blocks"&&y!==a.state.editSeoPageKey&&(L(a.state.editSeoPageKey),a.state.editSeoPageKey)){const ie=a.state.target;ie?.kind==="page"&&(f("pages"),p(l0(ie)),x(ie.key))}const[w,S]=k.useState(""),[j,C]=k.useState(null),[V,N]=k.useState(null),[T,A]=k.useState("date-desc"),[E,R]=k.useState(()=>new Set),[D,P]=k.useState(null),I=()=>{R(new Set),P(null)},O=ie=>{p(ie),x(null),!(r!=="blocks"||!ie)&&(ie.collection==="pages"?a.selectTarget({kind:"page",key:ie.key,path:ie.path}):ie.collection==="sections"&&a.selectTarget({kind:"section",key:ie.key}))},[B,z]=k.useState(u);B!==u&&(z(u),S(""),C(null),N(null),A("date-desc"),R(new Set),P(null));const{data:$,isLoading:U,isFetching:W}=nc(l,{fetchEnabled:o,refetchInterval:ie=>{const je=ie.state.data;if(u==="apps"&&m&&m.collection==="apps"){const Ue=d?.[m.key];return Jf(ie,typeof Ue?.__resolveType=="string"?Ue.__resolveType:void 0,je)}if(u==="site"&&d){const Ue=je?O0(d,je):null,We=d.site,ft=Ue?.resolveType??(typeof We?.__resolveType=="string"?We.__resolveType:void 0);return Jf(ie,ft,je,["seo"])}return!1}}),X=(ie,je)=>!Mg(ie,$,je)&&(U||W),{catalog:H,isLoading:Z}=$E($??void 0,d??void 0,{enabled:u==="apps"}),K=vc(l),Y=AE(l),F=vR({...l,packagePath:c}),Q=bR({...l,packagePath:c}),[J,ee]=k.useState(null),[q,se]=k.useState(),[ne,le]=k.useState(null),[G,oe]=k.useState(null),[me,ue]=k.useState(null);if(h||U)return i.jsx("div",{className:"h-full w-full flex items-center justify-center",children:i.jsx(Xe,{size:20,className:"animate-spin text-muted-foreground"})});if(!d||!$)return i.jsx(Un,{title:"Could not load site data."});const ye=D9(d).sort((ie,je)=>ie.name.localeCompare(je.name)),Le=Ip(d).sort((ie,je)=>ie.from.localeCompare(je.from)),Ce=O9(d,$),ze=u==="sections"?HS($):[],Te=O0(d,$),Se=Hg(d),be=uu.some(ie=>Se[ie].length>0),Re=So(u)?Se[u]:[],Ve=(be?zo(d,"categories"):[]).map(({key:ie,payload:je})=>{const Ue=typeof je.slug=="string"?je.slug:"",We=typeof je.name=="string"?je.name:"";return{slug:Ue||ie,name:We||Ue||ie}}).filter(ie=>ie.slug).sort((ie,je)=>ie.name.localeCompare(je.name)),he=u==="posts"&&(E.size>0||D!==null),Pe=he?Wg(d).filter(ie=>E.has(ie.key)):[],Me=mf($,"loaders"),xe=mf($,"actions");if(!I9(d,$)&&!be&&Me===0&&xe===0)return i.jsx(Un,{icon:Sn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Ae={pages:ye.length,sections:Ce.length,apps:H.length,loaders:Me,actions:xe,redirects:Le.length,posts:Se.posts.length,authors:Se.authors.length,categories:Se.categories.length},pe=new Set(ye.map(ie=>Wn(ie.path))),ke=new Set(ye.map(ie=>ie.name)),$e=new Set(Ce.map(ie=>ie.name)),ge=async ie=>{const je=d[ie.key];if(!je)return;const Ue=vg(d,ie.key),We=bg(d,ie.key,Math.max(0,Ue-1)),ft=iT(je.sections,We);if(ft)try{await K.mutateAsync({blockKey:ie.key,data:{...je,sections:ft}}),de.success(`Variant added to "${ie.name}"`),p({collection:"pages",key:ie.key,path:ie.path})}catch(Lt){de.error(Lt instanceof Error?Lt.message:"Could not add variant")}},Ke=()=>{se(void 0),ee({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},gt=ie=>{se(void 0),ee({mode:"duplicate",sourceKey:ie.key,initialName:_f(ke,ie.name),initialPath:FE(pe,ie.path)})},nt=ie=>{se(void 0),ee({mode:"rename",sourceKey:ie.key,initialName:ie.name,initialPath:ie.path})},lt=async ie=>{if(!J)return;const{mode:je,sourceKey:Ue}=J;try{if(je==="create"){let We;if(ie.templateKey){const Lt=d[ie.templateKey];if(!Lt)throw new Error("Selected template no longer exists.");We={...Lt,name:ie.name,path:ie.path}}else We=KE(ie.name,ie.path);const ft=qE(d,ie.name);await K.mutateAsync({blockKey:ft,data:We}),de.success(`Created "${ie.name}"`),p({collection:"pages",key:ft,path:ie.path})}else if(je==="duplicate"&&Ue){const We=d[Ue];if(!We)throw new Error("Source page not found");const{key:ft,data:Lt}=HE({source:We,pages:ye,newName:ie.name,newPath:ie.path});await K.mutateAsync({blockKey:ft,data:Lt}),de.success(`Duplicated as "${ie.name}"`),p({collection:"pages",key:ft,path:ie.path})}else if(je==="rename"&&Ue){const We=d[Ue];if(!We)throw new Error("Page not found");const ft={...We,name:ie.name,path:ie.path};await K.mutateAsync({blockKey:Ue,data:ft}),de.success("Page updated"),m?.collection==="pages"&&m.key===Ue&&p({collection:"pages",key:Ue,path:ie.path})}ee(null)}catch(We){se(We instanceof Error?We.message:"Save failed")}},qe=({path:ie})=>{if(!J)return null;const je=Wn(ie);return(J.mode==="rename"?Wn(J.initialPath):null)!==je&&pe.has(je)?`A page with path "${ie}" already exists.`:null},Rt=async(ie,je,Ue)=>{await K.mutateAsync({blockKey:je,data:{...Ue,name:je,__resolveType:ie}}),de.success(`Created section "${je}"`),p({collection:"sections",key:je})},ct=Fg((ie,je)=>K.mutate({blockKey:ie,data:je})),Ye=async ie=>{const je=d[ie.key];if(!je){de.error("Section not found.");return}const Ue=UE(d,ie.key),We=_f($e,ie.name),ft={...je,name:We};try{await K.mutateAsync({blockKey:Ue,data:ft}),de.success(`Duplicated "${ie.name}"`),p({collection:"sections",key:Ue})}catch(Lt){de.error(Lt instanceof Error?Lt.message:"Duplicate failed")}},ot=async ie=>{if(!ne)return;const je=d[ne];if(!je){de.error("Section not found.");return}try{await K.mutateAsync({blockKey:ne,data:{...je,name:ie}}),de.success("Section renamed"),le(null)}catch(Ue){de.error(Ue instanceof Error?Ue.message:"Rename failed")}},ht=async()=>{const ie="/redirect-from",je=XS(d,ie),Ue=GS({from:ie,to:"/redirect-to",type:"temporary",discardQueryParameters:!1});try{await K.mutateAsync({blockKey:je,data:Ue}),de.success("Created redirect"),p({collection:"redirects",key:je})}catch(We){de.error(We instanceof Error?We.message:"Could not create redirect")}},ae=async ie=>{const je=Sf(d,ie),Ue=ka(je,ie,cR(ie));try{await F.mutateAsync({blockKey:je,data:Ue}),de.success(`Created ${Lo[ie]}`),p({collection:ie,key:je})}catch(We){de.error(We instanceof Error?We.message:"Could not create")}},Fe=async ie=>{const je=d[ie.key];if(!je){de.error("Record not found.");return}const Ue=Sf(d,ie.kind),We=ie.kind==="posts"?"title":"name",ft={...structuredClone(Ka(je,ie.kind)),[We]:`${ie.label} (copy)`};try{await F.mutateAsync({blockKey:Ue,data:ka(Ue,ie.kind,ft)}),de.success(`Duplicated "${ie.label}"`),p({collection:ie.kind,key:Ue})}catch(Lt){de.error(Lt instanceof Error?Lt.message:"Duplicate failed")}},Ze=ie=>{R(je=>{const Ue=new Set(je);return Ue.has(ie)?Ue.delete(ie):Ue.add(ie),Ue})},mt=ie=>{f("posts"),z("posts"),p(null),x(null),S(""),C(null),N(null),A("date-desc"),R(new Set),P(ie||null)},Nt=async(ie,je)=>{const Ue=[...E];let We=0;for(const ft of Ue){const Lt=d[ft],On=Ka(Lt,"posts"),ai=ie==="add"?oR(On,je):aR(On,je);ai!==On&&(await F.mutateAsync({blockKey:ft,data:ka(ft,"posts",Lf(ai))}),We+=1)}return We},ms=async(ie,je)=>{const Ue=E.size;try{const We=await Nt(ie,je),ft=ie==="add"?"Added to":"Moved",Lt=Ue-We;de.success(`${ft} ${We} ${We===1?"post":"posts"}`+(Lt>0?` (${Lt} already set)`:"")),I()}catch(We){de.error(We instanceof Error?We.message:"Bulk update failed")}},Be=async()=>{if(G)try{if(G.kind==="blog-bulk"){for(const We of G.keys)await Q.mutateAsync({blockKey:We});de.success(`Deleted ${G.count} ${G.count===1?"post":"posts"}`),m&&m.collection!=="available-section"&&G.keys.includes(m.key)&&p(null),I(),oe(null);return}const{kind:ie,key:je,label:Ue}=G;if(ie==="blog"){if(G.blogKind==="categories"){const We=Ka(d[je],"categories").slug,ft=typeof We=="string"?We:"";if(ft)for(const{key:Lt,payload:On}of zo(d,"posts")){const ai=lR(On,ft);ai!==On&&await F.mutateAsync({blockKey:Lt,data:ka(Lt,"posts",Lf(ai))})}}await Q.mutateAsync({blockKey:je})}else await Y.mutateAsync({blockKey:je});de.success(`Deleted "${Ue}"`),m&&m.collection!=="available-section"&&m.key===je&&p(null),oe(null)}catch(ie){de.error(ie instanceof Error?ie.message:"Delete failed")}},Pt=Y.isPending||Q.isPending||F.isPending,Bs=G?.kind==="blog"?Lo[G.blogKind]:G?.kind==="blog-bulk"?`${G.count} ${G.count===1?"post":"posts"}`:G?.kind??"item";return i.jsxs("div",{className:"flex h-full w-full",children:[r==="content"&&i.jsx(BE,{active:u,counts:Ae,showBlog:be,onSelect:ie=>{f(ie),p(null),x(null)}}),u!=="seo"&&u!=="site"&&u!=="calendar"&&u!=="loaders"&&u!=="actions"&&i.jsx(xO,{blocksMode:r==="blocks",activeCollection:u,pages:ye,redirects:Le,sections:Ce,availableSections:ze,appCatalog:H,appCatalogLoading:Z,blogEntries:Re,decofile:d,searchQuery:w,onSearchChange:S,postCategoryFilter:j,postAuthorFilter:V,postSort:T,onPostCategoryFilterChange:ie=>{C(ie),R(new Set)},onPostAuthorFilterChange:ie=>{N(ie),R(new Set)},onPostSortChange:A,selectedPostKeys:E,postBulkPanelOpen:he,onTogglePostSelect:Ze,onSelectAllPosts:ie=>R(new Set(ie)),onClearPostSelection:()=>R(new Set),onExitPostSelection:I,onBulkDeletePosts:()=>oe({kind:"blog-bulk",keys:[...E],count:E.size}),selection:m,onSelect:O,onCollectionSelect:ie=>{f(ie),p(null),x(null)},onCreate:()=>{u==="pages"?Ke():u==="redirects"?ht():So(u)&&ae(u)},onDuplicatePage:gt,onRenamePage:nt,onAddPageVariant:ge,onDeletePage:ie=>oe({kind:"page",key:ie.key,label:ie.name}),onEditPageSeo:ie=>{const je={collection:"pages",key:ie.key,path:ie.path};p(je),x(ie.key),r==="blocks"&&a.editSeo({kind:"page",key:ie.key,path:ie.path})},onViewPageJson:ie=>ue(ie.key),onDuplicateSection:Ye,onRenameSection:ie=>le(ie.key),onDeleteSection:ie=>oe({kind:"section",key:ie.key,label:ie.name}),onDeleteRedirect:ie=>oe({kind:"redirect",key:ie.key,label:ie.from||ie.key}),onDuplicateBlog:Fe,onDeleteBlog:ie=>oe({kind:"blog",blogKind:ie.kind,key:ie.key,label:ie.label})}),i.jsx("div",{className:"flex-1 min-w-0",children:u==="loaders"||u==="actions"?i.jsx(TD,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:$,decofile:d,kind:u}):i.jsx(k.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(Xe,{size:20,className:"animate-spin text-muted-foreground"})}),children:u==="calendar"?i.jsx(dO,{decofile:d}):u==="site"?Te?i.jsx(Gf,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:Te.key,block:d[Te.key],decofile:d,meta:$,title:"Site",excludeFields:["seo"],schemaPending:X(Te.resolveType,["seo"]),previewBaseUrl:n},`site:${Te.key}`):i.jsx(Un,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):u==="seo"?i.jsx(cO,{orgSlug:t,virtualMcpId:e,branch:s,decofile:d,meta:$,target:{kind:"site"},previewBaseUrl:n}):u==="sections"?i.jsx(KD,{selection:m?.collection==="sections"||m?.collection==="available-section"?m:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:$,decofile:d,isCreating:K.isPending,onCreateAvailable:Rt,onSaveReferencedBlock:ct}):he?i.jsx(aO,{posts:Pe,categories:Ve,initialSlug:D,isPending:F.isPending,onApply:(ie,je)=>{ms(ie,je)},onClose:I},D??"selection"):m&&m.collection!=="available-section"?m.collection==="apps"?i.jsx(Gf,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:$,previewBaseUrl:n,schemaPending:X(typeof d[m.key]?.__resolveType=="string"?String(d[m.key].__resolveType):void 0)},`app:${m.key}`):m.collection==="posts"?i.jsx(iO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:$,previewBaseUrl:n},`post:${m.key}`):m.collection==="categories"?i.jsx(oO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key],decofile:d,meta:$,onManagePosts:mt,onOpenPost:ie=>{f("posts"),z("posts"),p({collection:"posts",key:ie}),x(null)},previewBaseUrl:n},`category:${m.key}`):m.collection==="authors"?i.jsx(rO,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:m.key,block:d[m.key]},`authors:${m.key}`):m.collection==="redirects"?i.jsx(uO,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:m.key,block:d[m.key]},`redirect:${m.key}`):i.jsx(lO,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:m.collection==="pages"?m.path:"/",activePageBlockKey:m.collection==="pages"?m.key:null,activeGlobalBlockKey:m.collection==="sections"?m.key:null,initialEditSeo:m.collection==="pages"&&g===m.key,onExitSeo:()=>{x(null),r==="blocks"&&a.consumeEditSeo()}},m.collection==="pages"?`page:${m.key}`:`section:${m.key}`):i.jsx(Un,{title:`Select ${So(u)?`a ${Lo[u]}`:u==="pages"?"a page":u==="apps"?"an app":u==="redirects"?"a redirect":"a section"} to edit`,description:u==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),J&&i.jsx(XE,{open:!!J,mode:J.mode,initialName:J.initialName,initialPath:J.initialPath,isPending:K.isPending,error:q,templates:ye,validate:qe,onSubmit:lt,onOpenChange:ie=>{ie||(ee(null),se(void 0))}}),ne&&i.jsx(QE,{open:!!ne,blockKey:ne,initialName:Ce.find(ie=>ie.key===ne)?.name??ne,isPending:K.isPending,onSubmit:ot,onOpenChange:ie=>{ie||le(null)}}),me&&i.jsx(_R,{open:!!me,onOpenChange:ie=>{ie||ue(null)},pageKey:me,decofile:d,onSave:ie=>K.mutateAsync({blockKey:me,data:ie})}),i.jsx(ol,{open:!!G,onOpenChange:ie=>{!ie&&!Pt&&oe(null)},children:i.jsxs(al,{children:[i.jsxs(ll,{children:[i.jsx(cl,{children:`Delete ${Bs}?`}),i.jsx(dl,{children:G?.kind==="section"?`"${G.label}" will be removed. Pages that still reference it will lose this section.`:G?.kind==="blog-bulk"?`${G.count} ${G.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:G?`"${G.label}" will be removed permanently. This can't be undone.`:null})]}),i.jsxs(ul,{children:[i.jsx(hl,{disabled:Pt,children:"Cancel"}),i.jsx(fl,{onClick:ie=>{ie.preventDefault(),Be()},disabled:Pt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Pt?i.jsxs(i.Fragment,{children:[i.jsx(Xe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function xO(t){const e=M.c(88),{blocksMode:s,activeCollection:n,pages:r,redirects:o,sections:a,availableSections:l,appCatalog:c,appCatalogLoading:d,blogEntries:h,decofile:u,searchQuery:f,onSearchChange:m,postCategoryFilter:p,postAuthorFilter:g,postSort:x,onPostCategoryFilterChange:v,onPostAuthorFilterChange:_,onPostSortChange:b,selectedPostKeys:y,postBulkPanelOpen:L,onTogglePostSelect:w,onSelectAllPosts:S,onClearPostSelection:j,onExitPostSelection:C,onBulkDeletePosts:V,selection:N,onSelect:T,onCollectionSelect:A,onCreate:E,onDuplicatePage:R,onRenamePage:D,onAddPageVariant:P,onDeletePage:I,onEditPageSeo:O,onViewPageJson:B,onDuplicateSection:z,onRenameSection:$,onDeleteSection:U,onDeleteRedirect:W,onDuplicateBlog:X,onDeleteBlog:H}=t;let Z,K,Y,F,Q,J,ee,q;if(e[0]!==n||e[1]!==c||e[2]!==d||e[3]!==l||e[4]!==s||e[5]!==h||e[6]!==u||e[7]!==P||e[8]!==V||e[9]!==j||e[10]!==A||e[11]!==E||e[12]!==H||e[13]!==I||e[14]!==W||e[15]!==U||e[16]!==X||e[17]!==R||e[18]!==z||e[19]!==O||e[20]!==C||e[21]!==_||e[22]!==v||e[23]!==b||e[24]!==D||e[25]!==$||e[26]!==m||e[27]!==T||e[28]!==S||e[29]!==w||e[30]!==B||e[31]!==r||e[32]!==g||e[33]!==L||e[34]!==p||e[35]!==x||e[36]!==o||e[37]!==f||e[38]!==a||e[39]!==y||e[40]!==N){const G=f.toLowerCase(),oe=r.filter(ae=>!G||ae.name.toLowerCase().includes(G)||ae.path.toLowerCase().includes(G)),me=o.filter(ae=>!G||ae.from.toLowerCase().includes(G)||ae.to.toLowerCase().includes(G)),ue=a.filter(ae=>!G||ae.name.toLowerCase().includes(G)||ae.key.toLowerCase().includes(G)||ae.resolveType.toLowerCase().includes(G)),ye=l.filter(ae=>!G||ae.title.toLowerCase().includes(G)||ae.resolveType.toLowerCase().includes(G)||(ae.description?.toLowerCase().includes(G)??!1)),Le=nO(ue),Ce=c.filter(ae=>!G||ae.title.toLowerCase().includes(G)||ae.app.toLowerCase().includes(G)||ae.vendor.toLowerCase().includes(G)||ae.category.toLowerCase().includes(G)),ze=h.filter(ae=>!G||ae.label.toLowerCase().includes(G)||ae.subtitle.toLowerCase().includes(G)),Te=n==="posts",Se=yO,be=Te?Wg(u):[],Re=new Map,Ve=new Map;for(const ae of be){for(const Fe of ae.categorySlugs)Re.set(Fe,(Re.get(Fe)??0)+1);for(const Fe of ae.authorEmails)Ve.set(Fe,(Ve.get(Fe)??0)+1)}const he=(Te?zo(u,"categories"):[]).map(ae=>{const{key:Fe,payload:Ze}=ae,mt=Se(Ze.slug)||Fe;return{slug:mt,name:Se(Ze.name)||Se(Ze.slug)||Fe,count:Re.get(mt)??0}}).filter(_O),Pe=(Te?zo(u,"authors"):[]).map(ae=>{const{key:Fe,payload:Ze}=ae,mt=Se(Ze.email);return{email:mt,name:Se(Ze.name)||Se(Ze.email)||Fe,count:Ve.get(mt)??0}}).filter(bO);let Me;e[49]!==p?(Me=ae=>!p||ae.categorySlugs.includes(p),e[49]=p,e[50]=Me):Me=e[50];let xe;e[51]!==g?(xe=ae=>!g||ae.authorEmails.includes(g),e[51]=g,e[52]=xe):xe=e[52];let Ae;e[53]!==x?(Ae=(ae,Fe)=>{if(x==="az")return ae.title.localeCompare(Fe.title);if(x==="za")return Fe.title.localeCompare(ae.title);const Ze=ae.date.localeCompare(Fe.date);return x==="date-asc"?Ze:-Ze},e[53]=x,e[54]=Ae):Ae=e[54];const pe=be.filter(ae=>!G||ae.title.toLowerCase().includes(G)||ae.slug.toLowerCase().includes(G)).filter(Me).filter(xe).sort(Ae),ke=y.size,$e=pe.map(vO),ge=$e.length>0&&$e.every(ae=>y.has(ae)),Ke=ke>0||L,gt=()=>{ge?j():S($e)},nt=`Search ${n}…`,lt=So(n)?`Create new ${Lo[n]}`:n==="redirects"?"Create new redirect":"Create new page",qe=n!=="apps"&&n!=="sections",Rt=s?"w-[240px]":"w-[300px]";e[55]!==Rt?(Q=te("shrink-0 border-r flex flex-col min-h-0",Rt),e[55]=Rt,e[56]=Q):Q=e[56],e[57]!==n||e[58]!==s||e[59]!==A?(J=s&&i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[i.jsxs(re,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("pages"),children:[i.jsx(kn,{size:14}),"Pages"]}),i.jsxs(re,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("sections"),children:[i.jsx(pn,{size:14}),"Sections"]})]}),e[57]=n,e[58]=s,e[59]=A,e[60]=J):J=e[60];let ct;e[61]===Symbol.for("react.memo_cache_sentinel")?(ct=i.jsx(p9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[61]=ct):ct=e[61];let Ye;e[62]!==m?(Ye=ae=>m(ae.target.value),e[62]=m,e[63]=Ye):Ye=e[63];let ot;e[64]!==nt||e[65]!==f||e[66]!==Ye?(ot=i.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[ct,i.jsx("input",{type:"text",value:f,onChange:Ye,placeholder:nt,"aria-label":nt,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[64]=nt,e[65]=f,e[66]=Ye,e[67]=ot):ot=e[67];let ht;e[68]!==lt||e[69]!==E||e[70]!==qe?(ht=qe&&i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:E,"aria-label":lt,children:i.jsx(kt,{size:14})})}),i.jsx(De,{side:"bottom",children:lt})]}),e[68]=lt,e[69]=E,e[70]=qe,e[71]=ht):ht=e[71],e[72]!==ot||e[73]!==ht?(ee=i.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[ot,ht]}),e[72]=ot,e[73]=ht,e[74]=ee):ee=e[74],q=Te&&(Ke?i.jsx(eO,{count:ke,allSelected:ge,onToggleSelectAll:gt,onDelete:V,onExit:C}):i.jsx(qD,{categories:he,authors:Pe,categoryFilter:p,authorFilter:g,sort:x,onCategoryFilterChange:v,onAuthorFilterChange:_,onSortChange:b})),Z=ti,F="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",K="flex flex-col gap-1 p-1.5",Y=n==="pages"?oe.length===0?i.jsx(Fi,{hasItems:r.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):oe.map(ae=>{const Fe=N?.collection==="pages"&&N.key===ae.key,Ze=vg(u,ae.key);return i.jsx(Xs,{icon:kn,title:ae.name,subtitle:ae.path,active:Fe,variantCount:Ze,onClick:()=>T({collection:"pages",key:ae.key,path:ae.path}),menu:i.jsx(Yr,{onDuplicate:()=>R(ae),onRename:()=>D(ae),onAddVariant:()=>P(ae),onEditSeo:()=>O(ae),onViewJson:()=>B(ae),onDelete:()=>I(ae)})},ae.key)}):n==="sections"?ue.length===0&&ye.length===0?i.jsx(Fi,{hasItems:a.length>0||l.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):i.jsxs(i.Fragment,{children:[Le.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(qf,{icon:pn,label:"Saved sections"}),Le.map(ae=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:ae.label}),ae.sections.map(Fe=>{const Ze=N?.collection==="sections"&&N.key===Fe.key;return i.jsx(Xs,{icon:pn,accent:"global",title:Fe.name,subtitle:ae.label,active:Ze,onClick:()=>T({collection:"sections",key:Fe.key}),menu:i.jsx(Yr,{onDuplicate:()=>z(Fe),onRename:()=>$(Fe),onDelete:()=>U(Fe)})},Fe.key)})]},ae.label))]}),ye.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(qf,{icon:kn,label:"Available sections",className:te(Le.length>0&&"mt-3")}),ye.map(ae=>{const Fe=N?.collection==="available-section"&&N.resolveType===ae.resolveType,Ze=ae.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return i.jsx(Xs,{icon:kn,title:ae.title,subtitle:Ze??ae.resolveType,active:Fe,onClick:()=>T({collection:"available-section",resolveType:ae.resolveType,title:ae.title})},ae.resolveType)})]})]}):n==="apps"?d?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Xe,{size:18,className:"animate-spin text-muted-foreground"})}):Ce.length===0?i.jsx(Fi,{hasItems:c.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):Ce.map(ae=>{const Fe=N?.collection==="apps"&&ae.blockKey!==null&&N.key===ae.blockKey;return i.jsx(Xs,{icon:v2,logoUrl:ae.logo,title:ae.title,subtitle:ae.category,active:Fe,trailing:ae.installed?i.jsx("span",{className:"shrink-0 rounded-full bg-success/15 px-1.5 py-0.5 text-[10px] font-medium text-success",children:"Installed"}):void 0,onClick:()=>{if(!ae.installed||!ae.blockKey){de.message(`${ae.title} is not installed on this site.`);return}T({collection:"apps",key:ae.blockKey})}},ae.id)}):n==="redirects"?me.length===0?i.jsx(Fi,{hasItems:o.length>0,emptyLabel:"No redirects yet.",emptyHint:'Click "+" to create your first redirect.'}):me.map(ae=>i.jsx(Xs,{icon:Mm,title:ae.from||"(no source)",subtitle:`→ ${ae.to||"(no target)"}`,active:N?.collection==="redirects"&&N.key===ae.key,trailing:i.jsx(ZE,{type:ae.type}),onClick:()=>T({collection:"redirects",key:ae.key}),menu:i.jsx(Yr,{onDelete:()=>W(ae)})},ae.key)):Te?pe.length===0?i.jsx(Fi,{hasItems:be.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):pe.map(ae=>{const Fe={key:ae.key,kind:"posts",label:ae.title,subtitle:ae.slug};return i.jsx(Xs,{icon:cr,title:ae.title,subtitle:ae.slug||"no slug",invalid:ae.missing.length>0,invalidReason:`Missing: ${ae.missing.join(", ")}`,active:N?.collection==="posts"&&N.key===ae.key,selectable:!0,selectionActive:Ke,selected:y.has(ae.key),onToggleSelect:()=>w(ae.key),onClick:()=>Ke?w(ae.key):T({collection:"posts",key:ae.key}),menu:i.jsx(Yr,{onDuplicate:()=>X(Fe),onDelete:()=>H(Fe)})},ae.key)}):ze.length===0?i.jsx(Fi,{hasItems:h.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${So(n)?Lo[n]:"item"}.`}):ze.map(ae=>{const Fe=N?.collection===ae.kind&&N.key===ae.key;return i.jsx(Xs,{icon:ae.kind==="posts"?cr:ae.kind==="authors"?h9:$m,title:ae.label,subtitle:ae.subtitle,active:Fe,onClick:()=>T({collection:ae.kind,key:ae.key}),menu:i.jsx(Yr,{onDuplicate:()=>X(ae),onDelete:()=>H(ae)})},ae.key)}),e[0]=n,e[1]=c,e[2]=d,e[3]=l,e[4]=s,e[5]=h,e[6]=u,e[7]=P,e[8]=V,e[9]=j,e[10]=A,e[11]=E,e[12]=H,e[13]=I,e[14]=W,e[15]=U,e[16]=X,e[17]=R,e[18]=z,e[19]=O,e[20]=C,e[21]=_,e[22]=v,e[23]=b,e[24]=D,e[25]=$,e[26]=m,e[27]=T,e[28]=S,e[29]=w,e[30]=B,e[31]=r,e[32]=g,e[33]=L,e[34]=p,e[35]=x,e[36]=o,e[37]=f,e[38]=a,e[39]=y,e[40]=N,e[41]=Z,e[42]=K,e[43]=Y,e[44]=F,e[45]=Q,e[46]=J,e[47]=ee,e[48]=q}else Z=e[41],K=e[42],Y=e[43],F=e[44],Q=e[45],J=e[46],ee=e[47],q=e[48];let se;e[75]!==K||e[76]!==Y?(se=i.jsx("div",{className:K,children:Y}),e[75]=K,e[76]=Y,e[77]=se):se=e[77];let ne;e[78]!==Z||e[79]!==F||e[80]!==se?(ne=i.jsx(Z,{className:F,children:se}),e[78]=Z,e[79]=F,e[80]=se,e[81]=ne):ne=e[81];let le;return e[82]!==Q||e[83]!==J||e[84]!==ee||e[85]!==q||e[86]!==ne?(le=i.jsxs("div",{className:Q,children:[J,ee,q,ne]}),e[82]=Q,e[83]=J,e[84]=ee,e[85]=q,e[86]=ne,e[87]=le):le=e[87],le}function vO(t){return t.key}function bO(t){return t.email}function _O(t){return t.slug}function yO(t){return typeof t=="string"?t:""}function LO(t){const e=M.c(2),{virtualMcpId:s}=t,n=fs(s);if(!tn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(Sn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No content to edit."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fO,{}),e[1]=o):o=e[1],o}const c0={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:Wd},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Kn},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:km}},SO=["fast","smart","thinking"];function wO(t){const e=M.c(15),{tier:s,onSelect:n}=t,[r,o]=k.useState(!1),a=c0[s].icon;let l;e[0]!==a?(l=i.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const c=c0[s];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(ts,{size:14,className:"text-muted-foreground"}),e[2]=d):d=e[2];let h;e[3]!==l||e[4]!==c.label?(h=i.jsx(As,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,c.label,d]})}),e[3]=l,e[4]=c.label,e[5]=h):h=e[5];let u;e[6]!==n||e[7]!==s?(u=SO.map(p=>{const g=c0[p],x=g.icon;return i.jsxs("button",{type:"button",onClick:()=>{n(p),o(!1)},className:te("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[i.jsx(x,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:g.label}),i.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&i.jsx(Ot,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=n,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=i.jsx(Ts,{align:"start",className:"p-1 w-64",children:i.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=i.jsxs(Ns,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function jO(t){const e=M.c(15),{tier:s,onTierChange:n,override:r,onOverrideChange:o}=t,[a,l]=k.useState(r!==null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a?(d=a?i.jsx(k.Suspense,{fallback:i.jsx(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:i.jsx(CO,{override:r,onOverrideChange:o})}):i.jsx(wO,{tier:s,onSelect:n}),e[1]=o,e[2]=n,e[3]=r,e[4]=s,e[5]=a,e[6]=d):d=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=i.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(hr,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d,u]})]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function CO(t){const e=M.c(10),{override:s,onOverrideChange:n}=t,r=Zm(),o=r[0]?.id??null,[a,l]=k.useState(s?.credentialId??o);let c;e[0]!==s?(c=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=c):c=e[1];const d=c;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==n?(h=f=>{const m=f.keyId??a??"";l(m),n({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=n,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==d||e[8]!==h?(u=i.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:i.jsx(bb,{variant:"bordered",placeholder:"Pick a model",model:d,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=d,e[8]=h,e[9]=u):u=e[9],u}const j4=[{key:"capabilities",heading:"Built-in capabilities",icon:v9,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:ii},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:An},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:Qs},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:sb}]},{key:"files",heading:"Files & code",icon:Xn,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:i2},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:x9},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:Hd},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:Po},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:Xn},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:nb}]},{key:"context",heading:"Context",icon:sl,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:sl},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:lr},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:lr}]},{key:"browser",heading:"Browser",icon:pn,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:jr},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:pn},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:Qo}]}],kO=j4.flatMap(t=>t.tools.map(e=>e.name));function VO(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function NO(t){const e=M.c(5),{agentId:s,value:n,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==n?(a=i.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?i.jsx(k.Suspense,{fallback:i.jsxs(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[i.jsx(v9,{size:14}),"Loading tools…"]}),children:i.jsx(AO,{agentId:s,value:n,onChange:r})}):i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=n,e[4]=a):a=e[4],a}function Xf(t){const e=M.c(17),{value:s,checked:n,onToggle:r,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=i.jsx(kr,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&i.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=i.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&i.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=i.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=i.jsxs(Cs,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=r,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function Qf(t){const e=M.c(20),{conn:s,label:n,icon:r,on:o,total:a,onToggle:l}=t,c=o===a;let d;e[0]!==r||e[1]!==s?(d=s?i.jsx(on,{icon:s.icon,name:s.title,size:"2xs"}):r?i.jsx(r,{size:14,className:"text-muted-foreground"}):i.jsx(ib,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=d):d=e[2];const h=s?.title??n??"Other tools";let u;e[3]!==h?(u=i.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=i.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=_=>{_.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=c?"None":"All";let g;e[10]!==m||e[11]!==p?(g=i.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==f||e[14]!==g?(x=i.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=x):x=e[15];let v;return e[16]!==d||e[17]!==u||e[18]!==x?(v=i.jsxs("div",{className:"flex items-center gap-2",children:[d,u,x]}),e[16]=d,e[17]=u,e[18]=x,e[19]=v):v=e[19],v}function AO(t){const e=M.c(70),{agentId:s,value:n,onChange:r}=t,{org:o}=Ee(),[a,l]=k.useState(!1);let c;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(c={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=c):c=e[3];const d=ut(c);let h;e[4]!==d?(h={client:d},e[4]=d,e[5]=h):h=e[5];const{data:u,isLoading:f}=r9(h),m=En();let p,g,x,v,_,b,y,L,w,S,j,C,V;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==n){const R=new Map(m.map(IO)),D=new Map;for(const G of u?.tools??[]){const oe=mn(G._meta)??"__other__",me=yr(G.name,oe==="__other__"?void 0:oe),ue=G.title,ye=ue&&ue!==G.name?ue:VO(me);D.has(oe)||D.set(oe,{clientId:oe,conn:R.get(oe),tools:[]}),D.get(oe).tools.push({name:G.name,display:ye,description:G.description})}const P=[...D.values()].sort(PO),I=(u?.tools??[]).map(RO),O=[...kO,...I],B=n===null?new Set(O):new Set(n),z=O.every(G=>B.has(G)),$=G=>r(O.every(oe=>G.has(oe))?null:[...G]),U=G=>{const oe=new Set(B);oe.has(G)?oe.delete(G):oe.add(G),$(oe)},W=(G,oe)=>{const me=new Set(B);for(const ue of G)oe?me.add(ue):me.delete(ue);$(me)};v=Ns,V=a,_=l;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=i.jsx(v9,{size:14,className:"text-muted-foreground"}),e[25]=X):X=e[25];const H=z?"All tools":"Tools",Z=!z&&i.jsxs(I6,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[B.size,"/",O.length]});let K;e[26]===Symbol.for("react.memo_cache_sentinel")?(K=i.jsx(ts,{size:14,className:"text-muted-foreground"}),e[26]=K):K=e[26],e[27]!==H||e[28]!==Z?(b=i.jsx(As,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[X,H,Z,K]})}),e[27]=H,e[28]=Z,e[29]=b):b=e[29],x=Ts,j="p-0 w-80",C="start",g=Cr,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(Ii,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const Y=z?`All ${O.length} tools enabled`:`${B.size} of ${O.length} enabled`;let F;e[31]!==Y?(F=i.jsx("span",{className:"text-xs text-muted-foreground",children:Y}),e[31]=Y,e[32]=F):F=e[32];let Q;e[33]!==r?(Q=()=>r(null),e[33]=r,e[34]=Q):Q=e[34];let J;e[35]!==z||e[36]!==Q?(J=i.jsx("button",{type:"button",onClick:Q,disabled:z,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=z,e[36]=Q,e[37]=J):J=e[37];let ee;e[38]===Symbol.for("react.memo_cache_sentinel")?(ee=i.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=ee):ee=e[38];let q;e[39]!==r?(q=()=>r([]),e[39]=r,e[40]=q):q=e[40];const se=B.size===0;let ne;e[41]!==q||e[42]!==se?(ne=i.jsx("button",{type:"button",onClick:q,disabled:se,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=q,e[42]=se,e[43]=ne):ne=e[43];let le;e[44]!==J||e[45]!==ne?(le=i.jsxs("div",{className:"flex items-center gap-2",children:[J,ee,ne]}),e[44]=J,e[45]=ne,e[46]=le):le=e[46],e[47]!==F||e[48]!==le?(S=i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[F,le]}),e[47]=F,e[48]=le,e[49]=S):S=e[49],p=Di,y="max-h-80",L=f?i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):i.jsxs(i.Fragment,{children:[i.jsx(Jn,{children:"No tools found"}),j4.map(G=>{const oe=G.tools.map(EO),me=oe.filter(ue=>B.has(ue)).length;return i.jsx(Is,{heading:i.jsx(Qf,{label:G.heading,icon:G.icon,on:me,total:oe.length,onToggle:()=>W(oe,me!==oe.length)}),children:G.tools.map(ue=>i.jsx(Xf,{value:`${ue.title} ${ue.name}`,checked:B.has(ue.name),onToggle:()=>U(ue.name),title:ue.title,description:ue.description,leading:i.jsx(ue.icon,{size:16,className:"text-muted-foreground"})},ue.name))},G.key)}),P.map(G=>{const oe=G.tools.map(TO),me=oe.filter(ue=>B.has(ue)).length;return i.jsx(Is,{heading:i.jsx(Qf,{conn:G.conn,on:me,total:oe.length,onToggle:()=>W(oe,me!==oe.length)}),children:G.tools.map(ue=>i.jsx(Xf,{value:`${ue.display} ${ue.name} ${G.conn?.title??""}`,checked:B.has(ue.name),onToggle:()=>U(ue.name),title:ue.display,description:ue.description},ue.name))},G.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=n,e[12]=p,e[13]=g,e[14]=x,e[15]=v,e[16]=_,e[17]=b,e[18]=y,e[19]=L,e[20]=w,e[21]=S,e[22]=j,e[23]=C,e[24]=V}else p=e[12],g=e[13],x=e[14],v=e[15],_=e[16],b=e[17],y=e[18],L=e[19],w=e[20],S=e[21],j=e[22],C=e[23],V=e[24];let N;e[50]!==p||e[51]!==y||e[52]!==L?(N=i.jsx(p,{className:y,children:L}),e[50]=p,e[51]=y,e[52]=L,e[53]=N):N=e[53];let T;e[54]!==g||e[55]!==N||e[56]!==w||e[57]!==S?(T=i.jsxs(g,{children:[w,S,N]}),e[54]=g,e[55]=N,e[56]=w,e[57]=S,e[58]=T):T=e[58];let A;e[59]!==x||e[60]!==T||e[61]!==j||e[62]!==C?(A=i.jsx(x,{className:j,align:C,children:T}),e[59]=x,e[60]=T,e[61]=j,e[62]=C,e[63]=A):A=e[63];let E;return e[64]!==v||e[65]!==_||e[66]!==b||e[67]!==A||e[68]!==V?(E=i.jsxs(v,{open:V,onOpenChange:_,children:[b,A]}),e[64]=v,e[65]=_,e[66]=b,e[67]=A,e[68]=V,e[69]=E):E=e[69],E}function TO(t){return t.name}function EO(t){return t.name}function RO(t){return t.name}function PO(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function IO(t){return[t.id,t]}function ko(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function DO(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function OO(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function MO(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return r?{count:parseInt(r[1]),unit:"days"}:null}function $O(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const BO=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function zO({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=ra(),[l,c]=k.useState(!1),d=e??l,h=m=>{s?s(m):c(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),de.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";de.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):de.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";de.error(p)}};return i.jsxs(as,{open:d,onOpenChange:h,children:[i.jsx(ls,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",children:[i.jsx(kt,{size:14}),"Add Starter"]})}),i.jsxs(cs,{align:"end",className:"w-[200px]",children:[i.jsxs(To,{children:[i.jsxs(Eo,{className:"gap-2.5",children:[i.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),i.jsx(Ro,{className:"w-[160px]",children:BO.map(m=>i.jsxs(Ge,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[i.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),i.jsxs(Ge,{className:"gap-2.5",onSelect:()=>{h(!1),n?.()},children:[i.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),i.jsxs(Ge,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[i.jsx(wi,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),i.jsxs(Ge,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[i.jsx(ii,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function C4(t){const e=M.c(31),{open:s,onOpenChange:n,url:r,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=k.useState(null),[f,m]=k.useState("curl"),[p,g]=k.useState("header"),x=k.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(R,D)=>{try{await navigator.clipboard.writeText(R),u(D),de.success("Copied"),setTimeout(()=>u(null),1500)}catch{de.error("Failed to copy")}},e[0]=v):v=e[0];const _=v;let b;e[1]!==p||e[2]!==o||e[3]!==r?(b=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=b):b=e[4];const y=b,L=r&&o?p==="header"?`curl -X POST "${y}" \\
484
+ -H "Authorization: Bearer ${o}" \\
485
+ -H "Content-Type: application/json" \\
486
+ -d '{"hello":"world"}'`:`curl -X POST "${y}" \\
487
+ -H "Content-Type: application/json" \\
488
+ -d '{"hello":"world"}'`:"",w=r&&o?p==="header"?`await fetch("${y}", {
489
+ method: "POST",
490
+ headers: {
491
+ Authorization: "Bearer ${o}",
492
+ "Content-Type": "application/json",
493
+ },
494
+ body: JSON.stringify({ hello: "world" }),
495
+ });`:`await fetch("${y}", {
496
+ method: "POST",
497
+ headers: {
498
+ "Content-Type": "application/json",
499
+ },
500
+ body: JSON.stringify({ hello: "world" }),
501
+ });`:"",S=f==="curl"?L:w;let j;e[5]!==c?(j=i.jsx(hs,{children:c}),e[5]=c,e[6]=j):j=e[6];let C;e[7]!==d?(C=i.jsx(si,{children:d}),e[7]=d,e[8]=C):C=e[8];let V;e[9]!==j||e[10]!==C?(V=i.jsxs(us,{children:[j,C]}),e[9]=j,e[10]=C,e[11]=V):V=e[11];let N;e[12]!==p||e[13]!==h||e[14]!==y||e[15]!==f||e[16]!==S||e[17]!==o||e[18]!==x||e[19]!==r?(N=r&&o?i.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:y}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>_(y,"url"),children:[i.jsx(Ds,{size:13}),h==="url"?"Copied":"Copy"]})]})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>_(o,"token"),children:[i.jsx(Ds,{size:13}),h==="token"?"Copied":"Copy"]})]})]}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(wr,{value:f,onValueChange:R=>m(R),children:i.jsxs(Zo,{className:"h-8 p-[2px]",children:[i.jsx(gn,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),i.jsx(gn,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),i.jsxs("label",{htmlFor:x,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(kr,{id:x,checked:p==="url",onCheckedChange:R=>g(R?"url":"header")}),"Token in URL"]})]}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>_(S,"example"),children:[i.jsx(Ds,{size:13}),h==="example"?"Copied":"Copy"]})]}),i.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:i.jsx(ia,{code:S,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=h,e[14]=y,e[15]=f,e[16]=S,e[17]=o,e[18]=x,e[19]=r,e[20]=N):N=e[20];let T;e[21]!==n?(T=i.jsx(Ei,{children:i.jsx(re,{onClick:()=>n(!1),children:"Done"})}),e[21]=n,e[22]=T):T=e[22];let A;e[23]!==V||e[24]!==N||e[25]!==T?(A=i.jsxs(Zt,{className:"max-w-lg",children:[V,N,T]}),e[23]=V,e[24]=N,e[25]=T,e[26]=A):A=e[26];let E;return e[27]!==n||e[28]!==s||e[29]!==A?(E=i.jsx(es,{open:s,onOpenChange:n,children:A}),e[27]=n,e[28]=s,e[29]=A,e[30]=E):E=e[30],E}function FO(t){const e=M.c(82),{trigger:s,automationId:n,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=ra(),[c,d]=k.useState(!1),[h,u]=k.useState(!1),[f,m]=k.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?MO(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const g=p,[x,v]=k.useState(g?.count??1),[_,b]=k.useState(!1),[y,L]=k.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,S=s.type==="cron",j=s.type==="webhook";let C;e[2]!==n||e[3]!==a||e[4]!==s.id?(C=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:n}),de.success("Starter removed")}catch{de.error("Failed to remove starter")}d(!1)},e[2]=n,e[3]=a,e[4]=s.id,e[5]=C):C=e[5];const V=C;let N;e[6]!==o||e[7]!==n||e[8]!==a||e[9]!==s.id?(N=async ue=>{await o.mutateAsync({automation_id:n,type:"cron",cron_expression:ue}),await a.mutateAsync({trigger_id:s.id,automation_id:n})},e[6]=o,e[7]=n,e[8]=a,e[9]=s.id,e[10]=N):N=e[10];const T=N;let A;e[11]!==y||e[12]!==T||e[13]!==s.cron_expression?(A=async()=>{const ue=y.trim();if(!ue||!ko(ue)||ue===s.cron_expression){b(!1),L(s.cron_expression??"");return}try{await T(ue),b(!1)}catch{de.error("Failed to update starter"),L(s.cron_expression??""),b(!1)}},e[11]=y,e[12]=T,e[13]=s.cron_expression,e[14]=A):A=e[14];const E=A;let R;e[15]!==n||e[16]!==l||e[17]!==s.id?(R=async()=>{u(!1);try{const ue=await l.mutateAsync({trigger_id:s.id,automation_id:n});m({url:ue.url,token:ue.token})}catch(ue){const ye=ue,Le=ye instanceof Error?ye.message:"Failed to rotate token";de.error(Le)}},e[15]=n,e[16]=l,e[17]=s.id,e[18]=R):R=e[18];const D=R;let P;e[19]!==g||e[20]!==T||e[21]!==s.cron_expression?(P=async ue=>{if(!g)return;const ye=g.unit==="minutes"?5:1,Le=Math.max(ye,ue);Le!==ue&&v(Le);const Ce=OO(Le,g.unit);if(Ce!==s.cron_expression)try{await T(Ce)}catch{de.error("Failed to update starter"),v(g.count)}},e[19]=g,e[20]=T,e[21]=s.cron_expression,e[22]=P):P=e[22];const I=P;let O;e[23]!==S||e[24]!==j?(O=S?i.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}):j?i.jsx(ii,{size:14,className:"text-muted-foreground shrink-0"}):i.jsx(wi,{size:14,className:"text-muted-foreground shrink-0"}),e[23]=S,e[24]=j,e[25]=O):O=e[25];let B;e[26]!==r||e[27]!==x||e[28]!==y||e[29]!==I||e[30]!==E||e[31]!==g||e[32]!==S||e[33]!==_||e[34]!==w||e[35]!==j||e[36]!==s.cron_expression||e[37]!==s.event_type||e[38]!==s.params?(B=g&&S?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx("input",{type:"number",min:g.unit==="minutes"?5:1,value:x,onChange:ue=>v(parseInt(ue.target.value)||1),onBlur:()=>I(x),onKeyDown:ue=>{ue.key==="Enter"&&ue.target.blur(),ue.key==="Escape"&&v(g.count)},disabled:w,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),i.jsx("span",{className:"text-sm",children:$O(g.unit,x)})]}):S&&_?i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:y,onChange:ue=>L(ue.target.value),onBlur:E,onKeyDown:ue=>{ue.key==="Enter"&&ue.target.blur(),ue.key==="Escape"&&(b(!1),L(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),y&&!ko(y)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):i.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[i.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:S?DO(s.cron_expression??""):j?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!S&&!j&&s.params&&Object.keys(s.params).length>0&&i.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(UO).join(", ")})]}),e[26]=r,e[27]=x,e[28]=y,e[29]=I,e[30]=E,e[31]=g,e[32]=S,e[33]=_,e[34]=w,e[35]=j,e[36]=s.cron_expression,e[37]=s.event_type,e[38]=s.params,e[39]=B):B=e[39];let z;e[40]!==w?(z=w&&i.jsx(Xe,{size:13,className:"animate-spin text-muted-foreground"}),e[40]=w,e[41]=z):z=e[41];let $;e[42]!==g||e[43]!==S||e[44]!==_||e[45]!==s.cron_expression?($=S&&!g&&!_&&i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{L(s.cron_expression??""),b(!0)},children:i.jsx(x9,{size:13,className:"text-muted-foreground"})}),e[42]=g,e[43]=S,e[44]=_,e[45]=s.cron_expression,e[46]=$):$=e[46];let U;e[47]!==j?(U=j&&i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:i.jsx(ir,{size:13,className:"text-muted-foreground"})}),e[47]=j,e[48]=U):U=e[48];let W;e[49]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(!0),children:i.jsx(Tn,{size:13,className:"text-muted-foreground"})}),e[49]=W):W=e[49];let X;e[50]!==$||e[51]!==U||e[52]!==z?(X=i.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[z,$,U,W]}),e[50]=$,e[51]=U,e[52]=z,e[53]=X):X=e[53];let H;e[54]!==X||e[55]!==O||e[56]!==B?(H=i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[O,B,X]}),e[54]=X,e[55]=O,e[56]=B,e[57]=H):H=e[57];let Z;e[58]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsxs(ll,{children:[i.jsx(cl,{children:"Remove Starter"}),i.jsx(dl,{children:"Are you sure you want to remove this starter?"})]}),e[58]=Z):Z=e[58];let K;e[59]===Symbol.for("react.memo_cache_sentinel")?(K=i.jsx(hl,{children:"Cancel"}),e[59]=K):K=e[59];let Y;e[60]!==V?(Y=i.jsxs(al,{children:[Z,i.jsxs(ul,{children:[K,i.jsx(fl,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[60]=V,e[61]=Y):Y=e[61];let F;e[62]!==c||e[63]!==Y?(F=i.jsx(ol,{open:c,onOpenChange:d,children:Y}),e[62]=c,e[63]=Y,e[64]=F):F=e[64];let Q;e[65]===Symbol.for("react.memo_cache_sentinel")?(Q=i.jsxs(ll,{children:[i.jsx(cl,{children:"Rotate webhook token"}),i.jsx(dl,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[65]=Q):Q=e[65];let J;e[66]===Symbol.for("react.memo_cache_sentinel")?(J=i.jsx(hl,{children:"Cancel"}),e[66]=J):J=e[66];let ee;e[67]!==D?(ee=i.jsxs(al,{children:[Q,i.jsxs(ul,{children:[J,i.jsx(fl,{onClick:D,children:"Rotate"})]})]}),e[67]=D,e[68]=ee):ee=e[68];let q;e[69]!==h||e[70]!==ee?(q=i.jsx(ol,{open:h,onOpenChange:u,children:ee}),e[69]=h,e[70]=ee,e[71]=q):q=e[71];const se=f!==null;let ne;e[72]===Symbol.for("react.memo_cache_sentinel")?(ne=ue=>{ue||m(null)},e[72]=ne):ne=e[72];const le=f?.url??null,G=f?.token??null;let oe;e[73]!==se||e[74]!==le||e[75]!==G?(oe=i.jsx(C4,{open:se,onOpenChange:ne,url:le,token:G,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[73]=se,e[74]=le,e[75]=G,e[76]=oe):oe=e[76];let me;return e[77]!==H||e[78]!==F||e[79]!==q||e[80]!==oe?(me=i.jsxs(i.Fragment,{children:[H,F,q,oe]}),e[77]=H,e[78]=F,e[79]=q,e[80]=oe,e[81]=me):me=e[81],me}function UO(t){const[e,s]=t;return`${e}: ${s}`}function HO(t){const e=M.c(55),{automationId:s,onDone:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=En(r),[a,l]=k.useState(),[c,d]=k.useState();let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={},e[1]=h):h=e[1];const[u,f]=k.useState(h),{triggerAdd:m}=ra(),{data:p,isLoading:g}=D6(a);let x,v,_,b,y,L;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==c||e[6]!==g||e[7]!==n||e[8]!==u||e[9]!==o||e[10]!==p){const j=p?.find(I=>I.type===c);let C;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==c||e[21]!==n||e[22]!==u?(C=async()=>{if(!(!a||!c))try{await m.mutateAsync({automation_id:s,type:"event",event_type:c,connection_id:a,params:u}),Ne("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:c}),de.success("Event trigger added"),n()}catch{de.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=c,e[21]=n,e[22]=u,e[23]=C):C=e[23],x=C,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let V,N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=i.jsx(wi,{size:14,className:"text-muted-foreground shrink-0"}),V=i.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=V,e[25]=N):(V=e[24],N=e[25]);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(Tn,{size:13}),e[26]=T):T=e[26],e[27]!==n?(_=i.jsxs("div",{className:"flex items-center gap-2",children:[N,V,i.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:n,children:T})]}),e[27]=n,e[28]=_):_=e[28];const A=a??"";let E;e[29]===Symbol.for("react.memo_cache_sentinel")?(E=I=>{l(I),d(void 0),f({})},e[29]=E):E=e[29];let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(Xt,{className:"w-full",children:i.jsx(rs,{placeholder:"Select connection..."})}),e[30]=R):R=e[30];let D;e[31]!==o?(D=o.length===0?i.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(qO),e[31]=o,e[32]=D):D=e[32];let P;e[33]!==D?(P=i.jsx(Yt,{children:D}),e[33]=D,e[34]=P):P=e[34],e[35]!==A||e[36]!==P?(b=i.jsxs(Jt,{value:A,onValueChange:E,children:[R,P]}),e[35]=A,e[36]=P,e[37]=b):b=e[37],e[38]!==a||e[39]!==c||e[40]!==g||e[41]!==p?(y=a&&i.jsxs(Jt,{value:c??"",onValueChange:I=>{d(I),f({})},children:[i.jsx(Xt,{className:"w-full",children:g?i.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[i.jsx(Xe,{size:13,className:"animate-spin"}),"Loading events..."]}):i.jsx(rs,{placeholder:"Select event type...",children:c??"Select event type..."})}),i.jsx(Yt,{children:p?.map(WO)})]}),e[38]=a,e[39]=c,e[40]=g,e[41]=p,e[42]=y):y=e[42],L=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&i.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(I=>{const[O,B]=I;return i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,B.description&&i.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",B.description]})]}),B.enum?i.jsxs(Jt,{value:u[O]??"",onValueChange:z=>f($=>({...$,[O]:z})),children:[i.jsx(Xt,{className:"w-full",children:i.jsx(rs,{placeholder:`Select ${O}...`})}),i.jsx(Yt,{children:B.enum.map(KO)})]}):i.jsx("input",{type:"text",value:u[O]??"",onChange:z=>f($=>({...$,[O]:z.target.value})),placeholder:B.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=c,e[6]=g,e[7]=n,e[8]=u,e[9]=o,e[10]=p,e[11]=x,e[12]=v,e[13]=_,e[14]=b,e[15]=y,e[16]=L}else x=e[11],v=e[12],_=e[13],b=e[14],y=e[15],L=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==c||e[46]!==x?(w=a&&c&&i.jsx(re,{size:"sm",onClick:x,disabled:m.isPending,children:m.isPending?i.jsx(Xe,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=c,e[46]=x,e[47]=w):w=e[47];let S;return e[48]!==v||e[49]!==_||e[50]!==b||e[51]!==y||e[52]!==L||e[53]!==w?(S=i.jsxs("div",{className:v,children:[_,b,y,L,w]}),e[48]=v,e[49]=_,e[50]=b,e[51]=y,e[52]=L,e[53]=w,e[54]=S):S=e[54],S}function KO(t){return i.jsx(pt,{value:t,children:t},t)}function WO(t){return i.jsx(pt,{value:t.type,children:i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{children:t.type}),i.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function qO(t){return i.jsx(pt,{value:t.id,children:t.title},t.id)}const GO=30;function YO(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},n=new Set(s.fields);for(const r of e.fields)n.add(r);return{...s,fields:n,saveCount:s.saveCount+1}}case"reset":return null}}function JO({automationId:t,automation:e,onBack:s,onDelete:n}){const r=e.virtual_mcp_id,{org:o}=Ee(),{update:a,triggerAdd:l,run:c}=ra(),d=En(),h=new Map(d.map(q=>[q.id,q.title])),{openTask:u}=Qt(),{openSidePanel:f}=Jo(),{sendMessage:m}=Ys(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[g,x]=k.useState(p),[v,_]=k.useState(!1),[b,y]=k.useState(!1),[L,w]=k.useState(!1),[S,j]=k.useState(""),[C,V]=k.useState(!1),[N,T]=k.useState(null),[A,E]=k.useState(!1),[R,D]=k.useState(!1),[P,I]=k.useState(!1),O=async()=>{if(A)return;const se=fx(g).filter(ne=>ne.type==="text").map(ne=>ne.text).join(`
502
+ `);if(se.trim()){E(!0);try{Q(),Ne("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:se.length}),f("chat"),await m({tiptapDoc:Mp({managerAgentId:gm.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:se})})}finally{E(!1)}}},B=e.models?.tier??"smart",z=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,$=Dd({defaultValues:{name:e.name,active:e.active,tier:B,modelOverride:z,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=$.watch("active"),[W,X]=k.useReducer(YO,null),H=()=>{W!==null&&(Ne("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(W.fields),save_count:W.saveCount,edit_duration_ms:Date.now()-W.start}),X({type:"reset"}))},Z=async()=>{const q=$.control._formState.dirtyFields,se=Object.keys(q);if(se.length===0&&!P)return!0;const ne=$.getValues(),le=$.control._defaultValues;$.reset(ne,{keepValues:!0});const G=P;I(!1);const oe={tier:ne.tier,...ne.modelOverride?{modelId:ne.modelOverride.modelId,credentialId:ne.modelOverride.credentialId,modelTitle:ne.modelOverride.title}:{}},me={id:t,name:ne.name,active:ne.active,models:oe,tools:ne.tools,maxAgentSteps:ne.maxAgentSteps,messages:hx(g),temperature:0};try{await a.mutateAsync(me)}catch{return $.reset(le,{keepValues:!0}),G&&I(!0),!1}const ue=[...se];return G&&ue.push("messages"),X({type:"accumulate",now:Date.now(),fields:ue}),F(),!0},{schedule:K,flush:Y}=pl({save:Z}),{schedule:F,flush:Q}=pl({delayMs:3e4,save:async()=>H()});k.useEffect(()=>{const q=$.watch(()=>K());return()=>q.unsubscribe()},[]);const J=q=>{if(x(q),!R){D(!0);return}I(!0),K()},ee=async()=>{Ne("automation_test_clicked",{automation_id:t,agent_id:r});const q=await Y();if(Q(),!!q){if(!g){de.error("No instructions configured for this automation");return}try{const se=await c.mutateAsync(t);se.threadId&&(f("chat"),u(se.threadId))}catch{}}};return i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex items-center pb-4 shrink-0",children:i.jsxs(re,{variant:"ghost",size:"sm",onClick:s,children:[i.jsx(Wl,{size:14}),"Back to list"]})}),i.jsxs("div",{className:"flex flex-col gap-8",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx(ws,{control:$.control,name:"name",render:({field:q})=>i.jsx(tt,{...q,placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),n&&i.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:i.jsx(ks,{size:14})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ws,{control:$.control,name:"active",render:({field:q})=>i.jsx(hr,{checked:q.value,onCheckedChange:se=>{q.onChange(se),Y()},className:"cursor-pointer"})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),i.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),i.jsx($p,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),i.jsx(zO,{automationId:t,open:v,onOpenChange:_,onCustomSelect:()=>{w(!0),V(!1),j("")},onEventSelect:()=>{V(!0),w(!1)},onWebhookCreated:q=>{Ne("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),T(q)}})]}),e.triggers.length===0&&!L?i.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:i.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",i.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:"Add a starter"})," ","to get going."]})}):i.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(q=>i.jsx(FO,{trigger:q,automationId:t,connectionName:q.connection_id?h.get(q.connection_id):void 0},q.id))}),L&&i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[i.jsx(xo,{size:14,className:"text-muted-foreground shrink-0"}),i.jsx("input",{type:"text",value:S,onChange:q=>j(q.target.value),onBlur:async()=>{const q=S.trim();if(!(!q||!ko(q)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:q}),Ne("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),de.success("Starter added"),w(!1),j("")}catch{de.error("Failed to add starter")}},onKeyDown:async q=>{const se=S.trim();q.key==="Enter"&&se&&ko(se)&&q.target.blur(),q.key==="Escape"&&(w(!1),j(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!ko(S)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&i.jsx(Xe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),i.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),j("")},children:i.jsx(Tn,{size:13})})]}),C&&i.jsx(k.Suspense,{fallback:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[i.jsx(Xe,{size:13,className:"animate-spin text-muted-foreground"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:i.jsx(HO,{automationId:t,onDone:()=>V(!1)})}),i.jsx(C4,{open:N!==null,onOpenChange:q=>{q||T(null)},url:N?.url??null,token:N?.token??null})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),i.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:A||!g,onClick:O,children:[i.jsx(Kn,{size:13}),"Improve"]})]}),i.jsx(pp,{tiptapDoc:g,setTiptapDoc:J,placeholder:"What should this automation do?",children:i.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[i.jsx(gp,{virtualMcpId:r||null,className:"max-h-[45vh]"}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:ee,disabled:!r,children:[i.jsx(Md,{size:16}),"Test"]})}),i.jsx(De,{children:"Test Automation"})]})})]})})]}),i.jsxs(Ax,{open:b,onOpenChange:y,className:"flex flex-col gap-2.5",children:[i.jsxs(Tx,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),i.jsx(ts,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),i.jsxs(Ex,{className:"flex flex-col gap-5 pt-0.5",children:[i.jsx(jO,{tier:$.watch("tier"),onTierChange:q=>$.setValue("tier",q,{shouldDirty:!0}),override:$.watch("modelOverride"),onOverrideChange:q=>$.setValue("modelOverride",q,{shouldDirty:!0})}),i.jsx(NO,{agentId:r||null,value:$.watch("tools"),onChange:q=>$.setValue("tools",q,{shouldDirty:!0})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),i.jsx(tt,{type:"number",min:1,max:100,className:"w-40",placeholder:`${GO} (default)`,value:$.watch("maxAgentSteps")??"",onChange:q=>{const se=q.target.value.trim(),ne=se===""?null:Number(se);$.setValue("maxAgentSteps",ne===null||Number.isNaN(ne)?null:ne,{shouldDirty:!0})}})]})]})]})]})]})}const k4=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function V4(t){const e=k4.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function XO(t){const e=M.c(12),{automationId:s,triggerIds:n}=t,[r,o]=k.useState("30d"),[a,l]=k.useState(ZO);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=p=>{const g=p;o(g),l(V4(g))},e[0]=c):c=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Xt,{className:"w-44",children:i.jsx(rs,{})}),e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Yt,{children:k4.map(QO)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=i.jsx("div",{className:"flex items-center justify-end",children:i.jsxs(Jt,{value:r,onValueChange:c,children:[d,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==n?(f=i.jsx(Rx,{automationId:s,triggerIds:n,range:a}),e[5]=s,e[6]=a,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=i.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function QO(t){return i.jsx(pt,{value:t.key,children:t.label},t.key)}function ZO(){return V4("30d")}function eM(t){const e=M.c(5),{tabId:s}=t;let n;e[0]!==s?(n=e2(s),e[0]=s,e[1]=n):n=e[1];const r=n;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(ji,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=i.jsx(k.Suspense,{fallback:o,children:i.jsx(tM,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function tM(t){const e=M.c(24),{id:s}=t,n=yt(),{data:r,isLoading:o}=O6(s),[a,l]=k.useState("settings");let c;e[0]!==n?(c=()=>{n({to:".",search:nM,replace:!0})},e[0]=n,e[1]=c):c=e[1];const d=c;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ji,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(sM),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Wl,{size:14}),e[6]=f):f=e[6];let m;e[7]!==d?(m=i.jsxs(re,{variant:"ghost",size:"sm",onClick:d,children:[f,"Back to list"]}),e[7]=d,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let x;e[11]!==a?(x=i.jsx(d2,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,x]}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(_=a==="settings"?i.jsx(JO,{automationId:s,automation:r}):i.jsx(XO,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=_):_=e[20];let b;return e[21]!==v||e[22]!==_?(b=i.jsx(Zs,{children:i.jsx(Zs.Content,{children:i.jsxs(Zs.Body,{children:[v,_]})})}),e[21]=v,e[22]=_,e[23]=b):b=e[23],b}function sM(t){return t.id}function nM(t){return{...t,main:"automations"}}function iM(t){const e=M.c(20),{virtualMcpId:s}=t,n=yt(),{data:r}=M6(s),o=r===void 0?[]:r,{create:a}=ra(),[l,c]=k.useState(""),d=l.toLowerCase(),h=o.filter(N=>N.name.toLowerCase().includes(d));let u;e[0]!==n?(u=N=>n({to:".",search:T=>({...T,main:"automation:"+N}),replace:!0}),e[0]=n,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ne("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const N=await a.mutateAsync($6(s));f(N.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(kt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=i.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const x=g,v=Zs,_=Zs,b=Zs;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Zs.Title,{children:"Automations"}),e[6]=y):y=e[6];const L=o.length>0&&i.jsx(d9,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==x||e[8]!==L?(w=i.jsxs("div",{className:"flex flex-col gap-6",children:[y,i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[L,x]})]}),e[7]=x,e[8]=L,e[9]=w):w=e[9];const S=o.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(Li,{image:i.jsx(wi,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:x})}):h.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(Li,{image:i.jsx(wi,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):i.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(N=>i.jsx(B6,{automation:N,onClick:()=>f(N.id)},N.id))});let j;e[10]!==S||e[11]!==b.Body||e[12]!==w?(j=i.jsxs(b.Body,{children:[w,S]}),e[10]=S,e[11]=b.Body,e[12]=w,e[13]=j):j=e[13];let C;e[14]!==j||e[15]!==_.Content?(C=i.jsx(_.Content,{children:j}),e[14]=j,e[15]=_.Content,e[16]=C):C=e[16];let V;return e[17]!==v||e[18]!==C?(V=i.jsx(v,{children:C}),e[17]=v,e[18]=C,e[19]=V):V=e[19],V}function rM(t){const e=M.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(ji,{}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(k.Suspense,{fallback:n,children:i.jsx(iM,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function oM(t){const e=M.c(37),{file:s,onClose:n}=t;let r,o;e[0]!==s.filename?(r=i.jsx(dr,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=Ib(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let c;e[7]!==r||e[8]!==o||e[9]!==l?(c=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(l6,{size:14}),e[11]=d):d=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",asChild:!0,children:i.jsx("a",{href:s.downloadUrl,download:s.filename,children:d})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(De,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=i.jsxs(Oe,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Rn,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(De,{side:"bottom",children:"Open in new tab"}),e[23]=x):x=e[23];let v;e[24]!==g?(v=i.jsxs(Oe,{children:[g,x]}),e[24]=g,e[25]=v):v=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(Tn,{size:14}),e[26]=_):_=e[26];let b;e[27]!==n?(b=i.jsx(Ie,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:n,children:_})}),e[27]=n,e[28]=b):b=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(De,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let L;e[30]!==b?(L=i.jsxs(Oe,{children:[b,y]}),e[30]=b,e[31]=L):L=e[31];let w;return e[32]!==v||e[33]!==L||e[34]!==c||e[35]!==f?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,f,v,L]}),e[32]=v,e[33]=L,e[34]=c,e[35]=f,e[36]=w):w=e[36],w}function aM(t){const e=M.c(24),{fileKey:s,taskId:n}=t,r=yt(),{data:o,isPending:a}=um(n);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==r?(d=()=>r({to:".",search:lM,replace:!0}),e[3]=r,e[4]=d):d=e[4];const h=d;if(!c){if(a){let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full w-full bg-background",children:i.jsx(Rb,{})}),e[5]=b):b=e[5],b}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=i.jsx(dr,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(re,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=v):v=e[12];let _;return e[13]!==g||e[14]!==v?(_=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,x,v]}),e[13]=g,e[14]=v,e[15]=_):_=e[15],_}let u;e[16]!==c||e[17]!==h?(u=i.jsx(oM,{file:c,onClose:h}),e[16]=c,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==c?(f=i.jsx("div",{className:"relative min-h-0 flex-1",children:i.jsx(Pb,{file:c})}),e[19]=c,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=i.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function lM(t){return{...t,main:0}}const d0="home";function cM(t){const e=M.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Et,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let r;e[1]!==s?(r=s&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,r]}),e[3]=r,e[4]=o):o=e[4],o}function dM(t){const e=M.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const r=Db(d0,s,n),o=Ob(d0)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=i.jsx(cM,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=Mb(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",c=r.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=i.jsx($b,{volume:d0,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=i.jsx(Bb,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function uM(t){const e=M.c(5),{path:s}=t,n=yt();let r;e[0]!==n?(r=()=>n({to:".",search:hM,replace:!0}),e[0]=n,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=i.jsx(zb,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function hM(t){return{...t,main:0}}function fM(){const t=M.c(12),e=yt(),[s,n]=k.useState(null),[r,o]=k.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=i.jsx(Fb,{onOpenFile:f=>l(Zb(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&i.jsx(Ub,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==r?(h=r&&i.jsx(Hb,{brandPath:r,onClose:()=>o(null)},r),t[6]=r,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=i.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const Zf=k.lazy(()=>Os(()=>import("./project-app-view-Cag9gDj3.js"),__vite__mapDeps([172,1,2,50,51,52,17,3,53,54,55,56,57,58,59,60,61,31,62,48,63,64,65,66,67,5,16,19,4,6,7,8,9,10,11,12,13,14,15,18,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,112,107,108,109,110,111,113,114,115,116,103,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,105,150,151,152,153,154,155])).then(t=>({default:t.AppViewContent})));function mM(t){const e=M.c(60),{activeTab:s,virtualMcpId:n,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(CN,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:i.jsx(wv,{})}),e[1]=L):L=e[1],L}if(e6(s)){let L;return e[2]!==n?(L=i.jsx(Dh,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=i.jsx(CA,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=i.jsx(rM,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=i.jsx(LE,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=t6(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=i.jsx(CE,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=i.jsx(LO,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(fM,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=i.jsx(eM,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=s2(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=i.jsx(dM,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=t2(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==r?(L=i.jsx(aM,{fileKey:m.key,taskId:r}),e[25]=m.key,e[26]=r,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=n2(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=i.jsx(uM,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=s6(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let V;e[38]!==v.connectionId||e[39]!==v.toolName?(V=N=>N.appId===v.connectionId&&N.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=V):V=e[40],L=a.find(V),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let S;e[41]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(ji,{}),e[41]=S):S=e[41];const j=w?.args;let C;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==j?(C=i.jsx(k.Suspense,{fallback:S,children:i.jsx(Zf,{connectionId:v.connectionId,toolName:v.toolName,args:j},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=j,e[46]=C):C=e[46],C}let _;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],_=o.find(L),e[47]=s,e[48]=o,e[49]=_}else _=e[49];const b=_;if(b){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(ji,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==b.id||e[55]!==b.view.appId||e[56]!==b.view.args?(w=i.jsx(k.Suspense,{fallback:L,children:i.jsx(Zf,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[53]=s,e[54]=b.id,e[55]=b.view.appId,e[56]=b.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=i.jsx(Dh,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function pM(t){const e=M.c(14),{taskId:s,virtualMcpId:n}=t;let r;e[0]!==s||e[1]!==n?(r={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=M9(r);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(ji,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=i.jsx(k.Suspense,{fallback:d,children:i.jsx(mM,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=i.jsx(vs,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const vi="setup";function gM(t){const e=M.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const n=s;let r;e[5]!==t?(r=()=>{t.active===vi?t.onToggle():t.onSelectTab(vi)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===vi;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=i.jsx(xM,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==t?(c=t.scriptTabs.map(m=>i.jsx(bM,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=c):c=e[12];let d;e[13]!==n||e[14]!==t.onAddScript?(d=i.jsx(_M,{scripts:n,onRun:t.onAddScript}),e[13]=n,e[14]=t.onAddScript,e[15]=d):d=e[15];let h;e[16]!==l||e[17]!==c||e[18]!==d?(h=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,c,d]}),e[16]=l,e[17]=c,e[18]=d,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?i.jsx(yM,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):i.jsx(vM,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function xM(t){const e=M.c(8),{active:s,open:n,onClick:r}=t,o=s&&n,a=s&&n,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let c;e[0]!==l?(c=te("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(rb,{className:"size-3.5"}),e[2]=d):d=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c?(h=i.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:c,children:[d,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=h):h=e[7],h}function vM(t){const e=M.c(24),{status:s,onStart:n,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Si,{className:"size-3.5"}),e[0]=c):c=e[0];let d;return e[1]!==n?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:n,children:[c," Start"]}),e[1]=n,e[2]=d):d=e[2],d}if(s==="suspended"&&a){let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Si,{className:"size-3.5"}),e[3]=c):c=e[3];let d;return e[4]!==a?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:a,children:[c," Resume"]}),e[4]=a,e[5]=d):d=e[5],d}if(s==="errored"&&l){let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(ir,{className:"size-3.5"}),e[6]=c):c=e[6];let d;return e[7]!==l?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:l,children:[c," Retry"]}),e[7]=l,e[8]=d):d=e[8],d}if(s==="starting"||s==="running"){const c=s==="running"&&!!o,d=c?"rounded-r-none border-r-0":void 0;let h;e[9]!==d?(h=te(d),e[9]=d,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Bm,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=i.jsx(Ie,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(De,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=i.jsxs(Oe,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==c?(g=c&&i.jsxs(as,{children:[i.jsx(ls,{asChild:!0,children:i.jsx(re,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:i.jsx(ts,{className:"size-3"})})}),i.jsx(cs,{align:"end",children:i.jsxs(Ge,{onClick:o,children:[i.jsx(ir,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=c,e[20]=g):g=e[20];let x;return e[21]!==p||e[22]!==g?(x=i.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=x):x=e[23],x}return null}function bM(t){const e=M.c(16),{active:s,onClick:n,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=te("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const c=r?"pl-2.5 pr-1":"px-2.5",d=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==c||e[3]!==d?(h=te("flex h-full items-center",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==n||e[7]!==h?(u=i.jsx("button",{type:"button",onClick:n,className:h,children:o}),e[5]=o,e[6]=n,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&i.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:i.jsx(js,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=i.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function _M(t){const e=M.c(10),{scripts:s,onRun:n}=t,[r,o]=k.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs(Oe,{children:[i.jsx(Ie,{asChild:!0,children:i.jsx(As,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"sm","aria-label":"Run script",children:i.jsx(kt,{className:"size-3.5"})})})}),i.jsx(De,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==s?(c=s.length===0?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>i.jsxs("button",{type:"button",onClick:()=>{o(!1),n(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=n,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==c?(d=i.jsxs(Ts,{align:"start",className:"p-1 w-56",children:[l,c]}),e[5]=c,e[6]=d):d=e[6];let h;return e[7]!==r||e[8]!==d?(h=i.jsxs(Ns,{open:r,onOpenChange:o,children:[a,d]}),e[7]=r,e[8]=d,e[9]=h):h=e[9],h}function yM(t){const e=M.c(13),{isRunning:s,isKilling:n,onRun:r,onStop:o}=t;if(n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[i.jsx(Xe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Si,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=i.jsx(Ie,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(De,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=i.jsxs(Oe,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Bm,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=i.jsx(Ie,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(De,{children:"Stop process"}),e[10]=c):c=e[10];let d;return e[11]!==l?(d=i.jsxs(Oe,{children:[l,c]}),e[11]=l,e[12]=d):d=e[12],d}var N4=Object.defineProperty,LM=Object.getOwnPropertyDescriptor,SM=(t,e)=>{for(var s in e)N4(t,s,{get:e[s],enumerable:!0})},Vt=(t,e,s,n)=>{for(var r=n>1?void 0:n?LM(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(e,s,r):a(r))||r);return n&&r&&N4(e,s,r),r},we=(t,e)=>(s,n)=>e(s,n,t),e1="Terminal input",Q0={get:()=>e1,set:t=>e1=t},t1="Too much output to announce, navigate to rows manually to read",Z0={get:()=>t1,set:t=>t1=t};function wM(t){return t.replace(/\r?\n/g,"\r")}function jM(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function CM(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function kM(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");A4(r,e,s,n)}}function A4(t,e,s,n){t=wM(t),t=jM(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function T4(t,e,s){let n=s.getBoundingClientRect(),r=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function s1(t,e,s,n,r){T4(t,e,s),r&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function Fn(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function jc(t,e=0,s=t.length){let n="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var VM=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},NM=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=r,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(r=t[u++],r<128)e[n++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},E4="",Hn=" ",ha=class R4{constructor(){this.fg=0,this.bg=0,this.extended=new Pl}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new R4;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Pl=class P4{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new P4(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},qs=class I4 extends ha{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Pl,this.combinedData=""}static fromCharData(e){let s=new I4;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Fn(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},n1="di$target",ed="di$dependencies",u0=new Map;function AM(t){return t[ed]||[]}function ss(t){if(u0.has(t))return u0.get(t);let e=function(s,n,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");TM(e,s,r)};return e._id=t,u0.set(t,e),e}function TM(t,e,s){e[n1]===e?e[ed].push({id:t,index:s}):(e[ed]=[{id:t,index:s}],e[n1]=e)}var ys=ss("BufferService"),D4=ss("CoreMouseService"),Bi=ss("CoreService"),EM=ss("CharsetService"),Su=ss("InstantiationService"),O4=ss("LogService"),Ls=ss("OptionsService"),M4=ss("OscLinkService"),RM=ss("UnicodeService"),fa=ss("DecorationService"),td=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],r=this._optionsService.rawOptions.linkHandler,o=new qs,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):PM(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};td=Vt([we(0,ys),we(1,Ls),we(2,M4)],td);function PM(t,e){if(confirm(`Do you want to navigate to ${e}?
503
+
504
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var Cc=ss("CharSizeService"),In=ss("CoreBrowserService"),wu=ss("MouseService"),Dn=ss("RenderService"),IM=ss("SelectionService"),$4=ss("CharacterJoinerService"),zr=ss("ThemeService"),B4=ss("LinkProviderService"),DM=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?i1.isErrorNoTelemetry(t)?new i1(t.message+`
505
+
506
+ `+t.stack):new Error(t.message+`
507
+
508
+ `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},OM=new DM;function Wa(t){MM(t)||OM.onUnexpectedError(t)}var sd="Canceled";function MM(t){return t instanceof $M?!0:t instanceof Error&&t.name===sd&&t.message===sd}var $M=class extends Error{constructor(){super(sd),this.name=this.message}};function BM(t){return new Error(`Illegal argument: ${t}`)}var i1=class nd extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof nd)return e;let s=new nd;return s.message=e.message,s.stack=e.stack,s}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},id=class z4 extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,z4.prototype)}};function Es(t,e=0){return t[t.length-(1+e)]}var zM;(t=>{function e(o){return o<0}t.isLessThan=e;function s(o){return o<=0}t.isLessThanOrEqual=s;function n(o){return o>0}t.isGreaterThan=n;function r(o){return o===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(zM||={});function FM(t,e){let s=this,n=!1,r;return function(){return n||(n=!0,e||(r=t.apply(s,arguments))),r}}var F4;(t=>{function e(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}t.is=e;let s=Object.freeze([]);function n(){return s}t.empty=n;function*r(y){yield y}t.single=r;function o(y){return e(y)?y:r(y)}t.wrap=o;function a(y){return y||s}t.from=a;function*l(y){for(let L=y.length-1;L>=0;L--)yield y[L]}t.reverse=l;function c(y){return!y||y[Symbol.iterator]().next().done===!0}t.isEmpty=c;function d(y){return y[Symbol.iterator]().next().value}t.first=d;function h(y,L){let w=0;for(let S of y)if(L(S,w++))return!0;return!1}t.some=h;function u(y,L){for(let w of y)if(L(w))return w}t.find=u;function*f(y,L){for(let w of y)L(w)&&(yield w)}t.filter=f;function*m(y,L){let w=0;for(let S of y)yield L(S,w++)}t.map=m;function*p(y,L){let w=0;for(let S of y)yield*L(S,w++)}t.flatMap=p;function*g(...y){for(let L of y)yield*L}t.concat=g;function x(y,L,w){let S=w;for(let j of y)S=L(S,j);return S}t.reduce=x;function*v(y,L,w=y.length){for(L<0&&(L+=y.length),w<0?w+=y.length:w>y.length&&(w=y.length);L<w;L++)yield y[L]}t.slice=v;function _(y,L=Number.POSITIVE_INFINITY){let w=[];if(L===0)return[w,y];let S=y[Symbol.iterator]();for(let j=0;j<L;j++){let C=S.next();if(C.done)return[w,t.empty()];w.push(C.value)}return[w,{[Symbol.iterator](){return S}}]}t.consume=_;async function b(y){let L=[];for await(let w of y)L.push(w);return Promise.resolve(L)}t.asyncToArray=b})(F4||={});function Vi(t){if(F4.is(t)){let e=[];for(let s of t)if(s)try{s.dispose()}catch(n){e.push(n)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function UM(...t){return _t(()=>Vi(t))}function _t(t){return{dispose:FM(()=>{t()})}}var U4=class H4{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Vi(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?H4.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};U4.DISABLE_DISPOSED_WARNING=!1;var Gn=U4,Qe=class{constructor(){this._store=new Gn,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Qe.None=Object.freeze({dispose(){}});var xr=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Vn=typeof window=="object"?window:globalThis,rd=class od{constructor(e){this.element=e,this.next=od.Undefined,this.prev=od.Undefined}};rd.Undefined=new rd(void 0);var St=rd,r1=class{constructor(){this._first=St.Undefined,this._last=St.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===St.Undefined}clear(){let t=this._first;for(;t!==St.Undefined;){let e=t.next;t.prev=St.Undefined,t.next=St.Undefined,t=e}this._first=St.Undefined,this._last=St.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,e){let s=new St(t);if(this._first===St.Undefined)this._first=s,this._last=s;else if(e){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==St.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==St.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==St.Undefined&&t.next!==St.Undefined){let e=t.prev;e.next=t.next,t.next.prev=e}else t.prev===St.Undefined&&t.next===St.Undefined?(this._first=St.Undefined,this._last=St.Undefined):t.next===St.Undefined?(this._last=this._last.prev,this._last.next=St.Undefined):t.prev===St.Undefined&&(this._first=this._first.next,this._first.prev=St.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==St.Undefined;)yield t.element,t=t.next}},HM=globalThis.performance&&typeof globalThis.performance.now=="function",KM=class K4{static create(e){return new K4(e)}constructor(e){this._now=HM&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},is;(t=>{t.None=()=>Qe.None;function e(T,A){return u(T,()=>{},0,void 0,!0,void 0,A)}t.defer=e;function s(T){return(A,E=null,R)=>{let D=!1,P;return P=T(I=>{if(!D)return P?P.dispose():D=!0,A.call(E,I)},null,R),D&&P.dispose(),P}}t.once=s;function n(T,A,E){return d((R,D=null,P)=>T(I=>R.call(D,A(I)),null,P),E)}t.map=n;function r(T,A,E){return d((R,D=null,P)=>T(I=>{A(I),R.call(D,I)},null,P),E)}t.forEach=r;function o(T,A,E){return d((R,D=null,P)=>T(I=>A(I)&&R.call(D,I),null,P),E)}t.filter=o;function a(T){return T}t.signal=a;function l(...T){return(A,E=null,R)=>{let D=UM(...T.map(P=>P(I=>A.call(E,I))));return h(D,R)}}t.any=l;function c(T,A,E,R){let D=E;return n(T,P=>(D=A(D,P),D),R)}t.reduce=c;function d(T,A){let E,R={onWillAddFirstListener(){E=T(D.fire,D)},onDidRemoveLastListener(){E?.dispose()}},D=new ve(R);return A?.add(D),D.event}function h(T,A){return A instanceof Array?A.push(T):A&&A.add(T),T}function u(T,A,E=100,R=!1,D=!1,P,I){let O,B,z,$=0,U,W={leakWarningThreshold:P,onWillAddFirstListener(){O=T(H=>{$++,B=A(B,H),R&&!z&&(X.fire(B),B=void 0),U=()=>{let Z=B;B=void 0,z=void 0,(!R||$>1)&&X.fire(Z),$=0},typeof E=="number"?(clearTimeout(z),z=setTimeout(U,E)):z===void 0&&(z=0,queueMicrotask(U))})},onWillRemoveListener(){D&&$>0&&U?.()},onDidRemoveLastListener(){U=void 0,O.dispose()}},X=new ve(W);return I?.add(X),X.event}t.debounce=u;function f(T,A=0,E){return t.debounce(T,(R,D)=>R?(R.push(D),R):[D],A,void 0,!0,void 0,E)}t.accumulate=f;function m(T,A=(R,D)=>R===D,E){let R=!0,D;return o(T,P=>{let I=R||!A(P,D);return R=!1,D=P,I},E)}t.latch=m;function p(T,A,E){return[t.filter(T,A,E),t.filter(T,R=>!A(R),E)]}t.split=p;function g(T,A=!1,E=[],R){let D=E.slice(),P=T(B=>{D?D.push(B):O.fire(B)});R&&R.add(P);let I=()=>{D?.forEach(B=>O.fire(B)),D=null},O=new ve({onWillAddFirstListener(){P||(P=T(B=>O.fire(B)),R&&R.add(P))},onDidAddFirstListener(){D&&(A?setTimeout(I):I())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return R&&R.add(O),O.event}t.buffer=g;function x(T,A){return(E,R,D)=>{let P=A(new _);return T(function(I){let O=P.evaluate(I);O!==v&&E.call(R,O)},void 0,D)}}t.chain=x;let v=Symbol("HaltChainable");class _{constructor(){this.steps=[]}map(A){return this.steps.push(A),this}forEach(A){return this.steps.push(E=>(A(E),E)),this}filter(A){return this.steps.push(E=>A(E)?E:v),this}reduce(A,E){let R=E;return this.steps.push(D=>(R=A(R,D),R)),this}latch(A=(E,R)=>E===R){let E=!0,R;return this.steps.push(D=>{let P=E||!A(D,R);return E=!1,R=D,P?D:v}),this}evaluate(A){for(let E of this.steps)if(A=E(A),A===v)break;return A}}function b(T,A,E=R=>R){let R=(...O)=>I.fire(E(...O)),D=()=>T.on(A,R),P=()=>T.removeListener(A,R),I=new ve({onWillAddFirstListener:D,onDidRemoveLastListener:P});return I.event}t.fromNodeEventEmitter=b;function y(T,A,E=R=>R){let R=(...O)=>I.fire(E(...O)),D=()=>T.addEventListener(A,R),P=()=>T.removeEventListener(A,R),I=new ve({onWillAddFirstListener:D,onDidRemoveLastListener:P});return I.event}t.fromDOMEventEmitter=y;function L(T){return new Promise(A=>s(T)(A))}t.toPromise=L;function w(T){let A=new ve;return T.then(E=>{A.fire(E)},()=>{A.fire(void 0)}).finally(()=>{A.dispose()}),A.event}t.fromPromise=w;function S(T,A){return T(E=>A.fire(E))}t.forward=S;function j(T,A,E){return A(E),T(R=>A(R))}t.runAndSubscribe=j;class C{constructor(A,E){this._observable=A,this._counter=0,this._hasChanged=!1;let R={onWillAddFirstListener:()=>{A.addObserver(this)},onDidRemoveLastListener:()=>{A.removeObserver(this)}};this.emitter=new ve(R),E&&E.add(this.emitter)}beginUpdate(A){this._counter++}handlePossibleChange(A){}handleChange(A,E){this._hasChanged=!0}endUpdate(A){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function V(T,A){return new C(T,A).emitter.event}t.fromObservable=V;function N(T){return(A,E,R)=>{let D=0,P=!1,I={beginUpdate(){D++},endUpdate(){D--,D===0&&(T.reportChanges(),P&&(P=!1,A.call(E)))},handlePossibleChange(){},handleChange(){P=!0}};T.addObserver(I),T.reportChanges();let O={dispose(){T.removeObserver(I)}};return R instanceof Gn?R.add(O):Array.isArray(R)&&R.push(O),O}}t.fromObservableLight=N})(is||={});var ad=class ld{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${ld._idPool++}`,ld.all.add(this)}start(e){this._stopWatch=new KM,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};ad.all=new Set,ad._idPool=0;var WM=ad,qM=-1,W4=class q4{constructor(e,s,n=(q4._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let c=new JM(l,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(e.value)||0;this._stacks.set(e.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,s=0;for(let[n,r]of this._stacks)(!e||s<r)&&(e=[n,r],s=r);return e}};W4._idPool=1;var GM=W4,YM=class G4{constructor(e){this.value=e}static create(){let e=new Error;return new G4(e.stack??"")}print(){console.warn(this.value.split(`
509
+ `).slice(2).join(`
510
+ `))}},JM=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},XM=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},QM=0,h0=class{constructor(t){this.value=t,this.id=QM++}},ZM=2,e$,ve=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new GM(t?.onListenerError??Wa,this._options?.leakWarningThreshold??qM):void 0,this._perfMon=this._options?._profName?new WM(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new XM(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Wa)(c),Qe.None}if(this._disposed)return Qe.None;e&&(t=t.bind(e));let n=new h0(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=YM.create(),r=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof h0?(this._deliveryQueue??=new t$,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=_t(()=>{r?.(),this._removeListener(n)});return s instanceof Gn?s.add(o):Array.isArray(s)&&s.push(o),o},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,s=e.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*ZM<=e.length){let r=0;for(let o=0;o<e.length;o++)e[o]?e[r++]=e[o]:n&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let s=this._options?.onListenerError||Wa;if(!s){t.value(e);return}try{t.value(e)}catch(n){s(n)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof h0)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},t$=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,s){this.i=0,this.end=s,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},cd=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ve,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ve,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,s){if(this.getZoomLevel(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),e)}setFullscreen(e,s){if(this.isFullscreen(s)===e)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};cd.INSTANCE=new cd;var ju=cd;function s$(t,e,s){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",s)}ju.INSTANCE.onDidChangeZoomLevel;function n$(t){return ju.INSTANCE.getZoomFactor(t)}ju.INSTANCE.onDidChangeFullscreen;var Fr=typeof navigator=="object"?navigator.userAgent:"",dd=Fr.indexOf("Firefox")>=0,i$=Fr.indexOf("AppleWebKit")>=0,Cu=Fr.indexOf("Chrome")>=0,r$=!Cu&&Fr.indexOf("Safari")>=0;Fr.indexOf("Electron/")>=0;Fr.indexOf("Android")>=0;var f0=!1;if(typeof Vn.matchMedia=="function"){let t=Vn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Vn.matchMedia("(display-mode: fullscreen)");f0=t.matches,s$(Vn,t,({matches:s})=>{f0&&e.matches||(f0=s)})}var Yi="en",ud=!1,hd=!1,qa=!1,Y4=!1,Pa,Ga=Yi,o1=Yi,o$,jn,bi=globalThis,Ps;typeof bi.vscode<"u"&&typeof bi.vscode.process<"u"?Ps=bi.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ps=process);var a$=typeof Ps?.versions?.electron=="string",l$=a$&&Ps?.type==="renderer";if(typeof Ps=="object"){ud=Ps.platform==="win32",hd=Ps.platform==="darwin",qa=Ps.platform==="linux",qa&&Ps.env.SNAP&&Ps.env.SNAP_REVISION,Ps.env.CI||Ps.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Pa=Yi,Ga=Yi;let t=Ps.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Pa=e.userLocale,o1=e.osLocale,Ga=e.resolvedLanguage||Yi,o$=e.languagePack?.translationsConfigFile}catch{}Y4=!0}else typeof navigator=="object"&&!l$?(jn=navigator.userAgent,ud=jn.indexOf("Windows")>=0,hd=jn.indexOf("Macintosh")>=0,(jn.indexOf("Macintosh")>=0||jn.indexOf("iPad")>=0||jn.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qa=jn.indexOf("Linux")>=0,jn?.indexOf("Mobi")>=0,Ga=globalThis._VSCODE_NLS_LANGUAGE||Yi,Pa=navigator.language.toLowerCase(),o1=Pa):console.error("Unable to resolve platform.");var J4=ud,xn=hd,c$=qa,a1=Y4,Ln=jn,Mn=Ga,d$;(t=>{function e(){return Mn}t.value=e;function s(){return Mn.length===2?Mn==="en":Mn.length>=3?Mn[0]==="e"&&Mn[1]==="n"&&Mn[2]==="-":!1}t.isDefaultVariant=s;function n(){return Mn==="en"}t.isDefault=n})(d$||={});var u$=typeof bi.postMessage=="function"&&!bi.importScripts;(()=>{if(u$){let t=[];bi.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,r=t.length;n<r;n++){let o=t[n];if(o.id===s.data.vscodeScheduleAsyncWork){t.splice(n,1),o.callback();return}}});let e=0;return s=>{let n=++e;t.push({id:n,callback:s}),bi.postMessage({vscodeScheduleAsyncWork:n},"*")}}return t=>setTimeout(t)})();var h$=!!(Ln&&Ln.indexOf("Chrome")>=0);Ln&&Ln.indexOf("Firefox")>=0;!h$&&Ln&&Ln.indexOf("Safari")>=0;Ln&&Ln.indexOf("Edg/")>=0;Ln&&Ln.indexOf("Android")>=0;var Ui=typeof navigator=="object"?navigator:{};a1||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ui&&Ui.clipboard&&Ui.clipboard.writeText,a1||Ui&&Ui.clipboard&&Ui.clipboard.readText;var ku=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},m0=new ku,l1=new ku,c1=new ku,f$=new Array(230),X4;(t=>{function e(l){return m0.keyCodeToStr(l)}t.toString=e;function s(l){return m0.strToKeyCode(l)}t.fromString=s;function n(l){return l1.keyCodeToStr(l)}t.toUserSettingsUS=n;function r(l){return c1.keyCodeToStr(l)}t.toUserSettingsGeneral=r;function o(l){return l1.strToKeyCode(l)||c1.strToKeyCode(l)}t.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return m0.keyCodeToStr(l)}t.toElectronAccelerator=a})(X4||={});var m$=class Q4{constructor(e,s,n,r,o){this.ctrlKey=e,this.shiftKey=s,this.altKey=n,this.metaKey=r,this.keyCode=o}equals(e){return e instanceof Q4&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${s}${n}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new p$([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},p$=class{constructor(t){if(t.length===0)throw BM("chords");this.chords=t}getHashCode(){let t="";for(let e=0,s=this.chords.length;e<s;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function g$(t){if(t.charCode){let s=String.fromCharCode(t.charCode).toUpperCase();return X4.fromString(s)}let e=t.keyCode;if(e===3)return 7;if(dd)switch(e){case 59:return 85;case 60:if(c$)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(xn)return 57;break}else if(i$&&(xn&&e===93||!xn&&e===92))return 57;return f$[e]||0}var x$=xn?256:2048,v$=512,b$=1024,_$=xn?2048:256,d1=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=g$(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=x$),this.altKey&&(e|=v$),this.shiftKey&&(e|=b$),this.metaKey&&(e|=_$),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new m$(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},u1=new WeakMap;function y$(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,s=t.parent.location;if(e.origin!=="null"&&s.origin!=="null"&&e.origin!==s.origin)return null}catch{return null}return t.parent}var L$=class{static getSameOriginWindowChain(t){let e=u1.get(t);if(!e){e=[],u1.set(t,e);let s=t,n;do n=y$(s),n?e.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):e.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let s=0,n=0,r=this.getSameOriginWindowChain(t);for(let o of r){let a=o.window.deref();if(s+=a?.scrollY??0,n+=a?.scrollX??0,a===e||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,n+=l.left}return{top:s,left:n}}},Ia=class{constructor(t,e){this.timestamp=Date.now(),this.browserEvent=e,this.leftButton=e.button===0,this.middleButton=e.button===1,this.rightButton=e.button===2,this.buttons=e.buttons,this.target=e.target,this.detail=e.detail||1,e.type==="dblclick"&&(this.detail=2),this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,typeof e.pageX=="number"?(this.posx=e.pageX,this.posy=e.pageY):(this.posx=e.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=e.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=L$.getPositionOfChildWindowRelativeToAncestorWindow(t,e.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},h1=class{constructor(t,e=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e;let n=!1;if(Cu){let r=navigator.userAgent.match(/Chrome\/(\d+)/);n=(r?parseInt(r[1]):123)<=122}if(t){let r=t,o=t,a=t.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")n?this.deltaY=r.wheelDeltaY/(120*a):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?dd&&!xn?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(typeof r.wheelDeltaX<"u")r$&&J4?this.deltaX=-(r.wheelDeltaX/120):n?this.deltaX=r.wheelDeltaX/(120*a):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if(t.type==="wheel"){let l=t;l.deltaMode===l.DOM_DELTA_LINE?dd&&!xn?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}this.deltaY===0&&this.deltaX===0&&t.wheelDelta&&(n?this.deltaY=t.wheelDelta/(120*a):this.deltaY=t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Z4=Object.freeze(function(t,e){let s=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(s)}}}),S$;(t=>{function e(s){return s===t.None||s===t.Cancelled||s instanceof w$?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:is.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Z4})})(S$||={});var w$=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Z4:(this._emitter||(this._emitter=new ve),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Vu=class{constructor(t,e){this._isDisposed=!1,this._token=-1,typeof t=="function"&&typeof e=="number"&&this.setIfNotSet(t,e)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,e){if(this._isDisposed)throw new id("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,t()},e)}setIfNotSet(t,e){if(this._isDisposed)throw new id("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,t()},e))}},j$=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,e,s=globalThis){if(this.isDisposed)throw new id("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{t()},e);this.disposable=_t(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},C$;(t=>{async function e(n){let r,o=await Promise.all(n.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return o}t.settled=e;function s(n){return new Promise(async(r,o)=>{try{await n(r,o)}catch(a){o(a)}})}t.withAsyncBody=s})(C$||={});var f1=class Us{static fromArray(e){return new Us(s=>{s.emitMany(e)})}static fromPromise(e){return new Us(async s=>{s.emitMany(await e)})}static fromPromises(e){return new Us(async s=>{await Promise.all(e.map(async n=>s.emitOne(await n)))})}static merge(e){return new Us(async s=>{await Promise.all(e.map(async n=>{for await(let r of n)s.emitOne(r)}))})}constructor(e,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new ve,queueMicrotask(async()=>{let n={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(n)),this.resolve()}catch(r){this.reject(r)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await is.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,s){return new Us(async n=>{for await(let r of e)n.emitOne(s(r))})}map(e){return Us.map(this,e)}static filter(e,s){return new Us(async n=>{for await(let r of e)s(r)&&n.emitOne(r)})}filter(e){return Us.filter(this,e)}static coalesce(e){return Us.filter(e,s=>!!s)}coalesce(){return Us.coalesce(this)}static async toPromise(e){let s=[];for await(let n of e)s.push(n);return s}toPromise(){return Us.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};f1.EMPTY=f1.fromArray([]);var{getWindow:fn,getWindowId:k$,onDidRegisterWindow:V$}=(function(){let t=new Map,e={window:Vn,disposables:new Gn};t.set(Vn.vscodeWindowId,e);let s=new ve,n=new ve,r=new ve;function o(a,l){return(typeof a=="number"?t.get(a):void 0)??(l?e:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:n.event,registerWindow(a){if(t.has(a.vscodeWindowId))return Qe.None;let l=new Gn,c={window:a,disposables:l.add(new Gn)};return t.set(a.vscodeWindowId,c),l.add(_t(()=>{t.delete(a.vscodeWindowId),n.fire(a)})),l.add(He(a,Ht.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(c),l},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return t.has(a)},getWindowById:o,getWindow(a){let l=a;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c?.view?c.view.window:Vn},getDocument(a){return fn(a).document}}})(),N$=class{constructor(t,e,s,n){this._node=t,this._type=e,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function He(t,e,s,n){return new N$(t,e,s,n)}var m1=function(t,e,s,n){return He(t,e,s,n)},Nu,A$=class extends j${constructor(t){super(),this.defaultTarget=t&&fn(t)}cancelAndSet(t,e,s){return super.cancelAndSet(t,e,s??this.defaultTarget)}},p1=class{constructor(t,e=0){this._runner=t,this.priority=e,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){Wa(t)}}static sort(t,e){return e.priority-t.priority}};(function(){let t=new Map,e=new Map,s=new Map,n=new Map,r=o=>{s.set(o,!1);let a=t.get(o)??[];for(e.set(o,a),t.set(o,[]),n.set(o,!0);a.length>0;)a.sort(p1.sort),a.shift().execute();n.set(o,!1)};Nu=(o,a,l=0)=>{let c=k$(o),d=new p1(a,l),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(d),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>r(c))),d}})();function T$(t){let e=t.getBoundingClientRect(),s=fn(t);return{left:e.left+s.scrollX,top:e.top+s.scrollY,width:e.width,height:e.height}}var Ht={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},E$=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let e=Ss(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Ss(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Ss(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Ss(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Ss(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Ss(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Ss(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Ss(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Ss(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Ss(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Ss(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Ss(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Ss(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Ss(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Ss(t){return typeof t=="number"?`${t}px`:t}function Vo(t){return new E$(t)}var e5=class{constructor(){this._hooks=new Gn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(e)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,e,s,n,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=r;let o=t;try{t.setPointerCapture(e),this._hooks.add(_t(()=>{try{t.releasePointerCapture(e)}catch{}}))}catch{o=fn(t)}this._hooks.add(He(o,Ht.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(He(o,Ht.POINTER_UP,a=>this.stopMonitoring(!0)))}};function R$(t,e,s){let n=null,r=null;if(typeof s.value=="function"?(n="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${e}`;s[n]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[o]}}var dn;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(dn||={});var uo=class os extends Qe{constructor(){super(),this.dispatched=!1,this.targets=new r1,this.ignoreTargets=new r1,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(is.runAndSubscribe(V$,({window:e,disposables:s})=>{s.add(He(e.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(He(e.document,"touchend",n=>this.onTouchEnd(e,n))),s.add(He(e.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:Vn,disposables:this._store}))}static addTarget(e){if(!os.isTouchDevice())return Qe.None;os.INSTANCE||(os.INSTANCE=new os);let s=os.INSTANCE.targets.push(e);return _t(s)}static ignoreTarget(e){if(!os.isTouchDevice())return Qe.None;os.INSTANCE||(os.INSTANCE=new os);let s=os.INSTANCE.ignoreTargets.push(e);return _t(s)}static isTouchDevice(){return"ontouchstart"in Vn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,r=e.targetTouches.length;n<r;n++){let o=e.targetTouches.item(n);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(dn.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,s){let n=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=Date.now()-c.initialTimeStamp;if(d<os.HOLD_DELAY&&Math.abs(c.initialPageX-Es(c.rollingPageX))<30&&Math.abs(c.initialPageY-Es(c.rollingPageY))<30){let h=this.newGestureEvent(dn.Tap,c.initialTarget);h.pageX=Es(c.rollingPageX),h.pageY=Es(c.rollingPageY),this.dispatchEvent(h)}else if(d>=os.HOLD_DELAY&&Math.abs(c.initialPageX-Es(c.rollingPageX))<30&&Math.abs(c.initialPageY-Es(c.rollingPageY))<30){let h=this.newGestureEvent(dn.Contextmenu,c.initialTarget);h.pageX=Es(c.rollingPageX),h.pageY=Es(c.rollingPageY),this.dispatchEvent(h)}else if(r===1){let h=Es(c.rollingPageX),u=Es(c.rollingPageY),f=Es(c.rollingTimestamps)-c.rollingTimestamps[0],m=h-c.rollingPageX[0],p=u-c.rollingPageY[0],g=[...this.targets].filter(x=>c.initialTarget instanceof Node&&x.contains(c.initialTarget));this.inertia(e,g,n,Math.abs(m)/f,m>0?1:-1,h,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(dn.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,s){let n=document.createEvent("CustomEvent");return n.initEvent(e,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(e){if(e.type===dn.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>os.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,e.tapCount=n}else(e.type===dn.Change||e.type===dn.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(e.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(e.initialTarget)){let r=0,o=e.initialTarget;for(;o&&o!==n;)r++,o=o.parentElement;s.push([r,n])}s.sort((n,r)=>n[0]-r[0]);for(let[n,r]of s)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,s,n,r,o,a,l,c,d){this.handle=Nu(e,()=>{let h=Date.now(),u=h-n,f=0,m=0,p=!0;r+=os.SCROLL_FRICTION*u,l+=os.SCROLL_FRICTION*u,r>0&&(p=!1,f=o*r*u),l>0&&(p=!1,m=c*l*u);let g=this.newGestureEvent(dn.Change);g.translationX=f,g.translationY=m,s.forEach(x=>x.dispatchEvent(g)),p||this.inertia(e,s,h,r,o,a+f,l,c,d+m)})}onTouchMove(e){let s=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let o=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(dn.Change,a.initialTarget);l.translationX=o.pageX-Es(a.rollingPageX),l.translationY=o.pageY-Es(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};uo.SCROLL_FRICTION=-.005,uo.HOLD_DELAY=700,uo.CLEAR_TAP_COUNT_TIME=400,Vt([R$],uo,"isTouchDevice",1);var P$=uo,Au=class extends Qe{onclick(t,e){this._register(He(t,Ht.CLICK,s=>e(new Ia(fn(t),s))))}onmousedown(t,e){this._register(He(t,Ht.MOUSE_DOWN,s=>e(new Ia(fn(t),s))))}onmouseover(t,e){this._register(He(t,Ht.MOUSE_OVER,s=>e(new Ia(fn(t),s))))}onmouseleave(t,e){this._register(He(t,Ht.MOUSE_LEAVE,s=>e(new Ia(fn(t),s))))}onkeydown(t,e){this._register(He(t,Ht.KEY_DOWN,s=>e(new d1(s))))}onkeyup(t,e){this._register(He(t,Ht.KEY_UP,s=>e(new d1(s))))}oninput(t,e){this._register(He(t,Ht.INPUT,e))}onblur(t,e){this._register(He(t,Ht.BLUR,e))}onfocus(t,e){this._register(He(t,Ht.FOCUS,e))}onchange(t,e){this._register(He(t,Ht.CHANGE,e))}ignoreGesture(t){return P$.ignoreTarget(t)}},g1=11,I$=class extends Au{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=g1+"px",this.domNode.style.height=g1+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new e5),this._register(m1(this.bgDomNode,Ht.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(m1(this.domNode,Ht.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new A$),this._pointerdownScheduleRepeatTimer=this._register(new Vu)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,fn(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},D$=class fd{constructor(e,s,n,r,o,a,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,r=r|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>n&&(r=n-s),r<0&&(r=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=n,this.scrollLeft=r,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,s){return new fd(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new fd(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,s){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,o=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:s,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},O$=class extends Qe{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ve),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new D$(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let s=this._state.withScrollDimensions(t,e);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let s=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;e?n=new v1(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(t);this._smoothScrolling=v1.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,e)))}},x1=class{constructor(t,e,s){this.scrollLeft=t,this.scrollTop=e,this.isDone=s}};function p0(t,e){let s=e-t;return function(n){return t+s*B$(n)}}function M$(t,e,s){return function(n){return n<s?t(n/s):e((n-s)/(1-s))}}var v1=class md{constructor(e,s,n,r){this.from=e,this.to=s,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,s,n){if(Math.abs(e-s)>2.5*n){let r,o;return e<s?(r=e+.75*n,o=s-.75*n):(r=e-.75*n,o=s+.75*n),M$(p0(e,r),p0(o,s),.33)}return p0(e,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let s=(e-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),r=this.scrollTop(s);return new x1(n,r,!1)}return new x1(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,s,n){return md.start(e,s,n)}static start(e,s,n){n=n+10;let r=Date.now()-10;return new md(e,s,r,n)}};function $$(t){return Math.pow(t,3)}function B$(t){return 1-$$(1-t)}var z$=class extends Qe{constructor(t,e,s){super(),this._visibility=t,this._visibleClassName=e,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Vu)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},F$=140,t5=class extends Au{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new z$(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new e5),this._shouldRender=!0,this.domNode=Vo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(He(this.domNode.domNode,Ht.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(t){let e=this._register(new I$(t));this.domNode.domNode.appendChild(e.bgDomNode),this.domNode.domNode.appendChild(e.domNode)}_createSlider(t,e,s,n){this.slider=Vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(e),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(He(this.slider.domNode,Ht.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let e=this.domNode.domNode.getClientRects()[0].top,s=e+this._scrollbarState.getSliderPosition(),n=e+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(t);s<=r&&r<=n?t.button===0&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let e,s;if(t.target===this.domNode.domNode&&typeof t.offsetX=="number"&&typeof t.offsetY=="number")e=t.offsetX,s=t.offsetY;else{let r=T$(this.domNode.domNode);e=t.pageX-r.left,s=t.pageY-r.top}let n=this._pointerDownRelativePosition(e,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),t.button===0&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-s);if(J4&&a>F$){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(r)-e;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let e={};this.writeScrollPosition(e,t),this._scrollable.setScrollPositionNow(e)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},s5=class pd{constructor(e,s,n,r,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new pd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let s=Math.round(e);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(e){let s=Math.round(e);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let s=Math.round(e);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,s,n,r,o){let a=Math.max(0,n-e),l=Math.max(0,a-2*s),c=r>0&&r>n;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(n*l/r))),h=(l-d)/(r-n),u=o*h;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(d),computedSliderRatio:h,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let e=pd._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let s=e-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+e;return Math.round(s/this._computedSliderRatio)}},U$=class extends t5{constructor(t,e,s){let n=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new s5(e.horizontalHasArrows?e.arrowSize:0,e.horizontal===2?0:e.horizontalScrollbarSize,e.vertical===2?0:e.verticalScrollbarSize,n.width,n.scrollWidth,r.scrollLeft),visibility:e.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:e.scrollByPage}),e.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((e.horizontalScrollbarSize-e.horizontalSliderSize)/2),0,void 0,e.horizontalSliderSize)}_updateSlider(t,e){this.slider.setWidth(t),this.slider.setLeft(e)}_renderDomNode(t,e){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,e){t.scrollLeft=e}updateOptions(t){this.updateScrollbarSize(t.horizontal===2?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},H$=class extends t5{constructor(t,e,s){let n=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:s,scrollbarState:new s5(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,n.height,n.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},K$=500,b1=50,W$=class{constructor(t,e,s){this.timestamp=t,this.deltaX=e,this.deltaY=s,this.score=0}},gd=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,s=0,n=1,r=this._rear;do{let o=r===this._front?e:Math.pow(2,-n);if(e-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(e){if(Cu){let s=fn(e.browserEvent),n=n$(s);this.accept(Date.now(),e.deltaX*n,e.deltaY*n)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,s,n){let r=null,o=new W$(e,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(e,s){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),s){let r=Math.abs(e.deltaX),o=Math.abs(e.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(r,a),1),d=Math.max(Math.min(o,l),1),h=Math.max(r,a),u=Math.max(o,l);h%c===0&&u%d===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};gd.INSTANCE=new gd;var q$=gd,G$=class extends Au{constructor(t,e,s){super(),this._onScroll=this._register(new ve),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ve),this.onWillScroll=this._onWillScroll.event,this._options=J$(e),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let n={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new H$(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new U$(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Vo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Vu),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Vi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,xn&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new h1(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Vi(this._mouseWheelToDispose),t)){let e=s=>{this._onMouseWheel(new h1(s))};this._mouseWheelToDispose.push(He(this._listenOnDomNode,Ht.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=q$.INSTANCE;e.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,o=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let a=!xn&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(r){let d=b1*r,h=l.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let d=b1*o,h=l.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,s=t.scrollLeft>0,n=s?" left":"",r=e?" top":"",o=s||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),K$)}},Y$=class extends G${constructor(t,e,s){super(t,e,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function J$(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,xn&&(e.className+=" mac"),e}var xd=class extends Qe{constructor(t,e,s,n,r,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new ve),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new O$({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>Nu(n.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Y$(e,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(is.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),t.appendChild(this._scrollableElement.getDomNode()),this._register(_t(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),e.appendChild(this._styleElement),this._register(_t(()=>this._styleElement.remove())),this._register(is.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
511
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(t){let e=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:e.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,e){e&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!e,scrollTop:t*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(t){t!==void 0&&(this._latestYDisp=t),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(t=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let e=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=e-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=e,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};xd=Vt([we(2,ys),we(3,In),we(4,D4),we(5,zr),we(6,Ls),we(7,Dn)],xd);var vd=class extends Qe{constructor(t,e,s,n,r){super(),this._screenElement=t,this._bufferService=e,this._coreBrowserService=s,this._decorationService=n,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(_t(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let e=this._coreBrowserService.mainDocument.createElement("div");e.classList.add("xterm-decoration"),e.classList.toggle("xterm-decoration-top-layer",t?.options?.layer==="top"),e.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,e.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,e.style.top=`${(t.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,e.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=t.options.x??0;return s&&s>this._bufferService.cols&&(e.style.display="none"),this._refreshXPosition(t,e),e}_refreshStyle(t){let e=t.marker.line-this._bufferService.buffers.active.ydisp;if(e<0||e>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose(()=>{this._decorationElements.delete(t),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(t.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${e*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,e=t.element){if(!e)return;let s=t.options.x??0;(t.options.anchor||"left")==="right"?e.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":e.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};vd=Vt([we(1,ys),we(2,In),we(3,fa),we(4,Dn)],vd);var X$=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(t){if(t.options.overviewRulerOptions){for(let e of this._zones)if(e.color===t.options.overviewRulerOptions.color&&e.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(e,t.marker.line))return;if(this._lineAdjacentToZone(e,t.marker.line,t.options.overviewRulerOptions.position)){this._addLineToZone(e,t.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,e){return e>=t.startBufferLine&&e<=t.endBufferLine}_lineAdjacentToZone(t,e,s){return e>=t.startBufferLine-this._linePadding[s||"full"]&&e<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,e){t.startBufferLine=Math.min(t.startBufferLine,e),t.endBufferLine=Math.max(t.endBufferLine,e)}},ln={full:0,left:0,center:0,right:0},$n={full:0,left:0,center:0,right:0},Jr={full:0,left:0,center:0,right:0},Il=class extends Qe{constructor(t,e,s,n,r,o,a,l){super(),this._viewportElement=t,this._screenElement=e,this._bufferService=s,this._decorationService=n,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new X$,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(_t(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let t=Math.floor((this._canvas.width-1)/3),e=Math.ceil((this._canvas.width-1)/3);$n.full=this._canvas.width,$n.left=t,$n.center=e,$n.right=t,this._refreshDrawHeightConstants(),Jr.full=1,Jr.left=1,Jr.center=1+$n.left,Jr.right=1+$n.left+$n.center}_refreshDrawHeightConstants(){ln.full=Math.round(2*this._coreBrowserService.dpr);let t=this._canvas.height/this._bufferService.buffer.lines.length,e=Math.round(Math.max(Math.min(t,12),6)*this._coreBrowserService.dpr);ln.left=e,ln.center=e,ln.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ln.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let e of t)e.position!=="full"&&this._renderColorZone(e);for(let e of t)e.position==="full"&&this._renderColorZone(e);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(Jr[t.position||"full"],Math.round((this._canvas.height-1)*(t.startBufferLine/this._bufferService.buffers.active.lines.length)-ln[t.position||"full"]/2),$n[t.position||"full"],Math.round((this._canvas.height-1)*((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length)+ln[t.position||"full"]))}_queueRefresh(t,e){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=e||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Il=Vt([we(2,ys),we(3,fa),we(4,Dn),we(5,Ls),we(6,zr),we(7,In)],Il);var fe;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
512
+ `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(fe||={});var Ya;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(Ya||={});var n5;(t=>t.ST=`${fe.ESC}\\`)(n5||={});var bd=class{constructor(t,e,s,n,r,o){this._textarea=t,this._compositionView=e,this._bufferService=s,this._optionsService=n,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(t.keyCode===20||t.keyCode===229||t.keyCode===16||t.keyCode===17||t.keyCode===18)return!1;this._finalizeComposition(!1)}return t.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;e.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(e.start,this._compositionPosition.start):s=this._textarea.value.substring(e.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let e=this._textarea.value,s=e.replace(t,"");this._dataAlreadySent=s,e.length>t.length?this._coreService.triggerDataEvent(s,!0):e.length<t.length?this._coreService.triggerDataEvent(`${fe.DEL}`,!0):e.length===t.length&&e!==t&&this._coreService.triggerDataEvent(e,!0)}},0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}t||setTimeout(()=>this.updateCompositionElements(!0),0)}}};bd=Vt([we(2,ys),we(3,Ls),we(4,Bi),we(5,Dn)],bd);var Wt=0,qt=0,Gt=0,jt=0,_1={css:"#00000000",rgba:0},Dt;(t=>{function e(r,o,a,l){return l!==void 0?`#${ci(r)}${ci(o)}${ci(a)}${ci(l)}`:`#${ci(r)}${ci(o)}${ci(a)}`}t.toCss=e;function s(r,o,a,l=255){return(r<<24|o<<16|a<<8|l)>>>0}t.toRgba=s;function n(r,o,a,l){return{css:t.toCss(r,o,a,l),rgba:t.toRgba(r,o,a,l)}}t.toColor=n})(Dt||={});var vt;(t=>{function e(c,d){if(jt=(d.rgba&255)/255,jt===1)return{css:d.css,rgba:d.rgba};let h=d.rgba>>24&255,u=d.rgba>>16&255,f=d.rgba>>8&255,m=c.rgba>>24&255,p=c.rgba>>16&255,g=c.rgba>>8&255;Wt=m+Math.round((h-m)*jt),qt=p+Math.round((u-p)*jt),Gt=g+Math.round((f-g)*jt);let x=Dt.toCss(Wt,qt,Gt),v=Dt.toRgba(Wt,qt,Gt);return{css:x,rgba:v}}t.blend=e;function s(c){return(c.rgba&255)===255}t.isOpaque=s;function n(c,d,h){let u=Ja.ensureContrastRatio(c.rgba,d.rgba,h);if(u)return Dt.toColor(u>>24&255,u>>16&255,u>>8&255)}t.ensureContrastRatio=n;function r(c){let d=(c.rgba|255)>>>0;return[Wt,qt,Gt]=Ja.toChannels(d),{css:Dt.toCss(Wt,qt,Gt),rgba:d}}t.opaque=r;function o(c,d){return jt=Math.round(d*255),[Wt,qt,Gt]=Ja.toChannels(c.rgba),{css:Dt.toCss(Wt,qt,Gt,jt),rgba:Dt.toRgba(Wt,qt,Gt,jt)}}t.opacity=o;function a(c,d){return jt=c.rgba&255,o(c,jt*d/255)}t.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}t.toColorRGB=l})(vt||={});var wt;(t=>{let e,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(e=o,e.globalCompositeOperation="copy",s=e.createLinearGradient(0,0,1,1))}catch{}function n(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Wt=parseInt(r.slice(1,2).repeat(2),16),qt=parseInt(r.slice(2,3).repeat(2),16),Gt=parseInt(r.slice(3,4).repeat(2),16),Dt.toColor(Wt,qt,Gt);case 5:return Wt=parseInt(r.slice(1,2).repeat(2),16),qt=parseInt(r.slice(2,3).repeat(2),16),Gt=parseInt(r.slice(3,4).repeat(2),16),jt=parseInt(r.slice(4,5).repeat(2),16),Dt.toColor(Wt,qt,Gt,jt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Wt=parseInt(o[1]),qt=parseInt(o[2]),Gt=parseInt(o[3]),jt=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Dt.toColor(Wt,qt,Gt,jt);if(!e||!s)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=s,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Wt,qt,Gt,jt]=e.getImageData(0,0,1,1).data,jt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Dt.toRgba(Wt,qt,Gt,jt),css:r}}t.toColor=n})(wt||={});var gs;(t=>{function e(n){return s(n>>16&255,n>>8&255,n&255)}t.relativeLuminance=e;function s(n,r,o){let a=n/255,l=r/255,c=o/255,d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return d*.2126+h*.7152+u*.0722}t.relativeLuminance2=s})(gs||={});var Ja;(t=>{function e(a,l){if(jt=(l&255)/255,jt===1)return l;let c=l>>24&255,d=l>>16&255,h=l>>8&255,u=a>>24&255,f=a>>16&255,m=a>>8&255;return Wt=u+Math.round((c-u)*jt),qt=f+Math.round((d-f)*jt),Gt=m+Math.round((h-m)*jt),Dt.toRgba(Wt,qt,Gt)}t.blend=e;function s(a,l,c){let d=gs.relativeLuminance(a>>8),h=gs.relativeLuminance(l>>8);if(wn(d,h)<c){if(h<d){let m=n(a,l,c),p=wn(d,gs.relativeLuminance(m>>8));if(p<c){let g=r(a,l,c),x=wn(d,gs.relativeLuminance(g>>8));return p>x?m:g}return m}let u=r(a,l,c),f=wn(d,gs.relativeLuminance(u>>8));if(f<c){let m=n(a,l,c),p=wn(d,gs.relativeLuminance(m>>8));return f>p?u:m}return u}}t.ensureContrastRatio=s;function n(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=wn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));for(;g<c&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=wn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.reduceLuminance=n;function r(a,l,c){let d=a>>24&255,h=a>>16&255,u=a>>8&255,f=l>>24&255,m=l>>16&255,p=l>>8&255,g=wn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));for(;g<c&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=wn(gs.relativeLuminance2(f,m,p),gs.relativeLuminance2(d,h,u));return(f<<24|m<<16|p<<8|255)>>>0}t.increaseLuminance=r;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}t.toChannels=o})(Ja||={});function ci(t){let e=t.toString(16);return e.length<2?"0"+e:e}function wn(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var Q$=class extends ha{constructor(t,e,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Dl=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new qs}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let s=[],n=e.translateToString(!0),r=0,o=0,a=0,l=e.getFg(0),c=e.getBg(0);for(let d=0;d<e.getTrimmedLength();d++)if(e.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(d-r>1){let h=this._getJoinedRanges(n,a,o,e,r);for(let u=0;u<h.length;u++)s.push(h[u])}r=d,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||Hn.length}if(this._bufferService.cols-r>1){let d=this._getJoinedRanges(n,a,o,e,r);for(let h=0;h<d.length;h++)s.push(d[h])}return s}_getJoinedRanges(t,e,s,n,r){let o=t.substring(e,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(o);for(let d=0;d<c.length;d++)Dl._mergeRanges(a,c[d])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,n,r),a}_stringRangesToCellRanges(t,e,s){let n=0,r=!1,o=0,a=t[n];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=e.getWidth(l),d=e.getString(l).length||Hn.length;if(c!==0){if(!r&&a[0]<=o&&(a[0]=l,r=!0),a[1]<=o){if(a[1]=l,a=t[++n],!a)break;a[0]<=o?(a[0]=l,r=!0):r=!1}o+=d}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let s=!1;for(let n=0;n<t.length;n++){let r=t[n];if(s){if(e[1]<=r[0])return t[n-1][1]=e[1],t;if(e[1]<=r[1])return t[n-1][1]=Math.max(e[1],r[1]),t.splice(n,1),t;t.splice(n,1),n--}else{if(e[1]<=r[0])return t.splice(n,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),s=!0);continue}}return s?t[t.length-1][1]=e[1]:t.push(e),t}};Dl=Vt([we(0,ys)],Dl);function Z$(t){return 57508<=t&&t<=57558}function eB(t){return 9472<=t&&t<=9631}function tB(t){return Z$(t)||eB(t)}function sB(){return{css:{canvas:Da(),cell:Da()},device:{canvas:Da(),cell:Da(),char:{width:0,height:0,left:0,top:0}}}}function Da(){return{width:0,height:0}}var _d=class{constructor(t,e,s,n,r,o,a){this._document=t,this._characterJoinerService=e,this._optionsService=s,this._coreBrowserService=n,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new qs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,e,s){this._selectionStart=t,this._selectionEnd=e,this._columnSelectMode=s}createRow(t,e,s,n,r,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(e),m=this._themeService.colors,p=t.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,x=0,v="",_=0,b=0,y=0,L=0,w=!1,S=0,j=!1,C=0,V=0,N=[],T=d!==-1&&h!==-1;for(let A=0;A<p;A++){t.loadCell(A,this._workCell);let E=this._workCell.getWidth();if(E===0)continue;let R=!1,D=A>=V,P=A,I=this._workCell;if(f.length>0&&A===f[0][0]&&D){let ee=f.shift(),q=this._isCellInSelection(ee[0],e);for(_=ee[0]+1;_<ee[1];_++)D&&=q===this._isCellInSelection(_,e);D&&=!s||o<ee[0]||o>=ee[1],D?(R=!0,I=new Q$(this._workCell,t.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),P=ee[1]-1,E=I.getWidth()):V=ee[1]}let O=this._isCellInSelection(A,e),B=s&&A===o,z=T&&A>=d&&A<=h,$=!1;this._decorationService.forEachDecorationAtCell(A,e,void 0,ee=>{$=!0});let U=I.getChars()||Hn;if(U===" "&&(I.isUnderline()||I.isOverline())&&(U=" "),C=E*l-c.get(U,I.isBold(),I.isItalic()),!g)g=this._document.createElement("span");else if(x&&(O&&j||!O&&!j&&I.bg===b)&&(O&&j&&m.selectionForeground||I.fg===y)&&I.extended.ext===L&&z===w&&C===S&&!B&&!R&&!$&&D){I.isInvisible()?v+=Hn:v+=U,x++;continue}else x&&(g.textContent=v),g=this._document.createElement("span"),x=0,v="";if(b=I.bg,y=I.fg,L=I.extended.ext,w=z,S=C,j=O,R&&o>=A&&o<=P&&(o=A),!this._coreService.isCursorHidden&&B&&this._coreService.isCursorInitialized){if(N.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&N.push("xterm-cursor-blink"),N.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":N.push("xterm-cursor-outline");break;case"block":N.push("xterm-cursor-block");break;case"bar":N.push("xterm-cursor-bar");break;case"underline":N.push("xterm-cursor-underline");break}}if(I.isBold()&&N.push("xterm-bold"),I.isItalic()&&N.push("xterm-italic"),I.isDim()&&N.push("xterm-dim"),I.isInvisible()?v=Hn:v=I.getChars()||Hn,I.isUnderline()&&(N.push(`xterm-underline-${I.extended.underlineStyle}`),v===" "&&(v=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${ha.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let ee=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&ee<8&&(ee+=8),g.style.textDecorationColor=m.ansi[ee].css}I.isOverline()&&(N.push("xterm-overline"),v===" "&&(v=" ")),I.isStrikethrough()&&N.push("xterm-strikethrough"),z&&(g.style.textDecoration="underline");let W=I.getFgColor(),X=I.getFgColorMode(),H=I.getBgColor(),Z=I.getBgColorMode(),K=!!I.isInverse();if(K){let ee=W;W=H,H=ee;let q=X;X=Z,Z=q}let Y,F,Q=!1;this._decorationService.forEachDecorationAtCell(A,e,void 0,ee=>{ee.options.layer!=="top"&&Q||(ee.backgroundColorRGB&&(Z=50331648,H=ee.backgroundColorRGB.rgba>>8&16777215,Y=ee.backgroundColorRGB),ee.foregroundColorRGB&&(X=50331648,W=ee.foregroundColorRGB.rgba>>8&16777215,F=ee.foregroundColorRGB),Q=ee.options.layer==="top")}),!Q&&O&&(Y=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,H=Y.rgba>>8&16777215,Z=50331648,Q=!0,m.selectionForeground&&(X=50331648,W=m.selectionForeground.rgba>>8&16777215,F=m.selectionForeground)),Q&&N.push("xterm-decoration-top");let J;switch(Z){case 16777216:case 33554432:J=m.ansi[H],N.push(`xterm-bg-${H}`);break;case 50331648:J=Dt.toColor(H>>16,H>>8&255,H&255),this._addStyle(g,`background-color:#${y1((H>>>0).toString(16),"0",6)}`);break;default:K?(J=m.foreground,N.push("xterm-bg-257")):J=m.background}switch(Y||I.isDim()&&(Y=vt.multiplyOpacity(J,.5)),X){case 16777216:case 33554432:I.isBold()&&W<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(W+=8),this._applyMinimumContrast(g,J,m.ansi[W],I,Y,void 0)||N.push(`xterm-fg-${W}`);break;case 50331648:let ee=Dt.toColor(W>>16&255,W>>8&255,W&255);this._applyMinimumContrast(g,J,ee,I,Y,F)||this._addStyle(g,`color:#${y1(W.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,J,m.foreground,I,Y,F)||K&&N.push("xterm-fg-257")}N.length&&(g.className=N.join(" "),N.length=0),!B&&!R&&!$&&D?x++:g.textContent=v,C!==this.defaultSpacing&&(g.style.letterSpacing=`${C}px`),u.push(g),A=P}return g&&x&&(g.textContent=v),u}_applyMinimumContrast(t,e,s,n,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||tB(n.getCode()))return!1;let a=this._getContrastCache(n),l;if(!r&&!o&&(l=a.getColor(e.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=vt.ensureContrastRatio(r||e,o||s,c),a.setColor((r||e).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(t,`color:${l.css}`),!0):!1}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,e){t.setAttribute("style",`${t.getAttribute("style")||""}${e};`)}_isCellInSelection(t,e){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?t>=s[0]&&e>=s[1]&&t<n[0]&&e<=n[1]:t<s[0]&&e>=s[1]&&t>=n[0]&&e<=n[1]:e>s[1]&&e<n[1]||s[1]===n[1]&&e===s[1]&&t>=s[0]&&t<n[0]||s[1]<n[1]&&e===n[1]&&t<n[0]||s[1]<n[1]&&e===s[1]&&t>=s[0]}};_d=Vt([we(1,$4),we(2,Ls),we(3,In),we(4,Bi),we(5,fa),we(6,zr)],_d);function y1(t,e,s){for(;t.length<s;)t=e+t;return t}var nB=class{constructor(t,e){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=t.createElement("span");s.classList.add("xterm-char-measure-element");let n=t.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=t.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,n,r,o],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(o),e.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(t,e,s,n){t===this._font&&e===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=t,this._fontSize=e,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(t,e,s){let n=0;if(!e&&!s&&t.length===1&&(n=t.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let a=this._measure(t,0);return a>0&&(this._flat[n]=a),a}let r=t;e&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;e&&(a|=1),s&&(a|=2),o=this._measure(t,a),o>0&&this._holey.set(r,o)}return o}_measure(t,e){let s=this._measureElements[e];return s.textContent=t.repeat(32),s.offsetWidth/32}},iB=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(t,e,s,n=!1){if(this.selectionStart=e,this.selectionEnd=s,!e||!s||e[0]===s[0]&&e[1]===s[1]){this.clear();return}let r=t.buffers.active.ydisp,o=e[1]-r,a=s[1]-r,l=Math.max(o,0),c=Math.min(a,t.rows-1);if(l>=t.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=s[0]}isCellSelected(t,e,s){return this.hasSelection?(s-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&s>=this.viewportCappedStartRow&&e<this.endCol&&s<=this.viewportCappedEndRow:e<this.startCol&&s>=this.viewportCappedStartRow&&e>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&e>=this.startCol):!1}};function rB(){return new iB}var g0="xterm-dom-renderer-owner-",Fs="xterm-rows",Oa="xterm-fg-",L1="xterm-bg-",Xr="xterm-focus",Ma="xterm-selection",oB=1,yd=class extends Qe{constructor(t,e,s,n,r,o,a,l,c,d,h,u,f,m){super(),this._terminal=t,this._document=e,this._element=s,this._screenElement=n,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=oB++,this._rowElements=[],this._selectionRenderModel=rB(),this.onRequestRedraw=this._register(new ve).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fs),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ma),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=sB(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(_d,document),this._element.classList.add(g0+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(_t(()=>{this._element.classList.remove(g0+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new nB(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let e=`${this._terminalSelector} .${Fs} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=e,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let e=`${this._terminalSelector} .${Fs} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;e+=`${this._terminalSelector} .${Fs} .xterm-dim { color: ${vt.multiplyOpacity(t.foreground,.5).css};}`,e+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;e+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,e+=`@keyframes ${n} { 50% { box-shadow: none; }}`,e+=`@keyframes ${r} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,e+=`${this._terminalSelector} .${Fs}.${Xr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fs}.${Xr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Fs}.${Xr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Fs} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Fs} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Fs} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fs} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Fs} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,e+=`${this._terminalSelector} .${Ma} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ma} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ma} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of t.ansi.entries())e+=`${this._terminalSelector} .${Oa}${o} { color: ${a.css}; }${this._terminalSelector} .${Oa}${o}.xterm-dim { color: ${vt.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${L1}${o} { background-color: ${a.css}; }`;e+=`${this._terminalSelector} .${Oa}257 { color: ${vt.opaque(t.background).css}; }${this._terminalSelector} .${Oa}257.xterm-dim { color: ${vt.multiplyOpacity(vt.opaque(t.background),.5).css}; }${this._terminalSelector} .${L1}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=e}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${t}px`,this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,e){for(let s=this._rowElements.length;s<=e;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,e){this._refreshRowElements(t,e),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Xr),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Xr),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,e,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,e,s),this.renderRows(0,this._bufferService.rows-1),!t||!e||(this._selectionRenderModel.update(this._terminal,t,e,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=t[0]>e[0];l.appendChild(this._createSelectionElement(o,c?e[0]:t[0],c?t[0]:e[0],a-o+1))}else{let c=n===o?t[0]:0,d=o===r?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,c,d));let h=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==a){let u=r===a?e[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(t,e,s,n=1){let r=this._document.createElement("div"),o=e*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-e);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${n*this.dimensions.css.cell.height}px`,r.style.top=`${t*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let t of this._rowElements)t.replaceChildren()}renderRows(t,e){let s=this._bufferService.buffer,n=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=t;c<=e;c++){let d=c+s.ydisp,h=this._rowElements[c],u=s.lines.get(d);if(!h||!u)break;h.replaceChildren(...this._rowFactory.createRow(u,d,d===n,a,l,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${g0}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,e,s,n,r,o){s<0&&(t=0),n<0&&(e=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),n=Math.max(Math.min(n,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,r-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=n;++m){let p=m+l.ydisp,g=this._rowElements[m],x=l.lines.get(p);if(!g||!x)break;g.replaceChildren(...this._rowFactory.createRow(x,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?m===s?t:0:-1,o?(m===n?e:r)-1:-1))}}};yd=Vt([we(7,Su),we(8,Cc),we(9,Ls),we(10,ys),we(11,Bi),we(12,In),we(13,zr)],yd);var Ld=class extends Qe{constructor(t,e,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ve),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new lB(this._optionsService))}catch{this._measureStrategy=this._register(new aB(t,e,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Ld=Vt([we(2,Ls)],Ld);var i5=class extends Qe{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},aB=class extends i5{constructor(t,e,s){super(),this._document=t,this._parentElement=e,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},lB=class extends i5{constructor(t){super(),this._optionsService=t,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let e=this._ctx.measureText("W");if(!("width"in e&&"fontBoundingBoxAscent"in e&&"fontBoundingBoxDescent"in e))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},cB=class extends Qe{constructor(t,e,s){super(),this._textarea=t,this._window=e,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new dB(this._window)),this._onDprChange=this._register(new ve),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ve),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(is.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(He(this._textarea,"focus",()=>this._isFocused=!0)),this._register(He(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},dB=class extends Qe{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new xr),this._onDprChange=this._register(new ve),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_t(()=>this.clearListener()))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=He(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},uB=class extends Qe{constructor(){super(),this.linkProviders=[],this._register(_t(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Tu(t,e,s){let n=s.getBoundingClientRect(),r=t.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-n.left-o,e.clientY-n.top-a]}function hB(t,e,s,n,r,o,a,l,c){if(!o)return;let d=Tu(t,e,s);if(d)return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),n+(c?1:0)),d[1]=Math.min(Math.max(d[1],1),r),d}var Sd=class{constructor(t,e){this._renderService=t,this._charSizeService=e}getCoords(t,e,s,n,r){return hB(window,t,e,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(t,e){let s=Tu(window,t,e);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Sd=Vt([we(0,Dn),we(1,Cc)],Sd);var fB=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},r5={};SM(r5,{getSafariVersion:()=>pB,isChromeOS:()=>c5,isFirefox:()=>o5,isIpad:()=>gB,isIphone:()=>xB,isLegacyEdge:()=>mB,isLinux:()=>Eu,isMac:()=>Ol,isNode:()=>kc,isSafari:()=>a5,isWindows:()=>l5});var kc=typeof process<"u"&&"title"in process,ma=kc?"node":navigator.userAgent,pa=kc?"node":navigator.platform,o5=ma.includes("Firefox"),mB=ma.includes("Edge"),a5=/^((?!chrome|android).)*safari/i.test(ma);function pB(){if(!a5)return 0;let t=ma.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Ol=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pa),gB=pa==="iPad",xB=pa==="iPhone",l5=["Windows","Win16","Win32","WinCE"].includes(pa),Eu=pa.indexOf("Linux")>=0,c5=/\bCrOS\b/.test(ma),d5=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(t){this._idleCallback=void 0;let e=0,s=0,n=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),s=Math.max(e,s),r=t.timeRemaining(),s*1.5>r){n-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-e))}ms`),this._start();return}n=r}this.clear()}},vB=class extends d5{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},bB=class extends d5{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Ml=!kc&&"requestIdleCallback"in window?bB:vB,_B=class{constructor(){this._queue=new Ml}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},wd=class extends Qe{constructor(t,e,s,n,r,o,a,l,c){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=n,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new xr),this._pausedResizeTask=new _B,this._observerDisposable=this._register(new xr),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new ve),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ve),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ve),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ve),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new fB((d,h)=>this._renderRows(d,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new yB(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_t(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,e),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,e)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,e){if("IntersectionObserver"in t){let s=new t.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(e),this._observerDisposable.value=_t(()=>s.disconnect())}}_handleIntersectionChange(t){this._isPaused=t.isIntersecting===void 0?t.intersectionRatio===0:!t.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(t,e,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}let n=this._syncOutputHandler.flush();n&&(t=Math.min(t,n.start),e=Math.max(e,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,e,this._rowCount)}_renderRows(t,e){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(t,e);return}t=Math.min(t,this._rowCount-1),e=Math.min(e,this._rowCount-1),this._renderer.value.renderRows(t,e),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:e}),this._onRender.fire({start:t,end:e}),this._isNextRenderRedrawOnly=!0}}resize(t,e){this._rowCount=e,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(t,e){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(t,e)):this._renderer.value.handleResize(t,e),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,e,s){this._selectionState.start=t,this._selectionState.end=e,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,e,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};wd=Vt([we(2,Ls),we(3,Cc),we(4,Bi),we(5,fa),we(6,ys),we(7,In),we(8,zr)],wd);var yB=class{constructor(t,e,s){this._coreBrowserService=t,this._coreService=e,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function LB(t,e,s,n){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return jB(r,o,t,e,s,n)+Vc(o,e,s,n)+CB(r,o,t,e,s,n);let a;if(o===e)return a=r>t?"D":"C",Ko(Math.abs(r-t),Ho(a,n));a=o>e?"D":"C";let l=Math.abs(o-e),c=wB(o>e?t:r,s)+(l-1)*s.cols+1+SB(o>e?r:t);return Ko(c,Ho(a,n))}function SB(t,e){return t-1}function wB(t,e){return e.cols-t}function jB(t,e,s,n,r,o){return Vc(e,n,r,o).length===0?"":Ko(h5(t,e,t,e-Ni(e,r),!1,r).length,Ho("D",o))}function Vc(t,e,s,n){let r=t-Ni(t,s),o=e-Ni(e,s),a=Math.abs(r-o)-kB(t,e,s);return Ko(a,Ho(u5(t,e),n))}function CB(t,e,s,n,r,o){let a;Vc(e,n,r,o).length>0?a=n-Ni(n,r):a=e;let l=n,c=VB(t,e,s,n,r,o);return Ko(h5(t,a,s,l,c==="C",r).length,Ho(c,o))}function kB(t,e,s){let n=0,r=t-Ni(t,s),o=e-Ni(e,s);for(let a=0;a<Math.abs(r-o);a++){let l=u5(t,e)==="A"?-1:1;s.buffer.lines.get(r+l*a)?.isWrapped&&n++}return n}function Ni(t,e){let s=0,n=e.buffer.lines.get(t),r=n?.isWrapped;for(;r&&t>=0&&t<e.rows;)s++,n=e.buffer.lines.get(--t),r=n?.isWrapped;return s}function VB(t,e,s,n,r,o){let a;return Vc(s,n,r,o).length>0?a=n-Ni(n,r):a=e,t<s&&a<=n||t>=s&&a<n?"C":"D"}function u5(t,e){return t>e?"A":"B"}function h5(t,e,s,n,r,o){let a=t,l=e,c="";for(;(a!==s||l!==n)&&l>=0&&l<o.buffer.lines.length;)a+=r?1:-1,r&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,t,a),a=0,t=0,l++):!r&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,t+1),a=o.cols-1,t=a,l--);return c+o.buffer.translateBufferLineToString(l,!1,t,a)}function Ho(t,e){let s=e?"O":"[";return fe.ESC+s+t}function Ko(t,e){t=Math.floor(t);let s="";for(let n=0;n<t;n++)s+=e;return s}var NB=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function S1(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var x0=50,AB=15,TB=50,EB=500,RB=" ",PB=new RegExp(RB,"g"),jd=class extends Qe{constructor(t,e,s,n,r,o,a,l,c){super(),this._element=t,this._screenElement=e,this._linkifier=s,this._bufferService=n,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new qs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ve),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ve),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ve),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ve),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new NB(this._bufferService),this._activeSelectionMode=0,this._register(_t(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!t||!e?!1:t[0]!==e[0]||t[1]!==e[1]}get selectionText(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;if(!t||!e)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(t[0]===e[0])return"";let r=t[0]<e[0]?t[0]:e[0],o=t[0]<e[0]?e[0]:t[0];for(let a=t[1];a<=e[1];a++){let l=s.translateBufferLineToString(a,!0,r,o);n.push(l)}}else{let r=t[1]===e[1]?e[0]:void 0;n.push(s.translateBufferLineToString(t[1],!0,t[0],r));for(let o=t[1]+1;o<=e[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?n[n.length-1]+=l:n.push(l)}if(t[1]!==e[1]){let o=s.lines.get(e[1]),a=s.translateBufferLineToString(e[1],!0,0,e[0]);o&&o.isWrapped?n[n.length-1]+=a:n.push(a)}}return n.map(r=>r.replace(PB," ")).join(l5?`\r
513
+ `:`
514
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Eu&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(t){let e=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n||!e?!1:this._areCoordsInSelection(e,s,n)}isCellInSelection(t,e){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([t,e],s,n)}_areCoordsInSelection(t,e,s){return t[1]>e[1]&&t[1]<s[1]||e[1]===s[1]&&t[1]===e[1]&&t[0]>=e[0]&&t[0]<s[0]||e[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||e[1]<s[1]&&t[1]===e[1]&&t[0]>=e[0]}_selectWordAtCursor(t,e){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=S1(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(t);return n?(this._selectWordAt(n,e),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,e){this._model.clearSelection(),t=Math.max(t,0),e=Math.min(e,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,e],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let e=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(e)return e[0]--,e[1]--,e[1]+=this._bufferService.buffer.ydisp,e}_getMouseEventScrollAmount(t){let e=Tu(this._coreBrowserService.window,t,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return e>=0&&e<=s?0:(e>s&&(e-=s),e=Math.min(Math.max(e,-x0),x0),e/=x0,e/Math.abs(e)+Math.round(e*(AB-1)))}shouldForceSelection(t){return Ol?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,!(t.button===2&&this.hasSelection)&&t.button===0){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):t.detail===1?this._handleSingleClick(t):t.detail===2?this._handleDoubleClick(t):t.detail===3&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),TB)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let e=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);e&&e.length!==this._model.selectionStart[0]&&e.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let e=this._getMouseBufferCoords(t);e&&(this._activeSelectionMode=2,this._selectLineAt(e[1]))}shouldColumnSelect(t){return t.altKey&&!(Ol&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.stopImmediatePropagation(),!this._model.selectionStart)return;let e=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(t),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let n=s.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!e||e[0]!==this._model.selectionEnd[0]||e[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let t=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let e=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&e<EB&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let n=LB(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,e=this._model.finalSelectionEnd,s=!!t&&!!e&&(t[0]!==e[0]||t[1]!==e[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(t,e,s);return}!t||!e||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||e[0]!==this._oldSelectionEnd[0]||e[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,e,s)}_fireOnSelectionChange(t,e,s){this._oldSelectionStart=t,this._oldSelectionEnd=e,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(t,e){let s=e;for(let n=0;e>=n;n++){let r=t.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&e!==n&&(s+=r-1)}return s}setSelection(t,e,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,e],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,e,s=!0,n=!0){if(t[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(t[1]);if(!o)return;let a=r.translateBufferLineToString(t[1],!1),l=this._convertViewportColToCharacterIndex(o,t[0]),c=l,d=t[0]-l,h=0,u=0,f=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let x=t[0],v=t[0];o.getWidth(x)===0&&(h++,x--),o.getWidth(v)===2&&(u++,v++);let _=o.getString(v).length;for(_>1&&(m+=_-1,c+=_-1);x>0&&l>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,x--):b>1&&(f+=b-1,l-=b-1),l--,x--}for(;v<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(v+1,this._workCell));){o.loadCell(v+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,v++):b>1&&(m+=b-1,c+=b-1),c++,v++}}c++;let p=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-m);if(!(!e&&a.slice(l,c).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let x=r.lines.get(t[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(v){let _=this._bufferService.cols-v.start;p-=_,g+=_}}}if(n&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=r.lines.get(t[1]+1);if(x?.isWrapped&&x.getCodePoint(0)!==32){let v=this._getWordAt([0,t[1]+1],!1,!1,!0);v&&(g+=v.length)}}return{start:p,length:g}}}_selectWordAt(t,e){let s=this._getWordAt(t,e);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let e=this._getWordAt(t,!0);if(e){let s=t[1];for(;e.start<0;)e.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;e.start+e.length>this._bufferService.cols;)e.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?e.start:e.start+e.length,s]}}_isCharWordSeparator(t){return t.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let e=this._bufferService.buffer.getWrappedRangeForLine(t),s={start:{x:0,y:e.first},end:{x:this._bufferService.cols-1,y:e.last}};this._model.selectionStart=[0,e.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=S1(s,this._bufferService.cols)}};jd=Vt([we(3,ys),we(4,Bi),we(5,wu),we(6,Ls),we(7,Dn),we(8,In)],jd);var w1=class{constructor(){this._data={}}set(t,e,s){this._data[t]||(this._data[t]={}),this._data[t][e]=s}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},j1=class{constructor(){this._color=new w1,this._css=new w1}setCss(t,e,s){this._css.set(t,e,s)}getCss(t,e){return this._css.get(t,e)}setColor(t,e,s){this._color.set(t,e,s)}getColor(t,e){return this._color.get(t,e)}clear(){this._color.clear(),this._css.clear()}},Mt=Object.freeze((()=>{let t=[wt.toColor("#2e3436"),wt.toColor("#cc0000"),wt.toColor("#4e9a06"),wt.toColor("#c4a000"),wt.toColor("#3465a4"),wt.toColor("#75507b"),wt.toColor("#06989a"),wt.toColor("#d3d7cf"),wt.toColor("#555753"),wt.toColor("#ef2929"),wt.toColor("#8ae234"),wt.toColor("#fce94f"),wt.toColor("#729fcf"),wt.toColor("#ad7fa8"),wt.toColor("#34e2e2"),wt.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=e[s/36%6|0],r=e[s/6%6|0],o=e[s%6];t.push({css:Dt.toCss(n,r,o),rgba:Dt.toRgba(n,r,o)})}for(let s=0;s<24;s++){let n=8+s*10;t.push({css:Dt.toCss(n,n,n),rgba:Dt.toRgba(n,n,n)})}return t})()),di=wt.toColor("#ffffff"),ho=wt.toColor("#000000"),C1=wt.toColor("#ffffff"),k1=ho,Qr={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},IB=di,Cd=class extends Qe{constructor(t){super(),this._optionsService=t,this._contrastCache=new j1,this._halfContrastCache=new j1,this._onChangeColors=this._register(new ve),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:di,background:ho,cursor:C1,cursorAccent:k1,selectionForeground:void 0,selectionBackgroundTransparent:Qr,selectionBackgroundOpaque:vt.blend(ho,Qr),selectionInactiveBackgroundTransparent:Qr,selectionInactiveBackgroundOpaque:vt.blend(ho,Qr),scrollbarSliderBackground:vt.opacity(di,.2),scrollbarSliderHoverBackground:vt.opacity(di,.4),scrollbarSliderActiveBackground:vt.opacity(di,.5),overviewRulerBorder:di,ansi:Mt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(t={}){let e=this._colors;if(e.foreground=dt(t.foreground,di),e.background=dt(t.background,ho),e.cursor=vt.blend(e.background,dt(t.cursor,C1)),e.cursorAccent=vt.blend(e.background,dt(t.cursorAccent,k1)),e.selectionBackgroundTransparent=dt(t.selectionBackground,Qr),e.selectionBackgroundOpaque=vt.blend(e.background,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundTransparent=dt(t.selectionInactiveBackground,e.selectionBackgroundTransparent),e.selectionInactiveBackgroundOpaque=vt.blend(e.background,e.selectionInactiveBackgroundTransparent),e.selectionForeground=t.selectionForeground?dt(t.selectionForeground,_1):void 0,e.selectionForeground===_1&&(e.selectionForeground=void 0),vt.isOpaque(e.selectionBackgroundTransparent)&&(e.selectionBackgroundTransparent=vt.opacity(e.selectionBackgroundTransparent,.3)),vt.isOpaque(e.selectionInactiveBackgroundTransparent)&&(e.selectionInactiveBackgroundTransparent=vt.opacity(e.selectionInactiveBackgroundTransparent,.3)),e.scrollbarSliderBackground=dt(t.scrollbarSliderBackground,vt.opacity(e.foreground,.2)),e.scrollbarSliderHoverBackground=dt(t.scrollbarSliderHoverBackground,vt.opacity(e.foreground,.4)),e.scrollbarSliderActiveBackground=dt(t.scrollbarSliderActiveBackground,vt.opacity(e.foreground,.5)),e.overviewRulerBorder=dt(t.overviewRulerBorder,IB),e.ansi=Mt.slice(),e.ansi[0]=dt(t.black,Mt[0]),e.ansi[1]=dt(t.red,Mt[1]),e.ansi[2]=dt(t.green,Mt[2]),e.ansi[3]=dt(t.yellow,Mt[3]),e.ansi[4]=dt(t.blue,Mt[4]),e.ansi[5]=dt(t.magenta,Mt[5]),e.ansi[6]=dt(t.cyan,Mt[6]),e.ansi[7]=dt(t.white,Mt[7]),e.ansi[8]=dt(t.brightBlack,Mt[8]),e.ansi[9]=dt(t.brightRed,Mt[9]),e.ansi[10]=dt(t.brightGreen,Mt[10]),e.ansi[11]=dt(t.brightYellow,Mt[11]),e.ansi[12]=dt(t.brightBlue,Mt[12]),e.ansi[13]=dt(t.brightMagenta,Mt[13]),e.ansi[14]=dt(t.brightCyan,Mt[14]),e.ansi[15]=dt(t.brightWhite,Mt[15]),t.extendedAnsi){let s=Math.min(e.ansi.length-16,t.extendedAnsi.length);for(let n=0;n<s;n++)e.ansi[n+16]=dt(t.extendedAnsi[n],Mt[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(t===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(t){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[t]=this._restoreColors.ansi[t]}}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Cd=Vt([we(0,Ls)],Cd);function dt(t,e){if(t!==void 0)try{return wt.toColor(t)}catch{}return e}var DB=class{constructor(...t){this._entries=new Map;for(let[e,s]of t)this.set(e,s)}set(t,e){let s=this._entries.get(t);return this._entries.set(t,e),s}forEach(t){for(let[e,s]of this._entries.entries())t(e,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},OB=class{constructor(){this._services=new DB,this._services.set(Su,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let s=AM(t).sort((o,a)=>o.index-a.index),n=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);n.push(a)}let r=s.length>0?s[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...n)}},MB={trace:0,debug:1,info:2,warn:3,error:4,off:5},$B="xterm.js: ",kd=class extends Qe{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=MB[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":$B)+e,...s)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};kd=Vt([we(0,Ls)],kd);var V1=class extends Qe{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new ve),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ve),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ve),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let e=new Array(t);for(let s=0;s<Math.min(t,this.length);s++)e[s]=this._array[this._getCyclicIndex(s)];this._array=e,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let e=this._length;e<t;e++)this._array[e]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,e){this._array[this._getCyclicIndex(t)]=e}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(t,e,...s){if(e){for(let n=t;n<this._length-e;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+e)];this._length-=e,this.onDeleteEmitter.fire({index:t,amount:e})}for(let n=this._length-1;n>=t;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(t+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,e,s){if(!(e<=0)){if(t<0||t>=this._length)throw new Error("start argument out of range");if(t+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=e-1;r>=0;r--)this.set(t+r+s,this.get(t+r));let n=t+e+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<e;n++)this.set(t+n+s,this.get(t+n))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},Je=3,It=Object.freeze(new ha),$a=0,v0=2,fo=class f5{constructor(e,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Je);let r=s||qs.fromCharData([0,E4,1,0]);for(let o=0;o<e;++o)this.setCell(o,r);this.length=e}get(e){let s=this._data[e*Je+0],n=s&2097151;return[this._data[e*Je+1],s&2097152?this._combined[e]:n?Fn(n):"",s>>22,s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,s){this._data[e*Je+1]=s[0],s[1].length>1?(this._combined[e]=s[1],this._data[e*Je+0]=e|2097152|s[2]<<22):this._data[e*Je+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(e){return this._data[e*Je+0]>>22}hasWidth(e){return this._data[e*Je+0]&12582912}getFg(e){return this._data[e*Je+1]}getBg(e){return this._data[e*Je+2]}hasContent(e){return this._data[e*Je+0]&4194303}getCodePoint(e){let s=this._data[e*Je+0];return s&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s&2097151}isCombined(e){return this._data[e*Je+0]&2097152}getString(e){let s=this._data[e*Je+0];return s&2097152?this._combined[e]:s&2097151?Fn(s&2097151):""}isProtected(e){return this._data[e*Je+2]&536870912}loadCell(e,s){return $a=e*Je,s.content=this._data[$a+0],s.fg=this._data[$a+1],s.bg=this._data[$a+2],s.content&2097152&&(s.combinedData=this._combined[e]),s.bg&268435456&&(s.extended=this._extendedAttrs[e]),s}setCell(e,s){s.content&2097152&&(this._combined[e]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[e]=s.extended),this._data[e*Je+0]=s.content,this._data[e*Je+1]=s.fg,this._data[e*Je+2]=s.bg}setCellFromCodepoint(e,s,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Je+0]=s|n<<22,this._data[e*Je+1]=r.fg,this._data[e*Je+2]=r.bg}addCodepointToCell(e,s,n){let r=this._data[e*Je+0];r&2097152?this._combined[e]+=Fn(s):r&2097151?(this._combined[e]=Fn(r&2097151)+Fn(s),r&=-2097152,r|=2097152):r=s|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Je+0]=r}insertCells(e,s,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length-e){let r=new qs;for(let o=this.length-e-s-1;o>=0;--o)this.setCell(e+s+o,this.loadCell(e+o,r));for(let o=0;o<s;++o)this.setCell(e+o,n)}else for(let r=e;r<this.length;++r)this.setCell(r,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,s,n){if(e%=this.length,s<this.length-e){let r=new qs;for(let o=0;o<this.length-e-s;++o)this.setCell(e+o,this.loadCell(e+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,n)}else for(let r=e;r<this.length;++r)this.setCell(r,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,s,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);e<s&&e<this.length;)this.setCell(e++,n)}resize(e,s){if(e===this.length)return this._data.length*4*v0<this._data.buffer.byteLength;let n=e*Je;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let r=new Uint32Array(n);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,n);let r=Object.keys(this._combined);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=e&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,n*4*v0<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*v0<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,s=!1){if(s){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,e);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let s in e._combined)this._combined[s]=e._combined[s];this._extendedAttrs={};for(let s in e._extendedAttrs)this._extendedAttrs[s]=e._extendedAttrs[s];this.isWrapped=e.isWrapped}clone(){let e=new f5(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let s in this._combined)e._combined[s]=this._combined[s];for(let s in this._extendedAttrs)e._extendedAttrs[s]=this._extendedAttrs[s];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Je+0]&4194303)return e+(this._data[e*Je+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Je+0]&4194303||this._data[e*Je+2]&50331648)return e+(this._data[e*Je+0]>>22);return 0}copyCellsFrom(e,s,n,r,o){let a=e._data;if(o)for(let c=r-1;c>=0;c--){for(let d=0;d<Je;d++)this._data[(n+c)*Je+d]=a[(s+c)*Je+d];a[(s+c)*Je+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let d=0;d<Je;d++)this._data[(n+c)*Je+d]=a[(s+c)*Je+d];a[(s+c)*Je+2]&268435456&&(this._extendedAttrs[n+c]=e._extendedAttrs[s+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=s&&(this._combined[d-s+n]=e._combined[d])}}translateToString(e,s,n,r){s=s??0,n=n??this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<n;){let a=this._data[s*Je+0],l=a&2097151,c=a&2097152?this._combined[s]:l?Fn(l):Hn;if(o+=c,r)for(let d=0;d<c.length;++d)r.push(s);s+=a>>22||1}return r&&r.push(s),o}};function BB(t,e,s,n,r,o){let a=[];for(let l=0;l<t.length-1;l++){let c=l,d=t.get(++c);if(!d.isWrapped)continue;let h=[t.get(l)];for(;c<t.length&&d.isWrapped;)h.push(d),d=t.get(++c);if(!o&&n>=l&&n<c){l+=h.length-1;continue}let u=0,f=Wo(h,u,e),m=1,p=0;for(;m<h.length;){let x=Wo(h,m,e),v=x-p,_=s-f,b=Math.min(v,_);h[u].copyCellsFrom(h[m],p,f,b,!1),f+=b,f===s&&(u++,f=0),p+=b,p===x&&(m++,p=0),f===0&&u!==0&&h[u-1].getWidth(s-1)===2&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,r))}h[u].replaceCells(f,s,r);let g=0;for(let x=h.length-1;x>0&&(x>u||h[x].getTrimmedLength()===0);x--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}function zB(t,e){let s=[],n=0,r=e[n],o=0;for(let a=0;a<t.length;a++)if(r===a){let l=e[++n];t.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,r=e[++n]}else s.push(a);return{layout:s,countRemoved:o}}function FB(t,e){let s=[];for(let n=0;n<e.length;n++)s.push(t.get(e[n]));for(let n=0;n<s.length;n++)t.set(n,s[n]);t.length=e.length}function UB(t,e,s){let n=[],r=t.map((c,d)=>Wo(t,d,e)).reduce((c,d)=>c+d),o=0,a=0,l=0;for(;l<r;){if(r-l<s){n.push(r-l);break}o+=s;let c=Wo(t,a,e);o>c&&(o-=c,a++);let d=t[a].getWidth(o-1)===2;d&&o--;let h=d?s-1:s;n.push(h),l+=h}return n}function Wo(t,e,s){if(e===t.length-1)return t[e].getTrimmedLength();let n=!t[e].hasContent(s-1)&&t[e].getWidth(s-1)===1,r=t[e+1].getWidth(0)===2;return n&&r?s-1:s}var m5=class p5{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=p5._nextId++,this._onDispose=this.register(new ve),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Vi(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};m5._nextId=1;var HB=m5,Ft={},ui=Ft.B;Ft[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ft.A={"#":"£"};Ft.B=void 0;Ft[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ft.C=Ft[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ft.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ft.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ft.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ft.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ft.E=Ft[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ft.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ft.H=Ft[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ft["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var N1=4294967295,A1=class{constructor(t,e,s){this._hasScrollback=t,this._optionsService=e,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=It.clone(),this.savedCharset=ui,this.markers=[],this._nullCell=qs.fromCharData([0,E4,1,0]),this._whitespaceCell=qs.fromCharData([0,Hn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ml,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new V1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Pl),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Pl),this._whitespaceCell}getBlankLine(t,e){return new fo(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>N1?N1:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=It);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new V1(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let s=this.getNullCell(It),n=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let a=0;a<this.lines.length;a++)n+=+this.lines.get(a).resize(t,s);let o=0;if(this._rows<e)for(let a=this._rows;a<e;a++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new fo(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new fo(t,s)));else for(let a=this._rows;a>e;a--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let a=this.lines.length-r;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(t,s);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,n=BB(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(It),s);if(n.length>0){let r=zB(this.lines,n);FB(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,s){let n=this.getNullCell(It),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new fo(t,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,e){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(It),r=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=t)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let b=this.ybase+this.y;if(b>=a&&b<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=UB(c,this._cols,t),u=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let b=0;b<u;b++){let y=this.getBlankLine(It,!0);m.push(y)}m.length>0&&(r.push({start:a+c.length+o,newLines:m}),o+=m.length),c.push(...m);let p=h.length-1,g=h[p];g===0&&(p--,g=h[p]);let x=c.length-u-1,v=d;for(;x>=0;){let b=Math.min(v,g);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[x],v-b,g-b,b,!0),g-=b,g===0&&(p--,g=h[p]),v-=b,v===0){x--;let y=Math.max(x,0);v=Wo(c,y,this._cols)}}for(let b=0;b<c.length;b++)h[b]<t&&c[b].setCell(h[b],n);let _=u-f;for(;_-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+e-1)}if(r.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let c=this.lines.length,d=c-1,h=0,u=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,c+o-1);g>=0;g--)if(u&&u.start>d+f){for(let x=u.newLines.length-1;x>=0;x--)this.lines.set(g--,u.newLines[x]);g++,a.push({index:d+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++h]}else this.lines.set(g,l[d--]);let m=0;for(let g=a.length-1;g>=0;g--)a[g].index+=m,this.lines.onInsertEmitter.fire(a[g]),m+=a[g].amount;let p=Math.max(0,c+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(t,e,s=0,n){let r=this.lines.get(t);return r?r.translateToString(e,s,n):""}getWrappedRangeForLine(t){let e=t,s=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:e,last:s}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new HB(t);return this.markers.push(e),e.register(this.lines.onTrim(s=>{e.line-=s,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(s=>{e.line>=s.index&&(e.line+=s.amount)})),e.register(this.lines.onDelete(s=>{e.line>=s.index&&e.line<s.index+s.amount&&e.dispose(),e.line>s.index&&(e.line-=s.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},KB=class extends Qe{constructor(t,e){super(),this._optionsService=t,this._bufferService=e,this._onBufferActivate=this._register(new ve),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new A1(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new A1(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(t,e){this._normal.resize(t,e),this._alt.resize(t,e),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},g5=2,x5=1,Vd=class extends Qe{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new ve),this.onResize=this._onResize.event,this._onScroll=this._register(new ve),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,g5),this.rows=Math.max(t.rawOptions.rows||0,x5),this.buffers=this._register(new KB(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let s=this.cols!==t,n=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==t.fg||n.getBg(0)!==t.bg)&&(n=s.getBlankLine(t,e),this._cachedBlankLine=n),n.isWrapped=e;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(o+1,0,n.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(o,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(t,e){let s=this.buffer;if(t<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),n!==s.ydisp&&(e||this._onScroll.fire(s.ydisp))}};Vd=Vt([we(0,Ls)],Vd);var Hi={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Ol,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},WB=["normal","bold","100","200","300","400","500","600","700","800","900"],qB=class extends Qe{constructor(t){super(),this._onOptionChange=this._register(new ve),this.onOptionChange=this._onOptionChange.event;let e={...Hi};for(let s in t)if(s in e)try{let n=t[s];e[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=e,this.options={...e},this._setupOptions(),this._register(_t(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(t,e){return this.onOptionChange(s=>{s===t&&e(this.rawOptions[t])})}onMultipleOptionChange(t,e){return this.onOptionChange(s=>{t.indexOf(s)!==-1&&e()})}_setupOptions(){let t=s=>{if(!(s in Hi))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},e=(s,n)=>{if(!(s in Hi))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:t.bind(this,s),set:e.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(t,e){switch(t){case"cursorStyle":if(e||(e=Hi[t]),!GB(e))throw new Error(`"${e}" is not a valid value for ${t}`);break;case"wordSeparator":e||(e=Hi[t]);break;case"fontWeight":case"fontWeightBold":if(typeof e=="number"&&1<=e&&e<=1e3)break;e=WB.includes(e)?e:Hi[t];break;case"cursorWidth":e=Math.floor(e);case"lineHeight":case"tabStopWidth":if(e<1)throw new Error(`${t} cannot be less than 1, value: ${e}`);break;case"minimumContrastRatio":e=Math.max(1,Math.min(21,Math.round(e*10)/10));break;case"scrollback":if(e=Math.min(e,4294967295),e<0)throw new Error(`${t} cannot be less than 0, value: ${e}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(e<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${e}`);break;case"rows":case"cols":if(!e&&e!==0)throw new Error(`${t} must be numeric, value: ${e}`);break;case"windowsPty":e=e??{};break}return e}};function GB(t){return t==="block"||t==="underline"||t==="bar"}function mo(t,e=5){if(typeof t!="object")return t;let s=Array.isArray(t)?[]:{};for(let n in t)s[n]=e<=1?t[n]:t[n]&&mo(t[n],e-1);return s}var T1=Object.freeze({insertMode:!1}),E1=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Nd=class extends Qe{constructor(t,e,s){super(),this._bufferService=t,this._logService=e,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ve),this.onData=this._onData.event,this._onUserInput=this._register(new ve),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ve),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ve),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=mo(T1),this.decPrivateModes=mo(E1)}reset(){this.modes=mo(T1),this.decPrivateModes=mo(E1)}triggerDataEvent(t,e=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;e&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),e&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(n=>n.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(t))}};Nd=Vt([we(0,ys),we(1,O4),we(2,Ls)],Nd);var R1={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function b0(t,e){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(s|=64,s|=t.action):(s|=t.button&3,t.button&4&&(s|=64),t.button&8&&(s|=128),t.action===32?s|=32:t.action===0&&!e&&(s|=3)),s}var _0=String.fromCharCode,P1={DEFAULT:t=>{let e=[b0(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${_0(e[0])}${_0(e[1])}${_0(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${b0(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${b0(t,!0)};${t.x};${t.y}${e}`}},Ad=class extends Qe{constructor(t,e,s){super(),this._bufferService=t,this._coreService=e,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ve),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(R1))this.addProtocol(n,R1[n]);for(let n of Object.keys(P1))this.addEncoding(n,P1[n]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,s){if(t.deltaY===0||t.shiftKey||e===void 0||s===void 0)return 0;let n=e/s,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=n+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,s){if(s){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Ad=Vt([we(0,ys),we(1,Bi),we(2,Ls)],Ad);var y0=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],YB=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],$t;function JB(t,e){let s=0,n=e.length-1,r;if(t<e[0][0]||t>e[n][1])return!1;for(;n>=s;)if(r=s+n>>1,t>e[r][1])s=r+1;else if(t<e[r][0])n=r-1;else return!0;return!1}var XB=class{constructor(){if(this.version="6",!$t){$t=new Uint8Array(65536),$t.fill(1),$t[0]=0,$t.fill(0,1,32),$t.fill(0,127,160),$t.fill(2,4352,4448),$t[9001]=2,$t[9002]=2,$t.fill(2,11904,42192),$t[12351]=1,$t.fill(2,44032,55204),$t.fill(2,63744,64256),$t.fill(2,65040,65050),$t.fill(2,65072,65136),$t.fill(2,65280,65377),$t.fill(2,65504,65511);for(let t=0;t<y0.length;++t)$t.fill(0,y0[t][0],y0[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?$t[t]:JB(t,YB)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let s=this.wcwidth(t),n=s===0&&e!==0;if(n){let r=pi.extractWidth(e);r===0?n=!1:r>s&&(s=r)}return pi.createPropertyValue(0,s,n)}},pi=class Xa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ve,this.onChange=this._onChange.event;let e=new XB;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,s,n=!1){return(e&16777215)<<3|(s&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let s=0,n=0,r=e.length;for(let o=0;o<r;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=r)return s+this.wcwidth(a);let d=e.charCodeAt(o);56320<=d&&d<=57343?a=(a-55296)*1024+d-56320+65536:s+=this.wcwidth(d)}let l=this.charProperties(a,n),c=Xa.extractWidth(l);Xa.extractShouldJoin(l)&&(c-=Xa.extractWidth(n)),s+=c,n=l}return s}charProperties(e,s){return this._activeProvider.charProperties(e,s)}},QB=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function I1(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&e&&(s.isWrapped=e[3]!==0&&e[3]!==32)}var Zr=2147483647,ZB=256,v5=class Td{constructor(e=32,s=32){if(this.maxLength=e,this.maxSubParamsLength=s,s>ZB)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let s=new Td;if(!e.length)return s;for(let n=Array.isArray(e[0])?1:0;n<e.length;++n){let r=e[n];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let e=new Td(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let s=0;s<this.length;++s){e.push(this.params[s]);let n=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Zr?Zr:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>Zr?Zr:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let s=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let e={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-n>0&&(e[s]=this._subParams.slice(n,r))}return e}addDigit(e){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[s-1];n[s-1]=~r?Math.min(r*10+e,Zr):e}},eo=[],ez=class{constructor(){this._state=0,this._active=eo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=eo}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=eo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||eo,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,s){if(!this._active.length)this._handlerFb(this._id,"PUT",jc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}start(){this.reset(),this._state=1}put(t,e,s){if(this._state!==3){if(this._state===1)for(;e<s;){let n=t[e++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&s-e>0&&this._put(t,e,s)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let s=!1,n=this._active.length-1,r=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;n>=0&&(s=this._active[n].end(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=eo,this._id=-1,this._state=0}}},Rs=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=jc(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,e}},to=[],tz=class{constructor(){this._handlers=Object.create(null),this._active=to,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=to}registerHandler(t,e){this._handlers[t]===void 0&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(e),{dispose:()=>{let n=s.indexOf(e);n!==-1&&s.splice(n,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=to,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||to,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(e)}put(t,e,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",jc(t,e,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(t,e,s)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let s=!1,n=this._active.length-1,r=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=e,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;n>=0&&(s=this._active[n].unhook(t),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=to,this._ident=0}},po=new v5;po.addParam(0);var D1=class{constructor(t){this._handler=t,this._data="",this._params=po,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():po,this._data="",this._hitLimit=!1}put(t,e,s){this._hitLimit||(this._data+=jc(t,e,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(s=>(this._params=po,this._data="",this._hitLimit=!1,s));return this._params=po,this._data="",this._hitLimit=!1,e}},sz=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,e){this.table.fill(t<<4|e)}add(t,e,s,n){this.table[e<<8|t]=s<<4|n}addMany(t,e,s,n){for(let r=0;r<t.length;r++)this.table[e<<8|t[r]]=s<<4|n}},Ws=160,nz=(function(){let t=new sz(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>e.slice(l,c),n=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),a;t.setDefault(1,0),t.addMany(n,0,2,0);for(a in o)t.addMany([24,26,153,154],a,3,0),t.addMany(s(128,144),a,3,0),t.addMany(s(144,152),a,3,0),t.add(156,a,0,0),t.add(27,a,11,1),t.add(157,a,4,8),t.addMany([152,158,159],a,0,7),t.add(155,a,11,3),t.add(144,a,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(n,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(n,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(n,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Ws,0,2,0),t.add(Ws,8,5,8),t.add(Ws,6,0,6),t.add(Ws,11,0,11),t.add(Ws,13,13,13),t})(),iz=class extends Qe{constructor(t=nz){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new v5,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,s,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,s)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_t(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ez),this._dcsParser=this._register(new tz),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(t,e=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<t.intermediates.length;++r){let o=t.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(t.final.length!==1)throw new Error("final must be a single byte");let n=t.final.charCodeAt(0);if(e[0]>n||n>e[1])throw new Error(`final must be in range ${e[0]} .. ${e[1]}`);return s<<=8,s|=n,s}identToString(t){let e=[];for(;t;)e.push(String.fromCharCode(t&255)),t>>=8;return e.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,e){let s=this._identifier(t,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(e),{dispose:()=>{let r=n.indexOf(e);r!==-1&&n.splice(r,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,e){this._executeHandlers[t.charCodeAt(0)]=e}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,e){let s=this._identifier(t);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(e),{dispose:()=>{let r=n.indexOf(e);r!==-1&&n.splice(r,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,e){return this._dcsParser.registerHandler(this._identifier(t),e)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,e){return this._oscParser.registerHandler(t,e)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,e,s,n,r){this._parseStack.state=t,this._parseStack.handlers=e,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=r}parse(t,e,s){let n=0,r=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(n=t[this._parseStack.chunkPos],a=this._dcsParser.unhook(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=t[this._parseStack.chunkPos],a=this._oscParser.end(n!==24&&n!==26,s),a)return a;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<e;++l){switch(n=t[l],r=this._transitions.table[this.currentState<<8|(n<160?n:Ws)],r>>4){case 2:for(let f=l+1;;++f){if(f>=e||(n=t[f])<32||n>126&&n<Ws){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<Ws){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<Ws){this._printHandler(t,l,f),l=f-1;break}if(++f>=e||(n=t[f])<32||n>126&&n<Ws){this._printHandler(t,l,f),l=f-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|n],d=c?c.length-1:-1;for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._preserveStack(3,c,d,r,l),a;d<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++l<e&&(n=t[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],u=h?h.length-1:-1;for(;u>=0&&(a=h[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,h,u,r,l),a;u<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let f=l+1;;++f)if(f>=e||(n=t[f])===24||n===26||n===27||n>127&&n<Ws){this._dcsParser.put(t,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(n!==24&&n!==26),a)return this._preserveStack(6,[],0,r,l),a;n===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=e||(n=t[f])<32||n>127&&n<Ws){this._oscParser.put(t,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(n!==24&&n!==26),a)return this._preserveStack(5,[],0,r,l),a;n===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},rz=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,oz=/^[\da-f]+$/;function O1(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let s=rz.exec(e);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),oz.exec(e)&&[3,6,9,12].includes(e.length))){let s=e.length/3,n=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(e.slice(s*r,s*r+s),16);n[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return n}}function L0(t,e){let s=t.toString(16),n=s.length<2?"0"+s:s;switch(e){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function az(t,e=16){let[s,n,r]=t;return`rgb:${L0(s,e)}/${L0(n,e)}/${L0(r,e)}`}var lz={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bn=131072,M1=10;function $1(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var B1=5e3,z1=0,cz=class extends Qe{constructor(t,e,s,n,r,o,a,l,c=new iz){super(),this._bufferService=t,this._charsetService=e,this._coreService=s,this._logService=n,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new VM,this._utf8Decoder=new NM,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=It.clone(),this._eraseAttrDataInternal=It.clone(),this._onRequestBell=this._register(new ve),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ve),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ve),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ve),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ve),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ve),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ve),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ve),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ve),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ve),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ve),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ve),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ve),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Ed(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:h.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,h,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:h,data:u})}),this._parser.setDcsHandlerFallback((d,h,u)=>{h==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:h,payload:u})}),this._parser.setPrintHandler((d,h,u)=>this.print(d,h,u)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(fe.BEL,()=>this.bell()),this._parser.setExecuteHandler(fe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(fe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(fe.BS,()=>this.backspace()),this._parser.setExecuteHandler(fe.HT,()=>this.tab()),this._parser.setExecuteHandler(fe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(fe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ya.IND,()=>this.index()),this._parser.setExecuteHandler(Ya.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ya.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Rs(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Rs(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Rs(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Rs(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Rs(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Rs(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Rs(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Rs(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Rs(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Rs(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Rs(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Rs(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Ft)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new D1((d,h)=>this.requestStatusString(d,h)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),B1))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${B1} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let s,n=this._activeBuffer.x,r=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Bn&&(o=this._parseStack.position+Bn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(d=>d.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Bn&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Bn))),a||this._dirtyRowTracker.clearRange(),t.length>Bn)for(let d=o;d<t.length;d+=Bn){let h=d+Bn<t.length?d+Bn:t.length,u=typeof t=="string"?this._stringDecoder.decode(t.substring(d,h),this._parseBuffer):this._utf8Decoder.decode(t.subarray(d,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(n,r,u,d),this._logSlowResolvingAsync(s),s}else if(!a){let d=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(n,r,d,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(t,e,s){let n,r,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-e>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let m=e;m<s;++m){if(n=t[m],n<127&&o){let v=o[String.fromCharCode(n)];v&&(n=v.charCodeAt(0))}let p=this._unicodeService.charProperties(n,f);r=pi.extractWidth(p);let g=pi.extractShouldJoin(p),x=g?pi.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Fn(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-x>l){if(c){let v=u,_=this._activeBuffer.x-x;for(this._activeBuffer.x=x,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&u instanceof fo&&u.copyCellsFrom(v,_,0,x,!1);_<l;)v.setCellFromCodepoint(_++,0,1,h)}else if(this._activeBuffer.x=l-1,r===2)continue}if(g&&this._activeBuffer.x){let v=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-v,n,r);for(let _=r-x;--_>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,r-x,this._activeBuffer.getNullCell(h)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,n,r,h),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-e>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,s=>$1(s.params[0],this._optionsService.rawOptions.windowOptions)?e(s):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new D1(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Rs(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,s,n=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);o.replaceCells(e,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),n&&(o.isWrapped=!1)}_resetBufferLine(t,e=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let s;switch(t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);s<this._bufferService.rows;s++)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;e--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(t){let e=t.params[0]||1;for(;e--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(It));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let s=t.params[0]||1,n=pi.extractWidth(e),r=this._activeBuffer.x-n,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(o.length*s),l=0;for(let d=0;d<o.length;){let h=o.codePointAt(d)||0;a[l++]=h,d+=h>65535?2:1}let c=l;for(let d=1;d<s;++d)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(fe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(fe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(fe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(fe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(fe.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ui),this._charsetService.setgCharset(1,ui),this._charsetService.setgCharset(2,ui),this._charsetService.setgCharset(3,ui);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let s;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let n=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:d,alt:h}=l,u=this._optionsService.rawOptions,f=(g,x)=>(a.triggerDataEvent(`${fe.ESC}[${e?"":"?"}${g};${x}$y`),!0),m=g=>g?1:2,p=t.params[0];return e?p===2?f(p,4):p===4?f(p,m(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(n.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,m(n.origin)):p===7?f(p,m(n.wraparound)):p===8?f(p,3):p===9?f(p,m(r==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!a.isCursorHidden)):p===45?f(p,m(n.reverseWraparound)):p===66?f(p,m(n.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(r==="VT200")):p===1002?f(p,m(r==="DRAG")):p===1003?f(p,m(r==="ANY")):p===1004?f(p,m(n.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(o==="SGR")):p===1015?f(p,4):p===1016?f(p,m(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(d===h)):p===2004?f(p,m(n.bracketedPasteMode)):p===2026?f(p,m(n.synchronizedOutput)):f(p,0)}_updateAttrColor(t,e,s,n,r){return e===2?(t|=50331648,t&=-16777216,t|=ha.fromColorRGB([s,n,r])):e===5&&(t&=-50331904,t|=33554432|s&255),t}_extractColor(t,e,s){let n=[0,0,-1,0,0,0],r=0,o=0;do{if(n[o+r]=t.params[e+o],t.hasSubParams(e+o)){let a=t.getSubParams(e+o),l=0;do n[1]===5&&(r=1),n[o+l+1+r]=a[l];while(++l<a.length&&l+o+1+r<n.length);break}if(n[1]===5&&o+r>=2||n[1]===2&&o+r>=5)break;n[1]&&(r=1)}while(++o+e<t.length&&o+r<n.length);for(let a=2;a<n.length;++a)n[a]===-1&&(n[a]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return o}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=It.fg,t.bg=It.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,s,n=this._curAttrData;for(let r=0;r<e;r++)s=t.params[r],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=It.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=It.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(t,r,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=It.fg&16777215,n.bg&=-67108864,n.bg|=It.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${fe.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[${e};${s}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${fe.ESC}[?${e};${s}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=It.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=e%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(t){let e=t.params[0]||1,s;return(t.length<2||(s=t.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(t){if(!$1(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${fe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>M1&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>M1&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(t){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],s=t.split(";");for(;s.length>1;){let n=s.shift(),r=s.shift();if(/^\d+$/.exec(n)){let o=parseInt(n);if(F1(o))if(r==="?")e.push({type:0,index:o});else{let a=O1(r);a&&e.push({type:1,index:o,color:a})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let s=t.slice(0,e).trim(),n=t.slice(e+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let s=t.split(":"),n,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(n=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let s=t.split(";");for(let n=0;n<s.length&&!(e>=this._specialColors.length);++n,++e)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=O1(s[n]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],s=t.split(";");for(let n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let r=parseInt(s[n]);F1(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ui),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(lz[t[0]],Ft[t[1]]||ui),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=It.clone(),this._eraseAttrDataInternal=It.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new qs;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let s=this._activeBuffer.ybase+this._activeBuffer.y+e,n=this._activeBuffer.lines.get(s);n&&(n.fill(t),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let s=a=>(this._coreService.triggerDataEvent(`${fe.ESC}${a}${fe.ESC}\\`),!0),n=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Ed=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(z1=t,t=e,e=z1),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ed=Vt([we(0,ys)],Ed);function F1(t){return 0<=t&&t<256}var dz=5e7,U1=12,uz=50,hz=class extends Qe{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ve),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,e){if(e!==void 0&&this._syncCalls>e){this._syncCalls=0;return}if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,e){if(this._pendingData>dz)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(e)}_innerWrite(t=0,e=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],r=this._action(n,e);if(r){let a=l=>performance.now()-s>=U1?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=U1)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>uz&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Rd=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let l=e.addMarker(e.ybase+e.y),c={data:t,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=t,n=this._getEntryIdKey(s),r=this._entriesWithId.get(n);if(r)return this.addLineToLink(r.id,e.ybase+e.y),r.id;let o=e.addMarker(e.ybase+e.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(t,e){let s=this._dataByLinkId.get(t);if(s&&s.lines.every(n=>n.line!==e)){let n=this._bufferService.buffer.addMarker(e);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let s=t.lines.indexOf(e);s!==-1&&(t.lines.splice(s,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};Rd=Vt([we(0,ys)],Rd);var H1=!1,fz=class extends Qe{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new xr),this._onBinary=this._register(new ve),this.onBinary=this._onBinary.event,this._onData=this._register(new ve),this.onData=this._onData.event,this._onLineFeed=this._register(new ve),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ve),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ve),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ve),this._instantiationService=new OB,this.optionsService=this._register(new qB(t)),this._instantiationService.setService(Ls,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vd)),this._instantiationService.setService(ys,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(kd)),this._instantiationService.setService(O4,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Nd)),this._instantiationService.setService(Bi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ad)),this._instantiationService.setService(D4,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(pi)),this._instantiationService.setService(RM,this.unicodeService),this._charsetService=this._instantiationService.createInstance(QB),this._instantiationService.setService(EM,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Rd),this._instantiationService.setService(M4,this._oscLinkService),this._inputHandler=this._register(new cz(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(is.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(is.forward(this._bufferService.onResize,this._onResize)),this._register(is.forward(this.coreService.onData,this._onData)),this._register(is.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new hz((e,s)=>this._inputHandler.parse(e,s))),this._register(is.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ve),this._onScroll.event(t=>{this._onScrollApi?.fire(t.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(t){for(let e in t)this.optionsService.options[e]=t[e]}write(t,e){this._writeBuffer.write(t,e)}writeSync(t,e){this._logService.logLevel<=3&&!H1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),H1=!0),this._writeBuffer.writeSync(t,e)}input(t,e=!0){this.coreService.triggerDataEvent(t,e)}resize(t,e){isNaN(t)||isNaN(e)||(t=Math.max(t,g5),e=Math.max(e,x5),this._bufferService.resize(t,e))}scroll(t,e=!1){this._bufferService.scroll(t,e)}scrollLines(t,e){this._bufferService.scrollLines(t,e)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}registerEscHandler(t,e){return this._inputHandler.registerEscHandler(t,e)}registerDcsHandler(t,e){return this._inputHandler.registerDcsHandler(t,e)}registerCsiHandler(t,e){return this._inputHandler.registerCsiHandler(t,e)}registerOscHandler(t,e){return this._inputHandler.registerOscHandler(t,e)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,e=this.optionsService.rawOptions.windowsPty;e&&e.buildNumber!==void 0&&e.buildNumber!==void 0?t=e.backend==="conpty"&&e.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(I1.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},()=>(I1(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_t(()=>{for(let e of t)e.dispose()})}}},mz={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function pz(t,e,s,n){let r={type:0,cancel:!1,key:void 0},o=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=fe.ESC+"OA":r.key=fe.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=fe.ESC+"OD":r.key=fe.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=fe.ESC+"OC":r.key=fe.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=fe.ESC+"OB":r.key=fe.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":fe.DEL,t.altKey&&(r.key=fe.ESC+r.key);break;case 9:if(t.shiftKey){r.key=fe.ESC+"[Z";break}r.key=fe.HT,r.cancel=!0;break;case 13:r.key=t.altKey?fe.ESC+fe.CR:fe.CR,r.cancel=!0;break;case 27:r.key=fe.ESC,t.altKey&&(r.key=fe.ESC+fe.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;o?r.key=fe.ESC+"[1;"+(o+1)+"D":e?r.key=fe.ESC+"OD":r.key=fe.ESC+"[D";break;case 39:if(t.metaKey)break;o?r.key=fe.ESC+"[1;"+(o+1)+"C":e?r.key=fe.ESC+"OC":r.key=fe.ESC+"[C";break;case 38:if(t.metaKey)break;o?r.key=fe.ESC+"[1;"+(o+1)+"A":e?r.key=fe.ESC+"OA":r.key=fe.ESC+"[A";break;case 40:if(t.metaKey)break;o?r.key=fe.ESC+"[1;"+(o+1)+"B":e?r.key=fe.ESC+"OB":r.key=fe.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=fe.ESC+"[2~");break;case 46:o?r.key=fe.ESC+"[3;"+(o+1)+"~":r.key=fe.ESC+"[3~";break;case 36:o?r.key=fe.ESC+"[1;"+(o+1)+"H":e?r.key=fe.ESC+"OH":r.key=fe.ESC+"[H";break;case 35:o?r.key=fe.ESC+"[1;"+(o+1)+"F":e?r.key=fe.ESC+"OF":r.key=fe.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=fe.ESC+"[5;"+(o+1)+"~":r.key=fe.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=fe.ESC+"[6;"+(o+1)+"~":r.key=fe.ESC+"[6~";break;case 112:o?r.key=fe.ESC+"[1;"+(o+1)+"P":r.key=fe.ESC+"OP";break;case 113:o?r.key=fe.ESC+"[1;"+(o+1)+"Q":r.key=fe.ESC+"OQ";break;case 114:o?r.key=fe.ESC+"[1;"+(o+1)+"R":r.key=fe.ESC+"OR";break;case 115:o?r.key=fe.ESC+"[1;"+(o+1)+"S":r.key=fe.ESC+"OS";break;case 116:o?r.key=fe.ESC+"[15;"+(o+1)+"~":r.key=fe.ESC+"[15~";break;case 117:o?r.key=fe.ESC+"[17;"+(o+1)+"~":r.key=fe.ESC+"[17~";break;case 118:o?r.key=fe.ESC+"[18;"+(o+1)+"~":r.key=fe.ESC+"[18~";break;case 119:o?r.key=fe.ESC+"[19;"+(o+1)+"~":r.key=fe.ESC+"[19~";break;case 120:o?r.key=fe.ESC+"[20;"+(o+1)+"~":r.key=fe.ESC+"[20~";break;case 121:o?r.key=fe.ESC+"[21;"+(o+1)+"~":r.key=fe.ESC+"[21~";break;case 122:o?r.key=fe.ESC+"[23;"+(o+1)+"~":r.key=fe.ESC+"[23~";break;case 123:o?r.key=fe.ESC+"[24;"+(o+1)+"~":r.key=fe.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=fe.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=fe.DEL:t.keyCode===219?r.key=fe.ESC:t.keyCode===220?r.key=fe.FS:t.keyCode===221&&(r.key=fe.GS);else if((!s||n)&&t.altKey&&!t.metaKey){let a=mz[t.keyCode]?.[t.shiftKey?1:0];if(a)r.key=fe.ESC+a;else if(t.keyCode>=65&&t.keyCode<=90){let l=t.ctrlKey?t.keyCode-64:t.keyCode+32,c=String.fromCharCode(l);t.shiftKey&&(c=c.toUpperCase()),r.key=fe.ESC+c}else if(t.keyCode===32)r.key=fe.ESC+(t.ctrlKey?fe.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let l=t.code.slice(3,4);t.shiftKey||(l=l.toLowerCase()),r.key=fe.ESC+l,r.cancel=!0}}else s&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=fe.US),t.key==="@"&&(r.key=fe.NUL));break}return r}var At=0,gz=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ml,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ml,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(t){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),e=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<n.length;r++)s>=this._array.length||this._getKey(t[e])<=this._getKey(this._array[s])?(n[r]=t[e],e++):n[r]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),this._array.length===0)return!1;let e=this._getKey(t);if(e===void 0||(At=this._search(e),At===-1)||this._getKey(this._array[At])!==e)return!1;do if(this._array[At]===t)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(At),!0;while(++At<this._array.length&&this._getKey(this._array[At])===e);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort((r,o)=>r-o),e=0,s=new Array(this._array.length-t.length),n=0;for(let r=0;r<this._array.length;r++)t[e]===r?e++:s[n++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(At=this._search(t),!(At<0||At>=this._array.length)&&this._getKey(this._array[At])===t))do yield this._array[At];while(++At<this._array.length&&this._getKey(this._array[At])===t)}forEachByKey(t,e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(At=this._search(t),!(At<0||At>=this._array.length)&&this._getKey(this._array[At])===t))do e(this._array[At]);while(++At<this._array.length&&this._getKey(this._array[At])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let e=0,s=this._array.length-1;for(;s>=e;){let n=e+s>>1,r=this._getKey(this._array[n]);if(r>t)s=n-1;else if(r<t)e=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===t;)n--;return n}}return e}},S0=0,K1=0,xz=class extends Qe{constructor(){super(),this._decorations=new gz(t=>t?.marker.line),this._onDecorationRegistered=this._register(new ve),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ve),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_t(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new vz(t);if(e){let s=e.marker.onDispose(()=>e.dispose()),n=e.onDispose(()=>{n.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),s.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,s){let n=0,r=0;for(let o of this._decorations.getKeyIterator(e))n=o.options.x??0,r=n+(o.options.width??1),t>=n&&t<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(t,e,s,n){this._decorations.forEachByKey(e,r=>{S0=r.options.x??0,K1=S0+(r.options.width??1),t>=S0&&t<K1&&(!s||(r.options.layer??"bottom")===s)&&n(r)})}},vz=class extends Gn{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new ve),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ve),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=wt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=wt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},bz=1e3,_z=class{constructor(t,e=bz){this._renderCallback=t,this._debounceThresholdMS=e,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,e,s){this._rowCount=s,t=t!==void 0?t:0,e=e!==void 0?e:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,t):t,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,e):e;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=n-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let t=Math.max(this._rowStart,0),e=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,e)}},W1=20,$l=class extends Qe{constructor(t,e,s,n){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new _z(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
515
+ `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(He(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_t(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<W1+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
516
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===W1+1&&(this._liveRegion.textContent+=Z0.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let s=this._terminal.buffer,n=s.lines.length.toString();for(let r=t;r<=e;r++){let o=s.lines.get(s.ydisp+r),a=[],l=o?.translateToString(!0,void 0,void 0,a)||"",c=(s.ydisp+r+1).toString(),d=this._rowElements[r];d&&(l.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=l,this._rowColumns.set(d,a)),d.setAttribute("aria-posinset",c),d.setAttribute("aria-setsize",n),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let s=t.target,n=this._rowElements[e===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||t.relatedTarget!==n)return;let a,l;if(e===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===s.node&&e.offset>s.offset)&&([e,s]=[s,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:l,offset:c})=>{let d=l instanceof Text?l.parentNode:l,h=parseInt(d?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(d);if(!u)return console.warn("columns is null. Race condition?"),null;let f=c<u.length?u[c]:u.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=r(e),a=r(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${n/e})`}};$l=Vt([we(1,Su),we(2,In),we(3,Dn)],$l);var Pd=class extends Qe{constructor(t,e,s,n,r){super(),this._element=t,this._mouseService=e,this._renderService=s,this._bufferService=n,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ve),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ve),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_t(()=>{Vi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(He(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(He(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(He(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(He(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let s=t.composedPath();for(let n=0;n<s.length;n++){let r=s[n];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[n,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(n)&&(s=this._checkLinkProviderResult(n,t,s)):r.provideLinks(t.y,o=>{if(this._isMouseOut)return;let a=o?.map(l=>({link:l}));this._activeProviderReplies?.set(n,a),s=this._checkLinkProviderResult(n,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let s=new Set;for(let n=0;n<e.size;n++){let r=e.get(n);if(r)for(let o=0;o<r.length;o++){let a=r[o],l=a.link.range.start.y<t?0:a.link.range.start.x,c=a.link.range.end.y>t?this._bufferService.cols:a.link.range.end.x;for(let d=l;d<=c;d++){if(s.has(d)){r.splice(o--,1);break}s.add(d)}}}}_checkLinkProviderResult(t,e,s){if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(t),r=!1;for(let o=0;o<t;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&n){let o=n.find(a=>this._linkAtPosition(a.link,e));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let a=this._activeProviderReplies.get(o)?.find(l=>this._linkAtPosition(l.link,e));if(a){s=!0,this._handleNewLink(a);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&yz(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Vi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(n,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(s,e.text)}_fireUnderlineEvent(t,e){let s=t.range,n=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(s,e.text)}_linkAtPosition(t,e){let s=t.range.start.y*this._bufferService.cols+t.range.start.x,n=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return s<=r&&r<=n}_positionFromMouseEvent(t,e,s){let n=s.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,s,n,r){return{x1:t,y1:e,x2:s,y2:n,cols:this._bufferService.cols,fg:r}}};Pd=Vt([we(1,wu),we(2,Dn),we(3,ys),we(4,B4)],Pd);function yz(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var Lz=class extends fz{constructor(t={}){super(t),this._linkifier=this._register(new xr),this.browser=r5,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new xr),this._onCursorMove=this._register(new ve),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ve),this.onKey=this._onKey.event,this._onRender=this._register(new ve),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ve),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ve),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ve),this.onBell=this._onBell.event,this._onFocus=this._register(new ve),this._onBlur=this._register(new ve),this._onA11yCharEmitter=this._register(new ve),this._onA11yTabEmitter=this._register(new ve),this._onWillOpen=this._register(new ve),this._setup(),this._decorationService=this._instantiationService.createInstance(xz),this._instantiationService.setService(fa,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(uB),this._instantiationService.setService(B4,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(td)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(is.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(is.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(is.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(is.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(_t(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(t){if(this._themeService)for(let e of t){let s,n="";switch(e.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+e.index}switch(e.type){case 0:let r=vt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[e.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${fe.ESC}]${n};${az(r)}${n5.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[e.index]=Dt.toColor(...e.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Dt.toColor(...e.color))}break;case 2:this._themeService.restoreColor(e.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($l,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(fe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.ybase+this.buffer.y,e=this.buffer.lines.get(t);if(!e)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,r=e.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(He(this.element,"copy",e=>{this.hasSelection()&&CM(e,this._selectionService)}));let t=e=>kM(e,this.textarea,this.coreService,this.optionsService);this._register(He(this.textarea,"paste",t)),this._register(He(this.element,"paste",t)),o5?this._register(He(this.element,"mousedown",e=>{e.button===2&&s1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(He(this.element,"contextmenu",e=>{s1(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Eu&&this._register(He(this.element,"auxclick",e=>{e.button===1&&T4(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(He(this.textarea,"keyup",t=>this._keyUp(t),!0)),this._register(He(this.textarea,"keydown",t=>this._keyDown(t),!0)),this._register(He(this.textarea,"keypress",t=>this._keyPress(t),!0)),this._register(He(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(He(this.textarea,"compositionupdate",t=>this._compositionHelper.compositionupdate(t))),this._register(He(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(He(this.textarea,"input",t=>this._inputEvent(t),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(t){if(!t)throw new Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=t.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),t.appendChild(this.element);let e=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(He(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Q0.get()),c5||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(cB,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(In,this._coreBrowserService),this._register(He(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(He(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ld,this._document,this._helperContainer),this._instantiationService.setService(Cc,this._charSizeService),this._themeService=this._instantiationService.createInstance(Cd),this._instantiationService.setService(zr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Dl),this._instantiationService.setService($4,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(wd,this.rows,this.screenElement)),this._instantiationService.setService(Dn,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(bd,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Sd),this._instantiationService.setService(wu,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(Pd,this.screenElement));this.element.appendChild(e);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(xd,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jd,this.element,this.screenElement,n)),this._instantiationService.setService(IM,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(is.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(vd,this.screenElement)),this._register(He(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance($l,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Il,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Il,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(yd,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,e=this.element;function s(o){let a=t._mouseService.getMouseReportCoords(o,t.screenElement);if(!a)return!1;let l,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,l=o.button<3?o.button:3;break;case"mousedown":c=1,l=o.button<3?o.button:3;break;case"wheel":if(t._customWheelEventHandler&&t._customWheelEventHandler(o)===!1)return!1;let d=o.deltaY;if(d===0||t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return!1;c=d<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:t.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?n.mousemove||(e.addEventListener("mousemove",r.mousemove),n.mousemove=r.mousemove):(e.removeEventListener("mousemove",n.mousemove),n.mousemove=null),o&16?n.wheel||(e.addEventListener("wheel",r.wheel,{passive:!1}),n.wheel=r.wheel):(e.removeEventListener("wheel",n.wheel),n.wheel=null),o&2?n.mouseup||(n.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),o&4?n.mousedrag||(n.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(He(e,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(o)})),this._register(He(e,"wheel",o=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(t.coreMouseService.consumeWheelEvent(o,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=fe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(t,e){this._renderService?.refreshRows(t,e)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(t,e){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,e),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let e=t-this._bufferService.buffer.ydisp;e!==0&&this.scrollLines(e)}paste(t){A4(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let e=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),e}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(t,e,s){this._selectionService.setSelection(t,e,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(t,e){this._selectionService?.selectLines(t,e)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!e&&(t.key==="Dead"||t.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=pz(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),this.cancel(t,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.key.length===1&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===fe.ETX||s.key===fe.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey)return this.cancel(t,!0);this._keyDownHandled=!0}_isThirdLevelShift(t,e){let s=t.isMac&&!this.options.macOptionIsMeta&&e.altKey&&!e.ctrlKey&&!e.metaKey||t.isWindows&&e.altKey&&e.ctrlKey&&!e.metaKey||t.isWindows&&e.getModifierState("AltGraph");return e.type==="keypress"?s:s&&(!e.keyCode||e.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)&&(Sz(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let e;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(t)===!1)return!1;if(this.cancel(t),t.charCode)e=t.charCode;else if(t.which===null||t.which===void 0)e=t.keyCode;else if(t.which!==0&&t.charCode!==0)e=t.which;else return!1;return!e||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)?!1:(e=String.fromCharCode(e),this._onKey.fire({key:e,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(e,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(t){if(t.data&&t.inputType==="insertText"&&(!t.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let e=t.data;return this.coreService.triggerDataEvent(e,!0),this.cancel(t),!0}return!1}resize(t,e){if(t===this.cols&&e===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(t,e)}_afterResize(t,e){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(It));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(fe.ESC+"[I"):this.coreService.triggerDataEvent(fe.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[4;${s};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${fe.ESC}[6;${r};${n}t`);break}}cancel(t,e){if(!(!this.options.cancelEvents&&!e))return t.preventDefault(),t.stopPropagation(),!1}};function Sz(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var wz=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let s={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(s),e.dispose=()=>this._wrappedAddonDispose(s),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){e=s;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}},jz=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new qs)}translateToString(t,e,s){return this._line.translateToString(t,e,s)}},q1=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(t){let e=this._buffer.lines.get(t);if(e)return new jz(e)}getNullCell(){return new qs}},Cz=class extends Qe{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new ve),this.onBufferChange=this._onBufferChange.event,this._normal=new q1(this._core.buffers.normal,"normal"),this._alternate=new q1(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},kz=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,s=>e(s.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(s,n)=>e(s,n.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},Vz=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},Nz=["cols","rows"],cn=0,Az=class extends Qe{constructor(t){super(),this._core=this._register(new Lz(t)),this._addonManager=this._register(new wz),this._publicOptions={...this._core.options};let e=n=>this._core.options[n],s=(n,r)=>{this._checkReadonlyOptions(n),this._core.options[n]=r};for(let n in this._core.options){let r={get:e.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,r)}}_checkReadonlyOptions(t){if(Nz.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new kz(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Vz(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new Cz(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,s){this._verifyIntegers(t,e,s),this._core.select(t,e,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
517
+ `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Q0.get()},set promptLabel(t){Q0.set(t)},get tooMuchOutput(){return Z0.get()},set tooMuchOutput(t){Z0.set(t)}}}_verifyIntegers(...t){for(cn of t)if(cn===1/0||isNaN(cn)||cn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(cn of t)if(cn&&(cn===1/0||isNaN(cn)||cn%1!==0||cn<0))throw new Error("This API only accepts positive integers")}};var Tz=2,Ez=1,Rz=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,d=n-l,h=r-c-e;return{cols:Math.max(Tz,Math.floor(h/t.css.cell.width)),rows:Math.max(Ez,Math.floor(d/t.css.cell.height))}}};function Pz({source:t,onReady:e,onSelectionChange:s,className:n}){const r=k.useRef(null),o=k.useRef(null),a=k.useRef(s);a.current=s;const l=$s(),c=k.useRef(t);return c.current=t,Y2((d,h)=>{d===c.current&&o.current?.write(h)}),k.useEffect(()=>{const d=r.current;if(!d)return;const h=getComputedStyle(document.documentElement),u=v=>h.getPropertyValue(v).trim()||void 0,f=new Az({allowTransparency:!1,fontFamily:u("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:u("--sidebar")||u("--card")||u("--background")||"#1e1e1e",cursor:"transparent",foreground:u("--foreground")||"#d4d4d4",selectionBackground:u("--accent"),selectionForeground:u("--accent-foreground"),black:u("--muted"),red:u("--destructive"),green:u("--success"),yellow:u("--warning"),blue:u("--chart-1"),magenta:u("--chart-3"),cyan:u("--chart-5"),white:u("--foreground"),brightBlack:u("--muted-foreground"),brightRed:u("--destructive"),brightGreen:u("--success"),brightYellow:u("--warning"),brightBlue:u("--chart-1"),brightMagenta:u("--chart-3"),brightCyan:u("--chart-5"),brightWhite:u("--foreground")}}),m=new Rz;f.loadAddon(m),f.open(d),m.fit();const p=l.getBuffer(t);p&&f.write(p),o.current=f,e?.(f);const g=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),x=new ResizeObserver(()=>{m.fit()});return x.observe(d),()=>{g.dispose(),x.disconnect(),o.current=null,f.dispose()}},[]),i.jsx("div",{className:te("h-full bg-sidebar p-3",n),children:i.jsx("div",{ref:r,className:"h-full"})})}function Iz(t){const e=$s(),[s,n]=k.useState(vi),[r,o]=k.useState([]),[a,l]=k.useState(new Set),c=k.useRef(!1);if(!c.current&&e.scripts.length>0){const L=Ny.find(w=>e.scripts.includes(w));L&&(c.current=!0,o(w=>w.includes(L)?w:[...w,L]),n(L))}if(a.size>0){let L=!1;const w=new Set(a);for(const S of a)e.activeProcesses.includes(S)||(w.delete(S),L=!0);L&&l(w)}const d=()=>t.onOpenChange(!t.open),h=L=>{n(L),t.open||t.onOpenChange(!0)},u=L=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(L)}`,{method:"POST"}),f=L=>!t.virtualMcpId||!t.branch?Promise.resolve(null):fetch(`/api/${encodeURIComponent(t.orgSlug)}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/exec/${encodeURIComponent(L)}/kill`,{method:"POST"}),m=async(L,w)=>{try{const S=await u(L);if(S===null)return;if(!S.ok)throw new Error(`Exec failed: ${S.statusText}`)}catch{de.error(w)}},p=async L=>{o(w=>w.includes(L)?w:[...w,L]),n(L),t.onOpenChange(!0),await m(L,"Failed to run "+L)},g=async L=>{await f(L),o(w=>w.filter(S=>S!==L)),s===L&&n(vi)},x=async()=>{const L=e.activeProcesses.includes(s);await m(s,(L?"Failed to restart ":"Failed to run ")+s)},v=async()=>{if(!a.has(s)){l(L=>new Set(L).add(s));try{const L=await f(s);if(L===null){l(w=>{const S=new Set(w);return S.delete(s),S});return}if(!L.ok)throw new Error(`Kill failed: ${L.statusText}`)}catch{l(L=>{const w=new Set(L);return w.delete(s),w}),de.error("Failed to stop "+s)}}},_=s!==vi&&r.includes(s),b=_&&e.activeProcesses.includes(s),y=_&&a.has(s);return i.jsxs("div",{className:"flex shrink-0 flex-col",style:{height:t.open?"50%":"auto"},children:[i.jsx(gM,{status:t.status,open:t.open,onToggle:d,onStart:t.status==="idle"?t.onStart:void 0,onStop:t.status==="running"||t.status==="starting"?t.onStop:void 0,onRestart:t.status==="running"?t.onRestart:void 0,onResume:t.status==="suspended"?t.onResume:void 0,onRetry:t.status==="errored"?t.onRetry:void 0,scripts:t.scripts,active:s,scriptTabs:r,onSelectTab:h,onAddScript:p,onCloseScript:g,showScriptControls:_,scriptIsRunning:b,scriptIsKilling:y,onRunActiveScript:x,onStopActiveScript:v}),t.open&&i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(Dz,{vmId:t.vmId,active:s,hasData:e.hasData(s),onRunActive:x})})]})}function Dz(t){const e=M.c(10),{vmId:s,active:n,hasData:r,onRunActive:o}=t;if(!s)return null;if(n===vi||r){let h;return e[0]!==n?(h=i.jsx(Pz,{source:n,className:"h-full"},n),e[0]=n,e[1]=h):h=e[1],h}let a;e[2]!==n?(a=i.jsxs("p",{children:['Script "',i.jsx("span",{className:"font-mono text-foreground",children:n}),'" not running']}),e[2]=n,e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(Si,{className:"size-3.5"}),e[4]=l):l=e[4];let c;e[5]!==o?(c=i.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground hover:bg-accent",children:[l," Run"]}),e[5]=o,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=i.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d}const b5=t=>`preview-drawer:${t}`,Oz=/Authentication failed for|Invalid username or token|Password authentication is not supported/i;function Mz(t){try{const e=localStorage.getItem(b5(t));return e?!!JSON.parse(e).open:!1}catch{return!1}}function $z(t,e){try{localStorage.setItem(b5(t),JSON.stringify({open:e}))}catch{}}function Bz(){const t=M.c(21),e=oi(),{org:s}=Ee(),n=e?.virtualMcpId??null,r=Vr(),o=$s(),a=k.useRef(null);let l;t[0]!==o||t[1]!==r||t[2]!==n?(l=_=>{_!=="setup"||!n||a.current!==n&&Oz.test(o.getBuffer("setup"))&&(a.current=n,r.restart())},t[0]=o,t[1]=r,t[2]=n,t[3]=l):l=t[3],Y2(l);const c=n??"__no-vmcp__",[d,h]=k.useState(null),u=k.useRef(null);u.current!==c&&(u.current=c,h(Mz(c)));const f=d??!1;let m;t[4]!==c?(m=_=>{h(_),$z(c,_)},t[4]=c,t[5]=m):m=t[5];const p=m,g=r.vmEntry?.sandboxHandle??"no-vm",x=r.vmEntry?.sandboxHandle??null;let v;return t[6]!==o.scripts||t[7]!==p||t[8]!==r.branch||t[9]!==r.restart||t[10]!==r.resume||t[11]!==r.retry||t[12]!==r.start||t[13]!==r.status||t[14]!==r.stop||t[15]!==f||t[16]!==s.slug||t[17]!==g||t[18]!==x||t[19]!==n?(v=i.jsx(Iz,{vmId:x,orgSlug:s.slug,virtualMcpId:n,branch:r.branch,status:r.status,scripts:o.scripts,open:f,onOpenChange:p,onStart:r.start,onStop:r.stop,onRestart:r.restart,onResume:r.resume,onRetry:r.retry},g),t[6]=o.scripts,t[7]=p,t[8]=r.branch,t[9]=r.restart,t[10]=r.resume,t[11]=r.retry,t[12]=r.start,t[13]=r.status,t[14]=r.stop,t[15]=f,t[16]=s.slug,t[17]=g,t[18]=x,t[19]=n,t[20]=v):v=t[20],v}function _5(t){const e=M.c(15),{virtualMcpId:s,taskId:n}=t,r=oi(),{activeTask:o}=Qt();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const{main:l}=_r(a);let c;e[1]!==o?.metadata||e[2]!==r?.entity?.metadata?(c=tn(r?.entity?.metadata)||tn(o?.metadata),e[1]=o?.metadata,e[2]=r?.entity?.metadata,e[3]=c):c=e[3];const d=c;let h;e[4]!==d||e[5]!==l?(h=d&&!(typeof l=="string"&&n6.has(l)),e[4]=d,e[5]=l,e[6]=h):h=e[6];const u=h;let f;e[7]!==n||e[8]!==s?(f=i.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:i.jsx(pM,{taskId:n,virtualMcpId:s})}),e[7]=n,e[8]=s,e[9]=f):f=e[9];let m;e[10]!==u?(m=u&&i.jsx(Bz,{}),e[10]=u,e[11]=m):m=e[11];let p;return e[12]!==f||e[13]!==m?(p=i.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[f,m]}),e[12]=f,e[13]=m,e[14]=p):p=e[14],p}function y5(t){const e=M.c(4),{chatContent:s}=t;let n;e[0]!==s?(n=s??i.jsx(bp,{}),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{"data-testid":"chat-panel",className:"h-full min-h-0",children:n}),e[2]=n,e[3]=r):r=e[3],r}function G1(t){const e=M.c(3),{children:s,testId:n}=t;let r;return e[0]!==s||e[1]!==n?(r=i.jsx("div",{className:"h-full p-0.5 pt-0.25",children:i.jsx("div",{"data-testid":n,className:"h-full min-h-0 overflow-hidden rounded-[0.75rem] bg-background card-shadow",children:s})}),e[0]=s,e[1]=n,e[2]=r):r=e[2],r}function zz(t){const e=M.c(38),{virtualMcpId:s,taskId:n,sidePanel:r,mainOpen:o,chatContent:a}=t,[,l]=k.useTransition(),[c,d]=LS(),h=k.useRef(null);let u;e[0]!==o||e[1]!==r?(u=xS({sidePanel:r,mainOpen:o}),e[0]=o,e[1]=r,e[2]=u):u=e[2];const f=u,m=r!==null&&o?c:f.side,p=100-m;let g,x;e[3]!==p||e[4]!==m?(g=()=>{h.current?.setLayout([m,p])},x=[m,p],e[3]=p,e[4]=m,e[5]=g,e[6]=x):(g=e[5],x=e[6]),k.useEffect(g,x);const v=`${s}-${n}`;let _;e[7]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[7]=_):_=e[7];const b=f.side,y=r!==null?"min-w-[320px]":"min-w-0";let L;e[8]!==y?(L=te("overflow-hidden bg-sidebar",y),e[8]=y,e[9]=L):L=e[9];let w;e[10]!==o||e[11]!==d||e[12]!==r?(w=P=>l(()=>{r!==null&&o&&P>0&&P<100&&d(P)}),e[10]=o,e[11]=d,e[12]=r,e[13]=w):w=e[13];let S;e[14]!==a||e[15]!==r?(S=r!==null&&i.jsx(y5,{chatContent:a}),e[14]=a,e[15]=r,e[16]=S):S=e[16];let j;e[17]!==S?(j=i.jsx(G1,{testId:"side-panel",children:S}),e[17]=S,e[18]=j):j=e[18];let C;e[19]!==f.side||e[20]!==j||e[21]!==L||e[22]!==w?(C=i.jsx(nl,{order:1,defaultSize:b,minSize:20,collapsible:!0,collapsedSize:0,className:L,onResize:w,children:j}),e[19]=f.side,e[20]=j,e[21]=L,e[22]=w,e[23]=C):C=e[23];let V;e[24]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(Qm,{className:"bg-sidebar"}),e[24]=V):V=e[24];const N=f.main,T=o?"min-w-[320px]":"min-w-0";let A;e[25]!==T?(A=te("min-w-0 overflow-hidden bg-sidebar",T),e[25]=T,e[26]=A):A=e[26];let E;e[27]!==n||e[28]!==s?(E=i.jsx(G1,{testId:"main-panel",children:i.jsx(_5,{taskId:n,virtualMcpId:s})}),e[27]=n,e[28]=s,e[29]=E):E=e[29];let R;e[30]!==f.main||e[31]!==A||e[32]!==E?(R=i.jsx(nl,{order:2,defaultSize:N,minSize:20,collapsible:!0,collapsedSize:0,className:A,children:E}),e[30]=f.main,e[31]=A,e[32]=E,e[33]=R):R=e[33];let D;return e[34]!==C||e[35]!==R||e[36]!==v?(D=i.jsxs(Xm,{ref:h,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[C,V,R]},v),e[34]=C,e[35]=R,e[36]=v,e[37]=D):D=e[37],D}function L5(t){const e=M.c(13),s=yt();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},e[0]=n):n=e[0];const r=zl(n);let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},e[1]=o):o=e[1];const a=_r(o),l=a.main===t,c=k.useRef(void 0),d=!!(r.org&&r.taskId);let h;e[2]!==l||e[3]!==s||e[4]!==t||e[5]!==r.org||e[6]!==r.taskId||e[7]!==a.main?(h=()=>{if(!r.org||!r.taskId)return;const m=r.org,p=r.taskId;s({to:"/$org/$taskId",params:{org:m,taskId:p},search:g=>{const x={...g};if(l){const v=c.current;v&&v!==t?x.main=v:delete x.main}else c.current=a.main===0?void 0:a.main,x.main=t;return x},replace:!0})},e[2]=l,e[3]=s,e[4]=t,e[5]=r.org,e[6]=r.taskId,e[7]=a.main,e[8]=h):h=e[8];const u=h;let f;return e[9]!==l||e[10]!==d||e[11]!==u?(f={active:l,enabled:d,toggle:u},e[9]=l,e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function Fz(){const t=M.c(7),e=Jl(),{active:s,enabled:n,toggle:r}=L5("files");if(!n||e)return null;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={kind:"component",Component:Xn},t[0]=o):o=t[0];let a;t[1]!==s||t[2]!==r?(a=()=>{Ne("agent_toolbar_toggled",{button:"library",next_state:s?"closed":"open"}),r()},t[1]=s,t[2]=r,t[3]=a):a=t[3];let l;return t[4]!==s||t[5]!==a?(l=i.jsx(Gl,{title:"Library",icon:o,active:s,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",onClick:a}),t[4]=s,t[5]=a,t[6]=l):l=t[6],l}function Uz(){const t=M.c(7),{active:e,enabled:s,toggle:n}=L5("board");if(!s)return null;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"component",Component:zm},t[0]=r):r=t[0];let o;t[1]!==e||t[2]!==n?(o=()=>{Ne("agent_toolbar_toggled",{button:"tasks",next_state:e?"closed":"open"}),n()},t[1]=e,t[2]=n,t[3]=o):o=t[3];let a;return t[4]!==e||t[5]!==o?(a=i.jsx(Gl,{title:"Tasks",icon:r,active:e,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",onClick:o}),t[4]=e,t[5]=o,t[6]=a):a=t[6],a}function Hz(t){const e=M.c(12),{sidePanel:s,toggleSidePanel:n,disableActiveSidePanelToggle:r}=t,o=r===void 0?!1:r;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={kind:"component",Component:Fm},e[0]=a):a=e[0];const l=s==="chat",c=o&&s==="chat";let d;e[1]!==s||e[2]!==n?(d=()=>{Ne("agent_toolbar_toggled",{button:"chat",next_state:s==="chat"?"closed":"open"}),n("chat")},e[1]=s,e[2]=n,e[3]=d):d=e[3];let h;e[4]!==l||e[5]!==c||e[6]!==d?(h=i.jsx(Gl,{title:"Chat",icon:a,active:l,disabled:c,className:"wco-no-drag h-10 md:h-8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50",onClick:d}),e[4]=l,e[5]=c,e[6]=d,e[7]=h):h=e[7];let u,f;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Uz,{}),f=i.jsx(Fz,{}),e[8]=u,e[9]=f):(u=e[8],f=e[9]);let m;return e[10]!==h?(m=i.jsxs(i.Fragment,{children:[h,u,f]}),e[10]=h,e[11]=m):m=e[11],m}function Kz(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const n=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:n,overflow:r};if(n.some(u=>u.id===e))return{visible:n,overflow:r};const a=r.findIndex(u=>u.id===e);if(a===-1)return{visible:n,overflow:r};const l=n[n.length-1],c=r[a],d=[...n.slice(0,-1),c],h=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:d,overflow:h}}function Wz(t){const e=M.c(13),{overflow:s,onSelect:n}=t,[r,o]=k.useState(!1);let a;e[0]!==n?(a=f=>{o(!1),n(f)},e[0]=n,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(As,{asChild:!0,children:i.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:i.jsx(ni,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=m=>i.jsx("li",{children:i.jsxs("button",{type:"button",onClick:()=>l(m.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[i.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:i.jsx(o9,{icon:m.icon})}),i.jsx("span",{className:"truncate",children:m.title})]})},m.id),e[6]=l,e[7]=f):f=e[7],d=s.map(f),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let h;e[8]!==d?(h=i.jsx(Ts,{align:"end",className:"w-56 p-1",children:i.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==r||e[11]!==h?(u=i.jsxs(Ns,{open:r,onOpenChange:o,children:[c,h]}),e[10]=r,e[11]=h,e[12]=u):u=e[12],u}const qz=6;function Gz(t){const e=M.c(21),{virtualMcpId:s,taskId:n,disableActiveMainToggle:r}=t,o=r===void 0?!1:r,a=yt();let l;e[0]!==n||e[1]!==s?(l={virtualMcpId:s,taskId:n},e[0]=n,e[1]=s,e[2]=l):l=e[2];const{tabs:c,activeTab:d,mainOpen:h,setActiveTab:u}=M9(l);let f,m,p,g;if(e[3]!==d||e[4]!==o||e[5]!==h||e[6]!==a||e[7]!==u||e[8]!==c||e[9]!==s){const _=i6({activeTab:d,mainOpen:h}),b=j=>j.id==="automations"?_:h&&j.id===d,L=c.find(j=>b(j))?.id??null,{visible:w,overflow:S}=Kz(c,L,qz);m=S,f=j=>{const C=c.find(N=>N.id===j);if(o&&C&&b(C))return;const V=L===j&&h;if(Ne("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:C?.kind??null,was_active:V}),j==="automations"){const N=r6({activeTab:d,mainOpen:h});a({to:".",search:T=>({...T,main:N}),replace:!0});return}u(j)},p="flex items-center min-w-0 gap-0.5",g=w.map(j=>i.jsx(Gl,{title:j.title,icon:j.icon,active:b(j),locked:o&&b(j),onClick:()=>f(j.id)},j.id)),e[3]=d,e[4]=o,e[5]=h,e[6]=a,e[7]=u,e[8]=c,e[9]=s,e[10]=f,e[11]=m,e[12]=p,e[13]=g}else f=e[10],m=e[11],p=e[12],g=e[13];let x;e[14]!==f||e[15]!==m?(x=m.length>0&&i.jsx(Wz,{overflow:m,onSelect:f}),e[14]=f,e[15]=m,e[16]=x):x=e[16];let v;return e[17]!==p||e[18]!==g||e[19]!==x?(v=i.jsxs("div",{className:p,children:[g,x]}),e[17]=p,e[18]=g,e[19]=x,e[20]=v):v=e[20],v}const w0="__mobile-main-panel-tab-select__";function Yz({tabs:t,activeTab:e,mainOpen:s}){const n=t.find(r=>r.id===e);return s?n?.title??"Main view":n?.title??t[0]?.title??"Main view"}const Jz={kind:"component",Component:Fm},Xz={kind:"component",Component:zm},Qz={kind:"component",Component:Xn};function Zz(t){const e=M.c(50),{virtualMcpId:s,taskId:n}=t,r=yt();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},e[0]=o):o=e[0];const a=zl(o);let l;e[1]!==n||e[2]!==s?(l={virtualMcpId:s,taskId:n},e[1]=n,e[2]=s,e[3]=l):l=e[3];const{tabs:c,activeTab:d,mainOpen:h}=M9(l),{org:u}=Ee(),f=Jl();let m;e[4]!==u.id?(m=el(u.id),e[4]=u.id,e[5]=m):m=e[5];const p=s===m,g=!!(a.org&&a.taskId);let x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x={value:"chat",title:"Chat",icon:Jz},e[6]=x):x=e[6];let v;if(e[7]!==g||e[8]!==c){let I,O;e[10]!==g?(I=g?[{value:"board",title:"Tasks",icon:Xz}]:[],O=g?[{value:"files",title:"Library",icon:Qz}]:[],e[10]=g,e[11]=I,e[12]=O):(I=e[11],O=e[12]),v=[x,...c.map(tF),...I,...O],e[7]=g,e[8]=c,e[9]=v}else v=e[9];const _=v;let b;e[13]!==d||e[14]!==h||e[15]!==_?(b=h?_.find(I=>I.value===d)?.value??d:"chat",e[13]=d,e[14]=h,e[15]=_,e[16]=b):b=e[16];const y=b;let L;e[17]!==y||e[18]!==_?(L=_.find(I=>I.value===y),e[17]=y,e[18]=_,e[19]=L):L=e[19];const w=L;let S;e[20]!==d||e[21]!==h||e[22]!==w?.title||e[23]!==c?(S=w?.title??Yz({tabs:c,activeTab:d,mainOpen:h}),e[20]=d,e[21]=h,e[22]=w?.title,e[23]=c,e[24]=S):S=e[24];const j=S;let C;e[25]!==r||e[26]!==p||e[27]!==u.id||e[28]!==u.slug||e[29]!==f||e[30]!==s?(C=I=>{if(I!==w0){if(Ne("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:I,source:"mobile_select"}),Op({reportsOnly:f,onReportAgent:p,tabId:I})){r({to:"/$org/$taskId",params:{org:u.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:el(u.id),main:I}});return}r({to:".",search:O=>I==="chat"?{...O,sidepanel:"chat",main:0}:{...O,sidepanel:0,main:I},replace:!0})}},e[25]=r,e[26]=p,e[27]=u.id,e[28]=u.slug,e[29]=f,e[30]=s,e[31]=C):C=e[31];const V=C;let N;e[32]!==w?(N=w&&i.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:i.jsx(o9,{icon:w.icon,className:"size-5"})}),e[32]=w,e[33]=N):N=e[33];let T;e[34]!==j?(T=i.jsx("span",{className:"min-w-0 truncate",children:j}),e[34]=j,e[35]=T):T=e[35];let A;e[36]!==N||e[37]!==T?(A=i.jsx(Xt,{"aria-label":"View",className:"h-10! w-full min-w-0 max-w-[7.5rem] rounded-md border-0 bg-transparent px-1.5 text-xs shadow-none [--card-shadow:none]",children:i.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[N,T]})}),e[36]=N,e[37]=T,e[38]=A):A=e[38];let E;e[39]!==j?(E=i.jsx(pt,{value:w0,disabled:!0,hideCheck:!0,className:"hidden",children:j}),e[39]=j,e[40]=E):E=e[40];let R;e[41]!==_?(R=_.map(eF),e[41]=_,e[42]=R):R=e[42];let D;e[43]!==E||e[44]!==R?(D=i.jsxs(Yt,{align:"end",className:"w-56",children:[E,R]}),e[43]=E,e[44]=R,e[45]=D):D=e[45];let P;return e[46]!==V||e[47]!==A||e[48]!==D?(P=i.jsxs(Jt,{value:w0,onValueChange:V,children:[A,D]}),e[46]=V,e[47]=A,e[48]=D,e[49]=P):P=e[49],P}function eF(t){return i.jsx(pt,{value:t.value,children:i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[i.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:i.jsx(o9,{icon:t.icon})}),i.jsx("span",{className:"min-w-0 truncate",children:t.title})]})},t.value)}function tF(t){return{value:t.id,title:t.title,icon:t.icon}}function S5(t){return oa({userName:t?.name,userEmail:t?.email})??void 0}const sF=new Set(["main","master"]);function Ru(t){return sF.has(t.trim().toLowerCase())?"Publish to production":"Publish"}function nF(t){const e=M.c(24),{baseBranch:s,disabled:n,loading:r,onPublish:o,onReview:a}=t,l=r===void 0?!1:r;let c;e[0]!==s?(c=Ru(s),e[0]=s,e[1]=c):c=e[1];const d=c;let h;e[2]!==o?(h=()=>{o()},e[2]=o,e[3]=h):h=e[3];let u;e[4]!==l?(u=l?i.jsx(or,{size:"xs",variant:"default"}):null,e[4]=l,e[5]=u):u=e[5];let f;e[6]!==n||e[7]!==d||e[8]!==h||e[9]!==u?(f=i.jsxs(re,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:n,onClick:h,children:[u,d]}),e[6]=n,e[7]=d,e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(ts,{className:"h-3.5 w-3.5"}),e[11]=m):m=e[11];let p;e[12]!==n?(p=i.jsx(ls,{asChild:!0,children:i.jsx(re,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:n,"aria-label":"More actions",children:m})}),e[12]=n,e[13]=p):p=e[13];let g;e[14]!==a?(g=a?i.jsx(Ge,{onClick:a,children:"Review"}):null,e[14]=a,e[15]=g):g=e[15];let x;e[16]!==g?(x=i.jsx(cs,{align:"end",children:g}),e[16]=g,e[17]=x):x=e[17];let v;e[18]!==p||e[19]!==x?(v=i.jsxs(as,{children:[p,x]}),e[18]=p,e[19]=x,e[20]=v):v=e[20];let _;return e[21]!==v||e[22]!==f?(_=i.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[f,v]}),e[21]=v,e[22]=f,e[23]=_):_=e[23],_}class so extends Error{constructor(e,s,n){super(e),this.step=s,this.pr=n,this.name="PublishFlowError"}step;pr}function iF(t){const e=M.c(10),[s,n]=k.useState(0);let r;e[0]!==t?(r=c=>{c&&n(rF),t.onOpenChange(c)},e[0]=t,e[1]=r):r=e[1];const o=r;let a;e[2]!==o||e[3]!==t||e[4]!==s?(a=t.open?i.jsx(oF,{...t,onOpenChange:o},s):null,e[2]=o,e[3]=t,e[4]=s,e[5]=a):a=e[5];let l;return e[6]!==o||e[7]!==t.open||e[8]!==a?(l=i.jsx(es,{open:t.open,onOpenChange:o,children:a}),e[6]=o,e[7]=t.open,e[8]=a,e[9]=l):l=e[9],l}function rF(t){return t+1}function oF({onOpenChange:t,orgSlug:e,orgId:s,virtualMcpId:n,branch:r,baseBranch:o,githubConnectionId:a,owner:l,repo:c,previewUrl:d,dialogIntent:h="open-pr",headSha:u=null,openPullRequest:f=null,onPullRequestChanged:m,onPublished:p}){const g=ut({connectionId:a,orgId:s,orgSlug:e}),x=ut({connectionId:Go,orgId:s,orgSlug:e}),{data:v}=Ai.useSession(),_=S9(x),b=S5(v?.user),y=f?.state==="open",L=h==="open-pr"&&!y,w=h==="publish-only",[S,j]=k.useState(null),[C,V]=k.useState(null),[N,T]=k.useState(!0),[A,E]=k.useState(!1),[R,D]=k.useState(""),[P,I]=k.useState(""),[O,B]=k.useState(),[z,$]=k.useState(!1),[U,W]=k.useState(),[X,H]=k.useState(!1),[Z,K]=k.useState(!1),[Y,F]=k.useState(!1),Q=k.useRef(!1),J=k.useRef(!1),ee={base:o,...u?{headSha:u}:{}},q=async xe=>{const Ae=(xe.aheadOfBase??0)>0?await tr(e,n,r,ee):null,pe=pc(xe)?await tr(e,n,r):null;return W3(Ae,pe)},se=async()=>{const xe=await Ha(e,n,r),Ae=w?await q(xe):await tr(e,n,r,zN(xe,{openPrFromCommits:L,commitToOpenPr:y})?ee:void 0);j(xe),V(Ae),D(`Changes from ${xe.current??r}`),F(!0),rf(e,n,r,{status:xe,diff:Ae}).then(pe=>{D(pe.title),I(pe.body)}).catch(()=>{}).finally(()=>F(!1))};Q.current||(Q.current=!0,(async()=>{T(!0),B(void 0),V(null),D(""),I(""),W(void 0);try{await se()}catch(xe){if(z3(xe)&&!J.current){J.current=!0;try{await _.mutateAsync({virtualMcpId:n,branch:r}),await se();return}catch(Ae){B(Ae instanceof Error?Ae.message:"Failed to load changes after re-provisioning the sandbox.");return}}B(xe instanceof Error?xe.message:"Failed to load changes.")}finally{T(!1)}})());const ne=$N(S)??r,le=Ru(o),G=()=>{!S||!C||(F(!0),rf(e,n,r,{status:S,diff:C}).then(xe=>{D(xe.title),I(xe.body)}).catch(()=>{}).finally(()=>F(!1)))},oe=H3(S),me=C?Object.keys(C.diffs).length:oe,ue=L?K3(S):BN(S,C),ye=!N&&(ue||L),Le=q3(C),Ce=ye&&Le.allowed,ze=ye?Le.reason:null,Te=L||!y&&(S?.aheadOfBase??0)>0,Se=!N&&(Te||ue)&&(me>0||ue),be=()=>[R.trim(),P.trim()].filter(Boolean).join(`
518
+
519
+ `),Re=xe=>{A||z||t(xe)},Ve=async()=>{E(!0),B(void 0);let xe;try{const Ae=R.trim()||`Changes from ${ne}`,pe=P.trim()||void 0,ke=be()||Ae;try{await of(e,n,r,ke)}catch($e){throw new so($e instanceof Error?$e.message:"Failed to push changes","push")}try{await PN(e,n,r,o)}catch($e){throw new so($e instanceof Error?$e.message:"Failed to rebase onto base","rebase")}try{xe=await eh(g,{owner:l,repo:c,branch:ne,title:Ae,body:pe,base:o,coAuthor:b})}catch($e){throw new so($e instanceof Error?$e.message:"Failed to open pull request","open-pr")}try{await U2(g,{owner:l,repo:c,pullNumber:xe.number,commitTitle:Ae,commitMessage:pe,coAuthor:b})}catch($e){throw new so($e instanceof Error?$e.message:"Failed to merge pull request","merge",xe)}de.success(`Published to ${o}`),Re(!1),V(null),D(""),I(""),await m?.(),await p?.()}catch(Ae){if(Ae instanceof so&&Ae.step==="merge"&&Ae.pr){const pe=`Changes were pushed and PR #${Ae.pr.number} is open, but merge failed: ${Ae.message}`;B(pe),de.error(pe,{action:{label:"View PR",onClick:()=>window.open(Ae.pr.htmlUrl,"_blank","noopener,noreferrer")}}),await m?.();return}B(Ae instanceof Error?Ae.message:"Failed to publish")}finally{E(!1)}},he=async xe=>{try{await af(e,n,r,[xe]),de.success(`Discarded changes to ${xe}`),V(pe=>{if(!pe)return pe;const ke={...pe,diffs:{...pe.diffs}};return delete ke.diffs[xe],ke});const Ae=await Ha(e,n,r);j(Ae)}catch(Ae){de.error(Ae instanceof Error?Ae.message:"Failed to discard changes")}},Pe=async()=>{if(C){H(!1),K(!0);try{const xe=Object.keys(C.diffs);if(xe.length===0)return;await af(e,n,r,xe),de.success("All changes discarded"),V(null);const Ae=await Ha(e,n,r);j(Ae),Re(!1)}catch(xe){de.error(xe instanceof Error?xe.message:"Failed to discard changes")}finally{K(!1)}}},Me=async()=>{$(!0),W(void 0);try{const xe=R.trim()||`Changes from ${ne}`,Ae=P.trim()||void 0,pe=be()||xe;await of(e,n,r,pe);const ke=await eh(g,{owner:l,repo:c,branch:ne,title:xe,body:Ae,base:o,coAuthor:b});de.success(`Submitted pull request #${ke.number} for review`,{action:{label:"View on GitHub",onClick:()=>window.open(ke.htmlUrl,"_blank","noopener,noreferrer")}}),Re(!1),await m?.()}catch(xe){W(xe instanceof Error?xe.message:"Failed to submit for review")}finally{$(!1)}};return i.jsx(Zt,{className:"top-14 left-auto right-4 flex h-[90%] max-h-[85vh] w-[90vw] max-w-[600px] translate-x-0 translate-y-0 flex-col gap-0 overflow-hidden p-0",children:i.jsxs(wr,{defaultValue:"description",className:"flex h-full flex-col gap-0",children:[i.jsxs("div",{className:"shrink-0 space-y-3 px-6 pt-5 pb-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:L?"Submit for review":le}),i.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full bg-success"}),me," ",me===1?"change":"changes"," ",L?"in this PR":"to publish"]})]}),X?i.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-destructive/5 px-3 py-2",children:[i.jsx("span",{className:"text-xs text-destructive",children:"Discard all changes? This cannot be undone."}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[i.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>H(!1),children:"Cancel"}),i.jsxs(re,{type:"button",size:"sm",className:"h-7 bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:Pe,disabled:Z,children:[Z?i.jsx(Xe,{className:"h-3 w-3 animate-spin"}):null,"Discard all"]})]})]}):i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs(Zo,{className:"h-8 w-auto",variant:"pill",children:[i.jsx(gn,{value:"description",className:"px-3 text-xs",children:"Description"}),i.jsx(gn,{value:"changes",className:"px-3 text-xs",children:"Changes"})]}),me>0&&!L&&i.jsx("button",{type:"button",className:"text-xs text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50",onClick:()=>H(!0),disabled:A||Z,children:"Discard all"})]})]}),i.jsx("div",{className:"border-t"}),i.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:N?i.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[i.jsx(Xe,{className:"h-4 w-4 animate-spin"}),i.jsx("span",{className:"text-sm",children:"Loading changes…"})]}):i.jsxs(i.Fragment,{children:[i.jsx(gi,{value:"description",className:"mt-0 px-6 py-5",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("p",{className:"text-sm font-medium",children:L?"Pull request":"Commit message"}),i.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",disabled:Y||A||z,onClick:G,children:[Y?i.jsx(Xe,{className:"h-3 w-3 animate-spin"}):i.jsx(Kn,{className:"h-3 w-3"}),Y?"Generating…":"Regenerate"]})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"publish-title",className:"text-xs font-medium text-muted-foreground",children:"Title"}),i.jsx(tt,{id:"publish-title",value:R,onChange:xe=>D(xe.target.value),placeholder:Y?"Generating…":"Commit title…",disabled:A||z||Y,className:"text-sm"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"publish-body",className:"text-xs font-medium text-muted-foreground",children:"Description"}),i.jsx(ur,{id:"publish-body",value:P,onChange:xe=>I(xe.target.value),placeholder:Y?"Generating…":"Description (optional)…",disabled:A||z||Y,rows:5,className:"resize-none text-sm"})]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["Branch: ",i.jsx("span",{className:"font-mono",children:r})," → ",i.jsx("span",{className:"font-mono",children:o})," · ",i.jsx("span",{className:"text-foreground/80",children:w?`${le} squash-merges into ${o}.`:`Opens a pull request into ${o} for review.`})]})]})}),i.jsx(gi,{value:"changes",className:"mt-0",children:i.jsx(G3,{diff:C,onDiscardFile:he})})]})}),i.jsx("div",{className:"shrink-0 border-t",children:i.jsxs("button",{type:"button",className:"flex w-full items-center justify-between px-6 py-3.5 text-sm transition-colors hover:bg-muted/50 disabled:opacity-50",onClick:()=>{d&&window.open(d,"_blank","noopener,noreferrer")},disabled:!d,children:[i.jsxs("span",{className:"flex items-center gap-3",children:[i.jsx(c2,{className:"h-4 w-4 text-muted-foreground"}),"Visit preview"]}),i.jsx(Sr,{className:"h-4 w-4 text-muted-foreground"})]})}),i.jsx("div",{className:"shrink-0 border-t px-6 py-3",children:w?i.jsxs(i.Fragment,{children:[i.jsx(aF,{label:le,canPublish:Ce,disabledReason:ze,isPublishing:A,onPublish:Ve}),O&&i.jsx("p",{className:"mt-2 text-xs text-destructive",children:O})]}):i.jsxs(i.Fragment,{children:[i.jsxs(re,{type:"button",className:"w-full",onClick:Me,disabled:!Se||z,children:[z?i.jsx(Xe,{className:"h-4 w-4 animate-spin"}):i.jsx(Qs,{className:"h-4 w-4"}),"Submit for review"]}),U&&i.jsx("p",{className:"mt-2 text-xs text-destructive",children:U})]})})]})})}function aF(t){const e=M.c(14),{label:s,canPublish:n,disabledReason:r,isPublishing:o,onPublish:a}=t,l=!n||o;let c;e[0]!==o?(c=o?i.jsx(Xe,{className:"h-4 w-4 animate-spin"}):null,e[0]=o,e[1]=c):c=e[1];let d;e[2]!==s||e[3]!==a||e[4]!==l||e[5]!==c?(d=i.jsxs(re,{type:"button",variant:"success",className:"w-full",onClick:a,disabled:l,children:[c,s]}),e[2]=s,e[3]=a,e[4]=l,e[5]=c,e[6]=d):d=e[6];const h=d;if(!r)return h;let u;e[7]!==h?(u=i.jsx(Ie,{asChild:!0,children:i.jsx("span",{className:"flex w-full",children:h})}),e[7]=h,e[8]=u):u=e[8];let f;e[9]!==r?(f=i.jsx(De,{children:r}),e[9]=r,e[10]=f):f=e[10];let m;return e[11]!==u||e[12]!==f?(m=i.jsx(_i,{children:i.jsxs(Oe,{children:[u,f]})}),e[11]=u,e[12]=f,e[13]=m):m=e[13],m}function lF(){return!1}function w5(t,e){lF()&&console.log(`[github-header] ${t}`,e??"")}function cF(t){if(!(t==="claiming"||t==="ready"||t==="failed"))return _g[t].short}const dF=new Set(["failure","timed_out","cancelled","action_required"]);function uF(t){return t.status==="completed"&&dF.has(t.conclusion)}function hF(t){return t.status==="queued"||t.status==="in_progress"}function fF(t){return t.isPending&&t.fetchStatus!=="idle"}function mF(t){const{lifecycle:e,branch:s,pr:n,checks:r,reviews:o,loading:a}=t;if(a)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.phase){case"idle":return{label:t.claimPhase&&cF(t.claimPhase.kind)||"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`}}if(s.kind!=="ready")return{label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for branch metadata from the sandbox daemon"};const l=s;if(l.workingTreeDirty)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push and open a PR for ${l.branch} → ${l.base}`,showPublishSide:!0};if(l.unpushed>0&&!(n&&l.headSha&&n.headSha&&l.headSha===n.headSha))return n?{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push local commits to PR #${n.number}`,showPublishSide:!0}:{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Push and open a PR for ${l.branch} → ${l.base}`,showPublishSide:!0};if(w5("no local work — checking PR/sync state",{workingTreeDirty:l.workingTreeDirty,unpushed:l.unpushed,aheadOfBase:l.aheadOfBase,behindBase:l.behindBase,branch:l.branch,base:l.base,prMerged:n?.merged??null,prState:n?.state??null}),n?.merged)return!!l.headSha&&!!n.headSha&&l.headSha!==n.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits",showPublishSide:!0}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${n.number} merged into ${n.base}`};if(l.aheadOfBase>0){if(n&&n.state==="closed"&&!n.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${n.number}`};if(!n)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${l.branch} → ${l.base}`,showPublishSide:!0};if((o?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${n.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${n.base} before merging`};const h=r.filter(uF).map(m=>m.name);if(h.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${h.join(", ")}`,meta:{failingChecks:h}};const u=r.filter(hF);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(o?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const f=o?.unresolvedConversations??0;return f>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${f} unresolved conversation${f===1?"":"s"}`}:o?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:Ru(n.base),action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${n.number} into ${n.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${l.base}`}}function pF(t,e,s){if(!e)return s??null;const n=t?.[e];if(!n)return s??null;if(s&&n[s])return s;for(const[r,o]of Object.entries(n))if(o&&Object.keys(o).length>0)return r;return s??null}function gF(t,e,s,n,r){return["publish-gate",t,e,s,n,r]}function xF(t){const e=M.c(21),{orgSlug:s,virtualMcpId:n,branch:r,base:o,headSha:a,signature:l,enabled:c}=t,d=c===void 0?!0:c;let h;e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==l||e[4]!==n?(h=gF(s,n,r,o,l),e[0]=o,e[1]=r,e[2]=s,e[3]=l,e[4]=n,e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==r||e[8]!==a||e[9]!==s||e[10]!==n?(u=async()=>{const v=await Ha(s,n,r),_=(v.aheadOfBase??0)>0?await tr(s,n,r,{base:o,...a?{headSha:a}:{}}):null,b=pc(v)?await tr(s,n,r):null;return W3(_,b)},e[6]=o,e[7]=r,e[8]=a,e[9]=s,e[10]=n,e[11]=u):u=e[11];const f=d&&!!r;let m;e[12]!==h||e[13]!==u||e[14]!==f?(m={queryKey:h,queryFn:u,enabled:f,refetchInterval:1e4,staleTime:5e3,retry:vF},e[12]=h,e[13]=u,e[14]=f,e[15]=m):m=e[15];const p=Ut(m);if(!p.data){let v;return e[16]===Symbol.for("react.memo_cache_sentinel")?(v={gate:{allowed:!0,reason:null},ready:!1},e[16]=v):v=e[16],v}let g;e[17]!==p.data?(g=q3(p.data),e[17]=p.data,e[18]=g):g=e[18];let x;return e[19]!==g?(x={gate:g,ready:!0},e[19]=g,e[20]=x):x=e[20],x}function vF(t,e){return!z3(e)&&t<2}const bF=6e4,_F=3e4;function yF(t){const e=M.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const n=ut(s),r=t.prNumber??0;let o;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=o):o=e[7];const a=!!t.prNumber;let l;return e[8]!==n||e[9]!==o||e[10]!==a?(l={client:n,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:bF,refetchIntervalInBackground:!1,staleTime:_F,select:LF},e[8]=n,e[9]=o,e[10]=a,e[11]=l):l=e[11],ta(l)}function LF(t){const e=Oi(t);if(!e)return null;const s=e.mergeable_state??"unknown",n=!!(e.draft??!1),r=Number(e.review_comments??0),o=s==="blocked"&&r>0?r:0;return{draft:n,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}const SF={label:"Loading branch…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for sandbox branch"};function wF({virtualMcpId:t}){const{org:e}=Ee(),{data:s}=Ai.useSession(),n=fs(t),{currentBranch:r,setCurrentTaskBranch:o}=Qt(),a=Ys(),[l,c]=k.useState(!1),[d,h]=k.useState("open-pr"),[u,f]=k.useState(!1),m=k.useRef(""),p=cb(n),g=p.status==="attached"||p.status==="public-clone"?p.repo:null,x=s?.user?.id,v=ut({connectionId:g?.connectionId??"",orgId:e.id,orgSlug:e.slug}),{lifecycle:_,branch:b,phase:y}=$s(),L=b.kind==="ready"?b.branch:null,w=pF(n?.metadata?.sandboxMap,x,r??L),S=r??L??w??void 0,j=(b.kind==="ready"?b.branch:null)??S??null,C=L9({orgId:e.id,orgSlug:e.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",branch:j}),V=C.data??null,N=K2({orgId:e.id,orgSlug:e.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",prNumber:V&&V.state==="open"?V.number:null}),T=yF({orgId:e.id,orgSlug:e.slug,connectionId:g?.connectionId??"",owner:g?.owner??"",repo:g?.name??"",prNumber:V&&V.state==="open"?V.number:null}),A=b,E=A.kind==="ready"?A.base:"main",R=A.kind==="ready"&&!!S&&(A.workingTreeDirty||A.unpushed>0||A.aheadOfBase>0),D=A.kind==="ready"?`${A.headSha}:${A.workingTreeDirty}:${A.unpushed}:${A.aheadOfBase}`:"unknown",{gate:P}=xF({orgSlug:e.slug,virtualMcpId:t,branch:S??"",base:E,headSha:A.kind==="ready"?A.headSha:null,signature:D,enabled:R});if(p.status==="detached")return i.jsx(Qa,{label:"GitHub connection was removed — relink the repository in Settings to save changes",children:i.jsx(re,{size:"sm",variant:"outline",disabled:!0,children:"Reconnect GitHub"})});if(!g)return null;const I=x&&j?Bl(n?.metadata?.sandboxMap?.[x]?.[j]):{},O=Object.values(I),z=(O.find(q=>q.sandboxProviderKind!=="user-desktop")??O[0])?.previewUrl??null,$=j?mF({lifecycle:_,branch:A,claimPhase:y,pr:V,checks:N.data??[],reviews:T.data??null,loading:fF(C)}):SF,U=JSON.stringify({label:$.label,branchKind:A.kind,workingTreeDirty:A.kind==="ready"?A.workingTreeDirty:null,unpushed:A.kind==="ready"?A.unpushed:null,aheadOfBase:A.kind==="ready"?A.aheadOfBase:null,lifecycle:_.phase,githubHeadBranch:j});m.current!==U&&(m.current=U,w5("header button",{label:$.label,tooltip:$.tooltip,action:$.action,chatBranch:r,sandboxBranch:L,sandboxMapBranch:w,sandboxRouteBranch:S,githubHeadBranch:j,branchMeta:b,effectiveBranchMeta:A,lifecyclePhase:_.phase,prNumber:V?.number??null,prState:V?.state??null}));const W=q=>a.sendMessage({parts:[{type:"text",text:q}]}),X=a.isStreaming,H=A.kind==="ready"?A.base:"main",Z=async()=>{await Promise.all([C.refetch(),N.refetch(),T.refetch()])},K=async()=>{const q=M2(s?.user?.name??s?.user?.email?.split("@")[0]);await o(q)},Y=async q=>{if(!(!g?.connectionId||u)){f(!0);try{const se=S5(s?.user);await U2(v,{owner:g.owner,repo:g.name,pullNumber:q,coAuthor:se}),de.success(`Published PR #${q}`),await Z(),await K()}catch(se){de.error(se instanceof Error?se.message:"Failed to merge pull request")}finally{f(!1)}}},F=q=>{if(!(!q||!j))switch(q){case"create-pr":h("open-pr"),c(!0);return;case"reopen":if(X)return;V&&W(WN({prNumber:V.number}));return;case"rebase":if(X)return;W(qN({branch:j}));return;case"fix-checks":if(X)return;V&&W(YN({prNumber:V.number,failingChecks:$.meta?.failingChecks??[]}));return;case"mark-ready":if(X)return;V&&W(JN({prNumber:V.number}));return;case"resolve-comments":if(X)return;V&&W(XN({prNumber:V.number}));return;case"merge-split":return}},Q=()=>{h("publish-only"),c(!0)},J=$.showPublishSide??!1,ee=u||X;return i.jsxs(i.Fragment,{children:[i.jsx(jF,{button:$,actionBusy:ee,githubActionPending:u,onActivate:F,showPublishSide:J,onPublishSide:Q,publishGate:P,prNumber:V?.number,prBase:V?.base,onSquashMerge:Y,onReview:V?()=>{X||W(QN({prNumber:V.number}))}:void 0}),S&&i.jsx(iF,{open:l,onOpenChange:c,orgSlug:e.slug,orgId:e.id,virtualMcpId:t,branch:S,baseBranch:H,githubConnectionId:g.connectionId??"",owner:g.owner,repo:g.name,previewUrl:z,dialogIntent:d,headSha:A.kind==="ready"?A.headSha:null,openPullRequest:d==="publish-only"?null:V?.state==="open"?V:null,onPullRequestChanged:Z,onPublished:K})]})}function jF(t){const e=M.c(33),{button:s,actionBusy:n,githubActionPending:r}=t,o=n&&s.action!=="create-pr"&&s.action!=="merge-split",a=!!s.disabled||o||r&&s.action==="merge-split",l=!!s.loading||r&&s.action==="merge-split",c=o?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null&&t.prBase!=null){let g;e[0]!==t?(g=()=>t.onSquashMerge(t.prNumber),e[0]=t,e[1]=g):g=e[1];let x;e[2]!==a||e[3]!==l||e[4]!==t.onReview||e[5]!==t.prBase||e[6]!==g?(x=i.jsx(nF,{baseBranch:t.prBase,disabled:a,loading:l,onPublish:g,onReview:t.onReview}),e[2]=a,e[3]=l,e[4]=t.onReview,e[5]=t.prBase,e[6]=g,e[7]=x):x=e[7];let v;return e[8]!==x||e[9]!==c?(v=i.jsx(Qa,{label:c,children:x}),e[8]=x,e[9]=c,e[10]=v):v=e[10],v}let d;e[11]!==s.action||e[12]!==t?(d=()=>{s.action&&t.onActivate(s.action)},e[11]=s.action,e[12]=t,e[13]=d):d=e[13];let h;e[14]!==l?(h=l?i.jsx(or,{size:"xs",variant:"default"}):null,e[14]=l,e[15]=h):h=e[15];let u;e[16]!==s.label||e[17]!==s.variant||e[18]!==a||e[19]!==d||e[20]!==h?(u=i.jsxs(re,{size:"sm",variant:s.variant,disabled:a,onClick:d,children:[h,s.label]}),e[16]=s.label,e[17]=s.variant,e[18]=a,e[19]=d,e[20]=h,e[21]=u):u=e[21];let f;e[22]!==u||e[23]!==c?(f=i.jsx(Qa,{label:c,children:u}),e[22]=u,e[23]=c,e[24]=f):f=e[24];let m;e[25]!==t.githubActionPending||e[26]!==t.onPublishSide||e[27]!==t.publishGate||e[28]!==t.showPublishSide?(m=t.showPublishSide?i.jsx(Qa,{label:t.publishGate.reason??"Publish directly, skipping review",children:i.jsx(re,{size:"sm",variant:"success",disabled:t.githubActionPending||!t.publishGate.allowed,onClick:t.onPublishSide,children:"Publish"})}):null,e[25]=t.githubActionPending,e[26]=t.onPublishSide,e[27]=t.publishGate,e[28]=t.showPublishSide,e[29]=m):m=e[29];let p;return e[30]!==f||e[31]!==m?(p=i.jsxs("div",{className:"flex items-center gap-2",children:[f,m]}),e[30]=f,e[31]=m,e[32]=p):p=e[32],p}function Qa(t){const e=M.c(9),{label:s,children:n}=t;if(!s){let l;return e[0]!==n?(l=i.jsx(i.Fragment,{children:n}),e[0]=n,e[1]=l):l=e[1],l}let r;e[2]!==n?(r=i.jsx(Ie,{asChild:!0,children:i.jsx("span",{children:n})}),e[2]=n,e[3]=r):r=e[3];let o;e[4]!==s?(o=i.jsx(De,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==r||e[7]!==o?(a=i.jsx(_i,{children:i.jsxs(Oe,{children:[r,o]})}),e[6]=r,e[7]=o,e[8]=a):a=e[8],a}function CF(t){const e=M.c(9),{virtualMcp:s}=t,n=Xo(),{navigateToTask:r}=mx(),{create:o}=Ul();let a,l;if(e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==s){l=Symbol.for("react.early_return_sentinel");e:{const c=db(s,n);if(!c){l=null;break e}const d=c.mode==="dev";let h;e[6]!==o||e[7]!==r?(h=async m=>{const p=crypto.randomUUID();try{await o({id:p,virtual_mcp_id:m})}catch{}r(p,{virtualMcpId:m})},e[6]=o,e[7]=r,e[8]=h):h=e[8];const u=h,f=(m,p)=>i.jsx("button",{type:"button","aria-pressed":p,onClick:()=>{p||u(c.targetId)},className:te("px-2.5 py-1 rounded-md transition-colors",p?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:m});a=i.jsxs("div",{className:"inline-flex items-center rounded-lg border border-border bg-muted p-0.5 text-xs font-medium",children:[f("Develop",d),f("Live",!d)]})}e[0]=n,e[1]=o,e[2]=r,e[3]=s,e[4]=a,e[5]=l}else a=e[4],l=e[5];return l!==Symbol.for("react.early_return_sentinel")?l:a}function kF(t){const e=M.c(10),{locator:s}=Ee(),n=Ms();let r;e[0]!==s?(r=it.taskBoardItems(s),e[0]=s,e[1]=r):r=e[1];let o;e[2]!==n?(o=async()=>(await n.call("TASK_BOARD_ITEM_LIST",{})).items,e[2]=n,e[3]=o):o=e[3];let a;e[4]!==r||e[5]!==o?(a={queryKey:r,queryFn:o},e[4]=r,e[5]=o,e[6]=a):a=e[6];const{data:l}=Ut(a);if(!t||!l)return null;let c;return e[7]!==l||e[8]!==t?(c=l.find(d=>d.threads.some(h=>h.threadId===t))?.id??null,e[7]=l,e[8]=t,e[9]=c):c=e[9],c}function VF(){const t=M.c(10),{org:e}=Ee(),{taskId:s}=Qt(),n=yt(),r=kF(s);if(!r)return null;let o;t[0]!==r||t[1]!==n||t[2]!==e.slug?(o=()=>n({to:"/$org/board",params:{org:e.slug},search:{task:r}}),t[0]=r,t[1]=n,t[2]=e.slug,t[3]=o):o=t[3];let a;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(kn,{size:16}),t[4]=a):a=t[4];let l;t[5]!==o?(l=i.jsx(Ie,{asChild:!0,children:i.jsx(A0,{"aria-label":"Open task in board",onClick:o,children:a})}),t[5]=o,t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(De,{children:"Open task in board"}),t[7]=c):c=t[7];let d;return t[8]!==l?(d=i.jsx(_i,{children:i.jsxs(Oe,{children:[l,c]})}),t[8]=l,t[9]=d):d=t[9],d}function NF(t){const e=M.c(9),{virtualMcp:s,inline:n}=t,r=n===void 0?!1:n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(VF,{}),e[0]=o):o=e[0];let a,l;e[1]!==s?(a=i.jsx(CF,{virtualMcp:s}),l=ub(s)?i.jsx(wF,{virtualMcpId:s.id}):null,e[1]=s,e[2]=a,e[3]=l):(a=e[2],l=e[3]);let c;e[4]!==a||e[5]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2",children:[o,a,l]}),e[4]=a,e[5]=l,e[6]=c):c=e[6];const d=c;if(r)return d;let h;return e[7]!==d?(h=i.jsx(rl.Right,{children:d}),e[7]=d,e[8]=h):h=e[8],h}function AF(t,e){const s=M.c(34),n=_m(),r=k.useSyncExternalStore(n.threads.subscribe,n.threads.get),o=k.useSyncExternalStore(n.threadsStatus.subscribe,n.threadsStatus.get);let a;s[0]!==t||s[1]!==r?(a=t?r.find(b=>b.id===t)??null:null,s[0]=t,s[1]=r,s[2]=a):a=s[2];const l=a,[c,d]=k.useState(void 0);let h;s[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d(void 0)},s[3]=h):h=s[3];let u;s[4]!==t?(u=[t],s[4]=t,s[5]=u):u=s[5],k.useEffect(h,u);let f,m;s[6]!==c||s[7]!==t||s[8]!==l||s[9]!==n||s[10]!==o.kind?(f=()=>{t&&(l||o.kind!=="loading"&&c===void 0&&(d("pending"),n.fetchThread(t).then(b=>{d(b)})))},m=[t,l,o.kind,c,n],s[6]=c,s[7]=t,s[8]=l,s[9]=n,s[10]=o.kind,s[11]=f,s[12]=m):(f=s[11],m=s[12]),k.useEffect(f,m);let p;s[13]!==n||s[14]!==e?(p={mutationFn:async b=>n.create({id:b,virtual_mcp_id:e})},s[13]=n,s[14]=e,s[15]=p):p=s[15];const g=Gs(p);let x,v;if(s[16]!==g||s[17]!==c||s[18]!==t||s[19]!==l||s[20]!==o.kind?(x=()=>{t&&(l||c===null&&o.kind!=="loading"&&(g.isPending||g.variables!==t&&g.mutate(t)))},v=[t,l,c,o.kind,g],s[16]=g,s[17]=c,s[18]=t,s[19]=l,s[20]=o.kind,s[21]=x,s[22]=v):(x=s[21],v=s[22]),k.useEffect(x,v),!t){let b;return s[23]===Symbol.for("react.memo_cache_sentinel")?(b={status:"ready",task:null},s[23]=b):b=s[23],b}if(l){let b;return s[24]!==l?(b={status:"ready",task:l},s[24]=l,s[25]=b):b=s[25],b}if(c&&typeof c=="object"){let b;return s[26]!==c?(b={status:"ready",task:c},s[26]=c,s[27]=b):b=s[27],b}if(g.data){let b;return s[28]!==g.data?(b={status:"ready",task:g.data},s[28]=g.data,s[29]=b):b=s[29],b}if(g.isError){let b;return s[30]!==g.error?(b={status:"error",error:g.error},s[30]=g.error,s[31]=b):b=s[31],b}if(g.isPending||o.kind!=="loading"){let b;return s[32]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[32]=b):b=s[32],b}let _;return s[33]===Symbol.for("react.memo_cache_sentinel")?(_={status:"loading"},s[33]=_):_=s[33],_}function TF(){const t=M.c(6),e=Lr(),s=yt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const{preview:r}=_r(n);if(!e||!r)return null;let o;t[1]!==s?(o=()=>s({to:".",search:EF}),t[1]=s,t[2]=o):o=t[2];let a;return t[3]!==r||t[4]!==o?(a=i.jsx(Kb,{previewPath:r,showSeeInLibrary:!0,onClose:o}),t[3]=r,t[4]=o,t[5]=a):a=t[5],a}function EF(t){const{preview:e,...s}=t;return s}const Wi=k.createContext(null);function oi(){return k.use(Wi)}function j5(t){const e=M.c(6),{children:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=n):n=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(bt.Skeleton,{}),e[1]=r):r=e[1];let o;e[2]!==s?(o=s??i.jsx(bp,{}),e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=i.jsx(vs,{fallback:n,children:i.jsx(k.Suspense,{fallback:r,children:o})}),e[4]=o,e[5]=a):a=e[5],a}function C5(t){const e=M.c(3),{onNewTaskRef:s,createNewTask:n}=t;let r;return e[0]!==n||e[1]!==s?(r=()=>(s.current=n,()=>{s.current=null}),e[0]=n,e[1]=s,e[2]=r):r=e[2],k.useLayoutEffect(r),null}function Y1(t){const e=M.c(23),{virtualMcpId:s,hasActiveGithubRepo:n,sandboxMap:r,children:o}=t,{currentBranch:a,activeTask:l}=Qt(),{pendingSandboxProviderKind:c}=Vs(),{data:d}=Ai.useSession(),h=d?.user?.id,u=l?.metadata?.sandboxMap,f=h&&a&&u?.[h]?.[a]?{...r??{},[h]:{...r?.[h]??{},[a]:u[h][a]}}:r;let m;e[0]!==l?.metadata||e[1]!==n?(m=n||tn(l?.metadata),e[0]=l?.metadata,e[1]=n,e[2]=m):m=e[2];const p=m,g=e8(s,a??void 0),x=h&&a?Bl(f?.[h]?.[a]):{},_=(c?x[c]??null:W2(x))?.previewUrl??null;let b;e[3]!==x||e[4]!==g?(b=Object.keys(x).length>0||g,e[3]=x,e[4]=g,e[5]=b):b=e[5];const y=b,L=a??null,w=a??null,S=h??null,j=`${s}:${a??"no-branch"}`;let C;e[6]!==o||e[7]!==j?(C=i.jsx(oE,{children:o},j),e[6]=o,e[7]=j,e[8]=C):C=e[8];let V;e[9]!==p||e[10]!==f||e[11]!==c||e[12]!==w||e[13]!==S||e[14]!==C||e[15]!==s?(V=i.jsx(x8,{virtualMcpId:s,branch:w,userId:S,hasActiveGithubRepo:p,sandboxMap:f,sandboxProviderKind:c,children:C}),e[9]=p,e[10]=f,e[11]=c,e[12]=w,e[13]=S,e[14]=C,e[15]=s,e[16]=V):V=e[16];let N;return e[17]!==_||e[18]!==y||e[19]!==L||e[20]!==V||e[21]!==s?(N=i.jsx(d8,{virtualMcpId:s,branch:L,previewUrl:_,enabled:y,children:V}),e[17]=_,e[18]=y,e[19]=L,e[20]=V,e[21]=s,e[22]=N):N=e[22],N}function RF(t){const e=M.c(26),{entity:s,virtualMcpId:n,layout:r,onNewTaskRef:o}=t,a=!r.mainOpen;let l;e[0]!==r.sidePanel||e[1]!==r.toggleSidePanel||e[2]!==a?(l=i.jsx(rl.Toggles,{children:i.jsx(Hz,{sidePanel:r.sidePanel,toggleSidePanel:r.toggleSidePanel,disableActiveSidePanelToggle:a})}),e[0]=r.sidePanel,e[1]=r.toggleSidePanel,e[2]=a,e[3]=l):l=e[3];const c=r.sidePanel===null;let d;e[4]!==r.taskId||e[5]!==c||e[6]!==n?(d=i.jsx(rl.Tabs,{children:i.jsx(Gz,{virtualMcpId:n,taskId:r.taskId,disableActiveMainToggle:c})}),e[4]=r.taskId,e[5]=c,e[6]=n,e[7]=d):d=e[7];let h;e[8]!==r.createNewTask||e[9]!==o?(h=i.jsx(C5,{onNewTaskRef:o,createNewTask:r.createNewTask}),e[8]=r.createNewTask,e[9]=o,e[10]=h):h=e[10];let u;e[11]!==s?(u=i.jsx(NF,{virtualMcp:s}),e[11]=s,e[12]=u):u=e[12];let f;e[13]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(bt.Skeleton,{}),e[13]=f):f=e[13];let m;e[14]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(j5,{}),e[14]=m):m=e[14];let p;e[15]!==r.mainOpen||e[16]!==r.sidePanel||e[17]!==r.taskId||e[18]!==n?(p=i.jsx(k.Suspense,{fallback:f,children:i.jsx(zz,{virtualMcpId:n,taskId:r.taskId,sidePanel:r.sidePanel,mainOpen:r.mainOpen,chatContent:m})}),e[15]=r.mainOpen,e[16]=r.sidePanel,e[17]=r.taskId,e[18]=n,e[19]=p):p=e[19];let g;return e[20]!==l||e[21]!==d||e[22]!==h||e[23]!==u||e[24]!==p?(g=i.jsxs(i.Fragment,{children:[l,d,h,u,p]}),e[20]=l,e[21]=d,e[22]=h,e[23]=u,e[24]=p,e[25]=g):g=e[25],g}function PF(t){const e=M.c(15),{virtualMcpId:s,layout:n,onNewTaskRef:r}=t,o=n.mainOpen?"main":n.sidePanel??"chat";let a;e[0]!==n.taskId||e[1]!==s?(a=i.jsx(rl.Tabs,{children:i.jsx(Zz,{virtualMcpId:s,taskId:n.taskId})}),e[0]=n.taskId,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n.createNewTask||e[4]!==r?(l=i.jsx(C5,{onNewTaskRef:r,createNewTask:n.createNewTask}),e[3]=n.createNewTask,e[4]=r,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(bt.Skeleton,{}),e[6]=c):c=e[6];let d;e[7]!==n.taskId||e[8]!==o||e[9]!==s?(d=i.jsx(k.Suspense,{fallback:c,children:i.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o==="main"?i.jsx(vs,{fallback:i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:i.jsx(k.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(Xe,{size:20,className:"animate-spin text-muted-foreground"})}),children:i.jsx("div",{"data-testid":"main-panel",className:"h-full",children:i.jsx(_5,{taskId:n.taskId,virtualMcpId:s})})})}):i.jsx(y5,{chatContent:i.jsx(j5,{})})})}),e[7]=n.taskId,e[8]=o,e[9]=s,e[10]=d):d=e[10];let h;return e[11]!==a||e[12]!==l||e[13]!==d?(h=i.jsxs(i.Fragment,{children:[a,l,d]}),e[11]=a,e[12]=l,e[13]=d,e[14]=h):h=e[14],h}function IF(){const t=M.c(75),e=Lr(),s=yt(),{org:n}=Ee();Gb(n.slug);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const o=zl(r),a=o.org??"";let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},t[1]=l):l=t[1];const c=_r(l);let d;t[2]!==n.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??qo(n.id).id,t[2]=n.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const h=d,u=AF(o.taskId??"",h),f=fs(h),m=f?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let x;t[7]!==f?(x=f&&ea(f),t[7]=f,t[8]=x):x=t[8];const v=!!x;let _;t[9]!==a||t[10]!==h?(_={virtualMcpId:h,orgSlug:a,isAgentRoute:!0},t[9]=a,t[10]=h,t[11]=_):_=t[11];const b=bS(g,_),y=k.useRef(null);let L,w;t[12]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{const I=O=>{ym(O)&&O.shiftKey&&O.code==="KeyS"&&!O.repeat&&(O.preventDefault(),y.current?.())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},w=[],t[12]=L,t[13]=w):(L=t[12],w=t[13]),k.useEffect(L,w);const S=h;let j;t[14]!==f||t[15]!==h?(j={virtualMcpId:h,entity:f},t[14]=f,t[15]=h,t[16]=j):j=t[16];const C=j;if(u.status==="creating"||u.status==="loading"){let I;t[17]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:i.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[i.jsx(Xe,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=I):I=t[17];let O;return t[18]!==C?(O=i.jsx(Wi,{value:C,children:I}),t[18]=C,t[19]=O):O=t[19],O}if(u.status==="error"){let I;t[20]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=I):I=t[20];let O;t[21]!==u.error.message?(O=i.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:i.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[I,i.jsx("div",{className:"text-muted-foreground",children:u.error.message})]})}),t[21]=u.error.message,t[22]=O):O=t[22];let B;return t[23]!==C||t[24]!==O?(B=i.jsx(Wi,{value:C,children:O}),t[23]=C,t[24]=O,t[25]=B):B=t[25],B}if(!f){let I;t[26]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(Sn,{size:48,className:"text-muted-foreground"}),t[26]=I):I=t[26];const O=`The agent "${h}" does not exist in this organization.`;let B;t[27]!==s||t[28]!==a?(B=i.jsx(re,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:a}}),children:"Go to organization home"}),t[27]=s,t[28]=a,t[29]=B):B=t[29];let z;t[30]!==O||t[31]!==B?(z=i.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:i.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:i.jsx(Li,{image:I,title:"Agent not found",description:O,actions:B})})}),t[30]=O,t[31]=B,t[32]=z):z=t[32];let $;return t[33]!==C||t[34]!==z?($=i.jsx(Wi,{value:C,children:z}),t[33]=C,t[34]=z,t[35]=$):$=t[35],$}if(e){const I=u.status==="ready"?u.task:null,O=f?.metadata?.sandboxMap;let B;t[36]===Symbol.for("react.memo_cache_sentinel")?(B=i.jsx(bt.Skeleton,{}),t[36]=B):B=t[36];let z;t[37]!==S||t[38]!==b?(z=i.jsx(k.Suspense,{fallback:B,children:i.jsx(PF,{virtualMcpId:S,layout:b,onNewTaskRef:y})}),t[37]=S,t[38]=b,t[39]=z):z=t[39];let $;t[40]!==b.taskId||t[41]!==z?($=i.jsx(bt.ActiveTaskProvider,{taskId:b.taskId,children:z},b.taskId),t[40]=b.taskId,t[41]=z,t[42]=$):$=t[42];let U;t[43]!==v||t[44]!==O||t[45]!==$||t[46]!==h?(U=i.jsx(Y1,{virtualMcpId:h,hasActiveGithubRepo:v,sandboxMap:O,children:$}),t[43]=v,t[44]=O,t[45]=$,t[46]=h,t[47]=U):U=t[47];let W;t[48]!==S||t[49]!==U||t[50]!==I?(W=i.jsx("div",{className:"flex flex-col flex-1 min-w-0 bg-background min-h-0",children:i.jsx(bt.Provider,{virtualMcpId:S,task:I,children:U},S)}),t[48]=S,t[49]=U,t[50]=I,t[51]=W):W=t[51];let X;return t[52]!==C||t[53]!==W?(X=i.jsx(Wi,{value:C,children:W}),t[52]=C,t[53]=W,t[54]=X):X=t[54],X}const V=u.status==="ready"?u.task:null,N=f?.metadata?.sandboxMap;let T;t[55]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(bt.Skeleton,{}),t[55]=T):T=t[55];let A;t[56]!==f||t[57]!==b||t[58]!==h?(A=i.jsx(k.Suspense,{fallback:T,children:i.jsx(RF,{entity:f,virtualMcpId:h,layout:b,onNewTaskRef:y})}),t[56]=f,t[57]=b,t[58]=h,t[59]=A):A=t[59];let E;t[60]!==b.taskId||t[61]!==A?(E=i.jsx(bt.ActiveTaskProvider,{taskId:b.taskId,children:A},b.taskId),t[60]=b.taskId,t[61]=A,t[62]=E):E=t[62];let R;t[63]!==v||t[64]!==N||t[65]!==E||t[66]!==h?(R=i.jsx(Y1,{virtualMcpId:h,hasActiveGithubRepo:v,sandboxMap:N,children:E}),t[63]=v,t[64]=N,t[65]=E,t[66]=h,t[67]=R):R=t[67];let D;t[68]!==S||t[69]!==R||t[70]!==V?(D=i.jsx(bt.Provider,{virtualMcpId:S,task:V,children:R},S),t[68]=S,t[69]=R,t[70]=V,t[71]=D):D=t[71];let P;return t[72]!==C||t[73]!==D?(P=i.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:i.jsx(Wi,{value:C,children:D})}),t[72]=C,t[73]=D,t[74]=P):P=t[74],P}function DF(){const t=M.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(ix,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(k.Suspense,{fallback:e,children:i.jsxs(d6,{children:[i.jsx(IF,{}),i.jsx(TF,{})]})}),t[1]=s):s=t[1],s}const PK=Object.freeze(Object.defineProperty({__proto__:null,default:DF,useInsetContext:oi},Symbol.toStringTag,{value:"Module"}));export{Wg as $,Lf as A,SK as B,zo as C,Na as D,H8 as E,Vg as F,V9 as G,dc as H,xI as I,Zn as J,Ir as K,eu as L,gr as M,Q9 as N,A3 as O,Dr as P,mc as Q,AR as R,Pn as S,xs as T,U9 as U,Z9 as V,yn as W,fR as X,pR as Y,jK as Z,X9 as _,XH as a,JH as a$,wK as a0,oK as a1,xu as a2,tP as a3,gK as a4,NK as a5,AK as a6,q9 as a7,Lu as a8,QH as a9,xK as aA,iT as aB,bK as aC,mK as aD,JA as aE,lK as aF,pK as aG,fK as aH,hK as aI,kK as aJ,rK as aK,aK as aL,iK as aM,VK as aN,vu as aO,lg as aP,ag as aQ,ZH as aR,PA as aS,tK as aT,sK as aU,DA as aV,LK as aW,uK as aX,yK as aY,Sp as aZ,_K as a_,vK as aa,wc as ab,sD as ac,sc as ad,nc as ae,oi as af,AE as ag,D9 as ah,ZS as ai,oc as aj,mg as ak,Tl as al,TP as am,eK as an,eD as ao,TK as ap,gg as aq,cK as ar,WI as as,EA as at,RA as au,bu as av,n4 as aw,_R as ax,Br as ay,dK as az,I0 as b,WS as b0,GS as b1,PK as b2,D0 as c,bn as d,hg as e,Ha as f,Uo as g,NE as h,ds as i,Ll as j,vc as k,CK as l,Fg as m,UE as n,wD as o,GH as p,YH as q,_n as r,w5 as s,nK as t,Vr as u,kE as v,vR as w,Ka as x,rR as y,ka as z};