solace-agent-mesh 1.6.3__py3-none-any.whl → 1.7.1__py3-none-any.whl

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.

Potentially problematic release.


This version of solace-agent-mesh might be problematic. Click here for more details.

Files changed (244) hide show
  1. solace_agent_mesh/agent/adk/adk_llm.txt +12 -18
  2. solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +1 -1
  3. solace_agent_mesh/agent/adk/callbacks.py +138 -20
  4. solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +2 -0
  5. solace_agent_mesh/agent/adk/models/lite_llm.py +38 -5
  6. solace_agent_mesh/agent/adk/models/models_llm.txt +82 -35
  7. solace_agent_mesh/agent/adk/runner.py +9 -0
  8. solace_agent_mesh/agent/adk/stream_parser.py +6 -1
  9. solace_agent_mesh/agent/adk/tool_wrapper.py +3 -0
  10. solace_agent_mesh/agent/agent_llm.txt +61 -70
  11. solace_agent_mesh/agent/protocol/event_handlers.py +29 -1
  12. solace_agent_mesh/agent/protocol/protocol_llm.txt +1 -1
  13. solace_agent_mesh/agent/proxies/a2a/a2a_llm.txt +190 -0
  14. solace_agent_mesh/agent/proxies/base/base_llm.txt +148 -0
  15. solace_agent_mesh/agent/proxies/proxies_llm.txt +283 -0
  16. solace_agent_mesh/agent/sac/app.py +22 -0
  17. solace_agent_mesh/agent/sac/component.py +76 -40
  18. solace_agent_mesh/agent/sac/sac_llm.txt +1 -1
  19. solace_agent_mesh/agent/sac/task_execution_context.py +21 -0
  20. solace_agent_mesh/agent/testing/testing_llm.txt +2 -1
  21. solace_agent_mesh/agent/tools/builtin_artifact_tools.py +13 -148
  22. solace_agent_mesh/agent/tools/dynamic_tool.py +2 -0
  23. solace_agent_mesh/agent/tools/tools_llm.txt +93 -80
  24. solace_agent_mesh/agent/tools/tools_llm_detail.txt +3 -2
  25. solace_agent_mesh/agent/utils/artifact_helpers.py +4 -0
  26. solace_agent_mesh/agent/utils/utils_llm.txt +16 -2
  27. solace_agent_mesh/assets/docs/404.html +3 -3
  28. solace_agent_mesh/assets/docs/assets/js/05749d90.c70b2be9.js +1 -0
  29. solace_agent_mesh/assets/docs/assets/js/15ba94aa.92fea363.js +1 -0
  30. solace_agent_mesh/assets/docs/assets/js/15e40e79.36003774.js +1 -0
  31. solace_agent_mesh/assets/docs/assets/js/2987107d.a80604f9.js +1 -0
  32. solace_agent_mesh/assets/docs/assets/js/3ac1795d.e4870a49.js +1 -0
  33. solace_agent_mesh/assets/docs/assets/js/3ff0015d.b63ee53a.js +1 -0
  34. solace_agent_mesh/assets/docs/assets/js/547e15cc.2f7790c1.js +1 -0
  35. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.45b32c2b.js +1 -0
  36. solace_agent_mesh/assets/docs/assets/js/631738c7.fa471607.js +1 -0
  37. solace_agent_mesh/assets/docs/assets/js/64195356.c498c4d0.js +1 -0
  38. solace_agent_mesh/assets/docs/assets/js/6a520c9d.b6e3f2ce.js +1 -0
  39. solace_agent_mesh/assets/docs/assets/js/6ad8f0bd.a5b36a60.js +1 -0
  40. solace_agent_mesh/assets/docs/assets/js/71da7b71.374b9d54.js +1 -0
  41. solace_agent_mesh/assets/docs/assets/js/8024126c.fa0e7186.js +1 -0
  42. solace_agent_mesh/assets/docs/assets/js/8b032486.91a91afc.js +1 -0
  43. solace_agent_mesh/assets/docs/assets/js/94e8668d.09ed9234.js +1 -0
  44. solace_agent_mesh/assets/docs/assets/js/{ab9708a8.3e6dd091.js → ab9708a8.245ae0ef.js} +1 -1
  45. solace_agent_mesh/assets/docs/assets/js/ad87452a.9d73dad6.js +1 -0
  46. solace_agent_mesh/assets/docs/assets/js/cbe2e9ea.f902fad8.js +1 -0
  47. solace_agent_mesh/assets/docs/assets/js/da0b5bad.b62f7b08.js +1 -0
  48. solace_agent_mesh/assets/docs/assets/js/db5d6442.3daf1696.js +1 -0
  49. solace_agent_mesh/assets/docs/assets/js/dd817ffc.c37a755e.js +1 -0
  50. solace_agent_mesh/assets/docs/assets/js/dd81e2b8.b682e9c2.js +1 -0
  51. solace_agent_mesh/assets/docs/assets/js/de915948.44a432bc.js +1 -0
  52. solace_agent_mesh/assets/docs/assets/js/e04b235d.c9c50c7b.js +1 -0
  53. solace_agent_mesh/assets/docs/assets/js/e3d9abda.d11c67a7.js +1 -0
  54. solace_agent_mesh/assets/docs/assets/js/{e6f9706b.e74a984d.js → e6f9706b.045d0fa1.js} +1 -1
  55. solace_agent_mesh/assets/docs/assets/js/e92d0134.3bda61dd.js +1 -0
  56. solace_agent_mesh/assets/docs/assets/js/f284c35a.5099c51e.js +1 -0
  57. solace_agent_mesh/assets/docs/assets/js/ff4d71f2.74710fc1.js +1 -0
  58. solace_agent_mesh/assets/docs/assets/js/main.f213fe0c.js +2 -0
  59. solace_agent_mesh/assets/docs/assets/js/runtime~main.d9606d6a.js +1 -0
  60. solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +4 -4
  61. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/artifact-management/index.html +4 -4
  62. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/audio-tools/index.html +4 -4
  63. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/data-analysis-tools/index.html +4 -4
  64. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/embeds/index.html +18 -4
  65. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/index.html +4 -4
  66. solace_agent_mesh/assets/docs/docs/documentation/components/cli/index.html +4 -4
  67. solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +5 -5
  68. solace_agent_mesh/assets/docs/docs/documentation/components/index.html +4 -4
  69. solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +4 -4
  70. solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +4 -4
  71. solace_agent_mesh/assets/docs/docs/documentation/components/projects/index.html +196 -0
  72. solace_agent_mesh/assets/docs/docs/documentation/components/proxies/index.html +4 -4
  73. solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +5 -5
  74. solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +6 -7
  75. solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +4 -4
  76. solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes-deployment/index.html +47 -0
  77. solace_agent_mesh/assets/docs/docs/documentation/deploying/logging/index.html +4 -4
  78. solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +4 -4
  79. solace_agent_mesh/assets/docs/docs/documentation/developing/create-agents/index.html +4 -4
  80. solace_agent_mesh/assets/docs/docs/documentation/developing/create-gateways/index.html +160 -169
  81. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-python-tools/index.html +4 -4
  82. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +4 -4
  83. solace_agent_mesh/assets/docs/docs/documentation/developing/evaluations/index.html +4 -4
  84. solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +4 -4
  85. solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +4 -4
  86. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/bedrock-agents/index.html +4 -4
  87. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/custom-agent/index.html +5 -5
  88. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/event-mesh-gateway/index.html +4 -4
  89. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mcp-integration/index.html +4 -4
  90. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mongodb-integration/index.html +4 -4
  91. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rag-integration/index.html +4 -4
  92. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rest-gateway/index.html +4 -4
  93. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +4 -4
  94. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/sql-database/index.html +4 -4
  95. solace_agent_mesh/assets/docs/docs/documentation/enterprise/agent-builder/index.html +59 -0
  96. solace_agent_mesh/assets/docs/docs/documentation/enterprise/connectors/index.html +62 -0
  97. solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +10 -6
  98. solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +4 -4
  99. solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +4 -4
  100. solace_agent_mesh/assets/docs/docs/documentation/enterprise/secure-user-delegated-access/index.html +440 -0
  101. solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +27 -4
  102. solace_agent_mesh/assets/docs/docs/documentation/enterprise/wheel-installation/index.html +62 -0
  103. solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +4 -4
  104. solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +5 -4
  105. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
  106. solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +3 -3
  107. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/artifact-storage/index.html +290 -0
  108. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/configurations/index.html +9 -9
  109. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +4 -4
  110. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +4 -4
  111. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +4 -4
  112. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +4 -4
  113. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/session-storage/index.html +251 -0
  114. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/user-feedback/index.html +88 -0
  115. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +3 -3
  116. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-technical-migration-map/index.html +3 -3
  117. solace_agent_mesh/assets/docs/lunr-index-1762283454666.json +1 -0
  118. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  119. solace_agent_mesh/assets/docs/search-doc-1762283454666.json +1 -0
  120. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  121. solace_agent_mesh/assets/docs/sitemap.xml +1 -1
  122. solace_agent_mesh/cli/__init__.py +1 -1
  123. solace_agent_mesh/cli/commands/docs_cmd.py +4 -1
  124. solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +1 -1
  125. solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-D4_RMYRh.js → authCallback-tcIFZLis.js} +1 -1
  126. solace_agent_mesh/client/webui/frontend/static/assets/{client-UZ3qU6Bq.js → client-CRYdKo2Q.js} +3 -3
  127. solace_agent_mesh/client/webui/frontend/static/assets/main-CojeY_1w.css +1 -0
  128. solace_agent_mesh/client/webui/frontend/static/assets/main-ILja9MCG.js +353 -0
  129. solace_agent_mesh/client/webui/frontend/static/assets/vendor-CINwxvwV.js +470 -0
  130. solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
  131. solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
  132. solace_agent_mesh/common/a2a/a2a_llm.txt +13 -20
  133. solace_agent_mesh/common/a2a/protocol.py +5 -0
  134. solace_agent_mesh/common/a2a/types.py +1 -0
  135. solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +49 -11
  136. solace_agent_mesh/common/a2a_spec/schemas/artifact_creation_progress.json +23 -6
  137. solace_agent_mesh/common/a2a_spec/schemas/feedback_event.json +51 -0
  138. solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +26 -9
  139. solace_agent_mesh/common/common_llm.txt +13 -34
  140. solace_agent_mesh/common/data_parts.py +20 -4
  141. solace_agent_mesh/common/middleware/middleware_llm.txt +1 -1
  142. solace_agent_mesh/common/sac/sac_llm.txt +1 -1
  143. solace_agent_mesh/common/sam_events/sam_events_llm.txt +1 -1
  144. solace_agent_mesh/common/services/employee_service.py +1 -1
  145. solace_agent_mesh/common/services/providers/providers_llm.txt +3 -2
  146. solace_agent_mesh/common/services/services_llm.txt +9 -4
  147. solace_agent_mesh/common/utils/embeds/constants.py +1 -0
  148. solace_agent_mesh/common/utils/embeds/embeds_llm.txt +1 -1
  149. solace_agent_mesh/common/utils/embeds/modifiers.py +2 -1
  150. solace_agent_mesh/common/utils/embeds/resolver.py +58 -6
  151. solace_agent_mesh/common/utils/embeds/types.py +8 -0
  152. solace_agent_mesh/common/utils/utils_llm.txt +5 -6
  153. solace_agent_mesh/core_a2a/core_a2a_llm.txt +1 -1
  154. solace_agent_mesh/gateway/adapter/__init__.py +1 -0
  155. solace_agent_mesh/gateway/adapter/base.py +143 -0
  156. solace_agent_mesh/gateway/adapter/types.py +221 -0
  157. solace_agent_mesh/gateway/base/app.py +29 -2
  158. solace_agent_mesh/gateway/base/base_llm.txt +10 -8
  159. solace_agent_mesh/gateway/base/component.py +573 -142
  160. solace_agent_mesh/gateway/gateway_llm.txt +55 -59
  161. solace_agent_mesh/gateway/generic/__init__.py +1 -0
  162. solace_agent_mesh/gateway/generic/app.py +50 -0
  163. solace_agent_mesh/gateway/generic/component.py +650 -0
  164. solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +99 -49
  165. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_fulltext_search_indexes.py +92 -0
  166. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_project_users_table.py +72 -0
  167. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_soft_delete_and_search.py +150 -0
  168. solace_agent_mesh/gateway/http_sse/alembic/versions/20251024_add_default_agent_to_projects.py +26 -0
  169. solace_agent_mesh/gateway/http_sse/alembic/versions/20251024_add_projects_table.py +135 -0
  170. solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +26 -20
  171. solace_agent_mesh/gateway/http_sse/app.py +0 -14
  172. solace_agent_mesh/gateway/http_sse/component.py +17 -56
  173. solace_agent_mesh/gateway/http_sse/components/components_llm.txt +1 -1
  174. solace_agent_mesh/gateway/http_sse/dependencies.py +21 -3
  175. solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +8 -8
  176. solace_agent_mesh/gateway/http_sse/main.py +23 -5
  177. solace_agent_mesh/gateway/http_sse/repository/__init__.py +19 -1
  178. solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +56 -98
  179. solace_agent_mesh/gateway/http_sse/repository/entities/project.py +81 -0
  180. solace_agent_mesh/gateway/http_sse/repository/entities/project_user.py +47 -0
  181. solace_agent_mesh/gateway/http_sse/repository/entities/session.py +23 -1
  182. solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +47 -0
  183. solace_agent_mesh/gateway/http_sse/repository/interfaces.py +112 -4
  184. solace_agent_mesh/gateway/http_sse/repository/models/__init__.py +9 -1
  185. solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +51 -60
  186. solace_agent_mesh/gateway/http_sse/repository/models/project_model.py +51 -0
  187. solace_agent_mesh/gateway/http_sse/repository/models/project_user_model.py +75 -0
  188. solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +7 -1
  189. solace_agent_mesh/gateway/http_sse/repository/project_repository.py +172 -0
  190. solace_agent_mesh/gateway/http_sse/repository/project_user_repository.py +186 -0
  191. solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +125 -157
  192. solace_agent_mesh/gateway/http_sse/repository/session_repository.py +269 -8
  193. solace_agent_mesh/gateway/http_sse/routers/artifacts.py +143 -51
  194. solace_agent_mesh/gateway/http_sse/routers/config.py +69 -0
  195. solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +198 -94
  196. solace_agent_mesh/gateway/http_sse/routers/dto/requests/project_requests.py +48 -0
  197. solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +68 -18
  198. solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +13 -0
  199. solace_agent_mesh/gateway/http_sse/routers/dto/responses/project_responses.py +30 -0
  200. solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +51 -35
  201. solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +2 -0
  202. solace_agent_mesh/gateway/http_sse/routers/feedback.py +133 -2
  203. solace_agent_mesh/gateway/http_sse/routers/projects.py +542 -0
  204. solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +9 -11
  205. solace_agent_mesh/gateway/http_sse/routers/sessions.py +154 -3
  206. solace_agent_mesh/gateway/http_sse/routers/tasks.py +296 -4
  207. solace_agent_mesh/gateway/http_sse/services/project_service.py +403 -0
  208. solace_agent_mesh/gateway/http_sse/services/services_llm.txt +16 -10
  209. solace_agent_mesh/gateway/http_sse/services/session_service.py +178 -6
  210. solace_agent_mesh/gateway/http_sse/shared/exception_handlers.py +2 -3
  211. solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +48 -14
  212. solace_agent_mesh/solace_agent_mesh_llm.txt +1 -1
  213. {solace_agent_mesh-1.6.3.dist-info → solace_agent_mesh-1.7.1.dist-info}/METADATA +3 -5
  214. {solace_agent_mesh-1.6.3.dist-info → solace_agent_mesh-1.7.1.dist-info}/RECORD +218 -175
  215. solace_agent_mesh/assets/docs/assets/js/15ba94aa.932dd2db.js +0 -1
  216. solace_agent_mesh/assets/docs/assets/js/3ac1795d.76654dd9.js +0 -1
  217. solace_agent_mesh/assets/docs/assets/js/3ff0015d.2be20244.js +0 -1
  218. solace_agent_mesh/assets/docs/assets/js/547e15cc.2cbb060a.js +0 -1
  219. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.eda4bcb2.js +0 -1
  220. solace_agent_mesh/assets/docs/assets/js/631738c7.7c4594c9.js +0 -1
  221. solace_agent_mesh/assets/docs/assets/js/6a520c9d.ba015d81.js +0 -1
  222. solace_agent_mesh/assets/docs/assets/js/6ad8f0bd.f4b15f3b.js +0 -1
  223. solace_agent_mesh/assets/docs/assets/js/71da7b71.ddbdfbe2.js +0 -1
  224. solace_agent_mesh/assets/docs/assets/js/8024126c.56e59919.js +0 -1
  225. solace_agent_mesh/assets/docs/assets/js/94e8668d.3b883666.js +0 -1
  226. solace_agent_mesh/assets/docs/assets/js/da0b5bad.d08a9466.js +0 -1
  227. solace_agent_mesh/assets/docs/assets/js/dd817ffc.0aa9630a.js +0 -1
  228. solace_agent_mesh/assets/docs/assets/js/dd81e2b8.d590bc9e.js +0 -1
  229. solace_agent_mesh/assets/docs/assets/js/de915948.27d6b065.js +0 -1
  230. solace_agent_mesh/assets/docs/assets/js/e3d9abda.6b9493d0.js +0 -1
  231. solace_agent_mesh/assets/docs/assets/js/e92d0134.4f395c6b.js +0 -1
  232. solace_agent_mesh/assets/docs/assets/js/f284c35a.720d2ef2.js +0 -1
  233. solace_agent_mesh/assets/docs/assets/js/ff4d71f2.15b02f97.js +0 -1
  234. solace_agent_mesh/assets/docs/assets/js/main.ed05b14d.js +0 -2
  235. solace_agent_mesh/assets/docs/assets/js/runtime~main.a8a75e0b.js +0 -1
  236. solace_agent_mesh/assets/docs/lunr-index-1761744323675.json +0 -1
  237. solace_agent_mesh/assets/docs/search-doc-1761744323675.json +0 -1
  238. solace_agent_mesh/client/webui/frontend/static/assets/main--3yJYl7S.css +0 -1
  239. solace_agent_mesh/client/webui/frontend/static/assets/main-DojKHS49.js +0 -342
  240. solace_agent_mesh/client/webui/frontend/static/assets/vendor-DSqhjwq_.js +0 -405
  241. /solace_agent_mesh/assets/docs/assets/js/{main.ed05b14d.js.LICENSE.txt → main.f213fe0c.js.LICENSE.txt} +0 -0
  242. {solace_agent_mesh-1.6.3.dist-info → solace_agent_mesh-1.7.1.dist-info}/WHEEL +0 -0
  243. {solace_agent_mesh-1.6.3.dist-info → solace_agent_mesh-1.7.1.dist-info}/entry_points.txt +0 -0
  244. {solace_agent_mesh-1.6.3.dist-info → solace_agent_mesh-1.7.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,353 @@
1
+ var jx=Object.defineProperty;var kx=(e,t,n)=>t in e?jx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fc=(e,t,n)=>kx(e,typeof t!="symbol"?t+"":t,n);import{c as Ax}from"./client-CRYdKo2Q.js";import{r as d,j as s,c as Au,a as ls,R as Sl,b as Tx,N as Ks,L as Ca,X as Er,E as _x,F as Di,d as Ix,e as Li,f as or,g as Tu,h as Oi,i as Fi,k as jt,C as na,l as El,m as $i,A as _u,n as cs,P as Iu,B as Mx,S as Rx,o as Px,p as Dx,q as Lx,s as Mu,I as Sa,T as Ox,t as Ru,u as Pu,v as $c,w as zc,x as Uc,y as Bc,z as Fx,D as xo,G as Ea,H as Nl,J as Hc,K as Wc,M as $x,O as Du,Q as Vc,W as zx,U as Ux,V as Bx,Y as Hx,Z as Wx,_ as Lu,$ as Vx,a0 as ds,a1 as Gx,a2 as Ou,a3 as ra,a4 as jl,a5 as Yx,a6 as Gc,a7 as Kx,a8 as qx,a9 as Fu,aa as Xx,ab as kt,ac as At,ad as Zx,ae as Jx,af as Yc,ag as Kc,ah as ni,ai as Qx,aj as ev,ak as tv,al as nv,am as rv,an as ov,ao as sv,ap as av,aq as iv,ar as lv,as as cv,at as $u,au as kl,av as dv,aw as uv,ax as Al,ay as oa,az as fv,aA as ri}from"./vendor-CINwxvwV.js";/**
2
+ * react-router v7.9.5
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */var qc="popstate";function pv(e={}){function t(r,o){let{pathname:a,search:i,hash:l}=r.location;return zi("",{pathname:a,search:i,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(r,o){return typeof o=="string"?o:Ko(o)}return hv(t,n,null,e)}function vt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Bn(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function mv(){return Math.random().toString(36).substring(2,10)}function Xc(e,t){return{usr:e.state,key:e.key,idx:t}}function zi(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?us(t):t,state:n,key:t&&t.key||r||mv()}}function Ko({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function us(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function hv(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:a=!1}=r,i=o.history,l="POP",c=null,u=p();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function p(){return(i.state||{idx:null}).idx}function f(){l="POP";let w=p(),v=w==null?null:w-u;u=w,c&&c({action:l,location:g.location,delta:v})}function m(w,v){l="PUSH";let b=zi(g.location,w,v);u=p()+1;let y=Xc(b,u),E=g.createHref(b);try{i.pushState(y,"",E)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;o.location.assign(E)}a&&c&&c({action:l,location:g.location,delta:1})}function h(w,v){l="REPLACE";let b=zi(g.location,w,v);u=p();let y=Xc(b,u),E=g.createHref(b);i.replaceState(y,"",E),a&&c&&c({action:l,location:g.location,delta:0})}function x(w){return gv(w)}let g={get action(){return l},get location(){return e(o,i)},listen(w){if(c)throw new Error("A history only accepts one active listener");return o.addEventListener(qc,f),c=w,()=>{o.removeEventListener(qc,f),c=null}},createHref(w){return t(o,w)},createURL:x,encodeLocation(w){let v=x(w);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:h,go(w){return i.go(w)}};return g}function gv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),vt(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Ko(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function zu(e,t,n="/"){return xv(e,t,n,!1)}function xv(e,t,n,r){let o=typeof t=="string"?us(t):t,a=ir(o.pathname||"/",n);if(a==null)return null;let i=Uu(e);vv(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=Tv(a);l=kv(i[c],u,r)}return l}function Uu(e,t=[],n=[],r="",o=!1){let a=(i,l,c=o,u)=>{let p={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&c)return;vt(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let f=sr([r,p.relativePath]),m=n.concat(p);i.children&&i.children.length>0&&(vt(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Uu(i.children,t,m,f,c)),!(i.path==null&&!i.index)&&t.push({path:f,score:Nv(f,i.index),routesMeta:m})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))a(i,l);else for(let u of Bu(i.path))a(i,l,!0,u)}),t}function Bu(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,o=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return o?[a,""]:[a];let i=Bu(r.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),o&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function vv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:jv(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var wv=/^:[\w-]+$/,bv=3,yv=2,Cv=1,Sv=10,Ev=-2,Zc=e=>e==="*";function Nv(e,t){let n=e.split("/"),r=n.length;return n.some(Zc)&&(r+=Ev),t&&(r+=yv),n.filter(o=>!Zc(o)).reduce((o,a)=>o+(wv.test(a)?bv:a===""?Cv:Sv),r)}function jv(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function kv(e,t,n=!1){let{routesMeta:r}=e,o={},a="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,p=a==="/"?t:t.slice(a.length)||"/",f=sa({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},p),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=sa({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},p)),!f)return null;Object.assign(o,f.params),i.push({params:o,pathname:sr([a,f.pathname]),pathnameBase:Rv(sr([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=sr([a,f.pathnameBase]))}return i}function sa(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Av(e.path,e.caseSensitive,e.end),o=t.match(n);if(!o)return null;let a=o[0],i=a.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:r.reduce((u,{paramName:p,isOptional:f},m)=>{if(p==="*"){let x=l[m]||"";i=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const h=l[m];return f&&!h?u[p]=void 0:u[p]=(h||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function Av(e,t=!1,n=!0){Bn(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function Tv(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Bn(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ir(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function _v(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?us(e):e;return{pathname:n?n.startsWith("/")?n:Iv(n,t):t,search:Pv(r),hash:Dv(o)}}function Iv(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function oi(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Mv(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Hu(e){let t=Mv(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Wu(e,t,n,r=!1){let o;typeof e=="string"?o=us(e):(o={...e},vt(!o.pathname||!o.pathname.includes("?"),oi("?","pathname","search",o)),vt(!o.pathname||!o.pathname.includes("#"),oi("#","pathname","hash",o)),vt(!o.search||!o.search.includes("#"),oi("#","search","hash",o)));let a=e===""||o.pathname==="",i=a?"/":o.pathname,l;if(i==null)l=n;else{let f=t.length-1;if(!r&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),f-=1;o.pathname=m.join("/")}l=f>=0?t[f]:"/"}let c=_v(o,l),u=i&&i!=="/"&&i.endsWith("/"),p=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}var sr=e=>e.join("/").replace(/\/\/+/g,"/"),Rv=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Pv=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Dv=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Lv(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Vu=["POST","PUT","PATCH","DELETE"];new Set(Vu);var Ov=["GET",...Vu];new Set(Ov);var vo=d.createContext(null);vo.displayName="DataRouter";var Na=d.createContext(null);Na.displayName="DataRouterState";d.createContext(!1);var Gu=d.createContext({isTransitioning:!1});Gu.displayName="ViewTransition";var Fv=d.createContext(new Map);Fv.displayName="Fetchers";var $v=d.createContext(null);$v.displayName="Await";var Vn=d.createContext(null);Vn.displayName="Navigation";var ja=d.createContext(null);ja.displayName="Location";var ur=d.createContext({outlet:null,matches:[],isDataRoute:!1});ur.displayName="Route";var Tl=d.createContext(null);Tl.displayName="RouteError";function zv(e,{relative:t}={}){vt(fs(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(Vn),{hash:o,pathname:a,search:i}=ps(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:sr([n,a])),r.createHref({pathname:l,search:i,hash:o})}function fs(){return d.useContext(ja)!=null}function Br(){return vt(fs(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(ja).location}var Yu="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ku(e){d.useContext(Vn).static||d.useLayoutEffect(e)}function Uv(){let{isDataRoute:e}=d.useContext(ur);return e?e0():Bv()}function Bv(){vt(fs(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(vo),{basename:t,navigator:n}=d.useContext(Vn),{matches:r}=d.useContext(ur),{pathname:o}=Br(),a=JSON.stringify(Hu(r)),i=d.useRef(!1);return Ku(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(Bn(i.current,Yu),!i.current)return;if(typeof c=="number"){n.go(c);return}let p=Wu(c,JSON.parse(a),o,u.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:sr([t,p.pathname])),(u.replace?n.replace:n.push)(p,u.state,u)},[t,n,a,o,e])}d.createContext(null);function ps(e,{relative:t}={}){let{matches:n}=d.useContext(ur),{pathname:r}=Br(),o=JSON.stringify(Hu(n));return d.useMemo(()=>Wu(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function Hv(e,t,n,r,o){vt(fs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=d.useContext(Vn),{matches:i}=d.useContext(ur),l=i[i.length-1],c=l?l.params:{},u=l?l.pathname:"/",p=l?l.pathnameBase:"/",f=l&&l.route;{let b=f&&f.path||"";qu(u,!f||b.endsWith("*")||b.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${b}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
11
+
12
+ Please change the parent <Route path="${b}"> to <Route path="${b==="/"?"*":`${b}/*`}">.`)}let m=Br(),h;h=m;let x=h.pathname||"/",g=x;if(p!=="/"){let b=p.replace(/^\//,"").split("/");g="/"+x.replace(/^\//,"").split("/").slice(b.length).join("/")}let w=zu(e,{pathname:g});return Bn(f||w!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),Bn(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),Kv(w&&w.map(b=>Object.assign({},b,{params:Object.assign({},c,b.params),pathname:sr([p,a.encodeLocation?a.encodeLocation(b.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?p:sr([p,a.encodeLocation?a.encodeLocation(b.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:b.pathnameBase])})),i,n,r,o)}function Wv(){let e=Qv(),t=Lv(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:a},"ErrorBoundary")," or"," ",d.createElement("code",{style:a},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:o},n):null,i)}var Vv=d.createElement(Wv,null),Gv=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?d.createElement(ur.Provider,{value:this.props.routeContext},d.createElement(Tl.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Yv({routeContext:e,match:t,children:n}){let r=d.useContext(vo);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(ur.Provider,{value:e},n)}function Kv(e,t=[],n=null,r=null,o=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,i=n==null?void 0:n.errors;if(i!=null){let u=a.findIndex(p=>p.route.id&&(i==null?void 0:i[p.route.id])!==void 0);vt(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let l=!1,c=-1;if(n)for(let u=0;u<a.length;u++){let p=a[u];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(c=u),p.route.id){let{loaderData:f,errors:m}=n,h=p.route.loader&&!f.hasOwnProperty(p.route.id)&&(!m||m[p.route.id]===void 0);if(p.route.lazy||h){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}return a.reduceRight((u,p,f)=>{let m,h=!1,x=null,g=null;n&&(m=i&&p.route.id?i[p.route.id]:void 0,x=p.route.errorElement||Vv,l&&(c<0&&f===0?(qu("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),h=!0,g=null):c===f&&(h=!0,g=p.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,f+1)),v=()=>{let b;return m?b=x:h?b=g:p.route.Component?b=d.createElement(p.route.Component,null):p.route.element?b=p.route.element:b=u,d.createElement(Yv,{match:p,routeContext:{outlet:u,matches:w,isDataRoute:n!=null},children:b})};return n&&(p.route.ErrorBoundary||p.route.errorElement||f===0)?d.createElement(Gv,{location:n.location,revalidation:n.revalidation,component:x,error:m,children:v(),routeContext:{outlet:null,matches:w,isDataRoute:!0},unstable_onError:r}):v()},null)}function _l(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function qv(e){let t=d.useContext(vo);return vt(t,_l(e)),t}function Xv(e){let t=d.useContext(Na);return vt(t,_l(e)),t}function Zv(e){let t=d.useContext(ur);return vt(t,_l(e)),t}function Il(e){let t=Zv(e),n=t.matches[t.matches.length-1];return vt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Jv(){return Il("useRouteId")}function Qv(){var r;let e=d.useContext(Tl),t=Xv("useRouteError"),n=Il("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function e0(){let{router:e}=qv("useNavigate"),t=Il("useNavigate"),n=d.useRef(!1);return Ku(()=>{n.current=!0}),d.useCallback(async(o,a={})=>{Bn(n.current,Yu),n.current&&(typeof o=="number"?e.navigate(o):await e.navigate(o,{fromRouteId:t,...a}))},[e,t])}var Jc={};function qu(e,t,n){!t&&!Jc[e]&&(Jc[e]=!0,Bn(!1,n))}d.memo(t0);function t0({routes:e,future:t,state:n,unstable_onError:r}){return Hv(e,void 0,n,r,t)}function n0({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:a=!1}){vt(!fs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),l=d.useMemo(()=>({basename:i,navigator:o,static:a,future:{}}),[i,o,a]);typeof n=="string"&&(n=us(n));let{pathname:c="/",search:u="",hash:p="",state:f=null,key:m="default"}=n,h=d.useMemo(()=>{let x=ir(c,i);return x==null?null:{location:{pathname:x,search:u,hash:p,state:f,key:m},navigationType:r}},[i,c,u,p,f,m,r]);return Bn(h!=null,`<Router basename="${i}"> is not able to match the URL "${c}${u}${p}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:d.createElement(Vn.Provider,{value:l},d.createElement(ja.Provider,{children:t,value:h}))}var qs="get",Xs="application/x-www-form-urlencoded";function ka(e){return e!=null&&typeof e.tagName=="string"}function r0(e){return ka(e)&&e.tagName.toLowerCase()==="button"}function o0(e){return ka(e)&&e.tagName.toLowerCase()==="form"}function s0(e){return ka(e)&&e.tagName.toLowerCase()==="input"}function a0(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i0(e,t){return e.button===0&&(!t||t==="_self")&&!a0(e)}var Ts=null;function l0(){if(Ts===null)try{new FormData(document.createElement("form"),0),Ts=!1}catch{Ts=!0}return Ts}var c0=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function si(e){return e!=null&&!c0.has(e)?(Bn(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Xs}"`),null):e}function d0(e,t){let n,r,o,a,i;if(o0(e)){let l=e.getAttribute("action");r=l?ir(l,t):null,n=e.getAttribute("method")||qs,o=si(e.getAttribute("enctype"))||Xs,a=new FormData(e)}else if(r0(e)||s0(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?ir(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||qs,o=si(e.getAttribute("formenctype"))||si(l.getAttribute("enctype"))||Xs,a=new FormData(l,e),!l0()){let{name:u,type:p,value:f}=e;if(p==="image"){let m=u?`${u}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else u&&a.append(u,f)}}else{if(ka(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=qs,r=null,o=Xs,i=e}return a&&o==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ml(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function u0(e,t,n){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname=`_root.${n}`:t&&ir(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function f0(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function p0(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function m0(e,t,n){let r=await Promise.all(e.map(async o=>{let a=t.routes[o.route.id];if(a){let i=await f0(a,n);return i.links?i.links():[]}return[]}));return v0(r.flat(1).filter(p0).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function Qc(e,t,n,r,o,a){let i=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var p;return n[u].pathname!==c.pathname||((p=n[u].route.path)==null?void 0:p.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return a==="assets"?t.filter((c,u)=>i(c,u)||l(c,u)):a==="data"?t.filter((c,u)=>{var f;let p=r.routes[c.route.id];if(!p||!p.hasLoader)return!1;if(i(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let m=c.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:((f=n[0])==null?void 0:f.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function h0(e,t,{includeHydrateFallback:n}={}){return g0(e.map(r=>{let o=t.routes[r.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function g0(e){return[...new Set(e)]}function x0(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function v0(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let a=JSON.stringify(x0(o));return n.has(a)||(n.add(a),r.push({key:a,link:o})),r},[])}function Xu(){let e=d.useContext(vo);return Ml(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function w0(){let e=d.useContext(Na);return Ml(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Rl=d.createContext(void 0);Rl.displayName="FrameworkContext";function Zu(){let e=d.useContext(Rl);return Ml(e,"You must render this element inside a <HydratedRouter> element"),e}function b0(e,t){let n=d.useContext(Rl),[r,o]=d.useState(!1),[a,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:p,onTouchStart:f}=t,m=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=v=>{v.forEach(b=>{i(b.isIntersecting)})},w=new IntersectionObserver(g,{threshold:.5});return m.current&&w.observe(m.current),()=>{w.disconnect()}}},[e]),d.useEffect(()=>{if(r){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[r]);let h=()=>{o(!0)},x=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,m,{}]:[a,m,{onFocus:Io(l,h),onBlur:Io(c,x),onMouseEnter:Io(u,h),onMouseLeave:Io(p,x),onTouchStart:Io(f,h)}]:[!1,m,{}]}function Io(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function y0({page:e,...t}){let{router:n}=Xu(),r=d.useMemo(()=>zu(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(S0,{page:e,matches:r,...t}):null}function C0(e){let{manifest:t,routeModules:n}=Zu(),[r,o]=d.useState([]);return d.useEffect(()=>{let a=!1;return m0(e,t,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,t,n]),r}function S0({page:e,matches:t,...n}){let r=Br(),{manifest:o,routeModules:a}=Zu(),{basename:i}=Xu(),{loaderData:l,matches:c}=w0(),u=d.useMemo(()=>Qc(e,t,c,o,r,"data"),[e,t,c,o,r]),p=d.useMemo(()=>Qc(e,t,c,o,r,"assets"),[e,t,c,o,r]),f=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,g=!1;if(t.forEach(v=>{var y;let b=o.routes[v.route.id];!b||!b.hasLoader||(!u.some(E=>E.route.id===v.route.id)&&v.route.id in l&&((y=a[v.route.id])!=null&&y.shouldRevalidate)||b.hasClientLoader?g=!0:x.add(v.route.id))}),x.size===0)return[];let w=u0(e,i,"data");return g&&x.size>0&&w.searchParams.set("_routes",t.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[w.pathname+w.search]},[i,l,r,o,u,t,e,a]),m=d.useMemo(()=>h0(p,o),[p,o]),h=C0(p);return d.createElement(d.Fragment,null,f.map(x=>d.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),m.map(x=>d.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),h.map(({key:x,link:g})=>d.createElement("link",{key:x,nonce:n.nonce,...g})))}function E0(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Ju=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ju&&(window.__reactRouterVersion="7.9.5")}catch{}function N0({basename:e,children:t,window:n}){let r=d.useRef();r.current==null&&(r.current=pv({window:n,v5Compat:!0}));let o=r.current,[a,i]=d.useState({action:o.action,location:o.location}),l=d.useCallback(c=>{d.startTransition(()=>i(c))},[i]);return d.useLayoutEffect(()=>o.listen(l),[o,l]),d.createElement(n0,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:o})}var Qu=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ef=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:o,reloadDocument:a,replace:i,state:l,target:c,to:u,preventScrollReset:p,viewTransition:f,...m},h){let{basename:x}=d.useContext(Vn),g=typeof u=="string"&&Qu.test(u),w,v=!1;if(typeof u=="string"&&g&&(w=u,Ju))try{let k=new URL(window.location.href),M=u.startsWith("//")?new URL(k.protocol+u):new URL(u),L=ir(M.pathname,x);M.origin===k.origin&&L!=null?u=L+M.search+M.hash:v=!0}catch{Bn(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let b=zv(u,{relative:o}),[y,E,T]=b0(r,m),C=T0(u,{replace:i,state:l,target:c,preventScrollReset:p,relative:o,viewTransition:f});function S(k){t&&t(k),k.defaultPrevented||C(k)}let N=d.createElement("a",{...m,...T,href:w||b,onClick:v||a?t:S,ref:E0(h,E),target:c,"data-discover":!g&&n==="render"?"true":void 0});return y&&!g?d.createElement(d.Fragment,null,N,d.createElement(y0,{page:b})):N});ef.displayName="Link";var j0=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:o=!1,style:a,to:i,viewTransition:l,children:c,...u},p){let f=ps(i,{relative:u.relative}),m=Br(),h=d.useContext(Na),{navigator:x,basename:g}=d.useContext(Vn),w=h!=null&&P0(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,b=m.pathname,y=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;n||(b=b.toLowerCase(),y=y?y.toLowerCase():null,v=v.toLowerCase()),y&&g&&(y=ir(y,g)||y);const E=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let T=b===v||!o&&b.startsWith(v)&&b.charAt(E)==="/",C=y!=null&&(y===v||!o&&y.startsWith(v)&&y.charAt(v.length)==="/"),S={isActive:T,isPending:C,isTransitioning:w},N=T?t:void 0,k;typeof r=="function"?k=r(S):k=[r,T?"active":null,C?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let M=typeof a=="function"?a(S):a;return d.createElement(ef,{...u,"aria-current":N,className:k,ref:p,style:M,to:i,viewTransition:l},typeof c=="function"?c(S):c)});j0.displayName="NavLink";var k0=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:a,method:i=qs,action:l,onSubmit:c,relative:u,preventScrollReset:p,viewTransition:f,...m},h)=>{let x=M0(),g=R0(l,{relative:u}),w=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&Qu.test(l),b=y=>{if(c&&c(y),y.defaultPrevented)return;y.preventDefault();let E=y.nativeEvent.submitter,T=(E==null?void 0:E.getAttribute("formmethod"))||i;x(E||y.currentTarget,{fetcherKey:t,method:T,navigate:n,replace:o,state:a,relative:u,preventScrollReset:p,viewTransition:f})};return d.createElement("form",{ref:h,method:w,action:g,onSubmit:r?c:b,...m,"data-discover":!v&&e==="render"?"true":void 0})});k0.displayName="Form";function A0(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function tf(e){let t=d.useContext(vo);return vt(t,A0(e)),t}function T0(e,{target:t,replace:n,state:r,preventScrollReset:o,relative:a,viewTransition:i}={}){let l=Uv(),c=Br(),u=ps(e,{relative:a});return d.useCallback(p=>{if(i0(p,t)){p.preventDefault();let f=n!==void 0?n:Ko(c)===Ko(u);l(e,{replace:f,state:r,preventScrollReset:o,relative:a,viewTransition:i})}},[c,l,u,n,r,t,e,o,a,i])}var _0=0,I0=()=>`__${String(++_0)}__`;function M0(){let{router:e}=tf("useSubmit"),{basename:t}=d.useContext(Vn),n=Jv();return d.useCallback(async(r,o={})=>{let{action:a,method:i,encType:l,formData:c,body:u}=d0(r,t);if(o.navigate===!1){let p=o.fetcherKey||I0();await e.fetch(p,n,o.action||a,{preventScrollReset:o.preventScrollReset,formData:c,body:u,formMethod:o.method||i,formEncType:o.encType||l,flushSync:o.flushSync})}else await e.navigate(o.action||a,{preventScrollReset:o.preventScrollReset,formData:c,body:u,formMethod:o.method||i,formEncType:o.encType||l,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[e,t,n])}function R0(e,{relative:t}={}){let{basename:n}=d.useContext(Vn),r=d.useContext(ur);vt(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),a={...ps(e||".",{relative:t})},i=Br();if(e==null){a.search=i.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(p=>p==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let p=l.toString();a.search=p?`?${p}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:sr([n,a.pathname])),Ko(a)}function P0(e,{relative:t}={}){let n=d.useContext(Gu);vt(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=tf("useViewTransitionState"),o=ps(e,{relative:t});if(!n.isTransitioning)return!1;let a=ir(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=ir(n.nextLocation.pathname,r)||n.nextLocation.pathname;return sa(o.pathname,i)!=null||sa(o.pathname,a)!=null}function ed(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Aa(...e){return t=>{let n=!1;const r=e.map(o=>{const a=ed(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():ed(e[o],null)}}}}function Le(...e){return d.useCallback(Aa(...e),e)}function vr(e){const t=D0(e),n=d.forwardRef((r,o)=>{const{children:a,...i}=r,l=d.Children.toArray(a),c=l.find(O0);if(c){const u=c.props.children,p=l.map(f=>f===c?d.Children.count(u)>1?d.Children.only(null):d.isValidElement(u)?u.props.children:null:f);return s.jsx(t,{...i,ref:o,children:d.isValidElement(u)?d.cloneElement(u,void 0,p):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var nf=vr("Slot");function D0(e){const t=d.forwardRef((n,r)=>{const{children:o,...a}=n;if(d.isValidElement(o)){const i=$0(o),l=F0(a,o.props);return o.type!==d.Fragment&&(l.ref=r?Aa(r,i):i),d.cloneElement(o,l)}return d.Children.count(o)>1?d.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rf=Symbol("radix.slottable");function L0(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=rf,t}function O0(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rf}function F0(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...l)=>{const c=a(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function $0(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const td=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,nd=Au,Nr=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return nd(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(u=>{const p=n==null?void 0:n[u],f=a==null?void 0:a[u];if(p===null)return null;const m=td(p)||td(f);return o[u][m]}),l=n&&Object.entries(n).reduce((u,p)=>{let[f,m]=p;return m===void 0||(u[f]=m),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,p)=>{let{class:f,className:m,...h}=p;return Object.entries(h).every(x=>{let[g,w]=x;return Array.isArray(w)?w.includes({...a,...l}[g]):{...a,...l}[g]===w})?[...u,f,m]:u},[]);return nd(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},Pl=()=>localStorage.getItem("access_token"),z0=()=>localStorage.getItem("refresh_token"),U0=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},B0=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},H0=async()=>{const e=z0();if(!e)return null;const t=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})});if(t.ok){const n=await t.json();return U0(n.access_token,n.refresh_token),n.access_token}return B0(),window.location.href="/api/v1/auth/login",null},Ne=async(e,t={})=>{const n=Pl();if(!n)return fetch(e,t);const r=await fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${n}`}});if(r.status===401){const o=await H0();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},W0=async e=>{const t=await Ne("/api/v1/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.json().catch(()=>({detail:"Failed to submit feedback"}));throw new Error(n.detail||"Failed to submit feedback")}return t.json()},Dl="-",V0=e=>{const t=Y0(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(Dl);return l[0]===""&&l.length!==1&&l.shift(),of(l,t)||G0(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},of=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?of(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(Dl);return(i=t.validators.find(({validator:l})=>l(a)))==null?void 0:i.classGroupId},rd=/^\[(.+)\]$/,G0=e=>{if(rd.test(e)){const t=rd.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Y0=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)Ui(n[o],r,o,t);return r},Ui=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:od(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(K0(o)){Ui(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Ui(i,od(t,a),n,r)})})},od=(e,t)=>{let n=e;return t.split(Dl).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},K0=e=>e.isThemeGetter,q0=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(a,i)=>{n.set(a,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let i=n.get(a);if(i!==void 0)return i;if((i=r.get(a))!==void 0)return o(a,i),i},set(a,i){n.has(a)?n.set(a,i):o(a,i)}}},Bi="!",Hi=":",X0=Hi.length,Z0=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const a=[];let i=0,l=0,c=0,u;for(let x=0;x<o.length;x++){let g=o[x];if(i===0&&l===0){if(g===Hi){a.push(o.slice(c,x)),c=x+X0;continue}if(g==="/"){u=x;continue}}g==="["?i++:g==="]"?i--:g==="("?l++:g===")"&&l--}const p=a.length===0?o:o.substring(c),f=J0(p),m=f!==p,h=u&&u>c?u-c:void 0;return{modifiers:a,hasImportantModifier:m,baseClassName:f,maybePostfixModifierPosition:h}};if(t){const o=t+Hi,a=r;r=i=>i.startsWith(o)?a(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=r;r=a=>n({className:a,parseClassName:o})}return r},J0=e=>e.endsWith(Bi)?e.substring(0,e.length-1):e.startsWith(Bi)?e.substring(1):e,Q0=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const o=[];let a=[];return r.forEach(i=>{i[0]==="["||t[i]?(o.push(...a.sort(),i),a=[]):a.push(i)}),o.push(...a.sort()),o}},ew=e=>({cache:q0(e.cacheSize),parseClassName:Z0(e),sortModifiers:Q0(e),...V0(e)}),tw=/\s+/,nw=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],l=e.trim().split(tw);let c="";for(let u=l.length-1;u>=0;u-=1){const p=l[u],{isExternal:f,modifiers:m,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:g}=n(p);if(f){c=p+(c.length>0?" "+c:c);continue}let w=!!g,v=r(w?x.substring(0,g):x);if(!v){if(!w){c=p+(c.length>0?" "+c:c);continue}if(v=r(x),!v){c=p+(c.length>0?" "+c:c);continue}w=!1}const b=a(m).join(":"),y=h?b+Bi:b,E=y+v;if(i.includes(E))continue;i.push(E);const T=o(v,w);for(let C=0;C<T.length;++C){const S=T[C];i.push(y+S)}c=p+(c.length>0?" "+c:c)}return c};function rw(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=sf(t))&&(r&&(r+=" "),r+=n);return r}const sf=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=sf(e[r]))&&(n&&(n+=" "),n+=t);return n};function ow(e,...t){let n,r,o,a=i;function i(c){const u=t.reduce((p,f)=>f(p),e());return n=ew(u),r=n.cache.get,o=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const p=nw(c,n);return o(c,p),p}return function(){return a(rw.apply(null,arguments))}}const gt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},af=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,lf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,sw=/^\d+\/\d+$/,aw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,iw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,lw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,cw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,dw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Kr=e=>sw.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),pr=e=>!!e&&Number.isInteger(Number(e)),ai=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),tr=e=>aw.test(e),uw=()=>!0,fw=e=>iw.test(e)&&!lw.test(e),cf=()=>!1,pw=e=>cw.test(e),mw=e=>dw.test(e),hw=e=>!le(e)&&!ce(e),gw=e=>wo(e,ff,cf),le=e=>af.test(e),_r=e=>wo(e,pf,fw),ii=e=>wo(e,yw,Ie),sd=e=>wo(e,df,cf),xw=e=>wo(e,uf,mw),_s=e=>wo(e,mf,pw),ce=e=>lf.test(e),Mo=e=>bo(e,pf),vw=e=>bo(e,Cw),ad=e=>bo(e,df),ww=e=>bo(e,ff),bw=e=>bo(e,uf),Is=e=>bo(e,mf,!0),wo=(e,t,n)=>{const r=af.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},bo=(e,t,n=!1)=>{const r=lf.exec(e);return r?r[1]?t(r[1]):n:!1},df=e=>e==="position"||e==="percentage",uf=e=>e==="image"||e==="url",ff=e=>e==="length"||e==="size"||e==="bg-size",pf=e=>e==="length",yw=e=>e==="number",Cw=e=>e==="family-name",mf=e=>e==="shadow",Sw=()=>{const e=gt("color"),t=gt("font"),n=gt("text"),r=gt("font-weight"),o=gt("tracking"),a=gt("leading"),i=gt("breakpoint"),l=gt("container"),c=gt("spacing"),u=gt("radius"),p=gt("shadow"),f=gt("inset-shadow"),m=gt("text-shadow"),h=gt("drop-shadow"),x=gt("blur"),g=gt("perspective"),w=gt("aspect"),v=gt("ease"),b=gt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...E(),ce,le],C=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],N=()=>[ce,le,c],k=()=>[Kr,"full","auto",...N()],M=()=>[pr,"none","subgrid",ce,le],L=()=>["auto",{span:["full",pr,ce,le]},pr,ce,le],O=()=>[pr,"auto",ce,le],V=()=>["auto","min","max","fr",ce,le],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],G=()=>["start","end","center","stretch","center-safe","end-safe"],R=()=>["auto",...N()],q=()=>[Kr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],j=()=>[e,ce,le],I=()=>[...E(),ad,sd,{position:[ce,le]}],D=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",ww,gw,{size:[ce,le]}],J=()=>[ai,Mo,_r],U=()=>["","none","full",u,ce,le],F=()=>["",Ie,Mo,_r],W=()=>["solid","dashed","dotted","double"],P=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],_=()=>[Ie,ai,ad,sd],H=()=>["","none",x,ce,le],X=()=>["none",Ie,ce,le],Q=()=>["none",Ie,ce,le],oe=()=>[Ie,ce,le],re=()=>[Kr,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[tr],breakpoint:[tr],color:[uw],container:[tr],"drop-shadow":[tr],ease:["in","out","in-out"],font:[hw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[tr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[tr],shadow:[tr],spacing:["px",Ie],text:[tr],"text-shadow":[tr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Kr,le,ce,w]}],container:["container"],columns:[{columns:[Ie,le,ce,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:k()}],"inset-x":[{"inset-x":k()}],"inset-y":[{"inset-y":k()}],start:[{start:k()}],end:[{end:k()}],top:[{top:k()}],right:[{right:k()}],bottom:[{bottom:k()}],left:[{left:k()}],visibility:["visible","invisible","collapse"],z:[{z:[pr,"auto",ce,le]}],basis:[{basis:[Kr,"full","auto",l,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,Kr,"auto","initial","none",le]}],grow:[{grow:["",Ie,ce,le]}],shrink:[{shrink:["",Ie,ce,le]}],order:[{order:[pr,"first","last","none",ce,le]}],"grid-cols":[{"grid-cols":M()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":M()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":V()}],"auto-rows":[{"auto-rows":V()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[...G(),"normal"]}],"justify-self":[{"justify-self":["auto",...G()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[...G(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...G(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[...G(),"baseline"]}],"place-self":[{"place-self":["auto",...G()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:R()}],mx:[{mx:R()}],my:[{my:R()}],ms:[{ms:R()}],me:[{me:R()}],mt:[{mt:R()}],mr:[{mr:R()}],mb:[{mb:R()}],ml:[{ml:R()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],w:[{w:[l,"screen",...q()]}],"min-w":[{"min-w":[l,"screen","none",...q()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",n,Mo,_r]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ce,ii]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ai,le]}],"font-family":[{font:[vw,le,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,ce,le]}],"line-clamp":[{"line-clamp":[Ie,"none",ce,ii]}],leading:[{leading:[a,...N()]}],"list-image":[{"list-image":["none",ce,le]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ce,le]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...W(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",ce,_r]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[Ie,"auto",ce,le]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ce,le]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ce,le]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:I()}],"bg-repeat":[{bg:D()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},pr,ce,le],radial:["",ce,le],conic:[pr,ce,le]},bw,xw]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:U()}],"rounded-s":[{"rounded-s":U()}],"rounded-e":[{"rounded-e":U()}],"rounded-t":[{"rounded-t":U()}],"rounded-r":[{"rounded-r":U()}],"rounded-b":[{"rounded-b":U()}],"rounded-l":[{"rounded-l":U()}],"rounded-ss":[{"rounded-ss":U()}],"rounded-se":[{"rounded-se":U()}],"rounded-ee":[{"rounded-ee":U()}],"rounded-es":[{"rounded-es":U()}],"rounded-tl":[{"rounded-tl":U()}],"rounded-tr":[{"rounded-tr":U()}],"rounded-br":[{"rounded-br":U()}],"rounded-bl":[{"rounded-bl":U()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":F()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...W(),"hidden","none"]}],"divide-style":[{divide:[...W(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...W(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,ce,le]}],"outline-w":[{outline:["",Ie,Mo,_r]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",p,Is,_s]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",f,Is,_s]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:F()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[Ie,_r]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",m,Is,_s]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[Ie,ce,le]}],"mix-blend":[{"mix-blend":[...P(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":P()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":_()}],"mask-image-linear-to-pos":[{"mask-linear-to":_()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":_()}],"mask-image-t-to-pos":[{"mask-t-to":_()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":_()}],"mask-image-r-to-pos":[{"mask-r-to":_()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":_()}],"mask-image-b-to-pos":[{"mask-b-to":_()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":_()}],"mask-image-l-to-pos":[{"mask-l-to":_()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":_()}],"mask-image-x-to-pos":[{"mask-x-to":_()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":_()}],"mask-image-y-to-pos":[{"mask-y-to":_()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[ce,le]}],"mask-image-radial-from-pos":[{"mask-radial-from":_()}],"mask-image-radial-to-pos":[{"mask-radial-to":_()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":_()}],"mask-image-conic-to-pos":[{"mask-conic-to":_()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:I()}],"mask-repeat":[{mask:D()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ce,le]}],filter:[{filter:["","none",ce,le]}],blur:[{blur:H()}],brightness:[{brightness:[Ie,ce,le]}],contrast:[{contrast:[Ie,ce,le]}],"drop-shadow":[{"drop-shadow":["","none",h,Is,_s]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",Ie,ce,le]}],"hue-rotate":[{"hue-rotate":[Ie,ce,le]}],invert:[{invert:["",Ie,ce,le]}],saturate:[{saturate:[Ie,ce,le]}],sepia:[{sepia:["",Ie,ce,le]}],"backdrop-filter":[{"backdrop-filter":["","none",ce,le]}],"backdrop-blur":[{"backdrop-blur":H()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,ce,le]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,ce,le]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,ce,le]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,ce,le]}],"backdrop-invert":[{"backdrop-invert":["",Ie,ce,le]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,ce,le]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,ce,le]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,ce,le]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ce,le]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",ce,le]}],ease:[{ease:["linear","initial",v,ce,le]}],delay:[{delay:[Ie,ce,le]}],animate:[{animate:["none",b,ce,le]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,ce,le]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:Q()}],"scale-x":[{"scale-x":Q()}],"scale-y":[{"scale-y":Q()}],"scale-z":[{"scale-z":Q()}],"scale-3d":["scale-3d"],skew:[{skew:oe()}],"skew-x":[{"skew-x":oe()}],"skew-y":[{"skew-y":oe()}],transform:[{transform:[ce,le,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:re()}],"translate-x":[{"translate-x":re()}],"translate-y":[{"translate-y":re()}],"translate-z":[{"translate-z":re()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ce,le]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ce,le]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[Ie,Mo,_r,ii]}],stroke:[{stroke:["none",...j()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Ew=ow(Sw);function ve(...e){return Ew(Au(e))}const Wi=e=>{try{const t=new URL(e);if(t.protocol!=="artifact:")return null;const n=t.pathname.split("/").filter(a=>a),r=n[n.length-1],o=t.searchParams.get("version");return{filename:r,version:o}}catch(t){return console.error("Invalid artifact URI:",t),null}},hf=(e,t)=>{try{const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t||"download",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch(n){console.error("Error downloading blob:",n)}},gf=async(e,t,n)=>{try{let r,o=e.name;if(e.content){const a=atob(e.content),i=new Array(a.length);for(let c=0;c<a.length;c++)i[c]=a.charCodeAt(c);const l=new Uint8Array(i);r=new Blob([l],{type:e.mime_type||"application/octet-stream"})}else if(e.uri){const a=Wi(e.uri);if(!a)throw new Error(`Invalid or unhandled URI format: ${e.uri}`);o=a.filename;const i=a.version||"latest";let l;t&&t.trim()&&t!=="null"&&t!=="undefined"?l=`/api/v1/artifacts/${encodeURIComponent(t)}/${encodeURIComponent(o)}/versions/${i}`:n?l=`/api/v1/artifacts/null/${encodeURIComponent(o)}/versions/${i}?project_id=${n}`:l=`/api/v1/artifacts/null/${encodeURIComponent(o)}/versions/${i}`;const c=await Ne(l,{credentials:"include"});if(!c.ok)throw new Error(`Failed to download file: ${c.statusText}`);r=await c.blob()}else throw new Error("File has no content or URI to download.");hf(r,o)}catch(r){console.error("Error creating download link:",r)}},Ta=(e,t=2)=>{if(e===0)return"0 Bytes";if(e<0||!Number.isFinite(e))return"Invalid size";const n=1024,r=t<0?0:t,o=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,a)).toFixed(r))+" "+o[a]},qo=e=>{if(!e)return"N/A";try{const t=new Date(e);if(isNaN(t.getTime()))return"N/A";const r=Math.floor((new Date().getTime()-t.getTime())/1e3),o=Math.floor(r/60),a=Math.floor(o/60),i=Math.floor(a/24);return r<60?`${r}s ago`:o<60?`${o}m ago`:a<24?`${a}h ago`:i===1?"Yesterday":i<7?`${i}d ago`:t.toLocaleDateString()}catch(t){return console.error("Error formatting date:",t),"Invalid date"}},xf=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}},id=(e="")=>`
13
+ break-words
14
+ leading-[24px]
15
+
16
+ /* Typography */
17
+ [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:text-foreground
18
+ [&_h2]:text-xl [&_h2]:font-bold [&_h2]:mb-3 [&_h2]:mt-5 [&_h2]:text-foreground
19
+ [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-foreground
20
+ [&_h4]:text-base [&_h4]:font-semibold [&_h4]:mb-2 [&_h4]:mt-3 [&_h4]:text-foreground
21
+ [&_h5]:text-sm [&_h5]:font-semibold [&_h5]:mb-1 [&_h5]:mt-2 [&_h5]:text-foreground
22
+ [&_h6]:text-xs [&_h6]:font-semibold [&_h6]:mb-1 [&_h6]:mt-2 [&_h6]:text-foreground
23
+
24
+ /* Paragraphs */
25
+ [&_p]:leading-[24px] [&_p]:text-foreground [&_p]:whitespace-pre-wrap
26
+
27
+ /* Text formatting */
28
+ [&_strong]:font-semibold [&_strong]:text-foreground
29
+ [&_em]:italic
30
+ [&_del]:line-through [&_del]:text-foreground
31
+
32
+ /* Links */
33
+ [&_a]:text-[var(--color-primary-wMain)] [&_a]:underline [&_a]:decoration-[var(--color-primary-wMain)] dark:[&_a]:text-[var(--color-primary-w20)] dark:[&_a]:decoration-[var(--color-primary-w20)]
34
+ [&_a:hover]:text-[var(--color-primary-w100)] [&_a:hover]:decoration-[var(--color-primary-w100)] dark:[&_a:hover]:text-[var(--color-primary-w10)] dark:[&_a:hover]:decoration-[var(--color-primary-w10)]
35
+
36
+ /* Lists */
37
+ [&_ul]:mb-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1
38
+ [&_ol]:mb-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1
39
+ [&_li]:text-foreground [&_li]:leading-[24px]
40
+ [&_ul_ul]:mt-1 [&_ul_ul]:mb-1
41
+ [&_ol_ol]:mt-1 [&_ol_ol]:mb-1
42
+
43
+ /* Code */
44
+ [&_code]:bg-transparent [&_code]:py-0.5 [&_code]:rounded
45
+ [&_code]:text-sm [&_code]:font-mono [&_code]:font-semibold [&_code]:text-foreground [&_code]:break-words
46
+ [&_pre]:bg-transparent [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:overflow-x-auto [&_pre]:max-w-full
47
+ [&_pre]:mb-4 [&_pre]:border [&_pre]:border-border [&_pre]:whitespace-pre-wrap
48
+ [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-sm [&_pre_code]:break-words
49
+
50
+ /* Blockquotes */
51
+ [&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4
52
+ [&_blockquote]:py-2 [&_blockquote]:mb-4 [&_blockquote]:italic
53
+ [&_blockquote]:text-foreground [&_blockquote]:bg-transparent
54
+
55
+ /* Tables */
56
+ [&_table]:w-full [&_table]:mb-4 [&_table]:border-collapse [&_table]:table-fixed [&_table]:max-w-full
57
+ [&_th]:border [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:break-words
58
+ [&_th]:bg-transparent [&_th]:font-semibold [&_th]:text-left
59
+ [&_td]:border [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:break-words
60
+ [&_tr:nth-child(even)]:bg-transparent
61
+
62
+ /* Horizontal rules */
63
+ [&_hr]:border-0 [&_hr]:border-t [&_hr]:border-border [&_hr]:my-6
64
+
65
+ /* Images */
66
+ [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded [&_img]:my-2 [&_img]:object-contain
67
+
68
+ ${e}
69
+ `.trim().replace(/\s+/g," "),Nw=(e="")=>`
70
+ /* Buttons - "important" overrides for flow controls */
71
+ [&>button]:bg-[var(--color-background-w10)]
72
+ [&>button]:dark:!bg-[var(--color-background-w100)]
73
+ [&>button]:hover:bg-[var(--color-background-w20)]
74
+ [&>button]:dark:hover:!bg-[var(--color-primary-w60)]
75
+ [&>button]:text-[var(--color-primary-text-wMain)]
76
+ [&>button]:dark:text-[var(--color-primary-text-w10)]
77
+ [&>button]:!border
78
+ [&>button]:!border-[var(--color-secondary-w40)]
79
+ [&>button]:dark:!border-[var(--color-secondary-w70)]
80
+
81
+ ${e}
82
+ `.trim().replace(/\s+/g," ");function xe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function jw(e,t){const n=d.createContext(t),r=a=>{const{children:i,...l}=a,c=d.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(a){const i=d.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function In(e,t=[]){let n=[];function r(a,i){const l=d.createContext(i),c=n.length;n=[...n,i];const u=f=>{var v;const{scope:m,children:h,...x}=f,g=((v=m==null?void 0:m[e])==null?void 0:v[c])||l,w=d.useMemo(()=>x,Object.values(x));return s.jsx(g.Provider,{value:w,children:h})};u.displayName=a+"Provider";function p(f,m){var g;const h=((g=m==null?void 0:m[e])==null?void 0:g[c])||l,x=d.useContext(h);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>d.createContext(i));return function(l){const c=(l==null?void 0:l[e])||a;return d.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[r,kw(o,...t)]}function kw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...l,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Aw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Se=Aw.reduce((e,t)=>{const n=vr(`Primitive.${t}`),r=d.forwardRef((o,a)=>{const{asChild:i,...l}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ll(e,t){e&&ls.flushSync(()=>e.dispatchEvent(t))}function on(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function vf(e,t=globalThis==null?void 0:globalThis.document){const n=on(e);d.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Tw="DismissableLayer",Vi="dismissableLayer.update",_w="dismissableLayer.pointerDownOutside",Iw="dismissableLayer.focusOutside",ld,wf=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ms=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(wf),[p,f]=d.useState(null),m=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=d.useState({}),x=Le(t,S=>f(S)),g=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(w),b=p?g.indexOf(p):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=v,T=Pw(S=>{const N=S.target,k=[...u.branches].some(M=>M.contains(N));!E||k||(o==null||o(S),i==null||i(S),S.defaultPrevented||l==null||l())},m),C=Dw(S=>{const N=S.target;[...u.branches].some(M=>M.contains(N))||(a==null||a(S),i==null||i(S),S.defaultPrevented||l==null||l())},m);return vf(S=>{b===u.layers.size-1&&(r==null||r(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},m),d.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(ld=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),cd(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=ld)}},[p,m,n,u]),d.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),cd())},[p,u]),d.useEffect(()=>{const S=()=>h({});return document.addEventListener(Vi,S),()=>document.removeEventListener(Vi,S)},[]),s.jsx(Se.div,{...c,ref:x,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,T.onPointerDownCapture)})});ms.displayName=Tw;var Mw="DismissableLayerBranch",Rw=d.forwardRef((e,t)=>{const n=d.useContext(wf),r=d.useRef(null),o=Le(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(Se.div,{...e,ref:o})});Rw.displayName=Mw;function Pw(e,t=globalThis==null?void 0:globalThis.document){const n=on(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){bf(_w,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Dw(e,t=globalThis==null?void 0:globalThis.document){const n=on(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&bf(Iw,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function cd(){const e=new CustomEvent(Vi);document.dispatchEvent(e)}function bf(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ll(o,a):o.dispatchEvent(a)}var St=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},Lw=Sl[" useId ".trim().toString()]||(()=>{}),Ow=0;function hn(e){const[t,n]=d.useState(Lw());return St(()=>{n(r=>r??String(Ow++))},[e]),t?`radix-${t}`:""}const Fw=["top","right","bottom","left"],wr=Math.min,tn=Math.max,aa=Math.round,Ms=Math.floor,zn=e=>({x:e,y:e}),$w={left:"right",right:"left",bottom:"top",top:"bottom"},zw={start:"end",end:"start"};function Gi(e,t,n){return tn(e,wr(t,n))}function lr(e,t){return typeof e=="function"?e(t):e}function cr(e){return e.split("-")[0]}function yo(e){return e.split("-")[1]}function Ol(e){return e==="x"?"y":"x"}function Fl(e){return e==="y"?"height":"width"}const Uw=new Set(["top","bottom"]);function Fn(e){return Uw.has(cr(e))?"y":"x"}function $l(e){return Ol(Fn(e))}function Bw(e,t,n){n===void 0&&(n=!1);const r=yo(e),o=$l(e),a=Fl(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ia(i)),[i,ia(i)]}function Hw(e){const t=ia(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>zw[t])}const dd=["left","right"],ud=["right","left"],Ww=["top","bottom"],Vw=["bottom","top"];function Gw(e,t,n){switch(e){case"top":case"bottom":return n?t?ud:dd:t?dd:ud;case"left":case"right":return t?Ww:Vw;default:return[]}}function Yw(e,t,n,r){const o=yo(e);let a=Gw(cr(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Yi)))),a}function ia(e){return e.replace(/left|right|bottom|top/g,t=>$w[t])}function Kw(e){return{top:0,right:0,bottom:0,left:0,...e}}function yf(e){return typeof e!="number"?Kw(e):{top:e,right:e,bottom:e,left:e}}function la(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function fd(e,t,n){let{reference:r,floating:o}=e;const a=Fn(t),i=$l(t),l=Fl(i),c=cr(t),u=a==="y",p=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let h;switch(c){case"top":h={x:p,y:r.y-o.height};break;case"bottom":h={x:p,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(yo(t)){case"start":h[i]-=m*(n&&u?-1:1);break;case"end":h[i]+=m*(n&&u?-1:1);break}return h}const qw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,l=a.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:f}=fd(u,r,c),m=r,h={},x=0;for(let g=0;g<l.length;g++){const{name:w,fn:v}=l[g],{x:b,y,data:E,reset:T}=await v({x:p,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:u,platform:i,elements:{reference:e,floating:t}});p=b??p,f=y??f,h={...h,[w]:{...h[w],...E}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(u=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y:f}=fd(u,m,c)),g=-1)}return{x:p,y:f,placement:m,strategy:o,middlewareData:h}};async function Xo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:m=!1,padding:h=0}=lr(t,e),x=yf(h),w=l[m?f==="floating"?"reference":"floating":f],v=la(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:p,strategy:c})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),E=await(a.isElement==null?void 0:a.isElement(y))?await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1}:{x:1,y:1},T=la(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:y,strategy:c}):b);return{top:(v.top-T.top+x.top)/E.y,bottom:(T.bottom-v.bottom+x.bottom)/E.y,left:(v.left-T.left+x.left)/E.x,right:(T.right-v.right+x.right)/E.x}}const Xw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:l,middlewareData:c}=t,{element:u,padding:p=0}=lr(e,t)||{};if(u==null)return{};const f=yf(p),m={x:n,y:r},h=$l(o),x=Fl(h),g=await i.getDimensions(u),w=h==="y",v=w?"top":"left",b=w?"bottom":"right",y=w?"clientHeight":"clientWidth",E=a.reference[x]+a.reference[h]-m[h]-a.floating[x],T=m[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let S=C?C[y]:0;(!S||!await(i.isElement==null?void 0:i.isElement(C)))&&(S=l.floating[y]||a.floating[x]);const N=E/2-T/2,k=S/2-g[x]/2-1,M=wr(f[v],k),L=wr(f[b],k),O=M,V=S-g[x]-L,K=S/2-g[x]/2+N,G=Gi(O,K,V),R=!c.arrow&&yo(o)!=null&&K!==G&&a.reference[x]/2-(K<O?M:L)-g[x]/2<0,q=R?K<O?K-O:K-V:0;return{[h]:m[h]+q,data:{[h]:G,centerOffset:K-G-q,...R&&{alignmentOffset:q}},reset:R}}}),Zw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...w}=lr(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=cr(o),b=Fn(l),y=cr(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),T=m||(y||!g?[ia(l)]:Hw(l)),C=x!=="none";!m&&C&&T.push(...Yw(l,g,x,E));const S=[l,...T],N=await Xo(t,w),k=[];let M=((r=a.flip)==null?void 0:r.overflows)||[];if(p&&k.push(N[v]),f){const K=Bw(o,i,E);k.push(N[K[0]],N[K[1]])}if(M=[...M,{placement:o,overflows:k}],!k.every(K=>K<=0)){var L,O;const K=(((L=a.flip)==null?void 0:L.index)||0)+1,G=S[K];if(G&&(!(f==="alignment"?b!==Fn(G):!1)||M.every(j=>j.overflows[0]>0&&Fn(j.placement)===b)))return{data:{index:K,overflows:M},reset:{placement:G}};let R=(O=M.filter(q=>q.overflows[0]<=0).sort((q,j)=>q.overflows[1]-j.overflows[1])[0])==null?void 0:O.placement;if(!R)switch(h){case"bestFit":{var V;const q=(V=M.filter(j=>{if(C){const I=Fn(j.placement);return I===b||I==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(I=>I>0).reduce((I,D)=>I+D,0)]).sort((j,I)=>j[1]-I[1])[0])==null?void 0:V[0];q&&(R=q);break}case"initialPlacement":R=l;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function pd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function md(e){return Fw.some(t=>e[t]>=0)}const Jw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=lr(e,t);switch(r){case"referenceHidden":{const a=await Xo(t,{...o,elementContext:"reference"}),i=pd(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:md(i)}}}case"escaped":{const a=await Xo(t,{...o,altBoundary:!0}),i=pd(a,n.floating);return{data:{escapedOffsets:i,escaped:md(i)}}}default:return{}}}}},Cf=new Set(["left","top"]);async function Qw(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=cr(n),l=yo(n),c=Fn(n)==="y",u=Cf.has(i)?-1:1,p=a&&c?-1:1,f=lr(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof x=="number"&&(h=l==="end"?x*-1:x),c?{x:h*p,y:m*u}:{x:m*u,y:h*p}}const eb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:l}=t,c=await Qw(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:a+c.y,data:{...c,placement:i}}}}},tb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:l={fn:w=>{let{x:v,y:b}=w;return{x:v,y:b}}},...c}=lr(e,t),u={x:n,y:r},p=await Xo(t,c),f=Fn(cr(o)),m=Ol(f);let h=u[m],x=u[f];if(a){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",b=h+p[w],y=h-p[v];h=Gi(b,h,y)}if(i){const w=f==="y"?"top":"left",v=f==="y"?"bottom":"right",b=x+p[w],y=x-p[v];x=Gi(b,x,y)}const g=l.fn({...t,[m]:h,[f]:x});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:a,[f]:i}}}}}},nb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=lr(e,t),p={x:n,y:r},f=Fn(o),m=Ol(f);let h=p[m],x=p[f];const g=lr(l,t),w=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const y=m==="y"?"height":"width",E=a.reference[m]-a.floating[y]+w.mainAxis,T=a.reference[m]+a.reference[y]-w.mainAxis;h<E?h=E:h>T&&(h=T)}if(u){var v,b;const y=m==="y"?"width":"height",E=Cf.has(cr(o)),T=a.reference[f]-a.floating[y]+(E&&((v=i.offset)==null?void 0:v[f])||0)+(E?0:w.crossAxis),C=a.reference[f]+a.reference[y]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?w.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[m]:h,[f]:x}}}},rb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:l}=t,{apply:c=()=>{},...u}=lr(e,t),p=await Xo(t,u),f=cr(o),m=yo(o),h=Fn(o)==="y",{width:x,height:g}=a.floating;let w,v;f==="top"||f==="bottom"?(w=f,v=m===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(v=f,w=m==="end"?"top":"bottom");const b=g-p.top-p.bottom,y=x-p.left-p.right,E=wr(g-p[w],b),T=wr(x-p[v],y),C=!t.middlewareData.shift;let S=E,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=b),C&&!m){const M=tn(p.left,0),L=tn(p.right,0),O=tn(p.top,0),V=tn(p.bottom,0);h?N=x-2*(M!==0||L!==0?M+L:tn(p.left,p.right)):S=g-2*(O!==0||V!==0?O+V:tn(p.top,p.bottom))}await c({...t,availableWidth:N,availableHeight:S});const k=await i.getDimensions(l.floating);return x!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}};function _a(){return typeof window<"u"}function Co(e){return Sf(e)?(e.nodeName||"").toLowerCase():"#document"}function rn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Gn(e){var t;return(t=(Sf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Sf(e){return _a()?e instanceof Node||e instanceof rn(e).Node:!1}function Tn(e){return _a()?e instanceof Element||e instanceof rn(e).Element:!1}function Hn(e){return _a()?e instanceof HTMLElement||e instanceof rn(e).HTMLElement:!1}function hd(e){return!_a()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof rn(e).ShadowRoot}const ob=new Set(["inline","contents"]);function hs(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=_n(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ob.has(o)}const sb=new Set(["table","td","th"]);function ab(e){return sb.has(Co(e))}const ib=[":popover-open",":modal"];function Ia(e){return ib.some(t=>{try{return e.matches(t)}catch{return!1}})}const lb=["transform","translate","scale","rotate","perspective"],cb=["transform","translate","scale","rotate","perspective","filter"],db=["paint","layout","strict","content"];function zl(e){const t=Ul(),n=Tn(e)?_n(e):e;return lb.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||cb.some(r=>(n.willChange||"").includes(r))||db.some(r=>(n.contain||"").includes(r))}function ub(e){let t=br(e);for(;Hn(t)&&!co(t);){if(zl(t))return t;if(Ia(t))return null;t=br(t)}return null}function Ul(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fb=new Set(["html","body","#document"]);function co(e){return fb.has(Co(e))}function _n(e){return rn(e).getComputedStyle(e)}function Ma(e){return Tn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function br(e){if(Co(e)==="html")return e;const t=e.assignedSlot||e.parentNode||hd(e)&&e.host||Gn(e);return hd(t)?t.host:t}function Ef(e){const t=br(e);return co(t)?e.ownerDocument?e.ownerDocument.body:e.body:Hn(t)&&hs(t)?t:Ef(t)}function Zo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ef(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=rn(o);if(a){const l=Ki(i);return t.concat(i,i.visualViewport||[],hs(o)?o:[],l&&n?Zo(l):[])}return t.concat(o,Zo(o,[],n))}function Ki(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Nf(e){const t=_n(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Hn(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=aa(n)!==a||aa(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Bl(e){return Tn(e)?e:e.contextElement}function so(e){const t=Bl(e);if(!Hn(t))return zn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=Nf(t);let i=(a?aa(n.width):n.width)/r,l=(a?aa(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const pb=zn(0);function jf(e){const t=rn(e);return!Ul()||!t.visualViewport?pb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function mb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==rn(e)?!1:t}function Pr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Bl(e);let i=zn(1);t&&(r?Tn(r)&&(i=so(r)):i=so(e));const l=mb(a,n,r)?jf(a):zn(0);let c=(o.left+l.x)/i.x,u=(o.top+l.y)/i.y,p=o.width/i.x,f=o.height/i.y;if(a){const m=rn(a),h=r&&Tn(r)?rn(r):r;let x=m,g=Ki(x);for(;g&&r&&h!==x;){const w=so(g),v=g.getBoundingClientRect(),b=_n(g),y=v.left+(g.clientLeft+parseFloat(b.paddingLeft))*w.x,E=v.top+(g.clientTop+parseFloat(b.paddingTop))*w.y;c*=w.x,u*=w.y,p*=w.x,f*=w.y,c+=y,u+=E,x=rn(g),g=Ki(x)}}return la({width:p,height:f,x:c,y:u})}function Hl(e,t){const n=Ma(e).scrollLeft;return t?t.left+n:Pr(Gn(e)).left+n}function kf(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Hl(e,r)),a=r.top+t.scrollTop;return{x:o,y:a}}function hb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Gn(r),l=t?Ia(t.floating):!1;if(r===i||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=zn(1);const p=zn(0),f=Hn(r);if((f||!f&&!a)&&((Co(r)!=="body"||hs(i))&&(c=Ma(r)),Hn(r))){const h=Pr(r);u=so(r),p.x=h.x+r.clientLeft,p.y=h.y+r.clientTop}const m=i&&!f&&!a?kf(i,c,!0):zn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+m.x,y:n.y*u.y-c.scrollTop*u.y+p.y+m.y}}function gb(e){return Array.from(e.getClientRects())}function xb(e){const t=Gn(e),n=Ma(e),r=e.ownerDocument.body,o=tn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=tn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Hl(e);const l=-n.scrollTop;return _n(r).direction==="rtl"&&(i+=tn(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:l}}function vb(e,t){const n=rn(e),r=Gn(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,c=0;if(o){a=o.width,i=o.height;const u=Ul();(!u||u&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}return{width:a,height:i,x:l,y:c}}const wb=new Set(["absolute","fixed"]);function bb(e,t){const n=Pr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=Hn(e)?so(e):zn(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,c=o*a.x,u=r*a.y;return{width:i,height:l,x:c,y:u}}function gd(e,t,n){let r;if(t==="viewport")r=vb(e,n);else if(t==="document")r=xb(Gn(e));else if(Tn(t))r=bb(t,n);else{const o=jf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return la(r)}function Af(e,t){const n=br(e);return n===t||!Tn(n)||co(n)?!1:_n(n).position==="fixed"||Af(n,t)}function yb(e,t){const n=t.get(e);if(n)return n;let r=Zo(e,[],!1).filter(l=>Tn(l)&&Co(l)!=="body"),o=null;const a=_n(e).position==="fixed";let i=a?br(e):e;for(;Tn(i)&&!co(i);){const l=_n(i),c=zl(i);!c&&l.position==="fixed"&&(o=null),(a?!c&&!o:!c&&l.position==="static"&&!!o&&wb.has(o.position)||hs(i)&&!c&&Af(e,i))?r=r.filter(p=>p!==i):o=l,i=br(i)}return t.set(e,r),r}function Cb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ia(t)?[]:yb(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((u,p)=>{const f=gd(t,p,o);return u.top=tn(f.top,u.top),u.right=wr(f.right,u.right),u.bottom=wr(f.bottom,u.bottom),u.left=tn(f.left,u.left),u},gd(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Sb(e){const{width:t,height:n}=Nf(e);return{width:t,height:n}}function Eb(e,t,n){const r=Hn(t),o=Gn(t),a=n==="fixed",i=Pr(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=zn(0);function u(){c.x=Hl(o)}if(r||!r&&!a)if((Co(t)!=="body"||hs(o))&&(l=Ma(t)),r){const h=Pr(t,!0,a,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&u();a&&!r&&o&&u();const p=o&&!r&&!a?kf(o,l):zn(0),f=i.left+l.scrollLeft-c.x-p.x,m=i.top+l.scrollTop-c.y-p.y;return{x:f,y:m,width:i.width,height:i.height}}function li(e){return _n(e).position==="static"}function xd(e,t){if(!Hn(e)||_n(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Gn(e)===n&&(n=n.ownerDocument.body),n}function Tf(e,t){const n=rn(e);if(Ia(e))return n;if(!Hn(e)){let o=br(e);for(;o&&!co(o);){if(Tn(o)&&!li(o))return o;o=br(o)}return n}let r=xd(e,t);for(;r&&ab(r)&&li(r);)r=xd(r,t);return r&&co(r)&&li(r)&&!zl(r)?n:r||ub(e)||n}const Nb=async function(e){const t=this.getOffsetParent||Tf,n=this.getDimensions,r=await n(e.floating);return{reference:Eb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function jb(e){return _n(e).direction==="rtl"}const kb={convertOffsetParentRelativeRectToViewportRelativeRect:hb,getDocumentElement:Gn,getClippingRect:Cb,getOffsetParent:Tf,getElementRects:Nb,getClientRects:gb,getDimensions:Sb,getScale:so,isElement:Tn,isRTL:jb};function _f(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ab(e,t){let n=null,r;const o=Gn(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),a();const u=e.getBoundingClientRect(),{left:p,top:f,width:m,height:h}=u;if(l||t(),!m||!h)return;const x=Ms(f),g=Ms(o.clientWidth-(p+m)),w=Ms(o.clientHeight-(f+h)),v=Ms(p),y={rootMargin:-x+"px "+-g+"px "+-w+"px "+-v+"px",threshold:tn(0,wr(1,c))||1};let E=!0;function T(C){const S=C[0].intersectionRatio;if(S!==c){if(!E)return i();S?i(!1,S):r=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!_f(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(T,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,y)}n.observe(e)}return i(!0),a}function If(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Bl(e),p=o||a?[...u?Zo(u):[],...Zo(t)]:[];p.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const f=u&&l?Ab(u,n):null;let m=-1,h=null;i&&(h=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(t)})),n()}),u&&!c&&h.observe(u),h.observe(t));let x,g=c?Pr(e):null;c&&w();function w(){const v=Pr(e);g&&!_f(g,v)&&n(),g=v,x=requestAnimationFrame(w)}return n(),()=>{var v;p.forEach(b=>{o&&b.removeEventListener("scroll",n),a&&b.removeEventListener("resize",n)}),f==null||f(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(x)}}const Tb=eb,_b=tb,Ib=Zw,Mb=rb,Rb=Jw,vd=Xw,Pb=nb,Db=(e,t,n)=>{const r=new Map,o={platform:kb,...n},a={...o.platform,_c:r};return qw(e,t,{...o,platform:a})};var Lb=typeof document<"u",Ob=function(){},Zs=Lb?d.useLayoutEffect:Ob;function ca(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ca(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!ca(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Mf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wd(e,t){const n=Mf(e);return Math.round(t*n)/n}function ci(e){const t=d.useRef(e);return Zs(()=>{t.current=e}),t}function Rf(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[p,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=d.useState(r);ca(m,r)||h(r);const[x,g]=d.useState(null),[w,v]=d.useState(null),b=d.useCallback(j=>{j!==C.current&&(C.current=j,g(j))},[]),y=d.useCallback(j=>{j!==S.current&&(S.current=j,v(j))},[]),E=a||x,T=i||w,C=d.useRef(null),S=d.useRef(null),N=d.useRef(p),k=c!=null,M=ci(c),L=ci(o),O=ci(u),V=d.useCallback(()=>{if(!C.current||!S.current)return;const j={placement:t,strategy:n,middleware:m};L.current&&(j.platform=L.current),Db(C.current,S.current,j).then(I=>{const D={...I,isPositioned:O.current!==!1};K.current&&!ca(N.current,D)&&(N.current=D,ls.flushSync(()=>{f(D)}))})},[m,t,n,L,O]);Zs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(j=>({...j,isPositioned:!1})))},[u]);const K=d.useRef(!1);Zs(()=>(K.current=!0,()=>{K.current=!1}),[]),Zs(()=>{if(E&&(C.current=E),T&&(S.current=T),E&&T){if(M.current)return M.current(E,T,V);V()}},[E,T,V,M,k]);const G=d.useMemo(()=>({reference:C,floating:S,setReference:b,setFloating:y}),[b,y]),R=d.useMemo(()=>({reference:E,floating:T}),[E,T]),q=d.useMemo(()=>{const j={position:n,left:0,top:0};if(!R.floating)return j;const I=wd(R.floating,p.x),D=wd(R.floating,p.y);return l?{...j,transform:"translate("+I+"px, "+D+"px)",...Mf(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:D}},[n,l,R.floating,p.x,p.y]);return d.useMemo(()=>({...p,update:V,refs:G,elements:R,floatingStyles:q}),[p,V,G,R,q])}const Fb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?vd({element:r.current,padding:o}).fn(n):{}:r?vd({element:r,padding:o}).fn(n):{}}}},Pf=(e,t)=>({...Tb(e),options:[e,t]}),Df=(e,t)=>({..._b(e),options:[e,t]}),Lf=(e,t)=>({...Pb(e),options:[e,t]}),Of=(e,t)=>({...Ib(e),options:[e,t]}),Ff=(e,t)=>({...Mb(e),options:[e,t]}),$f=(e,t)=>({...Rb(e),options:[e,t]}),zf=(e,t)=>({...Fb(e),options:[e,t]});var $b="Arrow",Uf=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(Se.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Uf.displayName=$b;var Bf=Uf;function Hf(e){const[t,n]=d.useState(void 0);return St(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Wl="Popper",[Wf,So]=In(Wl),[zb,Vf]=Wf(Wl),Gf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(zb,{scope:t,anchor:r,onAnchorChange:o,children:n})};Gf.displayName=Wl;var Yf="PopperAnchor",Kf=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Vf(Yf,n),i=d.useRef(null),l=Le(t,i);return d.useEffect(()=>{a.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:s.jsx(Se.div,{...o,ref:l})});Kf.displayName=Yf;var Vl="PopperContent",[Ub,Bb]=Wf(Vl),qf=d.forwardRef((e,t)=>{var _,H,X,Q,oe,re;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:x,...g}=e,w=Vf(Vl,n),[v,b]=d.useState(null),y=Le(t,de=>b(de)),[E,T]=d.useState(null),C=Hf(E),S=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,k=r+(a!=="center"?"-"+a:""),M=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},L=Array.isArray(u)?u:[u],O=L.length>0,V={padding:M,boundary:L.filter(Wb),altBoundary:O},{refs:K,floatingStyles:G,placement:R,isPositioned:q,middlewareData:j}=Rf({strategy:"fixed",placement:k,whileElementsMounted:(...de)=>If(...de,{animationFrame:h==="always"}),elements:{reference:w.anchor},middleware:[Pf({mainAxis:o+N,alignmentAxis:i}),c&&Df({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Lf():void 0,...V}),c&&Of({...V}),Ff({...V,apply:({elements:de,rects:ne,availableWidth:ue,availableHeight:Oe})=>{const{width:De,height:Te}=ne.reference,Be=de.floating.style;Be.setProperty("--radix-popper-available-width",`${ue}px`),Be.setProperty("--radix-popper-available-height",`${Oe}px`),Be.setProperty("--radix-popper-anchor-width",`${De}px`),Be.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),E&&zf({element:E,padding:l}),Vb({arrowWidth:S,arrowHeight:N}),m&&$f({strategy:"referenceHidden",...V})]}),[I,D]=Jf(R),z=on(x);St(()=>{q&&(z==null||z())},[q,z]);const J=(_=j.arrow)==null?void 0:_.x,U=(H=j.arrow)==null?void 0:H.y,F=((X=j.arrow)==null?void 0:X.centerOffset)!==0,[W,P]=d.useState();return St(()=>{v&&P(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:q?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(Q=j.transformOrigin)==null?void 0:Q.x,(oe=j.transformOrigin)==null?void 0:oe.y].join(" "),...((re=j.hide)==null?void 0:re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(Ub,{scope:n,placedSide:I,onArrowChange:T,arrowX:J,arrowY:U,shouldHideArrow:F,children:s.jsx(Se.div,{"data-side":I,"data-align":D,...g,ref:y,style:{...g.style,animation:q?void 0:"none"}})})})});qf.displayName=Vl;var Xf="PopperArrow",Hb={top:"bottom",right:"left",bottom:"top",left:"right"},Zf=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=Bb(Xf,r),i=Hb[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Bf,{...o,ref:n,style:{...o.style,display:"block"}})})});Zf.displayName=Xf;function Wb(e){return e!==null}var Vb=e=>({name:"transformOrigin",options:e,fn(t){var w,v,b;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,p]=Jf(n),f={start:"0%",center:"50%",end:"100%"}[p],m=(((v=o.arrow)==null?void 0:v.x)??0)+l/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?f:`${m}px`,g=`${-c}px`):u==="top"?(x=i?f:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?f:`${h}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?f:`${h}px`),{data:{x,y:g}}}});function Jf(e){const[t,n="center"]=e.split("-");return[t,n]}var Gl=Gf,Ra=Kf,Yl=qf,Kl=Zf,Gb="Portal",Eo=d.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,a]=d.useState(!1);St(()=>a(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Tx.createPortal(s.jsx(Se.div,{...r,ref:t}),i):null});Eo.displayName=Gb;function Yb(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var sn=e=>{const{present:t,children:n}=e,r=Kb(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),a=Le(r.ref,qb(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:a}):null};sn.displayName="Presence";function Kb(e){const[t,n]=d.useState(),r=d.useRef(null),o=d.useRef(e),a=d.useRef("none"),i=e?"mounted":"unmounted",[l,c]=Yb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const u=Rs(r.current);a.current=l==="mounted"?u:"none"},[l]),St(()=>{const u=r.current,p=o.current;if(p!==e){const m=a.current,h=Rs(u);e?c("MOUNT"):h==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(p&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),St(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,f=h=>{const g=Rs(r.current).includes(h.animationName);if(h.target===t&&g&&(c("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},m=h=>{h.target===t&&(a.current=Rs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:d.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Rs(e){return(e==null?void 0:e.animationName)||"none"}function qb(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xb=Sl[" useInsertionEffect ".trim().toString()]||St;function yr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=Zb({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const p=d.useRef(e!==void 0);d.useEffect(()=>{const f=p.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=l},[l,r])}const u=d.useCallback(p=>{var f;if(l){const m=Jb(p)?p(e):p;m!==e&&((f=i.current)==null||f.call(i,m))}else a(p)},[l,e,a,i]);return[c,u]}function Zb({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),o=d.useRef(n),a=d.useRef(t);return Xb(()=>{a.current=t},[t]),d.useEffect(()=>{var i;o.current!==n&&((i=a.current)==null||i.call(a,n),o.current=n)},[n,o]),[n,r,a]}function Jb(e){return typeof e=="function"}var Qf=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Qb="VisuallyHidden",ep=d.forwardRef((e,t)=>s.jsx(Se.span,{...e,ref:t,style:{...Qf,...e.style}}));ep.displayName=Qb;var ey=ep,[Pa,U_]=In("Tooltip",[So]),Da=So(),tp="TooltipProvider",ty=700,qi="tooltip.open",[ny,ql]=Pa(tp),np=e=>{const{__scopeTooltip:t,delayDuration:n=ty,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,i=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(ny,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:d.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(u=>{l.current=u},[]),disableHoverableContent:o,children:a})};np.displayName=tp;var Jo="Tooltip",[ry,gs]=Pa(Jo),rp=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:a,disableHoverableContent:i,delayDuration:l}=e,c=ql(Jo,e.__scopeTooltip),u=Da(t),[p,f]=d.useState(null),m=hn(),h=d.useRef(0),x=i??c.disableHoverableContent,g=l??c.delayDuration,w=d.useRef(!1),[v,b]=yr({prop:r,defaultProp:o??!1,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(qi))):c.onClose(),a==null||a(S)},caller:Jo}),y=d.useMemo(()=>v?w.current?"delayed-open":"instant-open":"closed",[v]),E=d.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w.current=!1,b(!0)},[b]),T=d.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),C=d.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{w.current=!0,b(!0),h.current=0},g)},[g,b]);return d.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx(Gl,{...u,children:s.jsx(ry,{scope:t,contentId:m,open:v,stateAttribute:y,trigger:p,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():E()},[c.isOpenDelayedRef,C,E]),onTriggerLeave:d.useCallback(()=>{x?T():(window.clearTimeout(h.current),h.current=0)},[T,x]),onOpen:E,onClose:T,disableHoverableContent:x,children:n})})};rp.displayName=Jo;var Xi="TooltipTrigger",op=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=gs(Xi,n),a=ql(Xi,n),i=Da(n),l=d.useRef(null),c=Le(t,l,o.onTriggerChange),u=d.useRef(!1),p=d.useRef(!1),f=d.useCallback(()=>u.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),s.jsx(Ra,{asChild:!0,...i,children:s.jsx(Se.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:xe(e.onPointerMove,m=>{m.pointerType!=="touch"&&!p.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:xe(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:xe(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:xe(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:xe(e.onBlur,o.onClose),onClick:xe(e.onClick,o.onClose)})})});op.displayName=Xi;var Xl="TooltipPortal",[oy,sy]=Pa(Xl,{forceMount:void 0}),sp=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,a=gs(Xl,t);return s.jsx(oy,{scope:t,forceMount:n,children:s.jsx(sn,{present:n||a.open,children:s.jsx(Eo,{asChild:!0,container:o,children:r})})})};sp.displayName=Xl;var uo="TooltipContent",ap=d.forwardRef((e,t)=>{const n=sy(uo,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...a}=e,i=gs(uo,e.__scopeTooltip);return s.jsx(sn,{present:r||i.open,children:i.disableHoverableContent?s.jsx(ip,{side:o,...a,ref:t}):s.jsx(ay,{side:o,...a,ref:t})})}),ay=d.forwardRef((e,t)=>{const n=gs(uo,e.__scopeTooltip),r=ql(uo,e.__scopeTooltip),o=d.useRef(null),a=Le(t,o),[i,l]=d.useState(null),{trigger:c,onClose:u}=n,p=o.current,{onPointerInTransitChange:f}=r,m=d.useCallback(()=>{l(null),f(!1)},[f]),h=d.useCallback((x,g)=>{const w=x.currentTarget,v={x:x.clientX,y:x.clientY},b=dy(v,w.getBoundingClientRect()),y=uy(v,b),E=fy(g.getBoundingClientRect()),T=my([...y,...E]);l(T),f(!0)},[f]);return d.useEffect(()=>()=>m(),[m]),d.useEffect(()=>{if(c&&p){const x=w=>h(w,p),g=w=>h(w,c);return c.addEventListener("pointerleave",x),p.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),p.removeEventListener("pointerleave",g)}}},[c,p,h,m]),d.useEffect(()=>{if(i){const x=g=>{const w=g.target,v={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(w))||(p==null?void 0:p.contains(w)),y=!py(v,i);b?m():y&&(m(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,p,i,u,m]),s.jsx(ip,{...e,ref:a})}),[iy,ly]=Pa(Jo,{isInside:!1}),cy=L0("TooltipContent"),ip=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=gs(uo,n),u=Da(n),{onClose:p}=c;return d.useEffect(()=>(document.addEventListener(qi,p),()=>document.removeEventListener(qi,p)),[p]),d.useEffect(()=>{if(c.trigger){const f=m=>{const h=m.target;h!=null&&h.contains(c.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,p]),s.jsx(ms,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:s.jsxs(Yl,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(cy,{children:r}),s.jsx(iy,{scope:n,isInside:!0,children:s.jsx(ey,{id:c.contentId,role:"tooltip",children:o||r})})]})})});ap.displayName=uo;var lp="TooltipArrow",cp=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Da(n);return ly(lp,n).isInside?null:s.jsx(Kl,{...o,...r,ref:t})});cp.displayName=lp;function dy(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,o,a)){case a:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function uy(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fy(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function py(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,p=l.y,f=c.x,m=c.y;p>r!=m>r&&n<(f-u)*(r-p)/(m-p)+u&&(o=!o)}return o}function my(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),hy(t)}function hy(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var gy=np,xy=rp,vy=op,wy=sp,by=ap,yy=cp;function Cy({delayDuration:e=0,...t}){return s.jsx(gy,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Zl({...e}){return s.jsx(Cy,{delayDuration:500,children:s.jsx(xy,{"data-slot":"tooltip",...e})})}function Jl({...e}){return s.jsx(vy,{"data-slot":"tooltip-trigger",...e})}function Ql({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(wy,{children:s.jsxs(by,{"data-slot":"tooltip-content",sideOffset:t,className:ve("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,s.jsx(yy,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const dp="text-[var(--color-primary-wMain)] enabled:hover:text-[var(--color-primary-text-w60)] dark:text-[var(--color-primary-w20)] dark:enabled:hover:text-[var(--color-primary-text-w10)]",di=dp+" enabled:hover:bg-[var(--color-primary-w10)] dark:enabled:hover:bg-[var(--color-primary-w60)]",Sy=Nr("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm font-semibold transition-all disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 cursor-pointer disabled:cursor-not-allowed",{variants:{variant:{default:"text-[var(--color-primary-text-w10)] bg-[var(--color-primary-wMain)] enabled:hover:bg-[var(--color-primary-w100)] dark:enabled:hover:bg-[var(--color-primary-w60)] dark:text-[--color-primary-w10]",destructive:"text-[var(--color-primary-text-w10)] bg-[var(--color-error-wMain)] enabled:hover:bg-[var(--color-error-w70)]",outline:di+" border border-1 border-[var(--color-primary-wMain)]",secondary:di,ghost:di,link:dp+" underline-offset-4 enabled:hover:underline"},size:{default:"h-9 px-5 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function te({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",testid:a="",...i}){const l=r?nf:"button",c=o?{...i,"aria-label":o}:i,u=s.jsx(l,{"data-slot":"button","data-testid":a||o||i.title,className:ve(Sy({variant:t,size:n,className:e})),...c});return o?s.jsxs(Zl,{children:[s.jsx(Jl,{asChild:!0,children:u}),s.jsx(Ql,{children:o})]}):u}const up=({onClick:e,text:t="View Agent Workflow"})=>s.jsx(te,{"data-testid":"viewAgentWorkflow",variant:"ghost",size:"sm",onClick:e,tooltip:t,children:s.jsx(Ks,{className:"h-4 w-4"})}),Hr=d.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:ve("flex min-h-[80px] w-full rounded-md border px-3 py-2 placeholder:opacity-75 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Hr.displayName="Textarea";function ec({className:e,type:t,...n}){return s.jsx("input",{type:t,"data-slot":"input",className:ve("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","outline-none focus-visible:border-[var(--color-brand-wMain)] focus-visible:ring-[2px] focus-visible:ring-[var(--color-brand-wMain)]/50","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function Ey({className:e,...t}){return s.jsx("div",{"data-slot":"card",className:ve("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function Ny({className:e,...t}){return s.jsx("div",{"data-slot":"card-content",className:ve("px-6",e),...t})}d.createContext({});d.createContext({});const jy=Nr("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),ky=Nr("animate-spin",{variants:{size:{small:"size-4",medium:"size-8",large:"size-12"},variant:{primary:"text-[var(--color-brand-wMain)]",secondary:"text-[var(--color-primary-wMain)]",muted:"text-[var(--color-secondary-text-wMain)] dark:text-[var(--color-secondary-text-w50)]",foreground:"text-foreground"}},defaultVariants:{size:"medium",variant:"primary"}});function Wn({size:e,show:t,children:n,className:r,variant:o}){return s.jsxs("span",{className:jy({show:t}),children:[s.jsx(Ca,{className:ve(ky({size:e,variant:o}),r)}),n]})}var ui="focusScope.autoFocusOnMount",fi="focusScope.autoFocusOnUnmount",bd={bubbles:!1,cancelable:!0},Ay="FocusScope",xs=d.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[l,c]=d.useState(null),u=on(o),p=on(a),f=d.useRef(null),m=Le(t,g=>c(g)),h=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let g=function(y){if(h.paused||!l)return;const E=y.target;l.contains(E)?f.current=E:mr(f.current,{select:!0})},w=function(y){if(h.paused||!l)return;const E=y.relatedTarget;E!==null&&(l.contains(E)||mr(f.current,{select:!0}))},v=function(y){if(document.activeElement===document.body)for(const T of y)T.removedNodes.length>0&&mr(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",w);const b=new MutationObserver(v);return l&&b.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",w),b.disconnect()}}},[r,l,h.paused]),d.useEffect(()=>{if(l){Cd.add(h);const g=document.activeElement;if(!l.contains(g)){const v=new CustomEvent(ui,bd);l.addEventListener(ui,u),l.dispatchEvent(v),v.defaultPrevented||(Ty(Py(fp(l)),{select:!0}),document.activeElement===g&&mr(l))}return()=>{l.removeEventListener(ui,u),setTimeout(()=>{const v=new CustomEvent(fi,bd);l.addEventListener(fi,p),l.dispatchEvent(v),v.defaultPrevented||mr(g??document.body,{select:!0}),l.removeEventListener(fi,p),Cd.remove(h)},0)}}},[l,u,p,h]);const x=d.useCallback(g=>{if(!n&&!r||h.paused)return;const w=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(w&&v){const b=g.currentTarget,[y,E]=_y(b);y&&E?!g.shiftKey&&v===E?(g.preventDefault(),n&&mr(y,{select:!0})):g.shiftKey&&v===y&&(g.preventDefault(),n&&mr(E,{select:!0})):v===b&&g.preventDefault()}},[n,r,h.paused]);return s.jsx(Se.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});xs.displayName=Ay;function Ty(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(mr(r,{select:t}),document.activeElement!==n)return}function _y(e){const t=fp(e),n=yd(t,e),r=yd(t.reverse(),e);return[n,r]}function fp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function yd(e,t){for(const n of e)if(!Iy(n,{upTo:t}))return n}function Iy(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function My(e){return e instanceof HTMLInputElement&&"select"in e}function mr(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&My(e)&&t&&e.select()}}var Cd=Ry();function Ry(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Sd(e,t),e.unshift(t)},remove(t){var n;e=Sd(e,t),(n=e[0])==null||n.resume()}}}function Sd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Py(e){return e.filter(t=>t.tagName!=="A")}var pi=0;function tc(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ed()),document.body.insertAdjacentElement("beforeend",e[1]??Ed()),pi++,()=>{pi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),pi--}},[])}function Ed(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var On=function(){return On=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},On.apply(this,arguments)};function pp(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Dy(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Js="right-scroll-bar-position",Qs="width-before-scroll-bar",Ly="with-scroll-bars-hidden",Oy="--removed-body-scroll-bar-size";function mi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Fy(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var $y=typeof window<"u"?d.useLayoutEffect:d.useEffect,Nd=new WeakMap;function zy(e,t){var n=Fy(null,function(r){return e.forEach(function(o){return mi(o,r)})});return $y(function(){var r=Nd.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(l){a.has(l)||mi(l,null)}),a.forEach(function(l){o.has(l)||mi(l,i)})}Nd.set(n,e)},[e]),n}function Uy(e){return e}function By(e,t){t===void 0&&(t=Uy);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var p=i;i=[],p.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(p){i.push(p),u()},filter:function(p){return i=i.filter(p),n}}}};return o}function Hy(e){e===void 0&&(e={});var t=By(null);return t.options=On({async:!0,ssr:!1},e),t}var mp=function(e){var t=e.sideCar,n=pp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,On({},n))};mp.isSideCarExport=!0;function Wy(e,t){return e.useMedium(t),mp}var hp=Hy(),hi=function(){},La=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:hi,onWheelCapture:hi,onTouchMoveCapture:hi}),o=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,p=e.enabled,f=e.shards,m=e.sideCar,h=e.noRelative,x=e.noIsolation,g=e.inert,w=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,y=e.gapMode,E=pp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,C=zy([n,t]),S=On(On({},E),o);return d.createElement(d.Fragment,null,p&&d.createElement(T,{sideCar:hp,removeScrollBar:u,shards:f,noRelative:h,noIsolation:x,inert:g,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:y}),i?d.cloneElement(d.Children.only(l),On(On({},S),{ref:C})):d.createElement(b,On({},S,{className:c,ref:C}),l))});La.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};La.classNames={fullWidth:Qs,zeroRight:Js};var Vy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Gy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Vy();return t&&e.setAttribute("nonce",t),e}function Yy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ky(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var qy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Gy())&&(Yy(t,n),Ky(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Xy=function(){var e=qy();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},gp=function(){var e=Xy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Zy={left:0,top:0,right:0,gap:0},gi=function(e){return parseInt(e||"",10)||0},Jy=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[gi(n),gi(r),gi(o)]},Qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Zy;var t=Jy(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},e1=gp(),ao="data-scroll-locked",t1=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
83
+ .`.concat(Ly,` {
84
+ overflow: hidden `).concat(r,`;
85
+ padding-right: `).concat(l,"px ").concat(r,`;
86
+ }
87
+ body[`).concat(ao,`] {
88
+ overflow: hidden `).concat(r,`;
89
+ overscroll-behavior: contain;
90
+ `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
91
+ padding-left: `.concat(o,`px;
92
+ padding-top: `).concat(a,`px;
93
+ padding-right: `).concat(i,`px;
94
+ margin-left:0;
95
+ margin-top:0;
96
+ margin-right: `).concat(l,"px ").concat(r,`;
97
+ `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
98
+ }
99
+
100
+ .`).concat(Js,` {
101
+ right: `).concat(l,"px ").concat(r,`;
102
+ }
103
+
104
+ .`).concat(Qs,` {
105
+ margin-right: `).concat(l,"px ").concat(r,`;
106
+ }
107
+
108
+ .`).concat(Js," .").concat(Js,` {
109
+ right: 0 `).concat(r,`;
110
+ }
111
+
112
+ .`).concat(Qs," .").concat(Qs,` {
113
+ margin-right: 0 `).concat(r,`;
114
+ }
115
+
116
+ body[`).concat(ao,`] {
117
+ `).concat(Oy,": ").concat(l,`px;
118
+ }
119
+ `)},jd=function(){var e=parseInt(document.body.getAttribute(ao)||"0",10);return isFinite(e)?e:0},n1=function(){d.useEffect(function(){return document.body.setAttribute(ao,(jd()+1).toString()),function(){var e=jd()-1;e<=0?document.body.removeAttribute(ao):document.body.setAttribute(ao,e.toString())}},[])},r1=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;n1();var a=d.useMemo(function(){return Qy(o)},[o]);return d.createElement(e1,{styles:t1(a,!t,o,n?"":"!important")})},Zi=!1;if(typeof window<"u")try{var Ps=Object.defineProperty({},"passive",{get:function(){return Zi=!0,!0}});window.addEventListener("test",Ps,Ps),window.removeEventListener("test",Ps,Ps)}catch{Zi=!1}var qr=Zi?{passive:!1}:!1,o1=function(e){return e.tagName==="TEXTAREA"},xp=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!o1(e)&&n[t]==="visible")},s1=function(e){return xp(e,"overflowY")},a1=function(e){return xp(e,"overflowX")},kd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=vp(e,r);if(o){var a=wp(e,r),i=a[1],l=a[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},i1=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},l1=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},vp=function(e,t){return e==="v"?s1(t):a1(t)},wp=function(e,t){return e==="v"?i1(t):l1(t)},c1=function(e,t){return e==="h"&&t==="rtl"?-1:1},d1=function(e,t,n,r,o){var a=c1(e,window.getComputedStyle(t).direction),i=a*r,l=n.target,c=t.contains(l),u=!1,p=i>0,f=0,m=0;do{if(!l)break;var h=wp(e,l),x=h[0],g=h[1],w=h[2],v=g-w-a*x;(x||v)&&vp(e,l)&&(f+=v,m+=x);var b=l.parentNode;l=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(p&&Math.abs(f)<1||!p&&Math.abs(m)<1)&&(u=!0),u},Ds=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ad=function(e){return[e.deltaX,e.deltaY]},Td=function(e){return e&&"current"in e?e.current:e},u1=function(e,t){return e[0]===t[0]&&e[1]===t[1]},f1=function(e){return`
120
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
121
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
122
+ `)},p1=0,Xr=[];function m1(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),o=d.useState(p1++)[0],a=d.useState(gp)[0],i=d.useRef(e);d.useEffect(function(){i.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Dy([e.lockRef.current],(e.shards||[]).map(Td),!0).filter(Boolean);return g.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(g,w){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var v=Ds(g),b=n.current,y="deltaX"in g?g.deltaX:b[0]-v[0],E="deltaY"in g?g.deltaY:b[1]-v[1],T,C=g.target,S=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in g&&S==="h"&&C.type==="range")return!1;var N=kd(S,C);if(!N)return!0;if(N?T=S:(T=S==="v"?"h":"v",N=kd(S,C)),!N)return!1;if(!r.current&&"changedTouches"in g&&(y||E)&&(r.current=T),!T)return!0;var k=r.current||T;return d1(k,w,g,k==="h"?y:E)},[]),c=d.useCallback(function(g){var w=g;if(!(!Xr.length||Xr[Xr.length-1]!==a)){var v="deltaY"in w?Ad(w):Ds(w),b=t.current.filter(function(T){return T.name===w.type&&(T.target===w.target||w.target===T.shadowParent)&&u1(T.delta,v)})[0];if(b&&b.should){w.cancelable&&w.preventDefault();return}if(!b){var y=(i.current.shards||[]).map(Td).filter(Boolean).filter(function(T){return T.contains(w.target)}),E=y.length>0?l(w,y[0]):!i.current.noIsolation;E&&w.cancelable&&w.preventDefault()}}},[]),u=d.useCallback(function(g,w,v,b){var y={name:g,delta:w,target:v,should:b,shadowParent:h1(v)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),p=d.useCallback(function(g){n.current=Ds(g),r.current=void 0},[]),f=d.useCallback(function(g){u(g.type,Ad(g),g.target,l(g,e.lockRef.current))},[]),m=d.useCallback(function(g){u(g.type,Ds(g),g.target,l(g,e.lockRef.current))},[]);d.useEffect(function(){return Xr.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,qr),document.addEventListener("touchmove",c,qr),document.addEventListener("touchstart",p,qr),function(){Xr=Xr.filter(function(g){return g!==a}),document.removeEventListener("wheel",c,qr),document.removeEventListener("touchmove",c,qr),document.removeEventListener("touchstart",p,qr)}},[]);var h=e.removeScrollBar,x=e.inert;return d.createElement(d.Fragment,null,x?d.createElement(a,{styles:f1(o)}):null,h?d.createElement(r1,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function h1(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const g1=Wy(hp,m1);var vs=d.forwardRef(function(e,t){return d.createElement(La,On({},e,{ref:t,sideCar:g1}))});vs.classNames=La.classNames;var x1=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Zr=new WeakMap,Ls=new WeakMap,Os={},xi=0,bp=function(e){return e&&(e.host||bp(e.parentNode))},v1=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=bp(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},w1=function(e,t,n,r){var o=v1(t,Array.isArray(e)?e:[e]);Os[n]||(Os[n]=new WeakMap);var a=Os[n],i=[],l=new Set,c=new Set(o),u=function(f){!f||l.has(f)||(l.add(f),u(f.parentNode))};o.forEach(u);var p=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(m){if(l.has(m))p(m);else try{var h=m.getAttribute(r),x=h!==null&&h!=="false",g=(Zr.get(m)||0)+1,w=(a.get(m)||0)+1;Zr.set(m,g),a.set(m,w),i.push(m),g===1&&x&&Ls.set(m,!0),w===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",m,v)}})};return p(t),l.clear(),xi++,function(){i.forEach(function(f){var m=Zr.get(f)-1,h=a.get(f)-1;Zr.set(f,m),a.set(f,h),m||(Ls.has(f)||f.removeAttribute(r),Ls.delete(f)),h||f.removeAttribute(n)}),xi--,xi||(Zr=new WeakMap,Zr=new WeakMap,Ls=new WeakMap,Os={})}},Oa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=x1(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),w1(r,o,n,"aria-hidden")):function(){return null}},Fa="Dialog",[yp,B_]=In(Fa),[b1,Mn]=yp(Fa),Cp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,l=d.useRef(null),c=d.useRef(null),[u,p]=yr({prop:r,defaultProp:o??!1,onChange:a,caller:Fa});return s.jsx(b1,{scope:t,triggerRef:l,contentRef:c,contentId:hn(),titleId:hn(),descriptionId:hn(),open:u,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(f=>!f),[p]),modal:i,children:n})};Cp.displayName=Fa;var Sp="DialogTrigger",Ep=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Mn(Sp,n),a=Le(t,o.triggerRef);return s.jsx(Se.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":oc(o.open),...r,ref:a,onClick:xe(e.onClick,o.onOpenToggle)})});Ep.displayName=Sp;var nc="DialogPortal",[y1,Np]=yp(nc,{forceMount:void 0}),jp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Mn(nc,t);return s.jsx(y1,{scope:t,forceMount:n,children:d.Children.map(r,i=>s.jsx(sn,{present:n||a.open,children:s.jsx(Eo,{asChild:!0,container:o,children:i})}))})};jp.displayName=nc;var da="DialogOverlay",kp=d.forwardRef((e,t)=>{const n=Np(da,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Mn(da,e.__scopeDialog);return a.modal?s.jsx(sn,{present:r||a.open,children:s.jsx(S1,{...o,ref:t})}):null});kp.displayName=da;var C1=vr("DialogOverlay.RemoveScroll"),S1=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Mn(da,n);return s.jsx(vs,{as:C1,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Se.div,{"data-state":oc(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Dr="DialogContent",Ap=d.forwardRef((e,t)=>{const n=Np(Dr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Mn(Dr,e.__scopeDialog);return s.jsx(sn,{present:r||a.open,children:a.modal?s.jsx(E1,{...o,ref:t}):s.jsx(N1,{...o,ref:t})})});Ap.displayName=Dr;var E1=d.forwardRef((e,t)=>{const n=Mn(Dr,e.__scopeDialog),r=d.useRef(null),o=Le(t,n.contentRef,r);return d.useEffect(()=>{const a=r.current;if(a)return Oa(a)},[]),s.jsx(Tp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:xe(e.onFocusOutside,a=>a.preventDefault())})}),N1=d.forwardRef((e,t)=>{const n=Mn(Dr,e.__scopeDialog),r=d.useRef(!1),o=d.useRef(!1);return s.jsx(Tp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Tp=d.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,l=Mn(Dr,n),c=d.useRef(null),u=Le(t,c);return tc(),s.jsxs(s.Fragment,{children:[s.jsx(xs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(ms,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":oc(l.open),...i,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(j1,{titleId:l.titleId}),s.jsx(A1,{contentRef:c,descriptionId:l.descriptionId})]})]})}),rc="DialogTitle",_p=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Mn(rc,n);return s.jsx(Se.h2,{id:o.titleId,...r,ref:t})});_p.displayName=rc;var Ip="DialogDescription",Mp=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Mn(Ip,n);return s.jsx(Se.p,{id:o.descriptionId,...r,ref:t})});Mp.displayName=Ip;var Rp="DialogClose",Pp=d.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Mn(Rp,n);return s.jsx(Se.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});Pp.displayName=Rp;function oc(e){return e?"open":"closed"}var Dp="DialogTitleWarning",[H_,Lp]=jw(Dp,{contentName:Dr,titleName:rc,docsSlug:"dialog"}),j1=({titleId:e})=>{const t=Lp(Dp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+
124
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
125
+
126
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},k1="DialogDescriptionWarning",A1=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Lp(k1).contentName}}.`;return d.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},T1=Cp,_1=Ep,I1=jp,M1=kp,R1=Ap,P1=_p,D1=Mp,Op=Pp;function Yn({...e}){return s.jsx(T1,{"data-slot":"dialog",...e})}function L1({...e}){return s.jsx(_1,{"data-slot":"dialog-trigger",...e})}function O1({...e}){return s.jsx(I1,{"data-slot":"dialog-portal",...e})}function _d({...e}){return s.jsx(Op,{"data-slot":"dialog-close",...e})}function F1({className:e,...t}){return s.jsx(M1,{"data-slot":"dialog-overlay",className:ve("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Kn({className:e,children:t,showCloseButton:n=!1,...r}){return s.jsxs(O1,{"data-slot":"dialog-portal",children:[s.jsx(F1,{}),s.jsxs(R1,{"data-slot":"dialog-content",className:ve("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-md border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,n&&s.jsxs(Op,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[s.jsx(Er,{}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function qn({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:ve("flex flex-col gap-2 text-center sm:text-left",e),...t})}function jr({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-footer",className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Xn({className:e,...t}){return s.jsx(P1,{"data-slot":"dialog-title",className:ve("text-lg leading-none font-semibold",e),...t})}function Zn({className:e,...t}){return s.jsx(D1,{"data-slot":"dialog-description",className:ve("py-4 text-sm",e),...t})}const $a=d.createContext(null);$a.displayName="PanelGroupContext";const ot={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},sc=10,Mr=d.useLayoutEffect,Id=Sl.useId,$1=typeof Id=="function"?Id:()=>null;let z1=0;function ac(e=null){const t=$1(),n=d.useRef(e||t||null);return n.current===null&&(n.current=""+z1++),e??n.current}function Fp({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:a,id:i,maxSize:l,minSize:c,onCollapse:u,onExpand:p,onResize:f,order:m,style:h,tagName:x="div",...g}){const w=d.useContext($a);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:b,getPanelSize:y,getPanelStyle:E,groupId:T,isPanelCollapsed:C,reevaluatePanelConstraints:S,registerPanel:N,resizePanel:k,unregisterPanel:M}=w,L=ac(i),O=d.useRef({callbacks:{onCollapse:u,onExpand:p,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:L,idIsFromProps:i!==void 0,order:m});d.useRef({didLogMissingDefaultSizeWarning:!1}),Mr(()=>{const{callbacks:K,constraints:G}=O.current,R={...G};O.current.id=L,O.current.idIsFromProps=i!==void 0,O.current.order=m,K.onCollapse=u,K.onExpand=p,K.onResize=f,G.collapsedSize=n,G.collapsible=r,G.defaultSize=o,G.maxSize=l,G.minSize=c,(R.collapsedSize!==G.collapsedSize||R.collapsible!==G.collapsible||R.maxSize!==G.maxSize||R.minSize!==G.minSize)&&S(O.current,R)}),Mr(()=>{const K=O.current;return N(K),()=>{M(K)}},[m,L,N,M]),d.useImperativeHandle(a,()=>({collapse:()=>{v(O.current)},expand:K=>{b(O.current,K)},getId(){return L},getSize(){return y(O.current)},isCollapsed(){return C(O.current)},isExpanded(){return!C(O.current)},resize:K=>{k(O.current,K)}}),[v,b,y,C,L,k]);const V=E(O.current,o);return d.createElement(x,{...g,children:e,className:t,id:L,style:{...V,...h},[ot.groupId]:T,[ot.panel]:"",[ot.panelCollapsible]:r||void 0,[ot.panelId]:L,[ot.panelSize]:parseFloat(""+V.flexGrow).toFixed(1)})}const $p=d.forwardRef((e,t)=>d.createElement(Fp,{...e,forwardedRef:t}));Fp.displayName="Panel";$p.displayName="forwardRef(Panel)";let Ji=null,ea=-1,hr=null;function U1(e,t){if(t){const n=(t&Wp)!==0,r=(t&Vp)!==0,o=(t&Gp)!==0,a=(t&Yp)!==0;if(n)return o?"se-resize":a?"ne-resize":"e-resize";if(r)return o?"sw-resize":a?"nw-resize":"w-resize";if(o)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function B1(){hr!==null&&(document.head.removeChild(hr),Ji=null,hr=null,ea=-1)}function vi(e,t){var n,r;const o=U1(e,t);if(Ji!==o){if(Ji=o,hr===null&&(hr=document.createElement("style"),document.head.appendChild(hr)),ea>=0){var a;(a=hr.sheet)===null||a===void 0||a.removeRule(ea)}ea=(n=(r=hr.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${o} !important;}`))!==null&&n!==void 0?n:-1}}function zp(e){return e.type==="keydown"}function Up(e){return e.type.startsWith("pointer")}function Bp(e){return e.type.startsWith("mouse")}function za(e){if(Up(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Bp(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function H1(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function W1(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function V1(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Pd(e),b:Pd(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ae(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:Rd(Md(n.a)),b:Rd(Md(n.b))};if(o.a===o.b){const a=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=a.length;for(;l--;){const c=a[l];if(c===i.a)return 1;if(c===i.b)return-1}}return Math.sign(o.a-o.b)}const G1=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Y1(e){var t;const n=getComputedStyle((t=Hp(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function K1(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Y1(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||G1.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Md(e){let t=e.length;for(;t--;){const n=e[t];if(Ae(n,"Missing node"),K1(n))return n}return null}function Rd(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Pd(e){const t=[];for(;e;)t.push(e),e=Hp(e);return t}function Hp(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Wp=1,Vp=2,Gp=4,Yp=8,q1=H1()==="coarse";let An=[],io=!1,gr=new Map,Ua=new Map;const Qo=new Set;function X1(e,t,n,r,o){var a;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(a=gr.get(i))!==null&&a!==void 0?a:0;return gr.set(i,c+1),Qo.add(l),ua(),function(){var p;Ua.delete(e),Qo.delete(l);const f=(p=gr.get(i))!==null&&p!==void 0?p:1;if(gr.set(i,f-1),ua(),f===1&&gr.delete(i),An.includes(l)){const m=An.indexOf(l);m>=0&&An.splice(m,1),lc(),o("up",!0,null)}}}function Z1(e){const{target:t}=e,{x:n,y:r}=za(e);io=!0,ic({target:t,x:n,y:r}),ua(),An.length>0&&(fa("down",e),e.preventDefault(),Kp(t)||e.stopImmediatePropagation())}function wi(e){const{x:t,y:n}=za(e);if(io&&e.buttons===0&&(io=!1,fa("up",e)),!io){const{target:r}=e;ic({target:r,x:t,y:n})}fa("move",e),lc(),An.length>0&&e.preventDefault()}function bi(e){const{target:t}=e,{x:n,y:r}=za(e);Ua.clear(),io=!1,An.length>0&&(e.preventDefault(),Kp(t)||e.stopImmediatePropagation()),fa("up",e),ic({target:t,x:n,y:r}),lc(),ua()}function Kp(e){let t=e;for(;t;){if(t.hasAttribute(ot.resizeHandle))return!0;t=t.parentElement}return!1}function ic({target:e,x:t,y:n}){An.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Qo.forEach(o=>{const{element:a,hitAreaMargins:i}=o,l=a.getBoundingClientRect(),{bottom:c,left:u,right:p,top:f}=l,m=q1?i.coarse:i.fine;if(t>=u-m&&t<=p+m&&n>=f-m&&n<=c+m){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&V1(r,a)>0){let x=r,g=!1;for(;x&&!x.contains(a);){if(W1(x.getBoundingClientRect(),l)){g=!0;break}x=x.parentElement}if(g)return}An.push(o)}})}function yi(e,t){Ua.set(e,t)}function lc(){let e=!1,t=!1;An.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;Ua.forEach(r=>{n|=r}),e&&t?vi("intersection",n):e?vi("horizontal",n):t?vi("vertical",n):B1()}let Ci;function ua(){var e;(e=Ci)===null||e===void 0||e.abort(),Ci=new AbortController;const t={capture:!0,signal:Ci.signal};Qo.size&&(io?(An.length>0&&gr.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",bi,t),o.addEventListener("pointerleave",wi,t),o.addEventListener("pointermove",wi,t))}),gr.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",bi,t),o.addEventListener("pointercancel",bi,t)})):gr.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",Z1,t),o.addEventListener("pointermove",wi,t))}))}function fa(e,t){Qo.forEach(n=>{const{setResizeHandlerState:r}=n,o=An.includes(n);r(e,o,t)})}function J1(){const[e,t]=d.useState(0);return d.useCallback(()=>t(n=>n+1),[])}function Ae(e,t){if(!e)throw console.error(t),Error(t)}function Lr(e,t,n=sc){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function rr(e,t,n=sc){return Lr(e,t,n)===0}function en(e,t,n){return Lr(e,t,n)===0}function Q1(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],a=t[r];if(!en(o,a,n))return!1}return!0}function no({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ae(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:a,maxSize:i=100,minSize:l=0}=r;if(Lr(n,l)<0)if(a){const c=(o+l)/2;Lr(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(sc)),n}function zo({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:a}){if(en(e,0))return t;const i=[...t],[l,c]=r;Ae(l!=null,"Invalid first pivot index"),Ae(c!=null,"Invalid second pivot index");let u=0;if(a==="keyboard"){{const f=e<0?c:l,m=n[f];Ae(m,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:x,minSize:g=0}=m;if(x){const w=t[f];if(Ae(w!=null,`Previous layout not found for panel index ${f}`),en(w,h)){const v=g-w;Lr(v,Math.abs(e))>0&&(e=e<0?0-v:v)}}}{const f=e<0?l:c,m=n[f];Ae(m,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:x,minSize:g=0}=m;if(x){const w=t[f];if(Ae(w!=null,`Previous layout not found for panel index ${f}`),en(w,g)){const v=w-h;Lr(v,Math.abs(e))>0&&(e=e<0?0-v:v)}}}}{const f=e<0?1:-1;let m=e<0?c:l,h=0;for(;;){const g=t[m];Ae(g!=null,`Previous layout not found for panel index ${m}`);const v=no({panelConstraints:n,panelIndex:m,size:100})-g;if(h+=v,m+=f,m<0||m>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-x:x}{let m=e<0?l:c;for(;m>=0&&m<n.length;){const h=Math.abs(e)-Math.abs(u),x=t[m];Ae(x!=null,`Previous layout not found for panel index ${m}`);const g=x-h,w=no({panelConstraints:n,panelIndex:m,size:g});if(!en(x,w)&&(u+=x-w,i[m]=w,u.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Q1(o,i))return o;{const f=e<0?c:l,m=t[f];Ae(m!=null,`Previous layout not found for panel index ${f}`);const h=m+u,x=no({panelConstraints:n,panelIndex:f,size:h});if(i[f]=x,!en(x,h)){let g=h-x,v=e<0?c:l;for(;v>=0&&v<n.length;){const b=i[v];Ae(b!=null,`Previous layout not found for panel index ${v}`);const y=b+g,E=no({panelConstraints:n,panelIndex:v,size:y});if(en(b,E)||(g-=E-b,i[v]=E),en(g,0))break;e>0?v--:v++}}}const p=i.reduce((f,m)=>m+f,0);return en(p,100)?i:o}function eC({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,a=0,i=0;const l=n[0];Ae(l!=null,"No pivot index found"),t.forEach((f,m)=>{const{constraints:h}=f,{maxSize:x=100,minSize:g=0}=h;m===l?(r=g,o=x):(a+=g,i+=x)});const c=Math.min(o,100-a),u=Math.max(r,100-i),p=e[l];return{valueMax:c,valueMin:u,valueNow:p}}function es(e,t=document){return Array.from(t.querySelectorAll(`[${ot.resizeHandleId}][data-panel-group-id="${e}"]`))}function qp(e,t,n=document){const o=es(e,n).findIndex(a=>a.getAttribute(ot.resizeHandleId)===t);return o??null}function Xp(e,t,n){const r=qp(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function tC(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Zp(e,t=document){if(tC(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Ba(e,t=document){const n=t.querySelector(`[${ot.resizeHandleId}="${e}"]`);return n||null}function nC(e,t,n,r=document){var o,a,i,l;const c=Ba(t,r),u=es(e,r),p=c?u.indexOf(c):-1,f=(o=(a=n[p])===null||a===void 0?void 0:a.id)!==null&&o!==void 0?o:null,m=(i=(l=n[p+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[f,m]}function rC({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:a,setLayout:i}){d.useRef({didWarnAboutMissingResizeHandle:!1}),Mr(()=>{if(!a)return;const l=es(n,a);for(let c=0;c<o.length-1;c++){const{valueMax:u,valueMin:p,valueNow:f}=eC({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const h=o[c];Ae(h,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",h.id),m.setAttribute("aria-valuemax",""+Math.round(u)),m.setAttribute("aria-valuemin",""+Math.round(p)),m.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{l.forEach((c,u)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,o,a]),d.useEffect(()=>{if(!a)return;const l=t.current;Ae(l,"Eager values not found");const{panelDataArray:c}=l,u=Zp(n,a);Ae(u!=null,`No group found for id "${n}"`);const p=es(n,a);Ae(p,`No resize handles found for group id "${n}"`);const f=p.map(m=>{const h=m.getAttribute(ot.resizeHandleId);Ae(h,"Resize handle element has no handle id attribute");const[x,g]=nC(n,h,c,a);if(x==null||g==null)return()=>{};const w=v=>{if(!v.defaultPrevented)switch(v.key){case"Enter":{v.preventDefault();const b=c.findIndex(y=>y.id===x);if(b>=0){const y=c[b];Ae(y,`No panel data found for index ${b}`);const E=r[b],{collapsedSize:T=0,collapsible:C,minSize:S=0}=y.constraints;if(E!=null&&C){const N=zo({delta:en(E,T)?S-T:T-E,initialLayout:r,panelConstraints:c.map(k=>k.constraints),pivotIndices:Xp(n,h,a),prevLayout:r,trigger:"keyboard"});r!==N&&i(N)}}break}}};return m.addEventListener("keydown",w),()=>{m.removeEventListener("keydown",w)}});return()=>{f.forEach(m=>m())}},[a,e,t,n,r,o,i])}function Dd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Jp(e,t){const n=e==="horizontal",{x:r,y:o}=za(t);return n?r:o}function oC(e,t,n,r,o){const a=n==="horizontal",i=Ba(t,o);Ae(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(ot.groupId);Ae(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const u=Jp(n,e),p=Zp(l,o);Ae(p,`No group element found for id "${l}"`);const f=p.getBoundingClientRect(),m=a?f.width:f.height;return(u-c)/m*100}function sC(e,t,n,r,o,a){if(zp(e)){const i=n==="horizontal";let l=0;e.shiftKey?l=100:o!=null?l=o:l=10;let c=0;switch(e.key){case"ArrowDown":c=i?0:l;break;case"ArrowLeft":c=i?-l:0;break;case"ArrowRight":c=i?l:0;break;case"ArrowUp":c=i?0:-l;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:oC(e,t,n,r,a)}function aC({panelDataArray:e}){const t=Array(e.length),n=e.map(a=>a.constraints);let r=0,o=100;for(let a=0;a<e.length;a++){const i=n[a];Ae(i,`Panel constraints not found for index ${a}`);const{defaultSize:l}=i;l!=null&&(r++,t[a]=l,o-=l)}for(let a=0;a<e.length;a++){const i=n[a];Ae(i,`Panel constraints not found for index ${a}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,u=o/c;r++,t[a]=u,o-=u}return t}function Jr(e,t,n){t.forEach((r,o)=>{const a=e[o];Ae(a,`Panel data not found for index ${o}`);const{callbacks:i,constraints:l,id:c}=a,{collapsedSize:u=0,collapsible:p}=l,f=n[c];if(f==null||r!==f){n[c]=r;const{onCollapse:m,onExpand:h,onResize:x}=i;x&&x(r,f),p&&(m||h)&&(h&&(f==null||rr(f,u))&&!rr(r,u)&&h(),m&&(f==null||!rr(f,u))&&rr(r,u)&&m())}})}function Fs(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function iC({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:a=3}){const i=n[o];let l;return i==null?l=e!=null?e.toPrecision(a):"1":r.length===1?l="1":l=i.toPrecision(a),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function lC(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function Ld(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Qp(e){return`react-resizable-panels:${e}`}function em(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:o,order:a}=t;return o?r:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function tm(e,t){try{const n=Qp(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function cC(e,t,n){var r,o;const a=(r=tm(e,n))!==null&&r!==void 0?r:{},i=em(t);return(o=a[i])!==null&&o!==void 0?o:null}function dC(e,t,n,r,o){var a;const i=Qp(e),l=em(t),c=(a=tm(e,o))!==null&&a!==void 0?a:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(c))}catch(u){console.error(u)}}function Od({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((a,i)=>a+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!en(r,100)&&n.length>0)for(let a=0;a<t.length;a++){const i=n[a];Ae(i!=null,`No layout data found for index ${a}`);const l=100/r*i;n[a]=l}let o=0;for(let a=0;a<t.length;a++){const i=n[a];Ae(i!=null,`No layout data found for index ${a}`);const l=no({panelConstraints:t,panelIndex:a,size:i});i!=l&&(o+=i-l,n[a]=l)}if(!en(o,0))for(let a=0;a<t.length;a++){const i=n[a];Ae(i!=null,`No layout data found for index ${a}`);const l=i+o,c=no({panelConstraints:t,panelIndex:a,size:l});if(i!==c&&(o-=c-i,n[a]=c,en(o,0)))break}return n}const uC=100,Uo={getItem:e=>(Ld(Uo),Uo.getItem(e)),setItem:(e,t)=>{Ld(Uo),Uo.setItem(e,t)}},Fd={};function nm({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:a=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Uo,style:u,tagName:p="div",...f}){const m=ac(a),h=d.useRef(null),[x,g]=d.useState(null),[w,v]=d.useState([]),b=J1(),y=d.useRef({}),E=d.useRef(new Map),T=d.useRef(0),C=d.useRef({autoSaveId:e,direction:r,dragState:x,id:m,keyboardResizeBy:l,onLayout:i,storage:c}),S=d.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});d.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),d.useImperativeHandle(o,()=>({getId:()=>C.current.id,getLayout:()=>{const{layout:U}=S.current;return U},setLayout:U=>{const{onLayout:F}=C.current,{layout:W,panelDataArray:P}=S.current,_=Od({layout:U,panelConstraints:P.map(H=>H.constraints)});Dd(W,_)||(v(_),S.current.layout=_,F&&F(_),Jr(P,_,y.current))}}),[]),Mr(()=>{C.current.autoSaveId=e,C.current.direction=r,C.current.dragState=x,C.current.id=m,C.current.onLayout=i,C.current.storage=c}),rC({committedValuesRef:C,eagerValuesRef:S,groupId:m,layout:w,panelDataArray:S.current.panelDataArray,setLayout:v,panelGroupElement:h.current}),d.useEffect(()=>{const{panelDataArray:U}=S.current;if(e){if(w.length===0||w.length!==U.length)return;let F=Fd[e];F==null&&(F=lC(dC,uC),Fd[e]=F);const W=[...U],P=new Map(E.current);F(e,W,P,w,c)}},[e,w,c]),d.useEffect(()=>{});const N=d.useCallback(U=>{const{onLayout:F}=C.current,{layout:W,panelDataArray:P}=S.current;if(U.constraints.collapsible){const _=P.map(oe=>oe.constraints),{collapsedSize:H=0,panelSize:X,pivotIndices:Q}=Ir(P,U,W);if(Ae(X!=null,`Panel size not found for panel "${U.id}"`),!rr(X,H)){E.current.set(U.id,X);const re=eo(P,U)===P.length-1?X-H:H-X,de=zo({delta:re,initialLayout:W,panelConstraints:_,pivotIndices:Q,prevLayout:W,trigger:"imperative-api"});Fs(W,de)||(v(de),S.current.layout=de,F&&F(de),Jr(P,de,y.current))}}},[]),k=d.useCallback((U,F)=>{const{onLayout:W}=C.current,{layout:P,panelDataArray:_}=S.current;if(U.constraints.collapsible){const H=_.map(ne=>ne.constraints),{collapsedSize:X=0,panelSize:Q=0,minSize:oe=0,pivotIndices:re}=Ir(_,U,P),de=F??oe;if(rr(Q,X)){const ne=E.current.get(U.id),ue=ne!=null&&ne>=de?ne:de,De=eo(_,U)===_.length-1?Q-ue:ue-Q,Te=zo({delta:De,initialLayout:P,panelConstraints:H,pivotIndices:re,prevLayout:P,trigger:"imperative-api"});Fs(P,Te)||(v(Te),S.current.layout=Te,W&&W(Te),Jr(_,Te,y.current))}}},[]),M=d.useCallback(U=>{const{layout:F,panelDataArray:W}=S.current,{panelSize:P}=Ir(W,U,F);return Ae(P!=null,`Panel size not found for panel "${U.id}"`),P},[]),L=d.useCallback((U,F)=>{const{panelDataArray:W}=S.current,P=eo(W,U);return iC({defaultSize:F,dragState:x,layout:w,panelData:W,panelIndex:P})},[x,w]),O=d.useCallback(U=>{const{layout:F,panelDataArray:W}=S.current,{collapsedSize:P=0,collapsible:_,panelSize:H}=Ir(W,U,F);return Ae(H!=null,`Panel size not found for panel "${U.id}"`),_===!0&&rr(H,P)},[]),V=d.useCallback(U=>{const{layout:F,panelDataArray:W}=S.current,{collapsedSize:P=0,collapsible:_,panelSize:H}=Ir(W,U,F);return Ae(H!=null,`Panel size not found for panel "${U.id}"`),!_||Lr(H,P)>0},[]),K=d.useCallback(U=>{const{panelDataArray:F}=S.current;F.push(U),F.sort((W,P)=>{const _=W.order,H=P.order;return _==null&&H==null?0:_==null?-1:H==null?1:_-H}),S.current.panelDataArrayChanged=!0,b()},[b]);Mr(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:U,onLayout:F,storage:W}=C.current,{layout:P,panelDataArray:_}=S.current;let H=null;if(U){const Q=cC(U,_,W);Q&&(E.current=new Map(Object.entries(Q.expandToSizes)),H=Q.layout)}H==null&&(H=aC({panelDataArray:_}));const X=Od({layout:H,panelConstraints:_.map(Q=>Q.constraints)});Dd(P,X)||(v(X),S.current.layout=X,F&&F(X),Jr(_,X,y.current))}}),Mr(()=>{const U=S.current;return()=>{U.layout=[]}},[]);const G=d.useCallback(U=>{let F=!1;const W=h.current;return W&&window.getComputedStyle(W,null).getPropertyValue("direction")==="rtl"&&(F=!0),function(_){_.preventDefault();const H=h.current;if(!H)return()=>null;const{direction:X,dragState:Q,id:oe,keyboardResizeBy:re,onLayout:de}=C.current,{layout:ne,panelDataArray:ue}=S.current,{initialLayout:Oe}=Q??{},De=Xp(oe,U,H);let Te=sC(_,U,X,Q,re,H);const Be=X==="horizontal";Be&&F&&(Te=-Te);const Et=ue.map(Lt=>Lt.constraints),et=zo({delta:Te,initialLayout:Oe??ne,panelConstraints:Et,pivotIndices:De,prevLayout:ne,trigger:zp(_)?"keyboard":"mouse-or-touch"}),wt=!Fs(ne,et);(Up(_)||Bp(_))&&T.current!=Te&&(T.current=Te,!wt&&Te!==0?Be?yi(U,Te<0?Wp:Vp):yi(U,Te<0?Gp:Yp):yi(U,0)),wt&&(v(et),S.current.layout=et,de&&de(et),Jr(ue,et,y.current))}},[]),R=d.useCallback((U,F)=>{const{onLayout:W}=C.current,{layout:P,panelDataArray:_}=S.current,H=_.map(ne=>ne.constraints),{panelSize:X,pivotIndices:Q}=Ir(_,U,P);Ae(X!=null,`Panel size not found for panel "${U.id}"`);const re=eo(_,U)===_.length-1?X-F:F-X,de=zo({delta:re,initialLayout:P,panelConstraints:H,pivotIndices:Q,prevLayout:P,trigger:"imperative-api"});Fs(P,de)||(v(de),S.current.layout=de,W&&W(de),Jr(_,de,y.current))},[]),q=d.useCallback((U,F)=>{const{layout:W,panelDataArray:P}=S.current,{collapsedSize:_=0,collapsible:H}=F,{collapsedSize:X=0,collapsible:Q,maxSize:oe=100,minSize:re=0}=U.constraints,{panelSize:de}=Ir(P,U,W);de!=null&&(H&&Q&&rr(de,_)?rr(_,X)||R(U,X):de<re?R(U,re):de>oe&&R(U,oe))},[R]),j=d.useCallback((U,F)=>{const{direction:W}=C.current,{layout:P}=S.current;if(!h.current)return;const _=Ba(U,h.current);Ae(_,`Drag handle element not found for id "${U}"`);const H=Jp(W,F);g({dragHandleId:U,dragHandleRect:_.getBoundingClientRect(),initialCursorPosition:H,initialLayout:P})},[]),I=d.useCallback(()=>{g(null)},[]),D=d.useCallback(U=>{const{panelDataArray:F}=S.current,W=eo(F,U);W>=0&&(F.splice(W,1),delete y.current[U.id],S.current.panelDataArrayChanged=!0,b())},[b]),z=d.useMemo(()=>({collapsePanel:N,direction:r,dragState:x,expandPanel:k,getPanelSize:M,getPanelStyle:L,groupId:m,isPanelCollapsed:O,isPanelExpanded:V,reevaluatePanelConstraints:q,registerPanel:K,registerResizeHandle:G,resizePanel:R,startDragging:j,stopDragging:I,unregisterPanel:D,panelGroupElement:h.current}),[N,x,r,k,M,L,m,O,V,q,K,G,R,j,I,D]),J={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return d.createElement($a.Provider,{value:z},d.createElement(p,{...f,children:t,className:n,id:a,ref:h,style:{...J,...u},[ot.group]:"",[ot.groupDirection]:r,[ot.groupId]:m}))}const rm=d.forwardRef((e,t)=>d.createElement(nm,{...e,forwardedRef:t}));nm.displayName="PanelGroup";rm.displayName="forwardRef(PanelGroup)";function eo(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Ir(e,t,n){const r=eo(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:a}}function fC({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){d.useEffect(()=>{if(e||n==null||r==null)return;const o=Ba(t,r);if(o==null)return;const a=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const l=o.getAttribute(ot.groupId);Ae(l,`No group element found for id "${l}"`);const c=es(l,r),u=qp(l,t,r);Ae(u!==null,`No resize element found for id "${t}"`);const p=i.shiftKey?u>0?u-1:c.length-1:u+1<c.length?u+1:0;c[p].focus();break}}};return o.addEventListener("keydown",a),()=>{o.removeEventListener("keydown",a)}},[r,e,t,n])}function om({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:a,onClick:i,onDragging:l,onFocus:c,onPointerDown:u,onPointerUp:p,style:f={},tabIndex:m=0,tagName:h="div",...x}){var g,w;const v=d.useRef(null),b=d.useRef({onClick:i,onDragging:l,onPointerDown:u,onPointerUp:p});d.useEffect(()=>{b.current.onClick=i,b.current.onDragging=l,b.current.onPointerDown=u,b.current.onPointerUp=p});const y=d.useContext($a);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:T,registerResizeHandle:C,startDragging:S,stopDragging:N,panelGroupElement:k}=y,M=ac(o),[L,O]=d.useState("inactive"),[V,K]=d.useState(!1),[G,R]=d.useState(null),q=d.useRef({state:L});Mr(()=>{q.current.state=L}),d.useEffect(()=>{if(n)R(null);else{const z=C(M);R(()=>z)}},[n,M,C]);const j=(g=r==null?void 0:r.coarse)!==null&&g!==void 0?g:15,I=(w=r==null?void 0:r.fine)!==null&&w!==void 0?w:5;d.useEffect(()=>{if(n||G==null)return;const z=v.current;Ae(z,"Element ref not attached");let J=!1;return X1(M,z,E,{coarse:j,fine:I},(F,W,P)=>{if(!W){O("inactive");return}switch(F){case"down":{O("drag"),J=!1,Ae(P,'Expected event to be defined for "down" action'),S(M,P);const{onDragging:_,onPointerDown:H}=b.current;_==null||_(!0),H==null||H();break}case"move":{const{state:_}=q.current;J=!0,_!=="drag"&&O("hover"),Ae(P,'Expected event to be defined for "move" action'),G(P);break}case"up":{O("hover"),N();const{onClick:_,onDragging:H,onPointerUp:X}=b.current;H==null||H(!1),X==null||X(),J||_==null||_();break}}})},[j,E,n,I,C,M,G,S,N]),fC({disabled:n,handleId:M,resizeHandler:G,panelGroupElement:k});const D={touchAction:"none",userSelect:"none"};return d.createElement(h,{...x,children:e,className:t,id:o,onBlur:()=>{K(!1),a==null||a()},onFocus:()=>{K(!0),c==null||c()},ref:v,role:"separator",style:{...D,...f},tabIndex:m,[ot.groupDirection]:E,[ot.groupId]:T,[ot.resizeHandle]:"",[ot.resizeHandleActive]:L==="drag"?"pointer":V?"keyboard":void 0,[ot.resizeHandleEnabled]:!n,[ot.resizeHandleId]:M,[ot.resizeHandleState]:L})}om.displayName="PanelResizeHandle";function sm({className:e,...t}){return s.jsx(rm,{"data-slot":"resizable-panel-group",className:ve("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Go({...e}){return s.jsx($p,{"data-slot":"resizable-panel",...e})}function Qi({withHandle:e,className:t,...n}){return s.jsx(om,{"data-slot":"resizable-handle",className:ve("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&s.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:s.jsx(_x,{className:"size-2.5"})})})}const pC=d.forwardRef(({className:e,...t},n)=>s.jsx("ul",{ref:n,className:ve("flex flex-row items-center gap-1",e),...t}));pC.displayName="PaginationContent";const mC=d.forwardRef(({className:e,...t},n)=>s.jsx("li",{ref:n,className:ve("",e),...t}));mC.displayName="PaginationItem";function hC({ref:e,anchorRef:t,onClickOutside:n,enabled:r=!0}){d.useEffect(()=>{if(!r)return;const o=a=>{const i=a.target,l=e.current&&!e.current.contains(i),c=t!=null&&t.current?!t.current.contains(i):!0;l&&c&&n()};return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[e,t,n,r])}function gC({onEscape:e,enabled:t=!0}){d.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[e,t])}const xC={x:0,y:0},mn=16,vC=["top-start","bottom-end","top-end"];function wC({anchorRef:e,placement:t="top-start",offset:n=xC,fallbackPlacements:r=vC}){const o=d.useCallback((c,u,p)=>{let f=0,m=0;switch(p){case"top":f=c.top-u.height-n.y,m=c.left+(c.width-u.width)/2+n.x;break;case"top-start":f=c.top-u.height-n.y,m=c.left+n.x;break;case"top-end":f=c.top-u.height-n.y,m=c.right-u.width-n.x;break;case"bottom":f=c.bottom+n.y,m=c.left+(c.width-u.width)/2+n.x;break;case"bottom-start":f=c.bottom+n.y,m=c.left+n.x;break;case"bottom-end":f=c.bottom+n.y,m=c.right-u.width-n.x;break;case"left":f=c.top+(c.height-u.height)/2+n.y,m=c.left-u.width-n.x;break;case"left-start":f=c.top+n.y,m=c.left-u.width-n.x;break;case"left-end":f=c.bottom-u.height-n.y,m=c.left-u.width-n.x;break;case"right":f=c.top+(c.height-u.height)/2+n.y,m=c.right+n.x;break;case"right-start":f=c.top+n.y,m=c.right+n.x;break;case"right-end":f=c.bottom-u.height-n.y,m=c.right+n.x;break}return console.log(`Calculated position for ${p}:`,{top:f,left:m}),{top:f,left:m,placement:p}},[n.x,n.y]),a=d.useCallback((c,u)=>{const p={width:window.innerWidth,height:window.innerHeight};return c.left<mn||c.top<mn||c.left+u.width>p.width-mn||c.top+u.height>p.height-mn},[]),i=d.useCallback(c=>{if(!e.current){const x={width:window.innerWidth,height:window.innerHeight};return{top:x.height/2-100,left:x.width/2-100,placement:t}}const u=e.current.getBoundingClientRect(),p=c.getBoundingClientRect(),f=o(u,p,t);if(!a(f,p))return f;for(const x of r){const g=o(u,p,x);if(!a(g,p))return g}const m={width:window.innerWidth,height:window.innerHeight},h={...f};return h.left<mn?h.left=mn:h.left+p.width>m.width-mn&&(h.left=m.width-p.width-mn),h.top<mn?h.top=mn:h.top+p.height>m.height-mn&&(h.top=m.height-p.height-mn),h},[e,t,r,o,a]);return{getPositionStyle:d.useCallback(c=>{const u=i(c);return{position:"fixed",top:u.top,left:u.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function bC({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:o}){const[a,i]=d.useState(e),[l,c]=d.useState(!1),u=d.useRef(0),p=d.useRef(e),f=d.useCallback(v=>{v.preventDefault(),c(!0),u.current=v.clientX,p.current=a},[a]),m=d.useCallback(v=>{if(!l)return;const b=v.clientX-u.current,y=r==="right"?-b:b,E=Math.min(Math.max(p.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),h=d.useCallback(()=>{c(!1)},[]),x=d.useCallback(v=>{v.preventDefault(),c(!0),u.current=v.touches[0].clientX,p.current=a},[a]),g=d.useCallback(v=>{if(!l)return;const b=v.touches[0].clientX-u.current,y=r==="right"?-b:b,E=Math.min(Math.max(p.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),w=d.useCallback(()=>{c(!1)},[]);return d.useEffect(()=>{if(l)return document.addEventListener("mousemove",m),document.addEventListener("mouseup",h),document.addEventListener("touchmove",g),document.addEventListener("touchend",w),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",h),document.removeEventListener("touchmove",g),document.removeEventListener("touchend",w),document.body.style.userSelect="",document.body.style.cursor=""}},[l,m,h,g,w]),{width:a,isResizing:l,handleMouseDown:f,handleTouchStart:x,setWidth:i}}const yC=d.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:o="left",resizable:a=!0,className:i,onWidthChange:l,...c},u)=>{const{width:p,isResizing:f,handleMouseDown:m,handleTouchStart:h}=bC({defaultWidth:t,minWidth:n,maxWidth:r,position:o,onWidthChange:l}),x={width:`${p}px`},g=o==="left"?"right-0":"left-0";return s.jsxs("div",{ref:u,className:ve("relative h-full flex-shrink-0 cursor-pointer",o==="left"?"border-r":"border-l",i),style:x,...c,children:[s.jsx("div",{className:ve("h-full overflow-x-hidden overflow-y-auto"),children:e}),a&&s.jsx("div",{className:ve("group absolute top-0 bottom-0 w-2",g,"cursor-col-resize","hover:bg-[var(--color-primary-wMain)]","transition-all duration-200",f&&"bg-[var(--color-primary-wMain)]"),onMouseDown:m,onTouchStart:h,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} panel`,tabIndex:0,onKeyDown:v=>{if(v.key==="ArrowLeft"||v.key==="ArrowRight"){v.preventDefault();const b=v.key==="ArrowRight"?10:-10,y=o==="right"?-b:b,E=Math.min(Math.max(p+y,n),r);l==null||l(E)}},children:s.jsx("div",{className:ve("absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 transform","bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]","group-hover:bg-[var(--color-primary-wMain)]","transition-colors duration-200",f&&"bg-[var(--color-primary-wMain)]")})})]})});yC.displayName="SidePanel";const am=d.createContext(null),im=d.createContext(void 0),lm=d.createContext(null),cm=d.createContext(null),dm=d.createContext(void 0),um=d.createContext(null);function _t(){const e=d.useContext(lm);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}const CC="https://solace.com/a2a/extensions/display-name",SC="https://solace.com/a2a/extensions/peer-agent-topology",EC="https://solace.com/a2a/extensions/sam/tools",NC=e=>{var o,a,i,l;let t,n,r;if((o=e.capabilities)!=null&&o.extensions){const c=e.capabilities.extensions.find(f=>f.uri===CC);(a=c==null?void 0:c.params)!=null&&a.display_name&&(t=c.params.display_name);const u=e.capabilities.extensions.find(f=>f.uri===SC);(i=u==null?void 0:u.params)!=null&&i.peer_agent_names&&(n=u.params.peer_agent_names);const p=e.capabilities.extensions.find(f=>f.uri===EC);(l=p==null?void 0:p.params)!=null&&l.tools&&(r=p.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},cc=()=>{const{configServerUrl:e}=_t(),[t,n]=d.useState([]),[r,o]=d.useState({}),[a,i]=d.useState(!0),[l,c]=d.useState(null),u=d.useCallback(async()=>{i(!0),c(null);try{const p=`${e}/api/v1`,f=await Ne(`${p}/agentCards`,{credentials:"include"});if(!f.ok){const g=await f.json().catch(()=>({message:`Failed to fetch agents: ${f.statusText}`}));throw new Error(g.message||`Failed to fetch agents: ${f.statusText}`)}const h=(await f.json()).map(NC);n(h);const x={};h.forEach(g=>{g.name&&(x[g.name]=g.displayName||g.name)}),o(x)}catch(p){console.error("Error fetching agents:",p),c(p instanceof Error?p.message:"Could not load agent information."),n([])}finally{i(!1)}},[e]);return d.useEffect(()=>{u()},[u]),d.useMemo(()=>({agents:t,agentNameMap:r,isLoading:a,error:l,refetch:u}),[t,r,a,l,u])};function jC(e,t){if(t&&t.toLowerCase().startsWith("text/"))return!0;if(!e)return!1;const n=e.toLowerCase();return!!(n.endsWith(".txt")||n.endsWith(".text")||n.endsWith(".sql")||n.endsWith(".xml")||n.endsWith(".toml")||n.endsWith(".ini")||n.endsWith(".conf")||n.endsWith(".config")||n.endsWith(".properties")||n.endsWith(".py")||n.endsWith(".js")||n.endsWith(".ts")||n.endsWith(".jsx")||n.endsWith(".tsx")||n.endsWith(".java")||n.endsWith(".c")||n.endsWith(".cpp")||n.endsWith(".h")||n.endsWith(".hpp")||n.endsWith(".cs")||n.endsWith(".go")||n.endsWith(".rs")||n.endsWith(".rb")||n.endsWith(".php")||n.endsWith(".swift")||n.endsWith(".kt")||n.endsWith(".scala")||n.endsWith(".sh")||n.endsWith(".bash")||n.endsWith(".zsh")||n.endsWith(".bat")||n.endsWith(".cmd")||n.endsWith(".ps1")||n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")||n.endsWith(".log")||n.endsWith(".env")||n.endsWith(".gitignore")||n.endsWith(".dockerignore")||n.endsWith(".editorconfig"))}function kC(e,t){if(t){const n=t.toLowerCase();if(n==="text/html"||n==="application/xhtml+xml")return!0}return e?e.toLowerCase().endsWith(".html")||e.toLowerCase().endsWith(".htm"):!1}function AC(e,t){if(t){const n=t.toLowerCase();if(n==="text/x-mermaid"||n==="application/x-mermaid")return!0}return e?e.toLowerCase().endsWith(".mermaid")||e.toLowerCase().endsWith(".mmd"):!1}function TC(e,t){if(t){const n=t.toLowerCase();if(n==="text/csv"||n==="application/csv")return!0}return e?e.toLowerCase().endsWith(".csv"):!1}function _C(e,t){if(t&&t.toLowerCase().startsWith("image/"))return!0;if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".gif")||n.endsWith(".bmp")||n.endsWith(".webp")||n.endsWith(".svg")}function IC(e,t){if(t){const n=t.toLowerCase();if(n==="application/json"||n==="text/json")return!0}return e?e.toLowerCase().endsWith(".json"):!1}function MC(e,t){if(t){const r=t.toLowerCase();if(r==="application/yaml"||r==="text/yaml"||r==="application/x-yaml"||r==="text/x-yaml")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".yaml")||n.endsWith(".yml")}function RC(e,t){if(t){const r=t.toLowerCase();if(r==="text/markdown"||r==="application/markdown"||r==="text/x-markdown")return!0}if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function PC(e,t){if(t&&t.toLowerCase().startsWith("audio/"))return!0;if(!e)return!1;const n=e.toLowerCase();return n.endsWith(".mp3")||n.endsWith(".wav")||n.endsWith(".ogg")||n.endsWith(".aac")||n.endsWith(".flac")||n.endsWith(".m4a")}function kn(e,t){return kC(e,t)?"html":AC(e,t)?"mermaid":_C(e,t)?"image":RC(e,t)?"markdown":PC(e,t)?"audio":IC(e,t)?"json":MC(e,t)?"yaml":TC(e,t)?"csv":jC(e,t)?"text":null}function fm(e){try{const t=Uint8Array.from(atob(e),n=>n.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!1}).decode(t)}catch(t){console.warn("TextDecoder failed (potentially non-UTF8 data), falling back to simple atob:",t);try{return atob(e)}catch(n){return console.error("Failed to decode base64 content with atob fallback:",n),e}}}const pm=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],DC=["image","audio"],mm=e=>{if(!e||!e.content)return"";const t=kn(e.name,e.mime_type);if(!t||!pm.includes(t))return"";if(DC.includes(t))return e.content;if(e.isPlainText)return console.log("Content is plain text from streaming, returning as-is"),e.content;try{return fm(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},hm=5*1024*1024,LC=Ta(hm);function OC(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=kn(e.filename,e.mime_type);return!t||!pm.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>hm?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${LC}.`}:{canPreview:!0}}const gm=(e,t="h-4 w-4")=>{if(!e)return s.jsx(Di,{className:t});switch(kn(e.filename,e.mime_type)){case"image":case"mermaid":return s.jsx(Fi,{className:t});case"audio":return s.jsx(Oi,{className:t});case"html":return s.jsx(Tu,{className:t});case"text":return s.jsx(or,{className:t});case"csv":return s.jsx(Li,{className:t});case"json":return s.jsx(Ix,{className:t});default:return s.jsx(Di,{className:t})}},FC=(e,t)=>{const n=kn(e,t);return n==="image"||n==="audio"},$C=(e,t)=>{const n=kn(e,t);return n?["text","markdown","json","yaml","csv","html","image","audio"].includes(n):!1},zC=({filename:e,mimeType:t,shouldAutoExpand:n})=>{const r=d.useMemo(()=>FC(e,t),[e,t]),[o,a]=d.useState(()=>n??r),i=d.useMemo(()=>$C(e,t),[e,t]),l=d.useMemo(()=>i?o:!1,[i,o]),c=d.useMemo(()=>i,[i]),u=d.useCallback(()=>{if(!e||!c){console.log(`[useArtifactRendering] Toggle blocked - filename: ${e}, isExpandable: ${c}`);return}a(p=>{const f=!p;return console.log(`[useArtifactRendering] ${f?"Expanding":"Collapsing"} ${e}`),f})},[e,c]);return{shouldRender:l,isExpandable:c,isExpanded:o,toggleExpanded:u}},xm=d.createContext(void 0);let el=null;const UC=e=>{el=e},BC=({children:e})=>{const{configServerUrl:t,projectsEnabled:n}=_t(),[r,o]=d.useState([]),[a,i]=d.useState(!0),[l,c]=d.useState(null),[u,p]=d.useState(null),[f,m]=d.useState(null),[h,x]=d.useState(null),g=`${t}/api/v1`,w=d.useCallback(async()=>{if(!n){i(!1),o([]);return}i(!0),c(null);try{const S=await Ne(`${g}/projects`,{credentials:"include"});if(!S.ok){const M=await S.json().catch(()=>({detail:`Failed to fetch projects: ${S.statusText}`}));throw new Error(M.detail||`Failed to fetch projects: ${S.statusText}`)}const k=[...(await S.json()).projects].sort((M,L)=>{const O=new Date(M.updatedAt||M.createdAt).getTime();return new Date(L.updatedAt||L.createdAt).getTime()-O});o(k)}catch(S){console.error("Error fetching projects:",S),c(S instanceof Error?S.message:"Could not load projects."),o([])}finally{i(!1)}},[g,n]),v=d.useCallback(async S=>{if(!n)throw new Error("Projects feature is disabled");try{const N=await Ne(`${g}/projects`,{method:"POST",body:S,credentials:"include"});if(!N.ok){const M=await N.text();let L=`Failed to create project: ${N.statusText}`;try{const O=JSON.parse(M);L=O.detail||O.message||L}catch{M&&M.length<200&&(L=M)}throw new Error(L)}const k=await N.json();return o(M=>[k,...M]),k}catch(N){const k=N instanceof Error?N.message:"Could not create project.";throw new Error(k)}},[g,n]),b=d.useCallback(async(S,N)=>{if(!n)throw new Error("Projects feature is disabled");try{const k=await Ne(`${g}/projects/${S}/artifacts`,{method:"POST",body:N,credentials:"include"});if(!k.ok){const M=await k.json().catch(()=>({detail:`Failed to add files: ${k.statusText}`}));throw new Error(M.detail||`Failed to add files: ${k.statusText}`)}c(null)}catch(k){console.error("Error adding files to project:",k);const M=k instanceof Error?k.message:"Could not add files to project.";throw new Error(M)}},[g,n]),y=d.useCallback(async(S,N)=>{if(!n)throw new Error("Projects feature is disabled");try{const k=await Ne(`${g}/projects/${S}/artifacts/${encodeURIComponent(N)}`,{method:"DELETE",credentials:"include"});if(!k.ok&&k.status!==204){const M=await k.json().catch(()=>({detail:`Failed to remove file: ${k.statusText}`}));throw new Error(M.detail||`Failed to remove file: ${k.statusText}`)}c(null)}catch(k){console.error("Error removing file from project:",k);const M=k instanceof Error?k.message:"Could not remove file from project.";throw new Error(M)}},[g,n]),E=d.useCallback(async(S,N)=>{if(!n)throw new Error("Projects feature is disabled");try{const k=await Ne(`${g}/projects/${S}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(N),credentials:"include"});if(!k.ok){let L=`Failed to update project: ${k.statusText}`;try{const O=await k.json();k.status===422?O.detail&&(Array.isArray(O.detail)?L=`Validation error: ${O.detail.map(K=>{var R;return`${((R=K.loc)==null?void 0:R.join("."))||"field"}: ${K.msg}`}).join(", ")}`:typeof O.detail=="string"&&(L=O.detail)):L=O.detail||O.message||L}catch{}throw new Error(L)}const M=await k.json();return o(L=>L.map(V=>V.id===M.id?M:V).sort((V,K)=>{const G=new Date(V.updatedAt||V.createdAt).getTime();return new Date(K.updatedAt||K.createdAt).getTime()-G})),p(L=>(L==null?void 0:L.id)===M.id?M:L),m(L=>(L==null?void 0:L.id)===M.id?M:L),x(L=>(L==null?void 0:L.id)===M.id?M:L),c(null),M}catch(k){console.error("Error updating project:",k);const M=k instanceof Error?k.message:"Could not update project.";throw new Error(M)}},[g,n]),T=d.useCallback(async S=>{if(!n)throw new Error("Projects feature is disabled");try{const N=await Ne(`${g}/projects/${S}`,{method:"DELETE",credentials:"include"});if(!N.ok&&N.status!==204){const k=await N.json().catch(()=>({detail:`Failed to delete project: ${N.statusText}`}));throw new Error(k.detail||`Failed to delete project: ${N.statusText}`)}o(k=>k.filter(M=>M.id!==S)),p(k=>(k==null?void 0:k.id)===S?null:k),m(k=>(k==null?void 0:k.id)===S?null:k),x(k=>(k==null?void 0:k.id)===S?null:k),c(null),el&&el(S)}catch(N){console.error("Error deleting project:",N);const k=N instanceof Error?N.message:"Could not delete project.";throw new Error(k)}},[g,n]);d.useEffect(()=>{w()},[w]);const C={projects:r,isLoading:a,error:l,createProject:v,refetch:w,currentProject:u,setCurrentProject:p,selectedProject:f,setSelectedProject:m,activeProject:h,setActiveProject:x,addFilesToProject:b,removeFileFromProject:y,updateProject:E,deleteProject:T};return s.jsx(xm.Provider,{value:C,children:e})},Jn=()=>{const e=d.useContext(xm);if(e===void 0)throw new Error("useProjectContext must be used within a ProjectProvider");return e},HC=e=>{const{configServerUrl:t}=_t(),{activeProject:n}=Jn(),[r,o]=d.useState([]),[a,i]=d.useState(!0),[l,c]=d.useState(null),u=`${t}/api/v1`,p=d.useCallback(async()=>{i(!0),c(null);try{let f;if(e&&e.trim()&&e!=="null"&&e!=="undefined")f=`${u}/artifacts/${e}`;else if(n!=null&&n.id)f=`${u}/artifacts/null?project_id=${n.id}`;else{o([]),i(!1);return}const m=await Ne(f,{credentials:"include"});if(!m.ok){const g=await m.json().catch(()=>({message:`Failed to fetch artifacts. ${m.statusText}`}));throw new Error(g.message||`Failed to fetch artifacts. ${m.statusText}`)}const x=(await m.json()).map(g=>({...g,uri:g.uri||`artifact://${e}/${g.filename}`}));o(x)}catch(f){const m=f instanceof Error?f.message:"Failed to fetch artifacts.";c(m),o([])}finally{i(!1)}},[u,e,n==null?void 0:n.id]);return d.useEffect(()=>{p()},[p]),{artifacts:r,isLoading:a,error:l,refetch:p,setArtifacts:o}},WC=()=>{const e=d.useContext(am);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},qe=()=>{const e=d.useContext(im);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e};function VC(){const{messages:e}=qe(),t=_t(),n=d.useCallback(r=>{if((t==null?void 0:t.persistenceEnabled)===!1&&!(e.length<=1))return r.preventDefault(),"Are you sure you want to leave? Your chat history will be lost."},[e.length,t==null?void 0:t.persistenceEnabled]);d.useEffect(()=>(window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}),[n])}function vm(){const e=d.useContext(cm);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function GC(e,t){const[n,r]=d.useState(e);return d.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const YC=async(e,t,n,r)=>{let o;if(t&&t.trim()&&t!=="null"&&t!=="undefined")o=`${e}/api/v1/artifacts/${t}/${encodeURIComponent(r.filename)}`;else if(n)o=`${e}/api/v1/artifacts/null/${encodeURIComponent(r.filename)}?project_id=${n}`;else throw new Error("No valid context for artifact download");const a=await Ne(o,{credentials:"include"});if(!a.ok)throw new Error(`Failed to download artifact: ${r.filename}. Status: ${a.status}`);const i=await a.blob();hf(i,r.filename)},dc=e=>{const{configServerUrl:t}=_t(),{addNotification:n,sessionId:r}=qe(),{activeProject:o}=Jn();return{onDownload:async i=>{const l=r&&r.trim()&&r!=="null"&&r!=="undefined",c=e||(o==null?void 0:o.id);if(!l&&!!!c){n("Cannot download artifact: No active session or project.","error");return}try{await YC(t,r,c||null,i),n(`Downloaded artifact: ${i.filename}.`)}catch{n(`Failed to download artifact: ${i.filename}.`,"error")}}}},KC=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,o]=d.useState(!1),a=d.useRef(0),i=d.useCallback(p=>{n||(p.preventDefault(),p.stopPropagation(),a.current=(a.current||0)+1,p.dataTransfer.types.includes("Files")&&o(!0))},[n,a]),l=d.useCallback(p=>{n||(p.preventDefault(),p.stopPropagation(),p.dataTransfer.types.includes("Files")&&(p.dataTransfer.dropEffect="copy"))},[n]),c=d.useCallback(p=>{n||(p.preventDefault(),p.stopPropagation(),a.current=(a.current||0)-1,a.current===0&&o(!1))},[n,a]),u=d.useCallback(p=>{if(n||(p.preventDefault(),p.stopPropagation(),o(!1),a.current=0,!p.dataTransfer.files||p.dataTransfer.files.length===0))return;const f=Array.from(p.dataTransfer.files),m=t?f.filter(t):f;m.length!==0&&e(m)},[n,a,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:u}},uc=()=>{const e=d.useContext(dm);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function Ha(){const e=d.useContext(um);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}const qC=e=>{const{configServerUrl:t}=_t(),[n,r]=d.useState([]),[o,a]=d.useState(!0),[i,l]=d.useState(null),c=`${t}/api/v1`,u=d.useCallback(async()=>{if(!e){r([]),a(!1);return}a(!0),l(null);try{const p=`${c}/sessions?project_id=${e}&pageNumber=1&pageSize=100`,f=await Ne(p,{credentials:"include"});if(!f.ok){const h=await f.json().catch(()=>({detail:`Failed to fetch sessions. ${f.statusText}`}));throw new Error(h.detail||`Failed to fetch sessions. ${f.statusText}`)}const m=await f.json();r(m.data||[])}catch(p){const f=p instanceof Error?p.message:"Failed to fetch sessions.";l(f),r([])}finally{a(!1)}},[c,e]);return d.useEffect(()=>{u();const p=()=>{u()},f=()=>{u()};return window.addEventListener("session-moved",p),window.addEventListener("new-chat-session",f),()=>{window.removeEventListener("session-moved",p),window.removeEventListener("new-chat-session",f)}},[u]),{sessions:n,isLoading:o,error:i,refetch:u}},XC=()=>{const{agents:e,sessionId:t,setMessages:n,setSelectedAgentName:r}=qe();return{handleAgentSelection:d.useCallback(a=>{if(a){const i=e.find(l=>l.name===a);if(i){r(a);const l=`Hi! I'm the ${i.displayName}. How can I help?`;n(c=>[...c,{parts:[{kind:"text",text:l}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:t||"",lastProcessedEventSequence:0}}])}else console.warn(`Selected agent not found: ${a}`)}},[e,t,n,r])}};d.createContext(null);function fc(e){const t=e+"CollectionProvider",[n,r]=In(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:w,children:v}=g,b=jt.useRef(null),y=jt.useRef(new Map).current;return s.jsx(o,{scope:w,itemMap:y,collectionRef:b,children:v})};i.displayName=t;const l=e+"CollectionSlot",c=vr(l),u=jt.forwardRef((g,w)=>{const{scope:v,children:b}=g,y=a(l,v),E=Le(w,y.collectionRef);return s.jsx(c,{ref:E,children:b})});u.displayName=l;const p=e+"CollectionItemSlot",f="data-radix-collection-item",m=vr(p),h=jt.forwardRef((g,w)=>{const{scope:v,children:b,...y}=g,E=jt.useRef(null),T=Le(w,E),C=a(p,v);return jt.useEffect(()=>(C.itemMap.set(E,{ref:E,...y}),()=>void C.itemMap.delete(E))),s.jsx(m,{[f]:"",ref:T,children:b})});h.displayName=p;function x(g){const w=a(e+"CollectionConsumer",g);return jt.useCallback(()=>{const b=w.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((C,S)=>y.indexOf(C.ref.current)-y.indexOf(S.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:i,Slot:u,ItemSlot:h},x,r]}var ZC=d.createContext(void 0);function Wa(e){const t=d.useContext(ZC);return e||t||"ltr"}const pc=d.forwardRef(({actions:e,className:t,...n},r)=>{const o=(i,l)=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l.onClick())},a=(i,l)=>{var u,p,f,m,h;const c=(u=i.currentTarget.parentElement)==null?void 0:u.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const x=(l+1)%c.length;(p=c[x])==null||p.focus();break}case"ArrowUp":{i.preventDefault();const x=(l-1+c.length)%c.length;(f=c[x])==null||f.focus();break}case"Home":i.preventDefault(),(m=c[0])==null||m.focus();break;case"End":i.preventDefault(),(h=c[c.length-1])==null||h.focus();break;case"Escape":i.preventDefault(),i.currentTarget.blur();break}};return s.jsx("div",{ref:r,role:"menu",className:ve("min-w-[8rem] overflow-hidden",t),...n,children:e.map((i,l)=>s.jsxs(d.Fragment,{children:[i.divider&&l>0&&s.jsx("div",{className:"my-1 h-px bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]"}),s.jsxs("div",{role:"menuitem",tabIndex:0,"data-disabled":i.disabled,className:ve("relative my-1.5 flex cursor-pointer items-center gap-2 px-3 py-1.5 text-sm transition-colors select-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)]"),onClick:i.onClick,onKeyDown:c=>{o(c,i),a(c,l)},children:[i.icon&&i.iconPosition!=="right"&&s.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon}),s.jsx("span",{className:"flex-1",children:i.label}),i.icon&&i.iconPosition==="right"&&s.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon})]})]},i.id))})});pc.displayName="Menu";var Va="Popover",[wm,W_]=In(Va,[So]),ws=So(),[JC,kr]=wm(Va),bm=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,l=ws(t),c=d.useRef(null),[u,p]=d.useState(!1),[f,m]=yr({prop:r,defaultProp:o??!1,onChange:a,caller:Va});return s.jsx(Gl,{...l,children:s.jsx(JC,{scope:t,contentId:hn(),triggerRef:c,open:f,onOpenChange:m,onOpenToggle:d.useCallback(()=>m(h=>!h),[m]),hasCustomAnchor:u,onCustomAnchorAdd:d.useCallback(()=>p(!0),[]),onCustomAnchorRemove:d.useCallback(()=>p(!1),[]),modal:i,children:n})})};bm.displayName=Va;var ym="PopoverAnchor",QC=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=kr(ym,n),a=ws(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return d.useEffect(()=>(i(),()=>l()),[i,l]),s.jsx(Ra,{...a,...r,ref:t})});QC.displayName=ym;var Cm="PopoverTrigger",Sm=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=kr(Cm,n),a=ws(n),i=Le(t,o.triggerRef),l=s.jsx(Se.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Am(o.open),...r,ref:i,onClick:xe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:s.jsx(Ra,{asChild:!0,...a,children:l})});Sm.displayName=Cm;var mc="PopoverPortal",[eS,tS]=wm(mc,{forceMount:void 0}),Em=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,a=kr(mc,t);return s.jsx(eS,{scope:t,forceMount:n,children:s.jsx(sn,{present:n||a.open,children:s.jsx(Eo,{asChild:!0,container:o,children:r})})})};Em.displayName=mc;var fo="PopoverContent",Nm=d.forwardRef((e,t)=>{const n=tS(fo,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,a=kr(fo,e.__scopePopover);return s.jsx(sn,{present:r||a.open,children:a.modal?s.jsx(rS,{...o,ref:t}):s.jsx(oS,{...o,ref:t})})});Nm.displayName=fo;var nS=vr("PopoverContent.RemoveScroll"),rS=d.forwardRef((e,t)=>{const n=kr(fo,e.__scopePopover),r=d.useRef(null),o=Le(t,r),a=d.useRef(!1);return d.useEffect(()=>{const i=r.current;if(i)return Oa(i)},[]),s.jsx(vs,{as:nS,allowPinchZoom:!0,children:s.jsx(jm,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),a.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;a.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),oS=d.forwardRef((e,t)=>{const n=kr(fo,e.__scopePopover),r=d.useRef(!1),o=d.useRef(!1);return s.jsx(jm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),jm=d.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,...f}=e,m=kr(fo,n),h=ws(n);return tc(),s.jsx(xs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(ms,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:p,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:s.jsx(Yl,{"data-state":Am(m.open),role:"dialog",id:m.contentId,...h,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),km="PopoverClose",sS=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=kr(km,n);return s.jsx(Se.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});sS.displayName=km;var aS="PopoverArrow",iS=d.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ws(n);return s.jsx(Kl,{...o,...r,ref:t})});iS.displayName=aS;function Am(e){return e?"open":"closed"}var lS=bm,cS=Sm,dS=Em,uS=Nm;function Tm({...e}){return s.jsx(lS,{"data-slot":"popover",...e})}function _m({...e}){return s.jsx(cS,{"data-slot":"popover-trigger",...e})}function Im({className:e,align:t="center",sideOffset:n=4,...r}){return s.jsx(dS,{children:s.jsx(uS,{"data-slot":"popover-content",align:t,sideOffset:n,className:ve("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background z-50 w-auto origin-(--radix-popover-content-transform-origin) rounded-sm border px-0 py-1 shadow-sm outline-hidden",e),...r})})}function fS({isOpen:e,onClose:t,anchorRef:n,children:r,placement:o="bottom-start",offset:a,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:u=!0,animationDuration:p=150,fallbackPlacements:f}){const m=d.useRef(null),[h,x]=d.useState({}),[g,w]=d.useState(!1);hC({ref:m,anchorRef:n,onClickOutside:t,enabled:e&&l}),gC({onEscape:t,enabled:e&&c});const{getPositionStyle:v}=wC({anchorRef:n,placement:o,offset:a,fallbackPlacements:f});if(d.useEffect(()=>{e&&m.current?(w(!1),requestAnimationFrame(()=>{if(m.current){const y=v(m.current);x(y),w(!0)}})):w(!1)},[e,v]),!e)return null;const b=s.jsx("div",{ref:m,role:"dialog","aria-modal":"false",className:ve("bg-background min-w-[8rem] overflow-hidden border shadow-md",i),style:{...h,opacity:e&&g?1:0,transform:`scale(${e&&g?1:.95})`,transition:`opacity ${p}ms ease-in-out, transform ${p}ms ease-in-out`,pointerEvents:e&&g?"auto":"none",visibility:g?"visible":"hidden"},children:r});return u?ls.createPortal(b,document.body):b}function $d(e,[t,n]){return Math.min(n,Math.max(t,e))}function ct(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}var pS="DismissableLayer",tl="dismissableLayer.update",mS="dismissableLayer.pointerDownOutside",hS="dismissableLayer.focusOutside",zd,Mm=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Rm=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=d.useContext(Mm),[p,f]=d.useState(null),m=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=d.useState({}),x=Le(t,S=>f(S)),g=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(w),b=p?g.indexOf(p):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=v,T=vS(S=>{const N=S.target,k=[...u.branches].some(M=>M.contains(N));!E||k||(o==null||o(S),i==null||i(S),S.defaultPrevented||l==null||l())},m),C=wS(S=>{const N=S.target;[...u.branches].some(M=>M.contains(N))||(a==null||a(S),i==null||i(S),S.defaultPrevented||l==null||l())},m);return vf(S=>{b===u.layers.size-1&&(r==null||r(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},m),d.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(zd=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),Ud(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=zd)}},[p,m,n,u]),d.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),Ud())},[p,u]),d.useEffect(()=>{const S=()=>h({});return document.addEventListener(tl,S),()=>document.removeEventListener(tl,S)},[]),s.jsx(Se.div,{...c,ref:x,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:ct(e.onFocusCapture,C.onFocusCapture),onBlurCapture:ct(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:ct(e.onPointerDownCapture,T.onPointerDownCapture)})});Rm.displayName=pS;var gS="DismissableLayerBranch",xS=d.forwardRef((e,t)=>{const n=d.useContext(Mm),r=d.useRef(null),o=Le(t,r);return d.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(Se.div,{...e,ref:o})});xS.displayName=gS;function vS(e,t=globalThis==null?void 0:globalThis.document){const n=on(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){Pm(mS,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function wS(e,t=globalThis==null?void 0:globalThis.document){const n=on(e),r=d.useRef(!1);return d.useEffect(()=>{const o=a=>{a.target&&!r.current&&Pm(hS,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Ud(){const e=new CustomEvent(tl);document.dispatchEvent(e)}function Pm(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ll(o,a):o.dispatchEvent(a)}var Si=0;function bS(){d.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Bd()),document.body.insertAdjacentElement("beforeend",e[1]??Bd()),Si++,()=>{Si===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Si--}},[])}function Bd(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var hc="Popper",[Dm,Lm]=In(hc),[yS,Om]=Dm(hc),Fm=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return s.jsx(yS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Fm.displayName=hc;var $m="PopperAnchor",zm=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Om($m,n),i=d.useRef(null),l=Le(t,i),c=d.useRef(null);return d.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&a.onAnchorChange(c.current)}),r?null:s.jsx(Se.div,{...o,ref:l})});zm.displayName=$m;var gc="PopperContent",[CS,SS]=Dm(gc),Um=d.forwardRef((e,t)=>{var _,H,X,Q,oe,re;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:x,...g}=e,w=Om(gc,n),[v,b]=d.useState(null),y=Le(t,de=>b(de)),[E,T]=d.useState(null),C=Hf(E),S=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,k=r+(a!=="center"?"-"+a:""),M=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},L=Array.isArray(u)?u:[u],O=L.length>0,V={padding:M,boundary:L.filter(NS),altBoundary:O},{refs:K,floatingStyles:G,placement:R,isPositioned:q,middlewareData:j}=Rf({strategy:"fixed",placement:k,whileElementsMounted:(...de)=>If(...de,{animationFrame:h==="always"}),elements:{reference:w.anchor},middleware:[Pf({mainAxis:o+N,alignmentAxis:i}),c&&Df({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Lf():void 0,...V}),c&&Of({...V}),Ff({...V,apply:({elements:de,rects:ne,availableWidth:ue,availableHeight:Oe})=>{const{width:De,height:Te}=ne.reference,Be=de.floating.style;Be.setProperty("--radix-popper-available-width",`${ue}px`),Be.setProperty("--radix-popper-available-height",`${Oe}px`),Be.setProperty("--radix-popper-anchor-width",`${De}px`),Be.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),E&&zf({element:E,padding:l}),jS({arrowWidth:S,arrowHeight:N}),m&&$f({strategy:"referenceHidden",...V})]}),[I,D]=Wm(R),z=on(x);St(()=>{q&&(z==null||z())},[q,z]);const J=(_=j.arrow)==null?void 0:_.x,U=(H=j.arrow)==null?void 0:H.y,F=((X=j.arrow)==null?void 0:X.centerOffset)!==0,[W,P]=d.useState();return St(()=>{v&&P(window.getComputedStyle(v).zIndex)},[v]),s.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:q?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(Q=j.transformOrigin)==null?void 0:Q.x,(oe=j.transformOrigin)==null?void 0:oe.y].join(" "),...((re=j.hide)==null?void 0:re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(CS,{scope:n,placedSide:I,onArrowChange:T,arrowX:J,arrowY:U,shouldHideArrow:F,children:s.jsx(Se.div,{"data-side":I,"data-align":D,...g,ref:y,style:{...g.style,animation:q?void 0:"none"}})})})});Um.displayName=gc;var Bm="PopperArrow",ES={top:"bottom",right:"left",bottom:"top",left:"right"},Hm=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=SS(Bm,r),i=ES[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Bf,{...o,ref:n,style:{...o.style,display:"block"}})})});Hm.displayName=Bm;function NS(e){return e!==null}var jS=e=>({name:"transformOrigin",options:e,fn(t){var w,v,b;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,p]=Wm(n),f={start:"0%",center:"50%",end:"100%"}[p],m=(((v=o.arrow)==null?void 0:v.x)??0)+l/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=i?f:`${m}px`,g=`${-c}px`):u==="top"?(x=i?f:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=i?f:`${h}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=i?f:`${h}px`),{data:{x,y:g}}}});function Wm(e){const[t,n="center"]=e.split("-");return[t,n]}var kS=Fm,AS=zm,TS=Um,_S=Hm;function IS(e){const t=d.useRef({value:e,previous:e});return d.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var MS=[" ","Enter","ArrowUp","ArrowDown"],RS=[" ","Enter"],Or="Select",[Ga,Ya,PS]=fc(Or),[No,V_]=In(Or,[PS,Lm]),Ka=Lm(),[DS,Ar]=No(Or),[LS,OS]=No(Or),Vm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:l,onValueChange:c,dir:u,name:p,autoComplete:f,disabled:m,required:h,form:x}=e,g=Ka(t),[w,v]=d.useState(null),[b,y]=d.useState(null),[E,T]=d.useState(!1),C=Wa(u),[S,N]=yr({prop:r,defaultProp:o??!1,onChange:a,caller:Or}),[k,M]=yr({prop:i,defaultProp:l,onChange:c,caller:Or}),L=d.useRef(null),O=w?x||!!w.closest("form"):!0,[V,K]=d.useState(new Set),G=Array.from(V).map(R=>R.props.value).join(";");return s.jsx(kS,{...g,children:s.jsxs(DS,{required:h,scope:t,trigger:w,onTriggerChange:v,valueNode:b,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:hn(),value:k,onValueChange:M,open:S,onOpenChange:N,dir:C,triggerPointerDownPosRef:L,disabled:m,children:[s.jsx(Ga.Provider,{scope:t,children:s.jsx(LS,{scope:e.__scopeSelect,onNativeOptionAdd:d.useCallback(R=>{K(q=>new Set(q).add(R))},[]),onNativeOptionRemove:d.useCallback(R=>{K(q=>{const j=new Set(q);return j.delete(R),j})},[]),children:n})}),O?s.jsxs(ph,{"aria-hidden":!0,required:h,tabIndex:-1,name:p,autoComplete:f,value:k,onChange:R=>M(R.target.value),disabled:m,form:x,children:[k===void 0?s.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};Vm.displayName=Or;var Gm="SelectTrigger",Ym=d.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=Ka(n),i=Ar(Gm,n),l=i.disabled||r,c=Le(t,i.onTriggerChange),u=Ya(n),p=d.useRef("touch"),[f,m,h]=hh(g=>{const w=u().filter(y=>!y.disabled),v=w.find(y=>y.value===i.value),b=gh(w,g,v);b!==void 0&&i.onValueChange(b.value)}),x=g=>{l||(i.onOpenChange(!0),h()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return s.jsx(AS,{asChild:!0,...a,children:s.jsx(Se.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":mh(i.value)?"":void 0,...o,ref:c,onClick:ct(o.onClick,g=>{g.currentTarget.focus(),p.current!=="mouse"&&x(g)}),onPointerDown:ct(o.onPointerDown,g=>{p.current=g.pointerType;const w=g.target;w.hasPointerCapture(g.pointerId)&&w.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:ct(o.onKeyDown,g=>{const w=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(w&&g.key===" ")&&MS.includes(g.key)&&(x(),g.preventDefault())})})})});Ym.displayName=Gm;var Km="SelectValue",qm=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...l}=e,c=Ar(Km,n),{onValueNodeHasChildrenChange:u}=c,p=a!==void 0,f=Le(t,c.onValueNodeChange);return St(()=>{u(p)},[u,p]),s.jsx(Se.span,{...l,ref:f,style:{pointerEvents:"none"},children:mh(c.value)?s.jsx(s.Fragment,{children:i}):a})});qm.displayName=Km;var FS="SelectIcon",Xm=d.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(Se.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Xm.displayName=FS;var $S="SelectPortal",Zm=e=>s.jsx(Eo,{asChild:!0,...e});Zm.displayName=$S;var Fr="SelectContent",Jm=d.forwardRef((e,t)=>{const n=Ar(Fr,e.__scopeSelect),[r,o]=d.useState();if(St(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?ls.createPortal(s.jsx(Qm,{scope:e.__scopeSelect,children:s.jsx(Ga.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),a):null}return s.jsx(eh,{...e,ref:t})});Jm.displayName=Fr;var Nn=10,[Qm,Tr]=No(Fr),zS="SelectContentImpl",US=vr("SelectContent.RemoveScroll"),eh=d.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:l,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:x,hideWhenDetached:g,avoidCollisions:w,...v}=e,b=Ar(Fr,n),[y,E]=d.useState(null),[T,C]=d.useState(null),S=Le(t,_=>E(_)),[N,k]=d.useState(null),[M,L]=d.useState(null),O=Ya(n),[V,K]=d.useState(!1),G=d.useRef(!1);d.useEffect(()=>{if(y)return Oa(y)},[y]),bS();const R=d.useCallback(_=>{const[H,...X]=O().map(re=>re.ref.current),[Q]=X.slice(-1),oe=document.activeElement;for(const re of _)if(re===oe||(re==null||re.scrollIntoView({block:"nearest"}),re===H&&T&&(T.scrollTop=0),re===Q&&T&&(T.scrollTop=T.scrollHeight),re==null||re.focus(),document.activeElement!==oe))return},[O,T]),q=d.useCallback(()=>R([N,y]),[R,N,y]);d.useEffect(()=>{V&&q()},[V,q]);const{onOpenChange:j,triggerPointerDownPosRef:I}=b;d.useEffect(()=>{if(y){let _={x:0,y:0};const H=Q=>{var oe,re;_={x:Math.abs(Math.round(Q.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((re=I.current)==null?void 0:re.y)??0))}},X=Q=>{_.x<=10&&_.y<=10?Q.preventDefault():y.contains(Q.target)||j(!1),document.removeEventListener("pointermove",H),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",H),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",H),document.removeEventListener("pointerup",X,{capture:!0})}}},[y,j,I]),d.useEffect(()=>{const _=()=>j(!1);return window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{window.removeEventListener("blur",_),window.removeEventListener("resize",_)}},[j]);const[D,z]=hh(_=>{const H=O().filter(oe=>!oe.disabled),X=H.find(oe=>oe.ref.current===document.activeElement),Q=gh(H,_,X);Q&&setTimeout(()=>Q.ref.current.focus())}),J=d.useCallback((_,H,X)=>{const Q=!G.current&&!X;(b.value!==void 0&&b.value===H||Q)&&(k(_),Q&&(G.current=!0))},[b.value]),U=d.useCallback(()=>y==null?void 0:y.focus(),[y]),F=d.useCallback((_,H,X)=>{const Q=!G.current&&!X;(b.value!==void 0&&b.value===H||Q)&&L(_)},[b.value]),W=r==="popper"?nl:th,P=W===nl?{side:l,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:x,hideWhenDetached:g,avoidCollisions:w}:{};return s.jsx(Qm,{scope:n,content:y,viewport:T,onViewportChange:C,itemRefCallback:J,selectedItem:N,onItemLeave:U,itemTextRefCallback:F,focusSelectedItem:q,selectedItemText:M,position:r,isPositioned:V,searchRef:D,children:s.jsx(vs,{as:US,allowPinchZoom:!0,children:s.jsx(xs,{asChild:!0,trapped:b.open,onMountAutoFocus:_=>{_.preventDefault()},onUnmountAutoFocus:ct(o,_=>{var H;(H=b.trigger)==null||H.focus({preventScroll:!0}),_.preventDefault()}),children:s.jsx(Rm,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:_=>_.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:s.jsx(W,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:_=>_.preventDefault(),...v,...P,onPlaced:()=>K(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:ct(v.onKeyDown,_=>{const H=_.ctrlKey||_.altKey||_.metaKey;if(_.key==="Tab"&&_.preventDefault(),!H&&_.key.length===1&&z(_.key),["ArrowUp","ArrowDown","Home","End"].includes(_.key)){let Q=O().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(_.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(_.key)){const oe=_.target,re=Q.indexOf(oe);Q=Q.slice(re+1)}setTimeout(()=>R(Q)),_.preventDefault()}})})})})})})});eh.displayName=zS;var BS="SelectItemAlignedPosition",th=d.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=Ar(Fr,n),i=Tr(Fr,n),[l,c]=d.useState(null),[u,p]=d.useState(null),f=Le(t,S=>p(S)),m=Ya(n),h=d.useRef(!1),x=d.useRef(!0),{viewport:g,selectedItem:w,selectedItemText:v,focusSelectedItem:b}=i,y=d.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&u&&g&&w&&v){const S=a.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),k=a.valueNode.getBoundingClientRect(),M=v.getBoundingClientRect();if(a.dir!=="rtl"){const oe=M.left-N.left,re=k.left-oe,de=S.left-re,ne=S.width+de,ue=Math.max(ne,N.width),Oe=window.innerWidth-Nn,De=$d(re,[Nn,Math.max(Nn,Oe-ue)]);l.style.minWidth=ne+"px",l.style.left=De+"px"}else{const oe=N.right-M.right,re=window.innerWidth-k.right-oe,de=window.innerWidth-S.right-re,ne=S.width+de,ue=Math.max(ne,N.width),Oe=window.innerWidth-Nn,De=$d(re,[Nn,Math.max(Nn,Oe-ue)]);l.style.minWidth=ne+"px",l.style.right=De+"px"}const L=m(),O=window.innerHeight-Nn*2,V=g.scrollHeight,K=window.getComputedStyle(u),G=parseInt(K.borderTopWidth,10),R=parseInt(K.paddingTop,10),q=parseInt(K.borderBottomWidth,10),j=parseInt(K.paddingBottom,10),I=G+R+V+j+q,D=Math.min(w.offsetHeight*5,I),z=window.getComputedStyle(g),J=parseInt(z.paddingTop,10),U=parseInt(z.paddingBottom,10),F=S.top+S.height/2-Nn,W=O-F,P=w.offsetHeight/2,_=w.offsetTop+P,H=G+R+_,X=I-H;if(H<=F){const oe=L.length>0&&w===L[L.length-1].ref.current;l.style.bottom="0px";const re=u.clientHeight-g.offsetTop-g.offsetHeight,de=Math.max(W,P+(oe?U:0)+re+q),ne=H+de;l.style.height=ne+"px"}else{const oe=L.length>0&&w===L[0].ref.current;l.style.top="0px";const de=Math.max(F,G+g.offsetTop+(oe?J:0)+P)+X;l.style.height=de+"px",g.scrollTop=H-F+g.offsetTop}l.style.margin=`${Nn}px 0`,l.style.minHeight=D+"px",l.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[m,a.trigger,a.valueNode,l,u,g,w,v,a.dir,r]);St(()=>y(),[y]);const[E,T]=d.useState();St(()=>{u&&T(window.getComputedStyle(u).zIndex)},[u]);const C=d.useCallback(S=>{S&&x.current===!0&&(y(),b==null||b(),x.current=!1)},[y,b]);return s.jsx(WS,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:s.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:s.jsx(Se.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});th.displayName=BS;var HS="SelectPopperPosition",nl=d.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Nn,...a}=e,i=Ka(n);return s.jsx(TS,{...i,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});nl.displayName=HS;var[WS,xc]=No(Fr,{}),rl="SelectViewport",nh=d.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=Tr(rl,n),i=xc(rl,n),l=Le(t,a.onViewportChange),c=d.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(Ga.Slot,{scope:n,children:s.jsx(Se.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ct(o.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const h=Math.abs(c.current-p.scrollTop);if(h>0){const x=window.innerHeight-Nn*2,g=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),v=Math.max(g,w);if(v<x){const b=v+h,y=Math.min(x,b),E=b-y;f.style.height=y+"px",f.style.bottom==="0px"&&(p.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});nh.displayName=rl;var rh="SelectGroup",[VS,GS]=No(rh),YS=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hn();return s.jsx(VS,{scope:n,id:o,children:s.jsx(Se.div,{role:"group","aria-labelledby":o,...r,ref:t})})});YS.displayName=rh;var oh="SelectLabel",KS=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=GS(oh,n);return s.jsx(Se.div,{id:o.id,...r,ref:t})});KS.displayName=oh;var pa="SelectItem",[qS,sh]=No(pa),ah=d.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,l=Ar(pa,n),c=Tr(pa,n),u=l.value===r,[p,f]=d.useState(a??""),[m,h]=d.useState(!1),x=Le(t,b=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,b,r,o)}),g=hn(),w=d.useRef("touch"),v=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(qS,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:d.useCallback(b=>{f(y=>y||((b==null?void 0:b.textContent)??"").trim())},[]),children:s.jsx(Ga.ItemSlot,{scope:n,value:r,disabled:o,textValue:p,children:s.jsx(Se.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:ct(i.onFocus,()=>h(!0)),onBlur:ct(i.onBlur,()=>h(!1)),onClick:ct(i.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:ct(i.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:ct(i.onPointerDown,b=>{w.current=b.pointerType}),onPointerMove:ct(i.onPointerMove,b=>{var y;w.current=b.pointerType,o?(y=c.onItemLeave)==null||y.call(c):w.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ct(i.onPointerLeave,b=>{var y;b.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:ct(i.onKeyDown,b=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(RS.includes(b.key)&&v(),b.key===" "&&b.preventDefault())})})})})});ah.displayName=pa;var Bo="SelectItemText",ih=d.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=Ar(Bo,n),l=Tr(Bo,n),c=sh(Bo,n),u=OS(Bo,n),[p,f]=d.useState(null),m=Le(t,v=>f(v),c.onItemTextChange,v=>{var b;return(b=l.itemTextRefCallback)==null?void 0:b.call(l,v,c.value,c.disabled)}),h=p==null?void 0:p.textContent,x=d.useMemo(()=>s.jsx("option",{value:c.value,disabled:c.disabled,children:h},c.value),[c.disabled,c.value,h]),{onNativeOptionAdd:g,onNativeOptionRemove:w}=u;return St(()=>(g(x),()=>w(x)),[g,w,x]),s.jsxs(s.Fragment,{children:[s.jsx(Se.span,{id:c.textId,...a,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ls.createPortal(a.children,i.valueNode):null]})});ih.displayName=Bo;var lh="SelectItemIndicator",ch=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return sh(lh,n).isSelected?s.jsx(Se.span,{"aria-hidden":!0,...r,ref:t}):null});ch.displayName=lh;var ol="SelectScrollUpButton",dh=d.forwardRef((e,t)=>{const n=Tr(ol,e.__scopeSelect),r=xc(ol,e.__scopeSelect),[o,a]=d.useState(!1),i=Le(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;a(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(fh,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});dh.displayName=ol;var sl="SelectScrollDownButton",uh=d.forwardRef((e,t)=>{const n=Tr(sl,e.__scopeSelect),r=xc(sl,e.__scopeSelect),[o,a]=d.useState(!1),i=Le(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)<u;a(p)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(fh,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});uh.displayName=sl;var fh=d.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=Tr("SelectScrollButton",n),i=d.useRef(null),l=Ya(n),c=d.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return d.useEffect(()=>()=>c(),[c]),St(()=>{var p;const u=l().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[l]),s.jsx(Se.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ct(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ct(o.onPointerMove,()=>{var u;(u=a.onItemLeave)==null||u.call(a),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ct(o.onPointerLeave,()=>{c()})})}),XS="SelectSeparator",ZS=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(Se.div,{"aria-hidden":!0,...r,ref:t})});ZS.displayName=XS;var al="SelectArrow",JS=d.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ka(n),a=Ar(al,n),i=Tr(al,n);return a.open&&i.position==="popper"?s.jsx(_S,{...o,...r,ref:t}):null});JS.displayName=al;var QS="SelectBubbleInput",ph=d.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=d.useRef(null),a=Le(r,o),i=IS(t);return d.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&p){const f=new Event("change",{bubbles:!0});p.call(l,t),l.dispatchEvent(f)}},[i,t]),s.jsx(Se.select,{...n,style:{...Qf,...n.style},ref:a,defaultValue:t})});ph.displayName=QS;function mh(e){return e===""||e===void 0}function hh(e){const t=on(e),n=d.useRef(""),r=d.useRef(0),o=d.useCallback(i=>{const l=n.current+i;t(l),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),a=d.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return d.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function gh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=eE(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function eE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tE=Vm,nE=Ym,rE=qm,oE=Xm,sE=Zm,aE=Jm,iE=nh,lE=ah,cE=ih,dE=ch,uE=dh,fE=uh;function bs({...e}){return s.jsx(tE,{"data-slot":"select",...e})}function ys({...e}){return s.jsx(rE,{"data-slot":"select-value",...e})}function Cs({className:e,size:t="default",children:n,...r}){return s.jsxs(nE,{"data-slot":"select-trigger","data-size":t,className:ve("flex w-fit items-center justify-between gap-2 border px-3 py-2 text-sm whitespace-nowrap shadow-xs disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,s.jsx(oE,{asChild:!0,children:s.jsx(na,{className:"size-4 opacity-50"})})]})}function Ss({className:e,children:t,position:n="popper",...r}){return s.jsx(sE,{children:s.jsxs(aE,{"data-slot":"select-content",className:ve("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-background relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[s.jsx(pE,{}),s.jsx(iE,{className:ve("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),s.jsx(mE,{})]})})}function Cr({className:e,children:t,...n}){return s.jsxs(lE,{"data-slot":"select-item",className:ve("[&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 py-1.5 pr-8 pl-2 text-sm select-none hover:bg-[var(--color-primary-w10)] hover:text-[var(--color-primary-text-w60)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:hover:bg-[var(--color-primary-w60)] dark:hover:text-[var(--color-primary-text-w10)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(dE,{children:s.jsx(El,{className:"size-4"})})}),s.jsx(cE,{children:t})]})}function pE({className:e,...t}){return s.jsx(uE,{"data-slot":"select-scroll-up-button",className:ve("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx($i,{className:"size-4"})})}function mE({className:e,...t}){return s.jsx(fE,{"data-slot":"select-scroll-down-button",className:ve("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(na,{className:"size-4"})})}var Ei="rovingFocusGroup.onEntryFocus",hE={bubbles:!1,cancelable:!0},Es="RovingFocusGroup",[il,xh,gE]=fc(Es),[xE,qa]=In(Es,[gE]),[vE,wE]=xE(Es),vh=d.forwardRef((e,t)=>s.jsx(il.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(il.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(bE,{...e,ref:t})})}));vh.displayName=Es;var bE=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=e,m=d.useRef(null),h=Le(t,m),x=Wa(a),[g,w]=yr({prop:i,defaultProp:l??null,onChange:c,caller:Es}),[v,b]=d.useState(!1),y=on(u),E=xh(n),T=d.useRef(!1),[C,S]=d.useState(0);return d.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(Ei,y),()=>N.removeEventListener(Ei,y)},[y]),s.jsx(vE,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:d.useCallback(N=>w(N),[w]),onItemShiftTab:d.useCallback(()=>b(!0),[]),onFocusableItemAdd:d.useCallback(()=>S(N=>N+1),[]),onFocusableItemRemove:d.useCallback(()=>S(N=>N-1),[]),children:s.jsx(Se.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{T.current=!0}),onFocus:xe(e.onFocus,N=>{const k=!T.current;if(N.target===N.currentTarget&&k&&!v){const M=new CustomEvent(Ei,hE);if(N.currentTarget.dispatchEvent(M),!M.defaultPrevented){const L=E().filter(R=>R.focusable),O=L.find(R=>R.active),V=L.find(R=>R.id===g),G=[O,V,...L].filter(Boolean).map(R=>R.ref.current);yh(G,p)}}T.current=!1}),onBlur:xe(e.onBlur,()=>b(!1))})})}),wh="RovingFocusGroupItem",bh=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...l}=e,c=hn(),u=a||c,p=wE(wh,n),f=p.currentTabStopId===u,m=xh(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:g}=p;return d.useEffect(()=>{if(r)return h(),()=>x()},[r,h,x]),s.jsx(il.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:s.jsx(Se.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...l,ref:t,onMouseDown:xe(e.onMouseDown,w=>{r?p.onItemFocus(u):w.preventDefault()}),onFocus:xe(e.onFocus,()=>p.onItemFocus(u)),onKeyDown:xe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=SE(w,p.orientation,p.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let y=m().filter(E=>E.focusable).map(E=>E.ref.current);if(v==="last")y.reverse();else if(v==="prev"||v==="next"){v==="prev"&&y.reverse();const E=y.indexOf(w.currentTarget);y=p.loop?EE(y,E+1):y.slice(E+1)}setTimeout(()=>yh(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});bh.displayName=wh;var yE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function SE(e,t,n){const r=CE(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return yE[r]}function yh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function EE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ch=vh,Sh=bh,Xa="Tabs",[NE,G_]=In(Xa,[qa]),Eh=qa(),[jE,vc]=NE(Xa),Nh=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:l,activationMode:c="automatic",...u}=e,p=Wa(l),[f,m]=yr({prop:r,onChange:o,defaultProp:a??"",caller:Xa});return s.jsx(jE,{scope:n,baseId:hn(),value:f,onValueChange:m,orientation:i,dir:p,activationMode:c,children:s.jsx(Se.div,{dir:p,"data-orientation":i,...u,ref:t})})});Nh.displayName=Xa;var jh="TabsList",kh=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=vc(jh,n),i=Eh(n);return s.jsx(Ch,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(Se.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});kh.displayName=jh;var Ah="TabsTrigger",Th=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=vc(Ah,n),l=Eh(n),c=Mh(i.baseId,r),u=Rh(i.baseId,r),p=r===i.value;return s.jsx(Sh,{asChild:!0,...l,focusable:!o,active:p,children:s.jsx(Se.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...a,ref:t,onMouseDown:xe(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(r):f.preventDefault()}),onKeyDown:xe(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(r)}),onFocus:xe(e.onFocus,()=>{const f=i.activationMode!=="manual";!p&&!o&&f&&i.onValueChange(r)})})})});Th.displayName=Ah;var _h="TabsContent",Ih=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,l=vc(_h,n),c=Mh(l.baseId,r),u=Rh(l.baseId,r),p=r===l.value,f=d.useRef(p);return d.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(sn,{present:o||p,children:({present:m})=>s.jsx(Se.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&a})})});Ih.displayName=_h;function Mh(e,t){return`${e}-trigger-${t}`}function Rh(e,t){return`${e}-content-${t}`}var kE=Nh,AE=kh,TE=Th,_E=Ih;function IE({className:e,...t}){return s.jsx(kE,{"data-slot":"tabs",className:ve("flex flex-col gap-2",e),...t})}function ME({className:e,...t}){return s.jsx(AE,{"data-slot":"tabs-list",className:ve("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function Hd({className:e,...t}){return s.jsx(TE,{"data-slot":"tabs-trigger","data-testid":t.value,"aria-label":t.value,title:t.title,className:ve("data-[state=active]:bg-background dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow,background-color] hover:bg-[var(--color-brand-w10)] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:text-[var(--color-brand-wMain)] data-[state=active]:shadow-sm dark:hover:bg-[var(--color-brand-wMain30)] dark:data-[state=active]:text-[var(--color-brand-wMain)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function Wd({className:e,...t}){return s.jsx(_E,{"data-slot":"tabs-content",className:ve("flex-1 outline-none",e),...t})}var ll=["Enter"," "],RE=["ArrowDown","PageUp","Home"],Ph=["ArrowUp","PageDown","End"],PE=[...RE,...Ph],DE={ltr:[...ll,"ArrowRight"],rtl:[...ll,"ArrowLeft"]},LE={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ns="Menu",[ts,OE,FE]=fc(Ns),[Wr,Dh]=In(Ns,[FE,So,qa]),Za=So(),Lh=qa(),[$E,Vr]=Wr(Ns),[zE,js]=Wr(Ns),Oh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,l=Za(t),[c,u]=d.useState(null),p=d.useRef(!1),f=on(a),m=Wa(o);return d.useEffect(()=>{const h=()=>{p.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>p.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),s.jsx(Gl,{...l,children:s.jsx($E,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:s.jsx(zE,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:m,modal:i,children:r})})})};Oh.displayName=Ns;var UE="MenuAnchor",wc=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Za(n);return s.jsx(Ra,{...o,...r,ref:t})});wc.displayName=UE;var bc="MenuPortal",[BE,Fh]=Wr(bc,{forceMount:void 0}),$h=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=Vr(bc,t);return s.jsx(BE,{scope:t,forceMount:n,children:s.jsx(sn,{present:n||a.open,children:s.jsx(Eo,{asChild:!0,container:o,children:r})})})};$h.displayName=bc;var gn="MenuContent",[HE,yc]=Wr(gn),zh=d.forwardRef((e,t)=>{const n=Fh(gn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Vr(gn,e.__scopeMenu),i=js(gn,e.__scopeMenu);return s.jsx(ts.Provider,{scope:e.__scopeMenu,children:s.jsx(sn,{present:r||a.open,children:s.jsx(ts.Slot,{scope:e.__scopeMenu,children:i.modal?s.jsx(WE,{...o,ref:t}):s.jsx(VE,{...o,ref:t})})})})}),WE=d.forwardRef((e,t)=>{const n=Vr(gn,e.__scopeMenu),r=d.useRef(null),o=Le(t,r);return d.useEffect(()=>{const a=r.current;if(a)return Oa(a)},[]),s.jsx(Cc,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:xe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),VE=d.forwardRef((e,t)=>{const n=Vr(gn,e.__scopeMenu);return s.jsx(Cc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),GE=vr("MenuContent.ScrollLock"),Cc=d.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:m,onDismiss:h,disableOutsideScroll:x,...g}=e,w=Vr(gn,n),v=js(gn,n),b=Za(n),y=Lh(n),E=OE(n),[T,C]=d.useState(null),S=d.useRef(null),N=Le(t,S,w.onContentChange),k=d.useRef(0),M=d.useRef(""),L=d.useRef(0),O=d.useRef(null),V=d.useRef("right"),K=d.useRef(0),G=x?vs:d.Fragment,R=x?{as:GE,allowPinchZoom:!0}:void 0,q=I=>{var _,H;const D=M.current+I,z=E().filter(X=>!X.disabled),J=document.activeElement,U=(_=z.find(X=>X.ref.current===J))==null?void 0:_.textValue,F=z.map(X=>X.textValue),W=o2(F,D,U),P=(H=z.find(X=>X.textValue===W))==null?void 0:H.ref.current;(function X(Q){M.current=Q,window.clearTimeout(k.current),Q!==""&&(k.current=window.setTimeout(()=>X(""),1e3))})(D),P&&setTimeout(()=>P.focus())};d.useEffect(()=>()=>window.clearTimeout(k.current),[]),tc();const j=d.useCallback(I=>{var z,J;return V.current===((z=O.current)==null?void 0:z.side)&&a2(I,(J=O.current)==null?void 0:J.area)},[]);return s.jsx(HE,{scope:n,searchRef:M,onItemEnter:d.useCallback(I=>{j(I)&&I.preventDefault()},[j]),onItemLeave:d.useCallback(I=>{var D;j(I)||((D=S.current)==null||D.focus(),C(null))},[j]),onTriggerLeave:d.useCallback(I=>{j(I)&&I.preventDefault()},[j]),pointerGraceTimerRef:L,onPointerGraceIntentChange:d.useCallback(I=>{O.current=I},[]),children:s.jsx(G,{...R,children:s.jsx(xs,{asChild:!0,trapped:o,onMountAutoFocus:xe(a,I=>{var D;I.preventDefault(),(D=S.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:s.jsx(ms,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:m,onDismiss:h,children:s.jsx(Ch,{asChild:!0,...y,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:xe(c,I=>{v.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Yl,{role:"menu","aria-orientation":"vertical","data-state":ng(w.open),"data-radix-menu-content":"",dir:v.dir,...b,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:xe(g.onKeyDown,I=>{const z=I.target.closest("[data-radix-menu-content]")===I.currentTarget,J=I.ctrlKey||I.altKey||I.metaKey,U=I.key.length===1;z&&(I.key==="Tab"&&I.preventDefault(),!J&&U&&q(I.key));const F=S.current;if(I.target!==F||!PE.includes(I.key))return;I.preventDefault();const P=E().filter(_=>!_.disabled).map(_=>_.ref.current);Ph.includes(I.key)&&P.reverse(),n2(P)}),onBlur:xe(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(k.current),M.current="")}),onPointerMove:xe(e.onPointerMove,ns(I=>{const D=I.target,z=K.current!==I.clientX;if(I.currentTarget.contains(D)&&z){const J=I.clientX>K.current?"right":"left";V.current=J,K.current=I.clientX}}))})})})})})})});zh.displayName=gn;var YE="MenuGroup",Sc=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(Se.div,{role:"group",...r,ref:t})});Sc.displayName=YE;var KE="MenuLabel",Uh=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(Se.div,{...r,ref:t})});Uh.displayName=KE;var ma="MenuItem",Vd="menu.itemSelect",Ja=d.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=d.useRef(null),i=js(ma,e.__scopeMenu),l=yc(ma,e.__scopeMenu),c=Le(t,a),u=d.useRef(!1),p=()=>{const f=a.current;if(!n&&f){const m=new CustomEvent(Vd,{bubbles:!0,cancelable:!0});f.addEventListener(Vd,h=>r==null?void 0:r(h),{once:!0}),Ll(f,m),m.defaultPrevented?u.current=!1:i.onClose()}};return s.jsx(Bh,{...o,ref:c,disabled:n,onClick:xe(e.onClick,p),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),u.current=!0},onPointerUp:xe(e.onPointerUp,f=>{var m;u.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:xe(e.onKeyDown,f=>{const m=l.searchRef.current!=="";n||m&&f.key===" "||ll.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ja.displayName=ma;var Bh=d.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=yc(ma,n),l=Lh(n),c=d.useRef(null),u=Le(t,c),[p,f]=d.useState(!1),[m,h]=d.useState("");return d.useEffect(()=>{const x=c.current;x&&h((x.textContent??"").trim())},[a.children]),s.jsx(ts.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:s.jsx(Sh,{asChild:!0,...l,focusable:!r,children:s.jsx(Se.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:u,onPointerMove:xe(e.onPointerMove,ns(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:xe(e.onPointerLeave,ns(x=>i.onItemLeave(x))),onFocus:xe(e.onFocus,()=>f(!0)),onBlur:xe(e.onBlur,()=>f(!1))})})})}),qE="MenuCheckboxItem",Hh=d.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(Kh,{scope:e.__scopeMenu,checked:n,children:s.jsx(Ja,{role:"menuitemcheckbox","aria-checked":ha(n)?"mixed":n,...o,ref:t,"data-state":Nc(n),onSelect:xe(o.onSelect,()=>r==null?void 0:r(ha(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Hh.displayName=qE;var Wh="MenuRadioGroup",[XE,ZE]=Wr(Wh,{value:void 0,onValueChange:()=>{}}),Vh=d.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=on(r);return s.jsx(XE,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(Sc,{...o,ref:t})})});Vh.displayName=Wh;var Gh="MenuRadioItem",Yh=d.forwardRef((e,t)=>{const{value:n,...r}=e,o=ZE(Gh,e.__scopeMenu),a=n===o.value;return s.jsx(Kh,{scope:e.__scopeMenu,checked:a,children:s.jsx(Ja,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Nc(a),onSelect:xe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Yh.displayName=Gh;var Ec="MenuItemIndicator",[Kh,JE]=Wr(Ec,{checked:!1}),qh=d.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=JE(Ec,n);return s.jsx(sn,{present:r||ha(a.checked)||a.checked===!0,children:s.jsx(Se.span,{...o,ref:t,"data-state":Nc(a.checked)})})});qh.displayName=Ec;var QE="MenuSeparator",Xh=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(Se.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Xh.displayName=QE;var e2="MenuArrow",Zh=d.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Za(n);return s.jsx(Kl,{...o,...r,ref:t})});Zh.displayName=e2;var t2="MenuSub",[Y_,Jh]=Wr(t2),Ho="MenuSubTrigger",Qh=d.forwardRef((e,t)=>{const n=Vr(Ho,e.__scopeMenu),r=js(Ho,e.__scopeMenu),o=Jh(Ho,e.__scopeMenu),a=yc(Ho,e.__scopeMenu),i=d.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,u={__scopeMenu:e.__scopeMenu},p=d.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return d.useEffect(()=>p,[p]),d.useEffect(()=>{const f=l.current;return()=>{window.clearTimeout(f),c(null)}},[l,c]),s.jsx(wc,{asChild:!0,...u,children:s.jsx(Bh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ng(n.open),...e,ref:Aa(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:xe(e.onPointerMove,ns(f=>{a.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:xe(e.onPointerLeave,ns(f=>{var h,x;p();const m=(h=n.content)==null?void 0:h.getBoundingClientRect();if(m){const g=(x=n.content)==null?void 0:x.dataset.side,w=g==="right",v=w?-5:5,b=m[w?"left":"right"],y=m[w?"right":"left"];a.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:b,y:m.top},{x:y,y:m.top},{x:y,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(f),f.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:xe(e.onKeyDown,f=>{var h;const m=a.searchRef.current!=="";e.disabled||m&&f.key===" "||DE[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Qh.displayName=Ho;var eg="MenuSubContent",tg=d.forwardRef((e,t)=>{const n=Fh(gn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=Vr(gn,e.__scopeMenu),i=js(gn,e.__scopeMenu),l=Jh(eg,e.__scopeMenu),c=d.useRef(null),u=Le(t,c);return s.jsx(ts.Provider,{scope:e.__scopeMenu,children:s.jsx(sn,{present:r||a.open,children:s.jsx(ts.Slot,{scope:e.__scopeMenu,children:s.jsx(Cc,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:xe(e.onFocusOutside,p=>{p.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:xe(e.onEscapeKeyDown,p=>{i.onClose(),p.preventDefault()}),onKeyDown:xe(e.onKeyDown,p=>{var h;const f=p.currentTarget.contains(p.target),m=LE[i.dir].includes(p.key);f&&m&&(a.onOpenChange(!1),(h=l.trigger)==null||h.focus(),p.preventDefault())})})})})})});tg.displayName=eg;function ng(e){return e?"open":"closed"}function ha(e){return e==="indeterminate"}function Nc(e){return ha(e)?"indeterminate":e?"checked":"unchecked"}function n2(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function r2(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function o2(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=r2(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function s2(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,p=l.y,f=c.x,m=c.y;p>r!=m>r&&n<(f-u)*(r-p)/(m-p)+u&&(o=!o)}return o}function a2(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return s2(n,t)}function ns(e){return t=>t.pointerType==="mouse"?e(t):void 0}var i2=Oh,l2=wc,c2=$h,d2=zh,u2=Sc,f2=Uh,p2=Ja,m2=Hh,h2=Vh,g2=Yh,x2=qh,v2=Xh,w2=Zh,b2=Qh,y2=tg,Qa="DropdownMenu",[C2,K_]=In(Qa,[Dh]),Ht=Dh(),[S2,rg]=C2(Qa),og=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,c=Ht(t),u=d.useRef(null),[p,f]=yr({prop:o,defaultProp:a??!1,onChange:i,caller:Qa});return s.jsx(S2,{scope:t,triggerId:hn(),triggerRef:u,contentId:hn(),open:p,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(m=>!m),[f]),modal:l,children:s.jsx(i2,{...c,open:p,onOpenChange:f,dir:r,modal:l,children:n})})};og.displayName=Qa;var sg="DropdownMenuTrigger",ag=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=rg(sg,n),i=Ht(n);return s.jsx(l2,{asChild:!0,...i,children:s.jsx(Se.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Aa(t,a.triggerRef),onPointerDown:xe(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:xe(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});ag.displayName=sg;var E2="DropdownMenuPortal",ig=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ht(t);return s.jsx(c2,{...r,...n})};ig.displayName=E2;var lg="DropdownMenuContent",cg=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=rg(lg,n),a=Ht(n),i=d.useRef(!1);return s.jsx(d2,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:xe(e.onCloseAutoFocus,l=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:xe(e.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,p=c.button===2||u;(!o.modal||p)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cg.displayName=lg;var N2="DropdownMenuGroup",j2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(u2,{...o,...r,ref:t})});j2.displayName=N2;var k2="DropdownMenuLabel",A2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(f2,{...o,...r,ref:t})});A2.displayName=k2;var T2="DropdownMenuItem",dg=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(p2,{...o,...r,ref:t})});dg.displayName=T2;var _2="DropdownMenuCheckboxItem",I2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(m2,{...o,...r,ref:t})});I2.displayName=_2;var M2="DropdownMenuRadioGroup",R2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(h2,{...o,...r,ref:t})});R2.displayName=M2;var P2="DropdownMenuRadioItem",D2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(g2,{...o,...r,ref:t})});D2.displayName=P2;var L2="DropdownMenuItemIndicator",O2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(x2,{...o,...r,ref:t})});O2.displayName=L2;var F2="DropdownMenuSeparator",ug=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(v2,{...o,...r,ref:t})});ug.displayName=F2;var $2="DropdownMenuArrow",z2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(w2,{...o,...r,ref:t})});z2.displayName=$2;var U2="DropdownMenuSubTrigger",B2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(b2,{...o,...r,ref:t})});B2.displayName=U2;var H2="DropdownMenuSubContent",W2=d.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ht(n);return s.jsx(y2,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});W2.displayName=H2;var V2=og,G2=ag,Y2=ig,K2=cg,q2=dg,X2=ug;function Z2({...e}){return s.jsx(V2,{"data-slot":"dropdown-menu",...e})}function J2({...e}){return s.jsx(G2,{"data-slot":"dropdown-menu-trigger",...e})}function Q2({className:e,sideOffset:t=4,...n}){return s.jsx(Y2,{children:s.jsx(K2,{"data-slot":"dropdown-menu-content",sideOffset:t,className:ve("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...n})})}function $s({className:e,inset:t,variant:n="default",...r}){return s.jsx(q2,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:ve("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function Gd({className:e,...t}){return s.jsx(X2,{"data-slot":"dropdown-menu-separator",className:ve("bg-border -mx-1 my-1 h-px",e),...t})}const fg=d.forwardRef(({className:e,...t},n)=>s.jsx(Hr,{autoComplete:"off",ref:n,name:"message","data-testid":"chat-input",className:ve("flex w-full items-center rounded-md px-4 py-3 placeholder:text-[var(--color-secondary-wMain)] disabled:cursor-not-allowed disabled:opacity-50",e),...t}));fg.displayName="ChatInput";const eN=Nr("flex gap-2 max-w-full items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),pg=d.forwardRef(({className:e,variant:t,layout:n,children:r,...o},a)=>s.jsx("div",{className:ve(eN({variant:t,layout:n,className:e}),"group relative"),ref:a,...o,children:d.Children.map(r,i=>d.isValidElement(i)&&typeof i.type!="string"?d.cloneElement(i,{variant:t,layout:n}):i)}));pg.displayName="ChatBubble";const tN=Nr("p-4",{variants:{variant:{received:"rounded-r-lg rounded-tl-lg",sent:"rounded-l-lg rounded-tr-lg justify-end bg-[var(--message-background)]"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),mg=d.forwardRef(({className:e,variant:t,layout:n,children:r,...o},a)=>s.jsx("div",{className:ve(tN({variant:t,layout:n,className:e}),"relative max-w-full break-words"),ref:a,...o,children:s.jsx(s.Fragment,{children:r})}));mg.displayName="ChatBubbleMessage";const nN=d.forwardRef(({variant:e,className:t,children:n,...r},o)=>s.jsx("div",{ref:o,className:ve("absolute top-1/2 flex -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover:opacity-100",e==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",t),...r,children:n}));nN.displayName="ChatBubbleActionWrapper";const hg={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},gg=jt.forwardRef(({className:e="",children:t,...n},r)=>{const{scrollRef:o,isAtBottom:a,disableAutoScroll:i,scrollToBottom:l,userHasScrolled:c}=dN({smooth:!0,content:t});return d.useImperativeHandle(r,()=>({scrollToBottom:l})),s.jsxs("div",{className:`fade-both-mask relative h-full min-h-0 w-full flex-1 py-3 ${e}`,children:[s.jsx("div",{className:"flex h-full w-full flex-col overflow-y-auto p-4",ref:o,onWheel:i,onTouchMove:i,...n,style:{scrollBehavior:"smooth"},children:s.jsx("div",{className:"flex flex-col gap-6",style:hg,children:t})}),!a&&c&&s.jsx(te,{onClick:()=>{l()},size:"icon",variant:"outline",className:"bg-background absolute bottom-2 left-1/2 z-20 inline-flex -translate-x-1/2 transform rounded-full shadow-md","aria-label":"Scroll to bottom",children:s.jsx(_u,{className:"h-4 w-4"})})]})});gg.displayName="ChatMessageList";function rN({className:e=""}){return s.jsx(Wn,{size:"small",variant:"primary",className:e})}const zs={error:"bg-[var(--color-error-w10)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-error-w10)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-warning-w10)]",info:"bg-[var(--color-info-w10)] text-[var(--color-info-wMain)] border-[var(--color-info-w10)] dark:bg-[var(--color-info-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-info-w10)]",success:"bg-[var(--color-success-w10)] text-[var(--color-success-wMain)] border-[var(--color-success-w10)] dark:bg-[var(--color-success-wMain)] dark:text-[var(--color-primary-text-w10)] dark:border-[var(--color-success-wMain)]"},oN=Nr("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent [a&]:hover:bg-primary/90",secondary:"border-transparent [a&]:hover:bg-secondary/90",destructive:"border-transparent [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"},type:{error:zs.error,warning:zs.warning,info:zs.info,success:zs.success}},defaultVariants:{variant:"default"}});function jo({className:e,variant:t,type:n,asChild:r=!1,...o}){const a=r?nf:"span";return s.jsx(a,{"data-slot":"badge",className:ve(oN({variant:t,type:n}),e),...o})}const sN=Nr("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function aN({className:e,variant:t,...n}){return s.jsx("div",{"data-slot":"alert",role:"alert",className:ve(sN({variant:t}),e),...n})}function iN({className:e,...t}){return s.jsx("div",{"data-slot":"alert-title",className:ve("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function lN({message:e,type:t}){return s.jsx("div",{className:"transform transition-all duration-200 ease-in-out",children:s.jsx(aN,{className:"border-border bg-accent max-w-80 rounded-sm shadow-md",children:s.jsxs(iN,{className:"flex items-center text-sm",children:[t==="error"&&s.jsx(cs,{className:"mr-2 text-[var(--color-error-wMain)]"}),s.jsx("div",{className:"truncate",children:e})]})})})}function cN(){const{notifications:e}=qe();return e.length===0?null:s.jsx("div",{className:"pointer-events-none fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 transform flex-col-reverse gap-2",children:e.map(t=>s.jsx("div",{className:"pointer-events-auto",children:s.jsx(lN,{id:t.id,message:t.message,type:t.type,duration:t.type==="error"?5e3:3e3})},t.id))})}function dN(e={}){const{offset:t=20,smooth:n=!1,content:r,autoScrollOnNewContent:o=!1}=e,a=d.useRef(null),i=d.useRef(0),l=d.useRef(!1),[c,u]=d.useState({isAtBottom:!0,autoScrollEnabled:!0}),p=d.useCallback(x=>{const{scrollTop:g,scrollHeight:w,clientHeight:v}=x;return Math.abs(w-g-v)<=t},[t]),f=d.useCallback(x=>{if(!a.current)return;const g=a.current.scrollHeight-a.current.clientHeight;x?a.current.scrollTop=g:a.current.scrollTo({top:g,behavior:n?"smooth":"auto"}),u({isAtBottom:!0,autoScrollEnabled:!0}),l.current=!1},[n]),m=d.useCallback(()=>{if(!a.current)return;const x=p(a.current);u(g=>({isAtBottom:x,autoScrollEnabled:x?!0:g.autoScrollEnabled}))},[p]);d.useEffect(()=>{const x=a.current;if(x)return x.addEventListener("scroll",m,{passive:!0}),()=>x.removeEventListener("scroll",m)},[m]),d.useEffect(()=>{const x=a.current;if(!x)return;const g=x.scrollHeight;g!==i.current&&((c.autoScrollEnabled||o)&&requestAnimationFrame(()=>{f(i.current===0)}),i.current=g)},[r,c.autoScrollEnabled,f,o]),d.useEffect(()=>{const x=a.current;if(!x)return;const g=new ResizeObserver(()=>{c.autoScrollEnabled&&f(!0)});return g.observe(x),()=>g.disconnect()},[c.autoScrollEnabled,f]);const h=d.useCallback(()=>{(a.current?p(a.current):!1)||(l.current=!0,u(g=>({...g,autoScrollEnabled:!1})))},[p]);return{scrollRef:a,isAtBottom:c.isAtBottom,autoScrollEnabled:c.autoScrollEnabled,scrollToBottom:()=>f(),disableAutoScroll:h,userHasScrolled:l.current}}const uN=({fileName:e,onRemove:t})=>s.jsxs(jo,{className:"bg-muted max-w-50 gap-1.5 rounded-full pr-1",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs md:text-sm",title:e,children:e}),t&&s.jsx(te,{variant:"ghost",size:"icon",onClick:t,className:"h-2 min-h-0 w-2 min-w-0 p-2",title:"Remove file",children:s.jsx(Er,{})})]}),fN=({agents:e=[],scrollToBottom:t})=>{const{isResponding:n,isCancelling:r,selectedAgentName:o,sessionId:a,handleSubmit:i,handleCancel:l}=qe(),{handleAgentSelection:c}=XC(),u=d.useRef(null),[p,f]=d.useState([]),m=d.useRef(null),h=d.useRef(n),[x,g]=d.useState("");d.useEffect(()=>{g("")},[a]),d.useEffect(()=>{h.current&&!n&&setTimeout(()=>{var O;(O=m.current)==null||O.focus()},100),h.current=n},[n]),d.useEffect(()=>{const O=()=>{setTimeout(()=>{var V;(V=m.current)==null||V.focus()},100)};return window.addEventListener("focus-chat-input",O),()=>{window.removeEventListener("focus-chat-input",O)}},[]);const w=()=>{var O;n||(O=u.current)==null||O.click()},v=O=>{const V=O.target.files;if(V){const K=Array.from(V).filter(G=>!p.some(R=>R.name===G.name&&R.size===G.size&&R.lastModified===G.lastModified));K.length>0&&f(G=>[...G,...K])}O.target&&(O.target.value=""),setTimeout(()=>{var K;(K=m.current)==null||K.focus()},100)},b=O=>{if(n)return;const V=O.clipboardData;if(!V||!V.files||V.files.length===0)return;V.files.length>0&&O.preventDefault();const K=Array.from(V.files).filter(G=>!p.some(R=>R.name===G.name&&R.size===G.size&&R.lastModified===G.lastModified));K.length>0&&f(G=>[...G,...K])},y=O=>{f(V=>V.filter((K,G)=>G!==O))},E=d.useMemo(()=>!n&&((x==null?void 0:x.trim())||p.length!==0),[n,x,p]),T=async O=>{O.preventDefault(),E&&(await i(O,p,x.trim()),f([]),g(""),t==null||t())},C=O=>{if(n)return;const V=O.filter(K=>!p.some(G=>G.name===K.name&&G.size===K.size&&G.lastModified===K.lastModified));V.length>0&&f(K=>[...K,...V])},{isDragging:S,handleDragEnter:N,handleDragOver:k,handleDragLeave:M,handleDrop:L}=KC({onFilesDropped:C,disabled:n});return s.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${S?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:N,onDragOver:k,onDragLeave:M,onDrop:L,children:[s.jsx("input",{type:"file",ref:u,className:"hidden",multiple:!0,onChange:v,accept:"*/*",disabled:n}),p.length>0&&s.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:p.map((O,V)=>s.jsx(uN,{fileName:O.name,onRemove:()=>y(V)},`${O.name}-${O.lastModified}-${V}`))}),s.jsx(fg,{ref:m,value:x,onChange:O=>g(O.target.value),placeholder:"How can I help you today?",className:"field-sizing-content max-h-50 min-h-0 resize-none rounded-2xl border-none p-3 text-base/normal shadow-none transition-[height] duration-500 ease-in-out focus-visible:outline-none",rows:1,onPaste:b,onKeyDown:O=>{O.key==="Enter"&&!O.shiftKey&&E&&T(O)}}),s.jsxs("div",{className:"m-2 flex items-center gap-2",children:[s.jsx(te,{variant:"ghost",onClick:w,disabled:n,tooltip:"Attach file",children:s.jsx(Iu,{className:"size-4"})}),s.jsx("div",{children:"Agent: "}),s.jsxs(bs,{value:o,onValueChange:c,disabled:n||e.length===0,children:[s.jsx(Cs,{className:"w-[250px]",children:s.jsx(ys,{defaultValue:o})}),s.jsx(Ss,{children:e.map(O=>s.jsx(Cr,{value:O.name,children:O.displayName||O.name},O.name))})]}),n&&!r?s.jsxs(te,{"data-testid":"cancel",className:"ml-auto gap-1.5",onClick:l,variant:"outline",disabled:r,tooltip:"Cancel",children:[s.jsx(Mx,{className:"size-4"}),"Stop"]}):s.jsx(te,{"data-testid":"sendMessage",variant:"ghost",className:"ml-auto gap-1.5",onClick:T,disabled:!E,tooltip:"Send message",children:s.jsx(Rx,{className:"size-4"})})]})]})};let Us=null,Bs=null;function pN({children:e}){const{fetchCsrfToken:t}=vm(),[n,r]=d.useState(Us),[o,a]=d.useState(!Us&&!Bs),[i,l]=d.useState(Bs);return d.useEffect(()=>{if(Us||Bs)return;let c=!0;return(async()=>{var p;a(!0),l(null);try{let f=await Ne("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"}}),m;if(f.ok)m=await f.json();else{const w=await f.text();if(console.error("Initial config fetch failed:",f.status,w),f.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const v=await t();if(!v)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),f=await Ne("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":v,Accept:"application/json"}}),!f.ok){const b=await f.text();throw console.error("Config fetch retry failed:",f.status,b),new Error(`Failed to fetch config on retry: ${f.status} ${b}`)}m=await f.json()}else throw new Error(`Failed to fetch config: ${f.status} ${w}`)}const h=m.frontend_use_authorization??!1;h&&(console.log("Fetching CSRF token for config-related requests..."),await t());const x=((p=m.frontend_feature_enablement)==null?void 0:p.projects)??!1,g={configServerUrl:m.frontend_server_url,configAuthLoginUrl:m.frontend_auth_login_url,configUseAuthorization:h,configWelcomeMessage:m.frontend_welcome_message,configRedirectUrl:m.frontend_redirect_url,configCollectFeedback:m.frontend_collect_feedback,configBotName:m.frontend_bot_name,configFeatureEnablement:m.frontend_feature_enablement??{},frontend_use_authorization:m.frontend_use_authorization,persistenceEnabled:m.persistence_enabled??!1,projectsEnabled:x,validationLimits:m.validation_limits};c&&(Us=g,r(g)),console.log("App config processed and set:",g)}catch(f){if(console.error("Error initializing app:",f),c){const m=f.message||"Failed to load application configuration.";Bs=m,l(m)}}finally{c&&a(!1)}})(),()=>{c=!1}},[t]),n?s.jsx(lm.Provider,{value:n,children:e}):o?s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),s.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Loading Configuration..."})]})}):i?s.jsx(rs,{className:"h-screen w-screen",variant:"error",title:"Configuration Error",subtitle:"Please check the backend server and network connection, then refresh the page."}):s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),s.jsx("h1",{className:"text-2xl",children:"Initializing Application..."})]})})}const mN=({children:e})=>{const{configServerUrl:t}=_t(),n=`${t}/api/v1`,[r,o]=d.useState(null),[a,i]=d.useState(!1),[l,c]=d.useState(!1),[u,p]=d.useState(null),[f,m]=d.useState({}),[h,x]=d.useState([]),[g,w]=d.useState(null),[v,b]=d.useState(0),[y,E]=d.useState(!1),T=10,C=d.useRef(null),S=d.useRef(null),N=d.useRef(null);d.useEffect(()=>{S.current=r},[r]);const k=d.useCallback(j=>{m(I=>{var U,F,W;const D=j.task_id;if(!D)return j.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",j),I;const z=I[D],J=new Date(j.timestamp);if(z){const P=[...z.events,j].sort((_,H)=>new Date(_.timestamp).getTime()-new Date(H.timestamp).getTime());return{...I,[D]:{...z,events:P,lastUpdated:J}}}else{let P="Task started...";if(j.direction==="request"&&((F=(U=j.full_payload)==null?void 0:U.method)!=null&&F.startsWith("message/"))){const H=j.full_payload.params;if((W=H==null?void 0:H.message)!=null&&W.parts){const X=H.message.parts.filter(Q=>Q.kind==="text"&&Q.text);X.length>0&&(P=X[X.length-1].text)}}const _={taskId:D,initialRequestText:P,events:[j],firstSeen:J,lastUpdated:J};return x(H=>[D,...H.filter(X=>X!==D)]),{...I,[D]:_}}})},[]),M=d.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),i(!1),c(!0),p(null),b(0),E(!1),N.current&&(clearTimeout(N.current),N.current=null)},[]),L=d.useCallback(j=>{try{const I=JSON.parse(j.data);k(I)}catch(I){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",I,"Raw data:",j.data),p("Received unparseable 'a2a_message' event from server.")}},[k]),O=d.useCallback(j=>{console.error("TaskMonitorContext: SSE connection error:",j),i(!1),c(!1),C.current&&C.current.readyState===EventSource.CLOSED?p("Task Monitor SSE connection closed by server or network issue."):p("Task Monitor SSE connection error occurred."),C.current&&(C.current.close(),C.current=null),N.current&&(clearTimeout(N.current),N.current=null)},[]),V=d.useCallback(async()=>{if(l||a){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),i(!0);try{const j={subscription_targets:[{type:"my_a2a_messages"}]},I=await Ne(`${n}/visualization/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j),credentials:"include"});if(!I.ok){const W=await I.json().catch(()=>({detail:"Failed to subscribe"}));if(W.error_type==="authorization_failure"){const P=W.message||"Access denied: insufficient permissions",_=W.suggested_action?` ${W.suggested_action}`:"";throw new Error(`${P}${_}`)}else if(W.error_type==="subscription_failure"){const P=W.message||"Subscription failed",_=W.suggested_action?` ${W.suggested_action}`:"";throw new Error(`${P}${_}`)}else throw new Error(W.detail||W.message||`Subscription failed: ${I.statusText}`)}const D=await I.json();o(D.stream_id);const z=D.sse_endpoint_url.startsWith("/")?`${t||""}${D.sse_endpoint_url}`:D.sse_endpoint_url;C.current&&C.current.close();const J=Pl(),U=`${z}${J?`?token=${J}`:""}`,F=new EventSource(U,{withCredentials:!0});C.current=F,F.onopen=M,F.addEventListener("a2a_message",L),F.onerror=O}catch(j){console.error("TaskMonitorContext: Error connecting stream:",j),p(j instanceof Error?j.message:String(j)),i(!1),c(!1),o(null),C.current&&(C.current.close(),C.current=null),N.current&&(clearTimeout(N.current),N.current=null)}},[n,t,l,a,M,L,O]),K=d.useCallback(()=>{if(N.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(v>=T){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),E(!1),p(`Connection lost. Max reconnection attempts (${T}) reached.`);return}const j=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${v+1}/${T} in ${j}ms...`),E(!0),b(I=>I+1),N.current=setTimeout(()=>{V()},j)},[v,V]),G=d.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),N.current&&(clearTimeout(N.current),N.current=null),C.current&&(C.current.close(),C.current=null);const j=S.current;if(j)try{await Ne(`${n}/visualization/${j}/unsubscribe`,{method:"DELETE",credentials:"include"})}catch(I){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${j}`,I)}o(null),i(!1),c(!1),p(null),m({}),x([]),w(null),b(0),E(!1)},[n]);d.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),C.current&&(C.current.close(),C.current=null);const j=S.current;if(j)if(navigator.sendBeacon){const I=new FormData;navigator.sendBeacon(`${n}/visualization/${j}/unsubscribe`,I)}else Ne(`${n}/visualization/${j}/unsubscribe`,{method:"DELETE",credentials:"include",keepalive:!0}).catch(I=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",I))},[n]),d.useEffect(()=>{!l&&!a&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),V())},[]),d.useEffect(()=>{!l&&!a&&u&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),K())},[l,a,u,K]),d.useEffect(()=>()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]);const R=d.useCallback(j=>{w(j)},[]),q={isTaskMonitorConnecting:a,isTaskMonitorConnected:l,taskMonitorSseError:u,monitoredTasks:f,monitoredTaskOrder:h,highlightedStepId:g,isReconnecting:y,reconnectionAttempts:v,connectTaskMonitorStream:V,disconnectTaskMonitorStream:G,setHighlightedStepId:R};return s.jsx(dm.Provider,{value:q,children:e})},Nt=[];for(let e=0;e<256;++e)Nt.push((e+256).toString(16).slice(1));function hN(e,t=0){return(Nt[e[t+0]]+Nt[e[t+1]]+Nt[e[t+2]]+Nt[e[t+3]]+"-"+Nt[e[t+4]]+Nt[e[t+5]]+"-"+Nt[e[t+6]]+Nt[e[t+7]]+"-"+Nt[e[t+8]]+Nt[e[t+9]]+"-"+Nt[e[t+10]]+Nt[e[t+11]]+Nt[e[t+12]]+Nt[e[t+13]]+Nt[e[t+14]]+Nt[e[t+15]]).toLowerCase()}let Ni;const gN=new Uint8Array(16);function xN(){if(!Ni){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ni=crypto.getRandomValues.bind(crypto)}return Ni(gN)}const vN=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Yd={randomUUID:vN};function wN(e,t,n){var o;e=e||{};const r=e.random??((o=e.rng)==null?void 0:o.call(e))??xN();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,hN(r)}function bN(e,t,n){return Yd.randomUUID&&!e?Yd.randomUUID():wN(e)}const Hs=1,yN=e=>({...e,taskMetadata:{...e.taskMetadata,schema_version:1}}),CN={0:yN},SN=({children:e})=>{const{configWelcomeMessage:t,configServerUrl:n,persistenceEnabled:r,configCollectFeedback:o}=_t(),a=d.useMemo(()=>`${n}/api/v1`,[n]),{activeProject:i,setActiveProject:l,projects:c}=Jn(),u=1*1024*1024,p=$=>new Promise((B,Y)=>{const ee=new FileReader;ee.readAsDataURL($),ee.onload=()=>B(ee.result.split(",")[1]),ee.onerror=fe=>Y(fe)}),[f,m]=d.useState(""),[h,x]=d.useState([]),[g,w]=d.useState(!1),[v,b]=d.useState([]),[y,E]=d.useState(null),T=d.useRef(null),[C,S]=d.useState(""),[N,k]=d.useState(!1),M=d.useRef(N),L=d.useRef(new Set),O=d.useRef(new Set),V=d.useRef(new Set);d.useEffect(()=>{M.current=N},[N]);const[K,G]=d.useState(null),R=d.useRef(null),q=d.useRef(!1),j=d.useRef(null),I=d.useRef(0),{agents:D,error:z,isLoading:J,refetch:U}=cc(),{artifacts:F,isLoading:W,refetch:P,setArtifacts:_}=HC(f),[H,X]=d.useState(!0),[Q,oe]=d.useState("files"),[re,de]=d.useState(!1),[ne,ue]=d.useState(null),[Oe,De]=d.useState(!1),[Te,Be]=d.useState(new Set),[Et,et]=d.useState(!1),[wt,Lt]=d.useState(null),[ut,ft]=d.useState(null),[st,qt]=d.useState(null),[Rn,Vt]=d.useState(null),Ot=d.useMemo(()=>wt&&F.find($=>$.filename===wt)||null,[F,wt]),[an,Xt]=d.useState({expandedArtifacts:new Set}),[ln,bt]=d.useState({}),ie=d.useCallback(($,B)=>{b(Y=>{if(Y.find(be=>be.message===$))return Y;const fe=Date.now().toString(),ge={id:fe,message:$,type:B||"info"};return setTimeout(()=>{b(be=>be.filter(Xe=>Xe.id!==fe))},3e3),[...Y,ge]})},[]),Gt=d.useCallback($=>{var ee,fe,ge;const B=(ee=$.parts)==null?void 0:ee.filter(be=>be.kind==="text"),Y=(B==null?void 0:B.map(be=>be.text).join(""))||"";return{id:((fe=$.metadata)==null?void 0:fe.messageId)||`msg-${crypto.randomUUID()}`,type:$.isUser?"user":"agent",text:Y,parts:$.parts,uploadedFiles:(ge=$.uploadedFiles)==null?void 0:ge.map(be=>({name:be.name,type:be.type})),isError:$.isError}},[]),Yt=d.useCallback(async $=>{if(!(!r||!f)&&!L.current.has($.task_id)){L.current.add($.task_id);try{const B=await Ne(`${a}/sessions/${f}/chat-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:$.task_id,userMessage:$.user_message,messageBubbles:JSON.stringify($.message_bubbles),taskMetadata:$.task_metadata?JSON.stringify($.task_metadata):null})});if(!B.ok){const Y=await B.json().catch(()=>({detail:"Failed to save task"}));throw new Error(Y.detail||`HTTP error ${B.status}`)}}catch(B){console.error(`Error saving task ${$.task_id}:`,B)}finally{setTimeout(()=>{L.current.delete($.task_id)},100)}}},[a,f,r]),Pn=d.useCallback($=>$.messageBubbles.map(B=>({taskId:$.taskId,role:B.type==="user"?"user":"agent",parts:B.parts||[{kind:"text",text:B.text||""}],isUser:B.type==="user",isComplete:!0,files:B.files,uploadedFiles:B.uploadedFiles,artifactNotification:B.artifactNotification,isError:B.isError,metadata:{messageId:B.id,sessionId:f,lastProcessedEventSequence:0}})),[f]),Zt=d.useCallback($=>{var ee;const B=((ee=$.taskMetadata)==null?void 0:ee.schema_version)||0;if(B>=Hs)return $;let Y=$;for(let fe=B;fe<Hs;fe++){const ge=CN[fe];ge?(Y=ge(Y),console.log(`Migrated task ${$.taskId} from v${fe} to v${fe+1}`)):console.warn(`No migration function found for version ${fe}`)}return Y},[]),Jt=d.useCallback(async $=>{var B,Y;try{const ee=await Ne(`${a}/sessions/${$}/chat-tasks`);if(!ee.ok){const je=await ee.json().catch(()=>({detail:"Failed to load session tasks"}));throw new Error(je.detail||`HTTP error ${ee.status}`)}const Xe=((await ee.json()).tasks||[]).map(je=>({...je,messageBubbles:JSON.parse(je.messageBubbles),taskMetadata:je.taskMetadata?JSON.parse(je.taskMetadata):null})).map(Zt),lt=[];for(const je of Xe){const Ue=Pn(je);lt.push(...Ue)}const nt={};for(const je of Xe)(B=je.taskMetadata)!=null&&B.feedback&&(nt[je.taskId]={type:je.taskMetadata.feedback.type,text:je.taskMetadata.feedback.text||""});let rt=null;for(let je=Xe.length-1;je>=0;je--)if((Y=Xe[je].taskMetadata)!=null&&Y.agent_name){rt=Xe[je].taskMetadata.agent_name;break}x(lt),bt(nt),rt&&S(rt)}catch(ee){throw console.error("Error loading session tasks:",ee),ie("Error loading session history. Please try again.","error"),ee}},[a,Pn,ie,Zt]),wn=d.useCallback(async($,B)=>{const Y=B||f,ee=new FormData;ee.append("file",$);try{const fe=await Ne(`${a}/artifacts/${Y}/${encodeURIComponent($.name)}`,{method:"POST",body:ee,credentials:"include"});if(!fe.ok){const be=await fe.json().catch(()=>({detail:`Failed to upload ${$.name}`}));throw new Error(be.detail||`HTTP error ${fe.status}`)}const ge=await fe.json();return ie(`Artifact "${$.name}" uploaded successfully.`),await P(),ge.uri?{uri:ge.uri,sessionId:Y}:null}catch(fe){return ie(`Error uploading artifact "${$.name}": ${fe instanceof Error?fe.message:"Unknown error"}`),null}},[a,f,ie,P]),[Qt,cn]=d.useState(null),[dn,Ge]=d.useState(null),[It,Dn]=d.useState(!1),bn=d.useCallback(async $=>{try{const B=await Ne(`${a}/artifacts/${f}/${encodeURIComponent($)}`,{method:"DELETE",credentials:"include"});if(!B.ok&&B.status!==204){const Y=await B.json().catch(()=>({detail:`Failed to delete ${$}`}));throw new Error(Y.detail||`HTTP error ${B.status}`)}ie(`File "${$}" deleted successfully.`),P()}catch(B){ie(`Error deleting file "${$}": ${B instanceof Error?B.message:"Unknown error"}`)}},[a,f,ie,P]),yn=d.useCallback($=>{ue($),de(!0)},[]),un=d.useCallback(()=>{ue(null),de(!1)},[]),Mt=d.useCallback($=>{Lt(($==null?void 0:$.filename)||null)},[]),ke=d.useCallback(async()=>{if(ne){const $=(Ot==null?void 0:Ot.filename)===ne.filename;await bn(ne.filename),$&&Mt(null)}un()},[ne,bn,un,Ot,Mt]),_e=d.useCallback(()=>{if(Te.size===0){ie("No files selected for deletion.");return}et(!0)},[Te,ie]),Fe=d.useCallback(async()=>{et(!1);const $=Array.from(Te);let B=0,Y=0;for(const ee of $)try{const fe=await Ne(`${a}/artifacts/${f}/${encodeURIComponent(ee)}`,{method:"DELETE",credentials:"include"});if(!fe.ok&&fe.status!==204)throw new Error(`Failed to delete ${ee}`);B++}catch(fe){console.error(fe),Y++}B>0&&ie(`${B} files(s) deleted successfully.`),Y>0&&ie(`Failed to delete ${Y} files(s).`),P(),Be(new Set),De(!1)},[Te,ie,P,a,f]),Me=d.useCallback(async $=>{if(O.current.has($))return null;O.current.add($),wt!==$&&(ft(null),qt(null),Vt(null));try{let B;if(f&&f.trim()&&f!=="null"&&f!=="undefined")B=`${a}/artifacts/${f}/${encodeURIComponent($)}/versions`;else if(i!=null&&i.id)B=`${a}/artifacts/null/${encodeURIComponent($)}/versions?project_id=${i.id}`;else throw new Error("No valid context for artifact preview");const Y=await Ne(B,{credentials:"include"});if(!Y.ok)throw new Error("Error fetching version list");const ee=await Y.json();if(!ee||ee.length===0)throw new Error("No versions available");ft(ee.sort((je,Ue)=>je-Ue));const fe=Math.max(...ee);qt(fe);let ge;if(f&&f.trim()&&f!=="null"&&f!=="undefined")ge=`${a}/artifacts/${f}/${encodeURIComponent($)}/versions/${fe}`;else if(i!=null&&i.id)ge=`${a}/artifacts/null/${encodeURIComponent($)}/versions/${fe}?project_id=${i.id}`;else throw new Error("No valid context for artifact content");const be=await Ne(ge,{credentials:"include"});if(!be.ok)throw new Error("Error fetching latest version content");const Xe=await be.blob(),lt=await new Promise((je,Ue)=>{const Ce=new FileReader;Ce.onloadend=()=>{var ye;return je(((ye=Ce.result)==null?void 0:ye.toString().split(",")[1])||"")},Ce.onerror=Ue,Ce.readAsDataURL(Xe)}),nt=F.find(je=>je.filename===$),rt={name:$,mime_type:(nt==null?void 0:nt.mime_type)||"application/octet-stream",content:lt,last_modified:(nt==null?void 0:nt.last_modified)||new Date().toISOString()};return Vt(rt),rt}catch(B){return ie(`Error loading preview for ${$}: ${B instanceof Error?B.message:"Unknown error"}`),null}finally{O.current.delete($)}},[a,f,i==null?void 0:i.id,F,ie,wt]),yt=d.useCallback(async($,B)=>{if(!ut||ut.length===0)return null;if(!ut.includes(B))return ie(`Version ${B} is not available for ${$}.`),null;Vt(null);try{let Y;if(f&&f.trim()&&f!=="null"&&f!=="undefined")Y=`${a}/artifacts/${f}/${encodeURIComponent($)}/versions/${B}`;else if(i!=null&&i.id)Y=`${a}/artifacts/null/${encodeURIComponent($)}/versions/${B}?project_id=${i.id}`;else throw new Error("No valid context for artifact navigation");const ee=await Ne(Y,{credentials:"include"});if(!ee.ok)throw new Error(`Error fetching version ${B}`);const fe=await ee.blob(),ge=await new Promise((lt,nt)=>{const rt=new FileReader;rt.onloadend=()=>{var je;return lt(((je=rt.result)==null?void 0:je.toString().split(",")[1])||"")},rt.onerror=nt,rt.readAsDataURL(fe)}),be=F.find(lt=>lt.filename===$),Xe={name:$,mime_type:(be==null?void 0:be.mime_type)||"application/octet-stream",content:ge,last_modified:(be==null?void 0:be.last_modified)||new Date().toISOString()};return qt(B),Vt(Xe),Xe}catch(Y){return ie(`Error loading version ${B}: ${Y instanceof Error?Y.message:"Unknown error"}`),null}},[a,ie,F,ut,f,i==null?void 0:i.id]),pt=d.useCallback($=>{ie(`Loading preview for attached file: ${$.name}`),Vt($),ft(null),qt(null)},[ie]),at=d.useCallback($=>{X(!1),oe($),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:$}}))},[]),Re=d.useCallback(()=>{R.current&&(clearTimeout(R.current),R.current=null),T.current&&(T.current.close(),T.current=null),q.current=!1},[]),Ke=d.useCallback(async $=>{if(V.current.has($))return console.log(`[ChatProvider] Skipping duplicate download for ${$} - already in progress`),null;V.current.add($);try{const B=F.find(nt=>nt.filename===$);if(!B)return console.error(`Artifact ${$} not found in state`),null;const Y=await Ne(`${a}/artifacts/${f}/${encodeURIComponent($)}/versions`,{credentials:"include"});if(!Y.ok)throw new Error("Error fetching version list");const ee=await Y.json();if(!ee||ee.length===0)throw new Error("No versions available");const fe=Math.max(...ee),ge=await Ne(`${a}/artifacts/${f}/${encodeURIComponent($)}/versions/${fe}`,{credentials:"include"});if(!ge.ok)throw new Error("Error fetching artifact content");const be=await ge.blob(),Xe=await new Promise((nt,rt)=>{const je=new FileReader;je.onloadend=()=>{var Ue;return nt(((Ue=je.result)==null?void 0:Ue.toString().split(",")[1])||"")},je.onerror=rt,je.readAsDataURL(be)}),lt={name:$,mime_type:B.mime_type||"application/octet-stream",content:Xe,last_modified:B.last_modified||new Date().toISOString()};return _(nt=>nt.map(rt=>rt.filename===$?{...rt,accumulatedContent:void 0,needsEmbedResolution:!1}:rt)),lt}catch(B){return console.error(`Error downloading artifact ${$}:`,B),ie(`Error downloading artifact: ${B instanceof Error?B.message:"Unknown error"}`,"error"),null}finally{V.current.delete($)}},[a,f,F,ie,_]),Rt=d.useCallback($=>{var nt,rt,je;I.current+=1;const B=I.current;let Y;try{Y=JSON.parse($.data)}catch(Ue){console.error("Failed to parse SSE message:",Ue),ie("Received unparseable agent update.","error");return}if("error"in Y&&Y.error){const Ce=`Error: ${Y.error.message}`;x(ye=>{const me=ye.filter(he=>!he.isStatusBubble);return me.push({role:"agent",parts:[{kind:"text",text:Ce}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${crypto.randomUUID()}`,lastProcessedEventSequence:B}}),me}),w(!1),Re(),E(null);return}if(!("result"in Y)||!Y.result){console.warn("Received SSE message without a result or error field.",Y);return}const ee=Y.result;let fe=!1,ge,be;switch(ee.kind){case"task":fe=!0,ge=void 0,be=ee.id;break;case"status-update":fe=ee.final,ge=(nt=ee.status)==null?void 0:nt.message,be=ee.taskId;break;case"artifact-update":P();return;default:console.warn("Received unknown result kind in SSE message:",ee);return}if(ge!=null&&ge.parts){const Ue=ge.parts.filter(Ce=>Ce.kind==="data");if(Ue.length>0)for(const Ce of Ue){const ye=Ce.data;if(ye&&typeof ye=="object"&&"type"in ye)switch(ye.type){case"agent_progress_update":{if(j.current=String((ye==null?void 0:ye.status_text)??"Processing..."),ge.parts.filter(he=>he.kind!=="data").length===0)return;break}case"artifact_creation_progress":{const{filename:me,status:he,bytes_transferred:Ee,mime_type:$e,description:Ve,artifact_chunk:Qe,version:Lc}=ye;let Oc=!1;_(fr=>{const Cn=fr.findIndex(Sn=>Sn.filename===me);if(Cn>=0){const Sn=[...fr],Ze=Sn[Cn],pn=Ze.isDisplayed||!1;return he==="completed"&&pn&&(Oc=!0),Sn[Cn]={...Ze,description:Ve!==void 0?Ve:Ze.description,size:Ee||Ze.size,last_modified:new Date().toISOString(),uri:Ze.uri||`artifact://${f}/${me}`,accumulatedContent:he==="in-progress"&&Qe?(Ze.accumulatedContent||"")+Qe:he==="completed"&&!pn?void 0:Ze.accumulatedContent,isAccumulatedContentPlainText:he==="in-progress"&&Qe?!0:Ze.isAccumulatedContentPlainText,mime_type:he==="completed"&&$e?$e:Ze.mime_type,needsEmbedResolution:he==="completed"?!0:Ze.needsEmbedResolution},Sn}else if(Ve!==void 0||he==="in-progress")return[...fr,{filename:me,description:Ve||null,mime_type:$e||"application/octet-stream",size:Ee||0,last_modified:new Date().toISOString(),uri:`artifact://${f}/${me}`,accumulatedContent:he==="in-progress"&&Qe?Qe:void 0,isAccumulatedContentPlainText:!!(he==="in-progress"&&Qe),needsEmbedResolution:he==="completed"}];return fr}),Oc&&setTimeout(()=>{Ke(me).catch(fr=>{console.error(`Auto-download failed for ${me}:`,fr)})},100),x(fr=>{const Cn=[...fr];let Sn=Cn.findLastIndex(ht=>!ht.isUser&&ht.taskId===be);if(Sn===-1){const ht={role:"agent",parts:[],taskId:be,isUser:!1,isComplete:!1,isStatusBubble:!1,metadata:{lastProcessedEventSequence:B}};Cn.push(ht),Sn=Cn.length-1}const Ze={...Cn[Sn],parts:[...Cn[Sn].parts]};Ze.isStatusBubble=!1;const pn=Ze.parts.findIndex(ht=>ht.kind==="artifact"&&ht.name===me);if(he==="in-progress")if(pn>-1){const Yr={...Ze.parts[pn],bytesTransferred:Ee,status:"in-progress"};Ze.parts[pn]=Yr}else{const ht={kind:"artifact",status:"in-progress",name:me,bytesTransferred:Ee};Ze.parts.push(ht)}else if(he==="completed"){const ht={name:me,mime_type:$e,uri:Lc!==void 0?`artifact://${f}/${me}?version=${Lc}`:`artifact://${f}/${me}`};if(pn>-1){const _o={...Ze.parts[pn],status:"completed",file:ht};delete _o.bytesTransferred,Ze.parts[pn]=_o}else Ze.parts.push({kind:"artifact",status:"completed",name:me,file:ht});P()}else{const ht=`Failed to create artifact: ${me}`;if(pn>-1){const _o={...Ze.parts[pn],status:"failed",error:ht};delete _o.bytesTransferred,Ze.parts[pn]=_o}else Ze.parts.push({kind:"artifact",status:"failed",name:me,error:ht});Ze.isError=!0}return Cn[Sn]=Ze,Cn.filter(ht=>!ht.isStatusBubble||ht.parts.some(Yr=>Yr.kind==="artifact"||Yr.kind==="file"))});return}case"tool_invocation_start":break;case"authentication_required":{const me=ye==null?void 0:ye.auth_uri,he=typeof(ye==null?void 0:ye.target_agent)=="string"?ye.target_agent:"Agent",Ee=typeof(ye==null?void 0:ye.gateway_task_id)=="string"?ye.gateway_task_id:void 0;if(typeof me=="string"&&me.startsWith("http")){const $e={role:"agent",parts:[{kind:"text",text:""}],authenticationLink:{url:me,text:"Click to Authenticate",targetAgent:he,gatewayTaskId:Ee},isUser:!1,isComplete:!0,metadata:{messageId:`auth-${bN()}`}};x(Ve=>[...Ve,$e])}break}default:console.warn("Received unknown data part type:",ye.type)}else if(((rt=Ce.metadata)==null?void 0:rt.tool_name)==="_notify_artifact_save"){const me=ye;me.status==="success"&&x(he=>he.map(Ee=>Ee.isUser||!Ee.parts.some($e=>$e.kind==="artifact"&&$e.name===me.filename)?Ee:{...Ee,parts:Ee.parts.map($e=>{if($e.kind==="artifact"&&$e.name===me.filename){const Ve={name:me.filename,uri:`artifact://${f}/${me.filename}`};return{kind:"artifact",status:"completed",name:me.filename,file:Ve}}return $e})}))}}}const Xe=((je=ge==null?void 0:ge.parts)==null?void 0:je.filter(Ue=>Ue.kind!=="data"))||[],lt=Xe.some(Ue=>Ue.kind==="file");x(Ue=>{var me;const Ce=[...Ue];let ye=Ce[Ce.length-1];if(ye!=null&&ye.isStatusBubble&&(Ce.pop(),ye=Ce[Ce.length-1]),ye&&!ye.isUser&&ye.taskId===ee.taskId&&Xe.length>0){const he={...ye,parts:[...ye.parts,...Xe],isComplete:fe||lt,metadata:{...ye.metadata,lastProcessedEventSequence:B}};Ce[Ce.length-1]=he}else if(Xe.some(Ee=>Ee.kind==="text"&&Ee.text.trim()||Ee.kind==="file")){const Ee={role:"agent",parts:Xe,taskId:ee.taskId,isUser:!1,isComplete:fe||lt,metadata:{messageId:((me=Y.id)==null?void 0:me.toString())||`msg-${crypto.randomUUID()}`,sessionId:ee.contextId,lastProcessedEventSequence:B}};Ce.push(Ee)}if(fe){j.current=null;for(let Ee=Ce.length-1;Ee>=0;Ee--){const $e=Ce[Ee];if($e.taskId===be&&$e.parts.some(Ve=>Ve.kind==="artifact"&&Ve.status==="in-progress")){const Ve=$e.parts.map(Qe=>Qe.kind==="artifact"&&Qe.status==="in-progress"?{...Qe,status:"failed",error:`Artifact creation for "${Qe.name}" did not complete.`}:Qe);Ce[Ee]={...$e,parts:Ve,isError:!0,isComplete:!0}}}const he=Ce.findLastIndex(Ee=>!Ee.isUser&&Ee.taskId===be);he!==-1&&(Ce[he]={...Ce[he],isComplete:!0,metadata:{...Ce[he].metadata,lastProcessedEventSequence:B}})}return Ce}),fe&&(M.current&&(ie("Task successfully cancelled."),R.current&&clearTimeout(R.current),k(!1)),be&&f&&x(Ue=>{var ye;const Ce=Ue.filter(me=>me.taskId===be&&!me.isStatusBubble);if(Ce.length>0){const me=Ce.map(Gt),he=Ce.find(Qe=>Qe.isUser),Ee=((ye=he==null?void 0:he.parts)==null?void 0:ye.filter(Qe=>Qe.kind==="text").map(Qe=>Qe.text).join(""))||"",Ve=Ce.some(Qe=>Qe.isError)?"error":"completed";Yt({task_id:be,user_message:Ee,message_bubbles:me,task_metadata:{schema_version:Hs,status:Ve,agent_name:C}})}return Ue}),x(Ue=>Ue.map(Ce=>Ce.isUser||!Ce.parts.some(me=>me.kind==="artifact"&&me.status==="in-progress")?Ce:{...Ce,parts:Ce.parts.map(me=>{var he;if(me.kind==="artifact"&&me.status==="in-progress"){const Ee=me,$e={name:Ee.name,mime_type:(he=Ee.file)==null?void 0:he.mime_type,uri:`artifact://${f}/${Ee.name}`};return{kind:"artifact",status:"completed",name:Ee.name,file:$e}}return me})})),w(!1),Re(),E(null),q.current=!0,P(),setTimeout(()=>{q.current=!1},100))},[ie,Re,P,f,C,Yt,Gt,Ke,_]),we=d.useCallback(async($=!1)=>{const B="ChatProvider.handleNewSession:";if(Re(),g&&y&&C&&!N)try{const Y={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:y}};Ne(`${a}/tasks/${y}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y),credentials:"include"})}catch(Y){console.warn(`${B} Failed to cancel current task:`,Y)}R.current&&(clearTimeout(R.current),R.current=null),k(!1),console.log(`${B} Resetting session state - new session will be created when first message is sent`),m(""),cn(null),i&&!$?l(null):i&&$&&console.log(`${B} Preserving project context: ${i.name}`),S(""),x([]),w(!1),E(null),G(null),Mt(null),q.current=!1,j.current=null,I.current=0,ie("New session started successfully."),typeof window<"u"&&window.dispatchEvent(new CustomEvent("focus-chat-input"))},[a,g,y,C,N,ie,Re,i,l,Mt]),ze=d.useCallback(async $=>{const B="ChatProvider.handleSwitchSession:";if(console.log(`${B} Switching to session ${$}...`),Dn(!0),x([]),Re(),g&&y&&C&&!N){console.log(`${B} Cancelling current task ${y}`);try{const Y={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:y}};await Ne(`${a}/tasks/${y}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y),credentials:"include"})}catch(Y){console.warn(`${B} Failed to cancel current task:`,Y)}}R.current&&(clearTimeout(R.current),R.current=null),k(!1);try{const Y=await Ne(`${a}/sessions/${$}`);let ee=null;if(Y.ok){const fe=await Y.json();if(ee=fe==null?void 0:fe.data,cn((ee==null?void 0:ee.name)??"N/A"),Qn.current=!0,ee!=null&&ee.projectId)if(console.log(`${B} Session belongs to project ${ee.projectId}`),(i==null?void 0:i.id)!==ee.projectId){const ge=c.find(be=>be.id===(ee==null?void 0:ee.projectId));ge?(console.log(`${B} Activating project context: ${ge.name}`),l(ge)):console.warn(`${B} Project ${ee.projectId} not found in projects array`)}else console.log(`${B} Already in correct project context`);else i!==null&&(console.log(`${B} Session has no project, deactivating project context`),l(null))}m($),w(!1),E(null),G(null),Mt(null),q.current=!1,j.current=null,I.current=0,await Jt($)}catch(Y){console.error(`${B} Failed to fetch session history:`,Y),ie("Error switching session. Please try again.","error")}finally{Dn(!1)}},[Re,g,y,C,N,a,ie,Jt,i,c,l,Mt]),tt=d.useCallback(async($,B)=>{try{const Y=await Ne(`${a}/sessions/${$}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})});if(!Y.ok){const ee=await Y.json().catch(()=>({detail:"Failed to update session name"}));throw new Error(ee.detail||`HTTP error ${Y.status}`)}ie("Session name updated successfully."),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(Y){ie(`Error updating session name: ${Y instanceof Error?Y.message:"Unknown error"}`)}},[a,ie]),ae=d.useCallback(async $=>{try{const B=await Ne(`${a}/sessions/${$}`,{method:"DELETE"});if(!B.ok){const Y=await B.json().catch(()=>({detail:"Failed to delete session"}));throw new Error(Y.detail||`HTTP error ${B.status}`)}ie("Session deleted successfully."),$===f&&we(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(B){ie(`Error deleting session: ${B instanceof Error?B.message:"Unknown error"}`)}},[a,ie,we,f]),A=d.useCallback($=>{Xt(B=>{const Y=new Set(B.expandedArtifacts);return Y.has($)?Y.delete($):Y.add($),{...B,expandedArtifacts:Y}})},[]),Z=d.useCallback($=>an.expandedArtifacts.has($),[an.expandedArtifacts]),se=d.useCallback(($,B)=>{_(Y=>Y.map(ee=>ee.filename===$?{...ee,isDisplayed:B}:ee))},[]),We=d.useCallback($=>{Ge($)},[]),it=d.useCallback(()=>{Ge(null)},[]),Je=d.useCallback(async()=>{dn&&(await ae(dn.id),Ge(null))},[dn,ae]),mt=d.useCallback(async()=>{if(!g&&!N||!y){ie("No active task to cancel.");return}if(N){ie("Cancellation already in progress.");return}ie(`Requesting cancellation for task ${y}...`),k(!0);try{const $={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"tasks/cancel",params:{id:y}},B=await Ne(`${a}/tasks/${y}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});if(B.status===202)R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{ie(`Cancellation for task ${y} timed out. Allowing new input.`),k(!1),w(!1),Re(),E(null),R.current=null,x(Y=>Y.filter(ee=>!ee.isStatusBubble))},15e3);else{const Y=await B.json().catch(()=>({detail:"Unknown cancellation error"}));ie(`Failed to request cancellation: ${Y.detail||B.statusText}`),k(!1)}}catch($){ie(`Error sending cancellation request: ${$ instanceof Error?$.message:"Network error"}`),k(!1)}},[g,N,y,a,ie,Re]),He=d.useCallback(async($,B,Y)=>{if(!f){console.error("Cannot submit feedback without a session ID.");return}try{await W0({taskId:$,sessionId:f,feedbackType:B,feedbackText:Y}),bt(ee=>({...ee,[$]:{type:B,text:Y}}))}catch(ee){throw console.error("Failed to submit feedback:",ee),ie("Failed to submit feedback. Please try again.","error"),ee}},[f,ie]),Pt=d.useCallback(()=>{},[]),fn=d.useCallback(()=>{g&&!q.current&&!M.current&&ie("Connection error with agent updates."),q.current||(w(!1),M.current||(Re(),E(null)),j.current=null),x($=>$.filter(B=>!B.isStatusBubble).map((B,Y,ee)=>Y===ee.length-1&&!B.isUser?{...B,isComplete:!0}:B))},[ie,Re,g]),Ye=d.useCallback(async($,B,Y)=>{$.preventDefault();const ee=(Y==null?void 0:Y.trim())||"",fe=B||[];if(!ee&&fe.length===0||g||N||!C){C||ie("Please select an agent first."),N&&ie("Cannot send new message while a task is being cancelled.");return}Re(),q.current=!1,w(!0),E(null),j.current=null,I.current=0;const ge={role:"user",parts:[{kind:"text",text:ee}],isUser:!0,uploadedFiles:fe.length>0?fe:void 0,metadata:{messageId:`msg-${crypto.randomUUID()}`,sessionId:f,lastProcessedEventSequence:0}};j.current="Thinking",x(be=>[...be,ge]);try{const be=fe.map(async he=>{if(he.size<u)return{kind:"file",file:{bytes:await p(he),name:he.name,mimeType:he.type}};{const Ee=await wn(he);return Ee?{kind:"file",file:{uri:Ee.uri,name:he.name,mimeType:he.type}}:(ie(`Failed to upload large file: ${he.name}`,"error"),null)}}),Xe=(await Promise.all(be)).filter(he=>he!==null),lt=[];if(ee&&lt.push({kind:"text",text:ee}),lt.push(...Xe),lt.length===0)throw new Error("Cannot send an empty message.");console.log(`ChatProvider handleSubmit: Using sessionId for contextId: ${f}`);const nt={role:"user",parts:lt,messageId:`msg-${crypto.randomUUID()}`,kind:"message",contextId:f,metadata:{agent_name:C,project_id:(i==null?void 0:i.id)||null}},rt={jsonrpc:"2.0",id:`req-${crypto.randomUUID()}`,method:"message/stream",params:{message:nt}};console.log("ChatProvider handleSubmit: Sending POST to /message:stream");const je=await Ne(`${a}/message:stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(rt)});if(!je.ok){const he=await je.json().catch(()=>({detail:"Unknown error"}));throw console.error("ChatProvider handleSubmit: Error from /message:stream",je.status,he),new Error(he.detail||`HTTP error ${je.status}`)}const Ue=await je.json(),Ce=Ue==null?void 0:Ue.result,ye=Ce==null?void 0:Ce.id,me=Ce==null?void 0:Ce.contextId;if(console.log(`ChatProvider handleSubmit: Extracted responseSessionId: ${me}, current sessionId: ${f}`),console.log("ChatProvider handleSubmit: Full result object:",Ue),!ye)throw console.error("ChatProvider handleSubmit: Backend did not return a valid taskId. Result:",Ue),new Error("Backend did not return a valid taskId.");if(console.log(`ChatProvider handleSubmit: Checking session update condition - responseSessionId: ${me}, sessionId: ${f}, different: ${me!==f}`),me&&me!==f){console.log(`ChatProvider handleSubmit: Updating sessionId from ${f} to ${me}`);const he=!f||f==="";if(m(me),x(Ee=>Ee.map($e=>{var Ve,Qe;return((Ve=$e.metadata)==null?void 0:Ve.messageId)===((Qe=ge.metadata)==null?void 0:Qe.messageId)?{...$e,metadata:{...$e.metadata,sessionId:me}}:$e})),await Yt({task_id:ye,user_message:ee,message_bubbles:[Gt(ge)],task_metadata:{schema_version:Hs,status:"pending",agent_name:C}}),he){const $e=ge.parts.filter(Ve=>Ve.kind==="text").map(Ve=>Ve.text).join(" ").trim();if($e){const Ve=$e.length>100?`${$e.substring(0,100)}...`:$e;cn(Ve),await tt(me,Ve)}}he&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}console.log(`ChatProvider handleSubmit: Received taskId ${ye}. Setting currentTaskId and taskIdInSidePanel.`),E(ye),G(ye),x(he=>he.map(Ee=>{var $e,Ve;return(($e=Ee.metadata)==null?void 0:$e.messageId)===((Ve=ge.metadata)==null?void 0:Ve.messageId)?{...Ee,taskId:ye}:Ee}))}catch(be){console.error("ChatProvider handleSubmit: Catch block error",be),ie(`Error: ${be instanceof Error?be.message:"Unknown error"}`),w(!1),x(Xe=>Xe.filter(lt=>!lt.isStatusBubble)),E(null),q.current=!1,j.current=null}},[f,g,N,C,Re,ie,a,wn,tt,Yt,Gt,u,i]),Gr=d.useRef(""),Qn=d.useRef(!1),er=d.useRef(!1);d.useEffect(()=>{UC(B=>{(i==null?void 0:i.id)===B&&(console.log(`Project ${B} was deleted, clearing session context`),we(!1))})},[i,we]),d.useEffect(()=>{const $=async B=>{const Y=B,{sessionId:ee,projectId:fe}=Y.detail;if(ee===f)if(er.current=!0,fe){const ge=c.find(be=>be.id===fe);ge&&l(ge)}else l(null)};return window.addEventListener("session-moved",$),()=>{window.removeEventListener("session-moved",$)}},[f,c,l]),d.useEffect(()=>{const $=Gr.current,B=i==null?void 0:i.id;B!==void 0&&$!==B&&!Qn.current&&!er.current&&(console.log("Active project changed explicitly, resetting chat view and preserving project context."),we(!0)),Gr.current=B,Qn.current=!1,er.current=!1},[i,we]),d.useEffect(()=>{if(!C&&D.length>0&&h.length===0&&!It){let $=D[0];if(i!=null&&i.defaultAgentId){const Y=D.find(ee=>ee.name===i.defaultAgentId);Y?($=Y,console.log(`Using project default agent: ${$.name}`)):(console.warn(`Project default agent "${i.defaultAgentId}" not found, falling back to OrchestratorAgent`),$=D.find(ee=>ee.name==="OrchestratorAgent")??D[0])}else $=D.find(Y=>Y.name==="OrchestratorAgent")??D[0];S($.name);const B=t||`Hi! I'm the ${$==null?void 0:$.displayName}. How can I help?`;x([{parts:[{kind:"text",text:B}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}])}},[D,t,h.length,C,f,It,i]);const ko=d.useRef(Rt),Ao=d.useRef(Pt),To=d.useRef(fn);d.useEffect(()=>{ko.current=Rt,Ao.current=Pt,To.current=fn},[Rt,Pt,fn]),d.useEffect(()=>{if(y&&a){const $=Pl(),B=`${a}/sse/subscribe/${y}${$?`?token=${$}`:""}`,Y=new EventSource(B,{withCredentials:!0});T.current=Y;const ee=()=>{Ao.current()},fe=()=>{To.current()},ge=be=>{ko.current(be)};return Y.onopen=ee,Y.onerror=fe,Y.addEventListener("status_update",ge),Y.addEventListener("artifact_update",ge),Y.addEventListener("final_response",ge),Y.addEventListener("error",ge),()=>{Y.removeEventListener("status_update",ge),Y.removeEventListener("artifact_update",ge),Y.removeEventListener("final_response",ge),Y.removeEventListener("error",ge),Y.close()}}else Re()},[y,a,Re]);const As={configCollectFeedback:o,submittedFeedback:ln,handleFeedbackSubmit:He,sessionId:f,setSessionId:m,sessionName:Qt,setSessionName:cn,messages:h,setMessages:x,isResponding:g,currentTaskId:y,isCancelling:N,latestStatusText:j,isLoadingSession:It,agents:D,agentsLoading:J,agentsError:z,agentsRefetch:U,handleNewSession:we,handleSwitchSession:ze,handleSubmit:Ye,handleCancel:mt,notifications:v,addNotification:ie,selectedAgentName:C,setSelectedAgentName:S,artifacts:F,artifactsLoading:W,artifactsRefetch:P,setArtifacts:_,uploadArtifactFile:wn,isSidePanelCollapsed:H,activeSidePanelTab:Q,setIsSidePanelCollapsed:X,setActiveSidePanelTab:oe,openSidePanelTab:at,taskIdInSidePanel:K,setTaskIdInSidePanel:G,isDeleteModalOpen:re,artifactToDelete:ne,openDeleteModal:yn,closeDeleteModal:un,confirmDelete:ke,openSessionDeleteModal:We,closeSessionDeleteModal:it,confirmSessionDelete:Je,sessionToDelete:dn,isArtifactEditMode:Oe,setIsArtifactEditMode:De,selectedArtifactFilenames:Te,setSelectedArtifactFilenames:Be,handleDeleteSelectedArtifacts:_e,confirmBatchDeleteArtifacts:Fe,isBatchDeleteModalOpen:Et,setIsBatchDeleteModalOpen:et,previewedArtifactAvailableVersions:ut,currentPreviewedVersionNumber:st,previewFileContent:Rn,openArtifactForPreview:Me,navigateArtifactVersion:yt,openMessageAttachmentForPreview:pt,previewArtifact:Ot,setPreviewArtifact:Mt,updateSessionName:tt,deleteSession:ae,toggleArtifactExpanded:A,isArtifactExpanded:Z,setArtifactRenderingState:Xt,artifactRenderingState:an,markArtifactAsDisplayed:se,downloadAndResolveArtifact:Ke};return s.jsx(im.Provider,{value:As,children:e})},EN=({children:e})=>{const{frontend_use_authorization:t,configAuthLoginUrl:n}=_t(),{fetchCsrfToken:r,clearCsrfToken:o}=vm(),[a,i]=d.useState(!1),[l,c]=d.useState(!0),[u,p]=d.useState(null);d.useEffect(()=>{let h=!0;const x=async()=>{if(!t){h&&(i(!0),c(!1));return}try{const w=await Ne("/api/v1/users/me",{credentials:"include",headers:{Accept:"application/json"}});if(w.ok){const v=await w.json();console.log("User is authenticated:",v),h&&(p(v),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}else w.status===401?(console.log("User is not authenticated"),h&&i(!1)):(console.error("Unexpected response from /users/me:",w.status),h&&i(!1))}catch(w){console.error("Error checking authentication:",w),h&&i(!1)}finally{h&&c(!1)}};x();const g=w=>{w.key==="access_token"&&x()};return window.addEventListener("storage",g),()=>{h=!1,window.removeEventListener("storage",g)}},[t,n,r]);const f=()=>{window.location.href=n},m=()=>{i(!1),p(null),o()};return l?s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),s.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Checking Authentication..."})]})}):s.jsx(am.Provider,{value:{isAuthenticated:a,useAuthorization:t,login:f,logout:m,userInfo:u},children:e})};function NN(e){var r;if(typeof document>"u")return null;const n=`; ${document.cookie}`.split(`; ${e}=`);return n.length===2&&((r=n.pop())==null?void 0:r.split(";").shift())||null}const jN=e=>new Promise(t=>setTimeout(t,e)),kN=async(e=5,t=50)=>{try{const n=await Ne("/api/v1/csrf-token",{credentials:"include"});if(!n.ok)throw new Error(`CSRF endpoint returned status ${n.status}`);const r=await n.json();if(r.csrf_token)return console.log("CSRF token found in response body:",r.csrf_token),r.csrf_token;for(let o=0;o<e;o++){const a=NN("csrf_token");if(a)return console.log(`CSRF token found in cookie after ${o} retries:`,a),a;console.log(`CSRF token not found in cookie, attempt ${o+1}/${e}. Waiting ${t}ms...`),await jN(t)}throw new Error("CSRF token not available in response or cookie after retries")}catch(n){return console.error("Error fetching/reading CSRF token:",n),null}};function AN({children:e}){const[t,n]=d.useState(null),r=d.useCallback(async()=>{if(t)return t;const i=await kN();if(i)n(i);else throw new Error("Failed to obtain CSRF token after config fetch failed.");return i},[t]),o=d.useCallback(()=>{n(null)},[]),a={fetchCsrfToken:r,clearCsrfToken:o};return s.jsx(cm.Provider,{value:a,children:e})}const TN={brand:{wMain:"#00C895",w30:"#B3EFDF",wMain30:"#00C8954d",w10:"#E6FAF4",w60:"#66DEBF",w100:"#00AD93"},primary:{w100:"#01374E",w90:"#014968",wMain:"#015B82",w60:"#679DB4",w40:"#99BDCD",w20:"#CCDEE6",w10:"#E6EFF2",text:{wMain:"#273749",w100:"#000000",w10:"#CCCCCC"}},secondary:{w70:"#536574",w80:"#354E62",w8040:"#354E6240",w100:"#000000",wMain:"#8790A0",w40:"#CFD3D9",w20:"#E7E9EC",w10:"#F3F4F6",text:{wMain:"#647481",w50:"#B1B9C0"}},background:{w100:"#021B2F",wMain:"#03223B",w20:"#F7F8F9",w10:"#FFFFFF"},info:{w100:"#2B71B1",wMain:"#0591D3",w70:"#7CD3F6",w30:"#B4DEF2",w20:"#CDE9F6",w10:"#E6F4FB"},error:{w100:"#C33135",wMain:"#E94C4E",w70:"#ED9B9D",w30:"#F8C9CA",w20:"#FBDBDC",w10:"#FDEDED"},warning:{w100:"#E1681F",wMain:"#FF8E2B",w70:"#F8C785",w30:"#FFDDBF",w20:"#FFE8D5",w10:"#FFF4EA"},success:{w100:"#006B53",wMain:"#009A80",w70:"#6FCCBC",w30:"#B3E1D9",w20:"#CCEBE6",w10:"#E6F5F2"},stateLayer:{w10:"#03223B1a",w20:"#03223B33"},accent:{n0:{w100:"#2F51AD",wMain:"#3C69E1",w30:"#C5D2F6",w10:"#ECF0FC"},n1:{w100:"#1F284C",wMain:"#3A4880",w30:"#C4C8D9",w60:"#8991B3",w20:"#D8DAE6",w10:"#EBEDF2"},n2:{w100:"#165E64",wMain:"#009193",w30:"#B3DEDF",w20:"#CCE9E9",w10:"#E6F4F4"},n3:{w100:"#542D75",wMain:"#7841A8",w30:"#D7C6E5",w10:"#F2ECF6"},n4:{w100:"#951379",wMain:"#CB1AA5",w30:"#F2C4E8"},n5:{w100:"#D03C1B",wMain:"#F66651",w30:"#FCCEC7",w60:"#FAA397"},n6:{w100:"#DE7E00",wMain:"#FCA829",w30:"#FEE5BF"},n7:{w100:"#2DADE1",wMain:"#7CD3F6",w30:"#CBEDFB"},n8:{w100:"#4F5A63",wMain:"#86939E",w30:"#DBDFE2"},n9:{wMain:"#DA162D"}},learning:{wMain:"#033A6F",w90:"#022E59",w100:"#022343",w20:"#CDD8E2",w10:"#E6EBF1"}},_N={light:{background:"background.w10",foreground:"primary.text.wMain",card:"background.w10","card-foreground":"primary.text.wMain",popover:"background.w10","popover-foreground":"primary.text.wMain",primary:"primary.wMain","primary-foreground":"primary.text.w10",secondary:"secondary.w10","secondary-foreground":"secondary.text.wMain",muted:"secondary.w10","muted-foreground":"secondary.text.wMain",accent:"secondary.w40","accent-foreground":"secondary.text.wMain",destructive:"error.wMain",border:"secondary.w40",input:"secondary.w40",ring:"brand.wMain","ring-offset":"brand.wMain","accent-background":"background.w20","message-background":"secondary.w20","chart-1":"brand.w60","chart-2":"primary.wMain","chart-3":"accent.n3.wMain","chart-4":"accent.n6.wMain","chart-5":"accent.n5.wMain",sidebar:"background.w20","sidebar-foreground":"primary.text.wMain","sidebar-primary":"primary.wMain","sidebar-primary-foreground":"primary.text.w10","sidebar-accent":"secondary.w10","sidebar-accent-foreground":"secondary.text.wMain","sidebar-border":"secondary.w40","sidebar-ring":"brand.wMain"},dark:{background:"background.w100",foreground:"primary.text.w10",card:"background.wMain","card-foreground":"primary.text.w10",popover:"background.wMain","popover-foreground":"primary.text.w10",primary:"primary.w60","primary-foreground":"primary.text.wMain",secondary:"secondary.w80","secondary-foreground":"secondary.text.w50",muted:"secondary.w80","muted-foreground":"secondary.text.w50",accent:"secondary.w80","accent-foreground":"secondary.text.w50",destructive:"error.w70",border:"secondary.w70",input:"secondary.w70",ring:"brand.w60","ring-offset":"brand.w60","accent-background":"primary.w90","message-background":"secondary.w70","chart-1":"brand.w100","chart-2":"primary.wMain","chart-3":"accent.n3.w100","chart-4":"accent.n6.w30","chart-5":"accent.n5.w60",sidebar:"background.wMain","sidebar-foreground":"primary.text.w10","sidebar-primary":"primary.w60","sidebar-primary-foreground":"primary.text.wMain","sidebar-accent":"secondary.w80","sidebar-accent-foreground":"secondary.text.w50","sidebar-border":"secondary.w70","sidebar-ring":"brand.w60"}},IN={"error-text-wMain":"error.wMain","error-text-w50":"error.w70","warning-text-wMain":"warning.wMain","warning-text-w50":"warning.w70","success-text-wMain":"success.wMain","success-text-w50":"success.w70","info-text-wMain":"info.wMain","info-text-w50":"info.w70"};function Kd(e,t){const n=t.split(".");let r=e;for(const o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return console.warn(`Color path not found: ${t}`),"#000000";return typeof r=="string"?r:"#000000"}function MN(e,t){const n={},r=_N[t];for(const[o,a]of Object.entries(r)){const i=Kd(e,a);n[`--${o}`]=i}for(const[o,a]of Object.entries(IN)){const i=Kd(e,a);n[`--color-${o}`]=i}return n}const ga="sam-theme";function RN(e){var n,r,o,a,i,l,c,u,p,f,m,h,x,g,w,v,b,y,E,T,C,S,N,k,M,L,O,V,K,G,R,q,j,I,D,z,J,U,F,W,P,_,H,X,Q,oe,re,de,ne,ue,Oe,De,Te,Be,Et,et,wt,Lt,ut,ft,st,qt,Rn,Vt,Ot,an,Xt,ln,bt,ie,Gt,Yt,Pn,Zt,Jt,wn,Qt,cn,dn,Ge,It,Dn,bn,yn,un,Mt,ke,_e,Fe,Me,yt,pt,at,Re,Ke,Rt,we,ze,tt,ae,A,Z,se;const t={};return e.brand.wMain&&(t["--color-brand-wMain"]=e.brand.wMain),e.brand.wMain30&&(t["--color-brand-wMain30"]=e.brand.wMain30),e.brand.w100&&(t["--color-brand-w100"]=e.brand.w100),e.brand.w60&&(t["--color-brand-w60"]=e.brand.w60),e.brand.w30&&(t["--color-brand-w30"]=e.brand.w30),e.brand.w10&&(t["--color-brand-w10"]=e.brand.w10),e.primary.wMain&&(t["--color-primary-wMain"]=e.primary.wMain),e.primary.w100&&(t["--color-primary-w100"]=e.primary.w100),e.primary.w90&&(t["--color-primary-w90"]=e.primary.w90),e.primary.w60&&(t["--color-primary-w60"]=e.primary.w60),e.primary.w40&&(t["--color-primary-w40"]=e.primary.w40),e.primary.w20&&(t["--color-primary-w20"]=e.primary.w20),e.primary.w10&&(t["--color-primary-w10"]=e.primary.w10),e.primary.text.wMain&&(t["--color-primary-text-wMain"]=e.primary.text.wMain),e.primary.text.w100&&(t["--color-primary-text-w100"]=e.primary.text.w100),e.primary.text.w10&&(t["--color-primary-text-w10"]=e.primary.text.w10),e.secondary.wMain&&(t["--color-secondary-wMain"]=e.secondary.wMain),e.secondary.w100&&(t["--color-secondary-w100"]=e.secondary.w100),e.secondary.w80&&(t["--color-secondary-w80"]=e.secondary.w80),e.secondary.w8040&&(t["--color-secondary-w8040"]=e.secondary.w8040),e.secondary.w70&&(t["--color-secondary-w70"]=e.secondary.w70),e.secondary.w40&&(t["--color-secondary-w40"]=e.secondary.w40),e.secondary.w20&&(t["--color-secondary-w20"]=e.secondary.w20),e.secondary.w10&&(t["--color-secondary-w10"]=e.secondary.w10),e.secondary.text.wMain&&(t["--color-secondary-text-wMain"]=e.secondary.text.wMain),e.secondary.text.w50&&(t["--color-secondary-text-w50"]=e.secondary.text.w50),e.background.wMain&&(t["--color-background-wMain"]=e.background.wMain),e.background.w100&&(t["--color-background-w100"]=e.background.w100),e.background.w20&&(t["--color-background-w20"]=e.background.w20),e.background.w10&&(t["--color-background-w10"]=e.background.w10),(n=e.info)!=null&&n.wMain&&(t["--color-info-wMain"]=e.info.wMain),(r=e.info)!=null&&r.w100&&(t["--color-info-w100"]=e.info.w100),(o=e.info)!=null&&o.w70&&(t["--color-info-w70"]=e.info.w70),(a=e.info)!=null&&a.w30&&(t["--color-info-w30"]=e.info.w30),(i=e.info)!=null&&i.w20&&(t["--color-info-w20"]=e.info.w20),(l=e.info)!=null&&l.w10&&(t["--color-info-w10"]=e.info.w10),(c=e.error)!=null&&c.wMain&&(t["--color-error-wMain"]=e.error.wMain),(u=e.error)!=null&&u.w100&&(t["--color-error-w100"]=e.error.w100),(p=e.error)!=null&&p.w70&&(t["--color-error-w70"]=e.error.w70),(f=e.error)!=null&&f.w30&&(t["--color-error-w30"]=e.error.w30),(m=e.error)!=null&&m.w20&&(t["--color-error-w20"]=e.error.w20),(h=e.error)!=null&&h.w10&&(t["--color-error-w10"]=e.error.w10),(x=e.warning)!=null&&x.wMain&&(t["--color-warning-wMain"]=e.warning.wMain),(g=e.warning)!=null&&g.w100&&(t["--color-warning-w100"]=e.warning.w100),(w=e.warning)!=null&&w.w70&&(t["--color-warning-w70"]=e.warning.w70),(v=e.warning)!=null&&v.w30&&(t["--color-warning-w30"]=e.warning.w30),(b=e.warning)!=null&&b.w20&&(t["--color-warning-w20"]=e.warning.w20),(y=e.warning)!=null&&y.w10&&(t["--color-warning-w10"]=e.warning.w10),(E=e.success)!=null&&E.wMain&&(t["--color-success-wMain"]=e.success.wMain),(T=e.success)!=null&&T.w100&&(t["--color-success-w100"]=e.success.w100),(C=e.success)!=null&&C.w70&&(t["--color-success-w70"]=e.success.w70),(S=e.success)!=null&&S.w30&&(t["--color-success-w30"]=e.success.w30),(N=e.success)!=null&&N.w20&&(t["--color-success-w20"]=e.success.w20),(k=e.success)!=null&&k.w10&&(t["--color-success-w10"]=e.success.w10),(M=e.stateLayer)!=null&&M.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(L=e.stateLayer)!=null&&L.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(V=(O=e.accent)==null?void 0:O.n0)!=null&&V.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(G=(K=e.accent)==null?void 0:K.n0)!=null&&G.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),(q=(R=e.accent)==null?void 0:R.n0)!=null&&q.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(I=(j=e.accent)==null?void 0:j.n0)!=null&&I.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(z=(D=e.accent)==null?void 0:D.n1)!=null&&z.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(U=(J=e.accent)==null?void 0:J.n1)!=null&&U.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(W=(F=e.accent)==null?void 0:F.n1)!=null&&W.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(_=(P=e.accent)==null?void 0:P.n1)!=null&&_.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(X=(H=e.accent)==null?void 0:H.n1)!=null&&X.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(oe=(Q=e.accent)==null?void 0:Q.n1)!=null&&oe.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(de=(re=e.accent)==null?void 0:re.n2)!=null&&de.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(ue=(ne=e.accent)==null?void 0:ne.n2)!=null&&ue.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(De=(Oe=e.accent)==null?void 0:Oe.n2)!=null&&De.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(Be=(Te=e.accent)==null?void 0:Te.n2)!=null&&Be.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(et=(Et=e.accent)==null?void 0:Et.n2)!=null&&et.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(Lt=(wt=e.accent)==null?void 0:wt.n3)!=null&&Lt.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(ft=(ut=e.accent)==null?void 0:ut.n3)!=null&&ft.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(qt=(st=e.accent)==null?void 0:st.n3)!=null&&qt.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(Vt=(Rn=e.accent)==null?void 0:Rn.n3)!=null&&Vt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(an=(Ot=e.accent)==null?void 0:Ot.n4)!=null&&an.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(ln=(Xt=e.accent)==null?void 0:Xt.n4)!=null&&ln.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(ie=(bt=e.accent)==null?void 0:bt.n4)!=null&&ie.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(Yt=(Gt=e.accent)==null?void 0:Gt.n5)!=null&&Yt.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(Zt=(Pn=e.accent)==null?void 0:Pn.n5)!=null&&Zt.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(wn=(Jt=e.accent)==null?void 0:Jt.n5)!=null&&wn.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(cn=(Qt=e.accent)==null?void 0:Qt.n5)!=null&&cn.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(Ge=(dn=e.accent)==null?void 0:dn.n6)!=null&&Ge.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(Dn=(It=e.accent)==null?void 0:It.n6)!=null&&Dn.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(yn=(bn=e.accent)==null?void 0:bn.n6)!=null&&yn.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),(Mt=(un=e.accent)==null?void 0:un.n7)!=null&&Mt.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(_e=(ke=e.accent)==null?void 0:ke.n7)!=null&&_e.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(Me=(Fe=e.accent)==null?void 0:Fe.n7)!=null&&Me.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(pt=(yt=e.accent)==null?void 0:yt.n8)!=null&&pt.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),(Re=(at=e.accent)==null?void 0:at.n8)!=null&&Re.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(Rt=(Ke=e.accent)==null?void 0:Ke.n8)!=null&&Rt.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),(ze=(we=e.accent)==null?void 0:we.n9)!=null&&ze.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(tt=e.learning)!=null&&tt.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(ae=e.learning)!=null&&ae.w100&&(t["--color-learning-w100"]=e.learning.w100),(A=e.learning)!=null&&A.w90&&(t["--color-learning-w90"]=e.learning.w90),(Z=e.learning)!=null&&Z.w20&&(t["--color-learning-w20"]=e.learning.w20),(se=e.learning)!=null&&se.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function PN(e,t="light"){const n={};if(e){const o=RN(e);Object.assign(n,o)}const r=MN(e,t);return Object.assign(n,r),n}function DN(){const e=localStorage.getItem(ga);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function LN(e,t){const n=PN(e,t),r=document.documentElement;for(const[o,a]of Object.entries(n))r.style.setProperty(o,a);requestAnimationFrame(()=>{console.log(`Applying ${t} theme with palette`),r.classList.remove("light","dark"),r.classList.add(t),localStorage.setItem(ga,t)})}const ON=({children:e})=>{const t=d.useMemo(()=>TN,[]),[n,r]=d.useState(()=>DN()),o=d.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const a=n==="light"?"dark":"light";r(a),localStorage.setItem(ga,a)}}),[n]);return d.useEffect(()=>{if(!(localStorage.getItem(ga)!==null)){const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{r(c.matches?"dark":"light")};return i.addEventListener?i.addEventListener("change",l):i.addListener(l),()=>{i.removeEventListener?i.removeEventListener("change",l):i.removeListener(l)}}},[]),d.useEffect(()=>{document.documentElement.classList.remove("light","dark"),LN(t,n)},[n,t]),s.jsx(um.Provider,{value:o,children:e})};/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:xg,setPrototypeOf:qd,isFrozen:FN,getPrototypeOf:$N,getOwnPropertyDescriptor:zN}=Object;let{freeze:Ut,seal:vn,create:vg}=Object,{apply:cl,construct:dl}=typeof Reflect<"u"&&Reflect;Ut||(Ut=function(t){return t});vn||(vn=function(t){return t});cl||(cl=function(t,n,r){return t.apply(n,r)});dl||(dl=function(t,n){return new t(...n)});const Ws=Bt(Array.prototype.forEach),UN=Bt(Array.prototype.lastIndexOf),Xd=Bt(Array.prototype.pop),Ro=Bt(Array.prototype.push),BN=Bt(Array.prototype.splice),ta=Bt(String.prototype.toLowerCase),ji=Bt(String.prototype.toString),Zd=Bt(String.prototype.match),Po=Bt(String.prototype.replace),HN=Bt(String.prototype.indexOf),WN=Bt(String.prototype.trim),jn=Bt(Object.prototype.hasOwnProperty),Ft=Bt(RegExp.prototype.test),Do=VN(TypeError);function Bt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return cl(e,t,r)}}function VN(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return dl(e,n)}}function Pe(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ta;qd&&qd(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const a=n(o);a!==o&&(FN(t)||(t[r]=a),o=a)}e[o]=!0}return e}function GN(e){for(let t=0;t<e.length;t++)jn(e,t)||(e[t]=null);return e}function nr(e){const t=vg(null);for(const[n,r]of xg(e))jn(e,n)&&(Array.isArray(r)?t[n]=GN(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=nr(r):t[n]=r);return t}function Lo(e,t){for(;e!==null;){const r=zN(e,t);if(r){if(r.get)return Bt(r.get);if(typeof r.value=="function")return Bt(r.value)}e=$N(e)}function n(){return null}return n}const Jd=Ut(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ki=Ut(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ai=Ut(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),YN=Ut(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ti=Ut(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),KN=Ut(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Qd=Ut(["#text"]),eu=Ut(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),_i=Ut(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),tu=Ut(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Vs=Ut(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),qN=vn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),XN=vn(/<%[\w\W]*|[\w\W]*%>/gm),ZN=vn(/\$\{[\w\W]*/gm),JN=vn(/^data-[\-\w.\u00B7-\uFFFF]+$/),QN=vn(/^aria-[\-\w]+$/),wg=vn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ej=vn(/^(?:\w+script|data):/i),tj=vn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bg=vn(/^html$/i),nj=vn(/^[a-z][.\w]*(-[.\w]+)+$/i);var nu=Object.freeze({__proto__:null,ARIA_ATTR:QN,ATTR_WHITESPACE:tj,CUSTOM_ELEMENT:nj,DATA_ATTR:JN,DOCTYPE_NAME:bg,ERB_EXPR:XN,IS_ALLOWED_URI:wg,IS_SCRIPT_OR_DATA:ej,MUSTACHE_EXPR:qN,TMPLIT_EXPR:ZN});const Oo={element:1,text:3,progressingInstruction:7,comment:8,document:9},rj=function(){return typeof window>"u"?null:window},oj=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},ru=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function yg(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:rj();const t=ae=>yg(ae);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==Oo.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:u,NamedNodeMap:p=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:f,DOMParser:m,trustedTypes:h}=e,x=c.prototype,g=Lo(x,"cloneNode"),w=Lo(x,"remove"),v=Lo(x,"nextSibling"),b=Lo(x,"childNodes"),y=Lo(x,"parentNode");if(typeof i=="function"){const ae=n.createElement("template");ae.content&&ae.content.ownerDocument&&(n=ae.content.ownerDocument)}let E,T="";const{implementation:C,createNodeIterator:S,createDocumentFragment:N,getElementsByTagName:k}=n,{importNode:M}=r;let L=ru();t.isSupported=typeof xg=="function"&&typeof y=="function"&&C&&C.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:O,ERB_EXPR:V,TMPLIT_EXPR:K,DATA_ATTR:G,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:j,CUSTOM_ELEMENT:I}=nu;let{IS_ALLOWED_URI:D}=nu,z=null;const J=Pe({},[...Jd,...ki,...Ai,...Ti,...Qd]);let U=null;const F=Pe({},[...eu,..._i,...tu,...Vs]);let W=Object.seal(vg(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),P=null,_=null,H=!0,X=!0,Q=!1,oe=!0,re=!1,de=!0,ne=!1,ue=!1,Oe=!1,De=!1,Te=!1,Be=!1,Et=!0,et=!1;const wt="user-content-";let Lt=!0,ut=!1,ft={},st=null;const qt=Pe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Rn=null;const Vt=Pe({},["audio","video","img","source","image","track"]);let Ot=null;const an=Pe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Xt="http://www.w3.org/1998/Math/MathML",ln="http://www.w3.org/2000/svg",bt="http://www.w3.org/1999/xhtml";let ie=bt,Gt=!1,Yt=null;const Pn=Pe({},[Xt,ln,bt],ji);let Zt=Pe({},["mi","mo","mn","ms","mtext"]),Jt=Pe({},["annotation-xml"]);const wn=Pe({},["title","style","font","a","script"]);let Qt=null;const cn=["application/xhtml+xml","text/html"],dn="text/html";let Ge=null,It=null;const Dn=n.createElement("form"),bn=function(A){return A instanceof RegExp||A instanceof Function},yn=function(){let A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(It&&It===A)){if((!A||typeof A!="object")&&(A={}),A=nr(A),Qt=cn.indexOf(A.PARSER_MEDIA_TYPE)===-1?dn:A.PARSER_MEDIA_TYPE,Ge=Qt==="application/xhtml+xml"?ji:ta,z=jn(A,"ALLOWED_TAGS")?Pe({},A.ALLOWED_TAGS,Ge):J,U=jn(A,"ALLOWED_ATTR")?Pe({},A.ALLOWED_ATTR,Ge):F,Yt=jn(A,"ALLOWED_NAMESPACES")?Pe({},A.ALLOWED_NAMESPACES,ji):Pn,Ot=jn(A,"ADD_URI_SAFE_ATTR")?Pe(nr(an),A.ADD_URI_SAFE_ATTR,Ge):an,Rn=jn(A,"ADD_DATA_URI_TAGS")?Pe(nr(Vt),A.ADD_DATA_URI_TAGS,Ge):Vt,st=jn(A,"FORBID_CONTENTS")?Pe({},A.FORBID_CONTENTS,Ge):qt,P=jn(A,"FORBID_TAGS")?Pe({},A.FORBID_TAGS,Ge):nr({}),_=jn(A,"FORBID_ATTR")?Pe({},A.FORBID_ATTR,Ge):nr({}),ft=jn(A,"USE_PROFILES")?A.USE_PROFILES:!1,H=A.ALLOW_ARIA_ATTR!==!1,X=A.ALLOW_DATA_ATTR!==!1,Q=A.ALLOW_UNKNOWN_PROTOCOLS||!1,oe=A.ALLOW_SELF_CLOSE_IN_ATTR!==!1,re=A.SAFE_FOR_TEMPLATES||!1,de=A.SAFE_FOR_XML!==!1,ne=A.WHOLE_DOCUMENT||!1,De=A.RETURN_DOM||!1,Te=A.RETURN_DOM_FRAGMENT||!1,Be=A.RETURN_TRUSTED_TYPE||!1,Oe=A.FORCE_BODY||!1,Et=A.SANITIZE_DOM!==!1,et=A.SANITIZE_NAMED_PROPS||!1,Lt=A.KEEP_CONTENT!==!1,ut=A.IN_PLACE||!1,D=A.ALLOWED_URI_REGEXP||wg,ie=A.NAMESPACE||bt,Zt=A.MATHML_TEXT_INTEGRATION_POINTS||Zt,Jt=A.HTML_INTEGRATION_POINTS||Jt,W=A.CUSTOM_ELEMENT_HANDLING||{},A.CUSTOM_ELEMENT_HANDLING&&bn(A.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=A.CUSTOM_ELEMENT_HANDLING.tagNameCheck),A.CUSTOM_ELEMENT_HANDLING&&bn(A.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=A.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),A.CUSTOM_ELEMENT_HANDLING&&typeof A.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=A.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),re&&(X=!1),Te&&(De=!0),ft&&(z=Pe({},Qd),U=[],ft.html===!0&&(Pe(z,Jd),Pe(U,eu)),ft.svg===!0&&(Pe(z,ki),Pe(U,_i),Pe(U,Vs)),ft.svgFilters===!0&&(Pe(z,Ai),Pe(U,_i),Pe(U,Vs)),ft.mathMl===!0&&(Pe(z,Ti),Pe(U,tu),Pe(U,Vs))),A.ADD_TAGS&&(z===J&&(z=nr(z)),Pe(z,A.ADD_TAGS,Ge)),A.ADD_ATTR&&(U===F&&(U=nr(U)),Pe(U,A.ADD_ATTR,Ge)),A.ADD_URI_SAFE_ATTR&&Pe(Ot,A.ADD_URI_SAFE_ATTR,Ge),A.FORBID_CONTENTS&&(st===qt&&(st=nr(st)),Pe(st,A.FORBID_CONTENTS,Ge)),Lt&&(z["#text"]=!0),ne&&Pe(z,["html","head","body"]),z.table&&(Pe(z,["tbody"]),delete P.tbody),A.TRUSTED_TYPES_POLICY){if(typeof A.TRUSTED_TYPES_POLICY.createHTML!="function")throw Do('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof A.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Do('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=A.TRUSTED_TYPES_POLICY,T=E.createHTML("")}else E===void 0&&(E=oj(h,o)),E!==null&&typeof T=="string"&&(T=E.createHTML(""));Ut&&Ut(A),It=A}},un=Pe({},[...ki,...Ai,...YN]),Mt=Pe({},[...Ti,...KN]),ke=function(A){let Z=y(A);(!Z||!Z.tagName)&&(Z={namespaceURI:ie,tagName:"template"});const se=ta(A.tagName),We=ta(Z.tagName);return Yt[A.namespaceURI]?A.namespaceURI===ln?Z.namespaceURI===bt?se==="svg":Z.namespaceURI===Xt?se==="svg"&&(We==="annotation-xml"||Zt[We]):!!un[se]:A.namespaceURI===Xt?Z.namespaceURI===bt?se==="math":Z.namespaceURI===ln?se==="math"&&Jt[We]:!!Mt[se]:A.namespaceURI===bt?Z.namespaceURI===ln&&!Jt[We]||Z.namespaceURI===Xt&&!Zt[We]?!1:!Mt[se]&&(wn[se]||!un[se]):!!(Qt==="application/xhtml+xml"&&Yt[A.namespaceURI]):!1},_e=function(A){Ro(t.removed,{element:A});try{y(A).removeChild(A)}catch{w(A)}},Fe=function(A,Z){try{Ro(t.removed,{attribute:Z.getAttributeNode(A),from:Z})}catch{Ro(t.removed,{attribute:null,from:Z})}if(Z.removeAttribute(A),A==="is")if(De||Te)try{_e(Z)}catch{}else try{Z.setAttribute(A,"")}catch{}},Me=function(A){let Z=null,se=null;if(Oe)A="<remove></remove>"+A;else{const Je=Zd(A,/^[\r\n\t ]+/);se=Je&&Je[0]}Qt==="application/xhtml+xml"&&ie===bt&&(A='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+A+"</body></html>");const We=E?E.createHTML(A):A;if(ie===bt)try{Z=new m().parseFromString(We,Qt)}catch{}if(!Z||!Z.documentElement){Z=C.createDocument(ie,"template",null);try{Z.documentElement.innerHTML=Gt?T:We}catch{}}const it=Z.body||Z.documentElement;return A&&se&&it.insertBefore(n.createTextNode(se),it.childNodes[0]||null),ie===bt?k.call(Z,ne?"html":"body")[0]:ne?Z.documentElement:it},yt=function(A){return S.call(A.ownerDocument||A,A,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},pt=function(A){return A instanceof f&&(typeof A.nodeName!="string"||typeof A.textContent!="string"||typeof A.removeChild!="function"||!(A.attributes instanceof p)||typeof A.removeAttribute!="function"||typeof A.setAttribute!="function"||typeof A.namespaceURI!="string"||typeof A.insertBefore!="function"||typeof A.hasChildNodes!="function")},at=function(A){return typeof l=="function"&&A instanceof l};function Re(ae,A,Z){Ws(ae,se=>{se.call(t,A,Z,It)})}const Ke=function(A){let Z=null;if(Re(L.beforeSanitizeElements,A,null),pt(A))return _e(A),!0;const se=Ge(A.nodeName);if(Re(L.uponSanitizeElement,A,{tagName:se,allowedTags:z}),de&&A.hasChildNodes()&&!at(A.firstElementChild)&&Ft(/<[/\w!]/g,A.innerHTML)&&Ft(/<[/\w!]/g,A.textContent)||A.nodeType===Oo.progressingInstruction||de&&A.nodeType===Oo.comment&&Ft(/<[/\w]/g,A.data))return _e(A),!0;if(!z[se]||P[se]){if(!P[se]&&we(se)&&(W.tagNameCheck instanceof RegExp&&Ft(W.tagNameCheck,se)||W.tagNameCheck instanceof Function&&W.tagNameCheck(se)))return!1;if(Lt&&!st[se]){const We=y(A)||A.parentNode,it=b(A)||A.childNodes;if(it&&We){const Je=it.length;for(let mt=Je-1;mt>=0;--mt){const He=g(it[mt],!0);He.__removalCount=(A.__removalCount||0)+1,We.insertBefore(He,v(A))}}}return _e(A),!0}return A instanceof c&&!ke(A)||(se==="noscript"||se==="noembed"||se==="noframes")&&Ft(/<\/no(script|embed|frames)/i,A.innerHTML)?(_e(A),!0):(re&&A.nodeType===Oo.text&&(Z=A.textContent,Ws([O,V,K],We=>{Z=Po(Z,We," ")}),A.textContent!==Z&&(Ro(t.removed,{element:A.cloneNode()}),A.textContent=Z)),Re(L.afterSanitizeElements,A,null),!1)},Rt=function(A,Z,se){if(Et&&(Z==="id"||Z==="name")&&(se in n||se in Dn))return!1;if(!(X&&!_[Z]&&Ft(G,Z))){if(!(H&&Ft(R,Z))){if(!U[Z]||_[Z]){if(!(we(A)&&(W.tagNameCheck instanceof RegExp&&Ft(W.tagNameCheck,A)||W.tagNameCheck instanceof Function&&W.tagNameCheck(A))&&(W.attributeNameCheck instanceof RegExp&&Ft(W.attributeNameCheck,Z)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(Z))||Z==="is"&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&Ft(W.tagNameCheck,se)||W.tagNameCheck instanceof Function&&W.tagNameCheck(se))))return!1}else if(!Ot[Z]){if(!Ft(D,Po(se,j,""))){if(!((Z==="src"||Z==="xlink:href"||Z==="href")&&A!=="script"&&HN(se,"data:")===0&&Rn[A])){if(!(Q&&!Ft(q,Po(se,j,"")))){if(se)return!1}}}}}}return!0},we=function(A){return A!=="annotation-xml"&&Zd(A,I)},ze=function(A){Re(L.beforeSanitizeAttributes,A,null);const{attributes:Z}=A;if(!Z||pt(A))return;const se={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:U,forceKeepAttr:void 0};let We=Z.length;for(;We--;){const it=Z[We],{name:Je,namespaceURI:mt,value:He}=it,Pt=Ge(Je),fn=He;let Ye=Je==="value"?fn:WN(fn);if(se.attrName=Pt,se.attrValue=Ye,se.keepAttr=!0,se.forceKeepAttr=void 0,Re(L.uponSanitizeAttribute,A,se),Ye=se.attrValue,et&&(Pt==="id"||Pt==="name")&&(Fe(Je,A),Ye=wt+Ye),de&&Ft(/((--!?|])>)|<\/(style|title)/i,Ye)){Fe(Je,A);continue}if(se.forceKeepAttr)continue;if(!se.keepAttr){Fe(Je,A);continue}if(!oe&&Ft(/\/>/i,Ye)){Fe(Je,A);continue}re&&Ws([O,V,K],Qn=>{Ye=Po(Ye,Qn," ")});const Gr=Ge(A.nodeName);if(!Rt(Gr,Pt,Ye)){Fe(Je,A);continue}if(E&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!mt)switch(h.getAttributeType(Gr,Pt)){case"TrustedHTML":{Ye=E.createHTML(Ye);break}case"TrustedScriptURL":{Ye=E.createScriptURL(Ye);break}}if(Ye!==fn)try{mt?A.setAttributeNS(mt,Je,Ye):A.setAttribute(Je,Ye),pt(A)?_e(A):Xd(t.removed)}catch{Fe(Je,A)}}Re(L.afterSanitizeAttributes,A,null)},tt=function ae(A){let Z=null;const se=yt(A);for(Re(L.beforeSanitizeShadowDOM,A,null);Z=se.nextNode();)Re(L.uponSanitizeShadowNode,Z,null),Ke(Z),ze(Z),Z.content instanceof a&&ae(Z.content);Re(L.afterSanitizeShadowDOM,A,null)};return t.sanitize=function(ae){let A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Z=null,se=null,We=null,it=null;if(Gt=!ae,Gt&&(ae="<!-->"),typeof ae!="string"&&!at(ae))if(typeof ae.toString=="function"){if(ae=ae.toString(),typeof ae!="string")throw Do("dirty is not a string, aborting")}else throw Do("toString is not a function");if(!t.isSupported)return ae;if(ue||yn(A),t.removed=[],typeof ae=="string"&&(ut=!1),ut){if(ae.nodeName){const He=Ge(ae.nodeName);if(!z[He]||P[He])throw Do("root node is forbidden and cannot be sanitized in-place")}}else if(ae instanceof l)Z=Me("<!---->"),se=Z.ownerDocument.importNode(ae,!0),se.nodeType===Oo.element&&se.nodeName==="BODY"||se.nodeName==="HTML"?Z=se:Z.appendChild(se);else{if(!De&&!re&&!ne&&ae.indexOf("<")===-1)return E&&Be?E.createHTML(ae):ae;if(Z=Me(ae),!Z)return De?null:Be?T:""}Z&&Oe&&_e(Z.firstChild);const Je=yt(ut?ae:Z);for(;We=Je.nextNode();)Ke(We),ze(We),We.content instanceof a&&tt(We.content);if(ut)return ae;if(De){if(Te)for(it=N.call(Z.ownerDocument);Z.firstChild;)it.appendChild(Z.firstChild);else it=Z;return(U.shadowroot||U.shadowrootmode)&&(it=M.call(r,it,!0)),it}let mt=ne?Z.outerHTML:Z.innerHTML;return ne&&z["!doctype"]&&Z.ownerDocument&&Z.ownerDocument.doctype&&Z.ownerDocument.doctype.name&&Ft(bg,Z.ownerDocument.doctype.name)&&(mt="<!DOCTYPE "+Z.ownerDocument.doctype.name+`>
127
+ `+mt),re&&Ws([O,V,K],He=>{mt=Po(mt,He," ")}),E&&Be?E.createHTML(mt):mt},t.setConfig=function(){let ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yn(ae),ue=!0},t.clearConfig=function(){It=null,ue=!1},t.isValidAttribute=function(ae,A,Z){It||yn({});const se=Ge(ae),We=Ge(A);return Rt(se,We,Z)},t.addHook=function(ae,A){typeof A=="function"&&Ro(L[ae],A)},t.removeHook=function(ae,A){if(A!==void 0){const Z=UN(L[ae],A);return Z===-1?void 0:BN(L[ae],Z,1)[0]}return Xd(L[ae])},t.removeHooks=function(ae){L[ae]=[]},t.removeAllHooks=function(){L=ru()},t}var Cg=yg();const sj={replace:e=>{e instanceof Lx.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function lo({children:e,className:t}){if(!e)return null;try{const n=Px.parse(e,{gfm:!0}),r=Cg.sanitize(n,{USE_PROFILES:{html:!0}}),o=Dx(r,sj);return s.jsx("div",{className:id(t),children:o})}catch{return s.jsx("div",{className:id(t),children:e})}}const aj={error:"bg-[var(--color-error-w20)] text-[var(--color-error-wMain)] border-[var(--color-error-wMain)] dark:bg-[var(--color-error-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-error-wMain)]",warning:"bg-[var(--color-warning-w10)] text-[var(--color-warning-wMain)] border-[var(--color-warning-wMain)] dark:bg-[var(--color-warning-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-warning-wMain)]",info:"bg-[var(--color-info-w20)] text-[var(--color-info-wMain)] border-[var(--color-info-wMain)] dark:bg-[var(--color-info-w100)]/60 dark:text-[var(--color-white)] dark:border-[var(--color-info-wMain)]",success:"bg-[var(--color-success-w20)] text-[var(--color-success-wMain)] border-[var(--color-success-w40)] dark:bg-[var(--color-success-w100)]/60 dark:text-[var(--color-white)] dark:border-l-[var(--color-success-w70)]"},ij=Nr("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:aj},defaultVariants:{variant:"error"}}),lj={error:cs,warning:Ox,info:Sa,success:Mu};function Yo({className:e,variant:t="error",message:n,action:r,buttonText:o,dismissible:a=!1,onDismiss:i,...l}){const c=lj[t||"error"];return s.jsxs("div",{className:ve(ij({variant:t,className:e}),"items-start"),role:"alert","aria-live":"polite",...l,children:[s.jsx(c,{className:"size-5 shrink-0"}),s.jsx("span",{children:n}),s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[r&&o&&s.jsx(te,{variant:"link",className:"h-min p-0 font-normal text-current underline hover:text-current/60 dark:hover:text-white",onClick:r,children:o}),a&&i&&s.jsx(te,{variant:"link",className:"h-min self-center p-0",onClick:i,"aria-label":"Dismiss",children:s.jsx(Er,{className:"size-3"})})]})]})}function cj({width:e=24,height:t=24}){const{currentTheme:n}=Ha(),r=n==="dark"?"var(--color-background-wMain)":"var(--color-background-w10)",o=n==="dark"?"var(--color-error-w100)":"var(--color-error-w10)";return s.jsxs("svg",{width:e,height:t,focusable:"false","aria-hidden":"true",viewBox:"0 0 131 131",fill:"none",children:[s.jsx("path",{d:"M119.681 63.9952C119.681 94.0948 95.2807 118.495 65.1812 118.495C35.0816 118.495 10.6812 94.0948 10.6812 63.9952C10.6812 33.8957 35.0816 9.49524 65.1812 9.49524C95.2807 9.49524 119.681 33.8957 119.681 63.9952Z",fill:o}),s.jsx("path",{d:"M2.68115 119.495H128.681V120.495H2.68115V119.495Z",fill:"var(--color-secondary-wMain)"}),s.jsx("rect",{x:14,y:34,width:104.054,height:70.6982,rx:1,fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M59.4929 105.314C59.6018 104.866 60.0032 104.55 60.4646 104.55H72.4448C72.9061 104.55 73.3076 104.866 73.4165 105.314L75.1457 112.433C75.2986 113.062 74.8218 113.669 74.174 113.669H58.7354C58.0876 113.669 57.6107 113.062 57.7637 112.433L59.4929 105.314Z",fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M47.7852 114.103C47.7852 113.55 48.2329 113.103 48.7852 113.103H83.2724C83.8247 113.103 84.2724 113.55 84.2724 114.103V118.656C84.2724 119.208 83.8247 119.656 83.2724 119.656H48.7852C48.2329 119.656 47.7852 119.208 47.7852 118.656V114.103Z",fill:r,stroke:"var(--color-secondary-wMain)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M15.1406 95.0068H117.773",stroke:"var(--color-secondary-wMain)",strokeWidth:2}),s.jsxs("g",{clipPath:"url(#clip0_1688:196070)",children:[s.jsx("rect",{opacity:.2,x:54.1126,y:45.1681,width:24.1,height:24.1,stroke:"var(--color-secondary-wMain)",strokeWidth:.1}),s.jsx("path",{d:"M65.6426 60.1142C65.5359 60.1142 65.4453 60.0769 65.3706 60.0022C65.2959 59.9275 65.2586 59.8369 65.2586 59.7302V52.4022C65.2586 52.2955 65.2959 52.2049 65.3706 52.1302C65.4453 52.0555 65.5359 52.0182 65.6426 52.0182H66.9386C67.0559 52.0182 67.1466 52.0555 67.2106 52.1302C67.2853 52.1942 67.3226 52.2849 67.3226 52.4022V59.7302C67.3226 59.8369 67.2853 59.9275 67.2106 60.0022C67.1466 60.0769 67.0559 60.1142 66.9386 60.1142H65.6426ZM65.5466 63.2182C65.4399 63.2182 65.3493 63.1809 65.2746 63.1062C65.1999 63.0315 65.1626 62.9409 65.1626 62.8342V61.3462C65.1626 61.2289 65.1999 61.1329 65.2746 61.0582C65.3493 60.9835 65.4399 60.9462 65.5466 60.9462H67.0346C67.1519 60.9462 67.2479 60.9835 67.3226 61.0582C67.3973 61.1329 67.4346 61.2289 67.4346 61.3462V62.8342C67.4346 62.9409 67.3973 63.0315 67.3226 63.1062C67.2479 63.1809 67.1519 63.2182 67.0346 63.2182H65.5466Z",fill:"var(--color-secondary-wMain)"})]}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.3433 73.2659C51.3433 72.9897 51.5671 72.7659 51.8433 72.7659H80.2102C80.4864 72.7659 80.7102 72.9897 80.7102 73.2659C80.7102 73.542 80.4864 73.7659 80.2102 73.7659H51.8433C51.5671 73.7659 51.3433 73.542 51.3433 73.2659Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M55.1851 83.2659C55.1851 82.9897 55.3503 82.7659 55.5542 82.7659H76.4995C76.7034 82.7659 76.8687 82.9897 76.8687 83.2659C76.8687 83.542 76.7034 83.7659 76.4995 83.7659H55.5542C55.3503 83.7659 55.1851 83.542 55.1851 83.2659Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.3433 78.2659C51.3433 77.9897 51.5671 77.7659 51.8433 77.7659H80.2102C80.4864 77.7659 80.7102 77.9897 80.7102 78.2659C80.7102 78.542 80.4864 78.7659 80.2102 78.7659H51.8433C51.5671 78.7659 51.3433 78.542 51.3433 78.2659Z",fill:"var(--color-secondary-wMain)"}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_1688:196070",children:s.jsx("rect",{width:24,height:24,fill:r,transform:"translate(54.1626 45.2181)"})})})]})}function dj({width:e=24,height:t=24}){const{currentTheme:n}=Ha(),r=n==="dark"?"var(--color-background-wMain)":"var(--color-background-w10)";return s.jsxs("svg",{width:e,height:t,viewBox:"0 0 130 130",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsxs("g",{clipPath:"url(#clip0_483_284)",children:[s.jsx("path",{opacity:.1,d:"M130 61.4874C130 95.4459 102.471 122.975 68.5125 122.975C34.554 122.975 7.02515 95.4459 7.02515 61.4874C7.02515 27.5288 34.554 0 68.5125 0C102.471 0 130 27.5288 130 61.4874Z",fill:"var(--color-info-wMain)"}),s.jsx("path",{d:"M0 25.9979C0 24.1286 1.51535 22.6133 3.38463 22.6133H41.082C49.1822 22.6133 55.7487 29.1798 55.7487 37.28V116.273C55.7487 118.142 54.2333 119.657 52.3641 119.657H3.38463C1.51535 119.657 0 118.142 0 116.273V25.9979Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M41.082 24.8697H3.38463C2.76154 24.8697 2.25642 25.3748 2.25642 25.9979V116.273C2.25642 116.896 2.76153 117.401 3.38463 117.401H52.3641C52.9871 117.401 53.4923 116.896 53.4923 116.273V37.28C53.4923 30.426 47.936 24.8697 41.082 24.8697ZM3.38463 22.6133C1.51535 22.6133 0 24.1286 0 25.9979V116.273C0 118.142 1.51535 119.657 3.38463 119.657H52.3641C54.2333 119.657 55.7487 118.142 55.7487 116.273V37.28C55.7487 29.1798 49.1822 22.6133 41.082 22.6133H3.38463Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M53.0258 112.821H2.25642V116.206C2.25642 116.829 2.76153 117.334 3.38462 117.334H51.8976C52.5207 117.334 53.0258 116.829 53.0258 116.206V112.821ZM0 110.565V116.206C0 118.075 1.51535 119.59 3.38462 119.59H51.8976C53.7669 119.59 55.2822 118.075 55.2822 116.206V110.565H0Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M51.8977 38.3591C51.8977 29.6358 58.9693 22.5642 67.6926 22.5642H107.18C109.049 22.5642 110.564 24.0796 110.564 25.9488V116.206C110.564 118.075 109.049 119.59 107.18 119.59H55.2823C53.413 119.59 51.8977 118.075 51.8977 116.206V38.3591Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M107.18 24.8206H67.6926C60.2155 24.8206 54.1541 30.882 54.1541 38.3591V116.206C54.1541 116.829 54.6592 117.334 55.2823 117.334H107.18C107.803 117.334 108.308 116.829 108.308 116.206V25.9488C108.308 25.3257 107.803 24.8206 107.18 24.8206ZM67.6926 22.5642C58.9693 22.5642 51.8977 29.6358 51.8977 38.3591V116.206C51.8977 118.075 53.413 119.59 55.2823 119.59H107.18C109.049 119.59 110.564 118.075 110.564 116.206V25.9488C110.564 24.0796 109.049 22.5642 107.18 22.5642H67.6926Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M108.308 112.821H54.1541V116.206C54.1541 116.829 54.6592 117.334 55.2823 117.334H107.18C107.803 117.334 108.308 116.829 108.308 116.206V112.821ZM51.8977 110.565V116.206C51.8977 118.075 53.413 119.59 55.2823 119.59H107.18C109.049 119.59 110.564 118.075 110.564 116.206V110.565H51.8977Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M29.0351 36.0336C29.0351 35.722 29.2876 35.4695 29.5992 35.4695H43.0726C43.3842 35.4695 43.6367 35.722 43.6367 36.0336C43.6367 36.3451 43.3842 36.5977 43.0726 36.5977H29.5992C29.2876 36.5977 29.0351 36.3451 29.0351 36.0336ZM29.0351 42.7441C29.0351 42.4325 29.2876 42.1799 29.5992 42.1799H43.0726C43.3842 42.1799 43.6367 42.4325 43.6367 42.7441C43.6367 43.0556 43.3842 43.3082 43.0726 43.3082H29.5992C29.2876 43.3082 29.0351 43.0556 29.0351 42.7441ZM29.0351 49.4545C29.0351 49.143 29.2876 48.8904 29.5992 48.8904H43.0726C43.3842 48.8904 43.6367 49.143 43.6367 49.4545C43.6367 49.7661 43.3842 50.0186 43.0726 50.0186H29.5992C29.2876 50.0186 29.0351 49.7661 29.0351 49.4545ZM9.75977 60.2946C9.75977 59.983 10.0123 59.7305 10.3239 59.7305H23.7973C24.1089 59.7305 24.3614 59.983 24.3614 60.2946C24.3614 60.6061 24.1089 60.8587 23.7973 60.8587H10.3239C10.0123 60.8587 9.75977 60.6061 9.75977 60.2946ZM9.75977 67.0051C9.75977 66.6935 10.0123 66.4409 10.3239 66.4409H23.7973C24.1089 66.4409 24.3614 66.6935 24.3614 67.0051C24.3614 67.3166 24.1089 67.5692 23.7973 67.5692H10.3239C10.0123 67.5692 9.75977 67.3166 9.75977 67.0051ZM9.75977 73.7155C9.75977 73.404 10.0123 73.1514 10.3239 73.1514H23.7973C24.1089 73.1514 24.3614 73.404 24.3614 73.7155C24.3614 74.0271 24.1089 74.2796 23.7973 74.2796H10.3239C10.0123 74.2796 9.75977 74.0271 9.75977 73.7155Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 83.5231C9.75977 83.2116 10.0123 82.959 10.3239 82.959H42.3277C42.6393 82.959 42.8918 83.2116 42.8918 83.5231C42.8918 83.8347 42.6393 84.0872 42.3277 84.0872H10.3239C10.0123 84.0872 9.75977 83.8347 9.75977 83.5231Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 93.8473C9.75977 93.5357 10.0123 93.2832 10.3239 93.2832H42.3277C42.6393 93.2832 42.8918 93.5357 42.8918 93.8473C42.8918 94.1588 42.6393 94.4114 42.3277 94.4114H10.3239C10.0123 94.4114 9.75977 94.1588 9.75977 93.8473Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 88.6852C9.75977 88.3737 10.0123 88.1211 10.3239 88.1211H42.3277C42.6393 88.1211 42.8918 88.3737 42.8918 88.6852C42.8918 88.9967 42.6393 89.2493 42.3277 89.2493H10.3239C10.0123 89.2493 9.75977 88.9967 9.75977 88.6852Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.75977 99.0089C9.75977 98.6974 10.0123 98.4448 10.3239 98.4448H42.3277C42.6393 98.4448 42.8918 98.6974 42.8918 99.0089C42.8918 99.3205 42.6393 99.573 42.3277 99.573H10.3239C10.0123 99.573 9.75977 99.3205 9.75977 99.0089Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M22.9252 42.8986C22.9252 46.6372 19.8945 49.6679 16.156 49.6679C12.4174 49.6679 9.38672 46.6372 9.38672 42.8986C9.38672 39.1601 12.4174 36.1294 16.156 36.1294C19.8945 36.1294 22.9252 39.1601 22.9252 42.8986Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.156 47.4115C18.6483 47.4115 20.6688 45.391 20.6688 42.8986C20.6688 40.4063 18.6483 38.3858 16.156 38.3858C13.6636 38.3858 11.6431 40.4063 11.6431 42.8986C11.6431 45.391 13.6636 47.4115 16.156 47.4115ZM16.156 49.6679C19.8945 49.6679 22.9252 46.6372 22.9252 42.8986C22.9252 39.1601 19.8945 36.1294 16.156 36.1294C12.4174 36.1294 9.38672 39.1601 9.38672 42.8986C9.38672 46.6372 12.4174 49.6679 16.156 49.6679Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M31.5107 63.1795C31.5107 61.9333 32.521 60.9231 33.7672 60.9231H40.5364C41.7826 60.9231 42.7928 61.9334 42.7928 63.1795V68.9231C42.7928 70.1693 41.7826 71.1796 40.5364 71.1796H33.7672C32.521 71.1796 31.5107 70.1693 31.5107 68.9231V63.1795Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.5364 63.1795H33.7672V68.9231H40.5364V63.1795ZM33.7672 60.9231C32.521 60.9231 31.5107 61.9333 31.5107 63.1795V68.9231C31.5107 70.1693 32.521 71.1796 33.7672 71.1796H40.5364C41.7826 71.1796 42.7928 70.1693 42.7928 68.9231V63.1795C42.7928 61.9334 41.7826 60.9231 40.5364 60.9231H33.7672Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M102.325 102.029C101.702 100.949 102.072 99.5694 103.151 98.9463L107.108 96.6618C108.188 96.0387 109.568 96.4084 110.191 97.4877L123.409 120.382C124.032 121.461 123.662 122.841 122.583 123.464L118.626 125.749C117.547 126.372 116.167 126.002 115.543 124.923L102.325 102.029Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M108.237 98.6159L104.28 100.9L117.498 123.795L121.455 121.51L108.237 98.6159ZM103.151 98.9463C102.072 99.5694 101.702 100.949 102.325 102.029L115.543 124.923C116.167 126.002 117.547 126.372 118.626 125.749L122.583 123.464C123.662 122.841 124.032 121.461 123.409 120.382L110.191 97.4877C109.568 96.4084 108.188 96.0387 107.108 96.6618L103.151 98.9463Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M115.803 66.4824C115.803 82.3642 102.928 95.239 87.0466 95.239C71.1648 95.239 58.29 82.3642 58.29 66.4824C58.29 50.6006 71.1648 37.7258 87.0466 37.7258C102.928 37.7258 115.803 50.6006 115.803 66.4824Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M87.0466 92.9825C101.682 92.9825 113.547 81.118 113.547 66.4824C113.547 51.8468 101.682 39.9822 87.0466 39.9822C72.411 39.9822 60.5465 51.8468 60.5465 66.4824C60.5465 81.118 72.411 92.9825 87.0466 92.9825ZM87.0466 95.239C102.928 95.239 115.803 82.3642 115.803 66.4824C115.803 50.6006 102.928 37.7258 87.0466 37.7258C71.1648 37.7258 58.29 50.6006 58.29 66.4824C58.29 82.3642 71.1648 95.239 87.0466 95.239Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M109.771 66.4825C109.771 79.0329 99.5964 89.2071 87.0459 89.2071C74.4954 89.2071 64.3213 79.0329 64.3213 66.4825C64.3213 53.932 74.4954 43.7578 87.0459 43.7578C99.5964 43.7578 109.771 53.932 109.771 66.4825Z",fill:r}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M87.0459 86.9507C98.3502 86.9507 107.514 77.7868 107.514 66.4825C107.514 55.1782 98.3502 46.0142 87.0459 46.0142C75.7416 46.0142 66.5777 55.1782 66.5777 66.4825C66.5777 77.7868 75.7416 86.9507 87.0459 86.9507ZM87.0459 89.2071C99.5964 89.2071 109.771 79.0329 109.771 66.4825C109.771 53.932 99.5964 43.7578 87.0459 43.7578C74.4954 43.7578 64.3213 53.932 64.3213 66.4825C64.3213 79.0329 74.4954 89.2071 87.0459 89.2071Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M86.4824 49.2829C86.4824 48.9713 86.735 48.7188 87.0465 48.7188C96.8572 48.7188 104.81 56.6717 104.81 66.4823C104.81 66.7939 104.558 67.0465 104.246 67.0465C103.935 67.0465 103.682 66.7939 103.682 66.4823C103.682 57.2948 96.2341 49.847 87.0465 49.847C86.735 49.847 86.4824 49.5944 86.4824 49.2829ZM72.0594 74.9461C72.3254 74.7838 72.6725 74.868 72.8348 75.134C73.8285 76.7627 75.0945 78.2075 76.5695 79.4049C77.4599 80.1277 78.4264 80.7603 79.4549 81.2888C81.7303 82.4579 84.3105 83.1178 87.0465 83.1178C87.3581 83.1178 87.6106 83.3704 87.6106 83.6819C87.6106 83.9935 87.3581 84.2461 87.0465 84.2461C84.127 84.2461 81.3705 83.5413 78.9393 82.2922C77.8408 81.7278 76.8089 81.0524 75.8584 80.2808C74.2841 79.0028 72.9327 77.4606 71.8717 75.7216C71.7094 75.4556 71.7935 75.1084 72.0594 74.9461Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M104.511 99.0423L100.011 91.2478L101.965 90.1196L106.465 97.9141L104.511 99.0423Z",fill:"var(--color-secondary-wMain)"}),s.jsx("path",{d:"M86.2924 72.1957C86.1299 72.1957 85.9945 72.1505 85.8862 72.0603C85.7779 71.952 85.7238 71.8076 85.7238 71.6271C85.7238 71.4465 85.7238 71.266 85.7238 71.0855C85.7238 70.905 85.7238 70.7245 85.7238 70.544C85.7599 69.7678 85.9314 69.0818 86.2382 68.4861C86.5451 67.8904 86.9152 67.3489 87.3484 66.8615C87.7997 66.3741 88.251 65.9138 88.7023 65.4806C89.1535 65.0293 89.5326 64.578 89.8395 64.1267C90.1644 63.6754 90.363 63.1971 90.4352 62.6916C90.5074 62.0418 90.381 61.5003 90.0561 61.067C89.7312 60.6157 89.2889 60.2728 88.7293 60.0381C88.1697 59.8034 87.5921 59.6861 86.9964 59.6861C86.0397 59.6861 85.2183 59.9388 84.5324 60.4442C83.8645 60.9316 83.4222 61.762 83.2056 62.9353C83.1515 63.1519 83.0612 63.3054 82.9348 63.3956C82.8085 63.4859 82.6641 63.531 82.5016 63.531H81.2019C81.0395 63.531 80.895 63.4769 80.7687 63.3686C80.6604 63.2603 80.6062 63.1158 80.6062 62.9353C80.6243 62.1952 80.7867 61.4912 81.0936 60.8233C81.4005 60.1554 81.8337 59.5688 82.3933 59.0633C82.9709 58.5579 83.6479 58.1608 84.4241 57.8719C85.2183 57.5651 86.1029 57.4116 87.0776 57.4116C88.1788 57.4116 89.1174 57.5651 89.8936 57.8719C90.6879 58.1608 91.3197 58.5579 91.789 59.0633C92.2764 59.5507 92.6284 60.0922 92.845 60.6879C93.0616 61.2836 93.1519 61.8793 93.1158 62.475C93.0617 63.1971 92.8811 63.8469 92.5743 64.4246C92.2674 64.9842 91.8973 65.5076 91.4641 65.995C91.0309 66.4644 90.5886 66.9337 90.1373 67.403C89.7041 67.8543 89.325 68.3327 89.0001 68.8381C88.6932 69.3255 88.5217 69.858 88.4856 70.4357C88.4676 70.6342 88.4495 70.8328 88.4315 71.0314C88.4315 71.2119 88.4315 71.3924 88.4315 71.5729C88.3954 71.7715 88.3232 71.9249 88.2149 72.0332C88.1066 72.1415 87.9531 72.1957 87.7546 72.1957H86.2924ZM86.0758 76.6363C85.8953 76.6363 85.7418 76.5821 85.6155 76.4738C85.5072 76.3475 85.453 76.194 85.453 76.0135V74.3618C85.453 74.1813 85.5072 74.0369 85.6155 73.9286C85.7418 73.8022 85.8953 73.7391 86.0758 73.7391H87.8358C88.0344 73.7391 88.1878 73.8022 88.2961 73.9286C88.4225 74.0369 88.4856 74.1813 88.4856 74.3618V76.0135C88.4856 76.194 88.4225 76.3475 88.2961 76.4738C88.1878 76.5821 88.0344 76.6363 87.8358 76.6363H86.0758Z",fill:"var(--color-secondary-wMain)"})]}),s.jsx("defs",{children:s.jsx("clipPath",{id:"clip0_483_284",children:s.jsx("rect",{width:130,height:130,fill:r})})})]})}function rs({title:e,subtitle:t,image:n,variant:r="error",buttons:o,className:a}){const i={error:s.jsx(cj,{width:150,height:150}),notFound:s.jsx(dj,{width:150,height:150}),loading:s.jsx(Wn,{size:"large"}),noImage:null};return s.jsxs("div",{className:ve("flex h-full w-full flex-col items-center justify-center gap-3",a),children:[n||i[r]||null,s.jsx("p",{className:"mt-4 text-lg",children:e}),t?s.jsx("p",{className:"text-sm",children:t}):null,s.jsx("div",{className:"flex gap-2",children:o&&o.map(({text:l,variant:c,onClick:u},p)=>s.jsx(te,{testid:l,title:l,variant:c,onClick:u,children:l},`button-${l}-${p}`))})]})}const uj=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"audio/mpeg"};base64,${e}`;return s.jsx("div",{className:"flex h-auto max-w-[100vw] items-center justify-center p-4",children:s.jsxs("audio",{controls:!0,className:"w-full",onLoad:()=>n(null),onError:()=>n("Failed to load audio content."),children:[s.jsx("source",{src:r,type:t||"audio/mpeg"}),"Your browser does not support the audio element."]})})},fj=e=>{if(!e)return[];const t=[];let n=[],r="",o=!1;for(let a=0;a<e.length;a++){const i=e[a],l=a<e.length-1?e[a+1]:"";i==='"'?l==='"'?(r+='"',a++):o=!o:i===","&&!o?(n.push(r.trim()),r=""):(i===`
128
+ `||i==="\r"&&l===`
129
+ `)&&!o?(i==="\r"&&l===`
130
+ `&&a++,n.push(r.trim()),r="",n.some(c=>c.trim())?(t.push(n),n=[]):n=[]):r+=i}return(r||n.length>0)&&(n.push(r.trim()),n.some(a=>a.trim())&&t.push(n)),t},pj=({content:e,setRenderError:t})=>{d.useEffect(()=>{t(null)},[e,t]);const n=d.useMemo(()=>{try{return fj(e)}catch(r){return console.error("Error parsing CSV:",r),t("Failed to parse CSV content."),[]}},[e,t]);return n.length?s.jsx("div",{className:"block w-full overflow-x-scroll p-4",children:s.jsx("div",{style:{minWidth:"min(100%, max-content)"},children:s.jsxs("table",{className:"w-full border text-sm",children:[s.jsx("thead",{className:"sticky top-0 z-10 shadow-sm",children:n.length>0&&s.jsx("tr",{children:n[0].map((r,o)=>s.jsx("th",{className:"border-b p-2 text-left font-medium whitespace-nowrap",title:r,children:(r==null?void 0:r.trim())||""},`header-${o}`))})}),s.jsx("tbody",{children:n.slice(1).map((r,o)=>s.jsx("tr",{className:o%2===0?"bg-muted dark:bg-gray-700":"",children:r.map((a,i)=>s.jsx("td",{className:"min-w-0 border-b p-2 align-top break-words",title:a,children:(a==null?void 0:a.trim())||""},`cell-${o}-${i}`))},`row-${o}`))})]})})}):s.jsx("div",{children:"No valid CSV content found or failed to parse."})},mj=({content:e,setRenderError:t})=>{const n=d.useMemo(()=>e.replace(/<script(?:\s[^>]*)?>([\s\S]*?)<\/script>/gi,(a,i)=>{const l=a.match(/<script(\s[^>]*)?>/i);return`<script${l&&l[1]?l[1]:""}>(function() {
131
+ try {
132
+ ${i}
133
+ } catch (e) { console.error('Error in sandboxed script:', e); }
134
+ })();<\/script>`}),[e]);return s.jsx("div",{className:"h-full w-full overflow-hidden border dark:bg-gray-400",children:s.jsx("iframe",{srcDoc:n,title:"HTML Preview",sandbox:"allow-scripts allow-same-origin allow-downloads allow-forms allow-popups",allow:"autoplay",className:"h-full w-full border-none",onError:()=>t("Failed to load HTML content."),onLoad:()=>t(null)})})},hj=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"image/png"};base64,${e}`;return s.jsx("div",{className:"flex h-auto w-auto max-w-[100vw] items-center justify-center p-4",children:s.jsx("img",{src:r,onError:()=>n("Failed to load image"),onLoad:()=>n(null),alt:"Preview",className:"h-full w-full object-contain"})})};function Sg(){const e=d.useRef(null),t=()=>{if(e.current){const r=document.createRange();r.selectNodeContents(e.current);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(r))}};return{ref:e,handleKeyDown:r=>{(r.metaKey||r.ctrlKey)&&r.key==="a"&&(r.preventDefault(),t())},selectAllContent:t}}const gj=({content:e})=>{const{ref:t,handleKeyDown:n}=Sg();return s.jsx("div",{className:"w-full p-4",children:s.jsx("div",{ref:t,className:"max-w-full overflow-hidden select-text focus-visible:outline-none",tabIndex:0,onKeyDown:n,children:s.jsx(lo,{className:"max-w-full break-words",children:e})})})},xj=({content:e,setRenderError:t})=>{const[n,r]=d.useState(""),o=d.useMemo(()=>Cg.sanitize(e,{USE_PROFILES:{html:!1},ALLOWED_TAGS:["br","em","strong","b","i"],ALLOWED_ATTR:[]}),[e]);return d.useEffect(()=>{r(`<!DOCTYPE html>
135
+ <html>
136
+ <head>
137
+ <meta charset="utf-8">
138
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
139
+ <title>Mermaid Preview</title>
140
+ <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>
141
+ <script src="https://cdn.jsdelivr.net/npm/panzoom@9.4.0/dist/panzoom.min.js"><\/script>
142
+ <script>
143
+ document.addEventListener('DOMContentLoaded', function() {
144
+ try {
145
+ mermaid.initialize({
146
+ startOnLoad: true,
147
+ theme: 'default',
148
+ fontFamily: 'arial, sans-serif',
149
+ logLevel: 'error',
150
+ securityLevel: 'strict'
151
+ });
152
+
153
+ // Initialize panzoom after Mermaid rendering
154
+ mermaid.run().then(() => {
155
+ const diagramContainer = document.getElementById('diagram-container');
156
+ if (diagramContainer) {
157
+ const pz = panzoom(diagramContainer, {
158
+ maxZoom: 10,
159
+ minZoom: 0.1,
160
+ smoothScroll: true,
161
+ bounds: true,
162
+ boundsPadding: 0.1
163
+ });
164
+ // Add zoom controls (old version had only reset)
165
+ const resetButton = document.getElementById('reset');
166
+ if (resetButton) {
167
+ resetButton.addEventListener('click', () => {
168
+ pz.moveTo(0, 0);
169
+ pz.zoomAbs(0, 0, 1);
170
+ });
171
+ }
172
+ }
173
+ }).catch(err => {
174
+ console.error("Mermaid rendering failed inside iframe:", err);
175
+ const mermaidDiv = document.querySelector('.mermaid');
176
+ if (mermaidDiv) mermaidDiv.innerText = "Error rendering diagram: " + err.message;
177
+ });
178
+
179
+ window.addEventListener('message', function(event) {
180
+ if (event.data && event.data.action === 'getMermaidSvg') {
181
+ const svgElement = document.querySelector('.mermaid svg');
182
+ if (svgElement) {
183
+ if (!svgElement.getAttribute('xmlns')) { // Ensure xmlns for standalone SVG
184
+ svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
185
+ }
186
+ const svgData = new XMLSerializer().serializeToString(svgElement);
187
+ window.parent.postMessage({
188
+ action: 'downloadSvg',
189
+ svgData: svgData,
190
+ filename: event.data.filename || 'mermaid-diagram.svg'
191
+ }, '*');
192
+ } else {
193
+ console.error('SVG element not found for download inside iframe.');
194
+ }
195
+ }
196
+ });
197
+ } catch (e) {
198
+ console.error("Error initializing Mermaid or Panzoom inside iframe:", e);
199
+ const mermaidDiv = document.querySelector('.mermaid');
200
+ if (mermaidDiv) mermaidDiv.innerText = "Failed to initialize diagram viewer: " + e.message;
201
+ }
202
+ });
203
+ <\/script>
204
+ <style>
205
+ /* Styles from old code */
206
+ html, body {
207
+ height: 100%;
208
+ margin: 0;
209
+ padding: 0;
210
+ overflow: hidden;
211
+ font-family: Arial, sans-serif; /* Old font */
212
+ }
213
+ .container {
214
+ display: flex;
215
+ flex-direction: column;
216
+ height: 100vh;
217
+ overflow: hidden;
218
+ }
219
+ .diagram-wrapper {
220
+ flex: 1;
221
+ overflow: hidden;
222
+ position: relative;
223
+ display: flex;
224
+ justify-content: center;
225
+ align-items: center;
226
+ background-color: #f9f9f9;
227
+ }
228
+ #diagram-container {
229
+ transform-origin: 0 0;
230
+ cursor: grab;
231
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
232
+ background-color: white;
233
+ padding: 20px;
234
+ border-radius: 5px;
235
+ /* Ensure diagram container can hold the content */
236
+ width: auto; /* Adjust as needed, or let content define it */
237
+ height: auto;
238
+ max-width: 100%;
239
+ max-height: 100%;
240
+ }
241
+ #diagram-container:active {
242
+ cursor: grabbing;
243
+ }
244
+ .mermaid {
245
+ display: flex; /* Helps in centering if SVG is smaller */
246
+ justify-content: center;
247
+ align-items: center;
248
+ /* width: 100%; Ensures mermaid div takes space, SVG might scale within it */
249
+ /* height: 100%; */
250
+ }
251
+ .mermaid svg {
252
+ max-width: 100%; /* Ensure SVG scales down if too large */
253
+ max-height: 100%;
254
+ }
255
+ .controls{
256
+ position: fixed;
257
+ bottom: 20px;
258
+ right: 20px;
259
+ z-index: 1000;
260
+ display: flex;
261
+ gap: 5px;
262
+ }
263
+ .control-btn {
264
+ width: 40px;
265
+ height: 40px;
266
+ border-radius: 50%;
267
+ border: none;
268
+ background-color: white;
269
+ box-shadow: 0 2px 5px rgba(0,0,0,0.2);
270
+ cursor: pointer;
271
+ font-size: 18px;
272
+ display: flex;
273
+ align-items: center;
274
+ justify-content: center;
275
+ }
276
+ .control-btn:hover {
277
+ background-color: #f0f0f0;
278
+ }
279
+ .instructions {
280
+ position: fixed;
281
+ top: 10px;
282
+ left: 10px;
283
+ background-color: rgba(255,255,255,0.8);
284
+ padding: 5px 10px;
285
+ border-radius: 4px;
286
+ font-size: 12px;
287
+ color: #666;
288
+ }
289
+ </style>
290
+ </head>
291
+ <body>
292
+ <div class="container">
293
+ <div class="diagram-wrapper">
294
+ <div id="diagram-container">
295
+ <div class="mermaid">
296
+ ${o}
297
+ </div>
298
+ </div>
299
+ </div>
300
+ <div class="instructions">
301
+ Drag to pan and scroll to zoom
302
+ </div>
303
+ <div class="controls">
304
+ <button id="reset" class="control-btn" title="Reset View">↺</button>
305
+ </div>
306
+ </div>
307
+ </body>
308
+ </html>`)},[o]),s.jsx("div",{className:"bg-background h-full p-4",children:s.jsx("iframe",{srcDoc:n,title:"Mermaid Diagram Preview",sandbox:"allow-scripts allow-same-origin allow-downloads",className:"h-96 w-full resize border-none",onError:()=>t("Failed to load Mermaid content."),onLoad:()=>t(null)})})};/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function Eg(e){return typeof e>"u"||e===null}function vj(e){return typeof e=="object"&&e!==null}function wj(e){return Array.isArray(e)?e:Eg(e)?[]:[e]}function bj(e,t){var n,r,o,a;if(t)for(a=Object.keys(t),n=0,r=a.length;n<r;n+=1)o=a[n],e[o]=t[o];return e}function yj(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function Cj(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Sj=Eg,Ej=vj,Nj=wj,jj=yj,kj=Cj,Aj=bj,xt={isNothing:Sj,isObject:Ej,toArray:Nj,repeat:jj,isNegativeZero:kj,extend:Aj};function Ng(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
309
+
310
+ `+e.mark.snippet),r+" "+n):r}function os(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Ng(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}os.prototype=Object.create(Error.prototype);os.prototype.constructor=os;os.prototype.toString=function(t){return this.name+": "+Ng(this,t)};var zt=os;function Ii(e,t,n,r,o){var a="",i="",l=Math.floor(o/2)-1;return r-t>l&&(a=" ... ",t=r-l+a.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:a+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+a.length}}function Mi(e,t){return xt.repeat(" ",t-e.length)+e}function Tj(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],a,i=-1;a=n.exec(e.buffer);)o.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,u,p=Math.min(e.line+t.linesAfter,o.length).toString().length,f=t.maxLength-(t.indent+p+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)u=Ii(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),f),l=xt.repeat(" ",t.indent)+Mi((e.line-c+1).toString(),p)+" | "+u.str+`
311
+ `+l;for(u=Ii(e.buffer,r[i],o[i],e.position,f),l+=xt.repeat(" ",t.indent)+Mi((e.line+1).toString(),p)+" | "+u.str+`
312
+ `,l+=xt.repeat("-",t.indent+p+3+u.pos)+`^
313
+ `,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)u=Ii(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),f),l+=xt.repeat(" ",t.indent)+Mi((e.line+c+1).toString(),p)+" | "+u.str+`
314
+ `;return l.replace(/\n$/,"")}var _j=Tj,Ij=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Mj=["scalar","sequence","mapping"];function Rj(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function Pj(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(Ij.indexOf(n)===-1)throw new zt('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=Rj(t.styleAliases||null),Mj.indexOf(this.kind)===-1)throw new zt('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Tt=Pj;function ou(e,t){var n=[];return e[t].forEach(function(r){var o=n.length;n.forEach(function(a,i){a.tag===r.tag&&a.kind===r.kind&&a.multi===r.multi&&(o=i)}),n[o]=r}),n}function Dj(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function ul(e){return this.extend(e)}ul.prototype.extend=function(t){var n=[],r=[];if(t instanceof Tt)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new zt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(a){if(!(a instanceof Tt))throw new zt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new zt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(a.multi)throw new zt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(a){if(!(a instanceof Tt))throw new zt("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(ul.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=ou(o,"implicit"),o.compiledExplicit=ou(o,"explicit"),o.compiledTypeMap=Dj(o.compiledImplicit,o.compiledExplicit),o};var jg=ul,kg=new Tt("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Ag=new Tt("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Tg=new Tt("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),_g=new jg({explicit:[kg,Ag,Tg]});function Lj(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function Oj(){return null}function Fj(e){return e===null}var Ig=new Tt("tag:yaml.org,2002:null",{kind:"scalar",resolve:Lj,construct:Oj,predicate:Fj,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function $j(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function zj(e){return e==="true"||e==="True"||e==="TRUE"}function Uj(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Mg=new Tt("tag:yaml.org,2002:bool",{kind:"scalar",resolve:$j,construct:zj,predicate:Uj,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Bj(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Hj(e){return 48<=e&&e<=55}function Wj(e){return 48<=e&&e<=57}function Vj(e){if(e===null)return!1;var t=e.length,n=0,r=!1,o;if(!t)return!1;if(o=e[n],(o==="-"||o==="+")&&(o=e[++n]),o==="0"){if(n+1===t)return!0;if(o=e[++n],o==="b"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(o!=="0"&&o!=="1")return!1;r=!0}return r&&o!=="_"}if(o==="x"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!Bj(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!Hj(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!Wj(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function Gj(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function Yj(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!xt.isNegativeZero(e)}var Rg=new Tt("tag:yaml.org,2002:int",{kind:"scalar",resolve:Vj,construct:Gj,predicate:Yj,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Kj=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function qj(e){return!(e===null||!Kj.test(e)||e[e.length-1]==="_")}function Xj(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var Zj=/^[-+]?[0-9]+e/;function Jj(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(xt.isNegativeZero(e))return"-0.0";return n=e.toString(10),Zj.test(n)?n.replace("e",".e"):n}function Qj(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||xt.isNegativeZero(e))}var Pg=new Tt("tag:yaml.org,2002:float",{kind:"scalar",resolve:qj,construct:Xj,predicate:Qj,represent:Jj,defaultStyle:"lowercase"}),Dg=_g.extend({implicit:[Ig,Mg,Rg,Pg]}),Lg=Dg,Og=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Fg=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function ek(e){return e===null?!1:Og.exec(e)!==null||Fg.exec(e)!==null}function tk(e){var t,n,r,o,a,i,l,c=0,u=null,p,f,m;if(t=Og.exec(e),t===null&&(t=Fg.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,o=+t[3],!t[4])return new Date(Date.UTC(n,r,o));if(a=+t[4],i=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(p=+t[10],f=+(t[11]||0),u=(p*60+f)*6e4,t[9]==="-"&&(u=-u)),m=new Date(Date.UTC(n,r,o,a,i,l,c)),u&&m.setTime(m.getTime()-u),m}function nk(e){return e.toISOString()}var $g=new Tt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:ek,construct:tk,instanceOf:Date,represent:nk});function rk(e){return e==="<<"||e===null}var zg=new Tt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:rk}),jc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
315
+ \r`;function ok(e){if(e===null)return!1;var t,n,r=0,o=e.length,a=jc;for(n=0;n<o;n++)if(t=a.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function sk(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,a=jc,i=0,l=[];for(t=0;t<o;t++)t%4===0&&t&&(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)),i=i<<6|a.indexOf(r.charAt(t));return n=o%4*6,n===0?(l.push(i>>16&255),l.push(i>>8&255),l.push(i&255)):n===18?(l.push(i>>10&255),l.push(i>>2&255)):n===12&&l.push(i>>4&255),new Uint8Array(l)}function ak(e){var t="",n=0,r,o,a=e.length,i=jc;for(r=0;r<a;r++)r%3===0&&r&&(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[r];return o=a%3,o===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):o===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):o===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function ik(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Ug=new Tt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ok,construct:sk,predicate:ik,represent:ak}),lk=Object.prototype.hasOwnProperty,ck=Object.prototype.toString;function dk(e){if(e===null)return!0;var t=[],n,r,o,a,i,l=e;for(n=0,r=l.length;n<r;n+=1){if(o=l[n],i=!1,ck.call(o)!=="[object Object]")return!1;for(a in o)if(lk.call(o,a))if(!i)i=!0;else return!1;if(!i)return!1;if(t.indexOf(a)===-1)t.push(a);else return!1}return!0}function uk(e){return e!==null?e:[]}var Bg=new Tt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dk,construct:uk}),fk=Object.prototype.toString;function pk(e){if(e===null)return!0;var t,n,r,o,a,i=e;for(a=new Array(i.length),t=0,n=i.length;t<n;t+=1){if(r=i[t],fk.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;a[t]=[o[0],r[o[0]]]}return!0}function mk(e){if(e===null)return[];var t,n,r,o,a,i=e;for(a=new Array(i.length),t=0,n=i.length;t<n;t+=1)r=i[t],o=Object.keys(r),a[t]=[o[0],r[o[0]]];return a}var Hg=new Tt("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:pk,construct:mk}),hk=Object.prototype.hasOwnProperty;function gk(e){if(e===null)return!0;var t,n=e;for(t in n)if(hk.call(n,t)&&n[t]!==null)return!1;return!0}function xk(e){return e!==null?e:{}}var Wg=new Tt("tag:yaml.org,2002:set",{kind:"mapping",resolve:gk,construct:xk}),kc=Lg.extend({implicit:[$g,zg],explicit:[Ug,Bg,Hg,Wg]}),Sr=Object.prototype.hasOwnProperty,xa=1,Vg=2,Gg=3,va=4,Ri=1,vk=2,su=3,wk=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,bk=/[\x85\u2028\u2029]/,yk=/[,\[\]\{\}]/,Yg=/^(?:!|!!|![a-z\-]+!)$/i,Kg=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function au(e){return Object.prototype.toString.call(e)}function Un(e){return e===10||e===13}function Rr(e){return e===9||e===32}function Kt(e){return e===9||e===32||e===10||e===13}function ro(e){return e===44||e===91||e===93||e===123||e===125}function Ck(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function Sk(e){return e===120?2:e===117?4:e===85?8:0}function Ek(e){return 48<=e&&e<=57?e-48:-1}function iu(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
316
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function Nk(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var qg=new Array(256),Xg=new Array(256);for(var Qr=0;Qr<256;Qr++)qg[Qr]=iu(Qr)?1:0,Xg[Qr]=iu(Qr);function jk(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||kc,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Zg(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=_j(n),new zt(t,n)}function pe(e,t){throw Zg(e,t)}function wa(e,t){e.onWarning&&e.onWarning.call(null,Zg(e,t))}var lu={YAML:function(t,n,r){var o,a,i;t.version!==null&&pe(t,"duplication of %YAML directive"),r.length!==1&&pe(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&pe(t,"ill-formed argument of the YAML directive"),a=parseInt(o[1],10),i=parseInt(o[2],10),a!==1&&pe(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&wa(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,a;r.length!==2&&pe(t,"TAG directive accepts exactly two arguments"),o=r[0],a=r[1],Yg.test(o)||pe(t,"ill-formed tag handle (first argument) of the TAG directive"),Sr.call(t.tagMap,o)&&pe(t,'there is a previously declared suffix for "'+o+'" tag handle'),Kg.test(a)||pe(t,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{pe(t,"tag prefix is malformed: "+a)}t.tagMap[o]=a}};function xr(e,t,n,r){var o,a,i,l;if(t<n){if(l=e.input.slice(t,n),r)for(o=0,a=l.length;o<a;o+=1)i=l.charCodeAt(o),i===9||32<=i&&i<=1114111||pe(e,"expected valid JSON character");else wk.test(l)&&pe(e,"the stream contains non-printable characters");e.result+=l}}function cu(e,t,n,r){var o,a,i,l;for(xt.isObject(n)||pe(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(n),i=0,l=o.length;i<l;i+=1)a=o[i],Sr.call(t,a)||(t[a]=n[a],r[a]=!0)}function oo(e,t,n,r,o,a,i,l,c){var u,p;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),u=0,p=o.length;u<p;u+=1)Array.isArray(o[u])&&pe(e,"nested arrays are not supported inside keys"),typeof o=="object"&&au(o[u])==="[object Object]"&&(o[u]="[object Object]");if(typeof o=="object"&&au(o)==="[object Object]"&&(o="[object Object]"),o=String(o),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(a))for(u=0,p=a.length;u<p;u+=1)cu(e,t,a[u],n);else cu(e,t,a,n);else!e.json&&!Sr.call(n,o)&&Sr.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,pe(e,"duplicated mapping key")),o==="__proto__"?Object.defineProperty(t,o,{configurable:!0,enumerable:!0,writable:!0,value:a}):t[o]=a,delete n[o];return t}function Ac(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):pe(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function dt(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;Rr(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(t&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(Un(o))for(Ac(e),o=e.input.charCodeAt(e.position),r++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&wa(e,"deficient indentation"),r}function ei(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||Kt(n)))}function Tc(e,t){t===1?e.result+=" ":t>1&&(e.result+=xt.repeat(`
317
+ `,t-1))}function kk(e,t,n){var r,o,a,i,l,c,u,p,f=e.kind,m=e.result,h;if(h=e.input.charCodeAt(e.position),Kt(h)||ro(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(o=e.input.charCodeAt(e.position+1),Kt(o)||n&&ro(o)))return!1;for(e.kind="scalar",e.result="",a=i=e.position,l=!1;h!==0;){if(h===58){if(o=e.input.charCodeAt(e.position+1),Kt(o)||n&&ro(o))break}else if(h===35){if(r=e.input.charCodeAt(e.position-1),Kt(r))break}else{if(e.position===e.lineStart&&ei(e)||n&&ro(h))break;if(Un(h))if(c=e.line,u=e.lineStart,p=e.lineIndent,dt(e,!1,-1),e.lineIndent>=t){l=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=u,e.lineIndent=p;break}}l&&(xr(e,a,i,!1),Tc(e,e.line-c),a=i=e.position,l=!1),Rr(h)||(i=e.position+1),h=e.input.charCodeAt(++e.position)}return xr(e,a,i,!1),e.result?!0:(e.kind=f,e.result=m,!1)}function Ak(e,t){var n,r,o;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=o=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(xr(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,o=e.position;else return!0;else Un(n)?(xr(e,r,o,!0),Tc(e,dt(e,!1,t)),r=o=e.position):e.position===e.lineStart&&ei(e)?pe(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);pe(e,"unexpected end of the stream within a single quoted scalar")}function Tk(e,t){var n,r,o,a,i,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return xr(e,n,e.position,!0),e.position++,!0;if(l===92){if(xr(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),Un(l))dt(e,!1,t);else if(l<256&&qg[l])e.result+=Xg[l],e.position++;else if((i=Sk(l))>0){for(o=i,a=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=Ck(l))>=0?a=(a<<4)+i:pe(e,"expected hexadecimal character");e.result+=Nk(a),e.position++}else pe(e,"unknown escape sequence");n=r=e.position}else Un(l)?(xr(e,n,r,!0),Tc(e,dt(e,!1,t)),n=r=e.position):e.position===e.lineStart&&ei(e)?pe(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}pe(e,"unexpected end of the stream within a double quoted scalar")}function _k(e,t){var n=!0,r,o,a,i=e.tag,l,c=e.anchor,u,p,f,m,h,x=Object.create(null),g,w,v,b;if(b=e.input.charCodeAt(e.position),b===91)p=93,h=!1,l=[];else if(b===123)p=125,h=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),b=e.input.charCodeAt(++e.position);b!==0;){if(dt(e,!0,t),b=e.input.charCodeAt(e.position),b===p)return e.position++,e.tag=i,e.anchor=c,e.kind=h?"mapping":"sequence",e.result=l,!0;n?b===44&&pe(e,"expected the node content, but found ','"):pe(e,"missed comma between flow collection entries"),w=g=v=null,f=m=!1,b===63&&(u=e.input.charCodeAt(e.position+1),Kt(u)&&(f=m=!0,e.position++,dt(e,!0,t))),r=e.line,o=e.lineStart,a=e.position,po(e,t,xa,!1,!0),w=e.tag,g=e.result,dt(e,!0,t),b=e.input.charCodeAt(e.position),(m||e.line===r)&&b===58&&(f=!0,b=e.input.charCodeAt(++e.position),dt(e,!0,t),po(e,t,xa,!1,!0),v=e.result),h?oo(e,l,x,w,g,v,r,o,a):f?l.push(oo(e,null,x,w,g,v,r,o,a)):l.push(g),dt(e,!0,t),b=e.input.charCodeAt(e.position),b===44?(n=!0,b=e.input.charCodeAt(++e.position)):n=!1}pe(e,"unexpected end of the stream within a flow collection")}function Ik(e,t){var n,r,o=Ri,a=!1,i=!1,l=t,c=0,u=!1,p,f;if(f=e.input.charCodeAt(e.position),f===124)r=!1;else if(f===62)r=!0;else return!1;for(e.kind="scalar",e.result="";f!==0;)if(f=e.input.charCodeAt(++e.position),f===43||f===45)Ri===o?o=f===43?su:vk:pe(e,"repeat of a chomping mode identifier");else if((p=Ek(f))>=0)p===0?pe(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?pe(e,"repeat of an indentation width identifier"):(l=t+p-1,i=!0);else break;if(Rr(f)){do f=e.input.charCodeAt(++e.position);while(Rr(f));if(f===35)do f=e.input.charCodeAt(++e.position);while(!Un(f)&&f!==0)}for(;f!==0;){for(Ac(e),e.lineIndent=0,f=e.input.charCodeAt(e.position);(!i||e.lineIndent<l)&&f===32;)e.lineIndent++,f=e.input.charCodeAt(++e.position);if(!i&&e.lineIndent>l&&(l=e.lineIndent),Un(f)){c++;continue}if(e.lineIndent<l){o===su?e.result+=xt.repeat(`
318
+ `,a?1+c:c):o===Ri&&a&&(e.result+=`
319
+ `);break}for(r?Rr(f)?(u=!0,e.result+=xt.repeat(`
320
+ `,a?1+c:c)):u?(u=!1,e.result+=xt.repeat(`
321
+ `,c+1)):c===0?a&&(e.result+=" "):e.result+=xt.repeat(`
322
+ `,c):e.result+=xt.repeat(`
323
+ `,a?1+c:c),a=!0,i=!0,c=0,n=e.position;!Un(f)&&f!==0;)f=e.input.charCodeAt(++e.position);xr(e,n,e.position,!1)}return!0}function du(e,t){var n,r=e.tag,o=e.anchor,a=[],i,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,pe(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!Kt(i))));){if(l=!0,e.position++,dt(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,po(e,t,Gg,!1,!0),a.push(e.result),dt(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)pe(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=o,e.kind="sequence",e.result=a,!0):!1}function Mk(e,t,n){var r,o,a,i,l,c,u=e.tag,p=e.anchor,f={},m=Object.create(null),h=null,x=null,g=null,w=!1,v=!1,b;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),b=e.input.charCodeAt(e.position);b!==0;){if(!w&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,pe(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),a=e.line,(b===63||b===58)&&Kt(r))b===63?(w&&(oo(e,f,m,h,x,null,i,l,c),h=x=g=null),v=!0,w=!0,o=!0):w?(w=!1,o=!0):pe(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,b=r;else{if(i=e.line,l=e.lineStart,c=e.position,!po(e,n,Vg,!1,!0))break;if(e.line===a){for(b=e.input.charCodeAt(e.position);Rr(b);)b=e.input.charCodeAt(++e.position);if(b===58)b=e.input.charCodeAt(++e.position),Kt(b)||pe(e,"a whitespace character is expected after the key-value separator within a block mapping"),w&&(oo(e,f,m,h,x,null,i,l,c),h=x=g=null),v=!0,w=!1,o=!1,h=e.tag,x=e.result;else if(v)pe(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=p,!0}else if(v)pe(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=p,!0}if((e.line===a||e.lineIndent>t)&&(w&&(i=e.line,l=e.lineStart,c=e.position),po(e,t,va,!0,o)&&(w?x=e.result:g=e.result),w||(oo(e,f,m,h,x,g,i,l,c),h=x=g=null),dt(e,!0,-1),b=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&b!==0)pe(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return w&&oo(e,f,m,h,x,null,i,l,c),v&&(e.tag=u,e.anchor=p,e.kind="mapping",e.result=f),v}function Rk(e){var t,n=!1,r=!1,o,a,i;if(i=e.input.charCodeAt(e.position),i!==33)return!1;if(e.tag!==null&&pe(e,"duplication of a tag property"),i=e.input.charCodeAt(++e.position),i===60?(n=!0,i=e.input.charCodeAt(++e.position)):i===33?(r=!0,o="!!",i=e.input.charCodeAt(++e.position)):o="!",t=e.position,n){do i=e.input.charCodeAt(++e.position);while(i!==0&&i!==62);e.position<e.length?(a=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):pe(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!Kt(i);)i===33&&(r?pe(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),Yg.test(o)||pe(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),yk.test(a)&&pe(e,"tag suffix cannot contain flow indicator characters")}a&&!Kg.test(a)&&pe(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{pe(e,"tag name is malformed: "+a)}return n?e.tag=a:Sr.call(e.tagMap,o)?e.tag=e.tagMap[o]+a:o==="!"?e.tag="!"+a:o==="!!"?e.tag="tag:yaml.org,2002:"+a:pe(e,'undeclared tag handle "'+o+'"'),!0}function Pk(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&pe(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!Kt(n)&&!ro(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&pe(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function Dk(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!Kt(r)&&!ro(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&pe(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),Sr.call(e.anchorMap,n)||pe(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],dt(e,!0,-1),!0}function po(e,t,n,r,o){var a,i,l,c=1,u=!1,p=!1,f,m,h,x,g,w;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=i=l=va===n||Gg===n,r&&dt(e,!0,-1)&&(u=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;Rk(e)||Pk(e);)dt(e,!0,-1)?(u=!0,l=a,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=u||o),(c===1||va===n)&&(xa===n||Vg===n?g=t:g=t+1,w=e.position-e.lineStart,c===1?l&&(du(e,w)||Mk(e,w,g))||_k(e,g)?p=!0:(i&&Ik(e,g)||Ak(e,g)||Tk(e,g)?p=!0:Dk(e)?(p=!0,(e.tag!==null||e.anchor!==null)&&pe(e,"alias node should not have any properties")):kk(e,g,xa===n)&&(p=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(p=l&&du(e,w))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&pe(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),f=0,m=e.implicitTypes.length;f<m;f+=1)if(x=e.implicitTypes[f],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(Sr.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,h=e.typeMap.multi[e.kind||"fallback"],f=0,m=h.length;f<m;f+=1)if(e.tag.slice(0,h[f].tag.length)===h[f].tag){x=h[f];break}x||pe(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&pe(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):pe(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||p}function Lk(e){var t=e.position,n,r,o,a=!1,i;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(i=e.input.charCodeAt(e.position))!==0&&(dt(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(a=!0,i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!Kt(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),o=[],r.length<1&&pe(e,"directive name must not be less than one character in length");i!==0;){for(;Rr(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!Un(i));break}if(Un(i))break;for(n=e.position;i!==0&&!Kt(i);)i=e.input.charCodeAt(++e.position);o.push(e.input.slice(n,e.position))}i!==0&&Ac(e),Sr.call(lu,r)?lu[r](e,r,o):wa(e,'unknown document directive "'+r+'"')}if(dt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,dt(e,!0,-1)):a&&pe(e,"directives end mark is expected"),po(e,e.lineIndent-1,va,!1,!0),dt(e,!0,-1),e.checkLineBreaks&&bk.test(e.input.slice(t,e.position))&&wa(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ei(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,dt(e,!0,-1));return}if(e.position<e.length-1)pe(e,"end of the stream or a document separator is expected");else return}function Jg(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
324
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new jk(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,pe(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Lk(n);return n.documents}function Ok(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=Jg(e,n);if(typeof t!="function")return r;for(var o=0,a=r.length;o<a;o+=1)t(r[o])}function Fk(e,t){var n=Jg(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new zt("expected a single document in the stream, but found more")}}var $k=Ok,zk=Fk,Qg={loadAll:$k,load:zk},ex=Object.prototype.toString,tx=Object.prototype.hasOwnProperty,_c=65279,Uk=9,ss=10,Bk=13,Hk=32,Wk=33,Vk=34,fl=35,Gk=37,Yk=38,Kk=39,qk=42,nx=44,Xk=45,ba=58,Zk=61,Jk=62,Qk=63,eA=64,rx=91,ox=93,tA=96,sx=123,nA=124,ax=125,Dt={};Dt[0]="\\0";Dt[7]="\\a";Dt[8]="\\b";Dt[9]="\\t";Dt[10]="\\n";Dt[11]="\\v";Dt[12]="\\f";Dt[13]="\\r";Dt[27]="\\e";Dt[34]='\\"';Dt[92]="\\\\";Dt[133]="\\N";Dt[160]="\\_";Dt[8232]="\\L";Dt[8233]="\\P";var rA=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],oA=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function sA(e,t){var n,r,o,a,i,l,c;if(t===null)return{};for(n={},r=Object.keys(t),o=0,a=r.length;o<a;o+=1)i=r[o],l=String(t[i]),i.slice(0,2)==="!!"&&(i="tag:yaml.org,2002:"+i.slice(2)),c=e.compiledTypeMap.fallback[i],c&&tx.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function aA(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new zt("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+xt.repeat("0",r-t.length)+t}var iA=1,as=2;function lA(e){this.schema=e.schema||kc,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=xt.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=sA(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?as:iA,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function uu(e,t){for(var n=xt.repeat(" ",t),r=0,o=-1,a="",i,l=e.length;r<l;)o=e.indexOf(`
325
+ `,r),o===-1?(i=e.slice(r),r=l):(i=e.slice(r,o+1),r=o+1),i.length&&i!==`
326
+ `&&(a+=n),a+=i;return a}function pl(e,t){return`
327
+ `+xt.repeat(" ",e.indent*t)}function cA(e,t){var n,r,o;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(o=e.implicitTypes[n],o.resolve(t))return!0;return!1}function ya(e){return e===Hk||e===Uk}function is(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==_c||65536<=e&&e<=1114111}function fu(e){return is(e)&&e!==_c&&e!==Bk&&e!==ss}function pu(e,t,n){var r=fu(e),o=r&&!ya(e);return(n?r:r&&e!==nx&&e!==rx&&e!==ox&&e!==sx&&e!==ax)&&e!==fl&&!(t===ba&&!o)||fu(t)&&!ya(t)&&e===fl||t===ba&&o}function dA(e){return is(e)&&e!==_c&&!ya(e)&&e!==Xk&&e!==Qk&&e!==ba&&e!==nx&&e!==rx&&e!==ox&&e!==sx&&e!==ax&&e!==fl&&e!==Yk&&e!==qk&&e!==Wk&&e!==nA&&e!==Zk&&e!==Jk&&e!==Kk&&e!==Vk&&e!==Gk&&e!==eA&&e!==tA}function uA(e){return!ya(e)&&e!==ba}function Wo(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function ix(e){var t=/^\n* /;return t.test(e)}var lx=1,ml=2,cx=3,dx=4,to=5;function fA(e,t,n,r,o,a,i,l){var c,u=0,p=null,f=!1,m=!1,h=r!==-1,x=-1,g=dA(Wo(e,0))&&uA(Wo(e,e.length-1));if(t||i)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Wo(e,c),!is(u))return to;g=g&&pu(u,p,l),p=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=Wo(e,c),u===ss)f=!0,h&&(m=m||c-x-1>r&&e[x+1]!==" ",x=c);else if(!is(u))return to;g=g&&pu(u,p,l),p=u}m=m||h&&c-x-1>r&&e[x+1]!==" "}return!f&&!m?g&&!i&&!o(e)?lx:a===as?to:ml:n>9&&ix(e)?to:i?a===as?to:ml:m?dx:cx}function pA(e,t,n,r,o){e.dump=function(){if(t.length===0)return e.quotingType===as?'""':"''";if(!e.noCompatMode&&(rA.indexOf(t)!==-1||oA.test(t)))return e.quotingType===as?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),i=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(u){return cA(e,u)}switch(fA(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case lx:return t;case ml:return"'"+t.replace(/'/g,"''")+"'";case cx:return"|"+mu(t,e.indent)+hu(uu(t,a));case dx:return">"+mu(t,e.indent)+hu(uu(mA(t,i),a));case to:return'"'+hA(t)+'"';default:throw new zt("impossible error: invalid scalar style")}}()}function mu(e,t){var n=ix(e)?String(t):"",r=e[e.length-1]===`
328
+ `,o=r&&(e[e.length-2]===`
329
+ `||e===`
330
+ `),a=o?"+":r?"":"-";return n+a+`
331
+ `}function hu(e){return e[e.length-1]===`
332
+ `?e.slice(0,-1):e}function mA(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var u=e.indexOf(`
333
+ `);return u=u!==-1?u:e.length,n.lastIndex=u,gu(e.slice(0,u),t)}(),o=e[0]===`
334
+ `||e[0]===" ",a,i;i=n.exec(e);){var l=i[1],c=i[2];a=c[0]===" ",r+=l+(!o&&!a&&c!==""?`
335
+ `:"")+gu(c,t),o=a}return r}function gu(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,o=0,a,i=0,l=0,c="";r=n.exec(e);)l=r.index,l-o>t&&(a=i>o?i:l,c+=`
336
+ `+e.slice(o,a),o=a+1),i=l;return c+=`
337
+ `,e.length-o>t&&i>o?c+=e.slice(o,i)+`
338
+ `+e.slice(i+1):c+=e.slice(o),c.slice(1)}function hA(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Wo(e,o),r=Dt[n],!r&&is(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||aA(n);return t}function gA(e,t,n){var r="",o=e.tag,a,i,l;for(a=0,i=n.length;a<i;a+=1)l=n[a],e.replacer&&(l=e.replacer.call(n,String(a),l)),(dr(e,t,l,!1,!1)||typeof l>"u"&&dr(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function xu(e,t,n,r){var o="",a=e.tag,i,l,c;for(i=0,l=n.length;i<l;i+=1)c=n[i],e.replacer&&(c=e.replacer.call(n,String(i),c)),(dr(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&dr(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=pl(e,t)),e.dump&&ss===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=a,e.dump=o||"[]"}function xA(e,t,n){var r="",o=e.tag,a=Object.keys(n),i,l,c,u,p;for(i=0,l=a.length;i<l;i+=1)p="",r!==""&&(p+=", "),e.condenseFlow&&(p+='"'),c=a[i],u=n[c],e.replacer&&(u=e.replacer.call(n,c,u)),dr(e,t,c,!1,!1)&&(e.dump.length>1024&&(p+="? "),p+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),dr(e,t,u,!1,!1)&&(p+=e.dump,r+=p));e.tag=o,e.dump="{"+r+"}"}function vA(e,t,n,r){var o="",a=e.tag,i=Object.keys(n),l,c,u,p,f,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new zt("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=pl(e,t)),u=i[l],p=n[u],e.replacer&&(p=e.replacer.call(n,u,p)),dr(e,t+1,u,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&ss===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,f&&(m+=pl(e,t)),dr(e,t+1,p,!0,f)&&(e.dump&&ss===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=a,e.dump=o||"{}"}function vu(e,t,n){var r,o,a,i,l,c;for(o=n?e.explicitTypes:e.implicitTypes,a=0,i=o.length;a<i;a+=1)if(l=o[a],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,ex.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(tx.call(l.represent,c))r=l.represent[c](t,c);else throw new zt("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function dr(e,t,n,r,o,a,i){e.tag=null,e.dump=n,vu(e,n,!1)||vu(e,n,!0);var l=ex.call(e.dump),c=r,u;r&&(r=e.flowLevel<0||e.flowLevel>t);var p=l==="[object Object]"||l==="[object Array]",f,m;if(p&&(f=e.duplicates.indexOf(n),m=f!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&t>0)&&(o=!1),m&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(p&&m&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(vA(e,t,e.dump,o),m&&(e.dump="&ref_"+f+e.dump)):(xA(e,t,e.dump),m&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?xu(e,t-1,e.dump,o):xu(e,t,e.dump,o),m&&(e.dump="&ref_"+f+e.dump)):(gA(e,t,e.dump),m&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&pA(e,e.dump,t,a,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new zt("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function wA(e,t){var n=[],r=[],o,a;for(hl(e,n,r),o=0,a=r.length;o<a;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(a)}function hl(e,t,n){var r,o,a;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,a=e.length;o<a;o+=1)hl(e[o],t,n);else for(r=Object.keys(e),o=0,a=r.length;o<a;o+=1)hl(e[r[o]],t,n)}function bA(e,t){t=t||{};var n=new lA(t);n.noRefs||wA(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),dr(n,0,r,!0,!0)?n.dump+`
339
+ `:""}var yA=bA,CA={dump:yA};function Ic(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var SA=Tt,EA=jg,NA=_g,jA=Dg,kA=Lg,AA=kc,TA=Qg.load,_A=Qg.loadAll,IA=CA.dump,MA=zt,RA={binary:Ug,float:Pg,map:Tg,null:Ig,pairs:Hg,set:Wg,timestamp:$g,bool:Mg,int:Rg,merge:zg,omap:Bg,seq:Ag,str:kg},PA=Ic("safeLoad","load"),DA=Ic("safeLoadAll","loadAll"),LA=Ic("safeDump","dump"),OA={Type:SA,Schema:EA,FAILSAFE_SCHEMA:NA,JSON_SCHEMA:jA,CORE_SCHEMA:kA,DEFAULT_SCHEMA:AA,load:TA,loadAll:_A,dump:IA,YAMLException:MA,types:RA,safeLoad:PA,safeLoadAll:DA,safeDump:LA};const FA=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=d.useState(!1);d.useEffect(()=>{n(null)},[e,n]);const[a,i]=d.useMemo(()=>{try{if(t==="yaml"){const l=OA.load(e);return[e,l]}else if(t==="json"){const l=JSON.parse(e);return[JSON.stringify(l,null,2),l]}throw new Error(`Unsupported renderer type: ${t}`)}catch(l){const c=t==="yaml"?"YAML":"JSON";console.error(`Error parsing ${c} for panel:`,l);const u={[`${c}_Parsing_Error`]:`The provided content is not valid ${c}.`,Details:l.message,Content_Snippet:e.substring(0,500)+(e.length>500?"...":"")};return n(`${c} parsing failed: ${l.message}`),[e,u]}},[e,t,n]);return s.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(te,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ru,{})," Structured"]}):s.jsxs(s.Fragment,{children:[s.jsx(Pu,{})," Raw Text"]})})}),s.jsx("div",{className:"flex min-h-0 flex-col",children:s.jsx("div",{className:"flex-1 overflow-auto",children:r?s.jsx(ux,{content:a,setRenderError:n}):s.jsx(Cl,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},ux=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=Sg();return s.jsx("div",{className:`overflow-auto p-4 ${t}`,children:s.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},Mc=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return s.jsx(pj,{content:e,setRenderError:r});case"mermaid":return s.jsx(xj,{content:e,setRenderError:r});case"html":return s.jsx(mj,{content:e,setRenderError:r});case"json":case"yaml":return s.jsx(FA,{content:e,rendererType:t,setRenderError:r});case"image":return s.jsx(hj,{content:e,mime_type:n,setRenderError:r});case"markdown":return s.jsx(gj,{content:e,setRenderError:r});case"audio":return s.jsx(uj,{content:e,mime_type:n,setRenderError:r});default:return s.jsx(ux,{content:e,setRenderError:r})}},Rc=e=>{const t=e.split(".");return t.length>1?t[t.length-1].toUpperCase():"FILE"},En=e=>{switch(e){case"html":return"bg-[#e34c26]";case"json":return"bg-[#fbc02d] text-[#333]";case"yaml":return"bg-[#cb171e]";case"markdown":return"bg-[#6c757d]";case"text":return"bg-[#5c6bc0]";default:return"bg-gray-500"}},$A=(e,t)=>{const n={className:"text-secondary-foreground/60"};if(e){if(e.startsWith("image/"))return s.jsx(Fi,{...n});if(e.startsWith("video/"))return s.jsx($c,{...n});if(e.startsWith("audio/"))return s.jsx(Oi,{...n});if(e==="application/pdf")return s.jsx(or,{...n});if(e==="application/zip"||e==="application/x-zip-compressed"||e==="application/x-rar-compressed"||e==="application/x-tar"||e==="application/gzip")return s.jsx(zc,{...n});if(e.includes("word")||e.includes("document"))return s.jsx(or,{...n});if(e.includes("excel")||e.includes("spreadsheet"))return s.jsx(Li,{...n});if(e.includes("powerpoint")||e.includes("presentation"))return s.jsx(Uc,{...n});if(e==="application/x-executable"||e==="application/x-msdownload")return s.jsx(Bc,{...n})}switch(t?Rc(t).toLowerCase():""){case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return s.jsx(Fi,{...n});case"mp4":case"avi":case"mov":case"wmv":case"flv":case"webm":case"mkv":return s.jsx($c,{...n});case"mp3":case"wav":case"flac":case"aac":case"ogg":case"m4a":return s.jsx(Oi,{...n});case"pdf":case"doc":case"docx":return s.jsx(or,{...n});case"xls":case"xlsx":case"csv":return s.jsx(Li,{...n});case"ppt":case"pptx":return s.jsx(Uc,{...n});case"zip":case"rar":case"7z":case"tar":case"gz":return s.jsx(zc,{...n});case"exe":case"msi":case"dmg":case"pkg":case"deb":case"rpm":return s.jsx(Bc,{...n});case"ttf":case"otf":case"woff":case"woff2":return s.jsx(Fx,{...n});case"htm":case"html":return s.jsx(Tu,{...n});default:return null}},zA=(e,t)=>{if(e){if(e.startsWith("text/html")||e==="application/xhtml+xml")return En("html");if(e==="application/json"||e==="text/json")return En("json");if(e==="application/yaml"||e==="text/yaml"||e==="application/x-yaml"||e==="text/x-yaml")return En("yaml");if(e.startsWith("text/"))return En("text");if(e.startsWith("text/markdown")||e==="application/markdown")return En("markdown")}switch(t?Rc(t).toLowerCase():""){case"html":case"htm":return En("html");case"json":return En("json");case"yaml":case"yml":return En("yaml");case"md":case"markdown":return En("markdown");case"txt":return En("text");default:return En("default")}},UA=({filename:e,mimeType:t,className:n})=>{if(!e||typeof e!="string")return console.warn("FileIcon: filename is required and must be a string"),null;const r=Rc(e),o=zA(t,e),a=$A(t,e);return s.jsx("div",{className:ve("relative flex-shrink-0",n),children:s.jsxs("div",{className:"bg-muted/50 relative h-[75px] w-[60px] border",children:[s.jsx("div",{className:"absolute top-[4px] right-[4px] bottom-[24px] left-[4px] overflow-hidden font-mono text-[3.5px] leading-[1.4]",children:a?s.jsx("div",{className:"flex h-full items-center justify-center",children:a}):s.jsx("div",{className:"text-secondary-foreground flex h-full text-[8px] select-none",children:s.jsx("div",{className:"flex h-full w-full items-center justify-center",children:s.jsx(Di,{className:"text-secondary-foreground/60"})})})}),s.jsx("div",{className:ve("absolute right-[4px] bottom-[4px] z-[4] px-[4px] py-[2px] text-[10px] font-bold text-[var(--color-primary-text-w10)] select-none",o),children:r.length>4?r.substring(0,4):r})]})})},wu=({message:e})=>s.jsx("div",{className:"w-full rounded-lg border border-[var(--color-error-w100)] bg-[var(--color-error-wMain-50)] p-3",children:s.jsxs("div",{className:"text-sm text-[var(--color-error-wMain)]",children:["Error: ",e]})}),BA=({filename:e,description:t,mimeType:n,size:r,status:o,expandable:a=!1,expanded:i=!1,onToggleExpand:l,actions:c,bytesTransferred:u,error:p,expandedContent:f,context:m="chat",isDeleted:h=!1,version:x,source:g})=>{const[w,v]=d.useState(f);if(d.useEffect(()=>{if(f)v(f);else{const N=setTimeout(()=>{v(void 0)},300);return()=>clearTimeout(N)}},[f]),!e||typeof e!="string")return console.error("ArtifactBar: filename is required and must be a string"),s.jsx(wu,{message:"Invalid artifact filename"});if(!o||!["in-progress","completed","failed"].includes(o))return console.error("ArtifactBar: status must be one of: in-progress, completed, failed"),s.jsx(wu,{message:"Invalid artifact status"});const y=(()=>{if(h)return{text:"Deleted",className:"text-[var(--color-secondary-foreground)]"};switch(o){case"in-progress":return{text:u?`Creating... ${(u/1024).toFixed(1)}KB`:"Creating...",className:"text-[var(--color-info-wMain)]"};case"failed":return{text:p||"Failed to create",className:"text-[var(--color-error-wMain)]"};case"completed":return{text:r?`${(r/1024).toFixed(1)}KB`:""};default:return{text:"Unknown",className:"text-[var(--color-secondary-foreground)]"}}})(),T=((N,k=100)=>{if(!N||typeof N!="string")return"";const M=N.replace(/\s+/g," ").trim();if(M.length<=k)return M;const L=M.substring(0,k),O=L.lastIndexOf(" ");return O>k*.7?L.substring(0,O)+"...":L+"..."})(t),C=t&&t.trim(),S=()=>{if(o==="completed"&&(c!=null&&c.onPreview))try{c.onPreview()}catch(N){console.error("Preview failed:",N)}};return s.jsxs("div",{className:`dark:bg-muted/30 w-full ${o==="completed"&&(c!=null&&c.onPreview)&&!h?"cursor-pointer transition-all duration-200 ease-in-out hover:shadow-md":""} ${m==="list"?"border-b":"border-border rounded-md border"} ${h?"opacity-60":""}`,onClick:h?void 0:S,children:[s.jsxs("div",{className:"flex min-h-[60px] items-center gap-3 p-3",children:[s.jsx(UA,{filename:e,mimeType:n,size:r,className:"flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1 py-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"truncate text-sm leading-tight font-semibold",title:C?t:e,children:C?T:e.length>50?`${e.substring(0,47)}...`:e}),g==="project"&&s.jsx(jo,{variant:"outline",className:"text-xs bg-primary/10 border-primary/30 text-primary font-semibold px-2 py-0.5 shadow-sm",children:"Project"})]}),s.jsx("div",{className:"text-secondary-foreground mt-1 flex items-center gap-2 text-xs leading-tight",title:C?e:y.text,children:C?s.jsxs("div",{className:"truncate",children:[e.length>60?`${e.substring(0,57)}...`:e,x!==void 0&&m==="chat"&&s.jsxs("span",{className:"ml-1.5",children:["(v",x,")"]})]}):s.jsxs(s.Fragment,{children:[o==="in-progress"&&s.jsx(Wn,{size:"small",variant:"primary"}),s.jsx("span",{className:y.className,children:y.text})]})}),C&&s.jsxs("div",{className:ve("mt-0.5 flex items-center gap-2 text-xs leading-tight",y.className),children:[o==="in-progress"&&s.jsx(Wn,{size:"small",variant:"primary"}),s.jsx("span",{children:y.text})]})]}),s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[o==="completed"&&(c==null?void 0:c.onInfo)&&!h&&s.jsx(te,{variant:"ghost",size:"icon",onClick:N=>{var k;N.stopPropagation();try{(k=c.onInfo)==null||k.call(c)}catch(M){console.error("Info failed:",M)}},tooltip:"Info",children:s.jsx(Sa,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onDownload)&&!h&&s.jsx(te,{variant:"ghost",size:"icon",onClick:N=>{var k;N.stopPropagation();try{(k=c.onDownload)==null||k.call(c)}catch(M){console.error("Download failed:",M)}},tooltip:"Download",children:s.jsx(xo,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onExpand)&&!h&&s.jsx(te,{variant:"ghost",size:"icon",onClick:N=>{var k;N.stopPropagation();try{(k=c.onExpand)==null||k.call(c)}catch(M){console.error("Expand failed:",M)}},tooltip:i?"Collapse":"Expand",children:i?s.jsx($i,{className:"h-4 w-4"}):s.jsx(na,{className:"h-4 w-4"})}),o==="completed"&&(c==null?void 0:c.onDelete)&&!h&&s.jsx(te,{variant:"ghost",size:"icon",onClick:N=>{var k;N.stopPropagation();try{(k=c.onDelete)==null||k.call(c)}catch(M){console.error("Delete failed:",M)}},tooltip:"Delete",children:s.jsx(Ea,{className:"h-4 w-4"})}),o==="failed"&&s.jsx("div",{className:"pr-4",title:"Artifact action failed",children:s.jsx(cs,{className:"h-4 w-4 text-[var(--color-error-wMain)]"})})]}),a&&l&&!h&&s.jsx(te,{variant:"ghost",size:"icon",onClick:N=>{N.stopPropagation();try{l()}catch(k){console.error("Toggle expand failed:",k)}},tooltip:i?"Collapse":"Expand",children:i?s.jsx($i,{className:"h-4 w-4 transition-transform duration-200"}):s.jsx(na,{className:"h-4 w-4 transition-transform duration-200"})})]}),s.jsx("div",{className:ve("grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-in-out",i&&f&&"grid-rows-[1fr]"),children:s.jsx("div",{className:"overflow-hidden",children:w&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-t"}),s.jsx("div",{className:"p-3",children:w})]})})})]})},fx=({isVisible:e,message:t="Resolving embeds..."})=>e?s.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200",style:{opacity:e?1:0,pointerEvents:e?"auto":"none"},children:s.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg bg-card p-6 shadow-lg",children:[s.jsx(Ca,{className:"h-6 w-6 animate-spin text-primary"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}):null,Vo=e=>{const{artifacts:t,setPreviewArtifact:n,openSidePanelTab:r,sessionId:o,openDeleteModal:a,markArtifactAsDisplayed:i,downloadAndResolveArtifact:l,navigateArtifactVersion:c}=qe(),{activeProject:u}=Jn(),[p,f]=d.useState(!1),[m,h]=d.useState(null),[x,g]=d.useState(null),[w,v]=d.useState(null),[b,y]=d.useState(!1),[E,T]=d.useState(!1),C=d.useMemo(()=>t.find(ne=>ne.filename===e.name),[t,e.name]),S=e.context||"chat",N=(C==null?void 0:C.source)==="project",k=d.useMemo(()=>{const ne=e.status==="completed"?e.fileAttachment:void 0;if(ne!=null&&ne.uri){const ue=Wi(ne.uri);return(ue==null?void 0:ue.version)!==null&&(ue==null?void 0:ue.version)!==void 0?parseInt(ue.version):void 0}},[e]),M=e.status==="completed"?e.fileAttachment:void 0,L=(M==null?void 0:M.name)||e.name,O=M==null?void 0:M.mime_type,V=d.useMemo(()=>e.status==="completed"&&!C,[e.status,C]),K=d.useMemo(()=>{const ne=kn(L,O);return(ne==="image"||ne==="audio")&&S==="chat"},[L,O,S]),{shouldRender:G,isExpandable:R,isExpanded:q,toggleExpanded:j}=zC({filename:L,mimeType:O,shouldAutoExpand:K}),I=d.useCallback(async()=>{C&&(r("files"),n(C),k!==void 0&&setTimeout(async()=>{await c(C.filename,k)},100))},[C,r,n,k,c]),D=d.useCallback(()=>{let ne=null;C?(ne={name:C.filename,mime_type:C.mime_type,uri:C.uri,size:C.size,last_modified:C.last_modified},!ne.uri&&(M!=null&&M.content)&&(ne.content=M.content)):M&&(ne=M),ne?gf(ne,o,u==null?void 0:u.id):console.error(`No file to download for artifact: ${e.name}`)},[C,M,o,u==null?void 0:u.id,e.name]),z=d.useCallback(()=>{C&&a(C)},[C,a]),J=d.useCallback(()=>{y(!b)},[b]);d.useEffect(()=>{const ne=C==null?void 0:C.filename;return G&&ne&&i(ne,!0),()=>{ne&&i(ne,!1)}},[G,C==null?void 0:C.filename,i]);const U=d.useMemo(()=>{const ne=kn(L,O);return ne==="image"||ne==="audio"},[L,O]),F=d.useMemo(()=>kn(L,O)==="image",[L,O]);d.useEffect(()=>{e.status==="in-progress"&&(C!=null&&C.accumulatedContent)&&G&&g(C.accumulatedContent)},[C==null?void 0:C.accumulatedContent,e.status,L,G,q]),d.useEffect(()=>{(async()=>{if(C!=null&&C.needsEmbedResolution&&e.status==="completed"&&G&&!E){T(!0);try{const ue=await l(C.filename);ue!=null&&ue.content&&g(ue.content)}catch(ue){console.error(`Error downloading ${L}:`,ue)}finally{T(!1)}}})()},[C==null?void 0:C.needsEmbedResolution,e.status,G,L,C==null?void 0:C.filename,l,E]),d.useEffect(()=>{(async()=>{if(p||!G)return;if(e.status==="in-progress"){C!=null&&C.accumulatedContent&&g(C.accumulatedContent);return}if(e.status!=="completed")return;if(C!=null&&C.accumulatedContent){g(C.accumulatedContent);return}const ue=M==null?void 0:M.content;if(x||ue){ue&&!x&&g(ue);return}const Oe=M==null?void 0:M.uri;if(Oe){f(!0),h(null);try{const De=Wi(Oe);if(!De)throw new Error("Invalid artifact URI.");const{filename:Te,version:Be}=De;let Et;o&&o.trim()&&o!=="null"&&o!=="undefined"?Et=`/api/v1/artifacts/${o}/${encodeURIComponent(Te)}/versions/${Be||"latest"}`:u!=null&&u.id?Et=`/api/v1/artifacts/null/${encodeURIComponent(Te)}/versions/${Be||"latest"}?project_id=${u.id}`:Et=`/api/v1/artifacts/null/${encodeURIComponent(Te)}/versions/${Be||"latest"}`;const et=await Ne(Et);if(!et.ok)throw new Error(`Failed to fetch artifact content: ${et.statusText}`);const wt=await et.blob(),Lt=await new Promise((ut,ft)=>{const st=new FileReader;st.onloadend=()=>{typeof st.result=="string"?ut(st.result.split(",")[1]):ft(new Error("Failed to read artifact content as a data URL."))},st.onerror=()=>{ft(st.error||new Error("An unknown error occurred while reading the file."))},st.readAsDataURL(wt)});g(Lt)}catch(De){console.error("Error fetching inline content:",De),h(De instanceof Error?De.message:"Unknown error fetching content.")}finally{f(!1)}}})()},[e.status,G,M,o,u==null?void 0:u.id,p,x,C==null?void 0:C.accumulatedContent,L,q,C]);const W=d.useMemo(()=>{if(e.status!=="failed")return S==="list"?{onInfo:J,onDownload:e.status==="completed"?D:void 0,onDelete:C&&e.status==="completed"&&!N?z:void 0}:{onPreview:e.status==="completed"?I:void 0,onDownload:e.status==="completed"?D:void 0,onInfo:J}},[e.status,S,D,C,z,J,I,N]),P=d.useMemo(()=>t.find(ne=>ne.filename===e.name),[t,e.name]),_=P==null?void 0:P.description,H=x||(M==null?void 0:M.content),X=kn(L,O);let Q=null;if(p)Q=s.jsx("div",{className:"bg-muted flex h-25 items-center justify-center",children:s.jsx(Wn,{})});else if(m)Q=s.jsx(Yo,{variant:"error",message:m});else if(H&&X)try{const ue=mm({...M||{name:L,mime_type:O},content:H,isPlainText:(C==null?void 0:C.isAccumulatedContentPlainText)&&x===(C==null?void 0:C.accumulatedContent)||e.status==="in-progress"&&!!x});ue&&(Q=s.jsxs("div",{className:"group relative max-w-full overflow-hidden",children:[w&&s.jsx(Yo,{variant:"error",message:w}),s.jsx("div",{style:{maxHeight:U&&!F?"300px":F?"none":"400px",overflowY:F?"visible":"auto"},className:F?"drop-shadow-md":"",children:s.jsx(Mc,{content:ue,rendererType:X,mime_type:M==null?void 0:M.mime_type,setRenderError:v})}),s.jsx(fx,{isVisible:E,message:"Resolving embeds..."})]}))}catch(ne){console.error("Failed to process file content:",ne),Q=s.jsx(Yo,{variant:"error",message:"Failed to process file content for rendering"})}const oe=G&&q,re=d.useMemo(()=>!b||!C?null:s.jsxs("div",{className:"space-y-2 text-sm",children:[C.description&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),s.jsx("div",{className:"mt-1",children:C.description})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Size:"}),s.jsx("div",{children:Ta(C.size)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Modified:"}),s.jsx("div",{children:qo(C.last_modified)})]})]}),C.mime_type&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),s.jsx("div",{children:C.mime_type})]})]}),[b,C]),de=d.useMemo(()=>{const ne=b&&re,ue=oe&&Q;if(ne&&ue)return s.jsxs("div",{className:"space-y-4",children:[re,s.jsx("hr",{className:"border-t"}),Q]});if(ne)return re;if(ue)return Q},[b,re,oe,Q]);return s.jsx(BA,{filename:L,description:_||"",mimeType:O,size:M==null?void 0:M.size,status:e.status,expandable:R&&S==="chat",expanded:q||b,onToggleExpand:R&&S==="chat"?j:void 0,actions:W,bytesTransferred:e.status==="in-progress"?e.bytesTransferred:void 0,error:e.status==="failed"?e.error:void 0,expandedContent:de,context:S,isDeleted:V,version:k,source:C==null?void 0:C.source})},px=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:a,setPreviewArtifact:i,openSidePanelTab:l}=qe(),c=d.useMemo(()=>a.find(m=>m.filename===e),[a,e]),u=d.useMemo(()=>gm(c||{filename:e,mime_type:t||""}),[c,e,t]),p=d.useCallback(m=>{m.stopPropagation(),c&&(l("files"),i(c))},[c,l,i]),f=d.useCallback(()=>{r&&r()},[r]);return s.jsxs("div",{className:`flex h-11 max-w-xs flex-shrink items-center gap-2 rounded-lg bg-[var(--accent-background)] px-2 py-1 ${n||""}`,children:[u,s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-9",title:e,children:s.jsx("strong",{children:s.jsx("code",{children:e})})}),c&&!o&&s.jsx(te,{variant:"ghost",onClick:p,tooltip:"Preview",children:s.jsx(Ru,{className:"h-4 w-4"})}),r&&s.jsx(te,{variant:"ghost",onClick:f,tooltip:"Download file",children:s.jsx(xo,{className:"h-4 w-4"})})]})},HA=jt.memo(({isOpen:e,onClose:t,feedbackType:n,onSubmit:r})=>{const[o,a]=d.useState(""),[i,l]=d.useState(!1),c=d.useRef(null);d.useEffect(()=>{e&&(a(""),l(!1),setTimeout(()=>{var m;(m=c.current)==null||m.focus()},100))},[e]);const u=async()=>{l(!0);try{await r(o),t()}catch{l(!1)}},p=()=>{i||t()},f=n==="up"?"What did you like about the response?":"What did you dislike about the response?";return s.jsx(Yn,{open:e,onOpenChange:p,children:s.jsxs(Kn,{className:"sm:max-w-[750px]",showCloseButton:!1,children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Provide Feedback"}),s.jsxs(Zn,{className:"flex flex-col gap-2",children:[s.jsx("span",{className:"font-medium",children:f}),s.jsx("span",{children:"Providing more details will help improve AI responses over time."})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Hr,{ref:c,value:o,onChange:m=>a(m.target.value),className:"min-h-[120px] text-sm",disabled:i}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Along with your feedback, details of the task will be recorded."})]}),s.jsxs(jr,{children:[s.jsx(te,{variant:"ghost",onClick:p,disabled:i,children:"Cancel"}),s.jsx(te,{variant:"default",onClick:u,disabled:i,children:i?"Submitting...":"Submit"})]})]})})}),WA={"application/pdf":"pdf","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/x-markdown":"md","application/json":"json","application/yaml":"yaml","text/yaml":"yaml","application/xml":"xml","text/xml":"xml","image/jpeg":"jpg","image/png":"png","image/gif":"gif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff","audio/mpeg":"mp3","audio/wav":"wav","audio/ogg":"ogg","audio/aac":"aac","audio/flac":"flac","audio/x-m4a":"m4a","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","application/javascript":"js","application/gzip":"gz","application/x-tar":"tar","application/rtf":"rtf"};function VA(e,t){const n=WA[e]||"bin";return`embedded_file_${t+1}.${n}`}function GA(e){if(!e||typeof e!="string")return[];const t=[],n=/data:([a-zA-Z0-9/.-]+);base64,([A-Za-z0-9+/=]+)/g;let r,o=0;for(;(r=n.exec(e))!==null;){const[a,i,l]=r,c=e[r.index-1],u=e[r.index+a.length];if(!(c==='"'&&u==='"'||c==="'"&&u==="'")&&l&&l.length>10){const p=kn(void 0,i);p?t.push({type:p,content:l,mimeType:i,originalMatch:a}):t.push({type:"file",content:l,mimeType:i,originalMatch:a,filename:VA(i,o++)})}}return t}function YA(e){if(!e||typeof e!="string")return[];const t=[],n=/<html[\s\S]*?<\/html>/gi;let r;for(;(r=n.exec(e))!==null;)t.push({type:"html",content:r[0].trim(),originalMatch:r[0]});return t}function KA(e){if(!e||typeof e!="string")return[];const t=[],n=/```mermaid\s*\n([\s\S]*?)```/gi;let r;for(;(r=n.exec(e))!==null;){const[o,a]=r;t.push({type:"mermaid",content:a.trim(),originalMatch:o})}return t}function qA(e){return!e||typeof e!="string"?[]:[...GA(e),...YA(e),...KA(e)]}const mx={LAYOUT:"layout"},$t=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:s.jsxs("div",{className:`mb-1.5 flex text-sm ${r?"flex-col items-start":"items-center"}`,children:[s.jsxs("div",{className:"flex w-36 flex-shrink-0 items-center text-sm font-semibold text-nowrap",children:[n&&s.jsx("span",{className:"mr-2",children:n}),e,":"]}),s.jsx("div",{className:`text-accent-foreground text-sm ${r?"mt-1 w-full":"truncate"}`,title:typeof t=="string"?t:void 0,children:t})]}),XA=({agent:e,isExpanded:t,onToggleExpand:n})=>{const r=l=>!l||Object.keys(l).length===0?s.jsx("span",{className:"text-sm",children:"N/A"}):s.jsx("ul",{className:"list-inside list-disc pl-1",children:Object.entries(l).map(([c,u])=>s.jsxs("li",{className:"text-sm",children:[s.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",u?"Yes":"No"]},c))}),o=(l,c="None")=>!l||l.length===0?s.jsx("span",{children:c}):l.map(u=>s.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:u},u)),a=l=>!l||l.length===0?s.jsx("span",{children:"No skills listed"}):s.jsx("div",{className:"space-y-1",children:l.map(c=>s.jsxs("div",{className:"rounded p-1.5 text-xs",children:[s.jsx("p",{className:"font-semibold",children:c.name}),s.jsx("p",{children:c.description})]},c.id||c.name))}),i=l=>!l||l.length===0?s.jsx("span",{children:"No tools listed"}):s.jsx("div",{className:"space-y-1",children:l.map(c=>s.jsxs("div",{className:"rounded p-1.5 text-xs",children:[s.jsx("p",{className:"text-foreground font-semibold",children:c.name}),s.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return s.jsx("div",{className:"bg-card h-[400px] w-full flex-shrink-0 cursor-pointer rounded-lg sm:w-[380px]",onClick:n,role:"button",tabIndex:0,"aria-expanded":t,children:s.jsxs("div",{className:`transform-style-preserve-3d relative h-full w-full transition-transform duration-700 ${t?"rotate-y-180":""}`,style:{transformStyle:"preserve-3d"},children:[s.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:[s.jsx("div",{className:"flex items-center p-4",children:s.jsxs("div",{className:"flex min-w-0 items-center",children:[s.jsx(Nl,{className:"mr-3 h-8 w-8 flex-shrink-0 text-[var(--color-brand-wMain)]"}),s.jsx("div",{className:"min-w-0",children:s.jsx("h2",{className:"truncate text-xl font-semibold",title:e.name,children:e.displayName||e.name})})]})}),s.jsxs("div",{className:"scrollbar-themed flex-grow space-y-3 overflow-y-auto p-4",children:[s.jsx("div",{className:"mb-2 line-clamp-4 text-base",children:e.description||"No description provided."}),s.jsx($t,{label:"Version",value:e.version,icon:s.jsx(Hc,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&s.jsx($t,{label:"Key Capabilities",value:r(e.capabilities),icon:s.jsx(Wc,{size:14}),fullWidthValue:!0})]}),s.jsx("div",{"data-testid":"clickForDetails",className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for details"})]}),s.jsxs("div",{className:"absolute flex h-full w-full flex-col overflow-hidden rounded-lg border shadow-xl",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[s.jsx("div",{className:"flex items-center p-3",children:s.jsxs("h3",{className:"text-md truncate font-semibold",title:e.name,children:["Details: ",e.displayName||e.name]})}),s.jsxs("div",{className:"scrollbar-themed flex-grow space-y-1.5 overflow-y-auto p-3 text-xs",children:[s.jsx($t,{label:"Name",value:e.name,icon:s.jsx(Sa,{size:14})}),s.jsx($t,{label:"Description",value:e.description,icon:s.jsx($x,{size:14}),fullWidthValue:!0}),s.jsx($t,{label:"Version",value:e.version,icon:s.jsx(Hc,{size:14})}),s.jsx($t,{label:"Endpoint",value:e.url||"N/A",icon:s.jsx(Du,{size:14})}),s.jsx($t,{label:"Docs",value:e.documentationUrl?s.jsx("a",{href:e.documentationUrl,target:"_blank",rel:"noopener noreferrer",className:"break-all",children:"View Docs"}):"N/A",icon:s.jsx(Iu,{size:14})}),e.provider&&s.jsxs("div",{className:"mt-1.5 border-t pt-1.5",children:[s.jsx("h4",{className:"mb-0.5 text-xs font-semibold",children:"Provider"}),s.jsx($t,{label:"Name",value:e.provider.organization}),s.jsx($t,{label:"URL",value:e.provider.url||"N/A"})]}),s.jsx($t,{label:"Capabilities",value:r(e.capabilities),icon:s.jsx(Wc,{size:14}),fullWidthValue:!0}),s.jsx($t,{label:"Input Modes",value:o(e.defaultInputModes),icon:s.jsx(Vc,{size:14}),fullWidthValue:!0}),s.jsx($t,{label:"Output Modes",value:o(e.defaultOutputModes),icon:s.jsx(Vc,{size:14}),fullWidthValue:!0}),s.jsx($t,{label:"Skills",value:a(e.skills),icon:s.jsx(zx,{size:14}),fullWidthValue:!0}),s.jsx($t,{label:"Tools Info",value:i(e.tools),icon:s.jsx(Pu,{size:14}),fullWidthValue:!0}),s.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:s.jsx($t,{label:"A2A Protocol",value:e.protocolVersion})})]}),s.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for summary"})]})]})})},gl=({agents:e})=>{const[t,n]=d.useState(null),[r,o]=d.useState(""),a=l=>{n(c=>c===l?null:l)},i=e.filter(l=>{var c;return(c=l.displayName||l.name)==null?void 0:c.toLowerCase().includes(r.toLowerCase())});return s.jsx(s.Fragment,{children:e.length===0?s.jsx(rs,{variant:"noImage",title:"No agents found",subtitle:"No agents discovered in the current namespace."}):s.jsxs("div",{className:"h-full w-full pt-12 pl-12",children:[s.jsx("input",{type:"text","data-testid":"agentSearchInput",placeholder:"Search...",value:r,onChange:l=>o(l.target.value),className:"bg-background mb-4 rounded-md border px-3 py-2"}),i.length===0&&r?s.jsx(rs,{title:"No agents match your search",variant:"noImage",buttons:[{text:"Clear Search",variant:"default",onClick:()=>o("")}]}):s.jsx("div",{className:"max-h-[calc(100vh-250px)] overflow-y-auto",children:s.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>s.jsx(XA,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>a(l.name)},l.name))})})]})})},ZA=({currentLayout:e,onLayoutChange:t,className:n=""})=>{const r=hx.getPluginsByType(mx.LAYOUT);return r&&r.length>1?s.jsxs("div",{className:`flex items-center space-x-1 ${n}`,children:[s.jsx("span",{className:"text-sm font-semibold",children:"Layout:"}),s.jsx("div",{className:"flex gap-1 rounded-sm p-1",children:r.map(o=>{const a=o.icon,i=e===o.id;return s.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>t(o.id),title:o.label,className:i?"bg-[var(--color-secondary-w20)] dark:bg-[var(--color-secondary-w80)]":"",children:[a&&s.jsx(a,{size:14}),s.jsx("span",{children:o.label})]},o.id)})})]}):null};class JA{constructor(){Fc(this,"_plugins",{});this.registerDefaultPlugins()}get plugins(){return Object.values(this._plugins)}registerPlugin(t){this._plugins[t.id]&&console.warn(`Plugin with ID ${t.id} already exists. Overwriting.`),this._plugins[t.id]=t}getPluginById(t){return this._plugins[t]}getPluginsByType(t){return Object.values(this._plugins).filter(n=>n.type===t)}registerDefaultPlugins(){this.registerPlugin({type:mx.LAYOUT,id:"cards",label:"Cards",icon:Ux,priority:100,render:t=>s.jsx(gl,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}const hx=new JA,bu={CARDS:"cards"},QA=({message:e})=>{const{handleCancel:t,setMessages:n,isResponding:r,isCancelling:o}=qe();if(e.authenticationLink){const a=e.authenticationLink.authenticationAttempted||!1,i=e.authenticationLink.rejected||!1,l=()=>{if(a||i)return;n(f=>f.map(m=>{var h,x;return((h=m.metadata)==null?void 0:h.messageId)===((x=e.metadata)==null?void 0:x.messageId)&&m.authenticationLink?{...m,authenticationLink:{...m.authenticationLink,authenticationAttempted:!0}}:m}));const p=window.open(e.authenticationLink.url,"_blank","width=800,height=700,scrollbars=yes,resizable=yes");p&&p.focus()},c=async()=>{a||i||(n(p=>p.map(f=>{var m,h;return((m=f.metadata)==null?void 0:m.messageId)===((h=e.metadata)==null?void 0:h.messageId)&&f.authenticationLink?{...f,authenticationLink:{...f.authenticationLink,rejected:!0}}:f})),t())},u=e.authenticationLink.targetAgent||"Agent";return s.jsxs("div",{className:"w-max rounded-lg border p-4",children:[s.jsx("div",{className:"font-semibold",children:"Action Needed"}),s.jsxs("div",{className:"py-4",children:['The "',u,'" agent requires authentication.']}),s.jsxs("div",{className:"flex flex-row flex-wrap justify-end gap-2",children:[s.jsx(te,{variant:"ghost",onClick:c,disabled:a||i||!r||o,children:"Reject"}),s.jsx(te,{onClick:l,disabled:a||i||!r||o,children:e.authenticationLink.text})]}),s.jsxs("div",{className:"text-muted-foreground text-center text-xs",children:[i&&s.jsx("div",{className:"mt-4",children:"Authentication request rejected."}),a&&s.jsx("div",{className:"mt-4",children:"Authentication window has been opened. Complete the process in the new window."})]})]})}return null},eT=["image","audio"],yu=({message:e,showWorkflowButton:t,showFeedbackActions:n,handleViewWorkflowClick:r})=>{var b;const{configCollectFeedback:o,submittedFeedback:a,handleFeedbackSubmit:i,addNotification:l}=qe(),[c,u]=d.useState(!1),[p,f]=d.useState(null),m=e.taskId,h=m?(b=a[m])==null?void 0:b.type:void 0,x=y=>{f(y),u(!0)},g=()=>{u(!1),f(null)},w=async y=>{if(!(!p||!m))try{await i(m,p,y),l("Feedback submitted successfully","success")}catch(E){throw l("Failed to submit feedback. Please try again.","error"),E}},v=n&&o;return!t&&!v?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 space-y-2",children:s.jsxs("div",{className:"flex items-center justify-start gap-2",children:[t&&s.jsx(up,{onClick:r}),v&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(te,{variant:"ghost",size:"icon",className:`h-6 w-6 ${h?"!opacity-100":""}`,onClick:()=>x("up"),disabled:!!h,children:s.jsx(Bx,{className:`h-4 w-4 ${h==="up"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] !opacity-100":""}`})}),s.jsx(te,{variant:"ghost",size:"icon",className:`h-6 w-6 ${h?"!opacity-100":""}`,onClick:()=>x("down"),disabled:!!h,children:s.jsx(Hx,{className:`h-4 w-4 ${h==="down"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] opacity-100":""}`})})]})]})}),p&&s.jsx(HA,{isOpen:c,onClose:g,feedbackType:p,onSubmit:w})]})},tT=jt.memo(({message:e})=>{var u;const[t,n]=d.useState(null),{sessionId:r}=qe(),o=((u=e.parts)==null?void 0:u.filter(p=>p.kind==="text").map(p=>p.text).join(""))||"",a=e.isUser?o.trim():o;if(e.isError)return s.jsxs("div",{className:"flex items-center",children:[s.jsx(cs,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),s.jsx(lo,{children:a})]});const i=qA(a);if(i.length===0)return s.jsx(lo,{children:a});let l=a;const c=[];return i.forEach((p,f)=>{if(l=l.replace(p.originalMatch,""),p.type==="file"){const m={name:p.filename||"downloaded_file",content:p.content,mime_type:p.mimeType};c.push(s.jsx("div",{className:"my-2",children:s.jsx(px,{filename:m.name,mimeType:m.mime_type,onDownload:()=>gf(m,r),isEmbedded:!0})},`embedded-file-${f}`))}else if(!eT.includes(p.type)){const m=fm(p.content);m&&c.push(s.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:s.jsx(Mc,{content:m,rendererType:p.type,mime_type:p.mimeType,setRenderError:n})},`embedded-${f}`))}}),s.jsxs("div",{children:[t&&s.jsx(Yo,{variant:"error",message:"Error rendering preview"}),s.jsx(lo,{children:l}),c]})}),nT=jt.memo(({message:e,children:t,className:n})=>s.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t})),rT=e=>e.uploadedFiles&&e.uploadedFiles.length>0?s.jsx(nT,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return s.jsx(px,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,oT=(e,t,n)=>{var g,w,v;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;if(e.authenticationLink)return s.jsx(QA,{message:e});const a=[];let i="";if((g=e.parts)==null||g.forEach(b=>{b.kind==="text"?i+=b.text:(b.kind==="file"||b.kind==="artifact")&&(i&&(a.push({kind:"text",text:i}),i=""),a.push(b))}),i&&a.push({kind:"text",text:i}),!a.some(b=>b.kind==="text"&&b.text.trim()||b.kind==="file"||b.kind==="artifact"))return null;const c=e.isUser?"sent":"received",u=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,p=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,f=()=>{e.taskId&&(o(e.taskId),r("workflow"))},m=(b,y)=>{var T;const E=e.taskId?`${e.taskId}-${b.kind==="file"?b.file.name:b.name}`:(T=e.metadata)!=null&&T.messageId?`${e.metadata.messageId}-${b.kind==="file"?b.file.name:b.name}`:void 0;if(b.kind==="file"){const S=b.file,N={name:S.name||"untitled_file",mime_type:S.mimeType};return"bytes"in S&&S.bytes?N.content=S.bytes:"uri"in S&&S.uri&&(N.uri=S.uri),s.jsx(Vo,{status:"completed",name:N.name,fileAttachment:N,uniqueKey:E},`part-file-${y}`)}if(b.kind==="artifact"){const C=b;switch(C.status){case"completed":return s.jsx(Vo,{status:"completed",name:C.name,fileAttachment:C.file,uniqueKey:E},`part-artifact-${y}`);case"in-progress":return s.jsx(Vo,{status:"in-progress",name:C.name,bytesTransferred:C.bytesTransferred,uniqueKey:E},`part-artifact-${y}`);case"failed":return s.jsx(Vo,{status:"failed",name:C.name,error:C.error,uniqueKey:E},`part-artifact-${y}`);default:return null}}return null},h=a.length-1,x=(w=a[h])==null?void 0:w.kind;return s.jsxs("div",{className:"space-y-2",children:[a.map((b,y)=>{const E=y===h;return b.kind==="text"?s.jsx(pg,{variant:c,children:s.jsxs(mg,{variant:c,children:[s.jsx(tT,{message:{...e,parts:[{kind:"text",text:b.text}]}}),E&&s.jsx(yu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!p,handleViewWorkflowClick:f})]})},`part-${y}`):b.kind==="artifact"||b.kind==="file"?m(b,y):null}),x==="artifact"||x==="file"?s.jsx("div",{className:`flex ${e.isUser?"justify-end pr-4":"justify-start pl-4"}`,children:s.jsx(yu,{message:e,showWorkflowButton:!!u,showFeedbackActions:!!p,handleViewWorkflowClick:f})}):null]},(v=e.metadata)==null?void 0:v.messageId)},sT=({message:e,isLastWithTaskId:t})=>{const n=qe();return e?s.jsxs(s.Fragment,{children:[oT(e,n,t),rT(e)]}):null};var xl=new Map,Gs=new WeakMap,Cu=0,aT=void 0;function iT(e){return e?(Gs.has(e)||(Cu+=1,Gs.set(e,Cu.toString())),Gs.get(e)):"0"}function lT(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?iT(e.root):e[t]}`).toString()}function cT(e){const t=lT(e);let n=xl.get(t);if(!n){const r=new Map;let o;const a=new IntersectionObserver(i=>{i.forEach(l=>{var c;const u=l.isIntersecting&&o.some(p=>l.intersectionRatio>=p);e.trackVisibility&&typeof l.isVisible>"u"&&(l.isVisible=u),(c=r.get(l.target))==null||c.forEach(p=>{p(u,l)})})},e);o=a.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:a,elements:r},xl.set(t,n)}return n}function dT(e,t,n={},r=aT){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const c=e.getBoundingClientRect();return t(r,{isIntersecting:r,target:e,intersectionRatio:typeof n.threshold=="number"?n.threshold:0,time:0,boundingClientRect:c,intersectionRect:c,rootBounds:c}),()=>{}}const{id:o,observer:a,elements:i}=cT(n),l=i.get(e)||[];return i.has(e)||i.set(e,l),l.push(t),a.observe(e),function(){l.splice(l.indexOf(t),1),l.length===0&&(i.delete(e),a.unobserve(e)),i.size===0&&(a.disconnect(),xl.delete(o))}}function uT({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:o,triggerOnce:a,skip:i,initialInView:l,fallbackInView:c,onChange:u}={}){var p;const[f,m]=d.useState(null),h=d.useRef(u),[x,g]=d.useState({inView:!!l,entry:void 0});h.current=u,d.useEffect(()=>{if(i||!f)return;let y;return y=dT(f,(E,T)=>{g({inView:E,entry:T}),h.current&&h.current(E,T),T.isIntersecting&&a&&y&&(y(),y=void 0)},{root:o,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{y&&y()}},[Array.isArray(e)?e.toString():e,f,o,r,a,i,n,c,t]);const w=(p=x.entry)==null?void 0:p.target,v=d.useRef(void 0);!f&&w&&!a&&!i&&v.current!==w&&(v.current=w,g({inView:!!l,entry:void 0}));const b=[m,x.inView,x.entry];return b.ref=b[0],b.inView=b[1],b.entry=b[2],b}const fT=({isOpen:e,onClose:t,onConfirm:n,session:r,projects:o,currentProjectId:a})=>{const[i,l]=d.useState(null),[c,u]=d.useState(!1);if(d.useEffect(()=>{e&&l("")},[e]),!e||!r)return null;const p=async()=>{u(!0);try{await n(i),t()}catch(v){console.error("Failed to move session:",v)}finally{u(!1)}},f=o.filter(v=>v.id!==a),m=()=>a?`Move "${r.name||"Untitled Session"}" to a different project or remove it from the current project.`:`Move "${r.name||"Untitled Session"}" to a project.`,h=()=>a?"No Project (Remove from current)":"No Project",x=()=>a?"Select a project":"Select a project to move to",g=c||i===""||i===null&&!a,w=()=>{c||t()};return s.jsx(Yn,{open:e,onOpenChange:v=>!v&&w(),children:s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Move Chat Session"}),s.jsx(Zn,{children:m()})]}),s.jsx("div",{className:"py-4",children:s.jsxs(bs,{value:i===null?"none":i||"",onValueChange:v=>l(v==="none"?null:v),children:[s.jsx(Cs,{className:"w-full rounded-md",children:s.jsx(ys,{placeholder:x()})}),s.jsxs(Ss,{children:[a&&s.jsx(Cr,{value:"none",children:h()}),f.map(v=>s.jsx(Cr,{value:v.id,children:v.name},v.id))]})]})}),s.jsxs(jr,{children:[s.jsx(te,{variant:"ghost",onClick:w,disabled:c,children:"Cancel"}),s.jsx(te,{onClick:p,disabled:g,children:c?"Moving...":"Move"})]})]})})},pT=({onSessionSelect:e,projectId:t})=>{const{configServerUrl:n}=_t(),[r,o]=d.useState(""),[a,i]=d.useState([]),[l,c]=d.useState(!1),[u,p]=d.useState(!1),f=GC(r,300),m=`${n}/api/v1`,h=d.useCallback(async(v,b)=>{if(!v.trim()){i([]),p(!1);return}c(!0);try{const y=new URLSearchParams({query:v.trim(),pageNumber:"1",pageSize:"20"});b&&y.append("projectId",b);const E=await Ne(`${m}/sessions/search?${y.toString()}`,{credentials:"include"});if(!E.ok)throw new Error("Search failed");const T=await E.json();i(T.data||[]),p(!0)}catch(y){console.error("Search error:",y),i([])}finally{c(!1)}},[m]);d.useEffect(()=>{h(f,t)},[f,t,h]);const x=()=>{o(""),i([]),p(!1)},g=v=>{e(v),x()},w=t?"Search within selected project":"Search within chats";return s.jsxs("div",{className:"relative w-full",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Wx,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx(ec,{type:"text",placeholder:w,value:r,onChange:v=>o(v.target.value),className:"pl-9 pr-9"}),r&&s.jsx(te,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2 p-0",onClick:x,children:s.jsx(Er,{className:"h-4 w-4"})})]}),u&&s.jsx("div",{className:"absolute z-50 mt-2 w-full rounded-md border bg-popover p-2 shadow-md",children:l?s.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Searching..."}):a.length>0?s.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:a.map(v=>s.jsxs("button",{onClick:()=>g(v.id),className:"w-full rounded-sm px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[s.jsx("div",{className:"font-medium truncate flex-1",children:v.name||"Untitled Session"}),v.projectName&&s.jsx(jo,{variant:"outline",className:"text-xs bg-primary/10 border-primary/30 text-primary font-semibold px-2 py-0.5 shadow-sm flex-shrink-0",children:v.projectName})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(v.updatedTime).toLocaleDateString()})]},v.id))}):s.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No results found"})})]})},mT=({projects:e=[]})=>{const{sessionId:t,handleSwitchSession:n,updateSessionName:r,openSessionDeleteModal:o,addNotification:a}=qe(),{configServerUrl:i,persistenceEnabled:l}=_t(),c=d.useRef(null),[u,p]=d.useState([]),[f,m]=d.useState(null),[h,x]=d.useState(""),[g,w]=d.useState(1),[v,b]=d.useState(!0),[y,E]=d.useState(!1),[T,C]=d.useState("all"),[S,N]=d.useState(!1),[k,M]=d.useState(null),{ref:L,inView:O}=uT({threshold:0,triggerOnce:!1}),V=d.useCallback(async(P=1,_=!1)=>{E(!0);const X=`${i}/api/v1/sessions?pageNumber=${P}&pageSize=20`;try{const Q=await Ne(X);if(Q.ok){const oe=await Q.json();p(_?re=>[...re,...oe.data]:oe.data),b(oe.meta.pagination.nextPage!==null),w(P)}else console.error(`Failed to fetch sessions: ${Q.status} ${Q.statusText}`)}catch(Q){console.error("An error occurred while fetching sessions:",Q)}finally{E(!1)}},[i]);d.useEffect(()=>{V(1,!1);const P=()=>{V(1,!1)},_=H=>{const{sessionId:X}=H.detail;p(Q=>{const oe=Q.find(re=>re.id===X);if(oe){const re=Q.filter(de=>de.id!==X);return[oe,...re]}return Q})};return window.addEventListener("new-chat-session",P),window.addEventListener("session-updated",_),()=>{window.removeEventListener("new-chat-session",P),window.removeEventListener("session-updated",_)}},[V]),d.useEffect(()=>{O&&v&&!y&&V(g+1,!0)},[O,v,y,g,V]),d.useEffect(()=>{f&&c.current&&c.current.focus()},[f]);const K=async P=>{f!==P&&await n(P)},G=P=>{m(P.id),x(P.name||"")},R=async()=>{if(f){const P=f,_=h;p(H=>H.map(X=>X.id===P?{...X,name:_}:X)),m(null),await r(P,_)}},q=P=>{o(P)},j=P=>{M(P),N(!0)},I=P=>{P.projectId&&typeof window<"u"&&window.dispatchEvent(new CustomEvent("navigate-to-project",{detail:{projectId:P.projectId}}))},D=async P=>{if(k)try{if(!(await Ne(`${i}/api/v1/sessions/${k.id}/project`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:P}),credentials:"include"})).ok)throw new Error("Failed to move session");p(H=>H.map(X=>{var Q;return X.id===k.id?{...X,projectId:P,projectName:P&&((Q=e.find(oe=>oe.id===P))==null?void 0:Q.name)||null}:X})),typeof window<"u"&&window.dispatchEvent(new CustomEvent("session-moved",{detail:{sessionId:k.id,projectId:P}})),a==null||a("Session moved successfully","success"),N(!1),M(null)}catch(_){console.error("Failed to move session:",_),a==null||a("Failed to move session","error")}},z=P=>xf(P),J=P=>{if(P.name&&P.name.trim())return P.name;const _=P.id;return _.startsWith("web-session-")?`Chat ${_.replace("web-session-","").substring(0,8)}`:`Session ${_.substring(0,8)}`},U=d.useMemo(()=>{const P=new Map;return u.forEach(_=>{if(_.projectName&&_.updatedTime)try{const H=new Date(_.updatedTime).getTime();if(!isNaN(H)){const X=P.get(_.projectName);(!X||H>X)&&P.set(_.projectName,H)}}catch(H){console.warn(`Failed to parse updatedTime for session ${_.id}:`,H)}}),Array.from(P.entries()).sort((_,H)=>{const X=H[1]-_[1];return X!==0?X:_[0].localeCompare(H[0])}).map(([_])=>_)},[u]),F=d.useMemo(()=>T==="all"?u:u.filter(P=>P.projectName===T),[u,T]),W=d.useMemo(()=>{if(T==="all")return null;const P=e.find(_=>_.name===T);return(P==null?void 0:P.id)||null},[T,e]);return s.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"pr-4",children:s.jsx(pT,{onSessionSelect:n,projectId:W})}),s.jsx("div",{className:"text-lg",children:"Chat Session History"}),l&&U.length>0&&s.jsxs("div",{className:"flex items-center gap-2 pr-4",children:[s.jsx("label",{className:"text-sm font-medium",children:"Project:"}),s.jsxs(bs,{value:T,onValueChange:C,children:[s.jsx(Cs,{className:"w-[200px] rounded-md",children:s.jsx(ys,{})}),s.jsxs(Ss,{children:[s.jsx(Cr,{value:"all",children:"All Chats"}),U.map(P=>s.jsx(Cr,{value:P,children:P},P))]})]})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[F.length>0&&s.jsx("ul",{children:F.map(P=>s.jsx("li",{className:"group my-2 pr-4",children:s.jsxs("div",{className:`flex items-center gap-2 rounded px-4 py-2 ${P.id===t?"bg-muted":""}`,children:[f===P.id?s.jsx("input",{ref:c,type:"text",value:h,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),R())},className:"flex-1 min-w-0 bg-transparent focus:outline-none"}):s.jsx("button",{onClick:()=>K(P.id),className:"flex-1 min-w-0 cursor-pointer text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[s.jsx("span",{className:"truncate font-semibold",title:J(P),children:J(P)}),s.jsx("span",{className:"text-muted-foreground text-xs truncate",children:z(P.updatedTime)})]}),P.projectName&&s.jsx(jo,{variant:"outline",className:"max-w-[120px] text-xs bg-primary/10 border-primary/30 text-primary font-semibold px-2 py-0.5 shadow-sm justify-start flex-shrink-0",children:s.jsx("span",{className:"truncate block",children:P.projectName})})]})}),s.jsx("div",{className:"flex items-center flex-shrink-0",children:f===P.id?s.jsxs(s.Fragment,{children:[s.jsx(te,{variant:"ghost",size:"sm",onClick:R,className:"h-8 w-8 p-0",children:s.jsx(El,{size:16})}),s.jsx(te,{variant:"ghost",size:"sm",onClick:()=>m(null),className:"h-8 w-8 p-0",children:s.jsx(Er,{size:16})})]}):s.jsxs(Z2,{children:[s.jsx(J2,{asChild:!0,children:s.jsx(te,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:_=>_.stopPropagation(),children:s.jsx(Lu,{size:16})})}),s.jsxs(Q2,{align:"end",className:"w-48",children:[P.projectId&&s.jsxs(s.Fragment,{children:[s.jsxs($s,{onClick:_=>{_.stopPropagation(),I(P)},children:[s.jsx(Vx,{size:16,className:"mr-2"}),"Go to Project"]}),s.jsx(Gd,{})]}),s.jsxs($s,{onClick:_=>{_.stopPropagation(),G(P)},children:[s.jsx(ds,{size:16,className:"mr-2"}),"Rename"]}),s.jsxs($s,{onClick:_=>{_.stopPropagation(),j(P)},children:[s.jsx(Gx,{size:16,className:"mr-2"}),"Move to Project"]}),s.jsx(Gd,{}),s.jsxs($s,{onClick:_=>{_.stopPropagation(),q(P)},children:[s.jsx(Ou,{size:16,className:"mr-2"}),"Delete"]})]})]})})]})},P.id))}),F.length===0&&u.length>0&&!y&&s.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[s.jsx(ra,{className:"mx-auto mb-4 h-12 w-12"}),"No sessions found for this project"]}),u.length===0&&!y&&s.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[s.jsx(ra,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),v&&s.jsx("div",{ref:L,className:"flex justify-center py-4",children:y&&s.jsx(Wn,{size:"small",variant:"muted"})})]}),s.jsx(fT,{isOpen:S,onClose:()=>{N(!1),M(null)},onConfirm:D,session:k,projects:e,currentProjectId:k==null?void 0:k.projectId})]})},hT=()=>{const{persistenceEnabled:e}=_t(),{sessionName:t}=qe(),{projects:n}=Jn();return e?s.jsx(mT,{projects:n}):s.jsx("div",{className:"flex h-full flex-col",children:s.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[s.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[s.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t||"New Chat"}),s.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),s.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Persistence is not enabled."})]})})},gT=({artifact:e,isPreview:t})=>{const{setPreviewArtifact:n}=qe(),r={name:e.filename,mime_type:e.mime_type,size:e.size,uri:e.uri},o=a=>{t||(a.stopPropagation(),n(e))};return s.jsx("div",{className:`${t?"":"cursor-pointer transition-all duration-150 hover:bg-[var(--accent-background)]"}`,onClick:o,children:s.jsx(Vo,{status:"completed",name:e.filename,fileAttachment:r,context:"list"})})},xT=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=qe();return!e||!t?null:s.jsx(Yn,{open:e,onOpenChange:n,children:s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsxs(Xn,{className:"flex max-w-[400px] flex-row gap-1",children:["Delete",s.jsx("span",{className:"inline-block truncate",title:t.filename,children:s.jsx("code",{children:t.filename})}),"?"]}),s.jsx(Zn,{className:"flex flex-col gap-2",children:s.jsx("div",{children:t.source==="project"?"This will remove the file from this chat session. The file will remain in the project.":"This file will be permanently deleted."})})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(te,{variant:"ghost",onClick:n,children:"Cancel"}),s.jsx(te,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},vT=({artifact:e,message:t})=>{const{onDownload:n}=dc();return s.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[s.jsx("div",{className:"mb-1 font-semibold",children:"Preview Coming Soon"}),s.jsx("div",{children:t}),s.jsx("div",{className:"mb-4",children:"Download file to view."}),s.jsxs(te,{onClick:()=>n(e),children:[s.jsx(xo,{className:"h-4 w-4"}),"Download"]})]})},Pi=({children:e})=>s.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),wT=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n,markArtifactAsDisplayed:r,downloadAndResolveArtifact:o}=qe(),a=d.useMemo(()=>OC(e),[e]),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),[m,h]=d.useState(!1),x=d.useRef(!1),g=d.useRef(null),w=d.useRef(!1);if(d.useEffect(()=>(r(e.filename,!0),()=>{r(e.filename,!1)}),[e.filename,r]),d.useEffect(()=>{l(!1),u(null),f(null),x.current=!1,g.current=null},[e.filename]),d.useEffect(()=>{if(e.accumulatedContent){const E={name:e.filename,mime_type:e.mime_type,content:e.accumulatedContent,last_modified:e.last_modified,isPlainText:e.isAccumulatedContentPlainText};f(E)}},[e.accumulatedContent,e.filename,e.mime_type,e.last_modified,e.isAccumulatedContentPlainText]),d.useEffect(()=>{async function E(){if(!(x.current&&g.current===e.filename)){x.current=!0,g.current=e.filename;try{l(!0),u(null),e.accumulatedContent?l(!1):await t(e.filename)}catch(T){console.error("Error fetching artifact content:",T),u(T instanceof Error?T.message:"Failed to load artifact content")}finally{l(!1)}}}a!=null&&a.canPreview&&E()},[e.filename,t,a,e.accumulatedContent]),d.useEffect(()=>{async function E(){if(e.needsEmbedResolution&&!m&&!w.current){w.current=!0,h(!0);try{const T=await o(e.filename);T&&f({...T,isPlainText:!1})}catch(T){console.error(`[ArtifactPreviewContent] Error downloading ${e.filename}:`,T)}finally{h(!1),w.current=!1}}}E()},[e.needsEmbedResolution,e.filename,o,m]),c)return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(Yo,{variant:"error",message:"Error rendering preview"}),s.jsx(Pi,{children:"No preview available"})]});if(i)return s.jsx(Pi,{children:s.jsx(Ca,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!a.canPreview)return s.jsx(vT,{artifact:e,message:a.reason??""});const v=p||n,b=kn(e.filename,e.mime_type),y=mm(v);return!b||!y?s.jsx(Pi,{children:"No preview available"}):s.jsxs("div",{className:"relative h-full w-full",children:[s.jsx(Mc,{content:y,rendererType:b,mime_type:v==null?void 0:v.mime_type,setRenderError:u}),s.jsx(fx,{isVisible:m,message:"Resolving embeds..."})]})},$n={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},bT=e=>{switch(e){case $n.NameAsc:return"Name (A-Z)";case $n.NameDesc:return"Name (Z-A)";case $n.DateAsc:return"Date (oldest first)";case $n.DateDesc:return"Date (newest first)"}},yT=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values($n).map(o=>({id:o,label:bT(o),onClick:()=>t(o),icon:e===o?s.jsx(El,{}):void 0,iconPosition:"right"}));return s.jsxs(Tm,{children:[s.jsx(_m,{asChild:!0,children:n}),s.jsx(Im,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:s.jsx(pc,{actions:r})})]})},CT=({children:e,hideDeleteAll:t=!1})=>{const{artifactsRefetch:n,setIsBatchDeleteModalOpen:r}=qe(),o=[{id:"refreshAll",label:"Refresh",onClick:()=>{n()},icon:s.jsx(jl,{}),iconPosition:"left"}];return t||o.push({id:"deleteAll",label:"Delete All",onClick:()=>{r(!0)},icon:s.jsx(Ea,{}),iconPosition:"left",divider:!0}),s.jsxs(Tm,{children:[s.jsx(_m,{asChild:!0,children:e}),s.jsx(Im,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:s.jsx(pc,{actions:o})})]})},ST=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=qe();if(d.useEffect(()=>{t&&o(new Set(e.map(u=>u.filename)))},[e,t,o]),!t)return null;const a=e.some(u=>u.source==="project"),i=e.filter(u=>u.source==="project").length,l=e.length-i,c=()=>a&&l===0?`${e.length===1?"This file":`All ${e.length} files`} will be removed from this chat session. ${e.length===1?"The file":"These files"} will remain in ${e.length===1?"the":"their"} project${e.length===1?"":"s"}.`:a&&l>0?`${l} ${l===1?"file":"files"} will be permanently deleted. ${i} project ${i===1?"file":"files"} will be removed from this chat but will remain in ${i===1?"the":"their"} project${i===1?"":"s"}.`:`${e.length===1?"One file":`All ${e.length} files`} will be permanently deleted.`;return s.jsx(Yn,{open:t,onOpenChange:n,children:s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Delete All?"}),s.jsx(Zn,{children:c()})]}),s.jsxs("div",{className:"flex justify-end space-x-2",children:[s.jsx(te,{variant:"ghost",onClick:()=>n(!1),children:"Cancel"}),s.jsx(te,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},ET=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:a,badge:i})=>{const{previewedArtifactAvailableVersions:l,currentPreviewedVersionNumber:c,navigateArtifactVersion:u}=qe(),p=d.useMemo(()=>l??[],[l]);return s.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),i&&i.badgeComponent]}),s.jsx("div",{className:"truncate text-xs",title:qo(e.last_modified),children:qo(e.last_modified)})]}),t&&p.length>1&&s.jsx("div",{className:"align-right",children:s.jsxs(bs,{value:c==null?void 0:c.toString(),onValueChange:f=>{u(e.filename,parseInt(f))},children:[s.jsx(Cs,{className:"h-[16px] py-0 text-xs shadow-none",children:s.jsx(ys,{placeholder:"Version"})}),s.jsx(Ss,{children:p.map(f=>s.jsxs(Cr,{value:f.toString(),children:["Version ",f]},f))})]})})]}),s.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[a&&s.jsx(te,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),a(!n)},tooltip:n?"Collapse Details":"Expand Details",children:s.jsx(Sa,{})}),o&&s.jsx(te,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await o(e)},tooltip:"Download",children:s.jsx(xo,{})}),r&&s.jsx(te,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r()},tooltip:"Delete",children:s.jsx(Ea,{})})]})]})},NT={[$n.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[$n.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[$n.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[$n.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},jT=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r,artifactsRefetch:o,openDeleteModal:a}=qe(),{onDownload:i}=dc(),[l,c]=d.useState($n.DateDesc),[u,p]=d.useState(!1),f=d.useMemo(()=>t?[]:e?[...e].sort(NT[l]):[],[e,t,l]),m=d.useMemo(()=>f.some(x=>x.source!=="project"),[f]),h=d.useMemo(()=>n?s.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[s.jsx(te,{variant:"ghost",onClick:()=>r(null),children:s.jsx(Yx,{})}),s.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):f.length>0&&s.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[s.jsx(yT,{currentSortOption:l,onSortChange:c,children:s.jsxs(te,{variant:"ghost",title:"Sort By",children:[s.jsx(_u,{className:"h-5 w-5"}),s.jsx("div",{children:"Sort By"})]})},"sort-popover"),s.jsx(CT,{hideDeleteAll:!m,children:s.jsx(te,{variant:"ghost",tooltip:"More",children:s.jsx(Lu,{className:"h-5 w-5"})})},"more-popover")]}),[n,f.length,l,r,m]);return s.jsxs("div",{className:"flex h-full flex-col",children:[h,s.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[f.map(x=>s.jsx(gT,{artifact:x},x.filename)),f.length===0&&s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&s.jsx(Ca,{className:"size-6 animate-spin"}),!t&&s.jsxs(s.Fragment,{children:[s.jsx(or,{className:"mx-auto mb-4 h-12 w-12"}),s.jsx("div",{className:"text-lg font-medium",children:"Files"}),s.jsx("div",{className:"mt-2 text-sm",children:"No files available"}),s.jsx(te,{className:"mt-4",variant:"default",onClick:o,"data-testid":"refreshFiles",title:"Refresh Files",children:"Refresh"})]})]})})]}),n&&s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{className:"border-b px-4 py-3",children:s.jsx(ET,{artifactInfo:n,isPreview:!0,isExpanded:u,setIsExpanded:p,onDelete:n.source==="project"?void 0:()=>a(n),onDownload:()=>i(n)})}),u&&s.jsx("div",{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"space-y-2 text-sm",children:[n.description&&s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Description:"}),s.jsx("div",{className:"mt-1",children:n.description})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Size:"}),s.jsx("div",{children:Ta(n.size)})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-secondary-foreground",children:"Type:"}),s.jsx("div",{children:n.mime_type||"Unknown"})]})]})]})}),s.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:s.jsx(wT,{artifact:n})})]})]}),s.jsx(xT,{}),s.jsx(ST,{})]})},kT=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:a,setPreviewArtifact:i,taskIdInSidePanel:l}=qe(),{isReconnecting:c,isTaskMonitorConnecting:u,isTaskMonitorConnected:p,monitoredTasks:f,connectTaskMonitorStream:m}=uc(),[h,x]=d.useState(null);d.useEffect(()=>{if(l&&f[l]){const y=f[l],E=l_(y.events||[],f,y);x(E)}else x(null)},[l,f]);const g=()=>c||u?{message:"Connecting to task monitor ...",showButton:!1}:p?l?h?null:{message:"No workflow data available for the selected task",showButton:!1}:{message:"No task selected to display",showButton:!1}:{message:"No connection to task monitor",showButton:!0,buttonText:"Reconnect",buttonIcon:Kx,buttonAction:m},w=()=>{const y=!t;n(y),e(y)},v=y=>{y==="files"&&i(null),a(y)},b=y=>{t&&(n(!1),e==null||e(!1)),v(y)};return t?s.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[s.jsx(te,{"data-testid":"expandPanel",variant:"ghost",size:"sm",onClick:w,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:s.jsx(Gc,{className:"size-5"})}),s.jsx("div",{className:"bg-border my-4 h-px w-8"}),s.jsx(te,{variant:"ghost",size:"sm",onClick:()=>b("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:s.jsx(or,{className:"size-5"})}),s.jsx(te,{variant:"ghost",size:"sm",onClick:()=>b("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:s.jsx(Ks,{className:"size-5"})})]}):s.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:s.jsx("div",{className:"m-1 min-h-0 flex-1",children:s.jsxs(IE,{value:o,onValueChange:y=>v(y),className:"flex h-full flex-col",children:[s.jsxs("div",{className:"flex gap-2 p-2",children:[s.jsx(te,{"data-testid":"collapsePanel",variant:"ghost",onClick:w,className:"p-1",tooltip:"Collapse Panel",children:s.jsx(Gc,{className:"size-5"})}),s.jsxs(ME,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[s.jsxs(Hd,{value:"files",title:"Files",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-l-md border border-r-0 data-[state=active]:z-10 data-[state=active]:border-r-0",children:[s.jsx(or,{className:"mr-2 h-4 w-4"}),"Files"]}),s.jsxs(Hd,{value:"workflow",title:"Workflow",className:"border-border bg-muted data-[state=active]:bg-background relative cursor-pointer rounded-none rounded-r-md border border-l-0 data-[state=active]:z-10 data-[state=active]:border-l-0",children:[s.jsx(Ks,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),s.jsxs("div",{className:"min-h-0 flex-1",children:[s.jsx(Wd,{value:"files",className:"m-0 h-full",children:s.jsx("div",{className:"h-full",children:s.jsx(jT,{})})}),s.jsx(Wd,{value:"workflow",className:"m-0 h-full",children:s.jsx("div",{className:"h-full",children:(()=>{const y=g();return!y&&h?s.jsxs("div",{className:"flex h-full flex-col",children:[s.jsx(_T,{task:h}),s.jsx(i_,{processedSteps:h.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsxs("div",{className:"text-muted-foreground text-center",children:[s.jsx(Ks,{className:"mx-auto mb-4 h-12 w-12"}),s.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),s.jsx("div",{className:"mt-2 text-sm",children:y==null?void 0:y.message}),(y==null?void 0:y.showButton)&&s.jsx("div",{className:"mt-4",children:s.jsxs(te,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return s.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},vl=jt.memo(({statusText:e,onViewWorkflow:t})=>s.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?s.jsx(up,{onClick:t}):s.jsx(rN,{className:"mr-3 ml-2"}),s.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&s.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]})),Su=({text:e,onClick:t})=>s.jsxs(te,{"data-testid":"startNewChat",variant:"ghost",onClick:t,tooltip:"Start New Chat Session",children:[s.jsx(qx,{className:"size-5"}),e]}),gx=({buttonText:e})=>{const{handleNewSession:t}=qe(),{persistenceEnabled:n}=_t();return n?s.jsx(Su,{text:e,onClick:()=>t()}):s.jsxs(Yn,{children:[s.jsx(L1,{asChild:!0,children:s.jsx(Su,{text:e})}),s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsx(Xn,{className:"flex max-w-[400px] flex-row gap-1",children:"New Chat Session?"}),s.jsx(Zn,{className:"flex flex-col gap-2",children:"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?"})]}),s.jsxs(jr,{children:[s.jsx(_d,{asChild:!0,children:s.jsx(te,{variant:"ghost",children:"Cancel"})}),s.jsx(_d,{asChild:!0,children:s.jsx(te,{variant:"default",onClick:()=>t(),children:"Start New Chat"})})]})]})]})},AT=({onToggle:e})=>s.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 pt-[35px] pb-3",children:[s.jsx(te,{variant:"ghost",onClick:e,className:"p-2","data-testid":"hideChatSessions",tooltip:"Hide Chat Sessions",children:s.jsx(Fu,{className:"size-5"})}),s.jsx(gx,{buttonText:"New Chat"})]}),s.jsx("div",{className:"mt-1 min-h-0 flex-1",children:s.jsx(hT,{})})]}),Fo=(e,t)=>s.jsx(jo,{type:t,className:"rounded-full border-none",children:s.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),TT=(e,t)=>{var r;if(e.currentStatusText)return s.jsx("div",{title:e.currentStatusText,children:s.jsx(vl,{statusText:e.currentStatusText})});const n=(r=t==null?void 0:t.parts)==null?void 0:r.filter(o=>o.kind==="text").map(o=>o.text).join("");switch(e.status){case"submitted":case"working":return s.jsx("div",{title:n||e.status,children:s.jsx(vl,{statusText:n||e.status})});case"input-required":return Fo("Input Required","info");case"completed":return Fo("Completed","success");case"canceled":return Fo("Canceled","info");case"failed":return Fo("Failed","error");default:return Fo("Unknown","info")}},_T=({task:e})=>{const{messages:t,addNotification:n}=qe(),{configServerUrl:r,configFeatureEnablement:o}=_t(),a=d.useMemo(()=>`${r}/api/v1`,[r]),i=(o==null?void 0:o.taskLogging)??!1,l=d.useMemo(()=>{const u=t.find(p=>p.isStatusBubble);return e?TT(e,u):null},[t,e]),c=async()=>{if(!e.taskId){n("Task ID is missing, cannot download.","error");return}try{const u=await Ne(`${a}/tasks/${e.taskId}`);if(!u.ok){const h=await u.json().catch(()=>({detail:`Failed to download: ${u.statusText}`}));throw new Error(h.detail||`HTTP error ${u.status}`)}const p=await u.blob(),f=window.URL.createObjectURL(p),m=document.createElement("a");m.href=f,m.download=`${e.taskId}.stim`,document.body.appendChild(m),m.click(),m.remove(),window.URL.revokeObjectURL(f),n("Task log download started.","success")}catch(u){console.error("Failed to download .stim file:",u),n(`Failed to download task log: ${u instanceof Error?u.message:"Unknown error"}`,"error")}};return e?s.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto] grid-rows-[32px_32px] items-center gap-x-8 border-b p-4",children:[s.jsx("div",{className:"text-muted-foreground",children:"User"}),s.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),s.jsx("div",{}),s.jsx("div",{className:"text-muted-foreground",children:"Status"}),s.jsx("div",{className:"truncate",children:l}),s.jsx("div",{children:i&&s.jsx(te,{variant:"ghost",size:"icon",onClick:c,tooltip:"Download Task Log (.stim)",children:s.jsx(xo,{className:"size-4"})})})]}):null};class xx{getEdgeAnimationState(t,n,r){const o=r.find(l=>l.id===t);if(!o)return{isAnimated:!1,animationType:"static"};if(!this.isAgentToToolRequest(o))return{isAnimated:!1,animationType:"static"};const a=r.slice(0,n+1);return this.hasMatchingResponse(o,a)?{isAnimated:!1,animationType:"static"}:{isAnimated:!0,animationType:"request"}}isAgentToToolRequest(t){var n,r;switch(t.type){case"AGENT_LLM_CALL":return!0;case"AGENT_TOOL_INVOCATION_START":return!(((n=t.data.toolDecision)==null?void 0:n.isPeerDelegation)||((r=t.data.toolInvocationStart)==null?void 0:r.isPeerInvocation)||t.target&&t.target.startsWith("peer_"));default:return!1}}hasMatchingResponse(t,n){switch(t.type){case"AGENT_LLM_CALL":return this.hasLLMResponse(t,n);case"AGENT_TOOL_INVOCATION_START":return this.hasToolResponse(t,n);default:return!1}}hasLLMResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.source;return n.some(a=>{var p;if(new Date(a.timestamp).getTime()<r)return!1;const l=(a.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||a.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&a.target===o,c=a.source===o&&(a.type==="AGENT_TOOL_INVOCATION_START"||a.type==="TASK_COMPLETED"),u=a.type==="AGENT_TOOL_EXECUTION_RESULT"&&((p=a.data.toolResult)==null?void 0:p.isPeerResponse);return l||c||u})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,a=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===a)}isRequestStep(t){return this.isAgentToToolRequest(t)}isResponseStep(t){return["AGENT_TOOL_EXECUTION_RESULT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_LLM_RESPONSE_TO_AGENT"].includes(t.type)}}function vx(e,t){return(t==null?void 0:t[e])||e}const ar={USER:50,MAIN_FLOW:300,TOOLS:600},IT=50,Ct=50,xn=330,$r=50,Ln=20,mo=10,Eu=Ct+20,MT=90;function zr(e,t,n){return e.push(n),t.add(n.id),n}function RT(e,t){return e.push(t),t}function Ur(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function Wt(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function ks(e){const t=Wt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function PT(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const a=e[o],i=n.find(l=>l.id===a.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return a}return null}function DT(e,t){if(!t)return null;const n=Wt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function LT(e,t){if(!t)return null;const n=Wt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function ti(e,t){var o;const n=Wt(e);if(!n)return null;if(t.functionCallId){const a=DT(e,t.functionCallId);if(a)return a}if(t.owningTaskId&&t.isSubTaskStep){const a=LT(e,t.owningTaskId);if(a){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return a}}const r=ks(e);if(r&&t.source){const a=t.source.replace(/[^a-zA-Z0-9_]/g,"_"),i=(o=t.target)==null?void 0:o.replace(/[^a-zA-Z0-9_]/g,"_"),l=r.peerAgent.id;if(l.includes(a)||i&&l.includes(i))return r}return r||null}function wx(e,t){var r,o,a;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(a=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:a.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function bx(e,t,n,r){var o;if(r)for(let a=e.length-1;a>=0;a--){const i=e[a];if(i.functionCallId===r){const l=n.find(c=>c.id===i.id);if(((o=l==null?void 0:l.data)==null?void 0:o.toolName)===t||t==="LLM")return i}}return PT(e,t,n)}function OT(e,t,n){const r=Wt(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),a=n==null?void 0:n.replace(/[^a-zA-Z0-9_]/g,"_");let i=null;for(const l of r.subflows)if(l.peerAgent.id.includes(o)||a&&l.peerAgent.id.includes(a)){i=l;break}if(!i)return null;if(i.isParallel)return i;if(i.parentSubflowId){const l=r.subflows.find(c=>c.id===i.parentSubflowId);if(l&&l.isParallel)return l;if(l)return yx(r,l)}return null}function yx(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return yx(e,n)}return null}function ho(e,t,n,r){const o=`phase_${e.phases.length}`,a=Ur(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=vx(t,e.agentNameMap),c={id:a,type:"orchestratorNode",position:{x:ar.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};zr(r,e.allCreatedNodeIds,c),e.nodePositions.set(a,c.position);const u={id:a,yPosition:i,height:Ct,width:xn},p={id:a,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:u};e.agentRegistry.registerAgent(p);const f={id:o,orchestratorAgent:u,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+Ct};return e.phases.push(f),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=f.maxY+$r,f}function wl(e,t,n,r,o){var M,L,O,V,K;const a=Wt(e);if(!a)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((M=n.data.toolResult)==null?void 0:M.isPeerResponse)===!0,l=n.source||"",c=n.target||"",u=go(l);!i&&!u&&!o&&e.indentationLevel++;const p=((O=(L=n.delegationInfo)==null?void 0:L[0])==null?void 0:O.subTaskId)||n.owningTaskId,f=Ur(e,`${t}_${p}`),m=Ur(e,`group_${t}_${p}`),h=((K=(V=n.data)==null?void 0:V.toolInvocationStart)==null?void 0:K.functionCallId)||n.functionCallId||"";let x,g,w;const v=Array.from(e.parallelFlows.values()).find(G=>G.subflowFunctionCallIds.includes(h)),b=ks(e),y=OT(e,l,c);o&&v?(x=v.startX+v.currentXOffset,g=v.startY,w=g+Ln,v.currentXOffset+=(xn+mo)*2.2):y?(w=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||ar.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,g=w-Ln):(w=e.nextAvailableGlobalY,x=ar.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,g=w-Ln);const E=vx(t,e.agentNameMap),T={id:f,type:"genericAgentNode",position:{x:50,y:Ln},data:{label:E,visualizerStepId:n.id},parentId:m},C={id:m,type:"group",position:{x,y:g},data:{label:`${E} Sub-flow`},style:{backgroundColor:"rgba(220, 220, 255, 0.1)",border:"1px solid #aac",borderRadius:"8px",minHeight:`${Ct+2*Ln}px`}};zr(r,e.allCreatedNodeIds,C),zr(r,e.allCreatedNodeIds,T),e.nodePositions.set(f,T.position),e.nodePositions.set(m,C.position);const S={id:f,xPosition:ar.MAIN_FLOW,yPosition:w,height:Ct,width:xn},N={id:f,name:t,type:"peer",phaseId:a.id,subflowId:p,context:"subflow",nodeInstance:S};e.agentRegistry.registerAgent(N);const k={id:p,functionCallId:h,isParallel:o,peerAgent:S,groupNode:{id:m,xPosition:x,yPosition:g,height:Ct+2*Ln,width:0},toolInstances:[],currentToolYOffset:0,maxY:w+Ct,maxContentXRelative:T.position.x+xn,callingPhaseId:a.id,parentSubflowId:b==null?void 0:b.id,inheritedXOffset:y==null?void 0:y.groupNode.xPosition};return a.subflows.push(k),y&&(y.lastSubflow=k),e.currentSubflowIndex=a.subflows.length-1,o&&v?(v.maxHeight=Math.max(v.maxHeight,k.groupNode.height),e.nextAvailableGlobalY=v.startY+v.maxHeight+$r):e.nextAvailableGlobalY=k.groupNode.yPosition+k.groupNode.height+$r,k}function Cx(e,t,n,r,o,a,i=!1){const l=Wt(e);if(!l)return null;const c=a?a.toolInstances:l.toolInstances,u=i?"LLM":`Tool: ${t}`,p=i?"LLM":t,f=a?a.groupNode.id:void 0;let m,h,x,g;if(a){if(m=a.peerAgent.yPosition+a.currentToolYOffset,a.currentToolYOffset+=Eu,x=50+300,a.groupNode.xPosition===void 0||a.groupNode.yPosition===void 0)return null;h=a.groupNode.xPosition+x,g=m-a.groupNode.yPosition}else h=ar.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=Eu,x=h,g=m;const w=Ur(e,`${p}_${r.id}`),v={id:w,type:n,position:{x,y:g},data:{label:u,visualizerStepId:r.id,toolName:t},parentId:f};zr(o,e.allCreatedNodeIds,v),e.nodePositions.set(w,{x,y:g});const b={id:w,xPosition:h,yPosition:m,height:Ct,width:xn,functionCallId:r.functionCallId};c.push(b);const y=m+Ct;if(a){a.maxY=Math.max(a.maxY,y),a.maxContentXRelative=Math.max(a.maxContentXRelative,x+xn);const E=a.maxY-a.groupNode.yPosition+Ln;a.groupNode.height=Math.max(a.groupNode.height,E);const T=a.maxContentXRelative+mo;a.groupNode.width=Math.max(a.groupNode.width||0,T);const C=o.find(S=>S.id===a.groupNode.id);C&&(C.style={...C.style,height:`${a.groupNode.height}px`,width:`${a.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,a.groupNode.yPosition+a.groupNode.height+$r)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+$r);return b}function Pc(e,t,n,r){e.userNodeCounter++;const o=Ur(e,`User_response_${e.userNodeCounter}`),a=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:ar.USER,y:a},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};zr(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:a,height:Ct,width:xn};t.userNodes.push(l),e.allUserNodes.push(l);const c=a+Ct;return t.maxY=Math.max(t.maxY,c),l}function nn(e,t,n,r,o,a,i,l,c){if(!e||!t||e===t)return;const u=o.allCreatedNodeIds.has(e),p=o.allCreatedNodeIds.has(t);if(!u||!p)return;const f=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(h=>h.id===f)){const h=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=a.isRequestStep(n),g={id:f,source:e,target:t,label:h,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:x,animationType:x?"request":"static",duration:1}};l&&(g.sourceHandle=l),c&&(g.targetHandle=c),RT(r,g)}}function FT(){const e=new Map;return{agents:e,findAgentByName(t){const n=t.startsWith("peer_")?t.substring(5):t,r=[];for(const[,o]of e)(o.name===n||o.name===t)&&r.push(o);return r.length===0?null:r.reduce((o,a)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(a.id.split("_").pop()||"0")>i?a:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function bl(e,t,n){return e==="orchestrator"?t==="output"?n==="bottom"?"orch-bottom-output":"orch-right-output-tools":n==="top"?"orch-top-input":"orch-right-input-tools":t==="output"?n==="bottom"?"peer-bottom-output":"peer-right-output-tools":n==="top"?"peer-top-input":"peer-right-input-tools"}function go(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const $T=["USER_REQUEST","AGENT_LLM_CALL","AGENT_LLM_RESPONSE_TO_AGENT","AGENT_LLM_RESPONSE_TOOL_DECISION","AGENT_TOOL_INVOCATION_START","AGENT_TOOL_EXECUTION_RESULT","AGENT_RESPONSE_TEXT","TASK_COMPLETED","TASK_FAILED"];function zT(e,t,n,r,o,a){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=Wt(t),u=ks(t);let p,f=!1;if(u?(p=u.peerAgent,p.id.startsWith(l+"_")&&(f=!0)):c&&(p=c.orchestratorAgent,p.id.startsWith(l+"_")&&(f=!0)),f&&p&&c){t.userNodeCounter++;const m=Ur(t,`User_continue_${t.userNodeCounter}`),h=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:ar.USER,y:h},data:{label:"User",visualizerStepId:e.id}};zr(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const g={id:m,yPosition:h,height:Ct,width:xn};c.userNodes.push(g),t.allUserNodes.push(g);const w=h+Ct;p.yPosition=Math.max(p.yPosition,h),c.maxY=Math.max(c.maxY,w,p.yPosition+Ct),t.nextAvailableGlobalY=c.maxY+$r;const v=go(i)?"orch-left-input":"peer-left-input";nn(g.id,p.id,e,r,t,o,a,"user-right-output",v)}else{const m=ho(t,i,e,n),h=Ur(t,`User_${m.id}`),x={id:h,type:"userNode",position:{x:ar.USER,y:m.orchestratorAgent.yPosition-MT},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};zr(n,t.allCreatedNodeIds,x),t.nodePositions.set(h,x.position);const g={id:h,yPosition:x.position.y,height:Ct,width:xn};m.userNodes.push(g),t.allUserNodes.push(g),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+Ct),t.nextAvailableGlobalY=m.maxY+$r,nn(h,m.orchestratorAgent.id,e,r,t,o,a,"user-bottom-output","orch-top-input")}}function UT(e,t,n,r,o,a){const i=Wt(t);if(!i)return;const l=ti(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,u=Cx(t,"LLM","llmNode",e,n,l,!0);u&&nn(c,u.id,e,r,t,o,a,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function BT(e,t,n,r,o,a){var x;if(e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"&&((x=e.data.toolDecision)!=null&&x.isParallel)){const g=`parallel-${e.id}`;e.data.toolDecision.decisions.filter(w=>w.isPeerDelegation).length>1&&t.parallelFlows.set(g,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(w=>w.isPeerDelegation).map(w=>w.functionCallId),completedSubflows:new Set,startX:ar.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=Wt(t);if(!i)return;const l=ti(t,e);let c;const p=bx((l||i).toolInstances,"LLM",n,e.functionCallId);if(p)c=p.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const f=e.target||"UnknownAgent";let m,h;l?(m=l.peerAgent.id,h="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(f.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,h="orch-right-input-tools"),c&&m&&h?nn(c,m,e,r,t,o,a,"llm-bottom-output",h):console.error(`[Timeline] Could not determine target agent node ID or handle for step type ${e.type}: ${e.id}. Target agent name: ${f}. Edge will be missing.`)}function HT(e,t,n,r,o,a){var p;const i=Wt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((p=e.data.toolInvocationStart)==null?void 0:p.isPeerInvocation)||c.startsWith("peer_")){const f=c.startsWith("peer_")?c.substring(5):c,m=t.agentRegistry.findAgentByName(l);if(!m){console.error(`[Timeline] Could not find source agent in registry: ${l} for step ${e.id}`);return}const h=m.nodeInstance,x=bl(m.type,"output","bottom"),g=wx(e,t),w=wl(t,f,e,n,g);w&&nn(h.id,w.peerAgent.id,e,r,t,o,a,x,"peer-top-input")}else{const f=ti(t,e);let m,h;if(f)m=f.peerAgent.id,h="peer-right-output-tools";else{const g=t.agentRegistry.findAgentByName(l);g?(m=g.id,h=bl(g.type,"output","right")):(m=i.orchestratorAgent.id,h="orch-right-output-tools")}const x=Cx(t,c,"genericToolNode",e,n,f);x&&nn(m,x.id,e,r,t,o,a,h,`${x.id}-tool-left-input`)}}function WT(e,t,n,r,o,a){var u,p;const i=Wt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((u=e.data.toolResult)!=null&&u.isPeerResponse){const f=(p=e.data.toolResult)==null?void 0:p.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,g])=>g.subflowFunctionCallIds.includes(f||""));if(m){const[x,g]=m;if(g.completedSubflows.add(f||""),g.completedSubflows.size<g.subflowFunctionCallIds.length)return;const w=i.subflows.filter(E=>g.subflowFunctionCallIds.includes(E.functionCallId)),v=e.target||"OrchestratorAgent";let b,y;if(go(v))t.indentationLevel=0,b=ho(t,v,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=wl(t,v,e,n,!1);if(!E)return;b=E.peerAgent,y="peer-top-input"}w.forEach(E=>{var T;nn(((T=E.lastSubflow)==null?void 0:T.peerAgent.id)??E.peerAgent.id,b.id,e,r,t,o,a,"peer-bottom-output",y)}),t.parallelFlows.delete(x);return}const h=t.agentRegistry.findAgentByName(l.startsWith("peer_")?l.substring(5):l);if(!h){console.error(`[Timeline] Source peer agent not found for peer response: ${l}.`);return}if(go(c)){t.indentationLevel=0;const x=ho(t,c,e,n);nn(h.id,x.orchestratorAgent.id,e,r,t,o,a,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=wx(e,t)||Array.from(t.parallelFlows.values()).some(w=>w.subflowFunctionCallIds.some(v=>i.subflows.some(b=>b.functionCallId===v))),g=wl(t,c,e,n,x);g&&nn(h.id,g.peerAgent.id,e,r,t,o,a,"peer-bottom-output","peer-top-input")}}else{let f;const m=ti(t,e),x=bx((m||i).toolInstances,l,n,e.functionCallId);if(x&&(f=x.id),f){let g,w;if(m)g=m.peerAgent.id,w="peer-right-input-tools";else{const v=t.agentRegistry.findAgentByName(c);v?(g=v.id,w=bl(v.type,"input","right")):(g=i.orchestratorAgent.id,w="orch-right-input-tools")}nn(f,g,e,r,t,o,a,l==="LLM"?"llm-bottom-output":`${f}-tool-bottom-output`,w)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function VT(e,t,n,r,o,a){const i=Wt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=Pc(t,i,e,n);nn(l,c.id,e,r,t,o,a,"orch-bottom-output","user-top-input")}function GT(e,t,n,r,o,a){const i=Wt(t);if(!i)return;const l=Array.from(t.parallelFlows.values()).find(h=>h.subflowFunctionCallIds.includes(e.functionCallId||""));if(l){if(l.completedSubflows.add(e.functionCallId||""),l.completedSubflows.size===l.subflowFunctionCallIds.length){t.indentationLevel=0;const h=ho(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&nn(x.peerAgent.id,h.orchestratorAgent.id,e,r,t,o,a,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=ks(t);if(!c){console.warn(`[Timeline] TASK_COMPLETED with isSubTaskStep=true but no active subflow. Step ID: ${e.id}`);return}if(!i){console.error(`[Timeline] No current phase found for TASK_COMPLETED. Step ID: ${e.id}`);return}const u=c.peerAgent,p=n.some(h=>typeof h.data.label=="string"&&go(h.data.label));let f,m;p?(t.indentationLevel=0,f=ho(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(f=Pc(t,i,e,n).id,m="user-top-input"),nn(u.id,f,e,r,t,o,a,"peer-bottom-output",m),t.currentSubflowIndex=-1}function YT(e,t,n,r){const o=Wt(t);if(!o)return;const a=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const u=ks(t);if(u&&u.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_")))l=u.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_")))l=o.orchestratorAgent,c="orch-bottom-output";else for(const m of o.subflows)if(m.peerAgent.id.includes(a.replace(/[^a-zA-Z0-9_]/g,"_"))){l=m.peerAgent,c="peer-bottom-output";break}if(!l){console.error(`[Timeline] Could not find source agent node for TASK_FAILED: ${a}`);return}let p,f;go(i)?(t.indentationLevel=0,p=ho(t,i,e,n).orchestratorAgent.id,f="orch-top-input",t.currentSubflowIndex=-1):(p=Pc(t,o,e,n).id,f="user-top-input"),KT(l.id,p,e,r,t,c,f)}function KT(e,t,n,r,o,a,i){var f;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const u=`error-edge-${e}${a||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===u)){const m=((f=n.data.errorDetails)==null?void 0:f.message)||"Task failed",h=m.length>30?"Error":m,x={id:u,source:e,target:t,label:h,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};a&&(x.sourceHandle=a),i&&(x.targetHandle=i),r.push(x)}}const qT=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new xx,a={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:IT,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:FT(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(u=>$T.includes(u.type)),l=i.findIndex(u=>u.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const u of c)switch(u.type){case"USER_REQUEST":zT(u,a,n,r,o,e);break;case"AGENT_LLM_CALL":UT(u,a,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":BT(u,a,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":HT(u,a,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":WT(u,a,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":VT(u,a,n,r,o,e);break;case"TASK_COMPLETED":GT(u,a,n,r,o,e);break;case"TASK_FAILED":YT(u,a,n,r);break}return a.phases.forEach(u=>{u.subflows.forEach(p=>{const f=n.find(m=>m.id===p.groupNode.id);if(f&&f.style){const h=p.maxY-p.groupNode.yPosition+Ln;f.style.height=`${Math.max(Ct+2*Ln,h)}px`;const x=p.maxContentXRelative+mo,g=xn+2*mo+a.indentationLevel*a.indentationStep;f.style.width=`${Math.max(x,g)}px`}})}),{nodes:n,edges:r}},XT=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:a,targetPosition:i,style:l={},markerEnd:c,data:u})=>{const[p,f]=d.useState(!1),[m]=Xx({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:o,targetPosition:i}),h=()=>{const w={strokeWidth:p?3:2,stroke:"var(--color-muted-foreground)",...l},v=u;return v!=null&&v.isError?{...w,stroke:p?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:p?3:2}:v!=null&&v.isSelected?{...w,stroke:"#3b82f6",strokeWidth:3}:v!=null&&v.isAnimated?{...w,stroke:p?"#1d4ed8":"#3b82f6",strokeWidth:p?4:3}:p?{...w,stroke:"var(--edge-hover-color)"}:w},x=()=>f(!0),g=()=>f(!1);return s.jsxs(s.Fragment,{children:[s.jsx("path",{id:`${e}-interaction`,style:{strokeWidth:16,stroke:"transparent",fill:"none",cursor:"pointer"},className:"react-flow__edge-interaction",d:m,onMouseEnter:x,onMouseLeave:g}),s.jsx("path",{id:e,style:{...h(),cursor:"pointer",transition:"all 0.2s ease-in-out"},className:"react-flow__edge-path",d:m,markerEnd:c,onMouseEnter:x,onMouseLeave:g})]})},ZT=({data:e})=>s.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-blue-700 bg-white px-5 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-blue-600 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"180px",textAlign:"center"},children:[s.jsx(kt,{type:"target",position:At.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),s.jsx(kt,{type:"source",position:At.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),s.jsx(kt,{type:"target",position:At.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),s.jsx(kt,{type:"source",position:At.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),s.jsx(kt,{type:"target",position:At.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),s.jsx("div",{className:"flex items-center justify-center",children:s.jsx("div",{className:"text-md truncate font-semibold",style:{maxWidth:"200px"},children:e.label})})]}),JT=({data:e,id:t})=>{const n=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-cyan-500"}};return s.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-cyan-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-cyan-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[s.jsx(kt,{type:"target",position:At.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),s.jsx("div",{className:"text-md truncate",style:{maxWidth:"200px"},children:e.label})]}),s.jsx(kt,{type:"source",position:At.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},QT=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-teal-500"}};return s.jsxs("div",{className:"cursor-pointer rounded-lg border-2 border-teal-600 bg-white px-3 py-3 text-gray-800 shadow-md transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-teal-400 dark:bg-gray-800 dark:text-gray-200",style:{minWidth:"100px",textAlign:"center"},children:[s.jsx(kt,{type:"target",position:At.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),s.jsx("div",{className:"text-md",children:e.label})]}),s.jsx(kt,{type:"source",position:At.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},e_=({data:e})=>s.jsxs("div",{className:"cursor-pointer rounded-lg border-indigo-600 bg-gradient-to-r from-indigo-50 to-purple-50 px-5 py-3 text-gray-900 shadow-xl transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-2xl dark:border-indigo-400 dark:bg-gradient-to-r dark:from-indigo-900 dark:to-purple-900 dark:text-gray-100",style:{minWidth:"180px",textAlign:"center",borderWidth:"2px",borderStyle:"solid",boxShadow:"0 0 0 1px rgba(79, 70, 229, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:[s.jsx(kt,{type:"source",position:At.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),s.jsx(kt,{type:"target",position:At.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),s.jsx(kt,{type:"target",position:At.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),s.jsx(kt,{type:"source",position:At.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),s.jsx(kt,{type:"target",position:At.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),s.jsx("div",{className:"flex items-center justify-center",children:s.jsx("div",{className:"text-md truncate font-bold",style:{maxWidth:"200px"},children:e.label})})]}),t_=({data:e})=>{const t=()=>{switch(e.status){case"completed":return"bg-green-500";case"in-progress":return"bg-blue-500";case"error":return"bg-red-500";case"started":return"bg-yellow-400";case"idle":default:return"bg-purple-500"}};return s.jsxs("div",{className:"cursor-pointer rounded-md border-2 border-purple-600 bg-white px-4 py-3 text-gray-800 shadow-lg transition-all duration-200 ease-in-out hover:scale-105 hover:shadow-xl dark:border-purple-400 dark:bg-gray-700 dark:text-gray-200",style:{minWidth:"120px",textAlign:"center"},children:[e.isTopNode&&s.jsx(kt,{type:"source",position:At.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&s.jsx(kt,{type:"target",position:At.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&s.jsx(kt,{type:"source",position:At.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),s.jsxs("div",{className:"flex items-center justify-center",children:[s.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),s.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},n_=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var v,b,y;switch(e.type){case"USER_REQUEST":return s.jsx(ev,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return s.jsx(ni,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return s.jsx(Mu,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return s.jsx(Qx,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return s.jsx(ni,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return s.jsx(ni,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const E=(b=(v=e.data.toolDecision)==null?void 0:v.decisions)==null?void 0:b[0];return(E==null?void 0:E.isPeerDelegation)?s.jsx(Yc,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):s.jsx(Kc,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(y=e.data.toolInvocationStart)!=null&&y.isPeerInvocation?s.jsx(Yc,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):s.jsx(Kc,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return s.jsx(Jx,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return s.jsx(or,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return s.jsx(Zx,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},a=new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=String(new Date(e.timestamp).getMilliseconds()).padStart(3,"0"),l=`${a}.${i}`,c=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Model:"})," ",v.modelName]}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:"Prompt Preview:"})}),s.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:v.promptPreview})]}),u=({data:v})=>{const[b,y]=jt.useState(!1),E=T=>{T.stopPropagation(),y(!b)};return b?s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[s.jsx("strong",{children:"LLM Response Details:"}),s.jsx("button",{onClick:E,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),v.modelName&&s.jsxs("p",{children:[s.jsx("strong",{children:"Model:"})," ",v.modelName]}),s.jsxs("div",{className:"mt-1",children:[s.jsx("p",{children:s.jsx("strong",{children:"Response Preview:"})}),s.jsx("pre",{className:"max-h-28 overflow-y-auto rounded bg-gray-100 p-1.5 font-mono text-xs break-all whitespace-pre-wrap dark:bg-gray-700",children:v.responsePreview})]}),v.isFinalResponse!==void 0&&s.jsxs("p",{className:"mt-1",children:[s.jsx("strong",{children:"Final Response:"})," ",v.isFinalResponse?"Yes":"No"]})]}):s.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("span",{className:"italic",children:"Internal LLM response"}),s.jsx("button",{onClick:E,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},p=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-blue-50 p-2 font-mono text-xs text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:[s.jsx("p",{className:"mb-2",children:s.jsxs("strong",{children:["🔧 ",v.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),s.jsx("ul",{className:"space-y-1 pl-2",children:v.decisions.map(b=>s.jsxs("li",{className:"flex items-center",children:[s.jsx("span",{className:"mr-2",children:"•"}),s.jsx("code",{children:b.toolName})]},b.functionCallId))})]}),f=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Tool:"})," ",v.toolName]}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:"Arguments:"})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:s.jsx(Cl,{data:v.toolArguments})})]}),m=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Tool:"})," ",v.toolName]}),s.jsx("p",{className:"mt-1",children:s.jsx("strong",{children:"Result:"})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof v.resultData=="object"?s.jsx(Cl,{data:v.resultData}):s.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(v.resultData)})})]}),h=v=>s.jsxs("div",{className:"mt-1.5 rounded-md bg-gray-50 p-2 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Artifact:"})," ",v.artifactName,v.version!==void 0&&s.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",v.version,")"]})]}),v.mimeType&&s.jsxs("p",{children:[s.jsx("strong",{children:"Type:"})," ",v.mimeType]}),v.description&&s.jsxs("p",{className:"mt-1",children:[s.jsx("strong",{children:"Description:"})," ",v.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},g=r==="popover"?`
340
+ p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
341
+ ${n?"cursor-pointer":""}
342
+ `:`
343
+ mb-3 p-3 border rounded-lg shadow-sm
344
+ bg-white dark:bg-gray-800 hover:shadow-md transition-shadow duration-150
345
+ ${t?"border-blue-500 dark:border-blue-400 ring-2 ring-blue-500 dark:ring-blue-400":"border-gray-200 dark:border-gray-700"}
346
+ ${n?"cursor-pointer":""}
347
+ `,w=()=>e.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||e.type==="AGENT_TOOL_INVOCATION_START"?"Delegated to: ":e.type==="AGENT_TOOL_EXECUTION_RESULT"?"Response from: ":"Peer Interaction with: ";return s.jsxs("div",{className:g,style:x,onClick:n,children:[s.jsxs("div",{className:"mb-1.5 flex w-full items-center gap-1",children:[o(),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"flex-1 truncate text-sm font-semibold",title:e.title,children:e.title}),s.jsx("span",{className:"text-muted-foreground shrink-0 font-mono text-xs",children:l})]})]}),e.delegationInfo&&e.delegationInfo.length>0&&s.jsx("div",{className:"mt-2 mb-1.5 space-y-2 rounded-r-md border-l-4 border-blue-500 bg-blue-50 p-2 text-sm dark:border-blue-400 dark:bg-gray-700/60",children:e.delegationInfo.map(v=>s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[s.jsx(Du,{className:"mr-2 h-4 w-4 flex-shrink-0"}),s.jsxs("span",{children:[w(),v.peerAgentName]})]}),v.subTaskId&&s.jsxs("div",{className:"mt-0.5 ml-[24px] text-xs text-blue-600 dark:text-blue-400",children:["Sub-Task:"," ",s.jsxs("span",{className:"font-mono",title:v.subTaskId,children:[v.subTaskId.substring(0,15),"..."]})]})]},v.functionCallId))}),e.data.text&&s.jsx("div",{className:"max-h-20 overflow-y-auto pl-1 text-sm text-gray-800 dark:text-gray-100",children:s.jsx(lo,{children:e.data.text})}),e.data.finalMessage&&s.jsx("div",{className:"pl-1 text-sm text-gray-800 dark:text-gray-100",children:s.jsx(lo,{children:e.data.finalMessage})}),e.type==="TASK_COMPLETED"&&!e.data.finalMessage&&s.jsx("div",{className:"pl-1 text-sm text-gray-600 italic dark:text-gray-300",children:"Task completed successfully."}),e.data.errorDetails&&s.jsxs("div",{className:"mt-1 rounded-md bg-red-50 p-2 pl-1 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400",children:[s.jsxs("p",{children:[s.jsx("strong",{children:"Error:"})," ",e.data.errorDetails.message]}),e.data.errorDetails.code&&s.jsxs("p",{className:"text-xs",children:["Code: ",e.data.errorDetails.code]})]}),e.data.llmCall&&c(e.data.llmCall),e.data.llmResponseToAgent&&s.jsx(u,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&p(e.data.toolDecision),e.data.toolInvocationStart&&f(e.data.toolInvocationStart),e.data.toolResult&&m(e.data.toolResult),e.data.artifactNotification&&h(e.data.artifactNotification)]})},r_={genericAgentNode:ZT,userNode:t_,llmNode:QT,orchestratorNode:e_,genericToolNode:JT},o_={defaultFlowEdge:XT},s_={x:16,y:0},a_=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,a]=nv([]),[i,l,c]=rv([]),{fitView:u}=ov(),{highlightedStepId:p,setHighlightedStepId:f}=uc(),{taskIdInSidePanel:m}=qe(),{agentNameMap:h}=cc(),x=d.useRef([]),[g,w]=d.useState(!1),[v,b]=d.useState(null),[y,E]=d.useState(!1),T=d.useRef(null),[C,S]=d.useState(null),N=d.useRef(new xx),k=d.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:qT(e,h),[e,h]),M=d.useMemo(()=>k.edges.length?k.edges.map(j=>{const I=j.data;let D={isAnimated:!1,animationType:"none"};if(I!=null&&I.visualizerStepId){const J=e.length-1;D=N.current.getEdgeAnimationState(I.visualizerStepId,J,e)}let z=j.id===C;return p&&(I==null?void 0:I.visualizerStepId)===p&&(z=!0),{...j,animated:D.isAnimated,data:{...I,isAnimated:D.isAnimated,animationType:D.animationType,isSelected:z}}}):[],[k.edges,e,C,p]),L=d.useCallback(()=>{o(j=>j.map(I=>{var oe,re,de,ne;if(I.type!=="group")return I;const D=j.filter(ue=>ue.parentId===I.id);if(D.length===0)return I;let z=0,J=0;D.forEach(ue=>{const Oe=ue.position.x+xn,De=ue.position.y+Ct;z=Math.max(z,Oe),J=Math.max(J,De)});const U=z+mo,F=J+Ln;let W=0;const P=I.id.split("_");if(P.length>2){const ue=P.find(Oe=>Oe.startsWith("subflow"));if(ue){const Oe=parseInt(ue.replace("subflow",""));isNaN(Oe)||(W=Oe)}}const _=xn+2*mo+W*50,H=Math.max(U,_),X=parseInt(((re=(oe=I.style)==null?void 0:oe.width)==null?void 0:re.toString().replace("px",""))||"0"),Q=parseInt(((ne=(de=I.style)==null?void 0:de.height)==null?void 0:ne.toString().replace("px",""))||"0");return X!==H||Q!==F?{...I,style:{...I.style,width:`${H}px`,height:`${F}px`}}:I}))},[o]);d.useEffect(()=>{o(k.nodes),l(M),L()},[k.nodes,M,o,l,L]);const O=d.useCallback((j,I)=>i.find(D=>D.source===j&&(I?D.sourceHandle===I:!0))||null,[i]),V=d.useCallback((j,I)=>{var z;w(!0);const D=(z=I.data)==null?void 0:z.visualizerStepId;if(D){const J=e.find(U=>U.id===D);J&&(S(I.id),t?f(D):(f(D),b(J),E(!0)))}},[e,t,f]),K=d.useCallback(j=>{switch(j.type){case"userNode":{const I=j.data;return I!=null&&I.isTopNode?["user-bottom-output"]:I!=null&&I.isBottomNode?["user-top-input"]:["user-right-output"]}case"orchestratorNode":return["orch-right-output-tools","orch-bottom-output"];case"genericAgentNode":return["peer-right-output-tools","peer-bottom-output"];case"llmNode":return["llm-bottom-output"];case"genericToolNode":return[`${j.id}-tool-bottom-output`];default:return[]}},[]),G=d.useCallback(()=>{E(!1),b(null)},[]),R=d.useCallback((j,I)=>{if(w(!0),I.type==="group"){f(null),S(null),G();return}const D=K(I);let z=null;for(const J of D)if(z=O(I.id,J),z)break;if(!z&&I.type==="userNode"){const J=I.data;J!=null&&J.isBottomNode&&(z=i.find(U=>U.target===I.id)||null)}z&&V(j,z)},[K,f,G,O,i,V]),q=d.useCallback(j=>{j!=null&&j.isTrusted&&w(!0)},[]);return d.useEffect(()=>{w(!1)},[m]),d.useEffect(()=>{!n&&u&&r.length>0&&x.current!==e&&g===!1&&(u({duration:200,padding:.1,maxZoom:1.2}),x.current=e)},[r.length,u,e,n,g]),d.useEffect(()=>{if(o(j=>j.map(I=>{var U;const D=((U=I.data)==null?void 0:U.visualizerStepId)&&I.data.visualizerStepId===p,z=k.nodes.find(F=>F.id===I.id),J=(z==null?void 0:z.style)||{};return{...I,style:{...J,boxShadow:D?"0px 4px 12px rgba(0, 0, 0, 0.2)":J.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),p){const j=M.find(I=>{const D=I.data;return(D==null?void 0:D.visualizerStepId)===p});j&&S(j.id)}else S(null)},[p,o,k.nodes,M]),!e||e.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:Object.keys(e).length>0?"Processing flow data...":"No steps to display in flow chart."}):k.nodes.length===0&&e.length>0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:"Generating flow chart..."}):s.jsxs("div",{style:{height:"100%",width:"100%"},className:"relative",children:[s.jsxs(sv,{nodes:r,edges:i.map(j=>({...j,markerEnd:{type:cv.ArrowClosed,color:"#888"}})),onNodesChange:a,onEdgesChange:c,onEdgeClick:V,onNodeClick:R,onPaneClick:()=>{f(null),S(null),G()},onMoveStart:q,nodeTypes:r_,edgeTypes:o_,fitViewOptions:{padding:.1},className:"bg-gray-50 dark:bg-gray-900 [&>button]:dark:bg-gray-700",proOptions:{hideAttribution:!0},nodesDraggable:!1,elementsSelectable:!1,nodesConnectable:!1,minZoom:.2,children:[s.jsx(av,{}),s.jsx(iv,{className:Nw()}),s.jsx(lv,{position:"top-right",className:"flex items-center space-x-4",children:s.jsx("div",{ref:T})})]}),s.jsx(fS,{isOpen:y,onClose:G,anchorRef:T,offset:s_,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:v&&s.jsx(n_,{step:v,variant:"popover"})})]})},i_=e=>s.jsx(tv,{children:s.jsx(a_,{...e})}),Sx=e=>{var t,n,r,o;if(e.events&&e.events.length>0){const a=e.events[0];if((o=(r=(n=(t=a.full_payload)==null?void 0:t.params)==null?void 0:n.message)==null?void 0:r.metadata)!=null&&o.parentTaskId)return a.full_payload.params.message.metadata.parentTaskId}},$o=e=>{var t,n,r;return((r=(n=(t=e.full_payload)==null?void 0:t.result)==null?void 0:n.status)==null?void 0:r.timestamp)||e.timestamp},Ex=(e,t,n,r)=>{const o=t[e];if(!o)return console.warn(`[collectAllDescendantEvents] Task not found in allMonitoredTasks: ${e}`),[];n.set(e,r);let a=[...o.events||[]];for(const i in t){const l=t[i];if(l.taskId===e)continue;Sx(l)===e&&(a=a.concat(Ex(l.taskId,t,n,r+1)))}return a},l_=(e,t,n)=>{if(!n)return null;const r={overall:{totalTaskDurationMs:0},agents:{}},o=new Map,a=new Map,i=(R,q)=>(r.agents[R]||(r.agents[R]={agentName:q,instanceId:R,displayName:q,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),r.agents[R]),l=new Map,c=Ex(n.taskId,t,l,0);if(c.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const u=c.sort((R,q)=>new Date($o(R)).getTime()-new Date($o(q)).getTime()),p=[];let f,m="",h,x,g=[],w=null,v;const b=new Map,y=new Map,E=new Map,T=R=>{if(m.trim()&&h&&x){const q=m.trim();let j=n.taskId;if(g.length>0){const z=g[0].split("-");z.length>2&&z[1]!=="global"&&(j=z.slice(1,z.length-1).join("-"))}else R&&(j=R);const I=l.get(j)??0,D=b.get(j)||E.get(j);p.push({id:`vstep-agenttext-${p.length}-${g[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:x,title:`${h}: Response`,source:h,target:"User",data:{text:q},rawEventIds:[...g],isSubTaskStep:I>0,nestingLevel:I,owningTaskId:j,functionCallId:D}),w=q}m="",h=void 0,x=void 0,g=[],v=void 0};u.forEach((R,q)=>{var _,H,X,Q,oe,re,de,ne,ue,Oe,De,Te,Be,Et,et,wt,Lt,ut,ft,st,qt,Rn,Vt,Ot,an,Xt,ln,bt,ie,Gt,Yt,Pn,Zt,Jt,wn,Qt,cn,dn,Ge,It,Dn,bn,yn,un,Mt;const j=$o(R),I=`raw-${R.task_id||"global"}-${q}`,D=R.full_payload,z=R.task_id||n.taskId,J=l.get(z)??0;let U=R.source_entity||"UnknownAgent";(X=(H=(_=D==null?void 0:D.params)==null?void 0:_.message)==null?void 0:H.metadata)!=null&&X.agent_name?U=D.params.message.metadata.agent_name:(oe=(Q=D==null?void 0:D.result)==null?void 0:Q.metadata)!=null&&oe.agent_name?U=D.result.metadata.agent_name:(ue=(ne=(de=(re=D==null?void 0:D.result)==null?void 0:re.status)==null?void 0:de.message)==null?void 0:ne.metadata)!=null&&ue.agent_name?U=D.result.status.message.metadata.agent_name:(Te=(De=(Oe=D==null?void 0:D.result)==null?void 0:Oe.artifact)==null?void 0:De.metadata)!=null&&Te.agent_name&&(U=D.result.artifact.metadata.agent_name);let F;if(J>0?F=b.get(z):F=E.get(z),R.direction==="request"&&J>0){const ke=(Be=D.params)==null?void 0:Be.metadata,_e=ke==null?void 0:ke.function_call_id,Fe=R.task_id;if(Fe&&_e){b.set(Fe,_e);return}}if(R.direction==="request"&&J===0&&R.task_id===n.taskId){T(z),w=null;const ke=D.params;let _e="User request";if((Et=ke==null?void 0:ke.message)!=null&&Et.parts){const Fe=ke.message.parts.filter(Me=>Me.kind==="text"&&Me.text);Fe.length>0&&(_e=Fe[Fe.length-1].text)}p.push({id:`vstep-userreq-${p.length}-${I}`,type:"USER_REQUEST",timestamp:j,title:"User Input",source:"User",target:R.target_entity||U,data:{text:_e},rawEventIds:[I],isSubTaskStep:!1,nestingLevel:0,owningTaskId:z});return}if(R.direction==="status-update"&&(D!=null&&D.result)){const ke=D.result,_e=(et=ke.status)==null?void 0:et.message,Fe=_e==null?void 0:_e.metadata;let Me;const yt=!!(Fe!=null&&Fe.forwarded_from_peer);yt?Me=Fe.forwarded_from_peer:(wt=ke.metadata)!=null&&wt.agent_name?Me=ke.metadata.agent_name:Fe!=null&&Fe.agent_name?Me=Fe.agent_name:Me=R.source_entity||"Agent";const pt=`${Me}:${z}`;if(!yt&&(_e!=null&&_e.parts))for(const at of _e.parts){if(at.kind==="data"){const Re=at.data;Re.type==="agent_progress_update"?f=Re.status_text:Re.type==="artifact_creation_progress"&&(f=`Saving artifact: ${Re.filename} (${Re.bytes_saved} bytes)`)}if(at.kind==="data"){T(z);const Ke=at.data;switch(Ke==null?void 0:Ke.type){case"agent_progress_update":{p.push({id:`vstep-progress-${p.length}-${I}`,type:"AGENT_RESPONSE_TEXT",timestamp:j,title:`${Me}: Progress Update`,source:Me,target:"User",data:{text:Ke.status_text},rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F});break}case"llm_invocation":{const we=Ke.request;let ze="System-initiated LLM call";if(we!=null&&we.contents&&Array.isArray(we.contents)&&we.contents.length>0){const ae=[...we.contents].reverse().find(A=>A.role==="user");ae&&ae.parts&&(ze=ae.parts.map(A=>A.text||"").join(`
348
+ `).trim())}const tt={modelName:(we==null?void 0:we.model)||"Unknown Model",promptPreview:ze||"No text in user prompt."};i(pt,Me),o.set(pt,{timestamp:j,modelName:tt.modelName}),p.push({id:`vstep-llmcall-${p.length}-${I}`,type:"AGENT_LLM_CALL",timestamp:j,title:`${Me}: LLM Call`,source:Me,target:"LLM",data:{llmCall:tt},rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F});break}case"llm_response":{const we=o.get(pt);if(we){const A=new Date(j).getTime()-new Date(we.timestamp).getTime();i(pt,Me).llmCalls.push({modelName:we.modelName,durationMs:A,timestamp:we.timestamp}),o.delete(pt)}const ze=Ke.data,tt=(Lt=ze.content)==null?void 0:Lt.parts,ae=tt==null?void 0:tt.filter(A=>A.function_call);if(ae&&ae.length>0){T(z),w=null,E.delete(z);const A=ae.map(He=>{var Pt;return{functionCallId:He.function_call.id,toolName:He.function_call.name,toolArguments:He.function_call.args||{},isPeerDelegation:(Pt=He.function_call.name)==null?void 0:Pt.startsWith("peer_")}}),Z={decisions:A,isParallel:A.length>1},se=[],We=new Set;A.forEach(He=>{if(He.isPeerDelegation){const Pt=He.toolName.substring(5);for(const fn in t){const Ye=t[fn];if(We.has(Ye.taskId))continue;if(Sx(Ye)===z&&Ye.events&&Ye.events.length>0){const Qn=Ye.events.find(er=>{var ko,Ao,To,As;return er.direction==="request"&&((As=(To=(Ao=(ko=er.full_payload)==null?void 0:ko.params)==null?void 0:Ao.message)==null?void 0:To.metadata)==null?void 0:As.function_call_id)===He.functionCallId});if(Qn&&new Date($o(Qn)).getTime()>=new Date(j).getTime()){const er={functionCallId:He.functionCallId,peerAgentName:Pt,subTaskId:Ye.taskId};se.push(er),y.set(He.functionCallId,er),Ye.taskId&&(b.set(Ye.taskId,He.functionCallId),We.add(Ye.taskId));break}}}}});const it={id:`vstep-tooldecision-${p.length}-${I}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:j,title:`LLM: Tool Decision${Z.isParallel?" (Parallel)":""}`,source:"LLM",target:Me,data:{toolDecision:Z},rawEventIds:[I],delegationInfo:se.length>0?se:void 0,isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F};p.push(it);const Je=Z.isParallel?it.id:void 0,mt=pt;i(mt,Me),A.forEach(He=>{var fn;const Pt=He.isPeerDelegation?(fn=y.get(He.functionCallId))==null?void 0:fn.subTaskId:void 0;a.has(He.functionCallId)||a.set(He.functionCallId,{timestamp:j,toolName:He.toolName,isPeer:He.isPeerDelegation,invokingAgentInstanceId:mt,subTaskId:Pt,parallelBlockId:Je})})}else{const A=(tt==null?void 0:tt.filter(se=>se.text).map(se=>se.text).join(`
349
+ `))||"",Z={responsePreview:A.substring(0,200)+(A.length>200?"...":""),isFinalResponse:(ze==null?void 0:ze.partial)===!1};p.push({id:`vstep-llmrespagent-${p.length}-${I}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:j,title:`${Me}: LLM Response`,source:"LLM",target:Me,data:{llmResponseToAgent:Z},rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F})}break}case"tool_invocation_start":{const we={functionCallId:Ke.function_call_id,toolName:Ke.tool_name,toolArguments:Ke.tool_args,isPeerInvocation:(ut=Ke.tool_name)==null?void 0:ut.startsWith("peer_")};p.push({id:`vstep-toolinvokestart-${p.length}-${I}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:j,title:`${Me}: Executing tool ${we.toolName}`,source:Me,target:we.toolName,data:{toolInvocationStart:we},rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F});break}case"tool_result":{const we=Ke.function_call_id,ze=a.get(we);if(ze){const ae=new Date(j).getTime()-new Date(ze.timestamp).getTime(),A=r.agents[ze.invokingAgentInstanceId];if(A){const Z={toolName:ze.toolName,durationMs:ae,isPeer:ze.isPeer,timestamp:ze.timestamp,peerAgentName:ze.isPeer?ze.toolName.substring(5):void 0,subTaskId:ze.subTaskId,parallelBlockId:ze.parallelBlockId};A.toolCalls.push(Z)}a.delete(we)}const tt={toolName:Ke.tool_name,functionCallId:we,resultData:Ke.result_data,isPeerResponse:(ft=Ke.tool_name)==null?void 0:ft.startsWith("peer_")};p.push({id:`vstep-toolresult-${p.length}-${I}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:j,title:`${Me}: Tool Result - ${tt.toolName}`,source:tt.toolName,target:Me,data:{toolResult:tt},rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F});break}}}else at.kind==="text"&&at.text&&(h&&h!==Me&&(T(z),w=null),h||(h=Me,x=j,v=yt),m+=at.text,g.push(I))}return}if(R.direction==="artifact_update"&&((st=D==null?void 0:D.result)!=null&&st.artifact)){T(z);const ke=D.result.artifact,_e=((qt=ke.metadata)==null?void 0:qt.agent_name)||R.source_entity||"Agent";let Fe;if(ke.parts&&ke.parts.length>0){const yt=ke.parts[0];yt.kind==="file"?Fe=yt.file.mimeType||void 0:(Rn=yt.metadata)!=null&&Rn.mime_type&&(Fe=yt.metadata.mime_type)}const Me={artifactName:ke.name||"Unnamed Artifact",version:typeof((Vt=ke.metadata)==null?void 0:Vt.version)=="number"?ke.metadata.version:void 0,description:ke.description||void 0,mimeType:Fe};p.push({id:`vstep-artifactnotify-${p.length}-${I}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:j,title:`${_e}: Artifact Update - ${Me.artifactName}`,source:_e,target:"User/System",data:{artifactNotification:Me},rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F});return}if(["response","task"].includes(R.direction)&&((an=(Ot=D==null?void 0:D.result)==null?void 0:Ot.status)!=null&&an.state)){m.trim()&&T(z);const ke=D.result,_e=ke.status.state,Fe=((Xt=ke.metadata)==null?void 0:Xt.agent_name)||((ie=(bt=(ln=ke.status)==null?void 0:ln.message)==null?void 0:bt.metadata)==null?void 0:ie.agent_name)||R.source_entity||"Agent";if(["completed","failed","canceled"].includes(_e)&&J==0){const Me=_e==="completed"?"TASK_COMPLETED":"TASK_FAILED",yt=`${Fe}: Task ${_e.charAt(0).toUpperCase()+_e.slice(1)}`;let pt={},at="";if((Gt=ke.status.message)!=null&&Gt.parts){const Rt=ke.status.message.parts.find(we=>we.kind==="text");Rt!=null&&Rt.text&&(at=Rt.text.trim())}const Re=z===n.taskId,Ke=at&&(!Re||at!==w);if(Me==="TASK_COMPLETED")pt={finalMessage:Ke?at:void 0};else{const we={message:Ke?at:`Task ${_e}.`},ze=D.error;ze&&(we.message=ze.message||we.message,we.code=ze.code,ze.data&&(we.details=ze.data)),ke.error&&(we.message=ke.error.message||we.message,we.code=ke.error.code||we.code,we.details=ke.error.data||we.details),pt={errorDetails:we}}p.push({id:`vstep-${_e}-${p.length}-${I}`,type:Me,timestamp:j,title:yt,source:Fe,target:"User",data:pt,rawEventIds:[I],isSubTaskStep:J>0,nestingLevel:J,owningTaskId:z,functionCallId:F}),Re&&(w=null);return}}const W=R.direction==="status-update"&&((Jt=(Zt=(Pn=(Yt=D==null?void 0:D.result)==null?void 0:Yt.status)==null?void 0:Pn.message)==null?void 0:Zt.parts)==null?void 0:Jt.some(ke=>ke.kind==="text"));let P=R.source_entity;(dn=(cn=(Qt=(wn=D==null?void 0:D.result)==null?void 0:wn.status)==null?void 0:Qt.message)==null?void 0:cn.metadata)!=null&&dn.forwarded_from_peer?P=D.result.status.message.metadata.forwarded_from_peer:(It=(Ge=D==null?void 0:D.result)==null?void 0:Ge.metadata)!=null&&It.agent_name?P=D.result.metadata.agent_name:(un=(yn=(bn=(Dn=D==null?void 0:D.result)==null?void 0:Dn.status)==null?void 0:bn.message)==null?void 0:yn.metadata)!=null&&un.agent_name&&(P=D.result.status.message.metadata.agent_name),m.trim()&&h&&(!W||W&&P!==h)&&(T(z),l.get(((Mt=g[0])==null?void 0:Mt.split("-")[1])||n.taskId)===0&&!v&&(w=null))});const C=u.length>0&&u[u.length-1].task_id||n.taskId;T(C);const S=u[0]?$o(u[0]):n.firstSeen.toISOString();let N,k="working";const M=p.filter(R=>R.owningTaskId===n.taskId),L=M.length>0?M[M.length-1]:null;if(L&&(L.type==="TASK_COMPLETED"?(k="completed",N=L.timestamp):L.type==="TASK_FAILED"&&(k="failed",N=L.timestamp)),k==="working"&&u.length>0){const R=u[u.length-1];t[R.task_id||n.taskId]}let O;S&&N&&(O=new Date(N).getTime()-new Date(S).getTime()),["completed","failed","canceled","rejected"].includes(k)&&(f=void 0);const V={taskId:n.taskId,initialRequestText:n.initialRequestText,status:k,currentStatusText:f,startTime:S,endTime:N,durationMs:O,steps:p};V.steps.forEach((R,q)=>{if(R.type==="TASK_COMPLETED"){let j="";for(let I=q-1;I>=0;I--){const D=V.steps[I];if(D.type!=="AGENT_RESPONSE_TEXT"||D.source!==R.source)break;j=D.data.text+j}R.data.finalMessage&&(j+=R.data.finalMessage),R.data.finalMessage=j.trim()||void 0}}),Object.values(r.agents).forEach(R=>{R.totalLlmTimeMs=R.llmCalls.reduce((z,J)=>z+J.durationMs,0);const q=R.toolCalls.filter(z=>!z.parallelBlockId),j=new Map;R.toolCalls.forEach(z=>{z.parallelBlockId&&(j.has(z.parallelBlockId)||j.set(z.parallelBlockId,[]),j.get(z.parallelBlockId).push(z))});const I=q.reduce((z,J)=>z+J.durationMs,0);let D=0;j.forEach(z=>{if(z.length>0){const J=Math.min(...z.map(F=>new Date(F.timestamp).getTime())),U=Math.max(...z.map(F=>new Date(F.timestamp).getTime()+F.durationMs));D+=U-J}}),R.totalToolTimeMs=I+D});const K=new Map;Object.values(r.agents).forEach(R=>{K.has(R.agentName)||K.set(R.agentName,[]),K.get(R.agentName).push(R)}),K.forEach(R=>{R.length>1&&(R.sort((q,j)=>{const I=D=>{const z=[...D.llmCalls.map(J=>new Date(J.timestamp).getTime()),...D.toolCalls.map(J=>new Date(J.timestamp).getTime())];return z.length>0?Math.min(...z):1/0};return I(q)-I(j)}),R.forEach((q,j)=>{q.displayName=`${q.agentName} (${j+1})`}))});const G=new Map;return Object.values(r.agents).forEach(R=>{const q=R.instanceId.split(":").slice(1).join(":");q&&G.set(q,R.displayName)}),Object.values(r.agents).forEach(R=>{R.toolCalls.forEach(q=>{if(q.isPeer&&q.subTaskId){const j=G.get(q.subTaskId);j&&(q.peerAgentName=j)}})}),O!==void 0&&(r.overall.totalTaskDurationMs=O),V.performanceReport=r,V},c_=({items:e,bottomItems:t,activeItem:n,onItemChange:r,onHeaderClick:o})=>{const a=i=>{r(i)};return s.jsxs("aside",{className:"flex h-screen w-[100px] flex-col border-r border-[var(--color-secondary-w70)] bg-[var(--color-primary-w100)]",children:[s.jsx(u_,{onClick:o}),s.jsx(p_,{items:e,bottomItems:t,activeItem:n,onItemClick:a})]})},d_=s.jsxs("svg",{id:"header-icon",xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 500 150",width:"100%",height:"100%",children:[s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M14.3,82.5c0-4.4,1-8.2,2.9-11.3,1.9-3.1,4.4-5.7,7.5-7.8,3.1-2,6.5-3.6,10.4-4.6,3.8-1,7.7-1.5,11.5-1.5s7.1.3,10.2.9c3.1.6,5.9,1.5,8.2,2.6,2.4,1.1,4.2,2.4,5.6,3.8,1.4,1.4,2,3,2,4.6,0,2.4,0,4.3-.2,5.7-.1,1.4-.3,2.4-.6,3.1-.3.7-.7,1.1-1.1,1.3-.4.2-.9.2-1.6.2-1.8,0-3.2-.7-4.3-2-1.1-1.3-2.3-2.8-3.7-4.4-1.4-1.6-3.1-3.1-5.3-4.4-2.1-1.3-5.3-2-9.3-2s-4.4.3-6,.9c-1.6.6-2.9,1.5-3.8,2.5-.9,1-1.6,2.2-2,3.4-.4,1.2-.6,2.4-.6,3.5,0,2.5,1,4.4,3.1,5.7,2.1,1.3,4.7,2.3,7.8,3.2,3.1.9,6.5,1.7,10.1,2.5,3.6.8,7,1.9,10.1,3.4,3.1,1.5,5.8,3.5,7.9,6.1,2.1,2.6,3.1,6.1,3.1,10.5s-.8,8-2.5,11.3c-1.7,3.4-4,6.2-7,8.5-3,2.3-6.6,4.1-10.8,5.3-4.2,1.3-8.9,1.9-13.9,1.9s-8.8-.6-12.5-1.9c-3.7-1.3-6.9-2.8-9.6-4.6-2.7-1.8-4.7-3.7-6.2-5.6-1.5-1.9-2.2-3.5-2.2-4.7,0-1.8.5-3.6,1.6-5.3,1-1.8,2.6-2.7,4.7-2.7s2.5.4,3.5,1.2c.9.8,1.8,1.7,2.7,2.8.8,1.1,1.7,2.3,2.6,3.7.9,1.4,2,2.6,3.3,3.7,1.3,1.1,2.9,2,4.7,2.8,1.8.8,4.1,1.2,6.8,1.2,4.1,0,7.5-1,10.3-3.1,2.8-2.1,4.2-4.8,4.2-8s-1-4.9-3.1-6.4c-2-1.4-4.6-2.6-7.7-3.5-3.1-.9-6.4-1.7-10-2.4-3.6-.7-7-1.8-10-3.2-3.1-1.4-5.7-3.4-7.7-6-2-2.6-3.1-6.3-3.1-11"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M124.6,66.8c-4,0-7.3.9-9.9,2.7-2.6,1.8-4.7,4.2-6.4,7.1-1.6,2.9-2.8,6.1-3.5,9.7-.7,3.5-1,6.9-1,10.1,0,4.9.5,9.2,1.6,13,1,3.7,2.5,6.8,4.4,9.3,1.9,2.5,4.1,4.3,6.7,5.6,2.6,1.3,5.3,1.9,8.2,1.9s5.7-.6,8.2-1.9c2.6-1.3,4.8-3.1,6.7-5.6,1.9-2.5,3.3-5.5,4.4-9.3,1-3.7,1.6-8,1.6-13,0-9.5-1.9-16.9-5.8-22-3.9-5.1-8.9-7.7-15.2-7.7M82.2,96.5c0-5.8,1.1-11,3.3-15.9,2.2-4.8,5.2-8.9,9.1-12.4,3.9-3.5,8.4-6.1,13.6-8,5.2-1.9,10.7-2.8,16.6-2.8s11.4.9,16.6,2.8c5.2,1.9,9.7,4.6,13.5,8,3.8,3.5,6.9,7.6,9.1,12.4,2.2,4.8,3.4,10.1,3.4,15.9s-1.1,11.2-3.4,15.9c-2.3,4.8-5.3,8.9-9.1,12.3-3.8,3.5-8.3,6.1-13.5,8-5.2,1.9-10.7,2.8-16.6,2.8s-11.4-.9-16.6-2.8c-5.2-1.9-9.7-4.6-13.6-8-3.9-3.5-6.9-7.6-9.1-12.3-2.2-4.8-3.3-10.1-3.3-15.9"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M172.3,23.3c0-.8.9-1.8,2.7-2.8,1.8-1,4-2,6.5-2.9,2.5-.9,5.1-1.6,7.7-2.3,2.6-.6,4.7-.9,6.3-.9s1.3,0,1.9.2c.6.2,1.2.5,1.8,1.2.6.6,1,1.6,1.4,2.9.4,1.3.5,3.1.5,5.4v94.7c0,2.4.4,4.1,1.2,4.9.8.9,1.6,1.5,2.5,2,.9.4,1.7.8,2.5,1.3.8.4,1.2,1.4,1.2,2.8s-.5,2.5-1.6,3.2c-1,.7-2.4,1-3.9,1h-24.2c-1.6,0-2.9-.3-3.9-1-1-.7-1.6-1.8-1.6-3.2s.4-2.3,1.2-2.7c.8-.5,1.6-.9,2.5-1.3.9-.4,1.7-1.1,2.5-2,.8-.9,1.2-2.5,1.2-4.9V34.5c0-2-.4-3.4-1.3-4.2-.9-.8-1.9-1.4-2.9-1.9-1-.5-2-1-2.9-1.6-.9-.6-1.3-1.8-1.3-3.5"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M254.4,93.3c-3.7,1.2-6.8,2.8-9.4,4.7-2.6,1.9-4.6,4.1-6,6.6-1.4,2.5-2.1,5-2.1,7.6s.3,3.6,1,5.3c.7,1.8,1.6,3.4,2.9,4.7,1.3,1.4,2.7,2.5,4.5,3.3,1.7.8,3.6,1.3,5.7,1.3s5.2-.7,7.2-2c2-1.3,3.6-2.9,4.9-4.7,1.3-1.8,2.2-3.7,2.7-5.7.6-1.9.9-3.6.9-4.9v-18.2c-4.5.1-8.6.8-12.2,2M220.5,69.7c0-1.9.9-3.6,2.6-5.1,1.7-1.5,4-2.8,6.8-3.8,2.8-1,6-1.9,9.5-2.4,3.5-.6,7-.9,10.4-.9,7,0,12.9.8,17.6,2.3,4.7,1.5,8.5,3.6,11.5,6.1,2.9,2.6,5,5.5,6.3,8.7,1.3,3.2,1.9,6.6,1.9,10v34.5c0,1.9.4,3.2,1.3,4.1.8.8,1.7,1.5,2.7,2,.9.5,1.8,1,2.7,1.5.8.5,1.3,1.4,1.3,2.7s-.4,2.5-1.2,3.4c-.8.9-2.7,1.3-5.7,1.3h-13.2c-2.4,0-4.1-.5-5.1-1.6-1-1-1.5-2.8-1.5-5.2v-1.7h-.6c-2.4,3.5-5.9,6-10.4,7.6-4.6,1.6-9.3,2.4-14.4,2.4s-8.5-.6-11.9-1.9c-3.4-1.3-6.3-3-8.6-5.1-2.4-2.1-4.1-4.6-5.3-7.5-1.2-2.8-1.8-5.8-1.8-8.8,0-5.2,1.6-9.7,4.8-13.5,3.2-3.8,7.3-6.8,12.2-9.2,5-2.4,10.5-4.1,16.6-5.2,6.1-1.1,12-1.6,17.9-1.6,0-4.7-1.3-8.6-4-11.5-2.7-3-6.6-4.5-11.7-4.5s-5.7.5-7.5,1.4c-1.9.9-3.6,2-5.1,3.1-1.5,1.2-3.1,2.2-4.7,3.1-1.6.9-3.7,1.4-6.2,1.4s-3.8-.5-5-1.6c-1.3-1.1-1.9-2.6-1.9-4.6"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M301.5,97.6c0-5.9,1-11.3,3.1-16.2,2.1-4.9,4.9-9.2,8.6-12.7,3.6-3.6,7.9-6.3,12.9-8.3,5-2,10.4-3,16.2-3s7.2.4,10.8,1.3c3.5.9,6.6,2.1,9.3,3.5,2.7,1.5,4.9,3.2,6.5,5.2,1.6,2,2.4,4.1,2.4,6.3s-.9,4.1-2.7,5.5c-1.8,1.4-4.2,2-7.2,2s-4.1-.8-5.3-2.4c-1.2-1.6-2.4-3.4-3.5-5.3-1.1-1.9-2.4-3.6-4-5.3-1.6-1.6-3.9-2.4-7.1-2.4s-5.2.8-7.5,2.3c-2.3,1.5-4.2,3.7-5.9,6.5-1.7,2.8-3,6.2-3.8,10-.9,3.9-1.3,8.2-1.3,12.9s.6,7.9,1.8,11.2c1.2,3.3,2.8,6.1,4.8,8.4,2,2.3,4.3,4.1,6.9,5.3,2.6,1.2,5.4,1.8,8.3,1.8s6.9-.6,9.4-1.9c2.5-1.3,4.7-2.6,6.4-4.2,1.8-1.5,3.3-2.9,4.6-4.2,1.3-1.3,2.6-1.9,4-1.9s2,.3,2.7,1c.8.7,1.2,1.6,1.2,2.7,0,1.7-.8,3.6-2.5,5.9-1.7,2.3-4,4.4-6.9,6.4-2.9,2-6.4,3.8-10.4,5.2-4,1.4-8.4,2.1-13.1,2.1s-10.7-.9-15.5-2.7c-4.8-1.8-8.9-4.4-12.3-7.8-3.5-3.3-6.2-7.4-8.2-12-2-4.7-3-9.8-3-15.5"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M423.2,65.9c-3.4,0-6.3.7-8.9,2.2-2.6,1.5-4.9,3.5-6.8,6.1-1.9,2.6-3.3,5.8-4.3,9.4-1,3.7-1.5,7.7-1.5,12.1v.9c3.5-.3,7.1-.9,11-1.7,3.9-.8,7.4-2,10.7-3.5,3.2-1.5,5.9-3.4,8.1-5.7,2.1-2.4,3.2-5.3,3.2-8.7s-.9-5.9-2.7-8c-1.8-2.1-4.7-3.1-8.7-3.1M380,98.4c0-5.7.9-11,2.7-15.9,1.8-5,4.5-9.3,8.2-13,3.7-3.7,8.3-6.6,13.9-8.8,5.6-2.1,12.2-3.2,19.9-3.2s6.8.4,10.4,1.2c3.6.8,6.8,2,9.8,3.8,3,1.7,5.4,4,7.4,6.8,1.9,2.8,2.9,6.1,2.9,10s-1.6,9-4.9,12.2c-3.3,3.2-7.5,5.8-12.6,7.7-5.1,1.9-10.8,3.4-16.9,4.3-6.1.9-12,1.6-17.7,1.9.5,3.1,1.5,5.9,2.9,8.3,1.4,2.4,3.1,4.4,5.2,6,2,1.6,4.2,2.8,6.6,3.6,2.4.8,4.7,1.2,7.1,1.2s5-.3,7.2-.9c2.2-.6,4.2-1.3,6-2.3,1.8-.9,3.5-2,4.9-3.1,1.5-1.1,2.8-2.2,3.9-3.2,1-1,2-1.9,2.8-2.4.8-.6,1.8-.9,3-.9,2.4,0,3.6,1.2,3.6,3.6s-1,4-3,6.4c-2,2.4-4.7,4.6-8,6.7-3.4,2-7.2,3.8-11.5,5.2-4.3,1.4-8.9,2.1-13.7,2.1s-10.9-.9-15.8-2.8c-4.9-1.9-9.1-4.5-12.7-7.8-3.6-3.3-6.4-7.2-8.5-11.8-2-4.6-3.1-9.5-3.1-14.8"}),s.jsx("path",{className:"fill-[var(--color-brand-wMain)]",d:"M464.7,123.7c0-6.5,5.3-11.8,11.8-11.8s11.8,5.3,11.8,11.8-5.3,11.8-11.8,11.8-11.8-5.3-11.8-11.8"})]}),u_=({onClick:e})=>s.jsx("div",{className:"flex h-[80px] min-h-[80px] cursor-pointer items-center justify-center border-b",onClick:e,children:s.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full",children:d_})}),f_=()=>{const{currentTheme:e,toggleTheme:t}=Ha(),n=`Toggle theme (currently ${e})`;return s.jsxs(Zl,{children:[s.jsx(Jl,{asChild:!0,children:s.jsx("button",{type:"button",onClick:t,className:"relative mx-auto flex w-full cursor-pointer flex-col items-center bg-[var(--color-primary-w100)] px-3 py-5 text-xs text-[var(--color-primary-text-w10)] transition-colors hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":n,title:n,children:s.jsx($u,{className:"mb-1 h-6 w-6"})})}),s.jsx(Ql,{side:"right",children:n})]})},p_=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>s.jsxs("nav",{className:"flex flex-1 flex-col",role:"navigation","aria-label":"Main navigation",children:[s.jsx("ul",{className:"space-y-1",children:e.map(o=>s.jsxs("li",{children:[s.jsx(Nu,{item:o,isActive:n===o.id,onItemClick:r}),o.showDividerAfter&&s.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},o.id))}),t&&t.length>0&&s.jsx("div",{className:"flex-1"}),t&&t.length>0&&s.jsx("ul",{className:"space-y-1",children:t.map(o=>s.jsx("li",{className:"my-4",children:o.id==="theme-toggle"?s.jsx(f_,{}):s.jsx(Nu,{item:o,isActive:n===o.id,onItemClick:r},o.id)},o.id))})]}),Nu=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:o,icon:a,disabled:i}=e,l=()=>{!i&&n&&n(r)},c=u=>{(u.key==="Enter"||u.key===" ")&&l()};return s.jsxs(Zl,{children:[s.jsx(Jl,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:n?l:void 0,onKeyDown:n?c:void 0,disabled:i,className:ve("relative mx-auto flex w-full cursor-pointer flex-col items-center border-l-4 border-[var(--color-primary-w100)] px-3 py-5 text-xs transition-colors","bg-[var(--color-primary-w100)] hover:bg-[var(--color-primary-w90)]","text-[var(--color-primary-text-w10)] hover:bg-[var(--color-primary-w90)] hover:text-[var(--color-primary-text-w10)]","disabled:cursor-not-allowed disabled:opacity-50",t?"border-l-4 border-[var(--color-brand-wMain)] bg-[var(--color-primary-w90)]":""),"aria-label":o,"aria-current":t?"page":void 0,children:[s.jsx(a,{className:ve("mb-1 h-6 w-6",t&&"text-[var(--color-brand-wMain)]")}),s.jsx("span",{className:"text-center text-[13px] leading-tight",children:o})]})}),s.jsx(Ql,{side:"right",children:o})]})},m_=[{id:"chat",label:"Chat",icon:ra},{id:"agentMesh",label:"Agents",icon:Nl},{id:"projects",label:"Projects",icon:kl}],ju=[{id:"theme-toggle",label:"Theme",icon:$u,onClick:()=>{}}];function Nx(e=!0){return m_.filter(t=>!(t.id==="projects"&&!e))}Nx(!0);const Dc=({title:e,breadcrumbs:t,tabs:n,buttons:r,leadingAction:o})=>s.jsxs("div",{className:"relative flex max-h-[80px] min-h-[80px] w-full items-center border-b px-8",children:[t&&t.length>0&&s.jsx("div",{className:"absolute top-1 left-8 flex h-8 items-center",children:t.map((a,i)=>s.jsxs(jt.Fragment,{children:[i>0&&s.jsx("span",{className:"mx-1",children:s.jsx(dv,{size:16})}),a.onClick?s.jsx(te,{variant:"link",className:"m-0 p-0",onClick:a.onClick,children:a.label}):s.jsx("div",{children:a.label})]},i))}),o&&s.jsx("div",{className:"mr-4 flex items-center pt-[35px]",children:o}),s.jsx("div",{className:"flex items-center pt-[35px] text-xl",children:e}),n&&n.length>0&&s.jsx("div",{className:"ml-8 flex items-center pt-[35px]",role:"tablist",children:n.map((a,i)=>s.jsxs("button",{role:"tab","aria-selected":a.isActive,onClick:a.onClick,className:`relative cursor-pointer px-4 py-3 font-medium transition-colors duration-200 ${a.isActive?"border-b-2 border-[var(--color-brand-wMain)] font-semibold":""} ${i>0?"ml-6":""}`,children:[a.label,a.isActive&&s.jsx("div",{className:"absolute right-0 bottom-0 left-0 h-0.5"})]},a.id))}),s.jsx("div",{className:"flex-1"}),r&&r.length>0&&s.jsx("div",{className:"flex items-center gap-2 pt-[35px]",children:r.map((a,i)=>s.jsx(jt.Fragment,{children:a},i))})]});function h_(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=qe(),[o,a]=d.useState("cards"),i=()=>{if(o===bu.CARDS)return s.jsx(gl,{agents:e});const l=hx.getPluginById(o);return l?l.render({agents:e}):(console.warn(`Layout ${o} not found, falling back to cards layout`),s.jsx(gl,{agents:e}))};return s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(Dc,{title:"Agents",buttons:[s.jsxs(te,{"data-testid":"refreshAgents",disabled:t,variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[s.jsx(jl,{className:"size-4"}),"Refresh Agents"]})]}),t?s.jsx(rs,{title:"Loading agents...",variant:"loading"}):n?s.jsx(rs,{variant:"error",title:"Error loading agents",subtitle:n}):s.jsxs("div",{className:`relative flex-1 p-4 ${o===bu.CARDS?"":"bg-[var(--muted)] dark:bg-[var(--color-bg-wMain)]"}`,children:[s.jsx("div",{className:"absolute right-8 z-20 flex items-center space-x-4",children:s.jsx(ZA,{currentLayout:o,onLayoutChange:a})}),i()]})]})}const g_=jt.memo(({isOpen:e,onClose:t,onConfirm:n,sessionName:r})=>e?s.jsx(Yn,{open:e,onOpenChange:t,children:s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Delete Chat Session?"}),s.jsxs(Zn,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",s.jsx("strong",{children:r})]})]}),s.jsxs(jr,{children:[s.jsx(te,{variant:"ghost",onClick:t,title:"Cancel",children:"Cancel"}),s.jsx(te,{onClick:n,title:"Delete",children:"Delete"})]})]})}):null),Ys=4,yl={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},x_={chatPanelSizes:{...yl.chatPanelSizes,min:50},sidePanelSizes:{...yl.sidePanelSizes,max:50}};function ku(){var U;const{activeProject:e}=Jn(),{agents:t,sessionName:n,messages:r,isSidePanelCollapsed:o,setIsSidePanelCollapsed:a,openSidePanelTab:i,setTaskIdInSidePanel:l,isResponding:c,latestStatusText:u,isLoadingSession:p,sessionToDelete:f,closeSessionDeleteModal:m,confirmSessionDelete:h,currentTaskId:x}=qe(),{isTaskMonitorConnected:g,isTaskMonitorConnecting:w,taskMonitorSseError:v,connectTaskMonitorStream:b}=uc(),[y,E]=d.useState(!0),[T,C]=d.useState(!1),S=d.useRef(null),N=d.useRef(null),k=d.useRef(null),{chatPanelSizes:M,sidePanelSizes:L}=d.useMemo(()=>y?yl:x_,[y]),O=d.useCallback(F=>{if(C(!0),N.current)if(F)N.current.resize(Ys);else{const W=k.current||L.default;N.current.resize(W)}setTimeout(()=>C(!1),300)},[L.default]),V=d.useCallback(()=>{a(!0)},[a]),K=d.useCallback(()=>{a(!1)},[a]),G=d.useCallback(F=>{F>Ys+1&&(k.current=F)},[]),R=d.useCallback(()=>{E(!y)},[y]),q=void 0,j=d.useMemo(()=>n||"New Chat",[n]);d.useEffect(()=>{N.current&&o&&N.current.resize(Ys);const F=()=>{if(N.current&&o){C(!0);const W=k.current||L.default;N.current.resize(W),a(!1),setTimeout(()=>C(!1),300)}};return window.addEventListener("expand-side-panel",F),()=>{window.removeEventListener("expand-side-panel",F)}},[o,a,L.default]);const I=d.useMemo(()=>{const F=new Map;return r.forEach((W,P)=>{W.taskId&&F.set(W.taskId,P)}),F},[r]),D=d.useMemo(()=>r.find(F=>F.isStatusBubble),[r]),z=d.useMemo(()=>{if(!D||!D.parts)return null;const F=D.parts.find(W=>W.kind==="text");return(F==null?void 0:F.text)||null},[D]),J=d.useMemo(()=>{if(x)return()=>{l(x),i("workflow")}},[x,l,i]);return d.useEffect(()=>{const F=()=>{!g&&!w&&v&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),b())};return window.addEventListener("focus",F),()=>{window.removeEventListener("focus",F)}},[g,w,v,b]),s.jsxs("div",{className:"relative flex h-screen w-full flex-col overflow-hidden",children:[s.jsx("div",{className:`absolute top-0 left-0 z-20 h-screen transition-transform duration-300 ${y?"-translate-x-full":"translate-x-0"}`,children:s.jsx(AT,{onToggle:R})}),s.jsx("div",{className:`transition-all duration-300 ${y?"ml-0":"ml-100"}`,children:s.jsx(Dc,{title:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{children:j}),e&&s.jsx(jo,{variant:"outline",className:"text-xs bg-primary/10 border-primary/30 text-primary font-semibold px-2 py-0.5 shadow-sm",children:e.name})]}),breadcrumbs:q,leadingAction:y?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(te,{"data-testid":"showSessionsPanel",variant:"ghost",onClick:R,className:"h-10 w-10 p-0",tooltip:"Show Chat Sessions",children:s.jsx(Fu,{className:"size-5"})}),s.jsx("div",{className:"h-6 border-r"}),s.jsx(gx,{})]}):null})}),s.jsx("div",{className:"flex min-h-0 flex-1",children:s.jsx("div",{className:`min-h-0 flex-1 overflow-x-auto transition-all duration-300 ${y?"ml-0":"ml-100"}`,children:s.jsxs(sm,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[s.jsx(Go,{defaultSize:M.default,minSize:M.min,maxSize:M.max,id:"chat-panel",children:s.jsx("div",{className:"flex h-full w-full flex-col",children:s.jsx("div",{className:"flex flex-1 flex-col py-6 min-h-0",children:p?s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx(Wn,{size:"medium",variant:"primary",children:s.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"Loading session..."})})}):s.jsxs(s.Fragment,{children:[s.jsx(gg,{className:"text-base",ref:S,children:r.map((F,W)=>{var H;const P=!!(F.taskId&&I.get(F.taskId)===W),_=((H=F.metadata)==null?void 0:H.messageId)||`temp-${W}`;return s.jsx(sT,{message:F,isLastWithTaskId:P},_)})}),s.jsxs("div",{style:hg,children:[c&&s.jsx(vl,{statusText:(z||u.current)??void 0,onViewWorkflow:J}),s.jsx(fN,{agents:t,scrollToBottom:(U=S.current)==null?void 0:U.scrollToBottom})]})]})})})}),s.jsx(Qi,{}),s.jsx(Go,{ref:N,defaultSize:L.default,minSize:L.min,maxSize:L.max,collapsedSize:Ys,collapsible:!0,onCollapse:V,onExpand:K,onResize:G,id:"chat-side-panel",className:T?"transition-all duration-300 ease-in-out":"",children:s.jsx("div",{className:"h-full",children:s.jsx(kT,{onCollapsedToggle:O,isSidePanelCollapsed:o,setIsSidePanelCollapsed:a,isSidePanelTransitioning:T})})})]})})}),s.jsx(g_,{isOpen:!!f,onClose:m,onConfirm:h,sessionName:(f==null?void 0:f.name)||`Session ${f==null?void 0:f.id.substring(0,8)}`})]})}const v_=e=>({displayName:e?"Solace Dark JER":"Solace Light JER",styles:{container:{backgroundColor:"transparent",fontFamily:"monospace",fontSize:"14px"},property:e?"var(--color-primary-text-w10)":"var(--color-primary-text-wMain)",bracket:"var(--color-secondary-text-w50)",itemCount:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},string:e?"var(--color-success-w70)":"var(--color-success-wMain)",number:"var(--color-accent-n0-wMain)",boolean:e?"var(--color-warning-w70)":"var(--color-warning-wMain)",null:{color:"var(--color-secondary-text-w50)",fontStyle:"italic"},iconCollection:"var(--color-secondary-text-w50)",iconCopy:"var(--color-secondary-text-w50)"}}),Cl=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=Ha(),o=d.useMemo(()=>v_(r==="dark"),[r]),a=d.useMemo(()=>t===void 0||t<0?!1:t,[t]),i=d.useMemo(()=>e===null||typeof e!="object"?{value:e}:e,[e]),l=`rounded-lg border overflow-auto ${n}`.trim();return e===void 0?s.jsx("div",{className:l,children:s.jsx("span",{className:"italic",children:"No JSON data"})}):s.jsx("div",{className:l,children:s.jsx(uv,{data:i,theme:o,viewOnly:!0,collapse:a,showStringQuotes:!0,showCollectionCount:"when-closed"})})},w_=({isOpen:e,onClose:t,onSubmit:n,isSubmitting:r=!1})=>{const[o,a]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(null),p=async m=>{if(m.preventDefault(),!o.trim()){u("Project name is required");return}try{await n({name:o.trim(),description:i.trim()}),a(""),l(""),u(null)}catch(h){u(h instanceof Error?h.message:"Failed to create project")}},f=()=>{r||(a(""),l(""),u(null),t())};return s.jsx(Yn,{open:e,onOpenChange:m=>!m&&f(),children:s.jsx(Kn,{className:"sm:max-w-[500px]",children:s.jsxs("form",{onSubmit:p,children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Create New Project"}),s.jsx(Zn,{children:"Create a new project to organize your chats and files. You can add more details after creation."})]}),s.jsxs("div",{className:"space-y-4 py-4",children:[c&&s.jsx("div",{className:"text-sm text-red-500 bg-red-50 dark:bg-red-900/20 p-2 rounded",children:c}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"project-name",className:"text-sm font-medium",children:["Project Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(ec,{id:"project-name",value:o,onChange:m=>a(m.target.value),disabled:r,required:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"project-description",className:"text-sm font-medium",children:"Description"}),s.jsx(Hr,{id:"project-description",value:i,onChange:m=>l(m.target.value),disabled:r,rows:3})]})]}),s.jsxs(jr,{children:[s.jsx(te,{type:"button",variant:"ghost",onClick:f,disabled:r,children:"Cancel"}),s.jsx(te,{type:"submit",disabled:r,children:r?"Creating...":"Create Project"})]})]})})})},b_=({isOpen:e,files:t,onClose:n,onConfirm:r,isSubmitting:o=!1})=>{const[a,i]=d.useState({});d.useEffect(()=>{e&&i({})},[e]);const l=d.useCallback((p,f)=>{i(m=>({...m,[p]:f}))},[]),c=d.useCallback(()=>{if(!t)return;const p=new FormData,f={};for(const m of Array.from(t))p.append("files",m),a[m.name]&&(f[m.name]=a[m.name]);Object.keys(f).length>0&&p.append("fileMetadata",JSON.stringify(f)),r(p)},[t,a,r]),u=t?Array.from(t):[];return s.jsx(Yn,{open:e,onOpenChange:p=>!p&&n(),children:s.jsxs(Kn,{className:"sm:max-w-[600px]",children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Add Files to Project"}),s.jsx(Zn,{children:"Add descriptions for each file. This helps Solace Agent Mesh understand the file's purpose."})]}),s.jsx("div",{className:"space-y-4 py-4",children:u.length>0?s.jsx("div",{className:"space-y-2 max-h-[50vh] overflow-y-auto pr-2",children:u.map((p,f)=>s.jsx(Ey,{className:"bg-muted/50",children:s.jsxs(Ny,{className:"p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(or,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-foreground truncate",title:p.name,children:p.name}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[(p.size/1024).toFixed(1)," KB"]})]})]}),s.jsx(Hr,{placeholder:`Add a description for ${p.name} (optional)`,className:"bg-background text-foreground placeholder:text-muted-foreground mt-2",rows:2,disabled:o,value:a[p.name]||"",onChange:m=>l(p.name,m.target.value)})]})},f))}):s.jsx("p",{className:"text-muted-foreground",children:"No files selected."})}),s.jsxs(jr,{children:[s.jsx(te,{variant:"ghost",onClick:n,disabled:o,children:"Cancel"}),s.jsx(te,{onClick:c,disabled:o||u.length===0,children:o?"Uploading...":`Upload ${u.length} File(s)`})]})]})})},y_=({project:e,isSelected:t,onClick:n,onDelete:r})=>{const o=a=>{a.stopPropagation(),r==null||r(e)};return s.jsx("div",{className:`
350
+ group cursor-pointer px-4 py-2 transition-colors
351
+ hover:bg-accent/50
352
+ ${t?"bg-accent":""}
353
+ `,onClick:n,role:"button",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),n())},children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",onClick:n,children:[s.jsx("h3",{className:"font-semibold text-foreground truncate mb-1",title:e.name,children:e.name}),e.description&&s.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",title:e.description,children:e.description})]}),r&&s.jsx("div",{className:"flex items-center opacity-0 transition-opacity group-hover:opacity-100",children:s.jsx(te,{variant:"ghost",size:"sm",onClick:o,title:"Delete project",className:"h-8 w-8 p-0",children:s.jsx(Ou,{size:16})})})]})})},C_=({isOpen:e,onClose:t,onConfirm:n,project:r,isDeleting:o=!1})=>!e||!r?null:s.jsx(Yn,{open:e,onOpenChange:t,children:s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Delete Project?"}),s.jsxs(Zn,{children:["Are you sure you want to delete the project ",s.jsxs("strong",{children:['"',r.name,'"']}),"?",s.jsx("br",{}),s.jsx("br",{}),"This will remove the project and all its associated chat sessions and artifacts. This action cannot be undone."]})]}),s.jsxs(jr,{children:[s.jsx(te,{variant:"ghost",onClick:t,disabled:o,children:"Cancel"}),s.jsx(te,{variant:"outline",onClick:n,disabled:o,children:o?"Deleting...":"Delete Project"})]})]})}),S_=({projects:e,selectedProject:t,isLoading:n,error:r,onProjectSelect:o,onProjectDelete:a})=>{const[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(!1),m=x=>{u(x),l(!0)},h=async()=>{if(!(!c||!a)){f(!0);try{await a(c.id),l(!1),u(null)}catch(x){console.error("Failed to delete project:",x)}finally{f(!1)}}};return s.jsxs("div",{className:"flex h-full flex-col bg-background border-r",children:[s.jsxs("div",{className:"flex-1 overflow-y-auto py-6 px-6",children:[n&&s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx(Wn,{size:"small"})}),r&&s.jsxs("div",{className:"p-4 text-sm text-destructive",children:["Error loading projects: ",r]}),!n&&!r&&e.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[s.jsx(kl,{className:"h-12 w-12 text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"No projects yet"})]}),!n&&!r&&e.length>0&&s.jsx("div",{children:e.map(x=>s.jsx(y_,{project:x,isSelected:(t==null?void 0:t.id)===x.id,onClick:()=>o(x),onDelete:a?m:void 0},x.id))})]}),s.jsx(C_,{isOpen:i,onClose:()=>{l(!1),u(null)},onConfirm:h,project:c,isDeleting:p})]})},E_=({project:e,isEditing:t,onToggleEdit:n,onSave:r,isSaving:o})=>{const[a,i]=d.useState(e.name);d.useEffect(()=>{i(e.name)},[e.name]);const l=async()=>{a.trim()&&a.trim()!==e.name?await r(a.trim()):n()},c=()=>{i(e.name),n()};return s.jsx("div",{className:"border-b px-6 py-4",children:s.jsx("div",{className:"flex items-center justify-between",children:t?s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(ec,{value:a,onChange:u=>i(u.target.value),className:"text-2xl font-bold",disabled:o,onKeyDown:u=>{u.key==="Enter"?l():u.key==="Escape"&&c()}}),s.jsx(te,{variant:"ghost",size:"sm",onClick:l,disabled:o||!a.trim(),children:s.jsx(Al,{className:"h-4 w-4"})}),s.jsx(te,{variant:"ghost",size:"sm",onClick:c,disabled:o,children:s.jsx(Er,{className:"h-4 w-4"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e.name}),s.jsx(te,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(ds,{className:"h-4 w-4"})})]})})})},N_=({project:e,isEditing:t,onToggleEdit:n,onSave:r,isSaving:o})=>{const[a,i]=d.useState(e.description||"");d.useEffect(()=>{i(e.description||"")},[e.description]);const l=async()=>{a.trim()!==(e.description||"")?await r(a.trim()):n()},c=()=>{i(e.description||""),n()};return s.jsxs("div",{className:"px-6 py-4 border-b",children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Description"}),!t&&s.jsx(te,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(ds,{className:"h-4 w-4"})})]}),t?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Hr,{value:a,onChange:u=>i(u.target.value),placeholder:"Add a description for this project...",rows:3,disabled:o}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(te,{size:"sm",onClick:l,disabled:o,children:[s.jsx(Al,{className:"h-4 w-4 mr-2"}),"Save"]}),s.jsxs(te,{variant:"outline",size:"sm",onClick:c,disabled:o,children:[s.jsx(Er,{className:"h-4 w-4 mr-2"}),"Cancel"]})]})]}):s.jsx("div",{className:`text-sm text-muted-foreground ${e.description?"":"rounded-md bg-muted p-3 text-center"}`,children:e.description||"No description provided."})]})},j_=({project:e,onChatClick:t,onStartNewChat:n})=>{const{sessions:r,isLoading:o,error:a}=qC(e.id);return s.jsxs("div",{className:"px-6 py-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Chats"}),n&&s.jsxs(te,{onClick:n,size:"sm",children:[s.jsx(oa,{className:"h-4 w-4 mr-2"}),"New Chat"]})]}),o&&s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx(Wn,{size:"small"})}),a&&s.jsxs("div",{className:"text-sm text-destructive p-4 border border-destructive/50 rounded-md",children:["Error loading chats: ",a]}),!o&&!a&&r.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center border border-dashed rounded-md",children:[s.jsx(ra,{className:"h-8 w-8 text-muted-foreground mb-2"}),s.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"No chats yet. Start a new chat with this project's context."}),n&&s.jsxs(te,{onClick:n,size:"sm",children:[s.jsx(oa,{className:"h-4 w-4 mr-2"}),"Start New Chat"]})]}),!o&&!a&&r.length>0&&s.jsx("div",{className:"space-y-2",children:r.map(i=>s.jsx("div",{className:"p-3 border rounded-md hover:bg-accent/50 cursor-pointer transition-colors shadow-sm",onClick:()=>t(i.id),role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),t(i.id))},children:s.jsx("div",{className:"flex items-start justify-between gap-2",children:s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:i.name||`Chat ${i.id.substring(0,8)}`}),s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-1",children:[s.jsx(fv,{className:"h-3 w-3"}),s.jsx("span",{children:xf(i.updatedTime)})]})]})})},i.id))})]})},k_=({selectedProject:e,onCreateNew:t,onChatClick:n,onStartNewChat:r})=>{const{updateProject:o}=Jn(),[a,i]=d.useState(!1),[l,c]=d.useState(!1),[u,p]=d.useState(!1);if(!e)return s.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx(kl,{className:"h-16 w-16 text-muted-foreground mx-auto"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"Select a project to view details"}),s.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Choose a project from the sidebar to see its details, chats, and files"}),t&&s.jsxs(te,{onClick:t,children:[s.jsx(oa,{className:"h-4 w-4 mr-2"}),"Create New Project"]})]})]})});const f=async x=>{p(!0);try{const g={name:x};await o(e.id,g),i(!1)}catch(g){console.error("Failed to update project name:",g)}finally{p(!1)}},m=async x=>{p(!0);try{const g={description:x};await o(e.id,g),c(!1)}catch(g){console.error("Failed to update project description:",g)}finally{p(!1)}},h=x=>{n&&n(x)};return s.jsxs("div",{className:"flex h-full flex-col bg-background overflow-y-auto",children:[s.jsx(E_,{project:e,isEditing:a,onToggleEdit:()=>i(!a),onSave:f,isSaving:u}),s.jsx(N_,{project:e,isEditing:l,onToggleEdit:()=>c(!l),onSave:m,isSaving:u}),s.jsx(j_,{project:e,onChatClick:h,onStartNewChat:r})]})},A_=({project:e,onSave:t,isSaving:n,error:r})=>{const{validationLimits:o}=_t(),a=(o==null?void 0:o.projectInstructionsMax)??4e3,[i,l]=d.useState(!1),[c,u]=d.useState(e.systemPrompt||""),[p,f]=d.useState(null);d.useEffect(()=>{u(e.systemPrompt||""),f(null)},[e.systemPrompt]),d.useEffect(()=>{r&&f(r)},[r]);const m=async()=>{if(f(null),c.trim()!==(e.systemPrompt||""))try{await t(c.trim()),l(!1)}catch{}else l(!1)},h=()=>{u(e.systemPrompt||""),f(null),l(!1)},x=c.length,g=x>a,w=x>a*.9;return s.jsxs("div",{className:"border-b",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Instructions"}),!i&&s.jsx(te,{variant:"ghost",size:"sm",onClick:()=>l(!0),className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(ds,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"px-4 pb-3",children:i?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Hr,{value:c,onChange:v=>u(v.target.value),placeholder:"Add instructions for this project...",rows:8,disabled:n,className:`text-sm ${g?"border-destructive focus-visible:ring-destructive":""}`}),s.jsx("div",{className:`mt-1 text-xs ${g?"text-destructive font-medium":w?"text-orange-500":"text-muted-foreground"}`,children:g?`Instructions must be less than ${a} characters (currently ${x})`:`${x} / ${a} characters`})]}),p&&s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:[s.jsx(cs,{className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{children:p})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(te,{size:"sm",onClick:m,disabled:n||g,children:[s.jsx(Al,{className:"h-4 w-4 mr-2"}),"Save"]}),s.jsxs(te,{variant:"outline",size:"sm",onClick:h,disabled:n,children:[s.jsx(Er,{className:"h-4 w-4 mr-2"}),"Cancel"]})]})]}):s.jsx("div",{className:`text-sm text-muted-foreground whitespace-pre-wrap rounded-md bg-muted p-3 min-h-[120px] max-h-[400px] overflow-y-auto ${e.systemPrompt?"":"flex items-center justify-center"}`,children:e.systemPrompt||"No instructions provided."})})]})},T_=({project:e,onSave:t,isSaving:n})=>{const[r,o]=d.useState(!1),[a,i]=d.useState(e.defaultAgentId||null),{agents:l,isLoading:c}=cc();d.useEffect(()=>{i(e.defaultAgentId||null)},[e.defaultAgentId]);const u=async()=>{a!==(e.defaultAgentId||null)&&await t(a),o(!1)},p=()=>{i(e.defaultAgentId||null),o(!1)},f=l.find(h=>h.name===e.defaultAgentId),m=(f==null?void 0:f.displayName)||e.defaultAgentId||"None";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"border-b",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Agent"}),s.jsx(te,{variant:"ghost",size:"sm",onClick:()=>o(!0),disabled:c,className:"h-8 w-8 p-0",tooltip:"Edit",children:s.jsx(ds,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"px-4 pb-3",children:s.jsx("div",{className:"text-sm text-muted-foreground rounded-md bg-muted p-2.5 flex items-center",children:e.defaultAgentId?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nl,{className:"h-4 w-4"}),s.jsx("span",{children:m})]}):s.jsx("span",{className:"w-full text-center",children:"No default agent set."})})})]}),s.jsx(Yn,{open:r,onOpenChange:o,children:s.jsxs(Kn,{children:[s.jsxs(qn,{children:[s.jsx(Xn,{children:"Edit Default Agent"}),s.jsx(Zn,{children:"Select the default agent for this project. This agent will be used when starting new chats in this project."})]}),s.jsx("div",{className:"py-4",children:s.jsxs(bs,{value:a||"none",onValueChange:h=>i(h==="none"?null:h),disabled:n||c,children:[s.jsx(Cs,{className:"w-full",children:s.jsx(ys,{placeholder:"Select default agent..."})}),s.jsxs(Ss,{children:[s.jsx(Cr,{value:"none",children:s.jsx("span",{className:"text-muted-foreground italic",children:"No default agent"})}),l.map(h=>s.jsx(Cr,{value:h.name||"",children:h.displayName||h.name},h.name))]})]})}),s.jsxs(jr,{children:[s.jsx(te,{variant:"ghost",onClick:p,disabled:n,children:"Cancel"}),s.jsx(te,{onClick:u,disabled:n||c,children:"Save"})]})]})})]})},__=e=>{const{configServerUrl:t}=_t(),[n,r]=d.useState([]),[o,a]=d.useState(!0),[i,l]=d.useState(null),c=`${t}/api/v1`,u=d.useCallback(async()=>{if(!e){r([]),a(!1);return}a(!0),l(null);try{const p=`${c}/projects/${e}/artifacts`,f=await Ne(p,{credentials:"include"});if(!f.ok){const h=await f.json().catch(()=>({message:`Failed to fetch project artifacts. ${f.statusText}`}));throw new Error(h.message||`Failed to fetch project artifacts. ${f.statusText}`)}const m=await f.json();r(m)}catch(p){const f=p instanceof Error?p.message:"Failed to fetch project artifacts.";l(f),r([])}finally{a(!1)}},[c,e]);return d.useEffect(()=>{u()},[u]),{artifacts:n,isLoading:o,error:i,refetch:u}},I_=({artifact:e,onDownload:t,onDelete:n})=>s.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-accent/50 rounded-md group",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[gm(e,"h-4 w-4 flex-shrink-0 text-muted-foreground"),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-medium text-foreground truncate",title:e.filename,children:e.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.last_modified&&s.jsx("span",{className:"truncate",title:qo(e.last_modified),children:qo(e.last_modified)}),e.size!==void 0&&s.jsxs(s.Fragment,{children:[e.last_modified&&s.jsx("span",{children:"•"}),s.jsx("span",{children:Ta(e.size)})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(te,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",tooltip:"Download",children:s.jsx(xo,{className:"h-4 w-4"})}),n&&s.jsx(te,{variant:"ghost",size:"sm",onClick:n,className:"h-8 w-8 p-0",tooltip:"Delete",children:s.jsx(Ea,{className:"h-4 w-4"})})]})]}),M_=({project:e})=>{const{artifacts:t,isLoading:n,error:r,refetch:o}=__(e.id),{addFilesToProject:a,removeFileFromProject:i}=Jn(),{onDownload:l}=dc(e.id),c=d.useRef(null),[u,p]=d.useState(null),[f,m]=d.useState(!1),[h,x]=d.useState(!1),g=jt.useMemo(()=>[...t].sort((S,N)=>{const k=S.last_modified?new Date(S.last_modified).getTime():0;return(N.last_modified?new Date(N.last_modified).getTime():0)-k}),[t]),w=()=>{var S;(S=c.current)==null||S.click()},v=S=>{const N=S.target.files;if(N&&N.length>0){const k=new DataTransfer;Array.from(N).forEach(M=>k.items.add(M)),p(k.files)}S.target&&(S.target.value="")},b=S=>{S.preventDefault(),S.stopPropagation(),x(!0)},y=S=>{S.preventDefault(),S.stopPropagation(),x(!1)},E=S=>{S.preventDefault(),S.stopPropagation(),x(!1);const N=S.dataTransfer.files;if(N&&N.length>0){const k=new DataTransfer;Array.from(N).forEach(M=>k.items.add(M)),p(k.files)}},T=async S=>{m(!0);try{await a(e.id,S),await o(),p(null)}catch(N){console.error("Failed to add files:",N)}finally{m(!1)}},C=async S=>{if(window.confirm(`Are you sure you want to delete ${S}?`))try{await i(e.id,S),await o()}catch(N){console.error(`Failed to delete file ${S}:`,N)}};return s.jsxs("div",{className:"border-b",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Knowledge"}),!n&&t.length>0&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",t.length,")"]})]}),s.jsxs(te,{variant:"ghost",size:"sm",onClick:w,children:[s.jsx(ri,{className:"h-4 w-4 mr-2"}),"Upload"]})]}),s.jsxs("div",{className:"px-4 pb-3",onDragOver:b,onDragLeave:y,onDrop:E,children:[n&&s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsx(Wn,{size:"small"})}),r&&s.jsxs("div",{className:"text-sm text-destructive p-3 border border-destructive/50 rounded-md",children:["Error loading files: ",r]}),!n&&!r&&t.length===0&&s.jsxs("div",{className:`flex flex-col items-center justify-center p-6 text-center border-2 border-dashed rounded-md transition-all ${h?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/30"}`,children:[s.jsx(ri,{className:`h-10 w-10 mb-3 transition-colors ${h?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`text-sm font-medium mb-1 transition-colors ${h?"text-primary":"text-foreground"}`,children:h?"Drop files here to upload":"Drag and drop files here"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"or click the Upload button above"})]}),!n&&!r&&t.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`mb-2 p-3 border-2 border-dashed rounded-md text-center transition-all ${h?"border-primary bg-primary/10 scale-[1.02]":"border-muted-foreground/20 bg-muted/30"}`,children:[s.jsx(ri,{className:`h-5 w-5 mx-auto mb-1 transition-colors ${h?"text-primary":"text-muted-foreground"}`}),s.jsx("p",{className:`text-xs transition-colors ${h?"text-primary font-medium":"text-muted-foreground"}`,children:h?"Drop files here to upload":"Drag and drop files here to upload"})]}),s.jsx("div",{className:"space-y-1 max-h-[400px] overflow-y-auto rounded-md",children:g.map(S=>s.jsx(I_,{artifact:S,onDownload:()=>l(S),onDelete:()=>C(S.filename)},S.filename))})]}),s.jsx("input",{type:"file",ref:c,onChange:v,className:"hidden",multiple:!0})]}),s.jsx(b_,{isOpen:!!u,files:u,onClose:()=>p(null),onConfirm:T,isSubmitting:f})]})},R_=({selectedProject:e})=>{const{updateProject:t}=Jn(),[n,r]=d.useState(!1),[o,a]=d.useState(null);if(!e)return s.jsx("div",{className:"flex h-full items-center justify-center bg-background border-l",children:s.jsx("p",{className:"text-sm text-muted-foreground px-4 text-center",children:"Select a project to view its details"})});const i=async c=>{r(!0),a(null);try{const u={systemPrompt:c};await t(e.id,u)}catch(u){console.error("Failed to update instructions:",u);const p=u instanceof Error?u.message:"Failed to update instructions";throw a(p),u}finally{r(!1)}},l=async c=>{r(!0);try{const u={defaultAgentId:c};await t(e.id,u)}catch(u){console.error("Failed to update default agent:",u)}finally{r(!1)}};return s.jsxs("div",{className:"flex h-full flex-col bg-background border-l overflow-y-auto",children:[s.jsx(A_,{project:e,onSave:i,isSaving:n,error:o}),s.jsx(T_,{project:e,onSave:l,isSaving:n}),s.jsx(M_,{project:e})]})},P_=({onProjectActivated:e})=>{const[t,n]=d.useState(!1),[r,o]=d.useState(!1),{projects:a,isLoading:i,error:l,createProject:c,deleteProject:u,selectedProject:p,setSelectedProject:f,setActiveProject:m,refetch:h}=Jn(),{handleSwitchSession:x,handleNewSession:g}=qe(),w=async T=>{o(!0);try{const C=new FormData;C.append("name",T.name),T.description&&C.append("description",T.description);const S=await c(C);n(!1),f(S)}finally{o(!1)}},v=T=>{f(T)},b=()=>{n(!0)},y=async T=>{await x(T),e()},E=async()=>{p&&(m(p),await g(!0),e(),setTimeout(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("focus-chat-input"))},150))};return d.useEffect(()=>{const T=C=>{const{projectId:S}=C.detail,N=a.find(k=>k.id===S);N&&f(N)};return window.addEventListener("navigate-to-project",T),()=>{window.removeEventListener("navigate-to-project",T)}},[a,f]),s.jsxs("div",{className:"flex h-full w-full flex-col",children:[s.jsx(Dc,{title:"Projects",buttons:[s.jsxs(te,{variant:"outline",onClick:b,className:"flex items-center gap-2",children:[s.jsx(oa,{className:"h-4 w-4"}),"Create Project"]},"create-project"),s.jsxs(te,{"data-testid":"refreshProjects",disabled:i,variant:"ghost",title:"Refresh Projects",onClick:()=>h(),children:[s.jsx(jl,{className:"size-4"}),"Refresh"]},"refresh-projects")]}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsxs(sm,{direction:"horizontal",className:"h-full",children:[s.jsx(Go,{defaultSize:20,minSize:15,maxSize:30,className:"min-w-[200px]",children:s.jsx(S_,{projects:a,selectedProject:p,isLoading:i,error:l,onProjectSelect:v,onCreateNew:b,onProjectDelete:u})}),s.jsx(Qi,{}),s.jsx(Go,{defaultSize:55,minSize:40,children:s.jsx(k_,{selectedProject:p,onCreateNew:b,onChatClick:y,onStartNewChat:E})}),s.jsx(Qi,{}),s.jsx(Go,{defaultSize:25,minSize:20,maxSize:40,children:s.jsx(R_,{selectedProject:p})})]})}),s.jsx(w_,{isOpen:t,onClose:()=>n(!1),onSubmit:w,isSubmitting:r})]})};function D_(){const[e,t]=d.useState("chat"),{isAuthenticated:n,login:r,useAuthorization:o}=WC(),{projectsEnabled:a}=_t();VC(),d.useEffect(()=>{const p=f=>{a&&!f.detail.handled&&(t("projects"),setTimeout(()=>{window.dispatchEvent(new CustomEvent("navigate-to-project",{detail:{...f.detail,handled:!0}}))},100))};return window.addEventListener("navigate-to-project",p),()=>{window.removeEventListener("navigate-to-project",p)}},[a]);const i=d.useMemo(()=>Nx(a??!1),[a]);if(o&&!n)return s.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:s.jsx(te,{onClick:r,children:"Login"})});const l=p=>{const f=i.find(m=>m.id===p)||ju.find(m=>m.id===p);f!=null&&f.onClick&&p!=="settings"?f.onClick():p!=="settings"&&t(p)},c=()=>{t("chat")},u=()=>{switch(e){case"chat":return s.jsx(ku,{});case"agentMesh":return s.jsx(h_,{});case"projects":return a?s.jsx(P_,{onProjectActivated:()=>t("chat")}):s.jsx(ku,{})}};return s.jsxs("div",{className:"relative flex h-screen",children:[s.jsx(c_,{items:i,bottomItems:ju,activeItem:e,onItemChange:l,onHeaderClick:c}),s.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:u()}),s.jsx(cN,{})]})}function L_(){return s.jsx(ON,{children:s.jsx(AN,{children:s.jsx(pN,{children:s.jsx(EN,{children:s.jsx(BC,{children:s.jsx(N0,{children:s.jsx(SN,{children:s.jsx(mN,{children:s.jsx(D_,{})})})})})})})})})}Ax.createRoot(document.getElementById("root")).render(s.jsx(d.StrictMode,{children:s.jsx(L_,{})}));