solace-agent-mesh 1.5.1__py3-none-any.whl → 1.6.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 (184) hide show
  1. solace_agent_mesh/agent/adk/callbacks.py +0 -5
  2. solace_agent_mesh/agent/adk/models/lite_llm.py +123 -8
  3. solace_agent_mesh/agent/adk/models/oauth2_token_manager.py +245 -0
  4. solace_agent_mesh/agent/protocol/event_handlers.py +213 -31
  5. solace_agent_mesh/agent/proxies/__init__.py +0 -0
  6. solace_agent_mesh/agent/proxies/a2a/__init__.py +3 -0
  7. solace_agent_mesh/agent/proxies/a2a/app.py +55 -0
  8. solace_agent_mesh/agent/proxies/a2a/component.py +1115 -0
  9. solace_agent_mesh/agent/proxies/a2a/config.py +140 -0
  10. solace_agent_mesh/agent/proxies/a2a/oauth_token_cache.py +104 -0
  11. solace_agent_mesh/agent/proxies/base/__init__.py +3 -0
  12. solace_agent_mesh/agent/proxies/base/app.py +99 -0
  13. solace_agent_mesh/agent/proxies/base/component.py +650 -0
  14. solace_agent_mesh/agent/proxies/base/config.py +85 -0
  15. solace_agent_mesh/agent/proxies/base/proxy_task_context.py +17 -0
  16. solace_agent_mesh/agent/sac/app.py +58 -5
  17. solace_agent_mesh/agent/sac/component.py +238 -75
  18. solace_agent_mesh/agent/sac/task_execution_context.py +46 -0
  19. solace_agent_mesh/agent/tools/audio_tools.py +125 -8
  20. solace_agent_mesh/agent/tools/web_tools.py +10 -5
  21. solace_agent_mesh/agent/utils/artifact_helpers.py +141 -3
  22. solace_agent_mesh/assets/docs/404.html +3 -3
  23. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.eda4bcb2.js +1 -0
  24. solace_agent_mesh/assets/docs/assets/js/6ad8f0bd.f4b15f3b.js +1 -0
  25. solace_agent_mesh/assets/docs/assets/js/71da7b71.38583438.js +1 -0
  26. solace_agent_mesh/assets/docs/assets/js/77cf947d.48cb18a2.js +1 -0
  27. solace_agent_mesh/assets/docs/assets/js/924ffdeb.8095e148.js +1 -0
  28. solace_agent_mesh/assets/docs/assets/js/9e9d0a82.570c057b.js +1 -0
  29. solace_agent_mesh/assets/docs/assets/js/{ad71b5ed.60668e9e.js → ad71b5ed.af3ecfd1.js} +1 -1
  30. solace_agent_mesh/assets/docs/assets/js/ceb2a7a6.5d92d7d0.js +1 -0
  31. solace_agent_mesh/assets/docs/assets/js/{da0b5bad.9d369087.js → da0b5bad.d08a9466.js} +1 -1
  32. solace_agent_mesh/assets/docs/assets/js/db924877.e98d12a1.js +1 -0
  33. solace_agent_mesh/assets/docs/assets/js/de915948.27d6b065.js +1 -0
  34. solace_agent_mesh/assets/docs/assets/js/{e3d9abda.2b916f9e.js → e3d9abda.6b9493d0.js} +1 -1
  35. solace_agent_mesh/assets/docs/assets/js/e6f9706b.e74a984d.js +1 -0
  36. solace_agent_mesh/assets/docs/assets/js/f284c35a.42f59cdd.js +1 -0
  37. solace_agent_mesh/assets/docs/assets/js/ff4d71f2.15b02f97.js +1 -0
  38. solace_agent_mesh/assets/docs/assets/js/{main.bd3c34f3.js → main.b12eac43.js} +2 -2
  39. solace_agent_mesh/assets/docs/assets/js/runtime~main.e268214e.js +1 -0
  40. solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +15 -4
  41. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/artifact-management/index.html +4 -4
  42. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/audio-tools/index.html +4 -4
  43. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/data-analysis-tools/index.html +4 -4
  44. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/embeds/index.html +4 -4
  45. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/index.html +4 -4
  46. solace_agent_mesh/assets/docs/docs/documentation/components/cli/index.html +4 -4
  47. solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +4 -4
  48. solace_agent_mesh/assets/docs/docs/documentation/components/index.html +4 -4
  49. solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +4 -4
  50. solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +4 -4
  51. solace_agent_mesh/assets/docs/docs/documentation/components/proxies/index.html +262 -0
  52. solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +3 -3
  53. solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +31 -3
  54. solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +3 -3
  55. solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +3 -3
  56. solace_agent_mesh/assets/docs/docs/documentation/developing/create-agents/index.html +4 -4
  57. solace_agent_mesh/assets/docs/docs/documentation/developing/create-gateways/index.html +5 -5
  58. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-python-tools/index.html +4 -4
  59. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +4 -4
  60. solace_agent_mesh/assets/docs/docs/documentation/developing/evaluations/index.html +135 -0
  61. solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +6 -4
  62. solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +4 -4
  63. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/bedrock-agents/index.html +4 -4
  64. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/custom-agent/index.html +4 -4
  65. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/event-mesh-gateway/index.html +5 -5
  66. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mcp-integration/index.html +4 -4
  67. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mongodb-integration/index.html +4 -4
  68. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rag-integration/index.html +4 -4
  69. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rest-gateway/index.html +4 -4
  70. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +4 -4
  71. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/sql-database/index.html +4 -4
  72. solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +3 -3
  73. solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +3 -3
  74. solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +3 -3
  75. solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +3 -3
  76. solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +3 -3
  77. solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +3 -3
  78. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +3 -3
  79. solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +3 -3
  80. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/configurations/index.html +6 -5
  81. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +3 -3
  82. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +3 -3
  83. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +100 -3
  84. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +3 -3
  85. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +3 -3
  86. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-technical-migration-map/index.html +3 -3
  87. solace_agent_mesh/assets/docs/lunr-index-1761248203150.json +1 -0
  88. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  89. solace_agent_mesh/assets/docs/search-doc-1761248203150.json +1 -0
  90. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  91. solace_agent_mesh/assets/docs/sitemap.xml +1 -1
  92. solace_agent_mesh/cli/__init__.py +1 -1
  93. solace_agent_mesh/cli/commands/add_cmd/agent_cmd.py +2 -69
  94. solace_agent_mesh/cli/commands/eval_cmd.py +11 -49
  95. solace_agent_mesh/cli/commands/init_cmd/__init__.py +0 -5
  96. solace_agent_mesh/cli/commands/init_cmd/env_step.py +10 -12
  97. solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +9 -61
  98. solace_agent_mesh/cli/commands/init_cmd/webui_gateway_step.py +9 -49
  99. solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +1 -2
  100. solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-DwrxZE0E.js → authCallback-BTf6dqwp.js} +1 -1
  101. solace_agent_mesh/client/webui/frontend/static/assets/{client-DarGQzyw.js → client-CaY59VuC.js} +1 -1
  102. solace_agent_mesh/client/webui/frontend/static/assets/main-B32noGmR.js +342 -0
  103. solace_agent_mesh/client/webui/frontend/static/assets/main-DHJKSW1S.css +1 -0
  104. solace_agent_mesh/client/webui/frontend/static/assets/{vendor-BKIeiHj_.js → vendor-BEmvJSYz.js} +1 -1
  105. solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
  106. solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
  107. solace_agent_mesh/common/a2a/__init__.py +24 -0
  108. solace_agent_mesh/common/a2a/artifact.py +39 -0
  109. solace_agent_mesh/common/a2a/events.py +29 -0
  110. solace_agent_mesh/common/a2a/message.py +68 -0
  111. solace_agent_mesh/common/a2a/protocol.py +151 -1
  112. solace_agent_mesh/common/agent_registry.py +83 -3
  113. solace_agent_mesh/common/constants.py +3 -1
  114. solace_agent_mesh/common/sac/sam_component_base.py +383 -4
  115. solace_agent_mesh/common/utils/pydantic_utils.py +12 -0
  116. solace_agent_mesh/config_portal/backend/common.py +1 -1
  117. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-ByU1X1HD.js +98 -0
  118. solace_agent_mesh/config_portal/frontend/static/client/assets/{manifest-44d62be6.js → manifest-61038fc6.js} +1 -1
  119. solace_agent_mesh/config_portal/frontend/static/client/index.html +1 -1
  120. solace_agent_mesh/evaluation/evaluator.py +128 -104
  121. solace_agent_mesh/evaluation/message_organizer.py +116 -110
  122. solace_agent_mesh/evaluation/report_data_processor.py +84 -86
  123. solace_agent_mesh/evaluation/report_generator.py +73 -79
  124. solace_agent_mesh/evaluation/run.py +421 -235
  125. solace_agent_mesh/evaluation/shared/__init__.py +92 -0
  126. solace_agent_mesh/evaluation/shared/constants.py +47 -0
  127. solace_agent_mesh/evaluation/shared/exceptions.py +50 -0
  128. solace_agent_mesh/evaluation/shared/helpers.py +35 -0
  129. solace_agent_mesh/evaluation/shared/test_case_loader.py +167 -0
  130. solace_agent_mesh/evaluation/shared/test_suite_loader.py +280 -0
  131. solace_agent_mesh/evaluation/subscriber.py +111 -232
  132. solace_agent_mesh/evaluation/summary_builder.py +227 -117
  133. solace_agent_mesh/gateway/base/app.py +16 -1
  134. solace_agent_mesh/gateway/base/component.py +112 -39
  135. solace_agent_mesh/gateway/http_sse/alembic/versions/20251015_add_session_performance_indexes.py +70 -0
  136. solace_agent_mesh/gateway/http_sse/component.py +99 -3
  137. solace_agent_mesh/gateway/http_sse/dependencies.py +4 -4
  138. solace_agent_mesh/gateway/http_sse/main.py +1 -0
  139. solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +12 -13
  140. solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +15 -18
  141. solace_agent_mesh/gateway/http_sse/repository/interfaces.py +25 -18
  142. solace_agent_mesh/gateway/http_sse/repository/session_repository.py +30 -26
  143. solace_agent_mesh/gateway/http_sse/repository/task_repository.py +35 -44
  144. solace_agent_mesh/gateway/http_sse/routers/agent_cards.py +4 -3
  145. solace_agent_mesh/gateway/http_sse/routers/artifacts.py +95 -203
  146. solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +4 -3
  147. solace_agent_mesh/gateway/http_sse/routers/sessions.py +2 -2
  148. solace_agent_mesh/gateway/http_sse/routers/tasks.py +33 -41
  149. solace_agent_mesh/gateway/http_sse/routers/users.py +47 -1
  150. solace_agent_mesh/gateway/http_sse/routers/visualization.py +17 -11
  151. solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +4 -4
  152. solace_agent_mesh/gateway/http_sse/services/feedback_service.py +51 -43
  153. solace_agent_mesh/gateway/http_sse/services/session_service.py +20 -20
  154. solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +8 -8
  155. solace_agent_mesh/gateway/http_sse/shared/base_repository.py +45 -71
  156. solace_agent_mesh/gateway/http_sse/shared/types.py +0 -18
  157. solace_agent_mesh/templates/gateway_config_template.yaml +0 -5
  158. solace_agent_mesh/templates/logging_config_template.ini +10 -6
  159. solace_agent_mesh/templates/plugin_gateway_config_template.yaml +0 -3
  160. solace_agent_mesh/templates/shared_config.yaml +40 -0
  161. {solace_agent_mesh-1.5.1.dist-info → solace_agent_mesh-1.6.1.dist-info}/METADATA +47 -21
  162. {solace_agent_mesh-1.5.1.dist-info → solace_agent_mesh-1.6.1.dist-info}/RECORD +166 -145
  163. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.e49689dd.js +0 -1
  164. solace_agent_mesh/assets/docs/assets/js/6ad8f0bd.39d5851d.js +0 -1
  165. solace_agent_mesh/assets/docs/assets/js/71da7b71.804d6567.js +0 -1
  166. solace_agent_mesh/assets/docs/assets/js/77cf947d.64c9bd6c.js +0 -1
  167. solace_agent_mesh/assets/docs/assets/js/9e9d0a82.dd810042.js +0 -1
  168. solace_agent_mesh/assets/docs/assets/js/db924877.cbc66f02.js +0 -1
  169. solace_agent_mesh/assets/docs/assets/js/de915948.139b4b9c.js +0 -1
  170. solace_agent_mesh/assets/docs/assets/js/e6f9706b.582a78ca.js +0 -1
  171. solace_agent_mesh/assets/docs/assets/js/f284c35a.5766a13d.js +0 -1
  172. solace_agent_mesh/assets/docs/assets/js/ff4d71f2.9c0297a6.js +0 -1
  173. solace_agent_mesh/assets/docs/assets/js/runtime~main.18dc45dd.js +0 -1
  174. solace_agent_mesh/assets/docs/lunr-index-1760121512891.json +0 -1
  175. solace_agent_mesh/assets/docs/search-doc-1760121512891.json +0 -1
  176. solace_agent_mesh/client/webui/frontend/static/assets/main-2nd1gbaH.js +0 -339
  177. solace_agent_mesh/client/webui/frontend/static/assets/main-DoKXctCM.css +0 -1
  178. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-BNuqpWDc.js +0 -98
  179. solace_agent_mesh/evaluation/config_loader.py +0 -657
  180. solace_agent_mesh/evaluation/test_case_loader.py +0 -714
  181. /solace_agent_mesh/assets/docs/assets/js/{main.bd3c34f3.js.LICENSE.txt → main.b12eac43.js.LICENSE.txt} +0 -0
  182. {solace_agent_mesh-1.5.1.dist-info → solace_agent_mesh-1.6.1.dist-info}/WHEEL +0 -0
  183. {solace_agent_mesh-1.5.1.dist-info → solace_agent_mesh-1.6.1.dist-info}/entry_points.txt +0 -0
  184. {solace_agent_mesh-1.5.1.dist-info → solace_agent_mesh-1.6.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,339 +0,0 @@
1
- var zp=Object.defineProperty;var $p=(e,t,n)=>t in e?zp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ga=(e,t,n)=>$p(e,typeof t!="symbol"?t+"":t,n);import{c as Bp}from"./client-DarGQzyw.js";import{r as u,j as a,c as ql,a as Kr,R as Ci,b as Up,N as Ao,X as Vo,E as Hp,d as Yt,C as Xl,e as Ei,f as Wp,A as Zl,L as Ti,g as Ai,P as Jl,B as Gp,S as Vp,F as xa,h as Yp,i as Kp,k as pr,l as qp,m as Xp,n as Zp,o as Ql,D as Yo,p as ec,T as Jp,q as Qp,s as em,t as tm,M as tc,I as ki,u as nc,v as nm,w as rm,x as om,y as rc,z as sm,G as oc,H as im,J as am,K as va,O as lm,Q as sc,U as ic,V as cm,W as lt,Y as ct,Z as ac,_ as um,$ as dm,a0 as wa,a1 as ba,a2 as xs,a3 as fm,a4 as pm,a5 as mm,a6 as hm,a7 as gm,a8 as xm,a9 as vm,aa as wm,ab as bm,ac as ym,ad as Sm,ae as lc,af as cc,ag as Cm,ah as ya,ai as Sa,aj as Em,ak as Ca,al as Tm,am as Am,an as km}from"./vendor-BKIeiHj_.js";function Ea(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function uc(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ea(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Ea(e[o],null)}}}}function ze(...e){return u.useCallback(uc(...e),e)}function Un(e){const t=Nm(e),n=u.forwardRef((r,o)=>{const{children:s,...i}=r,l=u.Children.toArray(s),c=l.find(Im);if(c){const d=c.props.children,f=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return a.jsx(t,{...i,ref:o,children:u.isValidElement(d)?u.cloneElement(d,void 0,f):null})}return a.jsx(t,{...i,ref:o,children:s})});return n.displayName=`${e}.Slot`,n}var dc=Un("Slot");function Nm(e){const t=u.forwardRef((n,r)=>{const{children:o,...s}=n;if(u.isValidElement(o)){const i=Mm(o),l=jm(s,o.props);return o.type!==u.Fragment&&(l.ref=r?uc(r,i):i),u.cloneElement(o,l)}return u.Children.count(o)>1?u.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fc=Symbol("radix.slottable");function _m(e){const t=({children:n})=>a.jsx(a.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=fc,t}function Im(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fc}function jm(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...l)=>{const c=s(...l);return o(...l),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Mm(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 Ta=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Aa=ql,Rn=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Aa(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(d=>{const f=n==null?void 0:n[d],p=s==null?void 0:s[d];if(f===null)return null;const m=Ta(f)||Ta(p);return o[d][m]}),l=n&&Object.entries(n).reduce((d,f)=>{let[p,m]=f;return m===void 0||(d[p]=m),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:p,className:m,...h}=f;return Object.entries(h).every(x=>{let[g,v]=x;return Array.isArray(v)?v.includes({...s,...l}[g]):{...s,...l}[g]===v})?[...d,p,m]:d},[]);return Aa(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},Ni=()=>localStorage.getItem("access_token"),Rm=()=>localStorage.getItem("refresh_token"),Pm=(e,t)=>{localStorage.setItem("access_token",e),localStorage.setItem("refresh_token",t)},Lm=()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")},Dm=async()=>{const e=Rm();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 Pm(n.access_token,n.refresh_token),n.access_token}return Lm(),window.location.href="/api/v1/auth/login",null},Pe=async(e,t={})=>{const n=Ni();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 Dm();if(o)return fetch(e,{...t,headers:{...t.headers,Authorization:`Bearer ${o}`}})}return r},Om=async e=>{const t=await Pe("/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()},_i="-",Fm=e=>{const t=$m(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const l=i.split(_i);return l[0]===""&&l.length!==1&&l.shift(),pc(l,t)||zm(i)},getConflictingClassGroupIds:(i,l)=>{const c=n[i]||[];return l&&r[i]?[...c,...r[i]]:c}}},pc=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?pc(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const s=e.join(_i);return(i=t.validators.find(({validator:l})=>l(s)))==null?void 0:i.classGroupId},ka=/^\[(.+)\]$/,zm=e=>{if(ka.test(e)){const t=ka.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},$m=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const o in n)Vs(n[o],r,o,t);return r},Vs=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const s=o===""?t:Na(t,o);s.classGroupId=n;return}if(typeof o=="function"){if(Bm(o)){Vs(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([s,i])=>{Vs(i,Na(t,s),n,r)})})},Na=(e,t)=>{let n=e;return t.split(_i).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Bm=e=>e.isThemeGetter,Um=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=r.get(s))!==void 0)return o(s,i),i},set(s,i){n.has(s)?n.set(s,i):o(s,i)}}},Ys="!",Ks=":",Hm=Ks.length,Wm=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const s=[];let i=0,l=0,c=0,d;for(let x=0;x<o.length;x++){let g=o[x];if(i===0&&l===0){if(g===Ks){s.push(o.slice(c,x)),c=x+Hm;continue}if(g==="/"){d=x;continue}}g==="["?i++:g==="]"?i--:g==="("?l++:g===")"&&l--}const f=s.length===0?o:o.substring(c),p=Gm(f),m=p!==f,h=d&&d>c?d-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const o=t+Ks,s=r;r=i=>i.startsWith(o)?s(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},Gm=e=>e.endsWith(Ys)?e.substring(0,e.length-1):e.startsWith(Ys)?e.substring(1):e,Vm=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const o=[];let s=[];return r.forEach(i=>{i[0]==="["||t[i]?(o.push(...s.sort(),i),s=[]):s.push(i)}),o.push(...s.sort()),o}},Ym=e=>({cache:Um(e.cacheSize),parseClassName:Wm(e),sortModifiers:Vm(e),...Fm(e)}),Km=/\s+/,qm=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],l=e.trim().split(Km);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:p,modifiers:m,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:g}=n(f);if(p){c=f+(c.length>0?" "+c:c);continue}let v=!!g,b=r(v?x.substring(0,g):x);if(!b){if(!v){c=f+(c.length>0?" "+c:c);continue}if(b=r(x),!b){c=f+(c.length>0?" "+c:c);continue}v=!1}const w=s(m).join(":"),y=h?w+Ys:w,E=y+b;if(i.includes(E))continue;i.push(E);const T=o(b,v);for(let j=0;j<T.length;++j){const k=T[j];i.push(y+k)}c=f+(c.length>0?" "+c:c)}return c};function Xm(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=mc(t))&&(r&&(r+=" "),r+=n);return r}const mc=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=mc(e[r]))&&(n&&(n+=" "),n+=t);return n};function Zm(e,...t){let n,r,o,s=i;function i(c){const d=t.reduce((f,p)=>p(f),e());return n=Ym(d),r=n.cache.get,o=n.cache.set,s=l,l(c)}function l(c){const d=r(c);if(d)return d;const f=qm(c,n);return o(c,f),f}return function(){return s(Xm.apply(null,arguments))}}const Ze=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},hc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,gc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Jm=/^\d+\/\d+$/,Qm=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eh=/\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$/,th=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nh=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Jn=e=>Jm.test(e),Ee=e=>!!e&&!Number.isNaN(Number(e)),En=e=>!!e&&Number.isInteger(Number(e)),vs=e=>e.endsWith("%")&&Ee(e.slice(0,-1)),gn=e=>Qm.test(e),oh=()=>!0,sh=e=>eh.test(e)&&!th.test(e),xc=()=>!1,ih=e=>nh.test(e),ah=e=>rh.test(e),lh=e=>!re(e)&&!oe(e),ch=e=>yr(e,bc,xc),re=e=>hc.test(e),Fn=e=>yr(e,yc,sh),ws=e=>yr(e,mh,Ee),_a=e=>yr(e,vc,xc),uh=e=>yr(e,wc,ah),lo=e=>yr(e,Sc,ih),oe=e=>gc.test(e),kr=e=>Sr(e,yc),dh=e=>Sr(e,hh),Ia=e=>Sr(e,vc),fh=e=>Sr(e,bc),ph=e=>Sr(e,wc),co=e=>Sr(e,Sc,!0),yr=(e,t,n)=>{const r=hc.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Sr=(e,t,n=!1)=>{const r=gc.exec(e);return r?r[1]?t(r[1]):n:!1},vc=e=>e==="position"||e==="percentage",wc=e=>e==="image"||e==="url",bc=e=>e==="length"||e==="size"||e==="bg-size",yc=e=>e==="length",mh=e=>e==="number",hh=e=>e==="family-name",Sc=e=>e==="shadow",gh=()=>{const e=Ze("color"),t=Ze("font"),n=Ze("text"),r=Ze("font-weight"),o=Ze("tracking"),s=Ze("leading"),i=Ze("breakpoint"),l=Ze("container"),c=Ze("spacing"),d=Ze("radius"),f=Ze("shadow"),p=Ze("inset-shadow"),m=Ze("text-shadow"),h=Ze("drop-shadow"),x=Ze("blur"),g=Ze("perspective"),v=Ze("aspect"),b=Ze("ease"),w=Ze("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(),oe,re],j=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],_=()=>[oe,re,c],G=()=>[Jn,"full","auto",..._()],U=()=>[En,"none","subgrid",oe,re],B=()=>["auto",{span:["full",En,oe,re]},En,oe,re],Z=()=>[En,"auto",oe,re],J=()=>["auto","min","max","fr",oe,re],D=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",..._()],Y=()=>[Jn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],C=()=>[e,oe,re],I=()=>[...E(),Ia,_a,{position:[oe,re]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],R=()=>["auto","cover","contain",fh,ch,{size:[oe,re]}],Q=()=>[vs,kr,Fn],O=()=>["","none","full",d,oe,re],W=()=>["",Ee,kr,Fn],z=()=>["solid","dashed","dotted","double"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],N=()=>[Ee,vs,Ia,_a],K=()=>["","none",x,oe,re],ee=()=>["none",Ee,oe,re],te=()=>["none",Ee,oe,re],le=()=>[Ee,oe,re],ne=()=>[Jn,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[gn],breakpoint:[gn],color:[oh],container:[gn],"drop-shadow":[gn],ease:["in","out","in-out"],font:[lh],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[gn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[gn],shadow:[gn],spacing:["px",Ee],text:[gn],"text-shadow":[gn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Jn,re,oe,v]}],container:["container"],columns:[{columns:[Ee,re,oe,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:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:G()}],"inset-x":[{"inset-x":G()}],"inset-y":[{"inset-y":G()}],start:[{start:G()}],end:[{end:G()}],top:[{top:G()}],right:[{right:G()}],bottom:[{bottom:G()}],left:[{left:G()}],visibility:["visible","invisible","collapse"],z:[{z:[En,"auto",oe,re]}],basis:[{basis:[Jn,"full","auto",l,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ee,Jn,"auto","initial","none",re]}],grow:[{grow:["",Ee,oe,re]}],shrink:[{shrink:["",Ee,oe,re]}],order:[{order:[En,"first","last","none",oe,re]}],"grid-cols":[{"grid-cols":U()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":Z()}],"col-end":[{"col-end":Z()}],"grid-rows":[{"grid-rows":U()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":Z()}],"row-end":[{"row-end":Z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...D(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...D()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":D()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],w:[{w:[l,"screen",...Y()]}],"min-w":[{"min-w":[l,"screen","none",...Y()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",n,kr,Fn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,oe,ws]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vs,re]}],"font-family":[{font:[dh,re,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,oe,re]}],"line-clamp":[{"line-clamp":[Ee,"none",oe,ws]}],leading:[{leading:[s,..._()]}],"list-image":[{"list-image":["none",oe,re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",oe,re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:C()}],"text-color":[{text:C()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...z(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ee,"from-font","auto",oe,Fn]}],"text-decoration-color":[{decoration:C()}],"underline-offset":[{"underline-offset":[Ee,"auto",oe,re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",oe,re]}],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",oe,re]}],"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:F()}],"bg-size":[{bg:R()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},En,oe,re],radial:["",oe,re],conic:[En,oe,re]},ph,uh]}],"bg-color":[{bg:C()}],"gradient-from-pos":[{from:Q()}],"gradient-via-pos":[{via:Q()}],"gradient-to-pos":[{to:Q()}],"gradient-from":[{from:C()}],"gradient-via":[{via:C()}],"gradient-to":[{to:C()}],rounded:[{rounded:O()}],"rounded-s":[{"rounded-s":O()}],"rounded-e":[{"rounded-e":O()}],"rounded-t":[{"rounded-t":O()}],"rounded-r":[{"rounded-r":O()}],"rounded-b":[{"rounded-b":O()}],"rounded-l":[{"rounded-l":O()}],"rounded-ss":[{"rounded-ss":O()}],"rounded-se":[{"rounded-se":O()}],"rounded-ee":[{"rounded-ee":O()}],"rounded-es":[{"rounded-es":O()}],"rounded-tl":[{"rounded-tl":O()}],"rounded-tr":[{"rounded-tr":O()}],"rounded-br":[{"rounded-br":O()}],"rounded-bl":[{"rounded-bl":O()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...z(),"hidden","none"]}],"divide-style":[{divide:[...z(),"hidden","none"]}],"border-color":[{border:C()}],"border-color-x":[{"border-x":C()}],"border-color-y":[{"border-y":C()}],"border-color-s":[{"border-s":C()}],"border-color-e":[{"border-e":C()}],"border-color-t":[{"border-t":C()}],"border-color-r":[{"border-r":C()}],"border-color-b":[{"border-b":C()}],"border-color-l":[{"border-l":C()}],"divide-color":[{divide:C()}],"outline-style":[{outline:[...z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ee,oe,re]}],"outline-w":[{outline:["",Ee,kr,Fn]}],"outline-color":[{outline:C()}],shadow:[{shadow:["","none",f,co,lo]}],"shadow-color":[{shadow:C()}],"inset-shadow":[{"inset-shadow":["none",p,co,lo]}],"inset-shadow-color":[{"inset-shadow":C()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:C()}],"ring-offset-w":[{"ring-offset":[Ee,Fn]}],"ring-offset-color":[{"ring-offset":C()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":C()}],"text-shadow":[{"text-shadow":["none",m,co,lo]}],"text-shadow-color":[{"text-shadow":C()}],opacity:[{opacity:[Ee,oe,re]}],"mix-blend":[{"mix-blend":[...q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":q()}],"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":[Ee]}],"mask-image-linear-from-pos":[{"mask-linear-from":N()}],"mask-image-linear-to-pos":[{"mask-linear-to":N()}],"mask-image-linear-from-color":[{"mask-linear-from":C()}],"mask-image-linear-to-color":[{"mask-linear-to":C()}],"mask-image-t-from-pos":[{"mask-t-from":N()}],"mask-image-t-to-pos":[{"mask-t-to":N()}],"mask-image-t-from-color":[{"mask-t-from":C()}],"mask-image-t-to-color":[{"mask-t-to":C()}],"mask-image-r-from-pos":[{"mask-r-from":N()}],"mask-image-r-to-pos":[{"mask-r-to":N()}],"mask-image-r-from-color":[{"mask-r-from":C()}],"mask-image-r-to-color":[{"mask-r-to":C()}],"mask-image-b-from-pos":[{"mask-b-from":N()}],"mask-image-b-to-pos":[{"mask-b-to":N()}],"mask-image-b-from-color":[{"mask-b-from":C()}],"mask-image-b-to-color":[{"mask-b-to":C()}],"mask-image-l-from-pos":[{"mask-l-from":N()}],"mask-image-l-to-pos":[{"mask-l-to":N()}],"mask-image-l-from-color":[{"mask-l-from":C()}],"mask-image-l-to-color":[{"mask-l-to":C()}],"mask-image-x-from-pos":[{"mask-x-from":N()}],"mask-image-x-to-pos":[{"mask-x-to":N()}],"mask-image-x-from-color":[{"mask-x-from":C()}],"mask-image-x-to-color":[{"mask-x-to":C()}],"mask-image-y-from-pos":[{"mask-y-from":N()}],"mask-image-y-to-pos":[{"mask-y-to":N()}],"mask-image-y-from-color":[{"mask-y-from":C()}],"mask-image-y-to-color":[{"mask-y-to":C()}],"mask-image-radial":[{"mask-radial":[oe,re]}],"mask-image-radial-from-pos":[{"mask-radial-from":N()}],"mask-image-radial-to-pos":[{"mask-radial-to":N()}],"mask-image-radial-from-color":[{"mask-radial-from":C()}],"mask-image-radial-to-color":[{"mask-radial-to":C()}],"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":[Ee]}],"mask-image-conic-from-pos":[{"mask-conic-from":N()}],"mask-image-conic-to-pos":[{"mask-conic-to":N()}],"mask-image-conic-from-color":[{"mask-conic-from":C()}],"mask-image-conic-to-color":[{"mask-conic-to":C()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:I()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:R()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",oe,re]}],filter:[{filter:["","none",oe,re]}],blur:[{blur:K()}],brightness:[{brightness:[Ee,oe,re]}],contrast:[{contrast:[Ee,oe,re]}],"drop-shadow":[{"drop-shadow":["","none",h,co,lo]}],"drop-shadow-color":[{"drop-shadow":C()}],grayscale:[{grayscale:["",Ee,oe,re]}],"hue-rotate":[{"hue-rotate":[Ee,oe,re]}],invert:[{invert:["",Ee,oe,re]}],saturate:[{saturate:[Ee,oe,re]}],sepia:[{sepia:["",Ee,oe,re]}],"backdrop-filter":[{"backdrop-filter":["","none",oe,re]}],"backdrop-blur":[{"backdrop-blur":K()}],"backdrop-brightness":[{"backdrop-brightness":[Ee,oe,re]}],"backdrop-contrast":[{"backdrop-contrast":[Ee,oe,re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ee,oe,re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ee,oe,re]}],"backdrop-invert":[{"backdrop-invert":["",Ee,oe,re]}],"backdrop-opacity":[{"backdrop-opacity":[Ee,oe,re]}],"backdrop-saturate":[{"backdrop-saturate":[Ee,oe,re]}],"backdrop-sepia":[{"backdrop-sepia":["",Ee,oe,re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",oe,re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ee,"initial",oe,re]}],ease:[{ease:["linear","initial",b,oe,re]}],delay:[{delay:[Ee,oe,re]}],animate:[{animate:["none",w,oe,re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,oe,re]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:le()}],"skew-x":[{"skew-x":le()}],"skew-y":[{"skew-y":le()}],transform:[{transform:[oe,re,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ne()}],"translate-x":[{"translate-x":ne()}],"translate-y":[{"translate-y":ne()}],"translate-z":[{"translate-z":ne()}],"translate-none":["translate-none"],accent:[{accent:C()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:C()}],"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",oe,re]}],"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":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"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",oe,re]}],fill:[{fill:["none",...C()]}],"stroke-w":[{stroke:[Ee,kr,Fn,ws]}],stroke:[{stroke:["none",...C()]}],"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"]}},xh=Zm(gh);function ve(...e){return xh(ql(e))}const vh=e=>{try{const t=new URL(e);if(t.protocol!=="artifact:")return null;const n=t.pathname.split("/").filter(s=>s),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}},Cc=(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)}},wh=async e=>{try{let t,n=e.name;if(e.content){const r=atob(e.content),o=new Array(r.length);for(let i=0;i<r.length;i++)o[i]=r.charCodeAt(i);const s=new Uint8Array(o);t=new Blob([s],{type:e.mime_type||"application/octet-stream"})}else if(e.uri){const r=vh(e.uri);if(!r)throw new Error(`Invalid or unhandled URI format: ${e.uri}`);n=r.filename;const o=r.version||"latest",s=`/api/v1/artifacts/${encodeURIComponent(n)}/versions/${o}`,i=await Pe(s,{credentials:"include"});if(!i.ok)throw new Error(`Failed to download file: ${i.statusText}`);t=await i.blob()}else throw new Error("File has no content or URI to download.");Cc(t,n)}catch(t){console.error("Error creating download link:",t)}},Ec=(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"],s=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,s)).toFixed(r))+" "+o[s]},ja=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),s=Math.floor(o/60),i=Math.floor(s/24);return r<60?`${r}s ago`:o<60?`${o}m ago`:s<24?`${s}h ago`:i===1?"Yesterday":i<7?`${i}d ago`:t.toLocaleDateString()}catch(t){return console.error("Error formatting date:",t),"Invalid date"}},bh=e=>{if(!e)return"N/A";try{const t=new Date(e);return isNaN(t.getTime())?"N/A":t.toLocaleString()}catch{return"N/A"}},Ma=(e="")=>`
2
- whitespace-normal
3
- break-words
4
- leading-[24px]
5
-
6
- /* Typography */
7
- [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:mb-4 [&_h1]:mt-6 [&_h1]:text-foreground
8
- [&_h2]:text-xl [&_h2]:font-bold [&_h2]:mb-3 [&_h2]:mt-5 [&_h2]:text-foreground
9
- [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:mb-2 [&_h3]:mt-4 [&_h3]:text-foreground
10
- [&_h4]:text-base [&_h4]:font-semibold [&_h4]:mb-2 [&_h4]:mt-3 [&_h4]:text-foreground
11
- [&_h5]:text-sm [&_h5]:font-semibold [&_h5]:mb-1 [&_h5]:mt-2 [&_h5]:text-foreground
12
- [&_h6]:text-xs [&_h6]:font-semibold [&_h6]:mb-1 [&_h6]:mt-2 [&_h6]:text-foreground
13
-
14
- /* Paragraphs */
15
- [&_p]:mb-2 [&_p]:leading-[24px] [&_p]:text-foreground
16
-
17
- /* Text formatting */
18
- [&_strong]:font-semibold [&_strong]:text-foreground
19
- [&_em]:italic
20
- [&_del]:line-through [&_del]:text-foreground
21
-
22
- /* Links */
23
- [&_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)]
24
- [&_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)]
25
-
26
- /* Lists */
27
- [&_ul]:mb-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1
28
- [&_ol]:mb-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1
29
- [&_li]:text-foreground [&_li]:leading-[24px]
30
- [&_ul_ul]:mt-1 [&_ul_ul]:mb-1
31
- [&_ol_ol]:mt-1 [&_ol_ol]:mb-1
32
-
33
- /* Code */
34
- [&_code]:bg-transparent [&_code]:py-0.5 [&_code]:rounded
35
- [&_code]:text-sm [&_code]:font-mono [&_code]:font-semibold [&_code]:text-foreground [&_code]:break-words
36
- [&_pre]:bg-transparent [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:overflow-x-auto [&_pre]:max-w-full
37
- [&_pre]:mb-4 [&_pre]:border [&_pre]:border-border [&_pre]:whitespace-pre-wrap
38
- [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-sm [&_pre_code]:break-words
39
-
40
- /* Blockquotes */
41
- [&_blockquote]:border-l-4 [&_blockquote]:border-border [&_blockquote]:pl-4
42
- [&_blockquote]:py-2 [&_blockquote]:mb-4 [&_blockquote]:italic
43
- [&_blockquote]:text-foreground [&_blockquote]:bg-transparent
44
-
45
- /* Tables */
46
- [&_table]:w-full [&_table]:mb-4 [&_table]:border-collapse [&_table]:table-fixed [&_table]:max-w-full
47
- [&_th]:border [&_th]:border-border [&_th]:px-3 [&_th]:py-2 [&_th]:break-words
48
- [&_th]:bg-transparent [&_th]:font-semibold [&_th]:text-left
49
- [&_td]:border [&_td]:border-border [&_td]:px-3 [&_td]:py-2 [&_td]:break-words
50
- [&_tr:nth-child(even)]:bg-transparent
51
-
52
- /* Horizontal rules */
53
- [&_hr]:border-0 [&_hr]:border-t [&_hr]:border-border [&_hr]:my-6
54
-
55
- /* Images */
56
- [&_img]:max-w-full [&_img]:h-auto [&_img]:rounded [&_img]:my-2 [&_img]:object-contain
57
-
58
- ${e}
59
- `.trim().replace(/\s+/g," "),yh=(e="")=>`
60
- /* Buttons - "important" overrides for flow controls */
61
- [&>button]:bg-[var(--color-background-w10)]
62
- [&>button]:dark:!bg-[var(--color-background-w100)]
63
- [&>button]:hover:bg-[var(--color-background-w20)]
64
- [&>button]:dark:hover:!bg-[var(--color-primary-w60)]
65
- [&>button]:text-[var(--color-primary-text-wMain)]
66
- [&>button]:dark:text-[var(--color-primary-text-w10)]
67
- [&>button]:!border
68
- [&>button]:!border-[var(--color-secondary-w40)]
69
- [&>button]:dark:!border-[var(--color-secondary-w70)]
70
-
71
- ${e}
72
- `.trim().replace(/\s+/g," ");function he(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 Sh(e,t){const n=u.createContext(t),r=s=>{const{children:i,...l}=s,c=u.useMemo(()=>l,Object.values(l));return a.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=u.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Pn(e,t=[]){let n=[];function r(s,i){const l=u.createContext(i),c=n.length;n=[...n,i];const d=p=>{var b;const{scope:m,children:h,...x}=p,g=((b=m==null?void 0:m[e])==null?void 0:b[c])||l,v=u.useMemo(()=>x,Object.values(x));return a.jsx(g.Provider,{value:v,children:h})};d.displayName=s+"Provider";function f(p,m){var g;const h=((g=m==null?void 0:m[e])==null?void 0:g[c])||l,x=u.useContext(h);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[d,f]}const o=()=>{const s=n.map(i=>u.createContext(i));return function(l){const c=(l==null?void 0:l[e])||s;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return o.scopeName=e,[r,Ch(o,...t)]}function Ch(...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(s){const i=r.reduce((l,{useScope:c,scopeName:d})=>{const p=c(s)[`__scope${d}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Eh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_e=Eh.reduce((e,t)=>{const n=Un(`Primitive.${t}`),r=u.forwardRef((o,s)=>{const{asChild:i,...l}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Th(e,t){e&&Kr.flushSync(()=>e.dispatchEvent(t))}function _n(e){const t=u.useRef(e);return u.useEffect(()=>{t.current=e}),u.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ah(e,t=globalThis==null?void 0:globalThis.document){const n=_n(e);u.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 kh="DismissableLayer",qs="dismissableLayer.update",Nh="dismissableLayer.pointerDownOutside",_h="dismissableLayer.focusOutside",Ra,Tc=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qr=u.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:l,...c}=e,d=u.useContext(Tc),[f,p]=u.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=u.useState({}),x=ze(t,k=>p(k)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(v),w=f?g.indexOf(f):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,E=w>=b,T=Mh(k=>{const _=k.target,G=[...d.branches].some(U=>U.contains(_));!E||G||(o==null||o(k),i==null||i(k),k.defaultPrevented||l==null||l())},m),j=Rh(k=>{const _=k.target;[...d.branches].some(U=>U.contains(_))||(s==null||s(k),i==null||i(k),k.defaultPrevented||l==null||l())},m);return Ah(k=>{w===d.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},m),u.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Ra=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),Pa(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ra)}},[f,m,n,d]),u.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),Pa())},[f,d]),u.useEffect(()=>{const k=()=>h({});return document.addEventListener(qs,k),()=>document.removeEventListener(qs,k)},[]),a.jsx(_e.div,{...c,ref:x,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,j.onFocusCapture),onBlurCapture:he(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,T.onPointerDownCapture)})});qr.displayName=kh;var Ih="DismissableLayerBranch",jh=u.forwardRef((e,t)=>{const n=u.useContext(Tc),r=u.useRef(null),o=ze(t,r);return u.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),a.jsx(_e.div,{...e,ref:o})});jh.displayName=Ih;function Mh(e,t=globalThis==null?void 0:globalThis.document){const n=_n(e),r=u.useRef(!1),o=u.useRef(()=>{});return u.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){Ac(Nh,n,d,{discrete:!0})};const d={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",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Rh(e,t=globalThis==null?void 0:globalThis.document){const n=_n(e),r=u.useRef(!1);return u.useEffect(()=>{const o=s=>{s.target&&!r.current&&Ac(_h,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Pa(){const e=new CustomEvent(qs);document.dispatchEvent(e)}function Ac(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Th(o,s):o.dispatchEvent(s)}var dt=globalThis!=null&&globalThis.document?u.useLayoutEffect:()=>{},Ph=Ci[" useId ".trim().toString()]||(()=>{}),Lh=0;function an(e){const[t,n]=u.useState(Ph());return dt(()=>{n(r=>r??String(Lh++))},[e]),t?`radix-${t}`:""}const Dh=["top","right","bottom","left"],In=Math.min,Mt=Math.max,Mo=Math.round,uo=Math.floor,ln=e=>({x:e,y:e}),Oh={left:"right",right:"left",bottom:"top",top:"bottom"},Fh={start:"end",end:"start"};function Xs(e,t,n){return Mt(e,In(t,n))}function bn(e,t){return typeof e=="function"?e(t):e}function yn(e){return e.split("-")[0]}function Cr(e){return e.split("-")[1]}function Ii(e){return e==="x"?"y":"x"}function ji(e){return e==="y"?"height":"width"}const zh=new Set(["top","bottom"]);function on(e){return zh.has(yn(e))?"y":"x"}function Mi(e){return Ii(on(e))}function $h(e,t,n){n===void 0&&(n=!1);const r=Cr(e),o=Mi(e),s=ji(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ro(i)),[i,Ro(i)]}function Bh(e){const t=Ro(e);return[Zs(e),t,Zs(t)]}function Zs(e){return e.replace(/start|end/g,t=>Fh[t])}const La=["left","right"],Da=["right","left"],Uh=["top","bottom"],Hh=["bottom","top"];function Wh(e,t,n){switch(e){case"top":case"bottom":return n?t?Da:La:t?La:Da;case"left":case"right":return t?Uh:Hh;default:return[]}}function Gh(e,t,n,r){const o=Cr(e);let s=Wh(yn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Zs)))),s}function Ro(e){return e.replace(/left|right|bottom|top/g,t=>Oh[t])}function Vh(e){return{top:0,right:0,bottom:0,left:0,...e}}function kc(e){return typeof e!="number"?Vh(e):{top:e,right:e,bottom:e,left:e}}function Po(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 Oa(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=Mi(t),l=ji(i),c=yn(t),d=s==="y",f=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let h;switch(c){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:p};break;case"left":h={x:r.x-o.width,y:p};break;default:h={x:r.x,y:r.y}}switch(Cr(t)){case"start":h[i]-=m*(n&&d?-1:1);break;case"end":h[i]+=m*(n&&d?-1:1);break}return h}const Yh=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,l=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:p}=Oa(d,r,c),m=r,h={},x=0;for(let g=0;g<l.length;g++){const{name:v,fn:b}=l[g],{x:w,y,data:E,reset:T}=await b({x:f,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:d,platform:i,elements:{reference:e,floating:t}});f=w??f,p=y??p,h={...h,[v]:{...h[v],...E}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(d=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:f,y:p}=Oa(d,m,c)),g=-1)}return{x:f,y:p,placement:m,strategy:o,middlewareData:h}};async function zr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:m=!1,padding:h=0}=bn(t,e),x=kc(h),v=l[m?p==="floating"?"reference":"floating":p],b=Po(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},T=Po(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:y,strategy:c}):w);return{top:(b.top-T.top+x.top)/E.y,bottom:(T.bottom-b.bottom+x.bottom)/E.y,left:(b.left-T.left+x.left)/E.x,right:(T.right-b.right+x.right)/E.x}}const Kh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=bn(e,t)||{};if(d==null)return{};const p=kc(f),m={x:n,y:r},h=Mi(o),x=ji(h),g=await i.getDimensions(d),v=h==="y",b=v?"top":"left",w=v?"bottom":"right",y=v?"clientHeight":"clientWidth",E=s.reference[x]+s.reference[h]-m[h]-s.floating[x],T=m[h]-s.reference[h],j=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let k=j?j[y]:0;(!k||!await(i.isElement==null?void 0:i.isElement(j)))&&(k=l.floating[y]||s.floating[x]);const _=E/2-T/2,G=k/2-g[x]/2-1,U=In(p[b],G),B=In(p[w],G),Z=U,J=k-g[x]-B,D=k/2-g[x]/2+_,X=Xs(Z,D,J),A=!c.arrow&&Cr(o)!=null&&D!==X&&s.reference[x]/2-(D<Z?U:B)-g[x]/2<0,Y=A?D<Z?D-Z:D-J:0;return{[h]:m[h]+Y,data:{[h]:X,centerOffset:D-X-Y,...A&&{alignmentOffset:Y}},reset:A}}}),qh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...v}=bn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=yn(o),w=on(l),y=yn(l)===l,E=await(c.isRTL==null?void 0:c.isRTL(d.floating)),T=m||(y||!g?[Ro(l)]:Bh(l)),j=x!=="none";!m&&j&&T.push(...Gh(l,g,x,E));const k=[l,...T],_=await zr(t,v),G=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&G.push(_[b]),p){const D=$h(o,i,E);G.push(_[D[0]],_[D[1]])}if(U=[...U,{placement:o,overflows:G}],!G.every(D=>D<=0)){var B,Z;const D=(((B=s.flip)==null?void 0:B.index)||0)+1,X=k[D];if(X&&(!(p==="alignment"?w!==on(X):!1)||U.every(C=>on(C.placement)===w?C.overflows[0]>0:!0)))return{data:{index:D,overflows:U},reset:{placement:X}};let A=(Z=U.filter(Y=>Y.overflows[0]<=0).sort((Y,C)=>Y.overflows[1]-C.overflows[1])[0])==null?void 0:Z.placement;if(!A)switch(h){case"bestFit":{var J;const Y=(J=U.filter(C=>{if(j){const I=on(C.placement);return I===w||I==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(I=>I>0).reduce((I,F)=>I+F,0)]).sort((C,I)=>C[1]-I[1])[0])==null?void 0:J[0];Y&&(A=Y);break}case"initialPlacement":A=l;break}if(o!==A)return{reset:{placement:A}}}return{}}}};function Fa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function za(e){return Dh.some(t=>e[t]>=0)}const Xh=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=bn(e,t);switch(r){case"referenceHidden":{const s=await zr(t,{...o,elementContext:"reference"}),i=Fa(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:za(i)}}}case"escaped":{const s=await zr(t,{...o,altBoundary:!0}),i=Fa(s,n.floating);return{data:{escapedOffsets:i,escaped:za(i)}}}default:return{}}}}},Nc=new Set(["left","top"]);async function Zh(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=yn(n),l=Cr(n),c=on(n)==="y",d=Nc.has(i)?-1:1,f=s&&c?-1:1,p=bn(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof x=="number"&&(h=l==="end"?x*-1:x),c?{x:h*f,y:m*d}:{x:m*d,y:h*f}}const Jh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:l}=t,c=await Zh(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},Qh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:v=>{let{x:b,y:w}=v;return{x:b,y:w}}},...c}=bn(e,t),d={x:n,y:r},f=await zr(t,c),p=on(yn(o)),m=Ii(p);let h=d[m],x=d[p];if(s){const v=m==="y"?"top":"left",b=m==="y"?"bottom":"right",w=h+f[v],y=h-f[b];h=Xs(w,h,y)}if(i){const v=p==="y"?"top":"left",b=p==="y"?"bottom":"right",w=x+f[v],y=x-f[b];x=Xs(w,x,y)}const g=l.fn({...t,[m]:h,[p]:x});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},eg=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=bn(e,t),f={x:n,y:r},p=on(o),m=Ii(p);let h=f[m],x=f[p];const g=bn(l,t),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const y=m==="y"?"height":"width",E=s.reference[m]-s.floating[y]+v.mainAxis,T=s.reference[m]+s.reference[y]-v.mainAxis;h<E?h=E:h>T&&(h=T)}if(d){var b,w;const y=m==="y"?"width":"height",E=Nc.has(yn(o)),T=s.reference[p]-s.floating[y]+(E&&((b=i.offset)==null?void 0:b[p])||0)+(E?0:v.crossAxis),j=s.reference[p]+s.reference[y]+(E?0:((w=i.offset)==null?void 0:w[p])||0)-(E?v.crossAxis:0);x<T?x=T:x>j&&(x=j)}return{[m]:h,[p]:x}}}},tg=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:l}=t,{apply:c=()=>{},...d}=bn(e,t),f=await zr(t,d),p=yn(o),m=Cr(o),h=on(o)==="y",{width:x,height:g}=s.floating;let v,b;p==="top"||p==="bottom"?(v=p,b=m===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,v=m==="end"?"top":"bottom");const w=g-f.top-f.bottom,y=x-f.left-f.right,E=In(g-f[v],w),T=In(x-f[b],y),j=!t.middlewareData.shift;let k=E,_=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),j&&!m){const U=Mt(f.left,0),B=Mt(f.right,0),Z=Mt(f.top,0),J=Mt(f.bottom,0);h?_=x-2*(U!==0||B!==0?U+B:Mt(f.left,f.right)):k=g-2*(Z!==0||J!==0?Z+J:Mt(f.top,f.bottom))}await c({...t,availableWidth:_,availableHeight:k});const G=await i.getDimensions(l.floating);return x!==G.width||g!==G.height?{reset:{rects:!0}}:{}}}};function Ko(){return typeof window<"u"}function Er(e){return _c(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function dn(e){var t;return(t=(_c(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _c(e){return Ko()?e instanceof Node||e instanceof Pt(e).Node:!1}function qt(e){return Ko()?e instanceof Element||e instanceof Pt(e).Element:!1}function un(e){return Ko()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function $a(e){return!Ko()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const ng=new Set(["inline","contents"]);function Xr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Xt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ng.has(o)}const rg=new Set(["table","td","th"]);function og(e){return rg.has(Er(e))}const sg=[":popover-open",":modal"];function qo(e){return sg.some(t=>{try{return e.matches(t)}catch{return!1}})}const ig=["transform","translate","scale","rotate","perspective"],ag=["transform","translate","scale","rotate","perspective","filter"],lg=["paint","layout","strict","content"];function Ri(e){const t=Pi(),n=qt(e)?Xt(e):e;return ig.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)||ag.some(r=>(n.willChange||"").includes(r))||lg.some(r=>(n.contain||"").includes(r))}function cg(e){let t=jn(e);for(;un(t)&&!mr(t);){if(Ri(t))return t;if(qo(t))return null;t=jn(t)}return null}function Pi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ug=new Set(["html","body","#document"]);function mr(e){return ug.has(Er(e))}function Xt(e){return Pt(e).getComputedStyle(e)}function Xo(e){return qt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function jn(e){if(Er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||$a(e)&&e.host||dn(e);return $a(t)?t.host:t}function Ic(e){const t=jn(e);return mr(t)?e.ownerDocument?e.ownerDocument.body:e.body:un(t)&&Xr(t)?t:Ic(t)}function $r(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ic(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const l=Js(i);return t.concat(i,i.visualViewport||[],Xr(o)?o:[],l&&n?$r(l):[])}return t.concat(o,$r(o,[],n))}function Js(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function jc(e){const t=Xt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=un(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,l=Mo(n)!==s||Mo(r)!==i;return l&&(n=s,r=i),{width:n,height:r,$:l}}function Li(e){return qt(e)?e:e.contextElement}function cr(e){const t=Li(e);if(!un(t))return ln(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=jc(t);let i=(s?Mo(n.width):n.width)/r,l=(s?Mo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const dg=ln(0);function Mc(e){const t=Pt(e);return!Pi()||!t.visualViewport?dg:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function fg(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Hn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Li(e);let i=ln(1);t&&(r?qt(r)&&(i=cr(r)):i=cr(e));const l=fg(s,n,r)?Mc(s):ln(0);let c=(o.left+l.x)/i.x,d=(o.top+l.y)/i.y,f=o.width/i.x,p=o.height/i.y;if(s){const m=Pt(s),h=r&&qt(r)?Pt(r):r;let x=m,g=Js(x);for(;g&&r&&h!==x;){const v=cr(g),b=g.getBoundingClientRect(),w=Xt(g),y=b.left+(g.clientLeft+parseFloat(w.paddingLeft))*v.x,E=b.top+(g.clientTop+parseFloat(w.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,p*=v.y,c+=y,d+=E,x=Pt(g),g=Js(x)}}return Po({width:f,height:p,x:c,y:d})}function Zo(e,t){const n=Xo(e).scrollLeft;return t?t.left+n:Hn(dn(e)).left+n}function Rc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Zo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function pg(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=dn(r),l=t?qo(t.floating):!1;if(r===i||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=ln(1);const f=ln(0),p=un(r);if((p||!p&&!s)&&((Er(r)!=="body"||Xr(i))&&(c=Xo(r)),un(r))){const h=Hn(r);d=cr(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const m=i&&!p&&!s?Rc(i,c):ln(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-c.scrollTop*d.y+f.y+m.y}}function mg(e){return Array.from(e.getClientRects())}function hg(e){const t=dn(e),n=Xo(e),r=e.ownerDocument.body,o=Mt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Mt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Zo(e);const l=-n.scrollTop;return Xt(r).direction==="rtl"&&(i+=Mt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:l}}const Ba=25;function gg(e,t){const n=Pt(e),r=dn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,l=0,c=0;if(o){s=o.width,i=o.height;const f=Pi();(!f||f&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}const d=Zo(r);if(d<=0){const f=r.ownerDocument,p=f.body,m=getComputedStyle(p),h=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-h);x<=Ba&&(s-=x)}else d<=Ba&&(s+=d);return{width:s,height:i,x:l,y:c}}const xg=new Set(["absolute","fixed"]);function vg(e,t){const n=Hn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=un(e)?cr(e):ln(1),i=e.clientWidth*s.x,l=e.clientHeight*s.y,c=o*s.x,d=r*s.y;return{width:i,height:l,x:c,y:d}}function Ua(e,t,n){let r;if(t==="viewport")r=gg(e,n);else if(t==="document")r=hg(dn(e));else if(qt(t))r=vg(t,n);else{const o=Mc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Po(r)}function Pc(e,t){const n=jn(e);return n===t||!qt(n)||mr(n)?!1:Xt(n).position==="fixed"||Pc(n,t)}function wg(e,t){const n=t.get(e);if(n)return n;let r=$r(e,[],!1).filter(l=>qt(l)&&Er(l)!=="body"),o=null;const s=Xt(e).position==="fixed";let i=s?jn(e):e;for(;qt(i)&&!mr(i);){const l=Xt(i),c=Ri(i);!c&&l.position==="fixed"&&(o=null),(s?!c&&!o:!c&&l.position==="static"&&!!o&&xg.has(o.position)||Xr(i)&&!c&&Pc(e,i))?r=r.filter(f=>f!==i):o=l,i=jn(i)}return t.set(e,r),r}function bg(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?qo(t)?[]:wg(t,this._c):[].concat(n),r],l=i[0],c=i.reduce((d,f)=>{const p=Ua(t,f,o);return d.top=Mt(p.top,d.top),d.right=In(p.right,d.right),d.bottom=In(p.bottom,d.bottom),d.left=Mt(p.left,d.left),d},Ua(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function yg(e){const{width:t,height:n}=jc(e);return{width:t,height:n}}function Sg(e,t,n){const r=un(t),o=dn(t),s=n==="fixed",i=Hn(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=ln(0);function d(){c.x=Zo(o)}if(r||!r&&!s)if((Er(t)!=="body"||Xr(o))&&(l=Xo(t)),r){const h=Hn(t,!0,s,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else o&&d();s&&!r&&o&&d();const f=o&&!r&&!s?Rc(o,l):ln(0),p=i.left+l.scrollLeft-c.x-f.x,m=i.top+l.scrollTop-c.y-f.y;return{x:p,y:m,width:i.width,height:i.height}}function bs(e){return Xt(e).position==="static"}function Ha(e,t){if(!un(e)||Xt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return dn(e)===n&&(n=n.ownerDocument.body),n}function Lc(e,t){const n=Pt(e);if(qo(e))return n;if(!un(e)){let o=jn(e);for(;o&&!mr(o);){if(qt(o)&&!bs(o))return o;o=jn(o)}return n}let r=Ha(e,t);for(;r&&og(r)&&bs(r);)r=Ha(r,t);return r&&mr(r)&&bs(r)&&!Ri(r)?n:r||cg(e)||n}const Cg=async function(e){const t=this.getOffsetParent||Lc,n=this.getDimensions,r=await n(e.floating);return{reference:Sg(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eg(e){return Xt(e).direction==="rtl"}const Tg={convertOffsetParentRelativeRectToViewportRelativeRect:pg,getDocumentElement:dn,getClippingRect:bg,getOffsetParent:Lc,getElementRects:Cg,getClientRects:mg,getDimensions:yg,getScale:cr,isElement:qt,isRTL:Eg};function Dc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ag(e,t){let n=null,r;const o=dn(e);function s(){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),s();const d=e.getBoundingClientRect(),{left:f,top:p,width:m,height:h}=d;if(l||t(),!m||!h)return;const x=uo(p),g=uo(o.clientWidth-(f+m)),v=uo(o.clientHeight-(p+h)),b=uo(f),y={rootMargin:-x+"px "+-g+"px "+-v+"px "+-b+"px",threshold:Mt(0,In(1,c))||1};let E=!0;function T(j){const k=j[0].intersectionRatio;if(k!==c){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Dc(d,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),s}function kg(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=Li(e),f=o||s?[...d?$r(d):[],...$r(t)]:[];f.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const p=d&&l?Ag(d,n):null;let m=-1,h=null;i&&(h=new ResizeObserver(b=>{let[w]=b;w&&w.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=h)==null||y.observe(t)})),n()}),d&&!c&&h.observe(d),h.observe(t));let x,g=c?Hn(e):null;c&&v();function v(){const b=Hn(e);g&&!Dc(g,b)&&n(),g=b,x=requestAnimationFrame(v)}return n(),()=>{var b;f.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(b=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(x)}}const Ng=Jh,_g=Qh,Ig=qh,jg=tg,Mg=Xh,Wa=Kh,Rg=eg,Pg=(e,t,n)=>{const r=new Map,o={platform:Tg,...n},s={...o.platform,_c:r};return Yh(e,t,{...o,platform:s})};var Lg=typeof document<"u",Dg=function(){},ko=Lg?u.useLayoutEffect:Dg;function Lo(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(!Lo(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 s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Lo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Oc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ga(e,t){const n=Oc(e);return Math.round(t*n)/n}function ys(e){const t=u.useRef(e);return ko(()=>{t.current=e}),t}function Og(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,p]=u.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=u.useState(r);Lo(m,r)||h(r);const[x,g]=u.useState(null),[v,b]=u.useState(null),w=u.useCallback(C=>{C!==j.current&&(j.current=C,g(C))},[]),y=u.useCallback(C=>{C!==k.current&&(k.current=C,b(C))},[]),E=s||x,T=i||v,j=u.useRef(null),k=u.useRef(null),_=u.useRef(f),G=c!=null,U=ys(c),B=ys(o),Z=ys(d),J=u.useCallback(()=>{if(!j.current||!k.current)return;const C={placement:t,strategy:n,middleware:m};B.current&&(C.platform=B.current),Pg(j.current,k.current,C).then(I=>{const F={...I,isPositioned:Z.current!==!1};D.current&&!Lo(_.current,F)&&(_.current=F,Kr.flushSync(()=>{p(F)}))})},[m,t,n,B,Z]);ko(()=>{d===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,p(C=>({...C,isPositioned:!1})))},[d]);const D=u.useRef(!1);ko(()=>(D.current=!0,()=>{D.current=!1}),[]),ko(()=>{if(E&&(j.current=E),T&&(k.current=T),E&&T){if(U.current)return U.current(E,T,J);J()}},[E,T,J,U,G]);const X=u.useMemo(()=>({reference:j,floating:k,setReference:w,setFloating:y}),[w,y]),A=u.useMemo(()=>({reference:E,floating:T}),[E,T]),Y=u.useMemo(()=>{const C={position:n,left:0,top:0};if(!A.floating)return C;const I=Ga(A.floating,f.x),F=Ga(A.floating,f.y);return l?{...C,transform:"translate("+I+"px, "+F+"px)",...Oc(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:F}},[n,l,A.floating,f.x,f.y]);return u.useMemo(()=>({...f,update:J,refs:X,elements:A,floatingStyles:Y}),[f,J,X,A,Y])}const Fg=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?Wa({element:r.current,padding:o}).fn(n):{}:r?Wa({element:r,padding:o}).fn(n):{}}}},zg=(e,t)=>({...Ng(e),options:[e,t]}),$g=(e,t)=>({..._g(e),options:[e,t]}),Bg=(e,t)=>({...Rg(e),options:[e,t]}),Ug=(e,t)=>({...Ig(e),options:[e,t]}),Hg=(e,t)=>({...jg(e),options:[e,t]}),Wg=(e,t)=>({...Mg(e),options:[e,t]}),Gg=(e,t)=>({...Fg(e),options:[e,t]});var Vg="Arrow",Fc=u.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return a.jsx(_e.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:a.jsx("polygon",{points:"0,0 30,0 15,10"})})});Fc.displayName=Vg;var Yg=Fc;function Kg(e){const[t,n]=u.useState(void 0);return dt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;i=d.inlineSize,l=d.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 Di="Popper",[zc,Tr]=Pn(Di),[qg,$c]=zc(Di),Bc=e=>{const{__scopePopper:t,children:n}=e,[r,o]=u.useState(null);return a.jsx(qg,{scope:t,anchor:r,onAnchorChange:o,children:n})};Bc.displayName=Di;var Uc="PopperAnchor",Hc=u.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=$c(Uc,n),i=u.useRef(null),l=ze(t,i),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||i.current,d!==c.current&&s.onAnchorChange(c.current)}),r?null:a.jsx(_e.div,{...o,ref:l})});Hc.displayName=Uc;var Oi="PopperContent",[Xg,Zg]=zc(Oi),Wc=u.forwardRef((e,t)=>{var N,K,ee,te,le,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:x,...g}=e,v=$c(Oi,n),[b,w]=u.useState(null),y=ze(t,de=>w(de)),[E,T]=u.useState(null),j=Kg(E),k=(j==null?void 0:j.width)??0,_=(j==null?void 0:j.height)??0,G=r+(s!=="center"?"-"+s:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},B=Array.isArray(d)?d:[d],Z=B.length>0,J={padding:U,boundary:B.filter(Qg),altBoundary:Z},{refs:D,floatingStyles:X,placement:A,isPositioned:Y,middlewareData:C}=Og({strategy:"fixed",placement:G,whileElementsMounted:(...de)=>kg(...de,{animationFrame:h==="always"}),elements:{reference:v.anchor},middleware:[zg({mainAxis:o+_,alignmentAxis:i}),c&&$g({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Bg():void 0,...J}),c&&Ug({...J}),Hg({...J,apply:({elements:de,rects:we,availableWidth:je,availableHeight:Re})=>{const{width:Le,height:Me}=we.reference,We=de.floating.style;We.setProperty("--radix-popper-available-width",`${je}px`),We.setProperty("--radix-popper-available-height",`${Re}px`),We.setProperty("--radix-popper-anchor-width",`${Le}px`),We.setProperty("--radix-popper-anchor-height",`${Me}px`)}}),E&&Gg({element:E,padding:l}),ex({arrowWidth:k,arrowHeight:_}),m&&Wg({strategy:"referenceHidden",...J})]}),[I,F]=Yc(A),R=_n(x);dt(()=>{Y&&(R==null||R())},[Y,R]);const Q=(N=C.arrow)==null?void 0:N.x,O=(K=C.arrow)==null?void 0:K.y,W=((ee=C.arrow)==null?void 0:ee.centerOffset)!==0,[z,q]=u.useState();return dt(()=>{b&&q(window.getComputedStyle(b).zIndex)},[b]),a.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:Y?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:z,"--radix-popper-transform-origin":[(te=C.transformOrigin)==null?void 0:te.x,(le=C.transformOrigin)==null?void 0:le.y].join(" "),...((ne=C.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:a.jsx(Xg,{scope:n,placedSide:I,onArrowChange:T,arrowX:Q,arrowY:O,shouldHideArrow:W,children:a.jsx(_e.div,{"data-side":I,"data-align":F,...g,ref:y,style:{...g.style,animation:Y?void 0:"none"}})})})});Wc.displayName=Oi;var Gc="PopperArrow",Jg={top:"bottom",right:"left",bottom:"top",left:"right"},Vc=u.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Zg(Gc,r),i=Jg[s.placedSide];return a.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:a.jsx(Yg,{...o,ref:n,style:{...o.style,display:"block"}})})});Vc.displayName=Gc;function Qg(e){return e!==null}var ex=e=>({name:"transformOrigin",options:e,fn(t){var v,b,w;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[d,f]=Yc(n),p={start:"0%",center:"50%",end:"100%"}[f],m=(((b=o.arrow)==null?void 0:b.x)??0)+l/2,h=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let x="",g="";return d==="bottom"?(x=i?p:`${m}px`,g=`${-c}px`):d==="top"?(x=i?p:`${m}px`,g=`${r.floating.height+c}px`):d==="right"?(x=`${-c}px`,g=i?p:`${h}px`):d==="left"&&(x=`${r.floating.width+c}px`,g=i?p:`${h}px`),{data:{x,y:g}}}});function Yc(e){const[t,n="center"]=e.split("-");return[t,n]}var Fi=Bc,Jo=Hc,zi=Wc,$i=Vc,tx="Portal",Zr=u.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,s]=u.useState(!1);dt(()=>s(!0),[]);const i=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Up.createPortal(a.jsx(_e.div,{...r,ref:t}),i):null});Zr.displayName=tx;function nx(e,t){return u.useReducer((n,r)=>t[n][r]??n,e)}var Cn=e=>{const{present:t,children:n}=e,r=rx(t),o=typeof n=="function"?n({present:r.isPresent}):u.Children.only(n),s=ze(r.ref,ox(o));return typeof n=="function"||r.isPresent?u.cloneElement(o,{ref:s}):null};Cn.displayName="Presence";function rx(e){const[t,n]=u.useState(),r=u.useRef(null),o=u.useRef(e),s=u.useRef("none"),i=e?"mounted":"unmounted",[l,c]=nx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=fo(r.current);s.current=l==="mounted"?d:"none"},[l]),dt(()=>{const d=r.current,f=o.current;if(f!==e){const m=s.current,h=fo(d);e?c("MOUNT"):h==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(f&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),dt(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,p=h=>{const g=fo(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&g&&(c("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=h=>{h.target===t&&(s.current=fo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function fo(e){return(e==null?void 0:e.animationName)||"none"}function ox(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 sx=Ci[" useInsertionEffect ".trim().toString()]||dt;function Wn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ix({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:o;{const f=u.useRef(e!==void 0);u.useEffect(()=>{const p=f.current;p!==l&&console.warn(`${r} is changing from ${p?"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.`),f.current=l},[l,r])}const d=u.useCallback(f=>{var p;if(l){const m=ax(f)?f(e):f;m!==e&&((p=i.current)==null||p.call(i,m))}else s(f)},[l,e,s,i]);return[c,d]}function ix({defaultProp:e,onChange:t}){const[n,r]=u.useState(e),o=u.useRef(n),s=u.useRef(t);return sx(()=>{s.current=t},[t]),u.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ax(e){return typeof e=="function"}var Kc=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"}),lx="VisuallyHidden",qc=u.forwardRef((e,t)=>a.jsx(_e.span,{...e,ref:t,style:{...Kc,...e.style}}));qc.displayName=lx;var cx=qc,[Qo]=Pn("Tooltip",[Tr]),es=Tr(),Xc="TooltipProvider",ux=700,Qs="tooltip.open",[dx,Bi]=Qo(Xc),Zc=e=>{const{__scopeTooltip:t,delayDuration:n=ux,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=u.useRef(!0),l=u.useRef(!1),c=u.useRef(0);return u.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),a.jsx(dx,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:u.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:u.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:s})};Zc.displayName=Xc;var Br="Tooltip",[fx,Jr]=Qo(Br),Jc=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:l}=e,c=Bi(Br,e.__scopeTooltip),d=es(t),[f,p]=u.useState(null),m=an(),h=u.useRef(0),x=i??c.disableHoverableContent,g=l??c.delayDuration,v=u.useRef(!1),[b,w]=Wn({prop:r,defaultProp:o??!1,onChange:k=>{k?(c.onOpen(),document.dispatchEvent(new CustomEvent(Qs))):c.onClose(),s==null||s(k)},caller:Br}),y=u.useMemo(()=>b?v.current?"delayed-open":"instant-open":"closed",[b]),E=u.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,w(!0)},[w]),T=u.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w(!1)},[w]),j=u.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,w(!0),h.current=0},g)},[g,w]);return u.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),a.jsx(Fi,{...d,children:a.jsx(fx,{scope:t,contentId:m,open:b,stateAttribute:y,trigger:f,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?j():E()},[c.isOpenDelayedRef,j,E]),onTriggerLeave:u.useCallback(()=>{x?T():(window.clearTimeout(h.current),h.current=0)},[T,x]),onOpen:E,onClose:T,disableHoverableContent:x,children:n})})};Jc.displayName=Br;var ei="TooltipTrigger",Qc=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Jr(ei,n),s=Bi(ei,n),i=es(n),l=u.useRef(null),c=ze(t,l,o.onTriggerChange),d=u.useRef(!1),f=u.useRef(!1),p=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),a.jsx(Jo,{asChild:!0,...i,children:a.jsx(_e.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:he(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:he(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:he(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:he(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:he(e.onBlur,o.onClose),onClick:he(e.onClick,o.onClose)})})});Qc.displayName=ei;var Ui="TooltipPortal",[px,mx]=Qo(Ui,{forceMount:void 0}),eu=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=Jr(Ui,t);return a.jsx(px,{scope:t,forceMount:n,children:a.jsx(Cn,{present:n||s.open,children:a.jsx(Zr,{asChild:!0,container:o,children:r})})})};eu.displayName=Ui;var hr="TooltipContent",tu=u.forwardRef((e,t)=>{const n=mx(hr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Jr(hr,e.__scopeTooltip);return a.jsx(Cn,{present:r||i.open,children:i.disableHoverableContent?a.jsx(nu,{side:o,...s,ref:t}):a.jsx(hx,{side:o,...s,ref:t})})}),hx=u.forwardRef((e,t)=>{const n=Jr(hr,e.__scopeTooltip),r=Bi(hr,e.__scopeTooltip),o=u.useRef(null),s=ze(t,o),[i,l]=u.useState(null),{trigger:c,onClose:d}=n,f=o.current,{onPointerInTransitChange:p}=r,m=u.useCallback(()=>{l(null),p(!1)},[p]),h=u.useCallback((x,g)=>{const v=x.currentTarget,b={x:x.clientX,y:x.clientY},w=wx(b,v.getBoundingClientRect()),y=bx(b,w),E=yx(g.getBoundingClientRect()),T=Cx([...y,...E]);l(T),p(!0)},[p]);return u.useEffect(()=>()=>m(),[m]),u.useEffect(()=>{if(c&&f){const x=v=>h(v,f),g=v=>h(v,c);return c.addEventListener("pointerleave",x),f.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),f.removeEventListener("pointerleave",g)}}},[c,f,h,m]),u.useEffect(()=>{if(i){const x=g=>{const v=g.target,b={x:g.clientX,y:g.clientY},w=(c==null?void 0:c.contains(v))||(f==null?void 0:f.contains(v)),y=!Sx(b,i);w?m():y&&(m(),d())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,f,i,d,m]),a.jsx(nu,{...e,ref:s})}),[gx,xx]=Qo(Br,{isInside:!1}),vx=_m("TooltipContent"),nu=u.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...l}=e,c=Jr(hr,n),d=es(n),{onClose:f}=c;return u.useEffect(()=>(document.addEventListener(Qs,f),()=>document.removeEventListener(Qs,f)),[f]),u.useEffect(()=>{if(c.trigger){const p=m=>{const h=m.target;h!=null&&h.contains(c.trigger)&&f()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,f]),a.jsx(qr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:a.jsxs(zi,{"data-state":c.stateAttribute,...d,...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:[a.jsx(vx,{children:r}),a.jsx(gx,{scope:n,isInside:!0,children:a.jsx(cx,{id:c.contentId,role:"tooltip",children:o||r})})]})})});tu.displayName=hr;var ru="TooltipArrow",ou=u.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=es(n);return xx(ru,n).isInside?null:a.jsx($i,{...o,...r,ref:t})});ou.displayName=ru;function wx(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function bx(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 yx(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 Sx(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const l=t[s],c=t[i],d=l.x,f=l.y,p=c.x,m=c.y;f>r!=m>r&&n<(p-d)*(r-f)/(m-f)+d&&(o=!o)}return o}function Cx(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),Ex(t)}function Ex(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 s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.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 s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.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 Tx=Zc,Ax=Jc,kx=Qc,Nx=eu,_x=tu,Ix=ou;function jx({delayDuration:e=0,...t}){return a.jsx(Tx,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Hi({...e}){return a.jsx(jx,{delayDuration:500,children:a.jsx(Ax,{"data-slot":"tooltip",...e})})}function Wi({...e}){return a.jsx(kx,{"data-slot":"tooltip-trigger",...e})}function Gi({className:e,sideOffset:t=0,children:n,...r}){return a.jsx(Nx,{children:a.jsxs(_x,{"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,a.jsx(Ix,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const su="text-[var(--color-primary-wMain)] hover:text-[var(--color-primary-text-w60)] dark:text-[var(--color-primary-w20)] dark:hover:text-[var(--color-primary-text-w10)]",Ss=su+" hover:bg-[var(--color-primary-w10)] dark:hover:bg-[var(--color-primary-w60)]",Mx=Rn("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 disabled:hover:bg-transparent dark:disabled:hover:bg-transparent",{variants:{variant:{default:"text-[var(--color-primary-text-w10)] bg-[var(--color-primary-wMain)] hover:bg-[var(--color-primary-w100)] dark:hover:bg-[var(--color-primary-w60)]",destructive:"text-[var(--color-primary-text-w10)] bg-[var(--color-error-wMain)] hover:bg-[var(--color-error-w70)]",outline:Ss+" border border-1 border-[var(--color-primary-wMain)]",secondary:Ss,ghost:Ss,link:su+" underline-offset-4 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 me({className:e,variant:t,size:n,asChild:r=!1,tooltip:o="",testid:s="",...i}){const l=r?dc:"button",c=o?{...i,"aria-label":o}:i,d=a.jsx(l,{"data-slot":"button","data-testid":s||o||i.title,className:ve(Mx({variant:t,size:n,className:e})),...c});return o?a.jsxs(Hi,{children:[a.jsx(Wi,{asChild:!0,children:d}),a.jsx(Gi,{children:o})]}):d}const iu=({onClick:e,text:t="View Agent Workflow"})=>a.jsx(me,{variant:"ghost",size:"sm",onClick:e,tooltip:t,children:a.jsx(Ao,{className:"h-4 w-4"})}),Vi=u.forwardRef(({className:e,...t},n)=>a.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}));Vi.displayName="Textarea";var Cs="focusScope.autoFocusOnMount",Es="focusScope.autoFocusOnUnmount",Va={bubbles:!1,cancelable:!0},Rx="FocusScope",ts=u.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[l,c]=u.useState(null),d=_n(o),f=_n(s),p=u.useRef(null),m=ze(t,g=>c(g)),h=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(r){let g=function(y){if(h.paused||!l)return;const E=y.target;l.contains(E)?p.current=E:Tn(p.current,{select:!0})},v=function(y){if(h.paused||!l)return;const E=y.relatedTarget;E!==null&&(l.contains(E)||Tn(p.current,{select:!0}))},b=function(y){if(document.activeElement===document.body)for(const T of y)T.removedNodes.length>0&&Tn(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,h.paused]),u.useEffect(()=>{if(l){Ka.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(Cs,Va);l.addEventListener(Cs,d),l.dispatchEvent(b),b.defaultPrevented||(Px(zx(au(l)),{select:!0}),document.activeElement===g&&Tn(l))}return()=>{l.removeEventListener(Cs,d),setTimeout(()=>{const b=new CustomEvent(Es,Va);l.addEventListener(Es,f),l.dispatchEvent(b),b.defaultPrevented||Tn(g??document.body,{select:!0}),l.removeEventListener(Es,f),Ka.remove(h)},0)}}},[l,d,f,h]);const x=u.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(v&&b){const w=g.currentTarget,[y,E]=Lx(w);y&&E?!g.shiftKey&&b===E?(g.preventDefault(),n&&Tn(y,{select:!0})):g.shiftKey&&b===y&&(g.preventDefault(),n&&Tn(E,{select:!0})):b===w&&g.preventDefault()}},[n,r,h.paused]);return a.jsx(_e.div,{tabIndex:-1,...i,ref:m,onKeyDown:x})});ts.displayName=Rx;function Px(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tn(r,{select:t}),document.activeElement!==n)return}function Lx(e){const t=au(e),n=Ya(t,e),r=Ya(t.reverse(),e);return[n,r]}function au(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 Ya(e,t){for(const n of e)if(!Dx(n,{upTo:t}))return n}function Dx(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 Ox(e){return e instanceof HTMLInputElement&&"select"in e}function Tn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ox(e)&&t&&e.select()}}var Ka=Fx();function Fx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=qa(e,t),e.unshift(t)},remove(t){var n;e=qa(e,t),(n=e[0])==null||n.resume()}}}function qa(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function zx(e){return e.filter(t=>t.tagName!=="A")}var Ts=0;function Yi(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Xa()),document.body.insertAdjacentElement("beforeend",e[1]??Xa()),Ts++,()=>{Ts===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ts--}},[])}function Xa(){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 rn=function(){return rn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},rn.apply(this,arguments)};function lu(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 $x(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var No="right-scroll-bar-position",_o="width-before-scroll-bar",Bx="with-scroll-bars-hidden",Ux="--removed-body-scroll-bar-size";function As(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Hx(e,t){var n=u.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 Wx=typeof window<"u"?u.useLayoutEffect:u.useEffect,Za=new WeakMap;function Gx(e,t){var n=Hx(null,function(r){return e.forEach(function(o){return As(o,r)})});return Wx(function(){var r=Za.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(l){s.has(l)||As(l,null)}),s.forEach(function(l){o.has(l)||As(l,i)})}Za.set(n,e)},[e]),n}function Vx(e){return e}function Yx(e,t){t===void 0&&(t=Vx);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(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(s),i=n}var c=function(){var f=i;i=[],f.forEach(s)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(f){i.push(f),d()},filter:function(f){return i=i.filter(f),n}}}};return o}function Kx(e){e===void 0&&(e={});var t=Yx(null);return t.options=rn({async:!0,ssr:!1},e),t}var cu=function(e){var t=e.sideCar,n=lu(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 u.createElement(r,rn({},n))};cu.isSideCarExport=!0;function qx(e,t){return e.useMedium(t),cu}var uu=Kx(),ks=function(){},ns=u.forwardRef(function(e,t){var n=u.useRef(null),r=u.useState({onScrollCapture:ks,onWheelCapture:ks,onTouchMoveCapture:ks}),o=r[0],s=r[1],i=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,f=e.enabled,p=e.shards,m=e.sideCar,h=e.noRelative,x=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,y=e.gapMode,E=lu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,j=Gx([n,t]),k=rn(rn({},E),o);return u.createElement(u.Fragment,null,f&&u.createElement(T,{sideCar:uu,removeScrollBar:d,shards:p,noRelative:h,noIsolation:x,inert:g,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:y}),i?u.cloneElement(u.Children.only(l),rn(rn({},k),{ref:j})):u.createElement(w,rn({},k,{className:c,ref:j}),l))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ns.classNames={fullWidth:_o,zeroRight:No};var Xx=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Zx(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xx();return t&&e.setAttribute("nonce",t),e}function Jx(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qx(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ev=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Zx())&&(Jx(t,n),Qx(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tv=function(){var e=ev();return function(t,n){u.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},du=function(){var e=tv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},nv={left:0,top:0,right:0,gap:0},Ns=function(e){return parseInt(e||"",10)||0},rv=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[Ns(n),Ns(r),Ns(o)]},ov=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return nv;var t=rv(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])}},sv=du(),ur="data-scroll-locked",iv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
73
- .`.concat(Bx,` {
74
- overflow: hidden `).concat(r,`;
75
- padding-right: `).concat(l,"px ").concat(r,`;
76
- }
77
- body[`).concat(ur,`] {
78
- overflow: hidden `).concat(r,`;
79
- overscroll-behavior: contain;
80
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
81
- padding-left: `.concat(o,`px;
82
- padding-top: `).concat(s,`px;
83
- padding-right: `).concat(i,`px;
84
- margin-left:0;
85
- margin-top:0;
86
- margin-right: `).concat(l,"px ").concat(r,`;
87
- `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
88
- }
89
-
90
- .`).concat(No,` {
91
- right: `).concat(l,"px ").concat(r,`;
92
- }
93
-
94
- .`).concat(_o,` {
95
- margin-right: `).concat(l,"px ").concat(r,`;
96
- }
97
-
98
- .`).concat(No," .").concat(No,` {
99
- right: 0 `).concat(r,`;
100
- }
101
-
102
- .`).concat(_o," .").concat(_o,` {
103
- margin-right: 0 `).concat(r,`;
104
- }
105
-
106
- body[`).concat(ur,`] {
107
- `).concat(Ux,": ").concat(l,`px;
108
- }
109
- `)},Ja=function(){var e=parseInt(document.body.getAttribute(ur)||"0",10);return isFinite(e)?e:0},av=function(){u.useEffect(function(){return document.body.setAttribute(ur,(Ja()+1).toString()),function(){var e=Ja()-1;e<=0?document.body.removeAttribute(ur):document.body.setAttribute(ur,e.toString())}},[])},lv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;av();var s=u.useMemo(function(){return ov(o)},[o]);return u.createElement(sv,{styles:iv(s,!t,o,n?"":"!important")})},ti=!1;if(typeof window<"u")try{var po=Object.defineProperty({},"passive",{get:function(){return ti=!0,!0}});window.addEventListener("test",po,po),window.removeEventListener("test",po,po)}catch{ti=!1}var Qn=ti?{passive:!1}:!1,cv=function(e){return e.tagName==="TEXTAREA"},fu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!cv(e)&&n[t]==="visible")},uv=function(e){return fu(e,"overflowY")},dv=function(e){return fu(e,"overflowX")},Qa=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=pu(e,r);if(o){var s=mu(e,r),i=s[1],l=s[2];if(i>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},pv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},pu=function(e,t){return e==="v"?uv(t):dv(t)},mu=function(e,t){return e==="v"?fv(t):pv(t)},mv=function(e,t){return e==="h"&&t==="rtl"?-1:1},hv=function(e,t,n,r,o){var s=mv(e,window.getComputedStyle(t).direction),i=s*r,l=n.target,c=t.contains(l),d=!1,f=i>0,p=0,m=0;do{if(!l)break;var h=mu(e,l),x=h[0],g=h[1],v=h[2],b=g-v-s*x;(x||b)&&pu(e,l)&&(p+=b,m+=x);var w=l.parentNode;l=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(f&&Math.abs(p)<1||!f&&Math.abs(m)<1)&&(d=!0),d},mo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},el=function(e){return[e.deltaX,e.deltaY]},tl=function(e){return e&&"current"in e?e.current:e},gv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xv=function(e){return`
110
- .block-interactivity-`.concat(e,` {pointer-events: none;}
111
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
112
- `)},vv=0,er=[];function wv(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),o=u.useState(vv++)[0],s=u.useState(du)[0],i=u.useRef(e);u.useEffect(function(){i.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=$x([e.lockRef.current],(e.shards||[]).map(tl),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=u.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var b=mo(g),w=n.current,y="deltaX"in g?g.deltaX:w[0]-b[0],E="deltaY"in g?g.deltaY:w[1]-b[1],T,j=g.target,k=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&j.type==="range")return!1;var _=Qa(k,j);if(!_)return!0;if(_?T=k:(T=k==="v"?"h":"v",_=Qa(k,j)),!_)return!1;if(!r.current&&"changedTouches"in g&&(y||E)&&(r.current=T),!T)return!0;var G=r.current||T;return hv(G,v,g,G==="h"?y:E)},[]),c=u.useCallback(function(g){var v=g;if(!(!er.length||er[er.length-1]!==s)){var b="deltaY"in v?el(v):mo(v),w=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&gv(T.delta,b)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var y=(i.current.shards||[]).map(tl).filter(Boolean).filter(function(T){return T.contains(v.target)}),E=y.length>0?l(v,y[0]):!i.current.noIsolation;E&&v.cancelable&&v.preventDefault()}}},[]),d=u.useCallback(function(g,v,b,w){var y={name:g,delta:v,target:b,should:w,shadowParent:bv(b)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),f=u.useCallback(function(g){n.current=mo(g),r.current=void 0},[]),p=u.useCallback(function(g){d(g.type,el(g),g.target,l(g,e.lockRef.current))},[]),m=u.useCallback(function(g){d(g.type,mo(g),g.target,l(g,e.lockRef.current))},[]);u.useEffect(function(){return er.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Qn),document.addEventListener("touchmove",c,Qn),document.addEventListener("touchstart",f,Qn),function(){er=er.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,Qn),document.removeEventListener("touchmove",c,Qn),document.removeEventListener("touchstart",f,Qn)}},[]);var h=e.removeScrollBar,x=e.inert;return u.createElement(u.Fragment,null,x?u.createElement(s,{styles:xv(o)}):null,h?u.createElement(lv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yv=qx(uu,wv);var rs=u.forwardRef(function(e,t){return u.createElement(ns,rn({},e,{ref:t,sideCar:yv}))});rs.classNames=ns.classNames;var Sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},tr=new WeakMap,ho=new WeakMap,go={},_s=0,hu=function(e){return e&&(e.host||hu(e.parentNode))},Cv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=hu(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})},Ev=function(e,t,n,r){var o=Cv(t,Array.isArray(e)?e:[e]);go[n]||(go[n]=new WeakMap);var s=go[n],i=[],l=new Set,c=new Set(o),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};o.forEach(d);var f=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var h=m.getAttribute(r),x=h!==null&&h!=="false",g=(tr.get(m)||0)+1,v=(s.get(m)||0)+1;tr.set(m,g),s.set(m,v),i.push(m),g===1&&x&&ho.set(m,!0),v===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return f(t),l.clear(),_s++,function(){i.forEach(function(p){var m=tr.get(p)-1,h=s.get(p)-1;tr.set(p,m),s.set(p,h),m||(ho.has(p)||p.removeAttribute(r),ho.delete(p)),h||p.removeAttribute(n)}),_s--,_s||(tr=new WeakMap,tr=new WeakMap,ho=new WeakMap,go={})}},Ki=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ev(r,o,n,"aria-hidden")):function(){return null}},os="Dialog",[gu]=Pn(os),[Tv,Zt]=gu(os),xu=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,l=u.useRef(null),c=u.useRef(null),[d,f]=Wn({prop:r,defaultProp:o??!1,onChange:s,caller:os});return a.jsx(Tv,{scope:t,triggerRef:l,contentRef:c,contentId:an(),titleId:an(),descriptionId:an(),open:d,onOpenChange:f,onOpenToggle:u.useCallback(()=>f(p=>!p),[f]),modal:i,children:n})};xu.displayName=os;var vu="DialogTrigger",Av=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Zt(vu,n),s=ze(t,o.triggerRef);return a.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Zi(o.open),...r,ref:s,onClick:he(e.onClick,o.onOpenToggle)})});Av.displayName=vu;var qi="DialogPortal",[kv,wu]=gu(qi,{forceMount:void 0}),bu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Zt(qi,t);return a.jsx(kv,{scope:t,forceMount:n,children:u.Children.map(r,i=>a.jsx(Cn,{present:n||s.open,children:a.jsx(Zr,{asChild:!0,container:o,children:i})}))})};bu.displayName=qi;var Do="DialogOverlay",yu=u.forwardRef((e,t)=>{const n=wu(Do,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Zt(Do,e.__scopeDialog);return s.modal?a.jsx(Cn,{present:r||s.open,children:a.jsx(_v,{...o,ref:t})}):null});yu.displayName=Do;var Nv=Un("DialogOverlay.RemoveScroll"),_v=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Zt(Do,n);return a.jsx(rs,{as:Nv,allowPinchZoom:!0,shards:[o.contentRef],children:a.jsx(_e.div,{"data-state":Zi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Gn="DialogContent",Su=u.forwardRef((e,t)=>{const n=wu(Gn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Zt(Gn,e.__scopeDialog);return a.jsx(Cn,{present:r||s.open,children:s.modal?a.jsx(Iv,{...o,ref:t}):a.jsx(jv,{...o,ref:t})})});Su.displayName=Gn;var Iv=u.forwardRef((e,t)=>{const n=Zt(Gn,e.__scopeDialog),r=u.useRef(null),o=ze(t,n.contentRef,r);return u.useEffect(()=>{const s=r.current;if(s)return Ki(s)},[]),a.jsx(Cu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:he(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&s.preventDefault()}),onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault())})}),jv=u.forwardRef((e,t)=>{const n=Zt(Gn,e.__scopeDialog),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(Cu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Cu=u.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,l=Zt(Gn,n),c=u.useRef(null),d=ze(t,c);return Yi(),a.jsxs(a.Fragment,{children:[a.jsx(ts,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(qr,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Zi(l.open),...i,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),a.jsxs(a.Fragment,{children:[a.jsx(Mv,{titleId:l.titleId}),a.jsx(Pv,{contentRef:c,descriptionId:l.descriptionId})]})]})}),Xi="DialogTitle",Eu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Zt(Xi,n);return a.jsx(_e.h2,{id:o.titleId,...r,ref:t})});Eu.displayName=Xi;var Tu="DialogDescription",Au=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Zt(Tu,n);return a.jsx(_e.p,{id:o.descriptionId,...r,ref:t})});Au.displayName=Tu;var ku="DialogClose",Nu=u.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Zt(ku,n);return a.jsx(_e.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});Nu.displayName=ku;function Zi(e){return e?"open":"closed"}var _u="DialogTitleWarning",[RE,Iu]=Sh(_u,{contentName:Gn,titleName:Xi,docsSlug:"dialog"}),Mv=({titleId:e})=>{const t=Iu(_u),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
113
-
114
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
115
-
116
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Rv="DialogDescriptionWarning",Pv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Iu(Rv).contentName}}.`;return u.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Lv=xu,Dv=bu,Ov=yu,Fv=Su,zv=Eu,$v=Au,Bv=Nu;function Qr({...e}){return a.jsx(Lv,{"data-slot":"dialog",...e})}function Uv({...e}){return a.jsx(Dv,{"data-slot":"dialog-portal",...e})}function Hv({className:e,...t}){return a.jsx(Ov,{"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 eo({className:e,children:t,showCloseButton:n=!1,...r}){return a.jsxs(Uv,{"data-slot":"dialog-portal",children:[a.jsx(Hv,{}),a.jsxs(Fv,{"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&&a.jsxs(Bv,{"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:[a.jsx(Vo,{}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function to({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-header",className:ve("flex flex-col gap-2 text-center sm:text-left",e),...t})}function ju({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-footer",className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function no({className:e,...t}){return a.jsx(zv,{"data-slot":"dialog-title",className:ve("text-lg leading-none font-semibold",e),...t})}function ro({className:e,...t}){return a.jsx($v,{"data-slot":"dialog-description",className:ve("py-4 text-sm",e),...t})}const ss=u.createContext(null);ss.displayName="PanelGroupContext";const Ve={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"},Ji=10,$n=u.useLayoutEffect,nl=Ci.useId,Wv=typeof nl=="function"?nl:()=>null;let Gv=0;function Qi(e=null){const t=Wv(),n=u.useRef(e||t||null);return n.current===null&&(n.current=""+Gv++),e??n.current}function Mu({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:s,id:i,maxSize:l,minSize:c,onCollapse:d,onExpand:f,onResize:p,order:m,style:h,tagName:x="div",...g}){const v=u.useContext(ss);if(v===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:w,getPanelSize:y,getPanelStyle:E,groupId:T,isPanelCollapsed:j,reevaluatePanelConstraints:k,registerPanel:_,resizePanel:G,unregisterPanel:U}=v,B=Qi(i),Z=u.useRef({callbacks:{onCollapse:d,onExpand:f,onResize:p},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:l,minSize:c},id:B,idIsFromProps:i!==void 0,order:m});u.useRef({didLogMissingDefaultSizeWarning:!1}),$n(()=>{const{callbacks:D,constraints:X}=Z.current,A={...X};Z.current.id=B,Z.current.idIsFromProps=i!==void 0,Z.current.order=m,D.onCollapse=d,D.onExpand=f,D.onResize=p,X.collapsedSize=n,X.collapsible=r,X.defaultSize=o,X.maxSize=l,X.minSize=c,(A.collapsedSize!==X.collapsedSize||A.collapsible!==X.collapsible||A.maxSize!==X.maxSize||A.minSize!==X.minSize)&&k(Z.current,A)}),$n(()=>{const D=Z.current;return _(D),()=>{U(D)}},[m,B,_,U]),u.useImperativeHandle(s,()=>({collapse:()=>{b(Z.current)},expand:D=>{w(Z.current,D)},getId(){return B},getSize(){return y(Z.current)},isCollapsed(){return j(Z.current)},isExpanded(){return!j(Z.current)},resize:D=>{G(Z.current,D)}}),[b,w,y,j,B,G]);const J=E(Z.current,o);return u.createElement(x,{...g,children:e,className:t,id:B,style:{...J,...h},[Ve.groupId]:T,[Ve.panel]:"",[Ve.panelCollapsible]:r||void 0,[Ve.panelId]:B,[Ve.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const Ru=u.forwardRef((e,t)=>u.createElement(Mu,{...e,forwardedRef:t}));Mu.displayName="Panel";Ru.displayName="forwardRef(Panel)";let ni=null,Io=-1,An=null;function Vv(e,t,n){const r=(t&Fu)!==0,o=(t&zu)!==0,s=(t&$u)!==0,i=(t&Bu)!==0;if(t){if(r)return s?"se-resize":i?"ne-resize":"e-resize";if(o)return s?"sw-resize":i?"nw-resize":"w-resize";if(s)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Yv(){An!==null&&(document.head.removeChild(An),ni=null,An=null,Io=-1)}function Is(e,t,n){var r,o;const s=Vv(e,t);if(ni!==s){if(ni=s,An===null&&(An=document.createElement("style"),document.head.appendChild(An)),Io>=0){var i;(i=An.sheet)===null||i===void 0||i.removeRule(Io)}Io=(r=(o=An.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function Pu(e){return e.type==="keydown"}function Lu(e){return e.type.startsWith("pointer")}function Du(e){return e.type.startsWith("mouse")}function is(e){if(Lu(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Du(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Kv(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function qv(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 Xv(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:sl(e),b:sl(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Se(r,"Stacking order can only be calculated for elements with a common ancestor");const o={a:ol(rl(n.a)),b:ol(rl(n.b))};if(o.a===o.b){const s=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let l=s.length;for(;l--;){const c=s[l];if(c===i.a)return 1;if(c===i.b)return-1}}return Math.sign(o.a-o.b)}const Zv=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Jv(e){var t;const n=getComputedStyle((t=Ou(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Qv(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Jv(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"||Zv.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rl(e){let t=e.length;for(;t--;){const n=e[t];if(Se(n,"Missing node"),Qv(n))return n}return null}function ol(e){return e&&Number(getComputedStyle(e).zIndex)||0}function sl(e){const t=[];for(;e;)t.push(e),e=Ou(e);return t}function Ou(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const Fu=1,zu=2,$u=4,Bu=8,ew=Kv()==="coarse";let Kt=[],dr=!1,kn=new Map,as=new Map;const Ur=new Set;function tw(e,t,n,r,o){var s;const{ownerDocument:i}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},c=(s=kn.get(i))!==null&&s!==void 0?s:0;return kn.set(i,c+1),Ur.add(l),Oo(),function(){var f;as.delete(e),Ur.delete(l);const p=(f=kn.get(i))!==null&&f!==void 0?f:1;if(kn.set(i,p-1),Oo(),p===1&&kn.delete(i),Kt.includes(l)){const m=Kt.indexOf(l);m>=0&&Kt.splice(m,1),ls(),o("up",!0,null)}}}function nw(e){const{target:t}=e,{x:n,y:r}=is(e);dr=!0,ea({target:t,x:n,y:r}),Oo(),Kt.length>0&&(Fo("down",e),ls(),e.preventDefault(),Uu(t)||e.stopImmediatePropagation())}function js(e){const{x:t,y:n}=is(e);if(dr&&e.type!=="pointerleave"&&e.buttons===0&&(dr=!1,Fo("up",e)),!dr){const{target:r}=e;ea({target:r,x:t,y:n})}Fo("move",e),ls(),Kt.length>0&&e.preventDefault()}function Ms(e){const{target:t}=e,{x:n,y:r}=is(e);as.clear(),dr=!1,Kt.length>0&&(e.preventDefault(),Uu(t)||e.stopImmediatePropagation()),Fo("up",e),ea({target:t,x:n,y:r}),ls(),Oo()}function Uu(e){let t=e;for(;t;){if(t.hasAttribute(Ve.resizeHandle))return!0;t=t.parentElement}return!1}function ea({target:e,x:t,y:n}){Kt.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Ur.forEach(o=>{const{element:s,hitAreaMargins:i}=o,l=s.getBoundingClientRect(),{bottom:c,left:d,right:f,top:p}=l,m=ew?i.coarse:i.fine;if(t>=d-m&&t<=f+m&&n>=p-m&&n<=c+m){if(r!==null&&document.contains(r)&&s!==r&&!s.contains(r)&&!r.contains(s)&&Xv(r,s)>0){let x=r,g=!1;for(;x&&!x.contains(s);){if(qv(x.getBoundingClientRect(),l)){g=!0;break}x=x.parentElement}if(g)return}Kt.push(o)}})}function Rs(e,t){as.set(e,t)}function ls(){let e=!1,t=!1;Kt.forEach(r=>{const{direction:o}=r;o==="horizontal"?e=!0:t=!0});let n=0;as.forEach(r=>{n|=r}),e&&t?Is("intersection",n):e?Is("horizontal",n):t?Is("vertical",n):Yv()}let Ps;function Oo(){var e;(e=Ps)===null||e===void 0||e.abort(),Ps=new AbortController;const t={capture:!0,signal:Ps.signal};Ur.size&&(dr?(Kt.length>0&&kn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("contextmenu",Ms,t),o.addEventListener("pointerleave",js,t),o.addEventListener("pointermove",js,t))}),kn.forEach((n,r)=>{const{body:o}=r;o.addEventListener("pointerup",Ms,t),o.addEventListener("pointercancel",Ms,t)})):kn.forEach((n,r)=>{const{body:o}=r;n>0&&(o.addEventListener("pointerdown",nw,t),o.addEventListener("pointermove",js,t))}))}function Fo(e,t){Ur.forEach(n=>{const{setResizeHandlerState:r}=n,o=Kt.includes(n);r(e,o,t)})}function rw(){const[e,t]=u.useState(0);return u.useCallback(()=>t(n=>n+1),[])}function Se(e,t){if(!e)throw console.error(t),Error(t)}function Vn(e,t,n=Ji){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function vn(e,t,n=Ji){return Vn(e,t,n)===0}function jt(e,t,n){return Vn(e,t,n)===0}function ow(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],s=t[r];if(!jt(o,s,n))return!1}return!0}function ir({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Se(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:s,maxSize:i=100,minSize:l=0}=r;if(Vn(n,l)<0)if(s){const c=(o+l)/2;Vn(n,c)<0?n=o:n=l}else n=l;return n=Math.min(i,n),n=parseFloat(n.toFixed(Ji)),n}function Lr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:s}){if(jt(e,0))return t;const i=[...t],[l,c]=r;Se(l!=null,"Invalid first pivot index"),Se(c!=null,"Invalid second pivot index");let d=0;if(s==="keyboard"){{const p=e<0?c:l,m=n[p];Se(m,`Panel constraints not found for index ${p}`);const{collapsedSize:h=0,collapsible:x,minSize:g=0}=m;if(x){const v=t[p];if(Se(v!=null,`Previous layout not found for panel index ${p}`),jt(v,h)){const b=g-v;Vn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?l:c,m=n[p];Se(m,`No panel constraints found for index ${p}`);const{collapsedSize:h=0,collapsible:x,minSize:g=0}=m;if(x){const v=t[p];if(Se(v!=null,`Previous layout not found for panel index ${p}`),jt(v,g)){const b=v-h;Vn(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let m=e<0?c:l,h=0;for(;;){const g=t[m];Se(g!=null,`Previous layout not found for panel index ${m}`);const b=ir({panelConstraints:n,panelIndex:m,size:100})-g;if(h+=b,m+=p,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(d),x=t[m];Se(x!=null,`Previous layout not found for panel index ${m}`);const g=x-h,v=ir({panelConstraints:n,panelIndex:m,size:g});if(!jt(x,v)&&(d+=x-v,i[m]=v,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(ow(o,i))return o;{const p=e<0?c:l,m=t[p];Se(m!=null,`Previous layout not found for panel index ${p}`);const h=m+d,x=ir({panelConstraints:n,panelIndex:p,size:h});if(i[p]=x,!jt(x,h)){let g=h-x,b=e<0?c:l;for(;b>=0&&b<n.length;){const w=i[b];Se(w!=null,`Previous layout not found for panel index ${b}`);const y=w+g,E=ir({panelConstraints:n,panelIndex:b,size:y});if(jt(w,E)||(g-=E-w,i[b]=E),jt(g,0))break;e>0?b--:b++}}}const f=i.reduce((p,m)=>m+p,0);return jt(f,100)?i:o}function sw({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,s=0,i=0;const l=n[0];Se(l!=null,"No pivot index found"),t.forEach((p,m)=>{const{constraints:h}=p,{maxSize:x=100,minSize:g=0}=h;m===l?(r=g,o=x):(s+=g,i+=x)});const c=Math.min(o,100-s),d=Math.max(r,100-i),f=e[l];return{valueMax:c,valueMin:d,valueNow:f}}function Hr(e,t=document){return Array.from(t.querySelectorAll(`[${Ve.resizeHandleId}][data-panel-group-id="${e}"]`))}function Hu(e,t,n=document){const o=Hr(e,n).findIndex(s=>s.getAttribute(Ve.resizeHandleId)===t);return o??null}function Wu(e,t,n){const r=Hu(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function iw(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Gu(e,t=document){if(iw(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function cs(e,t=document){const n=t.querySelector(`[${Ve.resizeHandleId}="${e}"]`);return n||null}function aw(e,t,n,r=document){var o,s,i,l;const c=cs(t,r),d=Hr(e,r),f=c?d.indexOf(c):-1,p=(o=(s=n[f])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,m=(i=(l=n[f+1])===null||l===void 0?void 0:l.id)!==null&&i!==void 0?i:null;return[p,m]}function lw({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:s,setLayout:i}){u.useRef({didWarnAboutMissingResizeHandle:!1}),$n(()=>{if(!s)return;const l=Hr(n,s);for(let c=0;c<o.length-1;c++){const{valueMax:d,valueMin:f,valueNow:p}=sw({layout:r,panelsArray:o,pivotIndices:[c,c+1]}),m=l[c];if(m!=null){const h=o[c];Se(h,`No panel data found for index "${c}"`),m.setAttribute("aria-controls",h.id),m.setAttribute("aria-valuemax",""+Math.round(d)),m.setAttribute("aria-valuemin",""+Math.round(f)),m.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{l.forEach((c,d)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,o,s]),u.useEffect(()=>{if(!s)return;const l=t.current;Se(l,"Eager values not found");const{panelDataArray:c}=l,d=Gu(n,s);Se(d!=null,`No group found for id "${n}"`);const f=Hr(n,s);Se(f,`No resize handles found for group id "${n}"`);const p=f.map(m=>{const h=m.getAttribute(Ve.resizeHandleId);Se(h,"Resize handle element has no handle id attribute");const[x,g]=aw(n,h,c,s);if(x==null||g==null)return()=>{};const v=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const w=c.findIndex(y=>y.id===x);if(w>=0){const y=c[w];Se(y,`No panel data found for index ${w}`);const E=r[w],{collapsedSize:T=0,collapsible:j,minSize:k=0}=y.constraints;if(E!=null&&j){const _=Lr({delta:jt(E,T)?k-T:T-E,initialLayout:r,panelConstraints:c.map(G=>G.constraints),pivotIndices:Wu(n,h,s),prevLayout:r,trigger:"keyboard"});r!==_&&i(_)}}break}}};return m.addEventListener("keydown",v),()=>{m.removeEventListener("keydown",v)}});return()=>{p.forEach(m=>m())}},[s,e,t,n,r,o,i])}function il(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 Vu(e,t){const n=e==="horizontal",{x:r,y:o}=is(t);return n?r:o}function cw(e,t,n,r,o){const s=n==="horizontal",i=cs(t,o);Se(i,`No resize handle element found for id "${t}"`);const l=i.getAttribute(Ve.groupId);Se(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const d=Vu(n,e),f=Gu(l,o);Se(f,`No group element found for id "${l}"`);const p=f.getBoundingClientRect(),m=s?p.width:p.height;return(d-c)/m*100}function uw(e,t,n,r,o,s){if(Pu(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:cw(e,t,n,r,s)}function dw({panelDataArray:e}){const t=Array(e.length),n=e.map(s=>s.constraints);let r=0,o=100;for(let s=0;s<e.length;s++){const i=n[s];Se(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;l!=null&&(r++,t[s]=l,o-=l)}for(let s=0;s<e.length;s++){const i=n[s];Se(i,`Panel constraints not found for index ${s}`);const{defaultSize:l}=i;if(l!=null)continue;const c=e.length-r,d=o/c;r++,t[s]=d,o-=d}return t}function nr(e,t,n){t.forEach((r,o)=>{const s=e[o];Se(s,`Panel data not found for index ${o}`);const{callbacks:i,constraints:l,id:c}=s,{collapsedSize:d=0,collapsible:f}=l,p=n[c];if(p==null||r!==p){n[c]=r;const{onCollapse:m,onExpand:h,onResize:x}=i;x&&x(r,p),f&&(m||h)&&(h&&(p==null||vn(p,d))&&!vn(r,d)&&h(),m&&(p==null||!vn(p,d))&&vn(r,d)&&m())}})}function xo(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 fw({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:s=3}){const i=n[o];let l;return i==null?l=e!=null?e.toFixed(s):"1":r.length===1?l="1":l=i.toFixed(s),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function pw(e,t=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},t)}}function al(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 Yu(e){return`react-resizable-panels:${e}`}function Ku(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:o,order:s}=t;return o?r:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function qu(e,t){try{const n=Yu(e),r=t.getItem(n);if(r){const o=JSON.parse(r);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function mw(e,t,n){var r,o;const s=(r=qu(e,n))!==null&&r!==void 0?r:{},i=Ku(t);return(o=s[i])!==null&&o!==void 0?o:null}function hw(e,t,n,r,o){var s;const i=Yu(e),l=Ku(t),c=(s=qu(e,o))!==null&&s!==void 0?s:{};c[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(c))}catch(d){console.error(d)}}function ll({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((s,i)=>s+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!jt(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const i=n[s];Se(i!=null,`No layout data found for index ${s}`);const l=100/r*i;n[s]=l}let o=0;for(let s=0;s<t.length;s++){const i=n[s];Se(i!=null,`No layout data found for index ${s}`);const l=ir({panelConstraints:t,panelIndex:s,size:i});i!=l&&(o+=i-l,n[s]=l)}if(!jt(o,0))for(let s=0;s<t.length;s++){const i=n[s];Se(i!=null,`No layout data found for index ${s}`);const l=i+o,c=ir({panelConstraints:t,panelIndex:s,size:l});if(i!==c&&(o-=c-i,n[s]=c,jt(o,0)))break}return n}const gw=100,Dr={getItem:e=>(al(Dr),Dr.getItem(e)),setItem:(e,t)=>{al(Dr),Dr.setItem(e,t)}},cl={};function Xu({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:s=null,onLayout:i=null,keyboardResizeBy:l=null,storage:c=Dr,style:d,tagName:f="div",...p}){const m=Qi(s),h=u.useRef(null),[x,g]=u.useState(null),[v,b]=u.useState([]),w=rw(),y=u.useRef({}),E=u.useRef(new Map),T=u.useRef(0),j=u.useRef({autoSaveId:e,direction:r,dragState:x,id:m,keyboardResizeBy:l,onLayout:i,storage:c}),k=u.useRef({layout:v,panelDataArray:[],panelDataArrayChanged:!1});u.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),u.useImperativeHandle(o,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:O}=k.current;return O},setLayout:O=>{const{onLayout:W}=j.current,{layout:z,panelDataArray:q}=k.current,N=ll({layout:O,panelConstraints:q.map(K=>K.constraints)});il(z,N)||(b(N),k.current.layout=N,W&&W(N),nr(q,N,y.current))}}),[]),$n(()=>{j.current.autoSaveId=e,j.current.direction=r,j.current.dragState=x,j.current.id=m,j.current.onLayout=i,j.current.storage=c}),lw({committedValuesRef:j,eagerValuesRef:k,groupId:m,layout:v,panelDataArray:k.current.panelDataArray,setLayout:b,panelGroupElement:h.current}),u.useEffect(()=>{const{panelDataArray:O}=k.current;if(e){if(v.length===0||v.length!==O.length)return;let W=cl[e];W==null&&(W=pw(hw,gw),cl[e]=W);const z=[...O],q=new Map(E.current);W(e,z,q,v,c)}},[e,v,c]),u.useEffect(()=>{});const _=u.useCallback(O=>{const{onLayout:W}=j.current,{layout:z,panelDataArray:q}=k.current;if(O.constraints.collapsible){const N=q.map(le=>le.constraints),{collapsedSize:K=0,panelSize:ee,pivotIndices:te}=zn(q,O,z);if(Se(ee!=null,`Panel size not found for panel "${O.id}"`),!vn(ee,K)){E.current.set(O.id,ee);const ne=or(q,O)===q.length-1?ee-K:K-ee,de=Lr({delta:ne,initialLayout:z,panelConstraints:N,pivotIndices:te,prevLayout:z,trigger:"imperative-api"});xo(z,de)||(b(de),k.current.layout=de,W&&W(de),nr(q,de,y.current))}}},[]),G=u.useCallback((O,W)=>{const{onLayout:z}=j.current,{layout:q,panelDataArray:N}=k.current;if(O.constraints.collapsible){const K=N.map(we=>we.constraints),{collapsedSize:ee=0,panelSize:te=0,minSize:le=0,pivotIndices:ne}=zn(N,O,q),de=W??le;if(vn(te,ee)){const we=E.current.get(O.id),je=we!=null&&we>=de?we:de,Le=or(N,O)===N.length-1?te-je:je-te,Me=Lr({delta:Le,initialLayout:q,panelConstraints:K,pivotIndices:ne,prevLayout:q,trigger:"imperative-api"});xo(q,Me)||(b(Me),k.current.layout=Me,z&&z(Me),nr(N,Me,y.current))}}},[]),U=u.useCallback(O=>{const{layout:W,panelDataArray:z}=k.current,{panelSize:q}=zn(z,O,W);return Se(q!=null,`Panel size not found for panel "${O.id}"`),q},[]),B=u.useCallback((O,W)=>{const{panelDataArray:z}=k.current,q=or(z,O);return fw({defaultSize:W,dragState:x,layout:v,panelData:z,panelIndex:q})},[x,v]),Z=u.useCallback(O=>{const{layout:W,panelDataArray:z}=k.current,{collapsedSize:q=0,collapsible:N,panelSize:K}=zn(z,O,W);return Se(K!=null,`Panel size not found for panel "${O.id}"`),N===!0&&vn(K,q)},[]),J=u.useCallback(O=>{const{layout:W,panelDataArray:z}=k.current,{collapsedSize:q=0,collapsible:N,panelSize:K}=zn(z,O,W);return Se(K!=null,`Panel size not found for panel "${O.id}"`),!N||Vn(K,q)>0},[]),D=u.useCallback(O=>{const{panelDataArray:W}=k.current;W.push(O),W.sort((z,q)=>{const N=z.order,K=q.order;return N==null&&K==null?0:N==null?-1:K==null?1:N-K}),k.current.panelDataArrayChanged=!0,w()},[w]);$n(()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:O,onLayout:W,storage:z}=j.current,{layout:q,panelDataArray:N}=k.current;let K=null;if(O){const te=mw(O,N,z);te&&(E.current=new Map(Object.entries(te.expandToSizes)),K=te.layout)}K==null&&(K=dw({panelDataArray:N}));const ee=ll({layout:K,panelConstraints:N.map(te=>te.constraints)});il(q,ee)||(b(ee),k.current.layout=ee,W&&W(ee),nr(N,ee,y.current))}}),$n(()=>{const O=k.current;return()=>{O.layout=[]}},[]);const X=u.useCallback(O=>{let W=!1;const z=h.current;return z&&window.getComputedStyle(z,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(N){N.preventDefault();const K=h.current;if(!K)return()=>null;const{direction:ee,dragState:te,id:le,keyboardResizeBy:ne,onLayout:de}=j.current,{layout:we,panelDataArray:je}=k.current,{initialLayout:Re}=te??{},Le=Wu(le,O,K);let Me=uw(N,O,ee,te,ne,K);const We=ee==="horizontal";We&&W&&(Me=-Me);const Lt=je.map(rt=>rt.constraints),qe=Lr({delta:Me,initialLayout:Re??we,panelConstraints:Lt,pivotIndices:Le,prevLayout:we,trigger:Pu(N)?"keyboard":"mouse-or-touch"}),Dt=!xo(we,qe);(Lu(N)||Du(N))&&T.current!=Me&&(T.current=Me,!Dt&&Me!==0?We?Rs(O,Me<0?Fu:zu):Rs(O,Me<0?$u:Bu):Rs(O,0)),Dt&&(b(qe),k.current.layout=qe,de&&de(qe),nr(je,qe,y.current))}},[]),A=u.useCallback((O,W)=>{const{onLayout:z}=j.current,{layout:q,panelDataArray:N}=k.current,K=N.map(we=>we.constraints),{panelSize:ee,pivotIndices:te}=zn(N,O,q);Se(ee!=null,`Panel size not found for panel "${O.id}"`);const ne=or(N,O)===N.length-1?ee-W:W-ee,de=Lr({delta:ne,initialLayout:q,panelConstraints:K,pivotIndices:te,prevLayout:q,trigger:"imperative-api"});xo(q,de)||(b(de),k.current.layout=de,z&&z(de),nr(N,de,y.current))},[]),Y=u.useCallback((O,W)=>{const{layout:z,panelDataArray:q}=k.current,{collapsedSize:N=0,collapsible:K}=W,{collapsedSize:ee=0,collapsible:te,maxSize:le=100,minSize:ne=0}=O.constraints,{panelSize:de}=zn(q,O,z);de!=null&&(K&&te&&vn(de,N)?vn(N,ee)||A(O,ee):de<ne?A(O,ne):de>le&&A(O,le))},[A]),C=u.useCallback((O,W)=>{const{direction:z}=j.current,{layout:q}=k.current;if(!h.current)return;const N=cs(O,h.current);Se(N,`Drag handle element not found for id "${O}"`);const K=Vu(z,W);g({dragHandleId:O,dragHandleRect:N.getBoundingClientRect(),initialCursorPosition:K,initialLayout:q})},[]),I=u.useCallback(()=>{g(null)},[]),F=u.useCallback(O=>{const{panelDataArray:W}=k.current,z=or(W,O);z>=0&&(W.splice(z,1),delete y.current[O.id],k.current.panelDataArrayChanged=!0,w())},[w]),R=u.useMemo(()=>({collapsePanel:_,direction:r,dragState:x,expandPanel:G,getPanelSize:U,getPanelStyle:B,groupId:m,isPanelCollapsed:Z,isPanelExpanded:J,reevaluatePanelConstraints:Y,registerPanel:D,registerResizeHandle:X,resizePanel:A,startDragging:C,stopDragging:I,unregisterPanel:F,panelGroupElement:h.current}),[_,x,r,G,U,B,m,Z,J,Y,D,X,A,C,I,F]),Q={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return u.createElement(ss.Provider,{value:R},u.createElement(f,{...p,children:t,className:n,id:s,ref:h,style:{...Q,...d},[Ve.group]:"",[Ve.groupDirection]:r,[Ve.groupId]:m}))}const Zu=u.forwardRef((e,t)=>u.createElement(Xu,{...e,forwardedRef:t}));Xu.displayName="PanelGroup";Zu.displayName="forwardRef(PanelGroup)";function or(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function zn(e,t,n){const r=or(e,t),s=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:s}}function xw({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){u.useEffect(()=>{if(e||n==null||r==null)return;const o=cs(t,r);if(o==null)return;const s=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(Ve.groupId);Se(l,`No group element found for id "${l}"`);const c=Hr(l,r),d=Hu(l,t,r);Se(d!==null,`No resize element found for id "${t}"`);const f=i.shiftKey?d>0?d-1:c.length-1:d+1<c.length?d+1:0;c[f].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[r,e,t,n])}function Ju({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:s,onClick:i,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:f,style:p={},tabIndex:m=0,tagName:h="div",...x}){var g,v;const b=u.useRef(null),w=u.useRef({onClick:i,onDragging:l,onPointerDown:d,onPointerUp:f});u.useEffect(()=>{w.current.onClick=i,w.current.onDragging=l,w.current.onPointerDown=d,w.current.onPointerUp=f});const y=u.useContext(ss);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:E,groupId:T,registerResizeHandle:j,startDragging:k,stopDragging:_,panelGroupElement:G}=y,U=Qi(o),[B,Z]=u.useState("inactive"),[J,D]=u.useState(!1),[X,A]=u.useState(null),Y=u.useRef({state:B});$n(()=>{Y.current.state=B}),u.useEffect(()=>{if(n)A(null);else{const R=j(U);A(()=>R)}},[n,U,j]);const C=(g=r==null?void 0:r.coarse)!==null&&g!==void 0?g:15,I=(v=r==null?void 0:r.fine)!==null&&v!==void 0?v:5;u.useEffect(()=>{if(n||X==null)return;const R=b.current;Se(R,"Element ref not attached");let Q=!1;return tw(U,R,E,{coarse:C,fine:I},(W,z,q)=>{if(!z){Z("inactive");return}switch(W){case"down":{Z("drag"),Q=!1,Se(q,'Expected event to be defined for "down" action'),k(U,q);const{onDragging:N,onPointerDown:K}=w.current;N==null||N(!0),K==null||K();break}case"move":{const{state:N}=Y.current;Q=!0,N!=="drag"&&Z("hover"),Se(q,'Expected event to be defined for "move" action'),X(q);break}case"up":{Z("hover"),_();const{onClick:N,onDragging:K,onPointerUp:ee}=w.current;K==null||K(!1),ee==null||ee(),Q||N==null||N();break}}})},[C,E,n,I,j,U,X,k,_]),xw({disabled:n,handleId:U,resizeHandler:X,panelGroupElement:G});const F={touchAction:"none",userSelect:"none"};return u.createElement(h,{...x,children:e,className:t,id:o,onBlur:()=>{D(!1),s==null||s()},onFocus:()=>{D(!0),c==null||c()},ref:b,role:"separator",style:{...F,...p},tabIndex:m,[Ve.groupDirection]:E,[Ve.groupId]:T,[Ve.resizeHandle]:"",[Ve.resizeHandleActive]:B==="drag"?"pointer":J?"keyboard":void 0,[Ve.resizeHandleEnabled]:!n,[Ve.resizeHandleId]:U,[Ve.resizeHandleState]:B})}Ju.displayName="PanelResizeHandle";function vw({className:e,...t}){return a.jsx(Zu,{"data-slot":"resizable-panel-group",className:ve("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function ul({...e}){return a.jsx(Ru,{"data-slot":"resizable-panel",...e})}function ww({withHandle:e,className:t,...n}){return a.jsx(Ju,{"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&&a.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:a.jsx(Hp,{className:"size-2.5"})})})}const bw=u.forwardRef(({className:e,...t},n)=>a.jsx("ul",{ref:n,className:ve("flex flex-row items-center gap-1",e),...t}));bw.displayName="PaginationContent";const yw=u.forwardRef(({className:e,...t},n)=>a.jsx("li",{ref:n,className:ve("",e),...t}));yw.displayName="PaginationItem";function Sw({ref:e,anchorRef:t,onClickOutside:n,enabled:r=!0}){u.useEffect(()=>{if(!r)return;const o=s=>{const i=s.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 Cw({onEscape:e,enabled:t=!0}){u.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[e,t])}const Ew={x:0,y:0},Bt=16,Tw=["top-start","bottom-end","top-end"];function Aw({anchorRef:e,placement:t="top-start",offset:n=Ew,fallbackPlacements:r=Tw}){const o=u.useCallback((c,d,f)=>{let p=0,m=0;switch(f){case"top":p=c.top-d.height-n.y,m=c.left+(c.width-d.width)/2+n.x;break;case"top-start":p=c.top-d.height-n.y,m=c.left+n.x;break;case"top-end":p=c.top-d.height-n.y,m=c.right-d.width-n.x;break;case"bottom":p=c.bottom+n.y,m=c.left+(c.width-d.width)/2+n.x;break;case"bottom-start":p=c.bottom+n.y,m=c.left+n.x;break;case"bottom-end":p=c.bottom+n.y,m=c.right-d.width-n.x;break;case"left":p=c.top+(c.height-d.height)/2+n.y,m=c.left-d.width-n.x;break;case"left-start":p=c.top+n.y,m=c.left-d.width-n.x;break;case"left-end":p=c.bottom-d.height-n.y,m=c.left-d.width-n.x;break;case"right":p=c.top+(c.height-d.height)/2+n.y,m=c.right+n.x;break;case"right-start":p=c.top+n.y,m=c.right+n.x;break;case"right-end":p=c.bottom-d.height-n.y,m=c.right+n.x;break}return console.log(`Calculated position for ${f}:`,{top:p,left:m}),{top:p,left:m,placement:f}},[n.x,n.y]),s=u.useCallback((c,d)=>{const f={width:window.innerWidth,height:window.innerHeight};return c.left<Bt||c.top<Bt||c.left+d.width>f.width-Bt||c.top+d.height>f.height-Bt},[]),i=u.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 d=e.current.getBoundingClientRect(),f=c.getBoundingClientRect(),p=o(d,f,t);if(!s(p,f))return p;for(const x of r){const g=o(d,f,x);if(!s(g,f))return g}const m={width:window.innerWidth,height:window.innerHeight},h={...p};return h.left<Bt?h.left=Bt:h.left+f.width>m.width-Bt&&(h.left=m.width-f.width-Bt),h.top<Bt?h.top=Bt:h.top+f.height>m.height-Bt&&(h.top=m.height-f.height-Bt),h},[e,t,r,o,s]);return{getPositionStyle:u.useCallback(c=>{const d=i(c);return{position:"fixed",top:d.top,left:d.left,zIndex:1e3}},[i]),getOptimalPosition:i}}function kw({defaultWidth:e,minWidth:t,maxWidth:n,position:r="left",onWidthChange:o}){const[s,i]=u.useState(e),[l,c]=u.useState(!1),d=u.useRef(0),f=u.useRef(e),p=u.useCallback(b=>{b.preventDefault(),c(!0),d.current=b.clientX,f.current=s},[s]),m=u.useCallback(b=>{if(!l)return;const w=b.clientX-d.current,y=r==="right"?-w:w,E=Math.min(Math.max(f.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),h=u.useCallback(()=>{c(!1)},[]),x=u.useCallback(b=>{b.preventDefault(),c(!0),d.current=b.touches[0].clientX,f.current=s},[s]),g=u.useCallback(b=>{if(!l)return;const w=b.touches[0].clientX-d.current,y=r==="right"?-w:w,E=Math.min(Math.max(f.current+y,t),n);i(E),o==null||o(E)},[l,t,n,r,o]),v=u.useCallback(()=>{c(!1)},[]);return u.useEffect(()=>{if(l)return document.addEventListener("mousemove",m),document.addEventListener("mouseup",h),document.addEventListener("touchmove",g),document.addEventListener("touchend",v),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",v),document.body.style.userSelect="",document.body.style.cursor=""}},[l,m,h,g,v]),{width:s,isResizing:l,handleMouseDown:p,handleTouchStart:x,setWidth:i}}const Nw=u.forwardRef(({children:e,defaultWidth:t=300,minWidth:n=200,maxWidth:r=800,position:o="left",resizable:s=!0,className:i,onWidthChange:l,...c},d)=>{const{width:f,isResizing:p,handleMouseDown:m,handleTouchStart:h}=kw({defaultWidth:t,minWidth:n,maxWidth:r,position:o,onWidthChange:l}),x={width:`${f}px`},g=o==="left"?"right-0":"left-0";return a.jsxs("div",{ref:d,className:ve("relative h-full flex-shrink-0 cursor-pointer",o==="left"?"border-r":"border-l",i),style:x,...c,children:[a.jsx("div",{className:ve("h-full overflow-x-hidden overflow-y-auto"),children:e}),s&&a.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",p&&"bg-[var(--color-primary-wMain)]"),onMouseDown:m,onTouchStart:h,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} panel`,tabIndex:0,onKeyDown:b=>{if(b.key==="ArrowLeft"||b.key==="ArrowRight"){b.preventDefault();const w=b.key==="ArrowRight"?10:-10,y=o==="right"?-w:w,E=Math.min(Math.max(f+y,n),r);l==null||l(E)}},children:a.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",p&&"bg-[var(--color-primary-wMain)]")})})]})});Nw.displayName="SidePanel";const Qu=u.createContext(null),ed=u.createContext(void 0),td=u.createContext(null),nd=u.createContext(null),rd=u.createContext(void 0),od=u.createContext(null);function Jt(){const e=u.useContext(td);if(e===null)throw new Error("useConfig must be used within a ConfigProvider");return e}const _w="https://solace.com/a2a/extensions/display-name",Iw="https://solace.com/a2a/extensions/peer-agent-topology",jw="https://solace.com/a2a/extensions/sam/tools",Mw=e=>{var o,s,i,l;let t,n,r;if((o=e.capabilities)!=null&&o.extensions){const c=e.capabilities.extensions.find(p=>p.uri===_w);(s=c==null?void 0:c.params)!=null&&s.display_name&&(t=c.params.display_name);const d=e.capabilities.extensions.find(p=>p.uri===Iw);(i=d==null?void 0:d.params)!=null&&i.peer_agent_names&&(n=d.params.peer_agent_names);const f=e.capabilities.extensions.find(p=>p.uri===jw);(l=f==null?void 0:f.params)!=null&&l.tools&&(r=f.params.tools)}return{...e,display_name:t,peer_agents:n||[],tools:r||[],displayName:t,peerAgents:n||[]}},sd=()=>{const{configServerUrl:e}=Jt(),[t,n]=u.useState([]),[r,o]=u.useState({}),[s,i]=u.useState(!0),[l,c]=u.useState(null),d=u.useCallback(async()=>{i(!0),c(null);try{const f=`${e}/api/v1`,p=await Pe(`${f}/agentCards`,{credentials:"include"});if(!p.ok){const g=await p.json().catch(()=>({message:`Failed to fetch agents: ${p.statusText}`}));throw new Error(g.message||`Failed to fetch agents: ${p.statusText}`)}const h=(await p.json()).map(Mw);n(h);const x={};h.forEach(g=>{g.name&&(x[g.name]=g.displayName||g.name)}),o(x)}catch(f){console.error("Error fetching agents:",f),c(f instanceof Error?f.message:"Could not load agent information."),n([])}finally{i(!1)}},[e]);return u.useEffect(()=>{d()},[d]),u.useMemo(()=>({agents:t,agentNameMap:r,isLoading:s,error:l,refetch:d}),[t,r,s,l,d])},Rw=e=>{const{configServerUrl:t}=Jt(),[n,r]=u.useState([]),[o,s]=u.useState(!0),[i,l]=u.useState(null),c=`${t}/api/v1`,d=u.useCallback(async()=>{if(!e){r([]),s(!1);return}s(!0),l(null);try{const f=await Pe(`${c}/artifacts/${e}`,{credentials:"include"});if(!f.ok){const m=await f.json().catch(()=>({message:`Failed to fetch artifacts. ${f.statusText}`}));throw new Error(m.message||`Failed to fetch artifacts. ${f.statusText}`)}const p=await f.json();r(p)}catch(f){const p=f instanceof Error?f.message:"Failed to fetch artifacts.";l(p),r([])}finally{s(!1)}},[c,e]);return u.useEffect(()=>{d()},[d]),{artifacts:n,isLoading:o,error:i,refetch:d}},Pw=()=>{const e=u.useContext(Qu);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Ye=()=>{const e=u.useContext(ed);if(e===void 0)throw new Error("useChatContext must be used within a ChatProvider");return e};function Lw(){const{messages:e}=Ye(),t=Jt(),n=u.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]);u.useEffect(()=>(window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n)}),[n])}function id(){const e=u.useContext(nd);if(!e)throw new Error("useCsrf must be used within a CsrfProvider");return e}function Dw(e,t){const[n,r]=u.useState(e);return u.useEffect(()=>{const o=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(o)}},[e,t]),n}const Ow=async(e,t,n)=>{const r=await Pe(`${e}/api/v1/artifacts/${t}/${encodeURIComponent(n.filename)}`,{credentials:"include"});if(!r.ok)throw new Error(`Failed to download artifact: ${n.filename}. Status: ${r.status}`);const o=await r.blob();Cc(o,n.filename)},ad=()=>{const{configServerUrl:e}=Jt(),{addNotification:t,sessionId:n}=Ye();return{onDownload:async o=>{if(!n){t("Cannot download artifact: No active session.","error");return}try{await Ow(e,n,o),t(`Downloaded artifact: ${o.filename}.`)}catch{t(`Failed to download artifact: ${o.filename}.`,"error")}}}},Fw=({onFilesDropped:e,fileFilter:t,disabled:n=!1})=>{const[r,o]=u.useState(!1),s=u.useRef(0),i=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),s.current=(s.current||0)+1,f.dataTransfer.types.includes("Files")&&o(!0))},[n,s]),l=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),f.dataTransfer.types.includes("Files")&&(f.dataTransfer.dropEffect="copy"))},[n]),c=u.useCallback(f=>{n||(f.preventDefault(),f.stopPropagation(),s.current=(s.current||0)-1,s.current===0&&o(!1))},[n,s]),d=u.useCallback(f=>{if(n||(f.preventDefault(),f.stopPropagation(),o(!1),s.current=0,!f.dataTransfer.files||f.dataTransfer.files.length===0))return;const p=Array.from(f.dataTransfer.files),m=t?p.filter(t):p;m.length!==0&&e(m)},[n,s,t,e]);return{isDragging:r,handleDragEnter:i,handleDragOver:l,handleDragLeave:c,handleDrop:d}},ta=()=>{const e=u.useContext(rd);if(e===void 0)throw new Error("useTaskContext must be used within a TaskProvider");return e};function ld(){const e=u.useContext(od);if(e===null)throw new Error("useThemeContext must be used within a ThemeProvider");return e}u.createContext(null);function cd(e){const t=e+"CollectionProvider",[n,r]=Pn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:v,children:b}=g,w=Yt.useRef(null),y=Yt.useRef(new Map).current;return a.jsx(o,{scope:v,itemMap:y,collectionRef:w,children:b})};i.displayName=t;const l=e+"CollectionSlot",c=Un(l),d=Yt.forwardRef((g,v)=>{const{scope:b,children:w}=g,y=s(l,b),E=ze(v,y.collectionRef);return a.jsx(c,{ref:E,children:w})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=Un(f),h=Yt.forwardRef((g,v)=>{const{scope:b,children:w,...y}=g,E=Yt.useRef(null),T=ze(v,E),j=s(f,b);return Yt.useEffect(()=>(j.itemMap.set(E,{ref:E,...y}),()=>void j.itemMap.delete(E))),a.jsx(m,{[p]:"",ref:T,children:w})});h.displayName=f;function x(g){const v=s(e+"CollectionConsumer",g);return Yt.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((j,k)=>y.indexOf(j.ref.current)-y.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:d,ItemSlot:h},x,r]}var zw=u.createContext(void 0);function na(e){const t=u.useContext(zw);return e||t||"ltr"}const ra=u.forwardRef(({actions:e,className:t,...n},r)=>{const o=(i,l)=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l.onClick())},s=(i,l)=>{var d,f,p,m,h;const c=(d=i.currentTarget.parentElement)==null?void 0:d.querySelectorAll('[role="menuitem"]');if(c)switch(i.key){case"ArrowDown":{i.preventDefault();const x=(l+1)%c.length;(f=c[x])==null||f.focus();break}case"ArrowUp":{i.preventDefault();const x=(l-1+c.length)%c.length;(p=c[x])==null||p.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 a.jsx("div",{ref:r,role:"menu",className:ve("min-w-[8rem] overflow-hidden",t),...n,children:e.map((i,l)=>a.jsxs(u.Fragment,{children:[i.divider&&l>0&&a.jsx("div",{className:"my-1 h-px bg-[var(--color-secondary-w40)] dark:bg-[var(--color-secondary-w70)]"}),a.jsxs("div",{role:"menuitem",tabIndex:0,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),s(c,l)},children:[i.icon&&i.iconPosition!=="right"&&a.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon}),a.jsx("span",{className:"flex-1",children:i.label}),i.icon&&i.iconPosition==="right"&&a.jsx("span",{className:"flex h-4 w-4 items-center justify-center",children:i.icon})]})]},i.id))})});ra.displayName="Menu";var us="Popover",[ud]=Pn(us,[Tr]),oo=Tr(),[$w,Ln]=ud(us),dd=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,l=oo(t),c=u.useRef(null),[d,f]=u.useState(!1),[p,m]=Wn({prop:r,defaultProp:o??!1,onChange:s,caller:us});return a.jsx(Fi,{...l,children:a.jsx($w,{scope:t,contentId:an(),triggerRef:c,open:p,onOpenChange:m,onOpenToggle:u.useCallback(()=>m(h=>!h),[m]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>f(!0),[]),onCustomAnchorRemove:u.useCallback(()=>f(!1),[]),modal:i,children:n})})};dd.displayName=us;var fd="PopoverAnchor",Bw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ln(fd,n),s=oo(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:l}=o;return u.useEffect(()=>(i(),()=>l()),[i,l]),a.jsx(Jo,{...s,...r,ref:t})});Bw.displayName=fd;var pd="PopoverTrigger",md=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ln(pd,n),s=oo(n),i=ze(t,o.triggerRef),l=a.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":wd(o.open),...r,ref:i,onClick:he(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:a.jsx(Jo,{asChild:!0,...s,children:l})});md.displayName=pd;var oa="PopoverPortal",[Uw,Hw]=ud(oa,{forceMount:void 0}),hd=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=Ln(oa,t);return a.jsx(Uw,{scope:t,forceMount:n,children:a.jsx(Cn,{present:n||s.open,children:a.jsx(Zr,{asChild:!0,container:o,children:r})})})};hd.displayName=oa;var gr="PopoverContent",gd=u.forwardRef((e,t)=>{const n=Hw(gr,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=Ln(gr,e.__scopePopover);return a.jsx(Cn,{present:r||s.open,children:s.modal?a.jsx(Gw,{...o,ref:t}):a.jsx(Vw,{...o,ref:t})})});gd.displayName=gr;var Ww=Un("PopoverContent.RemoveScroll"),Gw=u.forwardRef((e,t)=>{const n=Ln(gr,e.__scopePopover),r=u.useRef(null),o=ze(t,r),s=u.useRef(!1);return u.useEffect(()=>{const i=r.current;if(i)return Ki(i)},[]),a.jsx(rs,{as:Ww,allowPinchZoom:!0,children:a.jsx(xd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:he(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:he(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),Vw=u.forwardRef((e,t)=>{const n=Ln(gr,e.__scopePopover),r=u.useRef(!1),o=u.useRef(!1);return a.jsx(xd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),xd=u.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:f,...p}=e,m=Ln(gr,n),h=oo(n);return Yi(),a.jsx(ts,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:a.jsx(qr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:a.jsx(zi,{"data-state":wd(m.open),role:"dialog",id:m.contentId,...h,...p,ref:t,style:{...p.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)"}})})})}),vd="PopoverClose",Yw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ln(vd,n);return a.jsx(_e.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});Yw.displayName=vd;var Kw="PopoverArrow",qw=u.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=oo(n);return a.jsx($i,{...o,...r,ref:t})});qw.displayName=Kw;function wd(e){return e?"open":"closed"}var Xw=dd,Zw=md,Jw=hd,Qw=gd;function bd({...e}){return a.jsx(Xw,{"data-slot":"popover",...e})}function yd({...e}){return a.jsx(Zw,{"data-slot":"popover-trigger",...e})}function Sd({className:e,align:t="center",sideOffset:n=4,...r}){return a.jsx(Jw,{children:a.jsx(Qw,{"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 e0({isOpen:e,onClose:t,anchorRef:n,children:r,placement:o="bottom-start",offset:s,className:i,closeOnClickOutside:l=!0,closeOnEscape:c=!0,portal:d=!0,animationDuration:f=150,fallbackPlacements:p}){const m=u.useRef(null),[h,x]=u.useState({}),[g,v]=u.useState(!1);Sw({ref:m,anchorRef:n,onClickOutside:t,enabled:e&&l}),Cw({onEscape:t,enabled:e&&c});const{getPositionStyle:b}=Aw({anchorRef:n,placement:o,offset:s,fallbackPlacements:p});if(u.useEffect(()=>{e&&m.current?(v(!1),requestAnimationFrame(()=>{if(m.current){const y=b(m.current);x(y),v(!0)}})):v(!1)},[e,b]),!e)return null;const w=a.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 ${f}ms ease-in-out, transform ${f}ms ease-in-out`,pointerEvents:e&&g?"auto":"none",visibility:g?"visible":"hidden"},children:r});return d?Kr.createPortal(w,document.body):w}function dl(e,[t,n]){return Math.min(n,Math.max(t,e))}function t0(e){const t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var n0=[" ","Enter","ArrowUp","ArrowDown"],r0=[" ","Enter"],Yn="Select",[ds,fs,o0]=cd(Yn),[Ar]=Pn(Yn,[o0,Tr]),ps=Tr(),[s0,Dn]=Ar(Yn),[i0,a0]=Ar(Yn),Cd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:l,onValueChange:c,dir:d,name:f,autoComplete:p,disabled:m,required:h,form:x}=e,g=ps(t),[v,b]=u.useState(null),[w,y]=u.useState(null),[E,T]=u.useState(!1),j=na(d),[k,_]=Wn({prop:r,defaultProp:o??!1,onChange:s,caller:Yn}),[G,U]=Wn({prop:i,defaultProp:l,onChange:c,caller:Yn}),B=u.useRef(null),Z=v?x||!!v.closest("form"):!0,[J,D]=u.useState(new Set),X=Array.from(J).map(A=>A.props.value).join(";");return a.jsx(Fi,{...g,children:a.jsxs(s0,{required:h,scope:t,trigger:v,onTriggerChange:b,valueNode:w,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:an(),value:G,onValueChange:U,open:k,onOpenChange:_,dir:j,triggerPointerDownPosRef:B,disabled:m,children:[a.jsx(ds.Provider,{scope:t,children:a.jsx(i0,{scope:e.__scopeSelect,onNativeOptionAdd:u.useCallback(A=>{D(Y=>new Set(Y).add(A))},[]),onNativeOptionRemove:u.useCallback(A=>{D(Y=>{const C=new Set(Y);return C.delete(A),C})},[]),children:n})}),Z?a.jsxs(Gd,{"aria-hidden":!0,required:h,tabIndex:-1,name:f,autoComplete:p,value:G,onChange:A=>U(A.target.value),disabled:m,form:x,children:[G===void 0?a.jsx("option",{value:""}):null,Array.from(J)]},X):null]})})};Cd.displayName=Yn;var Ed="SelectTrigger",Td=u.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ps(n),i=Dn(Ed,n),l=i.disabled||r,c=ze(t,i.onTriggerChange),d=fs(n),f=u.useRef("touch"),[p,m,h]=Yd(g=>{const v=d().filter(y=>!y.disabled),b=v.find(y=>y.value===i.value),w=Kd(v,g,b);w!==void 0&&i.onValueChange(w.value)}),x=g=>{l||(i.onOpenChange(!0),h()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return a.jsx(Jo,{asChild:!0,...s,children:a.jsx(_e.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":Vd(i.value)?"":void 0,...o,ref:c,onClick:he(o.onClick,g=>{g.currentTarget.focus(),f.current!=="mouse"&&x(g)}),onPointerDown:he(o.onPointerDown,g=>{f.current=g.pointerType;const v=g.target;v.hasPointerCapture(g.pointerId)&&v.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:he(o.onKeyDown,g=>{const v=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(v&&g.key===" ")&&n0.includes(g.key)&&(x(),g.preventDefault())})})})});Td.displayName=Ed;var Ad="SelectValue",kd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...l}=e,c=Dn(Ad,n),{onValueNodeHasChildrenChange:d}=c,f=s!==void 0,p=ze(t,c.onValueNodeChange);return dt(()=>{d(f)},[d,f]),a.jsx(_e.span,{...l,ref:p,style:{pointerEvents:"none"},children:Vd(c.value)?a.jsx(a.Fragment,{children:i}):s})});kd.displayName=Ad;var l0="SelectIcon",Nd=u.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return a.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Nd.displayName=l0;var c0="SelectPortal",_d=e=>a.jsx(Zr,{asChild:!0,...e});_d.displayName=c0;var Kn="SelectContent",Id=u.forwardRef((e,t)=>{const n=Dn(Kn,e.__scopeSelect),[r,o]=u.useState();if(dt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Kr.createPortal(a.jsx(jd,{scope:e.__scopeSelect,children:a.jsx(ds.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(Md,{...e,ref:t})});Id.displayName=Kn;var Gt=10,[jd,On]=Ar(Kn),u0="SelectContentImpl",d0=Un("SelectContent.RemoveScroll"),Md=u.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:x,hideWhenDetached:g,avoidCollisions:v,...b}=e,w=Dn(Kn,n),[y,E]=u.useState(null),[T,j]=u.useState(null),k=ze(t,N=>E(N)),[_,G]=u.useState(null),[U,B]=u.useState(null),Z=fs(n),[J,D]=u.useState(!1),X=u.useRef(!1);u.useEffect(()=>{if(y)return Ki(y)},[y]),Yi();const A=u.useCallback(N=>{const[K,...ee]=Z().map(ne=>ne.ref.current),[te]=ee.slice(-1),le=document.activeElement;for(const ne of N)if(ne===le||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===K&&T&&(T.scrollTop=0),ne===te&&T&&(T.scrollTop=T.scrollHeight),ne==null||ne.focus(),document.activeElement!==le))return},[Z,T]),Y=u.useCallback(()=>A([_,y]),[A,_,y]);u.useEffect(()=>{J&&Y()},[J,Y]);const{onOpenChange:C,triggerPointerDownPosRef:I}=w;u.useEffect(()=>{if(y){let N={x:0,y:0};const K=te=>{var le,ne;N={x:Math.abs(Math.round(te.pageX)-(((le=I.current)==null?void 0:le.x)??0)),y:Math.abs(Math.round(te.pageY)-(((ne=I.current)==null?void 0:ne.y)??0))}},ee=te=>{N.x<=10&&N.y<=10?te.preventDefault():y.contains(te.target)||C(!1),document.removeEventListener("pointermove",K),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",ee,{capture:!0})}}},[y,C,I]),u.useEffect(()=>{const N=()=>C(!1);return window.addEventListener("blur",N),window.addEventListener("resize",N),()=>{window.removeEventListener("blur",N),window.removeEventListener("resize",N)}},[C]);const[F,R]=Yd(N=>{const K=Z().filter(le=>!le.disabled),ee=K.find(le=>le.ref.current===document.activeElement),te=Kd(K,N,ee);te&&setTimeout(()=>te.ref.current.focus())}),Q=u.useCallback((N,K,ee)=>{const te=!X.current&&!ee;(w.value!==void 0&&w.value===K||te)&&(G(N),te&&(X.current=!0))},[w.value]),O=u.useCallback(()=>y==null?void 0:y.focus(),[y]),W=u.useCallback((N,K,ee)=>{const te=!X.current&&!ee;(w.value!==void 0&&w.value===K||te)&&B(N)},[w.value]),z=r==="popper"?ri:Rd,q=z===ri?{side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:x,hideWhenDetached:g,avoidCollisions:v}:{};return a.jsx(jd,{scope:n,content:y,viewport:T,onViewportChange:j,itemRefCallback:Q,selectedItem:_,onItemLeave:O,itemTextRefCallback:W,focusSelectedItem:Y,selectedItemText:U,position:r,isPositioned:J,searchRef:F,children:a.jsx(rs,{as:d0,allowPinchZoom:!0,children:a.jsx(ts,{asChild:!0,trapped:w.open,onMountAutoFocus:N=>{N.preventDefault()},onUnmountAutoFocus:he(o,N=>{var K;(K=w.trigger)==null||K.focus({preventScroll:!0}),N.preventDefault()}),children:a.jsx(qr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:N=>N.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:a.jsx(z,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:N=>N.preventDefault(),...b,...q,onPlaced:()=>D(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:he(b.onKeyDown,N=>{const K=N.ctrlKey||N.altKey||N.metaKey;if(N.key==="Tab"&&N.preventDefault(),!K&&N.key.length===1&&R(N.key),["ArrowUp","ArrowDown","Home","End"].includes(N.key)){let te=Z().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(N.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(N.key)){const le=N.target,ne=te.indexOf(le);te=te.slice(ne+1)}setTimeout(()=>A(te)),N.preventDefault()}})})})})})})});Md.displayName=u0;var f0="SelectItemAlignedPosition",Rd=u.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Dn(Kn,n),i=On(Kn,n),[l,c]=u.useState(null),[d,f]=u.useState(null),p=ze(t,k=>f(k)),m=fs(n),h=u.useRef(!1),x=u.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:b,focusSelectedItem:w}=i,y=u.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&g&&v&&b){const k=s.trigger.getBoundingClientRect(),_=d.getBoundingClientRect(),G=s.valueNode.getBoundingClientRect(),U=b.getBoundingClientRect();if(s.dir!=="rtl"){const le=U.left-_.left,ne=G.left-le,de=k.left-ne,we=k.width+de,je=Math.max(we,_.width),Re=window.innerWidth-Gt,Le=dl(ne,[Gt,Math.max(Gt,Re-je)]);l.style.minWidth=we+"px",l.style.left=Le+"px"}else{const le=_.right-U.right,ne=window.innerWidth-G.right-le,de=window.innerWidth-k.right-ne,we=k.width+de,je=Math.max(we,_.width),Re=window.innerWidth-Gt,Le=dl(ne,[Gt,Math.max(Gt,Re-je)]);l.style.minWidth=we+"px",l.style.right=Le+"px"}const B=m(),Z=window.innerHeight-Gt*2,J=g.scrollHeight,D=window.getComputedStyle(d),X=parseInt(D.borderTopWidth,10),A=parseInt(D.paddingTop,10),Y=parseInt(D.borderBottomWidth,10),C=parseInt(D.paddingBottom,10),I=X+A+J+C+Y,F=Math.min(v.offsetHeight*5,I),R=window.getComputedStyle(g),Q=parseInt(R.paddingTop,10),O=parseInt(R.paddingBottom,10),W=k.top+k.height/2-Gt,z=Z-W,q=v.offsetHeight/2,N=v.offsetTop+q,K=X+A+N,ee=I-K;if(K<=W){const le=B.length>0&&v===B[B.length-1].ref.current;l.style.bottom="0px";const ne=d.clientHeight-g.offsetTop-g.offsetHeight,de=Math.max(z,q+(le?O:0)+ne+Y),we=K+de;l.style.height=we+"px"}else{const le=B.length>0&&v===B[0].ref.current;l.style.top="0px";const de=Math.max(W,X+g.offsetTop+(le?Q:0)+q)+ee;l.style.height=de+"px",g.scrollTop=K-W+g.offsetTop}l.style.margin=`${Gt}px 0`,l.style.minHeight=F+"px",l.style.maxHeight=Z+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[m,s.trigger,s.valueNode,l,d,g,v,b,s.dir,r]);dt(()=>y(),[y]);const[E,T]=u.useState();dt(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);const j=u.useCallback(k=>{k&&x.current===!0&&(y(),w==null||w(),x.current=!1)},[y,w]);return a.jsx(m0,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:j,children:a.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:a.jsx(_e.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Rd.displayName=f0;var p0="SelectPopperPosition",ri=u.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Gt,...s}=e,i=ps(n);return a.jsx(zi,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.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)"}})});ri.displayName=p0;var[m0,sa]=Ar(Kn,{}),oi="SelectViewport",Pd=u.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=On(oi,n),i=sa(oi,n),l=ze(t,s.onViewportChange),c=u.useRef(0);return a.jsxs(a.Fragment,{children:[a.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}),a.jsx(ds.Slot,{scope:n,children:a.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:he(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const h=Math.abs(c.current-f.scrollTop);if(h>0){const x=window.innerHeight-Gt*2,g=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),b=Math.max(g,v);if(b<x){const w=b+h,y=Math.min(x,w),E=w-y;p.style.height=y+"px",p.style.bottom==="0px"&&(f.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});Pd.displayName=oi;var Ld="SelectGroup",[h0,g0]=Ar(Ld),x0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=an();return a.jsx(h0,{scope:n,id:o,children:a.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});x0.displayName=Ld;var Dd="SelectLabel",v0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=g0(Dd,n);return a.jsx(_e.div,{id:o.id,...r,ref:t})});v0.displayName=Dd;var zo="SelectItem",[w0,Od]=Ar(zo),Fd=u.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,l=Dn(zo,n),c=On(zo,n),d=l.value===r,[f,p]=u.useState(s??""),[m,h]=u.useState(!1),x=ze(t,w=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,w,r,o)}),g=an(),v=u.useRef("touch"),b=()=>{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 a.jsx(w0,{scope:n,value:r,disabled:o,textId:g,isSelected:d,onItemTextChange:u.useCallback(w=>{p(y=>y||((w==null?void 0:w.textContent)??"").trim())},[]),children:a.jsx(ds.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:a.jsx(_e.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:he(i.onFocus,()=>h(!0)),onBlur:he(i.onBlur,()=>h(!1)),onClick:he(i.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:he(i.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:he(i.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:he(i.onPointerMove,w=>{var y;v.current=w.pointerType,o?(y=c.onItemLeave)==null||y.call(c):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:he(i.onPointerLeave,w=>{var y;w.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:he(i.onKeyDown,w=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(r0.includes(w.key)&&b(),w.key===" "&&w.preventDefault())})})})})});Fd.displayName=zo;var Or="SelectItemText",zd=u.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Dn(Or,n),l=On(Or,n),c=Od(Or,n),d=a0(Or,n),[f,p]=u.useState(null),m=ze(t,b=>p(b),c.onItemTextChange,b=>{var w;return(w=l.itemTextRefCallback)==null?void 0:w.call(l,b,c.value,c.disabled)}),h=f==null?void 0:f.textContent,x=u.useMemo(()=>a.jsx("option",{value:c.value,disabled:c.disabled,children:h},c.value),[c.disabled,c.value,h]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=d;return dt(()=>(g(x),()=>v(x)),[g,v,x]),a.jsxs(a.Fragment,{children:[a.jsx(_e.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Kr.createPortal(s.children,i.valueNode):null]})});zd.displayName=Or;var $d="SelectItemIndicator",Bd=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Od($d,n).isSelected?a.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});Bd.displayName=$d;var si="SelectScrollUpButton",Ud=u.forwardRef((e,t)=>{const n=On(si,e.__scopeSelect),r=sa(si,e.__scopeSelect),[o,s]=u.useState(!1),i=ze(t,r.onScrollButtonChange);return dt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollTop>0;s(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Wd,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});Ud.displayName=si;var ii="SelectScrollDownButton",Hd=u.forwardRef((e,t)=>{const n=On(ii,e.__scopeSelect),r=sa(ii,e.__scopeSelect),[o,s]=u.useState(!1),i=ze(t,r.onScrollButtonChange);return dt(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<d;s(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?a.jsx(Wd,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});Hd.displayName=ii;var Wd=u.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=On("SelectScrollButton",n),i=u.useRef(null),l=fs(n),c=u.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),dt(()=>{var f;const d=l().find(p=>p.ref.current===document.activeElement);(f=d==null?void 0:d.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),a.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:he(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:he(o.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{c()})})}),b0="SelectSeparator",y0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return a.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});y0.displayName=b0;var ai="SelectArrow",S0=u.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ps(n),s=Dn(ai,n),i=On(ai,n);return s.open&&i.position==="popper"?a.jsx($i,{...o,...r,ref:t}):null});S0.displayName=ai;var C0="SelectBubbleInput",Gd=u.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=u.useRef(null),s=ze(r,o),i=t0(t);return u.useEffect(()=>{const l=o.current;if(!l)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const p=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(p)}},[i,t]),a.jsx(_e.select,{...n,style:{...Kc,...n.style},ref:s,defaultValue:t})});Gd.displayName=C0;function Vd(e){return e===""||e===void 0}function Yd(e){const t=_n(e),n=u.useRef(""),r=u.useRef(0),o=u.useCallback(i=>{const l=n.current+i;t(l),(function c(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),s=u.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Kd(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=E0(e,Math.max(s,0));o.length===1&&(i=i.filter(d=>d!==n));const c=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function E0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var T0=Cd,A0=Td,k0=kd,N0=Nd,_0=_d,I0=Id,j0=Pd,M0=Fd,R0=zd,P0=Bd,L0=Ud,D0=Hd;function qd({...e}){return a.jsx(T0,{"data-slot":"select",...e})}function Xd({...e}){return a.jsx(k0,{"data-slot":"select-value",...e})}function Zd({className:e,size:t="default",children:n,...r}){return a.jsxs(A0,{"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,a.jsx(N0,{asChild:!0,children:a.jsx(Xl,{className:"size-4 opacity-50"})})]})}function Jd({className:e,children:t,position:n="popper",...r}){return a.jsx(_0,{children:a.jsxs(I0,{"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:[a.jsx(O0,{}),a.jsx(j0,{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}),a.jsx(F0,{})]})})}function Qd({className:e,children:t,...n}){return a.jsxs(M0,{"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:[a.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:a.jsx(P0,{children:a.jsx(Ei,{className:"size-4"})})}),a.jsx(R0,{children:t})]})}function O0({className:e,...t}){return a.jsx(L0,{"data-slot":"select-scroll-up-button",className:ve("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Wp,{className:"size-4"})})}function F0({className:e,...t}){return a.jsx(D0,{"data-slot":"select-scroll-down-button",className:ve("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(Xl,{className:"size-4"})})}var Ls="rovingFocusGroup.onEntryFocus",z0={bubbles:!1,cancelable:!0},so="RovingFocusGroup",[li,ef,$0]=cd(so),[B0,tf]=Pn(so,[$0]),[U0,H0]=B0(so),nf=u.forwardRef((e,t)=>a.jsx(li.Provider,{scope:e.__scopeRovingFocusGroup,children:a.jsx(li.Slot,{scope:e.__scopeRovingFocusGroup,children:a.jsx(W0,{...e,ref:t})})}));nf.displayName=so;var W0=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=u.useRef(null),h=ze(t,m),x=na(s),[g,v]=Wn({prop:i,defaultProp:l??null,onChange:c,caller:so}),[b,w]=u.useState(!1),y=_n(d),E=ef(n),T=u.useRef(!1),[j,k]=u.useState(0);return u.useEffect(()=>{const _=m.current;if(_)return _.addEventListener(Ls,y),()=>_.removeEventListener(Ls,y)},[y]),a.jsx(U0,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:g,onItemFocus:u.useCallback(_=>v(_),[v]),onItemShiftTab:u.useCallback(()=>w(!0),[]),onFocusableItemAdd:u.useCallback(()=>k(_=>_+1),[]),onFocusableItemRemove:u.useCallback(()=>k(_=>_-1),[]),children:a.jsx(_e.div,{tabIndex:b||j===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:he(e.onMouseDown,()=>{T.current=!0}),onFocus:he(e.onFocus,_=>{const G=!T.current;if(_.target===_.currentTarget&&G&&!b){const U=new CustomEvent(Ls,z0);if(_.currentTarget.dispatchEvent(U),!U.defaultPrevented){const B=E().filter(A=>A.focusable),Z=B.find(A=>A.active),J=B.find(A=>A.id===g),X=[Z,J,...B].filter(Boolean).map(A=>A.ref.current);sf(X,f)}}T.current=!1}),onBlur:he(e.onBlur,()=>w(!1))})})}),rf="RovingFocusGroupItem",of=u.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...l}=e,c=an(),d=s||c,f=H0(rf,n),p=f.currentTabStopId===d,m=ef(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:g}=f;return u.useEffect(()=>{if(r)return h(),()=>x()},[r,h,x]),a.jsx(li.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:a.jsx(_e.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:he(e.onMouseDown,v=>{r?f.onItemFocus(d):v.preventDefault()}),onFocus:he(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:he(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=Y0(v,f.orientation,f.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=m().filter(E=>E.focusable).map(E=>E.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const E=y.indexOf(v.currentTarget);y=f.loop?K0(y,E+1):y.slice(E+1)}setTimeout(()=>sf(y))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});of.displayName=rf;var G0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function V0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Y0(e,t,n){const r=V0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return G0[r]}function sf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var q0=nf,X0=of,ms="Tabs",[Z0]=Pn(ms,[tf]),af=tf(),[J0,ia]=Z0(ms),lf=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:l,activationMode:c="automatic",...d}=e,f=na(l),[p,m]=Wn({prop:r,onChange:o,defaultProp:s??"",caller:ms});return a.jsx(J0,{scope:n,baseId:an(),value:p,onValueChange:m,orientation:i,dir:f,activationMode:c,children:a.jsx(_e.div,{dir:f,"data-orientation":i,...d,ref:t})})});lf.displayName=ms;var cf="TabsList",uf=u.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=ia(cf,n),i=af(n);return a.jsx(q0,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:a.jsx(_e.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});uf.displayName=cf;var df="TabsTrigger",ff=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=ia(df,n),l=af(n),c=hf(i.baseId,r),d=gf(i.baseId,r),f=r===i.value;return a.jsx(X0,{asChild:!0,...l,focusable:!o,active:f,children:a.jsx(_e.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:he(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?i.onValueChange(r):p.preventDefault()}),onKeyDown:he(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(r)}),onFocus:he(e.onFocus,()=>{const p=i.activationMode!=="manual";!f&&!o&&p&&i.onValueChange(r)})})})});ff.displayName=df;var pf="TabsContent",mf=u.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,l=ia(pf,n),c=hf(l.baseId,r),d=gf(l.baseId,r),f=r===l.value,p=u.useRef(f);return u.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),a.jsx(Cn,{present:o||f,children:({present:m})=>a.jsx(_e.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&s})})});mf.displayName=pf;function hf(e,t){return`${e}-trigger-${t}`}function gf(e,t){return`${e}-content-${t}`}var Q0=lf,eb=uf,tb=ff,nb=mf;function rb({className:e,...t}){return a.jsx(Q0,{"data-slot":"tabs",className:ve("flex flex-col gap-2",e),...t})}function ob({className:e,...t}){return a.jsx(eb,{"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 fl({className:e,...t}){return a.jsx(tb,{"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 pl({className:e,...t}){return a.jsx(nb,{"data-slot":"tabs-content",className:ve("flex-1 outline-none",e),...t})}const xf=u.forwardRef(({className:e,...t},n)=>a.jsx(Vi,{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}));xf.displayName="ChatInput";const sb=Rn("flex gap-2 max-w-[90%] 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"}}),vf=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:ve(sb({variant:t,layout:n,className:e}),"group relative"),ref:s,...o,children:u.Children.map(r,i=>u.isValidElement(i)&&typeof i.type!="string"?u.cloneElement(i,{variant:t,layout:n}):i)}));vf.displayName="ChatBubble";const ib=Rn("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"}}),wf=u.forwardRef(({className:e,variant:t,layout:n,children:r,...o},s)=>a.jsx("div",{className:ve(ib({variant:t,layout:n,className:e}),"relative max-w-full break-words whitespace-pre-wrap"),ref:s,...o,children:a.jsx(a.Fragment,{children:r})}));wf.displayName="ChatBubbleMessage";const ab=u.forwardRef(({variant:e,className:t,children:n,...r},o)=>a.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}));ab.displayName="ChatBubbleActionWrapper";const bf={padding:"0 16px",maxWidth:"1280px",minWidth:"400px",margin:"0 auto",width:"100%"},yf=Yt.forwardRef(({className:e="",children:t,...n},r)=>{const{scrollRef:o,isAtBottom:s,disableAutoScroll:i,scrollToBottom:l,userHasScrolled:c}=xb({smooth:!0,content:t});return u.useImperativeHandle(r,()=>({scrollToBottom:l})),a.jsxs("div",{className:`fade-both-mask relative h-full min-h-0 w-full flex-1 py-3 ${e}`,children:[a.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:a.jsx("div",{className:"flex flex-col gap-6",style:bf,children:t})}),!s&&c&&a.jsx(me,{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:a.jsx(Zl,{className:"h-4 w-4"})})]})});yf.displayName="ChatMessageList";const lb=Rn("flex-col items-center justify-center",{variants:{show:{true:"flex",false:"hidden"}},defaultVariants:{show:!0}}),cb=Rn("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 Sf({size:e,show:t,children:n,className:r,variant:o}){return a.jsxs("span",{className:lb({show:t}),children:[a.jsx(Ti,{className:ve(cb({size:e,variant:o}),r)}),n]})}function ub({className:e=""}){return a.jsx(Sf,{size:"small",variant:"primary",className:e})}const vo={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)]"},db=Rn("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:vo.error,warning:vo.warning,info:vo.info,success:vo.success}},defaultVariants:{variant:"default"}});function Cf({className:e,variant:t,type:n,asChild:r=!1,...o}){const s=r?dc:"span";return a.jsx(s,{"data-slot":"badge",className:ve(db({variant:t,type:n}),e),...o})}const fb=Rn("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 pb({className:e,variant:t,...n}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:ve(fb({variant:t}),e),...n})}function mb({className:e,...t}){return a.jsx("div",{"data-slot":"alert-title",className:ve("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}function hb({message:e,type:t}){return a.jsx("div",{className:"transform transition-all duration-200 ease-in-out",children:a.jsx(pb,{className:"border-border bg-accent max-w-80 rounded-sm shadow-md",children:a.jsxs(mb,{className:"flex items-center text-sm",children:[t==="error"&&a.jsx(Ai,{className:"mr-2 text-[var(--color-error-wMain)]"}),a.jsx("div",{className:"truncate",children:e})]})})})}function gb(){const{notifications:e}=Ye();return e.length===0?null:a.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=>a.jsx("div",{className:"pointer-events-auto",children:a.jsx(hb,{id:t.id,message:t.message,type:t.type,duration:t.type==="error"?5e3:3e3})},t.id))})}function xb(e={}){const{offset:t=20,smooth:n=!1,content:r,autoScrollOnNewContent:o=!1}=e,s=u.useRef(null),i=u.useRef(0),l=u.useRef(!1),[c,d]=u.useState({isAtBottom:!0,autoScrollEnabled:!0}),f=u.useCallback(x=>{const{scrollTop:g,scrollHeight:v,clientHeight:b}=x;return Math.abs(v-g-b)<=t},[t]),p=u.useCallback(x=>{if(!s.current)return;const g=s.current.scrollHeight-s.current.clientHeight;x?s.current.scrollTop=g:s.current.scrollTo({top:g,behavior:n?"smooth":"auto"}),d({isAtBottom:!0,autoScrollEnabled:!0}),l.current=!1},[n]),m=u.useCallback(()=>{if(!s.current)return;const x=f(s.current);d(g=>({isAtBottom:x,autoScrollEnabled:x?!0:g.autoScrollEnabled}))},[f]);u.useEffect(()=>{const x=s.current;if(x)return x.addEventListener("scroll",m,{passive:!0}),()=>x.removeEventListener("scroll",m)},[m]),u.useEffect(()=>{const x=s.current;if(!x)return;const g=x.scrollHeight;g!==i.current&&((c.autoScrollEnabled||o)&&requestAnimationFrame(()=>{p(i.current===0)}),i.current=g)},[r,c.autoScrollEnabled,p,o]),u.useEffect(()=>{const x=s.current;if(!x)return;const g=new ResizeObserver(()=>{c.autoScrollEnabled&&p(!0)});return g.observe(x),()=>g.disconnect()},[c.autoScrollEnabled,p]);const h=u.useCallback(()=>{(s.current?f(s.current):!1)||(l.current=!0,d(g=>({...g,autoScrollEnabled:!1})))},[f]);return{scrollRef:s,isAtBottom:c.isAtBottom,autoScrollEnabled:c.autoScrollEnabled,scrollToBottom:()=>p(),disableAutoScroll:h,userHasScrolled:l.current}}const vb=({fileName:e,onRemove:t})=>a.jsxs(Cf,{className:"bg-muted max-w-50 gap-1.5 rounded-full pr-1",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs md:text-sm",title:e,children:e}),t&&a.jsx(me,{variant:"ghost",size:"icon",onClick:t,className:"h-2 min-h-0 w-2 min-w-0 p-2",title:"Remove file",children:a.jsx(Vo,{})})]}),wb=({agents:e=[],scrollToBottom:t})=>{const{isResponding:n,isCancelling:r,userInput:o,selectedAgentName:s,setSelectedAgentName:i,setUserInput:l,handleSubmit:c,handleCancel:d}=Ye(),f=u.useRef(null),[p,m]=u.useState([]),h=u.useRef(null),x=u.useRef(n),[g,v]=u.useState(o),b=Dw(g,300);u.useEffect(()=>{l(b)},[b,l]),u.useEffect(()=>{v(o)},[o]),u.useEffect(()=>{x.current&&!n&&setTimeout(()=>{var D;(D=h.current)==null||D.focus()},100),x.current=n},[n]);const w=()=>{var D;n||(D=f.current)==null||D.click()},y=D=>{const X=D.target.files;if(X){const A=Array.from(X).filter(Y=>!p.some(C=>C.name===Y.name&&C.size===Y.size&&C.lastModified===Y.lastModified));A.length>0&&m(Y=>[...Y,...A])}D.target&&(D.target.value=""),setTimeout(()=>{var A;(A=h.current)==null||A.focus()},100)},E=D=>{if(n)return;const X=D.clipboardData;if(!X||!X.files||X.files.length===0)return;X.files.length>0&&D.preventDefault();const A=Array.from(X.files).filter(Y=>!p.some(C=>C.name===Y.name&&C.size===Y.size&&C.lastModified===Y.lastModified));A.length>0&&m(Y=>[...Y,...A])},T=D=>{m(X=>X.filter((A,Y)=>Y!==D))},j=u.useMemo(()=>!n&&((g==null?void 0:g.trim())||p.length!==0),[n,g,p]),k=async D=>{D.preventDefault(),j&&(await c(D,p,g.trim()),m([]),v(""),t==null||t())},_=D=>{if(n)return;const X=D.filter(A=>!p.some(Y=>Y.name===A.name&&Y.size===A.size&&Y.lastModified===A.lastModified));X.length>0&&m(A=>[...A,...X])},{isDragging:G,handleDragEnter:U,handleDragOver:B,handleDragLeave:Z,handleDrop:J}=Fw({onFilesDropped:_,disabled:n});return a.jsxs("div",{className:`rounded-lg border p-4 shadow-sm ${G?"border-dotted border-[var(--primary-wMain)] bg-[var(--accent-background)]":""}`,onDragEnter:U,onDragOver:B,onDragLeave:Z,onDrop:J,children:[a.jsx("input",{type:"file",ref:f,className:"hidden",multiple:!0,onChange:y,accept:"*/*",disabled:n}),p.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:p.map((D,X)=>a.jsx(vb,{fileName:D.name,onRemove:()=>T(X)},`${D.name}-${D.lastModified}-${X}`))}),a.jsx(xf,{ref:h,value:g,onChange:D=>v(D.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:E,onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&j&&k(D)}}),a.jsxs("div",{className:"m-2 flex items-center gap-2",children:[a.jsx(me,{variant:"ghost",onClick:w,disabled:n,tooltip:"Attach file",children:a.jsx(Jl,{className:"size-4"})}),a.jsx("div",{children:"Agent: "}),a.jsxs(qd,{value:s,onValueChange:i,disabled:n||e.length===0,children:[a.jsx(Zd,{className:"w-[250px]",children:a.jsx(Xd,{defaultValue:s})}),a.jsx(Jd,{children:e.map(D=>a.jsx(Qd,{value:D.name,children:D.displayName||D.name},D.name))})]}),n&&!r?a.jsxs(me,{className:"ml-auto gap-1.5",onClick:d,variant:"outline",disabled:r,tooltip:"Cancel",children:[a.jsx(Gp,{className:"size-4"}),"Stop"]}):a.jsx(me,{variant:"ghost",className:"ml-auto gap-1.5",onClick:k,disabled:!j,tooltip:"Send message",children:a.jsx(Vp,{className:"size-4"})})]})]})};function bb(e,t){return t&&t.toLowerCase().startsWith("text/")?!0:e?e.toLowerCase().endsWith(".txt")||e.toLowerCase().endsWith(".text"):!1}function yb(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 Sb(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 Cb(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 Eb(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 Tb(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 Ab(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 kb(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 Nb(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 io(e,t){return yb(e,t)?"html":Sb(e,t)?"mermaid":Eb(e,t)?"image":kb(e,t)?"markdown":Nb(e,t)?"audio":Tb(e,t)?"json":Ab(e,t)?"yaml":Cb(e,t)?"csv":bb(e,t)?"text":null}function Ef(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 Tf=["csv","html","json","mermaid","image","markdown","audio","text","yaml"],_b=["image","audio"],Ib=e=>{if(!e||!e.content)return"";const t=io(e.name,e.mime_type);if(!t||!Tf.includes(t))return"";if(_b.includes(t))return e.content;try{return Ef(e.content)}catch(n){return console.error("Failed to decode base64 content:",n),""}},Af=5*1024*1024,jb=Ec(Af);function Mb(e){if(!e||!e.size)return{canPreview:!1,reason:"No artifact or content available."};const t=io(e.filename,e.mime_type);return!t||!Tf.includes(t)?{canPreview:!1,reason:"Preview not yet supported for this file type."}:e.size>Af?{canPreview:!1,reason:`Preview not supported for files this large. Maximum size is: ${jb}.`}:{canPreview:!0}}const kf=(e,t="h-4 w-4")=>{if(!e)return a.jsx(xa,{className:t});switch(io(e.filename,e.mime_type)){case"image":case"mermaid":return a.jsx(Zp,{className:t});case"audio":return a.jsx(Xp,{className:t});case"html":return a.jsx(qp,{className:t});case"text":return a.jsx(pr,{className:t});case"csv":return a.jsx(Kp,{className:t});case"json":return a.jsx(Yp,{className:t});default:return a.jsx(xa,{className:t})}},Nf=({fileAttachment:e,isEmbedded:t=!1})=>a.jsx(_f,{filename:e.name,mimeType:e.mime_type,onDownload:()=>wh(e),className:"ml-4",isEmbedded:t}),_f=({filename:e,mimeType:t,className:n,onDownload:r,isEmbedded:o=!1})=>{const{artifacts:s,setPreviewArtifact:i,openSidePanelTab:l}=Ye(),c=u.useMemo(()=>s.find(f=>f.filename===e),[s,e]),d=u.useMemo(()=>kf(c||{filename:e,mime_type:t||""}),[c,e,t]);return a.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:[d,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-9",title:e,children:a.jsx("strong",{children:a.jsx("code",{children:e})})}),c&&!o&&a.jsx(me,{variant:"ghost",onClick:f=>{f.stopPropagation(),l("files"),i(c)},tooltip:"Preview",children:a.jsx(Ql,{className:"h-4 w-4"})}),r&&a.jsx(me,{variant:"ghost",onClick:()=>r(),tooltip:"Download file",children:a.jsx(Yo,{className:"h-4 w-4"})})]})},Rb=({isOpen:e,onClose:t,feedbackType:n,onSubmit:r})=>{const[o,s]=u.useState(""),[i,l]=u.useState(!1),c=u.useRef(null);u.useEffect(()=>{e&&(s(""),l(!1),setTimeout(()=>{var m;(m=c.current)==null||m.focus()},100))},[e]);const d=async()=>{l(!0);try{await r(o),t()}catch{l(!1)}},f=()=>{i||t()},p=n==="up"?"What did you like about the response?":"What did you dislike about the response?";return a.jsx(Qr,{open:e,onOpenChange:f,children:a.jsxs(eo,{className:"sm:max-w-[750px]",showCloseButton:!1,children:[a.jsxs(to,{children:[a.jsx(no,{children:"Provide Feedback"}),a.jsxs(ro,{className:"flex flex-col gap-2",children:[a.jsx("span",{className:"font-medium",children:p}),a.jsx("span",{children:"Providing more details will help improve AI responses over time."})]})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Vi,{ref:c,value:o,onChange:m=>s(m.target.value),className:"min-h-[120px] text-sm",disabled:i}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Along with your feedback, details of the task will be recorded."})]}),a.jsxs(ju,{children:[a.jsx(me,{variant:"ghost",onClick:f,disabled:i,children:"Cancel"}),a.jsx(me,{variant:"default",onClick:d,disabled:i,children:i?"Submitting...":"Submit"})]})]})})},Pb=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"audio/mpeg"};base64,${e}`;return a.jsx("div",{className:"flex h-auto max-w-[100vw] items-center justify-center p-4",children:a.jsxs("audio",{controls:!0,className:"w-full",onLoad:()=>n(null),onError:()=>n("Failed to load audio content."),children:[a.jsx("source",{src:r,type:t||"audio/mpeg"}),"Your browser does not support the audio element."]})})},Lb=e=>{if(!e)return[];const t=[];let n=[],r="",o=!1;for(let s=0;s<e.length;s++){const i=e[s],l=s<e.length-1?e[s+1]:"";i==='"'?l==='"'?(r+='"',s++):o=!o:i===","&&!o?(n.push(r.trim()),r=""):(i===`
117
- `||i==="\r"&&l===`
118
- `)&&!o?(i==="\r"&&l===`
119
- `&&s++,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(s=>s.trim())&&t.push(n)),t},Db=({content:e,setRenderError:t})=>{u.useEffect(()=>{t(null)},[e,t]);const n=u.useMemo(()=>{try{return Lb(e)}catch(r){return console.error("Error parsing CSV:",r),t("Failed to parse CSV content."),[]}},[e,t]);return n.length?a.jsx("div",{className:"block w-full overflow-x-scroll p-4",children:a.jsx("div",{style:{minWidth:"min(100%, max-content)"},children:a.jsxs("table",{className:"w-full border text-sm",children:[a.jsx("thead",{className:"sticky top-0 z-10 shadow-sm",children:n.length>0&&a.jsx("tr",{children:n[0].map((r,o)=>a.jsx("th",{className:"border-b p-2 text-left font-medium whitespace-nowrap",title:r,children:(r==null?void 0:r.trim())||""},`header-${o}`))})}),a.jsx("tbody",{children:n.slice(1).map((r,o)=>a.jsx("tr",{className:o%2===0?"bg-muted dark:bg-gray-700":"",children:r.map((s,i)=>a.jsx("td",{className:"min-w-0 border-b p-2 align-top break-words",title:s,children:(s==null?void 0:s.trim())||""},`cell-${o}-${i}`))},`row-${o}`))})]})})}):a.jsx("div",{children:"No valid CSV content found or failed to parse."})},Ob=({content:e,setRenderError:t})=>{const n=u.useMemo(()=>e.replace(/<script(?:\s[^>]*)?>([\s\S]*?)<\/script>/gi,(s,i)=>{const l=s.match(/<script(\s[^>]*)?>/i);return`<script${l&&l[1]?l[1]:""}>(function() {
120
- try {
121
- ${i}
122
- } catch (e) { console.error('Error in sandboxed script:', e); }
123
- })();<\/script>`}),[e]);return a.jsx("div",{className:"h-full w-full overflow-hidden border dark:bg-gray-400",children:a.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)})})},Fb=({content:e,mime_type:t,setRenderError:n})=>{const r=`data:${t||"image/png"};base64,${e}`;return a.jsx("div",{className:"flex h-auto w-auto max-w-[100vw] items-center justify-center p-4",children:a.jsx("img",{src:r,onError:()=>n("Failed to load image"),onLoad:()=>n(null),alt:"Preview",className:"h-full w-full object-contain"})})};function If(){const e=u.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 zb=({content:e})=>{const{ref:t,handleKeyDown:n}=If();return a.jsx("div",{className:"w-full p-4",children:a.jsx("div",{ref:t,className:"max-w-full overflow-hidden select-text focus-visible:outline-none",tabIndex:0,onKeyDown:n,children:a.jsx(fr,{className:"max-w-full break-words",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:jf,setPrototypeOf:ml,isFrozen:$b,getPrototypeOf:Bb,getOwnPropertyDescriptor:Ub}=Object;let{freeze:vt,seal:Ht,create:Mf}=Object,{apply:ci,construct:ui}=typeof Reflect<"u"&&Reflect;vt||(vt=function(t){return t});Ht||(Ht=function(t){return t});ci||(ci=function(t,n,r){return t.apply(n,r)});ui||(ui=function(t,n){return new t(...n)});const wo=wt(Array.prototype.forEach),Hb=wt(Array.prototype.lastIndexOf),hl=wt(Array.prototype.pop),Nr=wt(Array.prototype.push),Wb=wt(Array.prototype.splice),jo=wt(String.prototype.toLowerCase),Ds=wt(String.prototype.toString),gl=wt(String.prototype.match),_r=wt(String.prototype.replace),Gb=wt(String.prototype.indexOf),Vb=wt(String.prototype.trim),Vt=wt(Object.prototype.hasOwnProperty),ht=wt(RegExp.prototype.test),Ir=Yb(TypeError);function wt(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 ci(e,t,r)}}function Yb(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ui(e,n)}}function Ne(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:jo;ml&&ml(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const s=n(o);s!==o&&($b(t)||(t[r]=s),o=s)}e[o]=!0}return e}function Kb(e){for(let t=0;t<e.length;t++)Vt(e,t)||(e[t]=null);return e}function xn(e){const t=Mf(null);for(const[n,r]of jf(e))Vt(e,n)&&(Array.isArray(r)?t[n]=Kb(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=xn(r):t[n]=r);return t}function jr(e,t){for(;e!==null;){const r=Ub(e,t);if(r){if(r.get)return wt(r.get);if(typeof r.value=="function")return wt(r.value)}e=Bb(e)}function n(){return null}return n}const xl=vt(["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"]),Os=vt(["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"]),Fs=vt(["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"]),qb=vt(["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"]),zs=vt(["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"]),Xb=vt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),vl=vt(["#text"]),wl=vt(["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"]),$s=vt(["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"]),bl=vt(["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"]),bo=vt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Zb=Ht(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Jb=Ht(/<%[\w\W]*|[\w\W]*%>/gm),Qb=Ht(/\$\{[\w\W]*/gm),ey=Ht(/^data-[\-\w.\u00B7-\uFFFF]+$/),ty=Ht(/^aria-[\-\w]+$/),Rf=Ht(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ny=Ht(/^(?:\w+script|data):/i),ry=Ht(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pf=Ht(/^html$/i),oy=Ht(/^[a-z][.\w]*(-[.\w]+)+$/i);var yl=Object.freeze({__proto__:null,ARIA_ATTR:ty,ATTR_WHITESPACE:ry,CUSTOM_ELEMENT:oy,DATA_ATTR:ey,DOCTYPE_NAME:Pf,ERB_EXPR:Jb,IS_ALLOWED_URI:Rf,IS_SCRIPT_OR_DATA:ny,MUSTACHE_EXPR:Zb,TMPLIT_EXPR:Qb});const Mr={element:1,text:3,progressingInstruction:7,comment:8,document:9},sy=function(){return typeof window>"u"?null:window},iy=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 s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Sl=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Lf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sy();const t=P=>Lf(P);if(t.version="3.2.6",t.removed=[],!e||!e.document||e.document.nodeType!==Mr.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:i,Node:l,Element:c,NodeFilter:d,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:h}=e,x=c.prototype,g=jr(x,"cloneNode"),v=jr(x,"remove"),b=jr(x,"nextSibling"),w=jr(x,"childNodes"),y=jr(x,"parentNode");if(typeof i=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let E,T="";const{implementation:j,createNodeIterator:k,createDocumentFragment:_,getElementsByTagName:G}=n,{importNode:U}=r;let B=Sl();t.isSupported=typeof jf=="function"&&typeof y=="function"&&j&&j.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Z,ERB_EXPR:J,TMPLIT_EXPR:D,DATA_ATTR:X,ARIA_ATTR:A,IS_SCRIPT_OR_DATA:Y,ATTR_WHITESPACE:C,CUSTOM_ELEMENT:I}=yl;let{IS_ALLOWED_URI:F}=yl,R=null;const Q=Ne({},[...xl,...Os,...Fs,...zs,...vl]);let O=null;const W=Ne({},[...wl,...$s,...bl,...bo]);let z=Object.seal(Mf(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}})),q=null,N=null,K=!0,ee=!0,te=!1,le=!0,ne=!1,de=!0,we=!1,je=!1,Re=!1,Le=!1,Me=!1,We=!1,Lt=!0,qe=!1;const Dt="user-content-";let rt=!0,At=!1,ot={},st=null;const Ot=Ne({},["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 Qt=null;const Wt=Ne({},["audio","video","img","source","image","track"]);let se=null;const kt=Ne({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),pt="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml";let mt=Qe,yt=!1,Ft=null;const fn=Ne({},[pt,Nt,Qe],Ds);let St=Ne({},["mi","mo","mn","ms","mtext"]),zt=Ne({},["annotation-xml"]);const pn=Ne({},["title","style","font","a","script"]);let _t=null;const mn=["application/xhtml+xml","text/html"],hn="text/html";let De=null,Ct=null;const Ue=n.createElement("form"),et=function(S){return S instanceof RegExp||S instanceof Function},It=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ct&&Ct===S)){if((!S||typeof S!="object")&&(S={}),S=xn(S),_t=mn.indexOf(S.PARSER_MEDIA_TYPE)===-1?hn:S.PARSER_MEDIA_TYPE,De=_t==="application/xhtml+xml"?Ds:jo,R=Vt(S,"ALLOWED_TAGS")?Ne({},S.ALLOWED_TAGS,De):Q,O=Vt(S,"ALLOWED_ATTR")?Ne({},S.ALLOWED_ATTR,De):W,Ft=Vt(S,"ALLOWED_NAMESPACES")?Ne({},S.ALLOWED_NAMESPACES,Ds):fn,se=Vt(S,"ADD_URI_SAFE_ATTR")?Ne(xn(kt),S.ADD_URI_SAFE_ATTR,De):kt,Qt=Vt(S,"ADD_DATA_URI_TAGS")?Ne(xn(Wt),S.ADD_DATA_URI_TAGS,De):Wt,st=Vt(S,"FORBID_CONTENTS")?Ne({},S.FORBID_CONTENTS,De):Ot,q=Vt(S,"FORBID_TAGS")?Ne({},S.FORBID_TAGS,De):xn({}),N=Vt(S,"FORBID_ATTR")?Ne({},S.FORBID_ATTR,De):xn({}),ot=Vt(S,"USE_PROFILES")?S.USE_PROFILES:!1,K=S.ALLOW_ARIA_ATTR!==!1,ee=S.ALLOW_DATA_ATTR!==!1,te=S.ALLOW_UNKNOWN_PROTOCOLS||!1,le=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ne=S.SAFE_FOR_TEMPLATES||!1,de=S.SAFE_FOR_XML!==!1,we=S.WHOLE_DOCUMENT||!1,Le=S.RETURN_DOM||!1,Me=S.RETURN_DOM_FRAGMENT||!1,We=S.RETURN_TRUSTED_TYPE||!1,Re=S.FORCE_BODY||!1,Lt=S.SANITIZE_DOM!==!1,qe=S.SANITIZE_NAMED_PROPS||!1,rt=S.KEEP_CONTENT!==!1,At=S.IN_PLACE||!1,F=S.ALLOWED_URI_REGEXP||Rf,mt=S.NAMESPACE||Qe,St=S.MATHML_TEXT_INTEGRATION_POINTS||St,zt=S.HTML_INTEGRATION_POINTS||zt,z=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&et(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&et(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ne&&(ee=!1),Me&&(Le=!0),ot&&(R=Ne({},vl),O=[],ot.html===!0&&(Ne(R,xl),Ne(O,wl)),ot.svg===!0&&(Ne(R,Os),Ne(O,$s),Ne(O,bo)),ot.svgFilters===!0&&(Ne(R,Fs),Ne(O,$s),Ne(O,bo)),ot.mathMl===!0&&(Ne(R,zs),Ne(O,bl),Ne(O,bo))),S.ADD_TAGS&&(R===Q&&(R=xn(R)),Ne(R,S.ADD_TAGS,De)),S.ADD_ATTR&&(O===W&&(O=xn(O)),Ne(O,S.ADD_ATTR,De)),S.ADD_URI_SAFE_ATTR&&Ne(se,S.ADD_URI_SAFE_ATTR,De),S.FORBID_CONTENTS&&(st===Ot&&(st=xn(st)),Ne(st,S.FORBID_CONTENTS,De)),rt&&(R["#text"]=!0),we&&Ne(R,["html","head","body"]),R.table&&(Ne(R,["tbody"]),delete q.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ir('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ir('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=S.TRUSTED_TYPES_POLICY,T=E.createHTML("")}else E===void 0&&(E=iy(h,o)),E!==null&&typeof T=="string"&&(T=E.createHTML(""));vt&&vt(S),Ct=S}},en=Ne({},[...Os,...Fs,...qb]),$t=Ne({},[...zs,...Xb]),xe=function(S){let L=y(S);(!L||!L.tagName)&&(L={namespaceURI:mt,tagName:"template"});const H=jo(S.tagName),ie=jo(L.tagName);return Ft[S.namespaceURI]?S.namespaceURI===Nt?L.namespaceURI===Qe?H==="svg":L.namespaceURI===pt?H==="svg"&&(ie==="annotation-xml"||St[ie]):!!en[H]:S.namespaceURI===pt?L.namespaceURI===Qe?H==="math":L.namespaceURI===Nt?H==="math"&&zt[ie]:!!$t[H]:S.namespaceURI===Qe?L.namespaceURI===Nt&&!zt[ie]||L.namespaceURI===pt&&!St[ie]?!1:!$t[H]&&(pn[H]||!en[H]):!!(_t==="application/xhtml+xml"&&Ft[S.namespaceURI]):!1},Ce=function(S){Nr(t.removed,{element:S});try{y(S).removeChild(S)}catch{v(S)}},Ie=function(S,L){try{Nr(t.removed,{attribute:L.getAttributeNode(S),from:L})}catch{Nr(t.removed,{attribute:null,from:L})}if(L.removeAttribute(S),S==="is")if(Le||Me)try{Ce(L)}catch{}else try{L.setAttribute(S,"")}catch{}},Te=function(S){let L=null,H=null;if(Re)S="<remove></remove>"+S;else{const fe=gl(S,/^[\r\n\t ]+/);H=fe&&fe[0]}_t==="application/xhtml+xml"&&mt===Qe&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const ie=E?E.createHTML(S):S;if(mt===Qe)try{L=new m().parseFromString(ie,_t)}catch{}if(!L||!L.documentElement){L=j.createDocument(mt,"template",null);try{L.documentElement.innerHTML=yt?T:ie}catch{}}const ge=L.body||L.documentElement;return S&&H&&ge.insertBefore(n.createTextNode(H),ge.childNodes[0]||null),mt===Qe?G.call(L,we?"html":"body")[0]:we?L.documentElement:ge},tt=function(S){return k.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Xe=function(S){return S instanceof p&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof f)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},Ge=function(S){return typeof l=="function"&&S instanceof l};function $e(P,S,L){wo(P,H=>{H.call(t,S,L,Ct)})}const Be=function(S){let L=null;if($e(B.beforeSanitizeElements,S,null),Xe(S))return Ce(S),!0;const H=De(S.nodeName);if($e(B.uponSanitizeElement,S,{tagName:H,allowedTags:R}),de&&S.hasChildNodes()&&!Ge(S.firstElementChild)&&ht(/<[/\w!]/g,S.innerHTML)&&ht(/<[/\w!]/g,S.textContent)||S.nodeType===Mr.progressingInstruction||de&&S.nodeType===Mr.comment&&ht(/<[/\w]/g,S.data))return Ce(S),!0;if(!R[H]||q[H]){if(!q[H]&&M(H)&&(z.tagNameCheck instanceof RegExp&&ht(z.tagNameCheck,H)||z.tagNameCheck instanceof Function&&z.tagNameCheck(H)))return!1;if(rt&&!st[H]){const ie=y(S)||S.parentNode,ge=w(S)||S.childNodes;if(ge&&ie){const fe=ge.length;for(let Ae=fe-1;Ae>=0;--Ae){const ce=g(ge[Ae],!0);ce.__removalCount=(S.__removalCount||0)+1,ie.insertBefore(ce,b(S))}}}return Ce(S),!0}return S instanceof c&&!xe(S)||(H==="noscript"||H==="noembed"||H==="noframes")&&ht(/<\/no(script|embed|frames)/i,S.innerHTML)?(Ce(S),!0):(ne&&S.nodeType===Mr.text&&(L=S.textContent,wo([Z,J,D],ie=>{L=_r(L,ie," ")}),S.textContent!==L&&(Nr(t.removed,{element:S.cloneNode()}),S.textContent=L)),$e(B.afterSanitizeElements,S,null),!1)},Et=function(S,L,H){if(Lt&&(L==="id"||L==="name")&&(H in n||H in Ue))return!1;if(!(ee&&!N[L]&&ht(X,L))){if(!(K&&ht(A,L))){if(!O[L]||N[L]){if(!(M(S)&&(z.tagNameCheck instanceof RegExp&&ht(z.tagNameCheck,S)||z.tagNameCheck instanceof Function&&z.tagNameCheck(S))&&(z.attributeNameCheck instanceof RegExp&&ht(z.attributeNameCheck,L)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(L))||L==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ht(z.tagNameCheck,H)||z.tagNameCheck instanceof Function&&z.tagNameCheck(H))))return!1}else if(!se[L]){if(!ht(F,_r(H,C,""))){if(!((L==="src"||L==="xlink:href"||L==="href")&&S!=="script"&&Gb(H,"data:")===0&&Qt[S])){if(!(te&&!ht(Y,_r(H,C,"")))){if(H)return!1}}}}}}return!0},M=function(S){return S!=="annotation-xml"&&gl(S,I)},$=function(S){$e(B.beforeSanitizeAttributes,S,null);const{attributes:L}=S;if(!L||Xe(S))return;const H={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:O,forceKeepAttr:void 0};let ie=L.length;for(;ie--;){const ge=L[ie],{name:fe,namespaceURI:Ae,value:ce}=ge,ke=De(fe),pe=ce;let ae=fe==="value"?pe:Vb(pe);if(H.attrName=ke,H.attrValue=ae,H.keepAttr=!0,H.forceKeepAttr=void 0,$e(B.uponSanitizeAttribute,S,H),ae=H.attrValue,qe&&(ke==="id"||ke==="name")&&(Ie(fe,S),ae=Dt+ae),de&&ht(/((--!?|])>)|<\/(style|title)/i,ae)){Ie(fe,S);continue}if(H.forceKeepAttr)continue;if(!H.keepAttr){Ie(fe,S);continue}if(!le&&ht(/\/>/i,ae)){Ie(fe,S);continue}ne&&wo([Z,J,D],He=>{ae=_r(ae,He," ")});const Oe=De(S.nodeName);if(!Et(Oe,ke,ae)){Ie(fe,S);continue}if(E&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!Ae)switch(h.getAttributeType(Oe,ke)){case"TrustedHTML":{ae=E.createHTML(ae);break}case"TrustedScriptURL":{ae=E.createScriptURL(ae);break}}if(ae!==pe)try{Ae?S.setAttributeNS(Ae,fe,ae):S.setAttribute(fe,ae),Xe(S)?Ce(S):hl(t.removed)}catch{Ie(fe,S)}}$e(B.afterSanitizeAttributes,S,null)},V=function P(S){let L=null;const H=tt(S);for($e(B.beforeSanitizeShadowDOM,S,null);L=H.nextNode();)$e(B.uponSanitizeShadowNode,L,null),Be(L),$(L),L.content instanceof s&&P(L.content);$e(B.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(P){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},L=null,H=null,ie=null,ge=null;if(yt=!P,yt&&(P="<!-->"),typeof P!="string"&&!Ge(P))if(typeof P.toString=="function"){if(P=P.toString(),typeof P!="string")throw Ir("dirty is not a string, aborting")}else throw Ir("toString is not a function");if(!t.isSupported)return P;if(je||It(S),t.removed=[],typeof P=="string"&&(At=!1),At){if(P.nodeName){const ce=De(P.nodeName);if(!R[ce]||q[ce])throw Ir("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof l)L=Te("<!---->"),H=L.ownerDocument.importNode(P,!0),H.nodeType===Mr.element&&H.nodeName==="BODY"||H.nodeName==="HTML"?L=H:L.appendChild(H);else{if(!Le&&!ne&&!we&&P.indexOf("<")===-1)return E&&We?E.createHTML(P):P;if(L=Te(P),!L)return Le?null:We?T:""}L&&Re&&Ce(L.firstChild);const fe=tt(At?P:L);for(;ie=fe.nextNode();)Be(ie),$(ie),ie.content instanceof s&&V(ie.content);if(At)return P;if(Le){if(Me)for(ge=_.call(L.ownerDocument);L.firstChild;)ge.appendChild(L.firstChild);else ge=L;return(O.shadowroot||O.shadowrootmode)&&(ge=U.call(r,ge,!0)),ge}let Ae=we?L.outerHTML:L.innerHTML;return we&&R["!doctype"]&&L.ownerDocument&&L.ownerDocument.doctype&&L.ownerDocument.doctype.name&&ht(Pf,L.ownerDocument.doctype.name)&&(Ae="<!DOCTYPE "+L.ownerDocument.doctype.name+`>
124
- `+Ae),ne&&wo([Z,J,D],ce=>{Ae=_r(Ae,ce," ")}),E&&We?E.createHTML(Ae):Ae},t.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};It(P),je=!0},t.clearConfig=function(){Ct=null,je=!1},t.isValidAttribute=function(P,S,L){Ct||It({});const H=De(P),ie=De(S);return Et(H,ie,L)},t.addHook=function(P,S){typeof S=="function"&&Nr(B[P],S)},t.removeHook=function(P,S){if(S!==void 0){const L=Hb(B[P],S);return L===-1?void 0:Wb(B[P],L,1)[0]}return hl(B[P])},t.removeHooks=function(P){B[P]=[]},t.removeAllHooks=function(){B=Sl()},t}var Df=Lf();const ay=({content:e,setRenderError:t})=>{const[n,r]=u.useState(""),o=u.useMemo(()=>Df.sanitize(e,{USE_PROFILES:{html:!1},ALLOWED_TAGS:["br","em","strong","b","i"],ALLOWED_ATTR:[]}),[e]);return u.useEffect(()=>{r(`<!DOCTYPE html>
125
- <html>
126
- <head>
127
- <meta charset="utf-8">
128
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
129
- <title>Mermaid Preview</title>
130
- <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"><\/script>
131
- <script src="https://cdn.jsdelivr.net/npm/panzoom@9.4.0/dist/panzoom.min.js"><\/script>
132
- <script>
133
- document.addEventListener('DOMContentLoaded', function() {
134
- try {
135
- mermaid.initialize({
136
- startOnLoad: true,
137
- theme: 'default',
138
- fontFamily: 'arial, sans-serif',
139
- logLevel: 'error',
140
- securityLevel: 'strict'
141
- });
142
-
143
- // Initialize panzoom after Mermaid rendering
144
- mermaid.run().then(() => {
145
- const diagramContainer = document.getElementById('diagram-container');
146
- if (diagramContainer) {
147
- const pz = panzoom(diagramContainer, {
148
- maxZoom: 10,
149
- minZoom: 0.1,
150
- smoothScroll: true,
151
- bounds: true,
152
- boundsPadding: 0.1
153
- });
154
- // Add zoom controls (old version had only reset)
155
- const resetButton = document.getElementById('reset');
156
- if (resetButton) {
157
- resetButton.addEventListener('click', () => {
158
- pz.moveTo(0, 0);
159
- pz.zoomAbs(0, 0, 1);
160
- });
161
- }
162
- }
163
- }).catch(err => {
164
- console.error("Mermaid rendering failed inside iframe:", err);
165
- const mermaidDiv = document.querySelector('.mermaid');
166
- if (mermaidDiv) mermaidDiv.innerText = "Error rendering diagram: " + err.message;
167
- });
168
-
169
- window.addEventListener('message', function(event) {
170
- if (event.data && event.data.action === 'getMermaidSvg') {
171
- const svgElement = document.querySelector('.mermaid svg');
172
- if (svgElement) {
173
- if (!svgElement.getAttribute('xmlns')) { // Ensure xmlns for standalone SVG
174
- svgElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
175
- }
176
- const svgData = new XMLSerializer().serializeToString(svgElement);
177
- window.parent.postMessage({
178
- action: 'downloadSvg',
179
- svgData: svgData,
180
- filename: event.data.filename || 'mermaid-diagram.svg'
181
- }, '*');
182
- } else {
183
- console.error('SVG element not found for download inside iframe.');
184
- }
185
- }
186
- });
187
- } catch (e) {
188
- console.error("Error initializing Mermaid or Panzoom inside iframe:", e);
189
- const mermaidDiv = document.querySelector('.mermaid');
190
- if (mermaidDiv) mermaidDiv.innerText = "Failed to initialize diagram viewer: " + e.message;
191
- }
192
- });
193
- <\/script>
194
- <style>
195
- /* Styles from old code */
196
- html, body {
197
- height: 100%;
198
- margin: 0;
199
- padding: 0;
200
- overflow: hidden;
201
- font-family: Arial, sans-serif; /* Old font */
202
- }
203
- .container {
204
- display: flex;
205
- flex-direction: column;
206
- height: 100vh;
207
- overflow: hidden;
208
- }
209
- .diagram-wrapper {
210
- flex: 1;
211
- overflow: hidden;
212
- position: relative;
213
- display: flex;
214
- justify-content: center;
215
- align-items: center;
216
- background-color: #f9f9f9;
217
- }
218
- #diagram-container {
219
- transform-origin: 0 0;
220
- cursor: grab;
221
- box-shadow: 0 0 10px rgba(0,0,0,0.1);
222
- background-color: white;
223
- padding: 20px;
224
- border-radius: 5px;
225
- /* Ensure diagram container can hold the content */
226
- width: auto; /* Adjust as needed, or let content define it */
227
- height: auto;
228
- max-width: 100%;
229
- max-height: 100%;
230
- }
231
- #diagram-container:active {
232
- cursor: grabbing;
233
- }
234
- .mermaid {
235
- display: flex; /* Helps in centering if SVG is smaller */
236
- justify-content: center;
237
- align-items: center;
238
- /* width: 100%; Ensures mermaid div takes space, SVG might scale within it */
239
- /* height: 100%; */
240
- }
241
- .mermaid svg {
242
- max-width: 100%; /* Ensure SVG scales down if too large */
243
- max-height: 100%;
244
- }
245
- .controls{
246
- position: fixed;
247
- bottom: 20px;
248
- right: 20px;
249
- z-index: 1000;
250
- display: flex;
251
- gap: 5px;
252
- }
253
- .control-btn {
254
- width: 40px;
255
- height: 40px;
256
- border-radius: 50%;
257
- border: none;
258
- background-color: white;
259
- box-shadow: 0 2px 5px rgba(0,0,0,0.2);
260
- cursor: pointer;
261
- font-size: 18px;
262
- display: flex;
263
- align-items: center;
264
- justify-content: center;
265
- }
266
- .control-btn:hover {
267
- background-color: #f0f0f0;
268
- }
269
- .instructions {
270
- position: fixed;
271
- top: 10px;
272
- left: 10px;
273
- background-color: rgba(255,255,255,0.8);
274
- padding: 5px 10px;
275
- border-radius: 4px;
276
- font-size: 12px;
277
- color: #666;
278
- }
279
- </style>
280
- </head>
281
- <body>
282
- <div class="container">
283
- <div class="diagram-wrapper">
284
- <div id="diagram-container">
285
- <div class="mermaid">
286
- ${o}
287
- </div>
288
- </div>
289
- </div>
290
- <div class="instructions">
291
- Drag to pan and scroll to zoom
292
- </div>
293
- <div class="controls">
294
- <button id="reset" class="control-btn" title="Reset View">↺</button>
295
- </div>
296
- </div>
297
- </body>
298
- </html>`)},[o]),a.jsx("div",{className:"bg-background h-full p-4",children:a.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 Of(e){return typeof e>"u"||e===null}function ly(e){return typeof e=="object"&&e!==null}function cy(e){return Array.isArray(e)?e:Of(e)?[]:[e]}function uy(e,t){var n,r,o,s;if(t)for(s=Object.keys(t),n=0,r=s.length;n<r;n+=1)o=s[n],e[o]=t[o];return e}function dy(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function fy(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var py=Of,my=ly,hy=cy,gy=dy,xy=fy,vy=uy,Je={isNothing:py,isObject:my,toArray:hy,repeat:gy,isNegativeZero:xy,extend:vy};function Ff(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+=`
299
-
300
- `+e.mark.snippet),r+" "+n):r}function Wr(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Ff(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Wr.prototype=Object.create(Error.prototype);Wr.prototype.constructor=Wr;Wr.prototype.toString=function(t){return this.name+": "+Ff(this,t)};var xt=Wr;function Bs(e,t,n,r,o){var s="",i="",l=Math.floor(o/2)-1;return r-t>l&&(s=" ... ",t=r-l+s.length),n-r>l&&(i=" ...",n=r+l-i.length),{str:s+e.slice(t,n).replace(/\t/g,"→")+i,pos:r-t+s.length}}function Us(e,t){return Je.repeat(" ",t-e.length)+e}function wy(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=[],s,i=-1;s=n.exec(e.buffer);)o.push(s.index),r.push(s.index+s[0].length),e.position<=s.index&&i<0&&(i=r.length-2);i<0&&(i=r.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,o.length).toString().length,p=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(i-c<0);c++)d=Bs(e.buffer,r[i-c],o[i-c],e.position-(r[i]-r[i-c]),p),l=Je.repeat(" ",t.indent)+Us((e.line-c+1).toString(),f)+" | "+d.str+`
301
- `+l;for(d=Bs(e.buffer,r[i],o[i],e.position,p),l+=Je.repeat(" ",t.indent)+Us((e.line+1).toString(),f)+" | "+d.str+`
302
- `,l+=Je.repeat("-",t.indent+f+3+d.pos)+`^
303
- `,c=1;c<=t.linesAfter&&!(i+c>=o.length);c++)d=Bs(e.buffer,r[i+c],o[i+c],e.position-(r[i]-r[i+c]),p),l+=Je.repeat(" ",t.indent)+Us((e.line+c+1).toString(),f)+" | "+d.str+`
304
- `;return l.replace(/\n$/,"")}var by=wy,yy=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Sy=["scalar","sequence","mapping"];function Cy(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function Ey(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(yy.indexOf(n)===-1)throw new xt('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=Cy(t.styleAliases||null),Sy.indexOf(this.kind)===-1)throw new xt('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var ut=Ey;function Cl(e,t){var n=[];return e[t].forEach(function(r){var o=n.length;n.forEach(function(s,i){s.tag===r.tag&&s.kind===r.kind&&s.multi===r.multi&&(o=i)}),n[o]=r}),n}function Ty(){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 di(e){return this.extend(e)}di.prototype.extend=function(t){var n=[],r=[];if(t instanceof ut)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 xt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(s){if(!(s instanceof ut))throw new xt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(s.loadKind&&s.loadKind!=="scalar")throw new xt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(s.multi)throw new xt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(s){if(!(s instanceof ut))throw new xt("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(di.prototype);return o.implicit=(this.implicit||[]).concat(n),o.explicit=(this.explicit||[]).concat(r),o.compiledImplicit=Cl(o,"implicit"),o.compiledExplicit=Cl(o,"explicit"),o.compiledTypeMap=Ty(o.compiledImplicit,o.compiledExplicit),o};var zf=di,$f=new ut("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Bf=new ut("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Uf=new ut("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Hf=new zf({explicit:[$f,Bf,Uf]});function Ay(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function ky(){return null}function Ny(e){return e===null}var Wf=new ut("tag:yaml.org,2002:null",{kind:"scalar",resolve:Ay,construct:ky,predicate:Ny,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function _y(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 Iy(e){return e==="true"||e==="True"||e==="TRUE"}function jy(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Gf=new ut("tag:yaml.org,2002:bool",{kind:"scalar",resolve:_y,construct:Iy,predicate:jy,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 My(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Ry(e){return 48<=e&&e<=55}function Py(e){return 48<=e&&e<=57}function Ly(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(!My(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}if(o==="o"){for(n++;n<t;n++)if(o=e[n],o!=="_"){if(!Ry(e.charCodeAt(n)))return!1;r=!0}return r&&o!=="_"}}if(o==="_")return!1;for(;n<t;n++)if(o=e[n],o!=="_"){if(!Py(e.charCodeAt(n)))return!1;r=!0}return!(!r||o==="_")}function Dy(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 Oy(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Je.isNegativeZero(e)}var Vf=new ut("tag:yaml.org,2002:int",{kind:"scalar",resolve:Ly,construct:Dy,predicate:Oy,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"]}}),Fy=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function zy(e){return!(e===null||!Fy.test(e)||e[e.length-1]==="_")}function $y(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 By=/^[-+]?[0-9]+e/;function Uy(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(Je.isNegativeZero(e))return"-0.0";return n=e.toString(10),By.test(n)?n.replace("e",".e"):n}function Hy(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Je.isNegativeZero(e))}var Yf=new ut("tag:yaml.org,2002:float",{kind:"scalar",resolve:zy,construct:$y,predicate:Hy,represent:Uy,defaultStyle:"lowercase"}),Kf=Hf.extend({implicit:[Wf,Gf,Vf,Yf]}),qf=Kf,Xf=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Zf=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 Wy(e){return e===null?!1:Xf.exec(e)!==null||Zf.exec(e)!==null}function Gy(e){var t,n,r,o,s,i,l,c=0,d=null,f,p,m;if(t=Xf.exec(e),t===null&&(t=Zf.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(s=+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]&&(f=+t[10],p=+(t[11]||0),d=(f*60+p)*6e4,t[9]==="-"&&(d=-d)),m=new Date(Date.UTC(n,r,o,s,i,l,c)),d&&m.setTime(m.getTime()-d),m}function Vy(e){return e.toISOString()}var Jf=new ut("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Wy,construct:Gy,instanceOf:Date,represent:Vy});function Yy(e){return e==="<<"||e===null}var Qf=new ut("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Yy}),aa=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
305
- \r`;function Ky(e){if(e===null)return!1;var t,n,r=0,o=e.length,s=aa;for(n=0;n<o;n++)if(t=s.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function qy(e){var t,n,r=e.replace(/[\r\n=]/g,""),o=r.length,s=aa,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|s.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 Xy(e){var t="",n=0,r,o,s=e.length,i=aa;for(r=0;r<s;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=s%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 Zy(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var ep=new ut("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Ky,construct:qy,predicate:Zy,represent:Xy}),Jy=Object.prototype.hasOwnProperty,Qy=Object.prototype.toString;function eS(e){if(e===null)return!0;var t=[],n,r,o,s,i,l=e;for(n=0,r=l.length;n<r;n+=1){if(o=l[n],i=!1,Qy.call(o)!=="[object Object]")return!1;for(s in o)if(Jy.call(o,s))if(!i)i=!0;else return!1;if(!i)return!1;if(t.indexOf(s)===-1)t.push(s);else return!1}return!0}function tS(e){return e!==null?e:[]}var tp=new ut("tag:yaml.org,2002:omap",{kind:"sequence",resolve:eS,construct:tS}),nS=Object.prototype.toString;function rS(e){if(e===null)return!0;var t,n,r,o,s,i=e;for(s=new Array(i.length),t=0,n=i.length;t<n;t+=1){if(r=i[t],nS.call(r)!=="[object Object]"||(o=Object.keys(r),o.length!==1))return!1;s[t]=[o[0],r[o[0]]]}return!0}function oS(e){if(e===null)return[];var t,n,r,o,s,i=e;for(s=new Array(i.length),t=0,n=i.length;t<n;t+=1)r=i[t],o=Object.keys(r),s[t]=[o[0],r[o[0]]];return s}var np=new ut("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:rS,construct:oS}),sS=Object.prototype.hasOwnProperty;function iS(e){if(e===null)return!0;var t,n=e;for(t in n)if(sS.call(n,t)&&n[t]!==null)return!1;return!0}function aS(e){return e!==null?e:{}}var rp=new ut("tag:yaml.org,2002:set",{kind:"mapping",resolve:iS,construct:aS}),la=qf.extend({implicit:[Jf,Qf],explicit:[ep,tp,np,rp]}),Mn=Object.prototype.hasOwnProperty,$o=1,op=2,sp=3,Bo=4,Hs=1,lS=2,El=3,cS=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,uS=/[\x85\u2028\u2029]/,dS=/[,\[\]\{\}]/,ip=/^(?:!|!!|![a-z\-]+!)$/i,ap=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Tl(e){return Object.prototype.toString.call(e)}function cn(e){return e===10||e===13}function Bn(e){return e===9||e===32}function Tt(e){return e===9||e===32||e===10||e===13}function ar(e){return e===44||e===91||e===93||e===123||e===125}function fS(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function pS(e){return e===120?2:e===117?4:e===85?8:0}function mS(e){return 48<=e&&e<=57?e-48:-1}function Al(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
306
- `: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 hS(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var lp=new Array(256),cp=new Array(256);for(var rr=0;rr<256;rr++)lp[rr]=Al(rr)?1:0,cp[rr]=Al(rr);function gS(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||la,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 up(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=by(n),new xt(t,n)}function ue(e,t){throw up(e,t)}function Uo(e,t){e.onWarning&&e.onWarning.call(null,up(e,t))}var kl={YAML:function(t,n,r){var o,s,i;t.version!==null&&ue(t,"duplication of %YAML directive"),r.length!==1&&ue(t,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),o===null&&ue(t,"ill-formed argument of the YAML directive"),s=parseInt(o[1],10),i=parseInt(o[2],10),s!==1&&ue(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=i<2,i!==1&&i!==2&&Uo(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var o,s;r.length!==2&&ue(t,"TAG directive accepts exactly two arguments"),o=r[0],s=r[1],ip.test(o)||ue(t,"ill-formed tag handle (first argument) of the TAG directive"),Mn.call(t.tagMap,o)&&ue(t,'there is a previously declared suffix for "'+o+'" tag handle'),ap.test(s)||ue(t,"ill-formed tag prefix (second argument) of the TAG directive");try{s=decodeURIComponent(s)}catch{ue(t,"tag prefix is malformed: "+s)}t.tagMap[o]=s}};function Nn(e,t,n,r){var o,s,i,l;if(t<n){if(l=e.input.slice(t,n),r)for(o=0,s=l.length;o<s;o+=1)i=l.charCodeAt(o),i===9||32<=i&&i<=1114111||ue(e,"expected valid JSON character");else cS.test(l)&&ue(e,"the stream contains non-printable characters");e.result+=l}}function Nl(e,t,n,r){var o,s,i,l;for(Je.isObject(n)||ue(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(n),i=0,l=o.length;i<l;i+=1)s=o[i],Mn.call(t,s)||(t[s]=n[s],r[s]=!0)}function lr(e,t,n,r,o,s,i,l,c){var d,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),d=0,f=o.length;d<f;d+=1)Array.isArray(o[d])&&ue(e,"nested arrays are not supported inside keys"),typeof o=="object"&&Tl(o[d])==="[object Object]"&&(o[d]="[object Object]");if(typeof o=="object"&&Tl(o)==="[object Object]"&&(o="[object Object]"),o=String(o),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(s))for(d=0,f=s.length;d<f;d+=1)Nl(e,t,s[d],n);else Nl(e,t,s,n);else!e.json&&!Mn.call(n,o)&&Mn.call(t,o)&&(e.line=i||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,ue(e,"duplicated mapping key")),o==="__proto__"?Object.defineProperty(t,o,{configurable:!0,enumerable:!0,writable:!0,value:s}):t[o]=s,delete n[o];return t}function ca(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++):ue(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Ke(e,t,n){for(var r=0,o=e.input.charCodeAt(e.position);o!==0;){for(;Bn(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(cn(o))for(ca(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&&Uo(e,"deficient indentation"),r}function hs(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||Tt(n)))}function ua(e,t){t===1?e.result+=" ":t>1&&(e.result+=Je.repeat(`
307
- `,t-1))}function xS(e,t,n){var r,o,s,i,l,c,d,f,p=e.kind,m=e.result,h;if(h=e.input.charCodeAt(e.position),Tt(h)||ar(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),Tt(o)||n&&ar(o)))return!1;for(e.kind="scalar",e.result="",s=i=e.position,l=!1;h!==0;){if(h===58){if(o=e.input.charCodeAt(e.position+1),Tt(o)||n&&ar(o))break}else if(h===35){if(r=e.input.charCodeAt(e.position-1),Tt(r))break}else{if(e.position===e.lineStart&&hs(e)||n&&ar(h))break;if(cn(h))if(c=e.line,d=e.lineStart,f=e.lineIndent,Ke(e,!1,-1),e.lineIndent>=t){l=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=c,e.lineStart=d,e.lineIndent=f;break}}l&&(Nn(e,s,i,!1),ua(e,e.line-c),s=i=e.position,l=!1),Bn(h)||(i=e.position+1),h=e.input.charCodeAt(++e.position)}return Nn(e,s,i,!1),e.result?!0:(e.kind=p,e.result=m,!1)}function vS(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(Nn(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 cn(n)?(Nn(e,r,o,!0),ua(e,Ke(e,!1,t)),r=o=e.position):e.position===e.lineStart&&hs(e)?ue(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);ue(e,"unexpected end of the stream within a single quoted scalar")}function wS(e,t){var n,r,o,s,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 Nn(e,n,e.position,!0),e.position++,!0;if(l===92){if(Nn(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),cn(l))Ke(e,!1,t);else if(l<256&&lp[l])e.result+=cp[l],e.position++;else if((i=pS(l))>0){for(o=i,s=0;o>0;o--)l=e.input.charCodeAt(++e.position),(i=fS(l))>=0?s=(s<<4)+i:ue(e,"expected hexadecimal character");e.result+=hS(s),e.position++}else ue(e,"unknown escape sequence");n=r=e.position}else cn(l)?(Nn(e,n,r,!0),ua(e,Ke(e,!1,t)),n=r=e.position):e.position===e.lineStart&&hs(e)?ue(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}ue(e,"unexpected end of the stream within a double quoted scalar")}function bS(e,t){var n=!0,r,o,s,i=e.tag,l,c=e.anchor,d,f,p,m,h,x=Object.create(null),g,v,b,w;if(w=e.input.charCodeAt(e.position),w===91)f=93,h=!1,l=[];else if(w===123)f=125,h=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),w=e.input.charCodeAt(++e.position);w!==0;){if(Ke(e,!0,t),w=e.input.charCodeAt(e.position),w===f)return e.position++,e.tag=i,e.anchor=c,e.kind=h?"mapping":"sequence",e.result=l,!0;n?w===44&&ue(e,"expected the node content, but found ','"):ue(e,"missed comma between flow collection entries"),v=g=b=null,p=m=!1,w===63&&(d=e.input.charCodeAt(e.position+1),Tt(d)&&(p=m=!0,e.position++,Ke(e,!0,t))),r=e.line,o=e.lineStart,s=e.position,xr(e,t,$o,!1,!0),v=e.tag,g=e.result,Ke(e,!0,t),w=e.input.charCodeAt(e.position),(m||e.line===r)&&w===58&&(p=!0,w=e.input.charCodeAt(++e.position),Ke(e,!0,t),xr(e,t,$o,!1,!0),b=e.result),h?lr(e,l,x,v,g,b,r,o,s):p?l.push(lr(e,null,x,v,g,b,r,o,s)):l.push(g),Ke(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(n=!0,w=e.input.charCodeAt(++e.position)):n=!1}ue(e,"unexpected end of the stream within a flow collection")}function yS(e,t){var n,r,o=Hs,s=!1,i=!1,l=t,c=0,d=!1,f,p;if(p=e.input.charCodeAt(e.position),p===124)r=!1;else if(p===62)r=!0;else return!1;for(e.kind="scalar",e.result="";p!==0;)if(p=e.input.charCodeAt(++e.position),p===43||p===45)Hs===o?o=p===43?El:lS:ue(e,"repeat of a chomping mode identifier");else if((f=mS(p))>=0)f===0?ue(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):i?ue(e,"repeat of an indentation width identifier"):(l=t+f-1,i=!0);else break;if(Bn(p)){do p=e.input.charCodeAt(++e.position);while(Bn(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!cn(p)&&p!==0)}for(;p!==0;){for(ca(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!i||e.lineIndent<l)&&p===32;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!i&&e.lineIndent>l&&(l=e.lineIndent),cn(p)){c++;continue}if(e.lineIndent<l){o===El?e.result+=Je.repeat(`
308
- `,s?1+c:c):o===Hs&&s&&(e.result+=`
309
- `);break}for(r?Bn(p)?(d=!0,e.result+=Je.repeat(`
310
- `,s?1+c:c)):d?(d=!1,e.result+=Je.repeat(`
311
- `,c+1)):c===0?s&&(e.result+=" "):e.result+=Je.repeat(`
312
- `,c):e.result+=Je.repeat(`
313
- `,s?1+c:c),s=!0,i=!0,c=0,n=e.position;!cn(p)&&p!==0;)p=e.input.charCodeAt(++e.position);Nn(e,n,e.position,!1)}return!0}function _l(e,t){var n,r=e.tag,o=e.anchor,s=[],i,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ue(e,"tab characters must not be used in indentation")),!(c!==45||(i=e.input.charCodeAt(e.position+1),!Tt(i))));){if(l=!0,e.position++,Ke(e,!0,-1)&&e.lineIndent<=t){s.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,xr(e,t,sp,!1,!0),s.push(e.result),Ke(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)ue(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=s,!0):!1}function SS(e,t,n){var r,o,s,i,l,c,d=e.tag,f=e.anchor,p={},m=Object.create(null),h=null,x=null,g=null,v=!1,b=!1,w;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=p),w=e.input.charCodeAt(e.position);w!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ue(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),s=e.line,(w===63||w===58)&&Tt(r))w===63?(v&&(lr(e,p,m,h,x,null,i,l,c),h=x=g=null),b=!0,v=!0,o=!0):v?(v=!1,o=!0):ue(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,w=r;else{if(i=e.line,l=e.lineStart,c=e.position,!xr(e,n,op,!1,!0))break;if(e.line===s){for(w=e.input.charCodeAt(e.position);Bn(w);)w=e.input.charCodeAt(++e.position);if(w===58)w=e.input.charCodeAt(++e.position),Tt(w)||ue(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(lr(e,p,m,h,x,null,i,l,c),h=x=g=null),b=!0,v=!1,o=!1,h=e.tag,x=e.result;else if(b)ue(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(b)ue(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===s||e.lineIndent>t)&&(v&&(i=e.line,l=e.lineStart,c=e.position),xr(e,t,Bo,!0,o)&&(v?x=e.result:g=e.result),v||(lr(e,p,m,h,x,g,i,l,c),h=x=g=null),Ke(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&w!==0)ue(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&lr(e,p,m,h,x,null,i,l,c),b&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=p),b}function CS(e){var t,n=!1,r=!1,o,s,i;if(i=e.input.charCodeAt(e.position),i!==33)return!1;if(e.tag!==null&&ue(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?(s=e.input.slice(t,e.position),i=e.input.charCodeAt(++e.position)):ue(e,"unexpected end of the stream within a verbatim tag")}else{for(;i!==0&&!Tt(i);)i===33&&(r?ue(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(t-1,e.position+1),ip.test(o)||ue(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),i=e.input.charCodeAt(++e.position);s=e.input.slice(t,e.position),dS.test(s)&&ue(e,"tag suffix cannot contain flow indicator characters")}s&&!ap.test(s)&&ue(e,"tag name cannot contain such characters: "+s);try{s=decodeURIComponent(s)}catch{ue(e,"tag name is malformed: "+s)}return n?e.tag=s:Mn.call(e.tagMap,o)?e.tag=e.tagMap[o]+s:o==="!"?e.tag="!"+s:o==="!!"?e.tag="tag:yaml.org,2002:"+s:ue(e,'undeclared tag handle "'+o+'"'),!0}function ES(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&ue(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!Tt(n)&&!ar(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ue(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function TS(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&&!Tt(r)&&!ar(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&ue(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),Mn.call(e.anchorMap,n)||ue(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Ke(e,!0,-1),!0}function xr(e,t,n,r,o){var s,i,l,c=1,d=!1,f=!1,p,m,h,x,g,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,s=i=l=Bo===n||sp===n,r&&Ke(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;CS(e)||ES(e);)Ke(e,!0,-1)?(d=!0,l=s,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||o),(c===1||Bo===n)&&($o===n||op===n?g=t:g=t+1,v=e.position-e.lineStart,c===1?l&&(_l(e,v)||SS(e,v,g))||bS(e,g)?f=!0:(i&&yS(e,g)||vS(e,g)||wS(e,g)?f=!0:TS(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&ue(e,"alias node should not have any properties")):xS(e,g,$o===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&_l(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&ue(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),p=0,m=e.implicitTypes.length;p<m;p+=1)if(x=e.implicitTypes[p],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(Mn.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"],p=0,m=h.length;p<m;p+=1)if(e.tag.slice(0,h[p].tag.length)===h[p].tag){x=h[p];break}x||ue(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&ue(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)):ue(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function AS(e){var t=e.position,n,r,o,s=!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&&(Ke(e,!0,-1),i=e.input.charCodeAt(e.position),!(e.lineIndent>0||i!==37));){for(s=!0,i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!Tt(i);)i=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),o=[],r.length<1&&ue(e,"directive name must not be less than one character in length");i!==0;){for(;Bn(i);)i=e.input.charCodeAt(++e.position);if(i===35){do i=e.input.charCodeAt(++e.position);while(i!==0&&!cn(i));break}if(cn(i))break;for(n=e.position;i!==0&&!Tt(i);)i=e.input.charCodeAt(++e.position);o.push(e.input.slice(n,e.position))}i!==0&&ca(e),Mn.call(kl,r)?kl[r](e,r,o):Uo(e,'unknown document directive "'+r+'"')}if(Ke(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,Ke(e,!0,-1)):s&&ue(e,"directives end mark is expected"),xr(e,e.lineIndent-1,Bo,!1,!0),Ke(e,!0,-1),e.checkLineBreaks&&uS.test(e.input.slice(t,e.position))&&Uo(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&hs(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Ke(e,!0,-1));return}if(e.position<e.length-1)ue(e,"end of the stream or a document separator is expected");else return}function dp(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
314
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new gS(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ue(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;)AS(n);return n.documents}function kS(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=dp(e,n);if(typeof t!="function")return r;for(var o=0,s=r.length;o<s;o+=1)t(r[o])}function NS(e,t){var n=dp(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new xt("expected a single document in the stream, but found more")}}var _S=kS,IS=NS,fp={loadAll:_S,load:IS},pp=Object.prototype.toString,mp=Object.prototype.hasOwnProperty,da=65279,jS=9,Gr=10,MS=13,RS=32,PS=33,LS=34,fi=35,DS=37,OS=38,FS=39,zS=42,hp=44,$S=45,Ho=58,BS=61,US=62,HS=63,WS=64,gp=91,xp=93,GS=96,vp=123,VS=124,wp=125,ft={};ft[0]="\\0";ft[7]="\\a";ft[8]="\\b";ft[9]="\\t";ft[10]="\\n";ft[11]="\\v";ft[12]="\\f";ft[13]="\\r";ft[27]="\\e";ft[34]='\\"';ft[92]="\\\\";ft[133]="\\N";ft[160]="\\_";ft[8232]="\\L";ft[8233]="\\P";var YS=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],KS=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function qS(e,t){var n,r,o,s,i,l,c;if(t===null)return{};for(n={},r=Object.keys(t),o=0,s=r.length;o<s;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&&mp.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[i]=l;return n}function XS(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 xt("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Je.repeat("0",r-t.length)+t}var ZS=1,Vr=2;function JS(e){this.schema=e.schema||la,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Je.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=qS(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==='"'?Vr:ZS,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 Il(e,t){for(var n=Je.repeat(" ",t),r=0,o=-1,s="",i,l=e.length;r<l;)o=e.indexOf(`
315
- `,r),o===-1?(i=e.slice(r),r=l):(i=e.slice(r,o+1),r=o+1),i.length&&i!==`
316
- `&&(s+=n),s+=i;return s}function pi(e,t){return`
317
- `+Je.repeat(" ",e.indent*t)}function QS(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 Wo(e){return e===RS||e===jS}function Yr(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==da||65536<=e&&e<=1114111}function jl(e){return Yr(e)&&e!==da&&e!==MS&&e!==Gr}function Ml(e,t,n){var r=jl(e),o=r&&!Wo(e);return(n?r:r&&e!==hp&&e!==gp&&e!==xp&&e!==vp&&e!==wp)&&e!==fi&&!(t===Ho&&!o)||jl(t)&&!Wo(t)&&e===fi||t===Ho&&o}function eC(e){return Yr(e)&&e!==da&&!Wo(e)&&e!==$S&&e!==HS&&e!==Ho&&e!==hp&&e!==gp&&e!==xp&&e!==vp&&e!==wp&&e!==fi&&e!==OS&&e!==zS&&e!==PS&&e!==VS&&e!==BS&&e!==US&&e!==FS&&e!==LS&&e!==DS&&e!==WS&&e!==GS}function tC(e){return!Wo(e)&&e!==Ho}function Fr(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 bp(e){var t=/^\n* /;return t.test(e)}var yp=1,mi=2,Sp=3,Cp=4,sr=5;function nC(e,t,n,r,o,s,i,l){var c,d=0,f=null,p=!1,m=!1,h=r!==-1,x=-1,g=eC(Fr(e,0))&&tC(Fr(e,e.length-1));if(t||i)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Fr(e,c),!Yr(d))return sr;g=g&&Ml(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Fr(e,c),d===Gr)p=!0,h&&(m=m||c-x-1>r&&e[x+1]!==" ",x=c);else if(!Yr(d))return sr;g=g&&Ml(d,f,l),f=d}m=m||h&&c-x-1>r&&e[x+1]!==" "}return!p&&!m?g&&!i&&!o(e)?yp:s===Vr?sr:mi:n>9&&bp(e)?sr:i?s===Vr?sr:mi:m?Cp:Sp}function rC(e,t,n,r,o){e.dump=(function(){if(t.length===0)return e.quotingType===Vr?'""':"''";if(!e.noCompatMode&&(YS.indexOf(t)!==-1||KS.test(t)))return e.quotingType===Vr?'"'+t+'"':"'"+t+"'";var s=e.indent*Math.max(1,n),i=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-s),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return QS(e,d)}switch(nC(t,l,e.indent,i,c,e.quotingType,e.forceQuotes&&!r,o)){case yp:return t;case mi:return"'"+t.replace(/'/g,"''")+"'";case Sp:return"|"+Rl(t,e.indent)+Pl(Il(t,s));case Cp:return">"+Rl(t,e.indent)+Pl(Il(oC(t,i),s));case sr:return'"'+sC(t)+'"';default:throw new xt("impossible error: invalid scalar style")}})()}function Rl(e,t){var n=bp(e)?String(t):"",r=e[e.length-1]===`
318
- `,o=r&&(e[e.length-2]===`
319
- `||e===`
320
- `),s=o?"+":r?"":"-";return n+s+`
321
- `}function Pl(e){return e[e.length-1]===`
322
- `?e.slice(0,-1):e}function oC(e,t){for(var n=/(\n+)([^\n]*)/g,r=(function(){var d=e.indexOf(`
323
- `);return d=d!==-1?d:e.length,n.lastIndex=d,Ll(e.slice(0,d),t)})(),o=e[0]===`
324
- `||e[0]===" ",s,i;i=n.exec(e);){var l=i[1],c=i[2];s=c[0]===" ",r+=l+(!o&&!s&&c!==""?`
325
- `:"")+Ll(c,t),o=s}return r}function Ll(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,o=0,s,i=0,l=0,c="";r=n.exec(e);)l=r.index,l-o>t&&(s=i>o?i:l,c+=`
326
- `+e.slice(o,s),o=s+1),i=l;return c+=`
327
- `,e.length-o>t&&i>o?c+=e.slice(o,i)+`
328
- `+e.slice(i+1):c+=e.slice(o),c.slice(1)}function sC(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=Fr(e,o),r=ft[n],!r&&Yr(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||XS(n);return t}function iC(e,t,n){var r="",o=e.tag,s,i,l;for(s=0,i=n.length;s<i;s+=1)l=n[s],e.replacer&&(l=e.replacer.call(n,String(s),l)),(Sn(e,t,l,!1,!1)||typeof l>"u"&&Sn(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function Dl(e,t,n,r){var o="",s=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)),(Sn(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&Sn(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=pi(e,t)),e.dump&&Gr===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=s,e.dump=o||"[]"}function aC(e,t,n){var r="",o=e.tag,s=Object.keys(n),i,l,c,d,f;for(i=0,l=s.length;i<l;i+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=s[i],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),Sn(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Sn(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function lC(e,t,n,r){var o="",s=e.tag,i=Object.keys(n),l,c,d,f,p,m;if(e.sortKeys===!0)i.sort();else if(typeof e.sortKeys=="function")i.sort(e.sortKeys);else if(e.sortKeys)throw new xt("sortKeys must be a boolean or a function");for(l=0,c=i.length;l<c;l+=1)m="",(!r||o!=="")&&(m+=pi(e,t)),d=i[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),Sn(e,t+1,d,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&Gr===e.dump.charCodeAt(0)?m+="?":m+="? "),m+=e.dump,p&&(m+=pi(e,t)),Sn(e,t+1,f,!0,p)&&(e.dump&&Gr===e.dump.charCodeAt(0)?m+=":":m+=": ",m+=e.dump,o+=m));e.tag=s,e.dump=o||"{}"}function Ol(e,t,n){var r,o,s,i,l,c;for(o=n?e.explicitTypes:e.implicitTypes,s=0,i=o.length;s<i;s+=1)if(l=o[s],(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,pp.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(mp.call(l.represent,c))r=l.represent[c](t,c);else throw new xt("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function Sn(e,t,n,r,o,s,i){e.tag=null,e.dump=n,Ol(e,n,!1)||Ol(e,n,!0);var l=pp.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",p,m;if(f&&(p=e.duplicates.indexOf(n),m=p!==-1),(e.tag!==null&&e.tag!=="?"||m||e.indent!==2&&t>0)&&(o=!1),m&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(f&&m&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(lC(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(aC(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!i&&t>0?Dl(e,t-1,e.dump,o):Dl(e,t,e.dump,o),m&&(e.dump="&ref_"+p+e.dump)):(iC(e,t,e.dump),m&&(e.dump="&ref_"+p+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&rC(e,e.dump,t,s,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new xt("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function cC(e,t){var n=[],r=[],o,s;for(hi(e,n,r),o=0,s=r.length;o<s;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(s)}function hi(e,t,n){var r,o,s;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,s=e.length;o<s;o+=1)hi(e[o],t,n);else for(r=Object.keys(e),o=0,s=r.length;o<s;o+=1)hi(e[r[o]],t,n)}function uC(e,t){t=t||{};var n=new JS(t);n.noRefs||cC(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),Sn(n,0,r,!0,!0)?n.dump+`
329
- `:""}var dC=uC,fC={dump:dC};function fa(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 pC=ut,mC=zf,hC=Hf,gC=Kf,xC=qf,vC=la,wC=fp.load,bC=fp.loadAll,yC=fC.dump,SC=xt,CC={binary:ep,float:Yf,map:Uf,null:Wf,pairs:np,set:rp,timestamp:Jf,bool:Gf,int:Vf,merge:Qf,omap:tp,seq:Bf,str:$f},EC=fa("safeLoad","load"),TC=fa("safeLoadAll","loadAll"),AC=fa("safeDump","dump"),kC={Type:pC,Schema:mC,FAILSAFE_SCHEMA:hC,JSON_SCHEMA:gC,CORE_SCHEMA:xC,DEFAULT_SCHEMA:vC,load:wC,loadAll:bC,dump:yC,YAMLException:SC,types:CC,safeLoad:EC,safeLoadAll:TC,safeDump:AC};const NC=({content:e,rendererType:t,setRenderError:n})=>{const[r,o]=u.useState(!1);u.useEffect(()=>{n(null)},[e,n]);const[s,i]=u.useMemo(()=>{try{if(t==="yaml"){const l=kC.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 d={[`${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,d]}},[e,t,n]);return a.jsxs("div",{className:"bg-background relative flex h-full flex-col overflow-hidden",children:[a.jsx("div",{className:"absolute top-4 right-4 z-10",children:a.jsx(me,{onClick:()=>o(!r),title:r?"Show Structured View":"Show Raw Text",children:r?a.jsxs(a.Fragment,{children:[a.jsx(Ql,{})," Structured"]}):a.jsxs(a.Fragment,{children:[a.jsx(ec,{})," Raw Text"]})})}),a.jsx("div",{className:"flex min-h-0 flex-col",children:a.jsx("div",{className:"flex-1 overflow-auto",children:r?a.jsx(Ep,{content:s,setRenderError:n}):a.jsx(Si,{data:i,maxDepth:4,className:"min-h-16 border-none p-2"})})})]})},Ep=({content:e,className:t=""})=>{const{ref:n,handleKeyDown:r}=If();return a.jsx("div",{className:`overflow-auto p-4 ${t}`,children:a.jsx("pre",{ref:n,className:"whitespace-pre-wrap select-text focus-visible:outline-none",style:{overflowWrap:"anywhere"},tabIndex:0,onKeyDown:r,children:e})})},Tp=({content:e,rendererType:t,mime_type:n,setRenderError:r})=>{switch(t){case"csv":return a.jsx(Db,{content:e,setRenderError:r});case"mermaid":return a.jsx(ay,{content:e,setRenderError:r});case"html":return a.jsx(Ob,{content:e,setRenderError:r});case"json":case"yaml":return a.jsx(NC,{content:e,rendererType:t,setRenderError:r});case"image":return a.jsx(Fb,{content:e,mime_type:n,setRenderError:r});case"markdown":return a.jsx(zb,{content:e,setRenderError:r});case"audio":return a.jsx(Pb,{content:e,mime_type:n,setRenderError:r});default:return a.jsx(Ep,{content:e,setRenderError:r})}},_C={"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 IC(e,t){const n=_C[e]||"bin";return`embedded_file_${t+1}.${n}`}function jC(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[s,i,l]=r,c=e[r.index-1],d=e[r.index+s.length];if(!(c==='"'&&d==='"'||c==="'"&&d==="'")&&l&&l.length>10){const f=io(void 0,i);f?t.push({type:f,content:l,mimeType:i,originalMatch:s}):t.push({type:"file",content:l,mimeType:i,originalMatch:s,filename:IC(i,o++)})}}return t}function MC(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 RC(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,s]=r;t.push({type:"mermaid",content:s.trim(),originalMatch:o})}return t}function PC(e){return!e||typeof e!="string"?[]:[...jC(e),...MC(e),...RC(e)]}const LC=["image","audio"],DC=({message:e,showWorkflowButton:t,showFeedbackActions:n,handleViewWorkflowClick:r})=>{var w;const{configCollectFeedback:o,submittedFeedback:s,handleFeedbackSubmit:i,addNotification:l}=Ye(),[c,d]=u.useState(!1),[f,p]=u.useState(null),m=e.taskId,h=m?(w=s[m])==null?void 0:w.type:void 0,x=y=>{p(y),d(!0)},g=()=>{d(!1),p(null)},v=async y=>{if(!(!f||!m))try{await i(m,f,y),l("Feedback submitted successfully","success")}catch(E){throw l("Failed to submit feedback. Please try again.","error"),E}},b=n&&o;return!t&&!b?null:a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mt-3 space-y-2",children:a.jsxs("div",{className:"flex items-center justify-start gap-2",children:[t&&a.jsx(iu,{onClick:r}),b&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(me,{variant:"ghost",size:"icon",className:`h-6 w-6 ${h?"!opacity-100":""}`,onClick:()=>x("up"),disabled:!!h,children:a.jsx(Jp,{className:`h-4 w-4 ${h==="up"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] !opacity-100":""}`})}),a.jsx(me,{variant:"ghost",size:"icon",className:`h-6 w-6 ${h?"!opacity-100":""}`,onClick:()=>x("down"),disabled:!!h,children:a.jsx(Qp,{className:`h-4 w-4 ${h==="down"?"fill-[var(--color-brand-wMain)] text-[var(--color-brand-wMain)] opacity-100":""}`})})]})]})}),f&&a.jsx(Rb,{isOpen:c,onClose:g,feedbackType:f,onSubmit:v})]})},OC=({message:e})=>{var d;const[t,n]=u.useState(null);if(e.isStatusBubble)return null;const r=(d=e.parts)==null?void 0:d.filter(f=>f.kind==="text"),o=(r==null?void 0:r.map(f=>f.text).join(""))||"";if(e.isUser)return a.jsx("span",{children:o});const s=o.trim();if(!s)return null;if(e.isError)return a.jsxs("div",{className:"flex items-center",children:[a.jsx(Ai,{className:"mr-2 self-start text-[var(--color-error-wMain)]"}),a.jsx(fr,{children:s})]});const i=PC(s);if(i.length===0)return a.jsx(fr,{children:s});let l=s;const c=[];return i.forEach((f,p)=>{if(l=l.replace(f.originalMatch,""),f.type==="file"){const m={name:f.filename||"downloaded_file",content:f.content,mime_type:f.mimeType};c.push(a.jsx("div",{className:"my-2",children:a.jsx(Nf,{fileAttachment:m,isEmbedded:!0})},`embedded-file-${p}`))}else if(!LC.includes(f.type)){const m=Ef(f.content);m&&c.push(a.jsx("div",{className:"my-2 h-auto w-md max-w-md",children:a.jsx(Tp,{content:m,rendererType:f.type,mime_type:f.mimeType,setRenderError:n})},`embedded-${p}`))}}),a.jsxs("div",{children:[t&&a.jsx(pa,{variant:"error",message:"Error rendering preview"}),a.jsx(fr,{children:l}),c]})},Ap=({message:e,children:t,className:n})=>a.jsx("div",{className:`mt-1 space-y-1 ${e.isUser?"ml-auto":"mr-auto"} ${n}`,children:t}),FC=e=>e.uploadedFiles&&e.uploadedFiles.length>0?a.jsx(Ap,{message:e,className:"flex flex-wrap justify-end gap-2",children:e.uploadedFiles.map((t,n)=>{var r;return a.jsx(_f,{filename:t.name,mimeType:t.type},`uploaded-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,zC=e=>e.files&&e.files.length>0?a.jsx(Ap,{message:e,children:e.files.map((t,n)=>{var r;return a.jsx(Nf,{fileAttachment:t},`file-${(r=e.metadata)==null?void 0:r.messageId}-${n}`)})}):null,$C=(e,t,n)=>{var f,p;const{openSidePanelTab:r,setTaskIdInSidePanel:o}=t;if(e.isStatusBubble)return null;const s=(f=e.parts)==null?void 0:f.some(m=>m.kind==="text"&&m.text.trim());if(!s&&!e.artifactNotification)return null;const i=e.isUser?"sent":"received",l=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,c=!e.isUser&&e.isComplete&&!!e.taskId&&!!n,d=()=>{e.taskId&&(o(e.taskId),r("workflow"))};return a.jsx(vf,{variant:i,children:a.jsxs(wf,{variant:i,children:[s&&a.jsx(OC,{message:e}),e.artifactNotification&&a.jsxs("div",{className:"my-1 flex items-center rounded-md bg-blue-100 p-2 dark:bg-blue-900/50",children:[a.jsx(pr,{className:"mr-2 text-blue-500 dark:text-blue-400"}),a.jsxs("span",{className:"text-sm",children:["Artifact created: ",a.jsx("strong",{children:e.artifactNotification.name}),e.artifactNotification.version&&` (v${e.artifactNotification.version})`]})]}),a.jsx(DC,{message:e,showWorkflowButton:!!l,showFeedbackActions:!!c,handleViewWorkflowClick:d})]})},(p=e.metadata)==null?void 0:p.messageId)},BC=({message:e,isLastWithTaskId:t})=>{const n=Ye();return e?a.jsxs(a.Fragment,{children:[$C(e,n,t),FC(e),zC(e)]}):null};var gi=new Map,yo=new WeakMap,Fl=0,UC=void 0;function HC(e){return e?(yo.has(e)||(Fl+=1,yo.set(e,Fl.toString())),yo.get(e)):"0"}function WC(e){return Object.keys(e).sort().filter(t=>e[t]!==void 0).map(t=>`${t}_${t==="root"?HC(e.root):e[t]}`).toString()}function GC(e){const t=WC(e);let n=gi.get(t);if(!n){const r=new Map;let o;const s=new IntersectionObserver(i=>{i.forEach(l=>{var c;const d=l.isIntersecting&&o.some(f=>l.intersectionRatio>=f);e.trackVisibility&&typeof l.isVisible>"u"&&(l.isVisible=d),(c=r.get(l.target))==null||c.forEach(f=>{f(d,l)})})},e);o=s.thresholds||(Array.isArray(e.threshold)?e.threshold:[e.threshold||0]),n={id:t,observer:s,elements:r},gi.set(t,n)}return n}function VC(e,t,n={},r=UC){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:s,elements:i}=GC(n),l=i.get(e)||[];return i.has(e)||i.set(e,l),l.push(t),s.observe(e),function(){l.splice(l.indexOf(t),1),l.length===0&&(i.delete(e),s.unobserve(e)),i.size===0&&(s.disconnect(),gi.delete(o))}}function YC({threshold:e,delay:t,trackVisibility:n,rootMargin:r,root:o,triggerOnce:s,skip:i,initialInView:l,fallbackInView:c,onChange:d}={}){var f;const[p,m]=u.useState(null),h=u.useRef(d),[x,g]=u.useState({inView:!!l,entry:void 0});h.current=d,u.useEffect(()=>{if(i||!p)return;let y;return y=VC(p,(E,T)=>{g({inView:E,entry:T}),h.current&&h.current(E,T),T.isIntersecting&&s&&y&&(y(),y=void 0)},{root:o,rootMargin:r,threshold:e,trackVisibility:n,delay:t},c),()=>{y&&y()}},[Array.isArray(e)?e.toString():e,p,o,r,s,i,n,c,t]);const v=(f=x.entry)==null?void 0:f.target,b=u.useRef(void 0);!p&&v&&!s&&!i&&b.current!==v&&(b.current=v,g({inView:!!l,entry:void 0}));const w=[m,x.inView,x.entry];return w.ref=w[0],w.inView=w[1],w.entry=w[2],w}const KC=()=>{const{handleSwitchSession:e,updateSessionName:t,openSessionDeleteModal:n}=Ye(),{configServerUrl:r}=Jt(),o=u.useRef(null),[s,i]=u.useState([]),[l,c]=u.useState(null),[d,f]=u.useState(""),[p,m]=u.useState(1),[h,x]=u.useState(!0),[g,v]=u.useState(!1),{ref:b,inView:w}=YC({threshold:0,triggerOnce:!1}),y=u.useCallback(async(U=1,B=!1)=>{v(!0);const J=`${r}/api/v1/sessions?pageNumber=${U}&pageSize=20`;try{const D=await Pe(J);if(D.ok){const X=await D.json();i(B?A=>[...A,...X.data]:X.data),x(X.meta.pagination.nextPage!==null),m(U)}else console.error(`Failed to fetch sessions: ${D.status} ${D.statusText}`)}catch(D){console.error("An error occurred while fetching sessions:",D)}finally{v(!1)}},[r]);u.useEffect(()=>{y(1,!1);const U=()=>{y(1,!1)},B=Z=>{const{sessionId:J}=Z.detail;i(D=>{const X=D.find(A=>A.id===J);if(X){const A=D.filter(Y=>Y.id!==J);return[X,...A]}return D})};return window.addEventListener("new-chat-session",U),window.addEventListener("session-updated",B),()=>{window.removeEventListener("new-chat-session",U),window.removeEventListener("session-updated",B)}},[y]),u.useEffect(()=>{w&&h&&!g&&y(p+1,!0)},[w,h,g,p,y]),u.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const E=async U=>{l!==U&&await e(U)},T=U=>{c(U.id),f(U.name||"")},j=async()=>{l&&(await t(l,d),c(null),y())},k=U=>{n(U)},_=U=>bh(U),G=U=>{if(U.name&&U.name.trim())return U.name;const B=U.id;return B.startsWith("web-session-")?`Chat ${B.replace("web-session-","").substring(0,8)}`:`Session ${B.substring(0,8)}`};return a.jsxs("div",{className:"flex h-full flex-col gap-4 py-6 pl-6",children:[a.jsx("div",{className:"text-lg",children:"Chat Session History"}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.length>0&&a.jsx("ul",{children:s.map(U=>a.jsx("li",{className:"group my-2 pr-4",children:a.jsxs("div",{className:"flex items-center justify-between rounded px-4 py-2 hover:bg-gray-200 dark:hover:bg-gray-700",children:[l===U.id?a.jsx("input",{ref:o,type:"text",value:d,onChange:B=>f(B.target.value),onKeyDown:B=>B.key==="Enter"&&j(),onBlur:j,className:"flex-grow bg-transparent focus:outline-none"}):a.jsx("button",{onClick:()=>E(U.id),className:"flex-grow text-left",children:a.jsxs("div",{className:"flex max-w-50 flex-col",children:[a.jsx("span",{className:"truncate font-semibold",title:G(U),children:G(U)}),a.jsx("span",{className:"text-muted-foreground text-xs",children:_(U.updatedTime)})]})}),a.jsx("div",{className:"flex items-center opacity-0 transition-opacity group-hover:opacity-100",children:l===U.id?a.jsxs(a.Fragment,{children:[a.jsx(me,{variant:"ghost",onClick:j,children:a.jsx(Ei,{size:16})}),a.jsx(me,{variant:"ghost",onClick:()=>c(null),children:a.jsx(Vo,{size:16})})]}):a.jsxs(a.Fragment,{children:[a.jsx(me,{variant:"ghost",onClick:()=>T(U),children:a.jsx(em,{size:16})}),a.jsx(me,{variant:"ghost",onClick:()=>k(U),children:a.jsx(tm,{size:16})})]})})]})},U.id))}),s.length===0&&!g&&a.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center text-sm",children:[a.jsx(tc,{className:"mx-auto mb-4 h-12 w-12"}),"No chat sessions available"]}),h&&a.jsx("div",{ref:b,className:"flex justify-center py-4",children:g&&a.jsx(Sf,{size:"small",variant:"muted"})})]})]})},qC=()=>{const{persistenceEnabled:e}=Jt(),{sessionName:t}=Ye();return e===!1?a.jsx("div",{className:"flex h-full flex-col",children:a.jsxs("div",{className:"flex-1 overflow-y-auto px-4",children:[a.jsxs("div",{className:"bg-accent/50 hover:bg-accent mb-3 cursor-pointer rounded-md p-3",children:[a.jsx("div",{className:"text-foreground truncate text-sm font-medium text-nowrap",children:t||"New Chat"}),a.jsx("div",{className:"text-muted-foreground mt-1 text-xs",children:"Current session"})]}),a.jsx("div",{className:"text-muted-foreground mt-4 text-center text-xs",children:"Multi-session support coming soon"})]})}):a.jsx(KC,{})},XC=({artifactInfo:e,isPreview:t=!1,isExpanded:n=!1,onDelete:r,onDownload:o,setIsExpanded:s})=>{const{previewedArtifactAvailableVersions:i,currentPreviewedVersionNumber:l,navigateArtifactVersion:c}=Ye(),d=u.useMemo(()=>i??[],[i]);return a.jsxs("div",{className:"flex flex-row justify-between gap-1",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"truncate text-sm",title:e.filename,children:e.filename}),a.jsx("div",{className:"truncate text-xs",title:ja(e.last_modified),children:ja(e.last_modified)})]}),t&&d.length>1&&a.jsx("div",{className:"align-right",children:a.jsxs(qd,{value:l==null?void 0:l.toString(),onValueChange:f=>{c(e.filename,parseInt(f))},children:[a.jsx(Zd,{className:"h-[16px] py-0 text-xs shadow-none",children:a.jsx(Xd,{placeholder:"Version"})}),a.jsx(Jd,{children:d.map(f=>a.jsxs(Qd,{value:f.toString(),children:["Version ",f]},f))})]})})]}),a.jsxs("div",{className:`whitespace-nowrap ${t?"opacity-100":"opacity-0 transition-opacity duration-150 group-focus-within:opacity-100 group-hover:opacity-100"}`,children:[s&&a.jsx(me,{variant:"ghost",size:"sm",onClick:f=>{f.stopPropagation(),f.preventDefault(),s(!n)},tooltip:n?"Collapse Details":"Expand Details",children:a.jsx(ki,{})}),o&&a.jsx(me,{variant:"ghost",size:"sm",onClick:async f=>{f.stopPropagation(),f.preventDefault(),await o(e)},tooltip:"Download",children:a.jsx(Yo,{})}),r&&a.jsx(me,{variant:"ghost",size:"sm",onClick:f=>{f.preventDefault(),f.stopPropagation(),r(e)},tooltip:"Delete",children:a.jsx(nc,{})})]})]})},zl=({artifact:e,isPreview:t})=>{const{openDeleteModal:n,setPreviewArtifact:r}=Ye(),{onDownload:o}=ad(),[s,i]=u.useState(!1),l=()=>{t&&r(null),n(e)},c=d=>{if(!d||typeof d=="object"&&Object.keys(d).length===0)return a.jsx("span",{children:"Not available"});const f=(p,m=0)=>typeof p=="string"?a.jsx("span",{children:p}):Array.isArray(p)?a.jsxs(a.Fragment,{children:["[",p.length>0&&f(p[0],m+1),p.length>1&&a.jsx("span",{children:", ..."}),"]"]}):typeof p=="object"&&p!==null?a.jsx("div",{className:`ml-${m*2} border-l pl-2`,children:Object.entries(p).map(([h,x],g)=>a.jsxs("div",{className:"text-xs",children:[a.jsxs("span",{className:"font-semibold",children:[h,":"]})," ",f(x,m+1)]},g))}):String(p);return a.jsxs("div",{className:"mt-1 space-y-0.5",children:[typeof d=="object"&&d.type&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",d.type," ",d.inferred&&a.jsx("span",{className:"text-xs",children:"(inferred)"})]}),typeof d=="object"&&d.columns&&a.jsxs("p",{children:[a.jsx("strong",{children:"Columns:"})," ",d.columns.join(", ")]}),typeof d=="object"&&d.structure&&a.jsxs("div",{children:[a.jsx("strong",{children:"Structure:"}),f(d.structure)]}),typeof d=="object"&&d.error&&a.jsxs("p",{className:"text-[var(--color-error-wMain)]",children:[a.jsx("strong",{children:"Schema Error:"})," ",d.error]}),typeof d=="string"&&a.jsx("p",{children:d})]})};return a.jsx("div",{className:`group relative w-full border-b px-4 py-3 transition-all duration-150 ${t?"":"cursor-pointer hover:bg-[var(--accent-background)]"}`,onClick:d=>{d.stopPropagation(),r(e)},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),r(e))},tabIndex:0,role:"button","aria-expanded":s,children:a.jsxs("div",{className:"flex items-start space-x-2",children:[a.jsx("div",{className:"flex-shrink-0 pt-0.5",children:kf(e,"h-4 w-4 flex-shrink-0")}),a.jsxs("div",{className:"min-w-0 flex-grow",children:[a.jsx(XC,{artifactInfo:e,isExpanded:s,onDelete:l,onDownload:o,setIsExpanded:i,isPreview:t}),s&&a.jsxs("div",{className:"text-xs",children:[a.jsx("div",{className:"mt-1 text-xs break-words whitespace-pre-wrap italic",children:e.description||"No description."}),a.jsxs("div",{className:"mt-2 space-y-1 pt-2",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Size: "}),Ec(e.size)]}),e.uri&&a.jsxs("div",{children:[a.jsx("strong",{children:"URI: "}),a.jsx("span",{className:"break-all",children:e.uri||"None"})]}),e.schema&&a.jsx("div",{children:c(e.schema)})]})]})]})]})})},ZC=()=>{const{isDeleteModalOpen:e,artifactToDelete:t,closeDeleteModal:n,confirmDelete:r}=Ye();return!e||!t?null:a.jsx(Qr,{open:e,onOpenChange:n,children:a.jsxs(eo,{children:[a.jsxs(to,{children:[a.jsxs(no,{className:"flex max-w-[400px] flex-row gap-1",children:["Delete",a.jsx("span",{className:"inline-block truncate",title:t.filename,children:a.jsx("code",{children:t.filename})}),"?"]}),a.jsx(ro,{className:"flex flex-col gap-2",children:a.jsx("div",{children:"This file will be permanently deleted. "})})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(me,{variant:"outline",onClick:n,children:"Cancel"}),a.jsx(me,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})})},JC={replace:e=>{e instanceof om.Element&&e.attribs&&e.name==="a"&&(e.attribs.target="_blank",e.attribs.rel="noopener noreferrer")}};function fr({children:e,className:t}){if(!e)return null;try{const n=nm.parse(e,{gfm:!0}),r=Df.sanitize(n,{USE_PROFILES:{html:!0}}),o=rm(r,JC);return a.jsx("div",{className:Ma(t),children:o})}catch{return a.jsx("div",{className:Ma(t),children:e})}}const QC=Rn("flex items-center gap-3 px-4 py-3 text-sm font-medium transition-all border-l-4 border-solid ",{variants:{variant:{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-w10)]"}},defaultVariants:{variant:"error"}}),e1={error:Ai,warning:sm,info:ki,success:rc};function pa({className:e,variant:t="error",message:n,dismissible:r=!1,onDismiss:o,...s}){const i=e1[t||"error"];return a.jsxs("div",{className:ve(QC({variant:t,className:e})),role:"alert","aria-live":"polite",...s,children:[a.jsx(i,{className:"size-5 shrink-0"}),a.jsx("span",{className:"flex-1",children:n}),r&&o&&a.jsx(me,{variant:"ghost",onClick:o,"aria-label":"Dismiss",children:a.jsx(Vo,{className:"size-3"})})]})}const t1=({artifact:e,message:t})=>{const{onDownload:n}=ad();return a.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-4",children:[a.jsx("div",{className:"mb-1 font-semibold",children:"Preview Coming Soon"}),a.jsx("div",{children:t}),a.jsx("div",{className:"mb-4",children:"Download file to view."}),a.jsxs(me,{onClick:()=>n(e),children:[a.jsx(Yo,{className:"h-4 w-4"}),"Download"]})]})},Ws=({children:e})=>a.jsx("div",{className:"text-muted-foreground flex h-[50vh] items-center justify-center",children:e||"No preview available"}),n1=({artifact:e})=>{const{openArtifactForPreview:t,previewFileContent:n}=Ye(),r=u.useMemo(()=>Mb(e),[e]),[o,s]=u.useState(!1),[i,l]=u.useState(null);if(u.useEffect(()=>{s(!1),l(null)},[e]),u.useEffect(()=>{async function f(){try{s(!0),l(null),await t(e.filename)}catch(p){console.error("Error fetching artifact content:",p),l(p instanceof Error?p.message:"Failed to load artifact content")}finally{s(!1)}}r!=null&&r.canPreview&&f()},[e,t,r]),i)return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(pa,{variant:"error",message:"Error rendering preview"}),a.jsx(Ws,{children:"No preview available"})]});if(o)return a.jsx(Ws,{children:a.jsx(Ti,{className:"text-muted-foreground h-6 w-6 animate-spin"})});if(!r.canPreview)return a.jsx(t1,{artifact:e,message:r.reason??""});const c=io(e.filename,e.mime_type),d=Ib(n);return!c||!d?a.jsx(Ws,{children:"No preview available"}):a.jsx(Tp,{content:d,rendererType:c,mime_type:n==null?void 0:n.mime_type,setRenderError:l})},sn={NameAsc:"name_asc",NameDesc:"name_desc",DateAsc:"date_asc",DateDesc:"date_desc"},r1=e=>{switch(e){case sn.NameAsc:return"Name (A-Z)";case sn.NameDesc:return"Name (Z-A)";case sn.DateAsc:return"Date (oldest first)";case sn.DateDesc:return"Date (newest first)"}},o1=({currentSortOption:e,onSortChange:t,children:n})=>{const r=Object.values(sn).map(o=>({id:o,label:r1(o),onClick:()=>t(o),icon:e===o?a.jsx(Ei,{}):void 0,iconPosition:"right"}));return a.jsxs(bd,{children:[a.jsx(yd,{asChild:!0,children:n}),a.jsx(Sd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(ra,{actions:r})})]})},s1=({children:e})=>{const{artifactsRefetch:t,setIsBatchDeleteModalOpen:n}=Ye(),r=[{id:"refreshAll",label:"Refresh",onClick:()=>{t()},icon:a.jsx(oc,{}),iconPosition:"left"},{id:"deleteAll",label:"Delete All",onClick:()=>{n(!0)},icon:a.jsx(nc,{}),iconPosition:"left",divider:!0}];return a.jsxs(bd,{children:[a.jsx(yd,{asChild:!0,children:e}),a.jsx(Sd,{align:"end",side:"bottom",className:"w-auto",sideOffset:0,children:a.jsx(ra,{actions:r})})]})},i1=()=>{const{artifacts:e,isBatchDeleteModalOpen:t,setIsBatchDeleteModalOpen:n,confirmBatchDeleteArtifacts:r,setSelectedArtifactFilenames:o}=Ye();return u.useEffect(()=>{t&&o(new Set(e.map(s=>s.filename)))},[e,t,o]),t?a.jsx(Qr,{open:t,onOpenChange:n,children:a.jsxs(eo,{children:[a.jsxs(to,{children:[a.jsx(no,{children:"Delete All?"}),a.jsxs(ro,{children:[e.length===1?"One file":`All ${e.length} files`," will be permanently deleted."]})]}),a.jsxs("div",{className:"flex justify-end space-x-2",children:[a.jsx(me,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),a.jsx(me,{variant:"default",onClick:()=>r(),children:"Delete"})]})]})}):null},a1={[sn.NameAsc]:(e,t)=>e.filename.localeCompare(t.filename),[sn.NameDesc]:(e,t)=>t.filename.localeCompare(e.filename),[sn.DateAsc]:(e,t)=>e.last_modified>t.last_modified?1:-1,[sn.DateDesc]:(e,t)=>e.last_modified<t.last_modified?1:-1},l1=()=>{const{artifacts:e,artifactsLoading:t,previewArtifact:n,setPreviewArtifact:r}=Ye(),[o,s]=u.useState(sn.DateDesc),i=u.useMemo(()=>t?[]:e?[...e].sort(a1[o]):[],[e,t,o]),l=u.useMemo(()=>n?a.jsxs("div",{className:"flex items-center gap-2 border-b p-2",children:[a.jsx(me,{variant:"ghost",onClick:()=>r(null),children:a.jsx(im,{})}),a.jsx("div",{className:"text-md font-semibold",children:"Preview"})]}):i.length>0&&a.jsxs("div",{className:"flex items-center justify-end border-b p-2",children:[a.jsx(o1,{currentSortOption:o,onSortChange:s,children:a.jsxs(me,{variant:"ghost",title:"Sort By",children:[a.jsx(Zl,{className:"h-5 w-5"}),a.jsx("div",{children:"Sort By"})]})},"sort-popover"),a.jsx(s1,{children:a.jsx(me,{variant:"ghost",tooltip:"More",children:a.jsx(am,{className:"h-5 w-5"})})},"more-popover")]}),[n,i.length,o,r]);return a.jsxs("div",{className:"flex h-full flex-col",children:[l,a.jsxs("div",{className:"flex min-h-0 flex-1",children:[!n&&a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.map(c=>a.jsx(zl,{artifact:c},c.filename)),i.length===0&&a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[t&&a.jsx(Ti,{className:"size-6 animate-spin"}),!t&&a.jsxs(a.Fragment,{children:[a.jsx(pr,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Files"}),a.jsx("div",{className:"mt-2 text-sm",children:"No files available"})]})]})})]}),n&&a.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[a.jsx(zl,{artifact:n,isPreview:!0},n.filename),a.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto",children:a.jsx(n1,{artifact:n})})]})]}),a.jsx(ZC,{}),a.jsx(i1,{})]})},c1=({onCollapsedToggle:e,isSidePanelCollapsed:t,setIsSidePanelCollapsed:n,isSidePanelTransitioning:r})=>{const{activeSidePanelTab:o,setActiveSidePanelTab:s,setPreviewArtifact:i,taskIdInSidePanel:l}=Ye(),{isReconnecting:c,isTaskMonitorConnecting:d,isTaskMonitorConnected:f,monitoredTasks:p,connectTaskMonitorStream:m}=ta(),[h,x]=u.useState(null);u.useEffect(()=>{if(l&&p[l]){const y=p[l],E=W1(y.events||[],p,y);x(E)}else x(null)},[l,p]);const g=()=>c||d?{message:"Connecting to task monitor ...",showButton:!1}:f?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:lm,buttonAction:m},v=()=>{const y=!t;n(y),e(y)},b=y=>{y==="files"&&i(null),s(y)},w=y=>{t&&(n(!1),e==null||e(!1)),b(y)};return t?a.jsxs("div",{className:"bg-background flex h-full w-full flex-col items-center border-l py-4",children:[a.jsx(me,{variant:"ghost",size:"sm",onClick:v,className:"h-10 w-10 p-0",tooltip:"Expand Panel",children:a.jsx(va,{className:"size-5"})}),a.jsx("div",{className:"bg-border my-4 h-px w-8"}),a.jsx(me,{variant:"ghost",size:"sm",onClick:()=>w("files"),className:"mb-2 h-10 w-10 p-0",tooltip:"Files",children:a.jsx(pr,{className:"size-5"})}),a.jsx(me,{variant:"ghost",size:"sm",onClick:()=>w("workflow"),className:"h-10 w-10 p-0",tooltip:"Workflow",children:a.jsx(Ao,{className:"size-5"})})]}):a.jsx("div",{className:"bg-background flex h-full flex-col border-l",children:a.jsx("div",{className:"m-1 min-h-0 flex-1",children:a.jsxs(rb,{value:o,onValueChange:y=>b(y),className:"flex h-full flex-col",children:[a.jsxs("div",{className:"flex gap-2 p-2",children:[a.jsx(me,{variant:"ghost",onClick:v,className:"p-1",tooltip:"Collapse Panel",children:a.jsx(va,{className:"size-5"})}),a.jsxs(ob,{className:"grid w-full grid-cols-2 bg-transparent p-0",children:[a.jsxs(fl,{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:[a.jsx(pr,{className:"mr-2 h-4 w-4"}),"Files"]}),a.jsxs(fl,{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:[a.jsx(Ao,{className:"mr-2 h-4 w-4"}),"Workflow"]})]})]}),a.jsxs("div",{className:"min-h-0 flex-1",children:[a.jsx(pl,{value:"files",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:a.jsx(l1,{})})}),a.jsx(pl,{value:"workflow",className:"m-0 h-full",children:a.jsx("div",{className:"h-full",children:(()=>{const y=g();return!y&&h?a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx(f1,{task:h}),a.jsx(H1,{processedSteps:h.steps||[],isRightPanelVisible:!1,isSidePanelTransitioning:r})]}):a.jsx("div",{className:"flex h-full items-center justify-center p-4",children:a.jsxs("div",{className:"text-muted-foreground text-center",children:[a.jsx(Ao,{className:"mx-auto mb-4 h-12 w-12"}),a.jsx("div",{className:"text-lg font-medium",children:"Workflow"}),a.jsx("div",{className:"mt-2 text-sm",children:y==null?void 0:y.message}),(y==null?void 0:y.showButton)&&a.jsx("div",{className:"mt-4",children:a.jsxs(me,{onClick:y.buttonAction,children:[y.buttonIcon&&(()=>{const E=y.buttonIcon;return a.jsx(E,{className:"h-4 w-4"})})(),y.buttonText]})})]})})})()})})]})]})})})},xi=({statusText:e,onViewWorkflow:t})=>a.jsxs("div",{className:"flex h-8 items-center space-x-3 py-1",children:[t?a.jsx(iu,{onClick:t}):a.jsx(ub,{className:"mr-3 ml-2"}),a.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:e&&a.jsx("span",{className:"text-muted-foreground animate-pulse truncate text-sm",title:e,children:e})})]}),kp=({isOpen:e,onClose:t})=>{const{handleNewSession:n}=Ye(),{persistenceEnabled:r}=Jt();return a.jsx(Qr,{open:e,onOpenChange:t,children:a.jsxs(eo,{children:[a.jsxs(to,{children:[a.jsx(no,{className:"flex max-w-[400px] flex-row gap-1",children:r===!1?"New Chat Session?":"Start New Chat Session?"}),a.jsx(ro,{className:"flex flex-col gap-2",children:r===!1?"Starting a new chat session will clear the current chat history and files. Are you sure you want to proceed?":"This will create a new chat session. Your current chat will be saved in the sessions panel."})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(me,{variant:"ghost",onClick:t,children:"Cancel"}),a.jsx(me,{variant:"default",onClick:()=>{n(),t()},children:"Start New Chat"})]})]})})},u1=({onToggle:e})=>{const[t,n]=u.useState(!1);return a.jsxs("div",{className:"bg-background flex h-full w-100 flex-col border-r",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 pt-[35px] pb-3",children:[a.jsx(me,{variant:"ghost",onClick:e,className:"p-2",tooltip:"Collapse Sessions Panel",children:a.jsx(sc,{className:"size-5"})}),a.jsxs(me,{variant:"ghost",onClick:()=>n(!0),tooltip:"Start New Chat Session",children:[a.jsx(ic,{className:"size-5"}),"New chat"]})]}),a.jsx("div",{className:"mt-1 min-h-0 flex-1",children:a.jsx(qC,{})}),a.jsx(kp,{isOpen:t,onClose:()=>n(!1)})]})},Rr=(e,t)=>a.jsx(Cf,{type:t,className:"rounded-full border-none",children:a.jsx("span",{className:"text-xs font-semibold",title:e,children:e})}),d1=(e,t)=>{var r;if(e.currentStatusText)return a.jsx("div",{title:e.currentStatusText,children:a.jsx(xi,{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 a.jsx("div",{title:n||e.status,children:a.jsx(xi,{statusText:n||e.status})});case"input-required":return Rr("Input Required","info");case"completed":return Rr("Completed","success");case"canceled":return Rr("Canceled","info");case"failed":return Rr("Failed","error");default:return Rr("Unknown","info")}},f1=({task:e})=>{const{messages:t,addNotification:n}=Ye(),{configServerUrl:r,configFeatureEnablement:o}=Jt(),s=u.useMemo(()=>`${r}/api/v1`,[r]),i=(o==null?void 0:o.taskLogging)??!1,l=u.useMemo(()=>{const d=t.find(f=>f.isStatusBubble);return e?d1(e,d):null},[t,e]),c=async()=>{if(!e.taskId){n("Task ID is missing, cannot download.","error");return}try{const d=await Pe(`${s}/tasks/${e.taskId}`);if(!d.ok){const h=await d.json().catch(()=>({detail:`Failed to download: ${d.statusText}`}));throw new Error(h.detail||`HTTP error ${d.status}`)}const f=await d.blob(),p=window.URL.createObjectURL(f),m=document.createElement("a");m.href=p,m.download=`${e.taskId}.stim`,document.body.appendChild(m),m.click(),m.remove(),window.URL.revokeObjectURL(p),n("Task log download started.","success")}catch(d){console.error("Failed to download .stim file:",d),n(`Failed to download task log: ${d instanceof Error?d.message:"Unknown error"}`,"error")}};return e?a.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto] grid-rows-[32px_32px] items-center gap-x-8 border-b p-4",children:[a.jsx("div",{className:"text-muted-foreground",children:"User"}),a.jsx("div",{className:"truncate",title:e.initialRequestText,children:e.initialRequestText}),a.jsx("div",{}),a.jsx("div",{className:"text-muted-foreground",children:"Status"}),a.jsx("div",{className:"truncate",children:l}),a.jsx("div",{children:i&&a.jsx(me,{variant:"ghost",size:"icon",onClick:c,tooltip:"Download Task Log (.stim)",children:a.jsx(Yo,{className:"size-4"})})})]}):null};class Np{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 s=r.slice(0,n+1);return this.hasMatchingResponse(o,s)?{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(s=>{var f;if(new Date(s.timestamp).getTime()<r)return!1;const l=(s.type==="AGENT_LLM_RESPONSE_TOOL_DECISION"||s.type==="AGENT_LLM_RESPONSE_TO_AGENT")&&s.target===o,c=s.source===o&&(s.type==="AGENT_TOOL_INVOCATION_START"||s.type==="TASK_COMPLETED"),d=s.type==="AGENT_TOOL_EXECUTION_RESULT"&&((f=s.data.toolResult)==null?void 0:f.isPeerResponse);return l||c||d})}hasToolResponse(t,n){const r=new Date(t.timestamp).getTime(),o=t.target,s=t.source;return n.some(i=>new Date(i.timestamp).getTime()<r?!1:i.type==="AGENT_TOOL_EXECUTION_RESULT"&&i.source===o&&i.target===s)}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 _p(e,t){return(t==null?void 0:t[e])||e}const wn={USER:50,MAIN_FLOW:300,TOOLS:600},p1=50,nt=50,Ut=330,qn=50,nn=20,vr=10,$l=nt+20,m1=90;function Xn(e,t,n){return e.push(n),t.add(n.id),n}function h1(e,t){return e.push(t),t}function Zn(e,t){return e.nodeIdCounter++,`${t.replace(/[^a-zA-Z0-9_]/g,"_")}_${e.nodeIdCounter}`}function bt(e){return e.currentPhaseIndex===-1||e.currentPhaseIndex>=e.phases.length?null:e.phases[e.currentPhaseIndex]}function ao(e){const t=bt(e);return!t||e.currentSubflowIndex===-1||e.currentSubflowIndex>=t.subflows.length?null:t.subflows[e.currentSubflowIndex]}function g1(e,t,n){var r;for(let o=e.length-1;o>=0;o--){const s=e[o],i=n.find(l=>l.id===s.id);if(((r=i==null?void 0:i.data)==null?void 0:r.toolName)===t)return s}return null}function x1(e,t){if(!t)return null;const n=bt(e);return n&&n.subflows.findLast(r=>r.functionCallId===t)||null}function v1(e,t){if(!t)return null;const n=bt(e);return n&&n.subflows.findLast(r=>r.id===t)||null}function gs(e,t){var o;const n=bt(e);if(!n)return null;if(t.functionCallId){const s=x1(e,t.functionCallId);if(s)return s}if(t.owningTaskId&&t.isSubTaskStep){const s=v1(e,t.owningTaskId);if(s){const i=n.subflows||[];if(!(new Set(i.map(c=>c.id)).size!==i.length))return s}}const r=ao(e);if(r&&t.source){const s=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(s)||i&&l.includes(i))return r}return r||null}function Ip(e,t){var r,o,s;if(((r=e.data.toolDecision)==null?void 0:r.isParallel)===!0)return!0;const n=(s=(o=e.data)==null?void 0:o.toolInvocationStart)==null?void 0:s.functionCallId;return n?Array.from(t.parallelFlows.values()).some(i=>i.subflowFunctionCallIds.includes(n)):!1}function jp(e,t,n,r){var o;if(r)for(let s=e.length-1;s>=0;s--){const i=e[s];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 g1(e,t,n)}function w1(e,t,n){const r=bt(e);if(!r)return null;const o=t.replace(/[^a-zA-Z0-9_]/g,"_"),s=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)||s&&l.peerAgent.id.includes(s)){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 Mp(r,l)}return null}function Mp(e,t){if(t.isParallel)return t;if(t.parentSubflowId){const n=e.subflows.find(r=>r.id===t.parentSubflowId);if(n)return Mp(e,n)}return null}function wr(e,t,n,r){const o=`phase_${e.phases.length}`,s=Zn(e,`${t}_${o}`),i=e.nextAvailableGlobalY,l=_p(t,e.agentNameMap),c={id:s,type:"orchestratorNode",position:{x:wn.MAIN_FLOW,y:i},data:{label:l,visualizerStepId:n.id}};Xn(r,e.allCreatedNodeIds,c),e.nodePositions.set(s,c.position);const d={id:s,yPosition:i,height:nt,width:Ut},f={id:s,name:t,type:"orchestrator",phaseId:o,context:"main",nodeInstance:d};e.agentRegistry.registerAgent(f);const p={id:o,orchestratorAgent:d,userNodes:[],subflows:[],toolInstances:[],currentToolYOffset:0,maxY:i+nt};return e.phases.push(p),e.currentPhaseIndex=e.phases.length-1,e.currentSubflowIndex=-1,e.nextAvailableGlobalY=p.maxY+qn,p}function vi(e,t,n,r,o){var U,B,Z,J,D;const s=bt(e);if(!s)return null;const i=n.type==="AGENT_TOOL_EXECUTION_RESULT"&&((U=n.data.toolResult)==null?void 0:U.isPeerResponse)===!0,l=n.source||"",c=n.target||"",d=br(l);!i&&!d&&!o&&e.indentationLevel++;const f=((Z=(B=n.delegationInfo)==null?void 0:B[0])==null?void 0:Z.subTaskId)||n.owningTaskId,p=Zn(e,`${t}_${f}`),m=Zn(e,`group_${t}_${f}`),h=((D=(J=n.data)==null?void 0:J.toolInvocationStart)==null?void 0:D.functionCallId)||n.functionCallId||"";let x,g,v;const b=Array.from(e.parallelFlows.values()).find(X=>X.subflowFunctionCallIds.includes(h)),w=ao(e),y=w1(e,l,c);o&&b?(x=b.startX+b.currentXOffset,g=b.startY,v=g+nn,b.currentXOffset+=(Ut+vr)*2.2):y?(v=e.nextAvailableGlobalY,x=(y.groupNode.xPosition||wn.MAIN_FLOW-50)+e.indentationLevel*e.indentationStep,g=v-nn):(v=e.nextAvailableGlobalY,x=wn.MAIN_FLOW-50+e.indentationLevel*e.indentationStep,g=v-nn);const E=_p(t,e.agentNameMap),T={id:p,type:"genericAgentNode",position:{x:50,y:nn},data:{label:E,visualizerStepId:n.id},parentId:m},j={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:`${nt+2*nn}px`}};Xn(r,e.allCreatedNodeIds,j),Xn(r,e.allCreatedNodeIds,T),e.nodePositions.set(p,T.position),e.nodePositions.set(m,j.position);const k={id:p,xPosition:wn.MAIN_FLOW,yPosition:v,height:nt,width:Ut},_={id:p,name:t,type:"peer",phaseId:s.id,subflowId:f,context:"subflow",nodeInstance:k};e.agentRegistry.registerAgent(_);const G={id:f,functionCallId:h,isParallel:o,peerAgent:k,groupNode:{id:m,xPosition:x,yPosition:g,height:nt+2*nn,width:0},toolInstances:[],currentToolYOffset:0,maxY:v+nt,maxContentXRelative:T.position.x+Ut,callingPhaseId:s.id,parentSubflowId:w==null?void 0:w.id,inheritedXOffset:y==null?void 0:y.groupNode.xPosition};return s.subflows.push(G),y&&(y.lastSubflow=G),e.currentSubflowIndex=s.subflows.length-1,o&&b?(b.maxHeight=Math.max(b.maxHeight,G.groupNode.height),e.nextAvailableGlobalY=b.startY+b.maxHeight+qn):e.nextAvailableGlobalY=G.groupNode.yPosition+G.groupNode.height+qn,G}function Rp(e,t,n,r,o,s,i=!1){const l=bt(e);if(!l)return null;const c=s?s.toolInstances:l.toolInstances,d=i?"LLM":`Tool: ${t}`,f=i?"LLM":t,p=s?s.groupNode.id:void 0;let m,h,x,g;if(s){if(m=s.peerAgent.yPosition+s.currentToolYOffset,s.currentToolYOffset+=$l,x=50+300,s.groupNode.xPosition===void 0||s.groupNode.yPosition===void 0)return null;h=s.groupNode.xPosition+x,g=m-s.groupNode.yPosition}else h=wn.TOOLS,m=l.orchestratorAgent.yPosition+l.currentToolYOffset,l.currentToolYOffset+=$l,x=h,g=m;const v=Zn(e,`${f}_${r.id}`),b={id:v,type:n,position:{x,y:g},data:{label:d,visualizerStepId:r.id,toolName:t},parentId:p};Xn(o,e.allCreatedNodeIds,b),e.nodePositions.set(v,{x,y:g});const w={id:v,xPosition:h,yPosition:m,height:nt,width:Ut,functionCallId:r.functionCallId};c.push(w);const y=m+nt;if(s){s.maxY=Math.max(s.maxY,y),s.maxContentXRelative=Math.max(s.maxContentXRelative,x+Ut);const E=s.maxY-s.groupNode.yPosition+nn;s.groupNode.height=Math.max(s.groupNode.height,E);const T=s.maxContentXRelative+vr;s.groupNode.width=Math.max(s.groupNode.width||0,T);const j=o.find(k=>k.id===s.groupNode.id);j&&(j.style={...j.style,height:`${s.groupNode.height}px`,width:`${s.groupNode.width}px`}),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,s.groupNode.yPosition+s.groupNode.height+qn)}else l.maxY=Math.max(l.maxY,y),e.nextAvailableGlobalY=Math.max(e.nextAvailableGlobalY,l.maxY+qn);return w}function ma(e,t,n,r){e.userNodeCounter++;const o=Zn(e,`User_response_${e.userNodeCounter}`),s=e.nextAvailableGlobalY+20,i={id:o,type:"userNode",position:{x:wn.USER,y:s},data:{label:"User",visualizerStepId:n.id,isBottomNode:!0}};Xn(r,e.allCreatedNodeIds,i),e.nodePositions.set(o,i.position);const l={id:o,yPosition:s,height:nt,width:Ut};t.userNodes.push(l),e.allUserNodes.push(l);const c=s+nt;return t.maxY=Math.max(t.maxY,c),l}function Rt(e,t,n,r,o,s,i,l,c){if(!e||!t||e===t)return;const d=o.allCreatedNodeIds.has(e),f=o.allCreatedNodeIds.has(t);if(!d||!f)return;const p=`edge-${e}${l||""}-to-${t}${c||""}-${n.id}`;if(!r.some(h=>h.id===p)){const h=n.title&&n.title.length>30?n.type.replace(/_/g," ").toLowerCase():n.title||"",x=s.isRequestStep(n),g={id:p,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),h1(r,g)}}function b1(){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,s)=>{const i=parseInt(o.id.split("_").pop()||"0");return parseInt(s.id.split("_").pop()||"0")>i?s:o})},findAgentById(t){for(const[,n]of e)if(n.id===t)return n;return null},registerAgent(t){e.set(t.id,t)}}}function wi(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 br(e){return e==="OrchestratorAgent"||e.toLowerCase().includes("orchestrator")}const y1=["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 S1(e,t,n,r,o,s){const i=e.target,l=i.replace(/[^a-zA-Z0-9_]/g,"_"),c=bt(t),d=ao(t);let f,p=!1;if(d?(f=d.peerAgent,f.id.startsWith(l+"_")&&(p=!0)):c&&(f=c.orchestratorAgent,f.id.startsWith(l+"_")&&(p=!0)),p&&f&&c){t.userNodeCounter++;const m=Zn(t,`User_continue_${t.userNodeCounter}`),h=t.nextAvailableGlobalY,x={id:m,type:"userNode",position:{x:wn.USER,y:h},data:{label:"User",visualizerStepId:e.id}};Xn(n,t.allCreatedNodeIds,x),t.nodePositions.set(m,x.position);const g={id:m,yPosition:h,height:nt,width:Ut};c.userNodes.push(g),t.allUserNodes.push(g);const v=h+nt;f.yPosition=Math.max(f.yPosition,h),c.maxY=Math.max(c.maxY,v,f.yPosition+nt),t.nextAvailableGlobalY=c.maxY+qn;const b=br(i)?"orch-left-input":"peer-left-input";Rt(g.id,f.id,e,r,t,o,s,"user-right-output",b)}else{const m=wr(t,i,e,n),h=Zn(t,`User_${m.id}`),x={id:h,type:"userNode",position:{x:wn.USER,y:m.orchestratorAgent.yPosition-m1},data:{label:"User",visualizerStepId:e.id,isTopNode:!0}};Xn(n,t.allCreatedNodeIds,x),t.nodePositions.set(h,x.position);const g={id:h,yPosition:x.position.y,height:nt,width:Ut};m.userNodes.push(g),t.allUserNodes.push(g),t.userNodeCounter++,m.maxY=Math.max(m.maxY,x.position.y+nt),t.nextAvailableGlobalY=m.maxY+qn,Rt(h,m.orchestratorAgent.id,e,r,t,o,s,"user-bottom-output","orch-top-input")}}function C1(e,t,n,r,o,s){const i=bt(t);if(!i)return;const l=gs(t,e),c=l?l.peerAgent.id:i.orchestratorAgent.id,d=Rp(t,"LLM","llmNode",e,n,l,!0);d&&Rt(c,d.id,e,r,t,o,s,l?"peer-right-output-tools":"orch-right-output-tools","llm-left-input")}function E1(e,t,n,r,o,s){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(v=>v.isPeerDelegation).length>1&&t.parallelFlows.set(g,{subflowFunctionCallIds:e.data.toolDecision.decisions.filter(v=>v.isPeerDelegation).map(v=>v.functionCallId),completedSubflows:new Set,startX:wn.MAIN_FLOW-50,startY:t.nextAvailableGlobalY,currentXOffset:0,maxHeight:0})}const i=bt(t);if(!i)return;const l=gs(t,e);let c;const f=jp((l||i).toolInstances,"LLM",n,e.functionCallId);if(f)c=f.id;else{console.error(`[Timeline] LLM node not found for step type ${e.type}: ${e.id}. Cannot create edge.`);return}const p=e.target||"UnknownAgent";let m,h;l?(m=l.peerAgent.id,h="peer-right-input-tools"):i.orchestratorAgent.id.startsWith(p.replace(/[^a-zA-Z0-9_]/g,"_")+"_")&&(m=i.orchestratorAgent.id,h="orch-right-input-tools"),c&&m&&h?Rt(c,m,e,r,t,o,s,"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: ${p}. Edge will be missing.`)}function T1(e,t,n,r,o,s){var f;const i=bt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"UnknownTool";if(((f=e.data.toolInvocationStart)==null?void 0:f.isPeerInvocation)||c.startsWith("peer_")){const p=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=wi(m.type,"output","bottom"),g=Ip(e,t),v=vi(t,p,e,n,g);v&&Rt(h.id,v.peerAgent.id,e,r,t,o,s,x,"peer-top-input")}else{const p=gs(t,e);let m,h;if(p)m=p.peerAgent.id,h="peer-right-output-tools";else{const g=t.agentRegistry.findAgentByName(l);g?(m=g.id,h=wi(g.type,"output","right")):(m=i.orchestratorAgent.id,h="orch-right-output-tools")}const x=Rp(t,c,"genericToolNode",e,n,p);x&&Rt(m,x.id,e,r,t,o,s,h,`${x.id}-tool-left-input`)}}function A1(e,t,n,r,o,s){var d,f;const i=bt(t);if(!i)return;const l=e.source||"UnknownSource",c=e.target||"OrchestratorAgent";if((d=e.data.toolResult)!=null&&d.isPeerResponse){const p=(f=e.data.toolResult)==null?void 0:f.functionCallId,m=Array.from(t.parallelFlows.entries()).find(([x,g])=>g.subflowFunctionCallIds.includes(p||""));if(m){const[x,g]=m;if(g.completedSubflows.add(p||""),g.completedSubflows.size<g.subflowFunctionCallIds.length)return;const v=i.subflows.filter(E=>g.subflowFunctionCallIds.includes(E.functionCallId)),b=e.target||"OrchestratorAgent";let w,y;if(br(b))t.indentationLevel=0,w=wr(t,b,e,n).orchestratorAgent,y="orch-top-input",t.currentSubflowIndex=-1;else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const E=vi(t,b,e,n,!1);if(!E)return;w=E.peerAgent,y="peer-top-input"}v.forEach(E=>{var T;Rt(((T=E.lastSubflow)==null?void 0:T.peerAgent.id)??E.peerAgent.id,w.id,e,r,t,o,s,"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(br(c)){t.indentationLevel=0;const x=wr(t,c,e,n);Rt(h.id,x.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input"),t.currentSubflowIndex=-1}else{t.indentationLevel=Math.max(0,t.indentationLevel-1);const x=Ip(e,t)||Array.from(t.parallelFlows.values()).some(v=>v.subflowFunctionCallIds.some(b=>i.subflows.some(w=>w.functionCallId===b))),g=vi(t,c,e,n,x);g&&Rt(h.id,g.peerAgent.id,e,r,t,o,s,"peer-bottom-output","peer-top-input")}}else{let p;const m=gs(t,e),x=jp((m||i).toolInstances,l,n,e.functionCallId);if(x&&(p=x.id),p){let g,v;if(m)g=m.peerAgent.id,v="peer-right-input-tools";else{const b=t.agentRegistry.findAgentByName(c);b?(g=b.id,v=wi(b.type,"input","right")):(g=i.orchestratorAgent.id,v="orch-right-input-tools")}Rt(p,g,e,r,t,o,s,l==="LLM"?"llm-bottom-output":`${p}-tool-bottom-output`,v)}else console.error(`[Timeline] Could not find source tool node for regular tool result: ${e.id}. Step source (tool name): ${l}.`)}}function k1(e,t,n,r,o,s){const i=bt(t);if(!i||e.isSubTaskStep)return;const l=i.orchestratorAgent.id,c=ma(t,i,e,n);Rt(l,c.id,e,r,t,o,s,"orch-bottom-output","user-top-input")}function N1(e,t,n,r,o,s){const i=bt(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=wr(t,"OrchestratorAgent",e,n);i.subflows.forEach(x=>{l.subflowFunctionCallIds.includes(x.functionCallId)&&Rt(x.peerAgent.id,h.orchestratorAgent.id,e,r,t,o,s,"peer-bottom-output","orch-top-input")}),t.currentSubflowIndex=-1}return}if(!e.isSubTaskStep)return;const c=ao(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 d=c.peerAgent,f=n.some(h=>typeof h.data.label=="string"&&br(h.data.label));let p,m;f?(t.indentationLevel=0,p=wr(t,"OrchestratorAgent",e,n).orchestratorAgent.id,m="orch-top-input"):(p=ma(t,i,e,n).id,m="user-top-input"),Rt(d.id,p,e,r,t,o,s,"peer-bottom-output",m),t.currentSubflowIndex=-1}function _1(e,t,n,r){const o=bt(t);if(!o)return;const s=e.source||"UnknownSource",i=e.target||"User";let l,c="orch-bottom-output";const d=ao(t);if(d&&d.peerAgent.id.includes(s.replace(/[^a-zA-Z0-9_]/g,"_")))l=d.peerAgent,c="peer-bottom-output";else if(o.orchestratorAgent.id.includes(s.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(s.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: ${s}`);return}let f,p;br(i)?(t.indentationLevel=0,f=wr(t,i,e,n).orchestratorAgent.id,p="orch-top-input",t.currentSubflowIndex=-1):(f=ma(t,o,e,n).id,p="user-top-input"),I1(l.id,f,e,r,t,c,p)}function I1(e,t,n,r,o,s,i){var p;if(!e||!t||e===t)return;const l=o.allCreatedNodeIds.has(e),c=o.allCreatedNodeIds.has(t);if(!l||!c)return;const d=`error-edge-${e}${s||""}-to-${t}${i||""}-${n.id}`;if(!r.some(m=>m.id===d)){const m=((p=n.data.errorDetails)==null?void 0:p.message)||"Task failed",h=m.length>30?"Error":m,x={id:d,source:e,target:t,label:h,type:"defaultFlowEdge",data:{visualizerStepId:n.id,isAnimated:!1,animationType:"static",isError:!0,errorMessage:m}};s&&(x.sourceHandle=s),i&&(x.targetHandle=i),r.push(x)}}const j1=(e,t={})=>{const n=[],r=[];if(!e||e.length===0)return{nodes:n,edges:r};const o=new Np,s={phases:[],currentPhaseIndex:-1,currentSubflowIndex:-1,parallelFlows:new Map,nextAvailableGlobalY:p1,nodeIdCounter:0,allCreatedNodeIds:new Set,nodePositions:new Map,allUserNodes:[],userNodeCounter:0,agentRegistry:b1(),indentationLevel:0,indentationStep:50,agentNameMap:t},i=e.filter(d=>y1.includes(d.type)),l=i.findIndex(d=>d.type==="USER_REQUEST");let c=i;l>0&&(c=[i[l],...i.slice(0,l),...i.slice(l+1)]);for(const d of c)switch(d.type){case"USER_REQUEST":S1(d,s,n,r,o,e);break;case"AGENT_LLM_CALL":C1(d,s,n,r,o,e);break;case"AGENT_LLM_RESPONSE_TO_AGENT":case"AGENT_LLM_RESPONSE_TOOL_DECISION":E1(d,s,n,r,o,e);break;case"AGENT_TOOL_INVOCATION_START":T1(d,s,n,r,o,e);break;case"AGENT_TOOL_EXECUTION_RESULT":A1(d,s,n,r,o,e);break;case"AGENT_RESPONSE_TEXT":k1(d,s,n,r,o,e);break;case"TASK_COMPLETED":N1(d,s,n,r,o,e);break;case"TASK_FAILED":_1(d,s,n,r);break}return s.phases.forEach(d=>{d.subflows.forEach(f=>{const p=n.find(m=>m.id===f.groupNode.id);if(p&&p.style){const h=f.maxY-f.groupNode.yPosition+nn;p.style.height=`${Math.max(nt+2*nn,h)}px`;const x=f.maxContentXRelative+vr,g=Ut+2*vr+s.indentationLevel*s.indentationStep;p.style.width=`${Math.max(x,g)}px`}})}),{nodes:n,edges:r}},M1=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,style:l={},markerEnd:c,data:d})=>{const[f,p]=u.useState(!1),[m]=cm({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i}),h=()=>{const v={strokeWidth:f?3:2,stroke:"var(--color-muted-foreground)",...l},b=d;return b!=null&&b.isError?{...v,stroke:f?"var(--color-error-wMain)":"var(--color-error-w70)",strokeWidth:f?3:2}:b!=null&&b.isSelected?{...v,stroke:"#3b82f6",strokeWidth:3}:b!=null&&b.isAnimated?{...v,stroke:f?"#1d4ed8":"#3b82f6",strokeWidth:f?4:3}:f?{...v,stroke:"var(--edge-hover-color)"}:v},x=()=>p(!0),g=()=>p(!1);return a.jsxs(a.Fragment,{children:[a.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}),a.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})]})},R1=({data:e})=>a.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:[a.jsx(lt,{type:"target",position:ct.Top,id:"peer-top-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx(lt,{type:"source",position:ct.Right,id:"peer-right-output-tools",className:"!bg-blue-700",style:{top:"25%"},isConnectable:!0}),a.jsx(lt,{type:"target",position:ct.Right,id:"peer-right-input-tools",className:"!bg-blue-700",style:{top:"75%"},isConnectable:!0}),a.jsx(lt,{type:"source",position:ct.Bottom,id:"peer-bottom-output",className:"!bg-blue-700",isConnectable:!0}),a.jsx(lt,{type:"target",position:ct.Left,id:"peer-left-input",className:"!bg-blue-700",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md truncate font-semibold",style:{maxWidth:"200px"},children:e.label})})]}),P1=({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 a.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:[a.jsx(lt,{type:"target",position:ct.Left,id:`${t}-tool-left-input`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${n()}`}),a.jsx("div",{className:"text-md truncate",style:{maxWidth:"200px"},children:e.label})]}),a.jsx(lt,{type:"source",position:ct.Left,id:`${t}-tool-bottom-output`,className:"!bg-cyan-500",isConnectable:!0,style:{top:"75%"}})]})},L1=({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 a.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:[a.jsx(lt,{type:"target",position:ct.Left,id:"llm-left-input",className:"!bg-teal-500",isConnectable:!0,style:{top:"25%"}}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-2 w-2 rounded-full ${t()}`}),a.jsx("div",{className:"text-md",children:e.label})]}),a.jsx(lt,{type:"source",position:ct.Left,id:"llm-bottom-output",className:"!bg-teal-500",isConnectable:!0,style:{top:"75%"}})]})},D1=({data:e})=>a.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:[a.jsx(lt,{type:"source",position:ct.Right,id:"orch-right-output-tools",className:"!bg-indigo-500",style:{top:"25%"},isConnectable:!0}),a.jsx(lt,{type:"target",position:ct.Right,id:"orch-right-input-tools",className:"!bg-indigo-500",style:{top:"75%"},isConnectable:!0}),a.jsx(lt,{type:"target",position:ct.Top,id:"orch-top-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(lt,{type:"source",position:ct.Bottom,id:"orch-bottom-output",className:"!bg-indigo-500",isConnectable:!0}),a.jsx(lt,{type:"target",position:ct.Left,id:"orch-left-input",className:"!bg-indigo-500",isConnectable:!0}),a.jsx("div",{className:"flex items-center justify-center",children:a.jsx("div",{className:"text-md truncate font-bold",style:{maxWidth:"200px"},children:e.label})})]}),O1=({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 a.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&&a.jsx(lt,{type:"source",position:ct.Bottom,id:"user-bottom-output",className:"!bg-gray-500",isConnectable:!0}),e.isBottomNode&&a.jsx(lt,{type:"target",position:ct.Top,id:"user-top-input",className:"!bg-gray-500",isConnectable:!0}),!e.isTopNode&&!e.isBottomNode&&a.jsx(lt,{type:"source",position:ct.Right,id:"user-right-output",className:"!bg-gray-500",isConnectable:!0}),a.jsxs("div",{className:"flex items-center justify-center",children:[a.jsx("div",{className:`mr-2 h-3 w-3 rounded-full ${t()}`}),a.jsx("div",{className:"text-sm font-bold",children:e.label})]})]})},F1=({step:e,isHighlighted:t,onClick:n,variant:r="list"})=>{const o=()=>{var w,y,E;switch(e.type){case"USER_REQUEST":return a.jsx(pm,{className:"mr-2 text-blue-500 dark:text-blue-400",size:18});case"AGENT_RESPONSE_TEXT":return a.jsx(xs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"TASK_COMPLETED":return a.jsx(rc,{className:"mr-2 text-green-500 dark:text-green-400",size:18});case"TASK_FAILED":return a.jsx(fm,{className:"mr-2 text-red-500 dark:text-red-400",size:18});case"AGENT_LLM_CALL":return a.jsx(xs,{className:"mr-2 text-purple-500 dark:text-purple-400",size:18});case"AGENT_LLM_RESPONSE_TO_AGENT":return a.jsx(xs,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_LLM_RESPONSE_TOOL_DECISION":{const T=(y=(w=e.data.toolDecision)==null?void 0:w.decisions)==null?void 0:y[0];return(T==null?void 0:T.isPeerDelegation)?a.jsx(wa,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18}):a.jsx(ba,{className:"mr-2 text-orange-500 dark:text-orange-400",size:18})}case"AGENT_TOOL_INVOCATION_START":return(E=e.data.toolInvocationStart)!=null&&E.isPeerInvocation?a.jsx(wa,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18}):a.jsx(ba,{className:"mr-2 text-cyan-500 dark:text-cyan-400",size:18});case"AGENT_TOOL_EXECUTION_RESULT":return a.jsx(dm,{className:"mr-2 text-teal-500 dark:text-teal-400",size:18});case"AGENT_ARTIFACT_NOTIFICATION":return a.jsx(pr,{className:"mr-2 text-indigo-500 dark:text-indigo-400",size:18});default:return a.jsx(um,{className:"mr-2 text-gray-500 dark:text-gray-400",size:18})}},s=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=`${s}.${i}`,c=w=>a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Prompt Preview:"})}),a.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:w.promptPreview})]}),d=({data:w})=>{const[y,E]=Yt.useState(!1),T=j=>{j.stopPropagation(),E(!y)};return y?a.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:[a.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[a.jsx("strong",{children:"LLM Response Details:"}),a.jsx("button",{onClick:T,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Hide details"})]}),w.modelName&&a.jsxs("p",{children:[a.jsx("strong",{children:"Model:"})," ",w.modelName]}),a.jsxs("div",{className:"mt-1",children:[a.jsx("p",{children:a.jsx("strong",{children:"Response Preview:"})}),a.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:w.responsePreview})]}),w.isFinalResponse!==void 0&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Final Response:"})," ",w.isFinalResponse?"Yes":"No"]})]}):a.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"italic",children:"Internal LLM response"}),a.jsx("button",{onClick:T,className:"text-xs text-blue-500 underline hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Show details"})]})},f=w=>a.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:[a.jsx("p",{className:"mb-2",children:a.jsxs("strong",{children:["🔧 ",w.isParallel?"Parallel Tool Calls:":"Tool Call:"]})}),a.jsx("ul",{className:"space-y-1 pl-2",children:w.decisions.map(y=>a.jsxs("li",{className:"flex items-center",children:[a.jsx("span",{className:"mr-2",children:"•"}),a.jsx("code",{children:y.toolName})]},y.functionCallId))})]}),p=w=>a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Arguments:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:a.jsx(Si,{data:w.toolArguments})})]}),m=w=>a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Tool:"})," ",w.toolName]}),a.jsx("p",{className:"mt-1",children:a.jsx("strong",{children:"Result:"})}),a.jsx("div",{className:"max-h-40 overflow-y-auto rounded bg-gray-100 p-1.5 dark:bg-gray-700",children:typeof w.resultData=="object"?a.jsx(Si,{data:w.resultData}):a.jsx("pre",{className:"font-mono text-xs break-all whitespace-pre-wrap",children:String(w.resultData)})})]}),h=w=>a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Artifact:"})," ",w.artifactName,w.version!==void 0&&a.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" (v",w.version,")"]})]}),w.mimeType&&a.jsxs("p",{children:[a.jsx("strong",{children:"Type:"})," ",w.mimeType]}),w.description&&a.jsxs("p",{className:"mt-1",children:[a.jsx("strong",{children:"Description:"})," ",w.description]})]}),x=r==="list"&&e.nestingLevel&&e.nestingLevel>0?{marginLeft:`${e.nestingLevel*24}px`}:{},g=r==="popover"?`
330
- p-3 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors duration-150
331
- ${n?"cursor-pointer":""}
332
- `:`
333
- mb-3 p-3 border rounded-lg shadow-sm
334
- bg-white dark:bg-gray-800 hover:shadow-md transition-shadow duration-150
335
- ${t?"border-blue-500 dark:border-blue-400 ring-2 ring-blue-500 dark:ring-blue-400":"border-gray-200 dark:border-gray-700"}
336
- ${n?"cursor-pointer":""}
337
- `,v=()=>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: ",b=e.title;return a.jsxs("div",{className:g,style:x,onClick:n,children:[a.jsxs("div",{className:"mb-1.5 flex items-center",children:[o(),a.jsx("h4",{className:"flex-grow text-sm font-semibold text-gray-700 dark:text-gray-200",title:e.title,children:b}),a.jsx("span",{className:"font-mono text-xs text-gray-500 dark:text-gray-400",children:l})]}),e.delegationInfo&&e.delegationInfo.length>0&&a.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(w=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center font-semibold text-blue-700 dark:text-blue-300",children:[a.jsx(ac,{className:"mr-2 h-4 w-4 flex-shrink-0"}),a.jsxs("span",{children:[v(),w.peerAgentName]})]}),w.subTaskId&&a.jsxs("div",{className:"mt-0.5 ml-[24px] text-xs text-blue-600 dark:text-blue-400",children:["Sub-Task:"," ",a.jsxs("span",{className:"font-mono",title:w.subTaskId,children:[w.subTaskId.substring(0,15),"..."]})]})]},w.functionCallId))}),e.data.text&&a.jsx("div",{className:"max-h-20 overflow-y-auto pl-1 text-sm text-gray-800 dark:text-gray-100",children:a.jsx(fr,{children:e.data.text})}),e.data.finalMessage&&a.jsx("div",{className:"pl-1 text-sm text-gray-800 dark:text-gray-100",children:a.jsx(fr,{children:e.data.finalMessage})}),e.type==="TASK_COMPLETED"&&!e.data.finalMessage&&a.jsx("div",{className:"pl-1 text-sm text-gray-600 italic dark:text-gray-300",children:"Task completed successfully."}),e.data.errorDetails&&a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Error:"})," ",e.data.errorDetails.message]}),e.data.errorDetails.code&&a.jsxs("p",{className:"text-xs",children:["Code: ",e.data.errorDetails.code]})]}),e.data.llmCall&&c(e.data.llmCall),e.data.llmResponseToAgent&&a.jsx(d,{data:e.data.llmResponseToAgent}),e.data.toolDecision&&f(e.data.toolDecision),e.data.toolInvocationStart&&p(e.data.toolInvocationStart),e.data.toolResult&&m(e.data.toolResult),e.data.artifactNotification&&h(e.data.artifactNotification)]})},z1={genericAgentNode:R1,userNode:O1,llmNode:L1,orchestratorNode:D1,genericToolNode:P1},$1={defaultFlowEdge:M1},B1={x:16,y:0},U1=({processedSteps:e,isRightPanelVisible:t=!1,isSidePanelTransitioning:n=!1})=>{const[r,o,s]=hm([]),[i,l,c]=gm([]),{fitView:d}=xm(),{highlightedStepId:f,setHighlightedStepId:p}=ta(),{taskIdInSidePanel:m}=Ye(),{agentNameMap:h}=sd(),x=u.useRef([]),[g,v]=u.useState(!1),[b,w]=u.useState(null),[y,E]=u.useState(!1),T=u.useRef(null),[j,k]=u.useState(null),_=u.useRef(new Np),G=u.useMemo(()=>!e||e.length===0?{nodes:[],edges:[]}:j1(e,h),[e,h]),U=u.useMemo(()=>G.edges.length?G.edges.map(C=>{const I=C.data;let F={isAnimated:!1,animationType:"none"};if(I!=null&&I.visualizerStepId){const Q=e.length-1;F=_.current.getEdgeAnimationState(I.visualizerStepId,Q,e)}let R=C.id===j;return f&&(I==null?void 0:I.visualizerStepId)===f&&(R=!0),{...C,animated:F.isAnimated,data:{...I,isAnimated:F.isAnimated,animationType:F.animationType,isSelected:R}}}):[],[G.edges,e,j,f]),B=u.useCallback(()=>{o(C=>C.map(I=>{var le,ne,de,we;if(I.type!=="group")return I;const F=C.filter(je=>je.parentId===I.id);if(F.length===0)return I;let R=0,Q=0;F.forEach(je=>{const Re=je.position.x+Ut,Le=je.position.y+nt;R=Math.max(R,Re),Q=Math.max(Q,Le)});const O=R+vr,W=Q+nn;let z=0;const q=I.id.split("_");if(q.length>2){const je=q.find(Re=>Re.startsWith("subflow"));if(je){const Re=parseInt(je.replace("subflow",""));isNaN(Re)||(z=Re)}}const N=Ut+2*vr+z*50,K=Math.max(O,N),ee=parseInt(((ne=(le=I.style)==null?void 0:le.width)==null?void 0:ne.toString().replace("px",""))||"0"),te=parseInt(((we=(de=I.style)==null?void 0:de.height)==null?void 0:we.toString().replace("px",""))||"0");return ee!==K||te!==W?{...I,style:{...I.style,width:`${K}px`,height:`${W}px`}}:I}))},[o]);u.useEffect(()=>{o(G.nodes),l(U),B()},[G.nodes,U,o,l,B]);const Z=u.useCallback((C,I)=>i.find(F=>F.source===C&&(I?F.sourceHandle===I:!0))||null,[i]),J=u.useCallback((C,I)=>{var R;v(!0);const F=(R=I.data)==null?void 0:R.visualizerStepId;if(F){const Q=e.find(O=>O.id===F);Q&&(k(I.id),t?p(F):(p(F),w(Q),E(!0)))}},[e,t,p]),D=u.useCallback(C=>{switch(C.type){case"userNode":{const I=C.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[`${C.id}-tool-bottom-output`];default:return[]}},[]),X=u.useCallback(()=>{E(!1),w(null)},[]),A=u.useCallback((C,I)=>{if(v(!0),I.type==="group"){p(null),k(null),X();return}const F=D(I);let R=null;for(const Q of F)if(R=Z(I.id,Q),R)break;if(!R&&I.type==="userNode"){const Q=I.data;Q!=null&&Q.isBottomNode&&(R=i.find(O=>O.target===I.id)||null)}R&&J(C,R)},[D,p,X,Z,i,J]),Y=u.useCallback(C=>{C!=null&&C.isTrusted&&v(!0)},[]);return u.useEffect(()=>{v(!1)},[m]),u.useEffect(()=>{!n&&d&&r.length>0&&x.current!==e&&g===!1&&(d({duration:200,padding:.1,maxZoom:1.2}),x.current=e)},[r.length,d,e,n,g]),u.useEffect(()=>{if(o(C=>C.map(I=>{var O;const F=((O=I.data)==null?void 0:O.visualizerStepId)&&I.data.visualizerStepId===f,R=G.nodes.find(W=>W.id===I.id),Q=(R==null?void 0:R.style)||{};return{...I,style:{...Q,boxShadow:F?"0px 4px 12px rgba(0, 0, 0, 0.2)":Q.boxShadow||"none",transition:"box-shadow 0.2s ease-in-out"}}})),f){const C=U.find(I=>{const F=I.data;return(F==null?void 0:F.visualizerStepId)===f});C&&k(C.id)}else k(null)},[f,o,G.nodes,U]),!e||e.length===0?a.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."}):G.nodes.length===0&&e.length>0?a.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 dark:text-gray-400",children:"Generating flow chart..."}):a.jsxs("div",{style:{height:"100%",width:"100%"},className:"relative",children:[a.jsxs(vm,{nodes:r,edges:i.map(C=>({...C,markerEnd:{type:Sm.ArrowClosed,color:"#888"}})),onNodesChange:s,onEdgesChange:c,onEdgeClick:J,onNodeClick:A,onPaneClick:()=>{p(null),k(null),X()},onMoveStart:Y,nodeTypes:z1,edgeTypes:$1,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:[a.jsx(wm,{}),a.jsx(bm,{className:yh()}),a.jsx(ym,{position:"top-right",className:"flex items-center space-x-4",children:a.jsx("div",{ref:T})})]}),a.jsx(e0,{isOpen:y,onClose:X,anchorRef:T,offset:B1,placement:"right-start",className:"max-w-[500px] min-w-[400px] p-2",children:b&&a.jsx(F1,{step:b,variant:"popover"})})]})},H1=e=>a.jsx(mm,{children:a.jsx(U1,{...e})}),Pp=e=>{var t,n,r,o;if(e.events&&e.events.length>0){const s=e.events[0];if((o=(r=(n=(t=s.full_payload)==null?void 0:t.params)==null?void 0:n.message)==null?void 0:r.metadata)!=null&&o.parentTaskId)return s.full_payload.params.message.metadata.parentTaskId}},Pr=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},Lp=(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 s=[...o.events||[]];for(const i in t){const l=t[i];if(l.taskId===e)continue;Pp(l)===e&&(s=s.concat(Lp(l.taskId,t,n,r+1)))}return s},W1=(e,t,n)=>{if(!n)return null;const r={overall:{totalTaskDurationMs:0},agents:{}},o=new Map,s=new Map,i=(A,Y)=>(r.agents[A]||(r.agents[A]={agentName:Y,instanceId:A,displayName:Y,llmCalls:[],toolCalls:[],totalLlmTimeMs:0,totalToolTimeMs:0}),r.agents[A]),l=new Map,c=Lp(n.taskId,t,l,0);if(c.length===0)return{taskId:n.taskId,initialRequestText:n.initialRequestText,status:"working",startTime:n.firstSeen.toISOString(),steps:[]};const d=c.sort((A,Y)=>new Date(Pr(A)).getTime()-new Date(Pr(Y)).getTime()),f=[];let p,m="",h,x,g=[],v=null,b;const w=new Map,y=new Map,E=new Map,T=A=>{if(m.trim()&&h&&x){const Y=m.trim();let C=n.taskId;if(g.length>0){const R=g[0].split("-");R.length>2&&R[1]!=="global"&&(C=R.slice(1,R.length-1).join("-"))}else A&&(C=A);const I=l.get(C)??0,F=w.get(C)||E.get(C);f.push({id:`vstep-agenttext-${f.length}-${g[0]||"unknown"}`,type:"AGENT_RESPONSE_TEXT",timestamp:x,title:`${h}: Response`,source:h,target:"User",data:{text:Y},rawEventIds:[...g],isSubTaskStep:I>0,nestingLevel:I,owningTaskId:C,functionCallId:F}),v=Y}m="",h=void 0,x=void 0,g=[],b=void 0};d.forEach((A,Y)=>{var N,K,ee,te,le,ne,de,we,je,Re,Le,Me,We,Lt,qe,Dt,rt,At,ot,st,Ot,Qt,Wt,se,kt,pt,Nt,Qe,mt,yt,Ft,fn,St,zt,pn,_t,mn,hn,De,Ct,Ue,et,It,en,$t;const C=Pr(A),I=`raw-${A.task_id||"global"}-${Y}`,F=A.full_payload,R=A.task_id||n.taskId,Q=l.get(R)??0;let O=A.source_entity||"UnknownAgent";(ee=(K=(N=F==null?void 0:F.params)==null?void 0:N.message)==null?void 0:K.metadata)!=null&&ee.agent_name?O=F.params.message.metadata.agent_name:(le=(te=F==null?void 0:F.result)==null?void 0:te.metadata)!=null&&le.agent_name?O=F.result.metadata.agent_name:(je=(we=(de=(ne=F==null?void 0:F.result)==null?void 0:ne.status)==null?void 0:de.message)==null?void 0:we.metadata)!=null&&je.agent_name?O=F.result.status.message.metadata.agent_name:(Me=(Le=(Re=F==null?void 0:F.result)==null?void 0:Re.artifact)==null?void 0:Le.metadata)!=null&&Me.agent_name&&(O=F.result.artifact.metadata.agent_name);let W;if(Q>0?W=w.get(R):W=E.get(R),A.direction==="request"&&Q>0){const xe=(We=F.params)==null?void 0:We.metadata,Ce=xe==null?void 0:xe.function_call_id,Ie=A.task_id;if(Ie&&Ce){w.set(Ie,Ce);return}}if(A.direction==="request"&&Q===0&&A.task_id===n.taskId){T(R),v=null;const xe=F.params;let Ce="User request";if((Lt=xe==null?void 0:xe.message)!=null&&Lt.parts){const Ie=xe.message.parts.filter(Te=>Te.kind==="text"&&Te.text);Ie.length>0&&(Ce=Ie[Ie.length-1].text)}f.push({id:`vstep-userreq-${f.length}-${I}`,type:"USER_REQUEST",timestamp:C,title:"User Input",source:"User",target:A.target_entity||O,data:{text:Ce},rawEventIds:[I],isSubTaskStep:!1,nestingLevel:0,owningTaskId:R});return}if(A.direction==="status-update"&&(F!=null&&F.result)){const xe=F.result,Ce=(qe=xe.status)==null?void 0:qe.message,Ie=Ce==null?void 0:Ce.metadata;let Te;const tt=!!(Ie!=null&&Ie.forwarded_from_peer);tt?Te=Ie.forwarded_from_peer:(Dt=xe.metadata)!=null&&Dt.agent_name?Te=xe.metadata.agent_name:Ie!=null&&Ie.agent_name?Te=Ie.agent_name:Te=A.source_entity||"Agent";const Xe=`${Te}:${R}`;if(!tt&&(Ce!=null&&Ce.parts))for(const Ge of Ce.parts){if(Ge.kind==="data"){const $e=Ge.data;$e.type==="agent_progress_update"?p=$e.status_text:$e.type==="artifact_creation_progress"&&(p=`Saving artifact: ${$e.filename} (${$e.bytes_saved} bytes)`)}if(Ge.kind==="data"){T(R);const Be=Ge.data;switch(Be==null?void 0:Be.type){case"agent_progress_update":{f.push({id:`vstep-progress-${f.length}-${I}`,type:"AGENT_RESPONSE_TEXT",timestamp:C,title:`${Te}: Progress Update`,source:Te,target:"User",data:{text:Be.status_text},rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W});break}case"llm_invocation":{const M=Be.request;let $="System-initiated LLM call";if(M!=null&&M.contents&&Array.isArray(M.contents)&&M.contents.length>0){const P=[...M.contents].reverse().find(S=>S.role==="user");P&&P.parts&&($=P.parts.map(S=>S.text||"").join(`
338
- `).trim())}const V={modelName:(M==null?void 0:M.model)||"Unknown Model",promptPreview:$||"No text in user prompt."};i(Xe,Te),o.set(Xe,{timestamp:C,modelName:V.modelName}),f.push({id:`vstep-llmcall-${f.length}-${I}`,type:"AGENT_LLM_CALL",timestamp:C,title:`${Te}: LLM Call`,source:Te,target:"LLM",data:{llmCall:V},rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W});break}case"llm_response":{const M=o.get(Xe);if(M){const S=new Date(C).getTime()-new Date(M.timestamp).getTime();i(Xe,Te).llmCalls.push({modelName:M.modelName,durationMs:S,timestamp:M.timestamp}),o.delete(Xe)}const $=Be.data,V=(rt=$.content)==null?void 0:rt.parts,P=V==null?void 0:V.filter(S=>S.function_call);if(P&&P.length>0){T(R),v=null,E.delete(R);const S=P.map(ce=>{var ke;return{functionCallId:ce.function_call.id,toolName:ce.function_call.name,toolArguments:ce.function_call.args||{},isPeerDelegation:(ke=ce.function_call.name)==null?void 0:ke.startsWith("peer_")}}),L={decisions:S,isParallel:S.length>1},H=[],ie=new Set;S.forEach(ce=>{if(ce.isPeerDelegation){const ke=ce.toolName.substring(5);for(const pe in t){const ae=t[pe];if(ie.has(ae.taskId))continue;if(Pp(ae)===R&&ae.events&&ae.events.length>0){const He=ae.events.find(Fe=>{var be,ye,it,ha;return Fe.direction==="request"&&((ha=(it=(ye=(be=Fe.full_payload)==null?void 0:be.params)==null?void 0:ye.message)==null?void 0:it.metadata)==null?void 0:ha.function_call_id)===ce.functionCallId});if(He&&new Date(Pr(He)).getTime()>=new Date(C).getTime()){const Fe={functionCallId:ce.functionCallId,peerAgentName:ke,subTaskId:ae.taskId};H.push(Fe),y.set(ce.functionCallId,Fe),ae.taskId&&(w.set(ae.taskId,ce.functionCallId),ie.add(ae.taskId));break}}}}});const ge={id:`vstep-tooldecision-${f.length}-${I}`,type:"AGENT_LLM_RESPONSE_TOOL_DECISION",timestamp:C,title:`LLM: Tool Decision${L.isParallel?" (Parallel)":""}`,source:"LLM",target:Te,data:{toolDecision:L},rawEventIds:[I],delegationInfo:H.length>0?H:void 0,isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W};f.push(ge);const fe=L.isParallel?ge.id:void 0,Ae=Xe;i(Ae,Te),S.forEach(ce=>{var pe;const ke=ce.isPeerDelegation?(pe=y.get(ce.functionCallId))==null?void 0:pe.subTaskId:void 0;s.has(ce.functionCallId)||s.set(ce.functionCallId,{timestamp:C,toolName:ce.toolName,isPeer:ce.isPeerDelegation,invokingAgentInstanceId:Ae,subTaskId:ke,parallelBlockId:fe})})}else{const S=(V==null?void 0:V.filter(H=>H.text).map(H=>H.text).join(`
339
- `))||"",L={responsePreview:S.substring(0,200)+(S.length>200?"...":""),isFinalResponse:($==null?void 0:$.partial)===!1};f.push({id:`vstep-llmrespagent-${f.length}-${I}`,type:"AGENT_LLM_RESPONSE_TO_AGENT",timestamp:C,title:`${Te}: LLM Response`,source:"LLM",target:Te,data:{llmResponseToAgent:L},rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W})}break}case"tool_invocation_start":{const M={functionCallId:Be.function_call_id,toolName:Be.tool_name,toolArguments:Be.tool_args,isPeerInvocation:(At=Be.tool_name)==null?void 0:At.startsWith("peer_")};f.push({id:`vstep-toolinvokestart-${f.length}-${I}`,type:"AGENT_TOOL_INVOCATION_START",timestamp:C,title:`${Te}: Executing tool ${M.toolName}`,source:Te,target:M.toolName,data:{toolInvocationStart:M},rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W});break}case"tool_result":{const M=Be.function_call_id,$=s.get(M);if($){const P=new Date(C).getTime()-new Date($.timestamp).getTime(),S=r.agents[$.invokingAgentInstanceId];if(S){const L={toolName:$.toolName,durationMs:P,isPeer:$.isPeer,timestamp:$.timestamp,peerAgentName:$.isPeer?$.toolName.substring(5):void 0,subTaskId:$.subTaskId,parallelBlockId:$.parallelBlockId};S.toolCalls.push(L)}s.delete(M)}const V={toolName:Be.tool_name,functionCallId:M,resultData:Be.result_data,isPeerResponse:(ot=Be.tool_name)==null?void 0:ot.startsWith("peer_")};f.push({id:`vstep-toolresult-${f.length}-${I}`,type:"AGENT_TOOL_EXECUTION_RESULT",timestamp:C,title:`${Te}: Tool Result - ${V.toolName}`,source:V.toolName,target:Te,data:{toolResult:V},rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W});break}}}else Ge.kind==="text"&&Ge.text&&(h&&h!==Te&&(T(R),v=null),h||(h=Te,x=C,b=tt),m+=Ge.text,g.push(I))}return}if(A.direction==="artifact_update"&&((st=F==null?void 0:F.result)!=null&&st.artifact)){T(R);const xe=F.result.artifact,Ce=((Ot=xe.metadata)==null?void 0:Ot.agent_name)||A.source_entity||"Agent";let Ie;if(xe.parts&&xe.parts.length>0){const tt=xe.parts[0];tt.kind==="file"?Ie=tt.file.mimeType||void 0:(Qt=tt.metadata)!=null&&Qt.mime_type&&(Ie=tt.metadata.mime_type)}const Te={artifactName:xe.name||"Unnamed Artifact",version:typeof((Wt=xe.metadata)==null?void 0:Wt.version)=="number"?xe.metadata.version:void 0,description:xe.description||void 0,mimeType:Ie};f.push({id:`vstep-artifactnotify-${f.length}-${I}`,type:"AGENT_ARTIFACT_NOTIFICATION",timestamp:C,title:`${Ce}: Artifact Update - ${Te.artifactName}`,source:Ce,target:"User/System",data:{artifactNotification:Te},rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W});return}if(["response","task"].includes(A.direction)&&((kt=(se=F==null?void 0:F.result)==null?void 0:se.status)!=null&&kt.state)){m.trim()&&T(R);const xe=F.result,Ce=xe.status.state,Ie=((pt=xe.metadata)==null?void 0:pt.agent_name)||((mt=(Qe=(Nt=xe.status)==null?void 0:Nt.message)==null?void 0:Qe.metadata)==null?void 0:mt.agent_name)||A.source_entity||"Agent";if(["completed","failed","canceled"].includes(Ce)&&Q==0){const Te=Ce==="completed"?"TASK_COMPLETED":"TASK_FAILED",tt=`${Ie}: Task ${Ce.charAt(0).toUpperCase()+Ce.slice(1)}`;let Xe={},Ge="";if((yt=xe.status.message)!=null&&yt.parts){const Et=xe.status.message.parts.find(M=>M.kind==="text");Et!=null&&Et.text&&(Ge=Et.text.trim())}const $e=R===n.taskId,Be=Ge&&(!$e||Ge!==v);if(Te==="TASK_COMPLETED")Xe={finalMessage:Be?Ge:void 0};else{const M={message:Be?Ge:`Task ${Ce}.`},$=F.error;$&&(M.message=$.message||M.message,M.code=$.code,$.data&&(M.details=$.data)),xe.error&&(M.message=xe.error.message||M.message,M.code=xe.error.code||M.code,M.details=xe.error.data||M.details),Xe={errorDetails:M}}f.push({id:`vstep-${Ce}-${f.length}-${I}`,type:Te,timestamp:C,title:tt,source:Ie,target:"User",data:Xe,rawEventIds:[I],isSubTaskStep:Q>0,nestingLevel:Q,owningTaskId:R,functionCallId:W}),$e&&(v=null);return}}const z=A.direction==="status-update"&&((zt=(St=(fn=(Ft=F==null?void 0:F.result)==null?void 0:Ft.status)==null?void 0:fn.message)==null?void 0:St.parts)==null?void 0:zt.some(xe=>xe.kind==="text"));let q=A.source_entity;(hn=(mn=(_t=(pn=F==null?void 0:F.result)==null?void 0:pn.status)==null?void 0:_t.message)==null?void 0:mn.metadata)!=null&&hn.forwarded_from_peer?q=F.result.status.message.metadata.forwarded_from_peer:(Ct=(De=F==null?void 0:F.result)==null?void 0:De.metadata)!=null&&Ct.agent_name?q=F.result.metadata.agent_name:(en=(It=(et=(Ue=F==null?void 0:F.result)==null?void 0:Ue.status)==null?void 0:et.message)==null?void 0:It.metadata)!=null&&en.agent_name&&(q=F.result.status.message.metadata.agent_name),m.trim()&&h&&(!z||z&&q!==h)&&(T(R),l.get((($t=g[0])==null?void 0:$t.split("-")[1])||n.taskId)===0&&!b&&(v=null))});const j=d.length>0&&d[d.length-1].task_id||n.taskId;T(j);const k=d[0]?Pr(d[0]):n.firstSeen.toISOString();let _,G="working";const U=f.filter(A=>A.owningTaskId===n.taskId),B=U.length>0?U[U.length-1]:null;if(B&&(B.type==="TASK_COMPLETED"?(G="completed",_=B.timestamp):B.type==="TASK_FAILED"&&(G="failed",_=B.timestamp)),G==="working"&&d.length>0){const A=d[d.length-1];t[A.task_id||n.taskId]}let Z;k&&_&&(Z=new Date(_).getTime()-new Date(k).getTime()),["completed","failed","canceled","rejected"].includes(G)&&(p=void 0);const J={taskId:n.taskId,initialRequestText:n.initialRequestText,status:G,currentStatusText:p,startTime:k,endTime:_,durationMs:Z,steps:f};J.steps.forEach((A,Y)=>{if(A.type==="TASK_COMPLETED"){let C="";for(let I=Y-1;I>=0;I--){const F=J.steps[I];if(F.type!=="AGENT_RESPONSE_TEXT"||F.source!==A.source)break;C=F.data.text+C}A.data.finalMessage&&(C+=A.data.finalMessage),A.data.finalMessage=C.trim()||void 0}}),Object.values(r.agents).forEach(A=>{A.totalLlmTimeMs=A.llmCalls.reduce((R,Q)=>R+Q.durationMs,0);const Y=A.toolCalls.filter(R=>!R.parallelBlockId),C=new Map;A.toolCalls.forEach(R=>{R.parallelBlockId&&(C.has(R.parallelBlockId)||C.set(R.parallelBlockId,[]),C.get(R.parallelBlockId).push(R))});const I=Y.reduce((R,Q)=>R+Q.durationMs,0);let F=0;C.forEach(R=>{if(R.length>0){const Q=Math.min(...R.map(W=>new Date(W.timestamp).getTime())),O=Math.max(...R.map(W=>new Date(W.timestamp).getTime()+W.durationMs));F+=O-Q}}),A.totalToolTimeMs=I+F});const D=new Map;Object.values(r.agents).forEach(A=>{D.has(A.agentName)||D.set(A.agentName,[]),D.get(A.agentName).push(A)}),D.forEach(A=>{A.length>1&&(A.sort((Y,C)=>{const I=F=>{const R=[...F.llmCalls.map(Q=>new Date(Q.timestamp).getTime()),...F.toolCalls.map(Q=>new Date(Q.timestamp).getTime())];return R.length>0?Math.min(...R):1/0};return I(Y)-I(C)}),A.forEach((Y,C)=>{Y.displayName=`${Y.agentName} (${C+1})`}))});const X=new Map;return Object.values(r.agents).forEach(A=>{const Y=A.instanceId.split(":").slice(1).join(":");Y&&X.set(Y,A.displayName)}),Object.values(r.agents).forEach(A=>{A.toolCalls.forEach(Y=>{if(Y.isPeer&&Y.subTaskId){const C=X.get(Y.subTaskId);C&&(Y.peerAgentName=C)}})}),Z!==void 0&&(r.overall.totalTaskDurationMs=Z),J.performanceReport=r,J},G1=({items:e,bottomItems:t,activeItem:n,onItemChange:r,onHeaderClick:o})=>{const s=i=>{r(i)};return a.jsxs("aside",{className:"flex h-screen w-[100px] flex-col border-r border-[var(--color-secondary-w70)] bg-[var(--color-primary-w100)]",children:[a.jsx(Y1,{onClick:o}),a.jsx(q1,{items:e,bottomItems:t,activeItem:n,onItemClick:s})]})},V1=a.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:[a.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"}),a.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"}),a.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"}),a.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"}),a.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"}),a.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"}),a.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"})]}),Y1=({onClick:e})=>a.jsx("div",{className:"flex h-[80px] min-h-[80px] cursor-pointer items-center justify-center border-b",onClick:e,children:a.jsx("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full",children:V1})}),K1=()=>{const{currentTheme:e,toggleTheme:t}=ld(),n=`Toggle theme (currently ${e})`;return a.jsxs(Hi,{children:[a.jsx(Wi,{asChild:!0,children:a.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:a.jsx(lc,{className:"mb-1 h-6 w-6"})})}),a.jsx(Gi,{side:"right",children:n})]})},q1=({items:e,bottomItems:t,activeItem:n,onItemClick:r})=>a.jsxs("nav",{className:"flex flex-1 flex-col",role:"navigation","aria-label":"Main navigation",children:[a.jsx("ul",{className:"space-y-1",children:e.map(o=>a.jsxs("li",{children:[a.jsx(Bl,{item:o,isActive:n===o.id,onItemClick:r}),o.showDividerAfter&&a.jsx("div",{className:"mx-4 my-3 border-t border-[var(--color-secondary-w70)]"})]},o.id))}),t&&t.length>0&&a.jsx("div",{className:"flex-1"}),t&&t.length>0&&a.jsx("ul",{className:"space-y-1",children:t.map(o=>a.jsx("li",{className:"my-4",children:o.id==="theme-toggle"?a.jsx(K1,{}):a.jsx(Bl,{item:o,isActive:n===o.id,onItemClick:r},o.id)},o.id))})]}),Bl=({item:e,isActive:t,onItemClick:n})=>{const{id:r,label:o,icon:s,disabled:i}=e,l=()=>{!i&&n&&n(r)},c=d=>{(d.key==="Enter"||d.key===" ")&&l()};return a.jsxs(Hi,{children:[a.jsx(Wi,{asChild:!0,children:a.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:[a.jsx(s,{className:ve("mb-1 h-6 w-6",t&&"text-[var(--color-brand-wMain)]")}),a.jsx("span",{className:"text-center text-[13px] leading-tight",children:o})]})}),a.jsx(Gi,{side:"right",children:o})]})},Ul=[{id:"chat",label:"Chat",icon:tc},{id:"agentMesh",label:"Agents",icon:cc}],Hl=[{id:"theme-toggle",label:"Theme",icon:lc,onClick:()=>{}}],Dp=({title:e,breadcrumbs:t,tabs:n,buttons:r,leadingAction:o})=>a.jsxs("div",{className:"relative flex max-h-[80px] min-h-[80px] w-full items-center border-b px-8",children:[t&&t.length>0&&a.jsx("div",{className:"absolute top-1 left-8 flex h-8 items-center",children:t.map((s,i)=>a.jsxs(Yt.Fragment,{children:[i>0&&a.jsx("span",{className:"mx-1",children:a.jsx(Cm,{size:16})}),s.onClick?a.jsx(me,{variant:"link",className:"m-0 p-0",onClick:s.onClick,children:s.label}):a.jsx("div",{children:s.label})]},i))}),o&&a.jsx("div",{className:"mr-4 flex items-center pt-[35px]",children:o}),a.jsx("div",{className:"truncate pt-[35px] text-xl text-nowrap",children:e}),n&&n.length>0&&a.jsx("div",{className:"ml-8 flex items-center pt-[35px]",role:"tablist",children:n.map((s,i)=>a.jsxs("button",{role:"tab","aria-selected":s.isActive,onClick:s.onClick,className:`relative cursor-pointer px-4 py-3 font-medium transition-colors duration-200 ${s.isActive?"border-b-2 border-[var(--color-brand-wMain)] font-semibold":""} ${i>0?"ml-6":""}`,children:[s.label,s.isActive&&a.jsx("div",{className:"absolute right-0 bottom-0 left-0 h-0.5"})]},s.id))}),a.jsx("div",{className:"flex-1"}),r&&r.length>0&&a.jsx("div",{className:"flex items-center gap-2 pt-[35px]",children:r.map((s,i)=>a.jsx(Yt.Fragment,{children:s},i))})]}),gt=({label:e,value:t,icon:n,fullWidthValue:r=!1})=>t==null||typeof t=="string"&&!t.trim()?null:a.jsxs("div",{className:`mb-1.5 flex text-sm ${r?"flex-col items-start":"items-center"}`,children:[a.jsxs("div",{className:"flex w-36 flex-shrink-0 items-center text-sm font-semibold text-nowrap",children:[n&&a.jsx("span",{className:"mr-2",children:n}),e,":"]}),a.jsx("div",{className:`text-accent-foreground text-sm ${r?"mt-1 w-full":"truncate"}`,title:typeof t=="string"?t:void 0,children:t})]}),X1=({agent:e,isExpanded:t,onToggleExpand:n})=>{const r=l=>!l||Object.keys(l).length===0?a.jsx("span",{className:"text-sm",children:"N/A"}):a.jsx("ul",{className:"list-inside list-disc pl-1",children:Object.entries(l).map(([c,d])=>a.jsxs("li",{className:"text-sm",children:[a.jsxs("span",{className:"capitalize",children:[c.replace(/_/g," "),":"]})," ",d?"Yes":"No"]},c))}),o=(l,c="None")=>!l||l.length===0?a.jsx("span",{children:c}):l.map(d=>a.jsx("span",{className:"mr-1 mb-1 inline-block rounded-full px-2 py-0.5 text-xs font-medium",children:d},d)),s=l=>!l||l.length===0?a.jsx("span",{children:"No skills listed"}):a.jsx("div",{className:"space-y-1",children:l.map(c=>a.jsxs("div",{className:"rounded p-1.5 text-xs",children:[a.jsx("p",{className:"font-semibold",children:c.name}),a.jsx("p",{children:c.description})]},c.id||c.name))}),i=l=>!l||l.length===0?a.jsx("span",{children:"No tools listed"}):a.jsx("div",{className:"space-y-1",children:l.map(c=>a.jsxs("div",{className:"rounded p-1.5 text-xs",children:[a.jsx("p",{className:"text-foreground font-semibold",children:c.name}),a.jsx("p",{className:"mb-1",children:c.description})]},c.name))});return a.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:a.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:[a.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:[a.jsx("div",{className:"flex items-center p-4",children:a.jsxs("div",{className:"flex min-w-0 items-center",children:[a.jsx(cc,{className:"mr-3 h-8 w-8 flex-shrink-0 text-[var(--color-brand-wMain)]"}),a.jsx("div",{className:"min-w-0",children:a.jsx("h2",{className:"truncate text-xl font-semibold",title:e.name,children:e.displayName||e.name})})]})}),a.jsxs("div",{className:"scrollbar-themed flex-grow space-y-3 overflow-y-auto p-4",children:[a.jsx("div",{className:"mb-2 line-clamp-4 text-base",children:e.description||"No description provided."}),a.jsx(gt,{label:"Version",value:e.version,icon:a.jsx(ya,{size:14})}),e.capabilities&&Object.keys(e.capabilities).length>0&&a.jsx(gt,{label:"Key Capabilities",value:r(e.capabilities),icon:a.jsx(Sa,{size:14}),fullWidthValue:!0})]}),a.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for details"})]}),a.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:[a.jsx("div",{className:"flex items-center p-3",children:a.jsxs("h3",{className:"text-md truncate font-semibold",title:e.name,children:["Details: ",e.displayName||e.name]})}),a.jsxs("div",{className:"scrollbar-themed flex-grow space-y-1.5 overflow-y-auto p-3 text-xs",children:[a.jsx(gt,{label:"Name",value:e.name,icon:a.jsx(ki,{size:14})}),a.jsx(gt,{label:"Description",value:e.description,icon:a.jsx(Em,{size:14}),fullWidthValue:!0}),a.jsx(gt,{label:"Version",value:e.version,icon:a.jsx(ya,{size:14})}),a.jsx(gt,{label:"Endpoint",value:e.url||"N/A",icon:a.jsx(ac,{size:14})}),a.jsx(gt,{label:"Docs",value:e.documentationUrl?a.jsx("a",{href:e.documentationUrl,target:"_blank",rel:"noopener noreferrer",className:"break-all",children:"View Docs"}):"N/A",icon:a.jsx(Jl,{size:14})}),e.provider&&a.jsxs("div",{className:"mt-1.5 border-t pt-1.5",children:[a.jsx("h4",{className:"mb-0.5 text-xs font-semibold",children:"Provider"}),a.jsx(gt,{label:"Name",value:e.provider.organization}),a.jsx(gt,{label:"URL",value:e.provider.url||"N/A"})]}),a.jsx(gt,{label:"Capabilities",value:r(e.capabilities),icon:a.jsx(Sa,{size:14}),fullWidthValue:!0}),a.jsx(gt,{label:"Input Modes",value:o(e.defaultInputModes),icon:a.jsx(Ca,{size:14}),fullWidthValue:!0}),a.jsx(gt,{label:"Output Modes",value:o(e.defaultOutputModes),icon:a.jsx(Ca,{size:14}),fullWidthValue:!0}),a.jsx(gt,{label:"Skills",value:s(e.skills),icon:a.jsx(Tm,{size:14}),fullWidthValue:!0}),a.jsx(gt,{label:"Tools Info",value:i(e.tools),icon:a.jsx(ec,{size:14}),fullWidthValue:!0}),a.jsx("div",{className:"text-2xs mt-1.5 pt-1.5",children:a.jsx(gt,{label:"A2A Protocol",value:e.protocolVersion})})]}),a.jsx("div",{className:"text-accent-foreground border-t p-2 text-center text-sm",children:"Click for summary"})]})]})})},bi=({agents:e})=>{const[t,n]=u.useState(null),[r,o]=u.useState(""),s=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 a.jsx("div",{children:e.length===0?a.jsx("div",{className:"flex h-[calc(100vh-250px)] items-center justify-center",children:"No agents discovered in the current namespace."}):a.jsxs("div",{className:"mx-auto mt-[50px] ml-[50px]",children:[a.jsx("div",{className:"my-4",children:a.jsx("input",{type:"text","data-testid":"agent-search-input",placeholder:"Search...",value:r,onChange:l=>o(l.target.value),className:"bg-background rounded-md border px-3 py-2"})}),i.length===0&&r?a.jsxs("div",{className:"flex h-[calc(100vh-250px)] flex-col items-center justify-center gap-6",children:["No agents match your search.",a.jsx(me,{variant:"outline",title:"Clear Search",onClick:()=>o(""),children:"Clear Search"})]}):a.jsx("div",{className:"max-h-[calc(100vh-250px)] overflow-y-auto",children:a.jsx("div",{className:"flex flex-wrap gap-10",children:i.map(l=>a.jsx(X1,{agent:l,isExpanded:t===l.name,onToggleExpand:()=>s(l.name)},l.name))})})]})})},Op={LAYOUT:"layout"};class Z1{constructor(){ga(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:Op.LAYOUT,id:"cards",label:"Cards",icon:Am,priority:100,render:t=>a.jsx(bi,{agents:t.agents||[]})})}renderPlugin(t,n){const r=this.getPluginById(t);if(r)return r.render(n)}}const Fp=new Z1,J1=({currentLayout:e,onLayoutChange:t,className:n=""})=>{const r=Fp.getPluginsByType(Op.LAYOUT);return r&&r.length>1?a.jsxs("div",{className:`flex items-center space-x-1 ${n}`,children:[a.jsx("span",{className:"text-sm font-semibold",children:"Layout:"}),a.jsx("div",{className:"flex gap-1 rounded-sm p-1",children:r.map(o=>{const s=o.icon,i=e===o.id;return a.jsxs(me,{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:[s&&a.jsx(s,{size:14}),a.jsx("span",{children:o.label})]},o.id)})})]}):null},Wl={CARDS:"cards"};function Q1(){const{agents:e,agentsLoading:t,agentsError:n,agentsRefetch:r}=Ye(),[o,s]=u.useState("cards");if(t)return a.jsx("div",{className:"space-y-6",children:a.jsx("div",{className:"flex h-96 items-center justify-center",children:a.jsx("div",{children:"Loading agents..."})})});if(n)return a.jsx("div",{className:"space-y-6",children:a.jsx("div",{className:"flex h-96 items-center justify-center",children:a.jsx(pa,{variant:"error",message:`Error loading agents. ${n}`})})});const i=()=>{if(o===Wl.CARDS)return a.jsx(bi,{agents:e});const l=Fp.getPluginById(o);return l?l.render({agents:e}):(console.warn(`Layout ${o} not found, falling back to cards layout`),a.jsx(bi,{agents:e}))};return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsx(Dp,{title:"Agents",buttons:[a.jsxs(me,{variant:"ghost",title:"Refresh Agents",onClick:()=>r(),children:[a.jsx(oc,{className:"size-4"}),"Refresh Agents"]})]}),a.jsxs("div",{className:`relative flex-1 p-4 ${o===Wl.CARDS?"":"bg-[var(--muted)] dark:bg-[var(--color-bg-wMain)]"}`,children:[a.jsx("div",{className:"absolute right-8 z-20 flex items-center space-x-4",children:a.jsx(J1,{currentLayout:o,onLayoutChange:s})}),i()]})]})}const eE=({isOpen:e,onClose:t,onConfirm:n,sessionName:r})=>e?a.jsx(Qr,{open:e,onOpenChange:t,children:a.jsxs(eo,{children:[a.jsxs(to,{children:[a.jsx(no,{children:"Delete Chat Session?"}),a.jsxs(ro,{children:["This action cannot be undone. This chat session and any associated artifacts will be permanently deleted: ",a.jsx("strong",{children:r})]})]}),a.jsxs(ju,{children:[a.jsx(me,{variant:"outline",onClick:t,title:"Cancel",children:"Cancel"}),a.jsx(me,{onClick:n,title:"Delete",children:"Delete"})]})]})}):null,So=4,yi={chatPanelSizes:{default:50,min:30,max:96},sidePanelSizes:{default:50,min:20,max:70}},tE={chatPanelSizes:{...yi.chatPanelSizes,min:50},sidePanelSizes:{...yi.sidePanelSizes,max:50}};function nE(){var W;const{agents:e,sessionId:t,messages:n,setMessages:r,selectedAgentName:o,setSelectedAgentName:s,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,openSidePanelTab:c,setTaskIdInSidePanel:d,isResponding:f,latestStatusText:p,sessionToDelete:m,closeSessionDeleteModal:h,confirmSessionDelete:x,sessionName:g}=Ye(),{isTaskMonitorConnected:v,isTaskMonitorConnecting:b,taskMonitorSseError:w,connectTaskMonitorStream:y}=ta(),[E,T]=u.useState(!0),[j,k]=u.useState(!1),[_,G]=u.useState(!1),U=u.useRef(null),B=u.useRef(null),Z=u.useRef(null),{chatPanelSizes:J,sidePanelSizes:D}=u.useMemo(()=>E?yi:tE,[E]),X=u.useCallback(z=>{if(k(!0),B.current)if(z)B.current.resize(So);else{const q=Z.current||D.default;B.current.resize(q)}setTimeout(()=>k(!1),300)},[D.default]),A=u.useCallback(()=>{l(!0)},[l]),Y=u.useCallback(()=>{l(!1)},[l]),C=u.useCallback(z=>{z>So+1&&(Z.current=z)},[]),I=u.useCallback(()=>{T(!E)},[E]);u.useEffect(()=>{B.current&&i&&B.current.resize(So);const z=()=>{if(B.current&&i){k(!0);const q=Z.current||D.default;B.current.resize(q),l(!1),setTimeout(()=>k(!1),300)}};return window.addEventListener("expand-side-panel",z),()=>{window.removeEventListener("expand-side-panel",z)}},[i,l,D.default]),u.useEffect(()=>{if(!o&&e.length>0){const z=e.find(ee=>ee.name==="OrchestratorAgent"),q=z?z.name:e[0].name;s(q);const N=e.find(ee=>ee.name===q),K=N!=null&&N.displayName?`Hi! I'm the ${N==null?void 0:N.displayName}. How can I help?`:`Hi! I'm ${q}. How can I help?`;r(ee=>[...ee.filter(le=>!le.isStatusBubble),{role:"agent",kind:"message",messageId:`welcome-${Date.now()}`,parts:[{kind:"text",text:K}],isUser:!1,isComplete:!0,metadata:{sessionId:t,lastProcessedEventSequence:0}}])}},[e,o,t,r,s]);const F=u.useMemo(()=>{const z=new Map;return n.forEach((q,N)=>{q.taskId&&z.set(q.taskId,N)}),z},[n]),R=u.useMemo(()=>n.find(z=>z.isStatusBubble),[n]),Q=u.useMemo(()=>{if(!R||!R.parts)return null;const z=R.parts.find(q=>q.kind==="text");return(z==null?void 0:z.text)||null},[R]),O=u.useMemo(()=>{if(R!=null&&R.taskId)return()=>{d(R.taskId),c("workflow")}},[R==null?void 0:R.taskId,d,c]);return u.useEffect(()=>{const z=()=>{!v&&!b&&w&&(console.log("ChatPage: Window focused while disconnected, attempting reconnection..."),y())};return window.addEventListener("focus",z),()=>{window.removeEventListener("focus",z)}},[v,b,w,y]),a.jsxs("div",{className:"relative flex h-screen w-full flex-col overflow-hidden",children:[a.jsx("div",{className:`absolute top-0 left-0 z-20 h-screen transition-transform duration-300 ${E?"-translate-x-full":"translate-x-0"}`,children:a.jsx(u1,{onToggle:I})}),a.jsx("div",{className:`transition-all duration-300 ${E?"ml-0":"ml-100"}`,children:a.jsx(Dp,{title:g||"New Chat",leadingAction:E?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(me,{variant:"ghost",onClick:I,className:"h-10 w-10 p-0",tooltip:"Show Sessions Panel",children:a.jsx(sc,{className:"size-5"})}),a.jsx("div",{className:"h-6 w-px bg-gray-300 dark:bg-gray-600"}),a.jsx(me,{variant:"ghost",onClick:()=>G(!0),className:"h-10 w-10 p-0",tooltip:"Start New Chat Session",children:a.jsx(ic,{className:"size-5"})})]}):null})}),a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsx("div",{className:`min-h-0 flex-1 overflow-x-auto transition-all duration-300 ${E?"ml-0":"ml-100"}`,children:a.jsxs(vw,{direction:"horizontal",autoSaveId:"chat-side-panel",className:"h-full",children:[a.jsx(ul,{defaultSize:J.default,minSize:J.min,maxSize:J.max,id:"chat-panel",children:a.jsxs("div",{className:"flex h-full w-full flex-col py-6",children:[a.jsx(yf,{className:"text-base",ref:U,children:n.map((z,q)=>{var K;const N=!!(z.taskId&&F.get(z.taskId)===q);return a.jsx(BC,{message:z,isLastWithTaskId:N},`${((K=z.metadata)==null?void 0:K.sessionId)||"session"}-${q}-${z.isUser?"received":"sent"}`)})}),a.jsxs("div",{style:bf,children:[f&&a.jsx(xi,{statusText:(Q||p.current)??void 0,onViewWorkflow:O}),a.jsx(wb,{agents:e,scrollToBottom:(W=U.current)==null?void 0:W.scrollToBottom})]})]})}),a.jsx(ww,{}),a.jsx(ul,{ref:B,defaultSize:D.default,minSize:D.min,maxSize:D.max,collapsedSize:So,collapsible:!0,onCollapse:A,onExpand:Y,onResize:C,id:"chat-side-panel",className:j?"transition-all duration-300 ease-in-out":"",children:a.jsx("div",{className:"h-full",children:a.jsx(c1,{onCollapsedToggle:X,isSidePanelCollapsed:i,setIsSidePanelCollapsed:l,isSidePanelTransitioning:j})})})]})})}),a.jsx(kp,{isOpen:_,onClose:()=>G(!1)}),a.jsx(eE,{isOpen:!!m,onClose:h,onConfirm:x,sessionName:(m==null?void 0:m.name)||`Session ${m==null?void 0:m.id.substring(0,8)}`})]})}const rE=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)"}}),Si=({data:e,maxDepth:t=2,className:n=""})=>{const{currentTheme:r}=ld(),o=u.useMemo(()=>rE(r==="dark"),[r]),s=u.useMemo(()=>t===void 0||t<0?!1:t,[t]),i=u.useMemo(()=>e===null||typeof e!="object"?{value:e}:e,[e]),l=`rounded-lg border overflow-auto ${n}`.trim();return e===void 0?a.jsx("div",{className:l,children:a.jsx("span",{className:"italic",children:"No JSON data"})}):a.jsx("div",{className:l,children:a.jsx(km,{data:i,theme:o,viewOnly:!0,collapse:s,showStringQuotes:!0,showCollectionCount:"when-closed"})})};let Co=null,Eo=null;function oE({children:e}){const{fetchCsrfToken:t}=id(),[n,r]=u.useState(Co),[o,s]=u.useState(!Co&&!Eo),[i,l]=u.useState(Eo);return u.useEffect(()=>{if(Co||Eo)return;let c=!0;return(async()=>{s(!0),l(null);try{let f=await Pe("/api/v1/config",{credentials:"include",headers:{Accept:"application/json"}}),p;if(f.ok)p=await f.json();else{const x=await f.text();if(console.error("Initial config fetch failed:",f.status,x),f.status===403){console.log("Config fetch failed with 403, attempting to get CSRF token first...");const g=await t();if(!g)throw new Error("Failed to obtain CSRF token after config fetch failed.");if(console.log("Retrying config fetch with CSRF token..."),f=await Pe("/api/v1/config",{credentials:"include",headers:{"X-CSRF-TOKEN":g,Accept:"application/json"}}),!f.ok){const v=await f.text();throw console.error("Config fetch retry failed:",f.status,v),new Error(`Failed to fetch config on retry: ${f.status} ${v}`)}p=await f.json()}else throw new Error(`Failed to fetch config: ${f.status} ${x}`)}const m=p.frontend_use_authorization??!1;m&&(console.log("Fetching CSRF token for config-related requests..."),await t());const h={configServerUrl:p.frontend_server_url,configAuthLoginUrl:p.frontend_auth_login_url,configUseAuthorization:m,configWelcomeMessage:p.frontend_welcome_message,configRedirectUrl:p.frontend_redirect_url,configCollectFeedback:p.frontend_collect_feedback,configBotName:p.frontend_bot_name,configFeatureEnablement:p.frontend_feature_enablement??{},frontend_use_authorization:p.frontend_use_authorization,persistenceEnabled:p.persistence_enabled??!0};c&&(Co=h,r(h)),console.log("App config processed and set:",h)}catch(f){if(console.error("Error initializing app:",f),c){const p=f.message||"Failed to load application configuration.";Eo=p,l(p)}}finally{c&&s(!1)}})(),()=>{c=!1}},[t]),n?a.jsx(td.Provider,{value:n,children:e}):o?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Loading Configuration..."})]})}):i?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-red-100 dark:bg-red-900",children:a.jsxs("div",{className:"rounded border border-red-400 bg-white p-4 text-center dark:bg-gray-800",children:[a.jsx("h1",{className:"text-xl font-bold text-red-700 dark:text-red-300",children:"Configuration Error"}),a.jsx("p",{className:"mt-2 text-red-600 dark:text-red-200",children:i}),a.jsx("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:"Please check the backend server and network connection, then refresh the page."})]})}):a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl",children:"Initializing Application..."})]})})}const sE=({children:e})=>{const{configServerUrl:t}=Jt(),n=`${t}/api/v1`,[r,o]=u.useState(null),[s,i]=u.useState(!1),[l,c]=u.useState(!1),[d,f]=u.useState(null),[p,m]=u.useState({}),[h,x]=u.useState([]),[g,v]=u.useState(null),[b,w]=u.useState(0),[y,E]=u.useState(!1),T=10,j=u.useRef(null),k=u.useRef(null),_=u.useRef(null);u.useEffect(()=>{k.current=r},[r]);const G=u.useCallback(C=>{m(I=>{var O,W,z;const F=C.task_id;if(!F)return C.direction==="discovery"||console.warn("TaskMonitorContext: Received event without task_id, skipping:",C),I;const R=I[F],Q=new Date(C.timestamp);if(R){const q=[...R.events,C].sort((N,K)=>new Date(N.timestamp).getTime()-new Date(K.timestamp).getTime());return{...I,[F]:{...R,events:q,lastUpdated:Q}}}else{let q="Task started...";if(C.direction==="request"&&((W=(O=C.full_payload)==null?void 0:O.method)!=null&&W.startsWith("message/"))){const K=C.full_payload.params;if((z=K==null?void 0:K.message)!=null&&z.parts){const ee=K.message.parts.filter(te=>te.kind==="text"&&te.text);ee.length>0&&(q=ee[ee.length-1].text)}}const N={taskId:F,initialRequestText:q,events:[C],firstSeen:Q,lastUpdated:Q};return x(K=>[F,...K.filter(ee=>ee!==F)]),{...I,[F]:N}}})},[]),U=u.useCallback(()=>{console.log("TaskMonitorContext: SSE connection opened."),i(!1),c(!0),f(null),w(0),E(!1),_.current&&(clearTimeout(_.current),_.current=null)},[]),B=u.useCallback(C=>{try{const I=JSON.parse(C.data);G(I)}catch(I){console.error("TaskMonitorContext: Failed to parse SSE 'a2a_message' event data:",I,"Raw data:",C.data),f("Received unparseable 'a2a_message' event from server.")}},[G]),Z=u.useCallback(C=>{console.error("TaskMonitorContext: SSE connection error:",C),i(!1),c(!1),j.current&&j.current.readyState===EventSource.CLOSED?f("Task Monitor SSE connection closed by server or network issue."):f("Task Monitor SSE connection error occurred."),j.current&&(j.current.close(),j.current=null),_.current&&(clearTimeout(_.current),_.current=null)},[]),J=u.useCallback(async()=>{if(l||s){console.warn("TaskMonitorContext: Stream is already active or connecting.");return}console.log("TaskMonitorContext: Attempting to connect stream..."),i(!0);try{const C={subscription_targets:[{type:"my_a2a_messages"}]},I=await Pe(`${n}/visualization/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C),credentials:"include"});if(!I.ok){const z=await I.json().catch(()=>({detail:"Failed to subscribe"}));if(z.error_type==="authorization_failure"){const q=z.message||"Access denied: insufficient permissions",N=z.suggested_action?` ${z.suggested_action}`:"";throw new Error(`${q}${N}`)}else if(z.error_type==="subscription_failure"){const q=z.message||"Subscription failed",N=z.suggested_action?` ${z.suggested_action}`:"";throw new Error(`${q}${N}`)}else throw new Error(z.detail||z.message||`Subscription failed: ${I.statusText}`)}const F=await I.json();o(F.stream_id);const R=F.sse_endpoint_url.startsWith("/")?`${t||""}${F.sse_endpoint_url}`:F.sse_endpoint_url;j.current&&j.current.close();const Q=Ni(),O=`${R}${Q?`?token=${Q}`:""}`,W=new EventSource(O,{withCredentials:!0});j.current=W,W.onopen=U,W.addEventListener("a2a_message",B),W.onerror=Z}catch(C){console.error("TaskMonitorContext: Error connecting stream:",C),f(C instanceof Error?C.message:String(C)),i(!1),c(!1),o(null),j.current&&(j.current.close(),j.current=null),_.current&&(clearTimeout(_.current),_.current=null)}},[n,t,l,s,U,B,Z]),D=u.useCallback(()=>{if(_.current){console.log("TaskMonitorContext: Reconnection already in progress, skipping...");return}if(b>=T){console.warn("TaskMonitorContext: Max reconnection attempts reached. Stopping auto-reconnection."),E(!1),f(`Connection lost. Max reconnection attempts (${T}) reached.`);return}const C=2e3;console.log(`TaskMonitorContext: Attempting reconnection ${b+1}/${T} in ${C}ms...`),E(!0),w(I=>I+1),_.current=setTimeout(()=>{J()},C)},[b,J]),X=u.useCallback(async()=>{console.log("TaskMonitorContext: Disconnecting stream..."),_.current&&(clearTimeout(_.current),_.current=null),j.current&&(j.current.close(),j.current=null);const C=k.current;if(C)try{await Pe(`${n}/visualization/${C}/unsubscribe`,{method:"DELETE",credentials:"include"})}catch(I){console.error(`TaskMonitorContext: Error unsubscribing from stream ID: ${C}`,I)}o(null),i(!1),c(!1),f(null),m({}),x([]),v(null),w(0),E(!1)},[n]);u.useEffect(()=>()=>{console.log("TaskMonitorProvider: Unmounting. Cleaning up Task Monitor SSE connection."),j.current&&(j.current.close(),j.current=null);const C=k.current;if(C)if(navigator.sendBeacon){const I=new FormData;navigator.sendBeacon(`${n}/visualization/${C}/unsubscribe`,I)}else Pe(`${n}/visualization/${C}/unsubscribe`,{method:"DELETE",credentials:"include",keepalive:!0}).catch(I=>console.error("TaskMonitorProvider: Error in final unsubscribe on unmount (fetch):",I))},[n]),u.useEffect(()=>{!l&&!s&&(console.log("TaskProvider: Auto-connecting to task monitor stream..."),J())},[]),u.useEffect(()=>{!l&&!s&&d&&(console.log("TaskMonitorContext: Connection lost, initiating auto-reconnection..."),D())},[l,s,d,D]),u.useEffect(()=>()=>{_.current&&(clearTimeout(_.current),_.current=null)},[]);const A=u.useCallback(C=>{v(C)},[]),Y={isTaskMonitorConnecting:s,isTaskMonitorConnected:l,taskMonitorSseError:d,monitoredTasks:p,monitoredTaskOrder:h,highlightedStepId:g,isReconnecting:y,reconnectionAttempts:b,connectTaskMonitorStream:J,disconnectTaskMonitorStream:X,setHighlightedStepId:A};return a.jsx(rd.Provider,{value:Y,children:e})},at=[];for(let e=0;e<256;++e)at.push((e+256).toString(16).slice(1));function iE(e,t=0){return(at[e[t+0]]+at[e[t+1]]+at[e[t+2]]+at[e[t+3]]+"-"+at[e[t+4]]+at[e[t+5]]+"-"+at[e[t+6]]+at[e[t+7]]+"-"+at[e[t+8]]+at[e[t+9]]+"-"+at[e[t+10]]+at[e[t+11]]+at[e[t+12]]+at[e[t+13]]+at[e[t+14]]+at[e[t+15]]).toLowerCase()}let Gs;const aE=new Uint8Array(16);function lE(){if(!Gs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Gs=crypto.getRandomValues.bind(crypto)}return Gs(aE)}const cE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Gl={randomUUID:cE};function uE(e,t,n){var o;e=e||{};const r=e.random??((o=e.rng)==null?void 0:o.call(e))??lE();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,iE(r)}function tn(e,t,n){return Gl.randomUUID&&!e?Gl.randomUUID():uE(e)}const To=1,dE=e=>({...e,taskMetadata:{...e.taskMetadata,schema_version:1}}),fE={0:dE},Vl=1*1024*1024,Yl=e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result.split(",")[1]),r.onerror=o=>n(o)}),pE=({children:e})=>{const{configWelcomeMessage:t,configServerUrl:n,persistenceEnabled:r,configCollectFeedback:o}=Jt(),s=u.useMemo(()=>`${n}/api/v1`,[n]),[i,l]=u.useState(""),[c,d]=u.useState([]),[f,p]=u.useState(""),[m,h]=u.useState(!1),[x,g]=u.useState([]),[v,b]=u.useState(null),w=u.useRef(null),[y,E]=u.useState(""),[T,j]=u.useState(!1),[k,_]=u.useState(null),G=u.useRef(null),U=u.useRef(!1),B=u.useRef(null),Z=u.useRef(0),J=u.useRef(T),D=u.useRef(new Set);u.useEffect(()=>{J.current=T},[T]);const{agents:X,error:A,isLoading:Y,refetch:C}=sd(),{artifacts:I,isLoading:F,refetch:R}=Rw(i),[Q,O]=u.useState(!0),[W,z]=u.useState("files"),[q,N]=u.useState(!1),[K,ee]=u.useState(null),[te,le]=u.useState(!1),[ne,de]=u.useState(new Set),[we,je]=u.useState(!1),[Re,Le]=u.useState(null),[Me,We]=u.useState(null),[Lt,qe]=u.useState(null),[Dt,rt]=u.useState(null),[At,ot]=u.useState(null),[st,Ot]=u.useState(null),[Qt,Wt]=u.useState({}),se=u.useCallback((M,$)=>{g(V=>{if(V.find(H=>H.message===M))return V;const S=Date.now().toString(),L={id:S,message:M,type:$||"info"};return setTimeout(()=>{g(H=>H.filter(ie=>ie.id!==S))},3e3),[...V,L]})},[]),kt=u.useCallback(M=>{var P,S,L;const $=(P=M.parts)==null?void 0:P.filter(H=>H.kind==="text"),V=($==null?void 0:$.map(H=>H.text).join(""))||"";return{id:((S=M.metadata)==null?void 0:S.messageId)||`msg-${tn()}`,type:M.isUser?"user":M.artifactNotification?"artifact_notification":"agent",text:V,parts:M.parts,files:M.files,uploadedFiles:(L=M.uploadedFiles)==null?void 0:L.map(H=>({name:H.name,type:H.type})),artifactNotification:M.artifactNotification,isError:M.isError}},[]),pt=u.useCallback(async M=>{if(!(!r||!i)&&!D.current.has(M.task_id)){D.current.add(M.task_id);try{const $=await Pe(`${s}/sessions/${i}/chat-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:M.task_id,userMessage:M.user_message,messageBubbles:JSON.stringify(M.message_bubbles),taskMetadata:M.task_metadata?JSON.stringify(M.task_metadata):null})});if(!$.ok){const V=await $.json().catch(()=>({detail:"Failed to save task"}));throw new Error(V.detail||`HTTP error ${$.status}`)}}catch($){console.error(`Error saving task ${M.task_id}:`,$)}finally{setTimeout(()=>{D.current.delete(M.task_id)},100)}}},[s,i,r]),Nt=u.useCallback(M=>M.messageBubbles.map($=>({taskId:M.taskId,role:$.type==="user"?"user":"agent",parts:$.parts||[{kind:"text",text:$.text||""}],isUser:$.type==="user",isComplete:!0,files:$.files,uploadedFiles:void 0,artifactNotification:$.artifactNotification,isError:$.isError,metadata:{messageId:$.id,sessionId:i,lastProcessedEventSequence:0}})),[i]),Qe=u.useCallback(M=>{var P;const $=((P=M.taskMetadata)==null?void 0:P.schema_version)||0;if($>=To)return M;let V=M;for(let S=$;S<To;S++){const L=fE[S];L?(V=L(V),console.log(`Migrated task ${M.taskId} from v${S} to v${S+1}`)):console.warn(`No migration function found for version ${S}`)}return V},[]),mt=u.useCallback(async M=>{var $,V;try{const P=await Pe(`${s}/sessions/${M}/chat-tasks`);if(!P.ok){const ce=await P.json().catch(()=>({detail:"Failed to load session tasks"}));throw new Error(ce.detail||`HTTP error ${P.status}`)}const ie=((await P.json()).tasks||[]).map(ce=>({...ce,messageBubbles:JSON.parse(ce.messageBubbles),taskMetadata:ce.taskMetadata?JSON.parse(ce.taskMetadata):null})).map(Qe),ge=[];for(const ce of ie){const ke=Nt(ce);ge.push(...ke)}const fe={};for(const ce of ie)($=ce.taskMetadata)!=null&&$.feedback&&(fe[ce.taskId]={type:ce.taskMetadata.feedback.type,text:ce.taskMetadata.feedback.text||""});let Ae=null;for(let ce=ie.length-1;ce>=0;ce--)if((V=ie[ce].taskMetadata)!=null&&V.agent_name){Ae=ie[ce].taskMetadata.agent_name;break}d(ge),Wt(fe),Ae&&E(Ae)}catch(P){throw console.error("Error loading session tasks:",P),se("Error loading session history. Please try again.","error"),P}},[s,Nt,se,Qe]),yt=u.useCallback(async(M,$)=>{const V=$||i,P=new FormData;P.append("upload_file",M),P.append("filename",M.name),V&&P.append("sessionId",V);try{const S=await Pe(`${s}/artifacts/upload`,{method:"POST",body:P,credentials:"include"});if(!S.ok){const ie=await S.json().catch(()=>({detail:`Failed to upload ${M.name}`}));throw new Error(ie.detail||`HTTP error ${S.status}`)}const L=await S.json(),H=L.data||L;return se(`Artifact "${M.name}" uploaded successfully.`),await R(),{uri:H.uri,sessionId:H.sessionId}}catch(S){return se(`Error uploading artifact "${M.name}": ${S instanceof Error?S.message:"Unknown error"}`),null}},[s,i,se,R]),Ft=u.useCallback(async M=>{try{const $=await Pe(`${s}/artifacts/${i}/${encodeURIComponent(M)}`,{method:"DELETE",credentials:"include"});if(!$.ok&&$.status!==204){const V=await $.json().catch(()=>({detail:`Failed to delete ${M}`}));throw new Error(V.detail||`HTTP error ${$.status}`)}se(`File "${M}" deleted successfully.`),R()}catch($){se(`Error deleting file "${M}": ${$ instanceof Error?$.message:"Unknown error"}`)}},[s,i,se,R]),fn=u.useCallback(M=>{ee(M),N(!0)},[]),St=u.useCallback(()=>{ee(null),N(!1)},[]),zt=u.useCallback(async()=>{K&&await Ft(K.filename),St()},[K,Ft,St]),pn=u.useCallback(()=>{if(ne.size===0){se("No files selected for deletion.");return}je(!0)},[ne,se]),_t=u.useCallback(async()=>{je(!1);const M=Array.from(ne);let $=0,V=0;for(const P of M)try{const S=await Pe(`${s}/artifacts/${encodeURIComponent(P)}`,{method:"DELETE",credentials:"include"});if(!S.ok&&S.status!==204)throw new Error(`Failed to delete ${P}`);$++}catch(S){console.error(S),V++}$>0&&se(`${$} files(s) deleted successfully.`),V>0&&se(`Failed to delete ${V} files(s).`),R(),de(new Set),le(!1)},[ne,s,se,R]),mn=u.useCallback(async M=>{We(null),qe(null),rt(null);try{const $=await Pe(`${s}/artifacts/${i}/${encodeURIComponent(M)}/versions`,{credentials:"include"});if(!$.ok)throw new Error("Error fetching version list");const V=await $.json();if(!V||V.length===0)throw new Error("No versions available");We(V.sort((fe,Ae)=>fe-Ae));const P=Math.max(...V);qe(P);const S=await Pe(`${s}/artifacts/${i}/${encodeURIComponent(M)}/versions/${P}`,{credentials:"include"});if(!S.ok)throw new Error("Error fetching latest version content");const L=await S.blob(),H=await new Promise((fe,Ae)=>{const ce=new FileReader;ce.onloadend=()=>{var ke;return fe(((ke=ce.result)==null?void 0:ke.toString().split(",")[1])||"")},ce.onerror=Ae,ce.readAsDataURL(L)}),ie=I.find(fe=>fe.filename===M),ge={name:M,mime_type:(ie==null?void 0:ie.mime_type)||"application/octet-stream",content:H,last_modified:(ie==null?void 0:ie.last_modified)||new Date().toISOString()};return rt(ge),ge}catch($){return se(`Error loading preview for ${M}: ${$ instanceof Error?$.message:"Unknown error"}`),null}},[s,i,I,se]),hn=u.useCallback(async(M,$)=>{if(!Me||!Me.includes($))return se(`Version ${$} is not available for ${M}.`),null;rt(null);try{const V=await Pe(`${s}/artifacts/${i}/${encodeURIComponent(M)}/versions/${$}`,{credentials:"include"});if(!V.ok)throw new Error(`Error fetching version ${$}`);const P=await V.blob(),S=await new Promise((ie,ge)=>{const fe=new FileReader;fe.onloadend=()=>{var Ae;return ie(((Ae=fe.result)==null?void 0:Ae.toString().split(",")[1])||"")},fe.onerror=ge,fe.readAsDataURL(P)}),L=I.find(ie=>ie.filename===M),H={name:M,mime_type:(L==null?void 0:L.mime_type)||"application/octet-stream",content:S,last_modified:(L==null?void 0:L.last_modified)||new Date().toISOString()};return qe($),rt(H),H}catch(V){return se(`Error loading version ${$}: ${V instanceof Error?V.message:"Unknown error"}`),null}},[s,se,I,Me,i]),De=u.useCallback(M=>{se(`Loading preview for attached file: ${M.name}`),rt(M),We(null),qe(null)},[se]),Ct=u.useCallback(M=>{O(!1),z(M),typeof window<"u"&&window.dispatchEvent(new CustomEvent("expand-side-panel",{detail:{tab:M}}))},[]),Ue=u.useCallback(()=>{G.current&&(clearTimeout(G.current),G.current=null),w.current&&(w.current.close(),w.current=null),U.current=!1},[]),et=u.useCallback(M=>{var ce;Z.current+=1;const $=Z.current;let V;try{V=JSON.parse(M.data)}catch(ke){console.error("Failed to parse SSE message:",ke),se("Received unparseable agent update.","error");return}if("error"in V&&V.error){const pe=`Error: ${V.error.message}`;d(ae=>{const Oe=ae.filter(He=>!He.isStatusBubble);return Oe.push({role:"agent",parts:[{kind:"text",text:pe}],isUser:!1,isError:!0,isComplete:!0,metadata:{messageId:`msg-${tn()}`,lastProcessedEventSequence:$}}),Oe}),h(!1),Ue(),b(null);return}if(!("result"in V)||!V.result){console.warn("Received SSE message without a result or error field.",V);return}const P=V.result;let S=!1,L,H,ie;switch(P.kind){case"task":S=!0,L=void 0,ie=P.id,P.artifacts&&P.artifacts.length>0&&console.log("Final task has artifacts to process:",P.artifacts);break;case"status-update":S=P.final,L=(ce=P.status)==null?void 0:ce.message,ie=P.taskId;break;case"artifact-update":H=P.artifact,ie=P.taskId;break;default:console.warn("Received unknown result kind in SSE message:",P);return}const ge=[],fe=[];let Ae=null;if(L!=null&&L.parts)for(const ke of L.parts)if(ke.kind==="data"){const pe=ke.data;if(pe&&typeof pe=="object"&&"type"in pe)switch(pe.type){case"agent_progress_update":Ae=String((pe==null?void 0:pe.status_text)??"Processing...");break;case"artifact_creation_progress":Ae=`Saving artifact: ${String((pe==null?void 0:pe.filename)??"unknown file")} (${Number((pe==null?void 0:pe.bytes_saved)??0)} bytes)`;break;case"tool_invocation_start":break;default:ge.push(ke)}}else if(ke.kind==="file"){const ae=ke.file,Oe={name:ae.name||"untitled_file",mime_type:ae.mimeType};"bytes"in ae&&ae.bytes?Oe.content=ae.bytes:"uri"in ae&&ae.uri&&(Oe.uri=ae.uri),fe.push(Oe)}else ge.push(ke);Ae&&(B.current=Ae),d(ke=>{var Fe;const pe=[...ke];let ae=pe[pe.length-1];ae!=null&&ae.isStatusBubble&&(pe.pop(),ae=pe[pe.length-1]);const Oe=ge.find(be=>be.kind==="text"),He=ge.filter(be=>be.kind!=="text");if(ae&&!ae.isUser&&!ae.isComplete&&ae.taskId===P.taskId&&(Oe||fe.length>0)){const be={...ae,parts:[...ae.parts],files:ae.files?[...ae.files]:[],isComplete:S||fe.length>0,metadata:{...ae.metadata,lastProcessedEventSequence:$}};if(Oe){const ye=be.parts[be.parts.length-1];(ye==null?void 0:ye.kind)==="text"?be.parts[be.parts.length-1]={...ye,text:ye.text+Oe.text}:be.parts.push(Oe)}He.length>0&&be.parts.push(...He),fe.length>0&&be.files.push(...fe),pe[pe.length-1]=be}else if(ge.some(ye=>ye.kind==="text"&&ye.text.trim())||fe.length>0||H){const ye={role:"agent",parts:ge,files:fe.length>0?fe:void 0,taskId:P.taskId,isUser:!1,isComplete:S||fe.length>0,metadata:{messageId:((Fe=V.id)==null?void 0:Fe.toString())||`msg-${tn()}`,sessionId:P.contextId,lastProcessedEventSequence:$}};H&&(ye.artifactNotification={name:H.name||H.artifactId}),pe.push(ye)}if(!S&&B.current)pe.push({role:"agent",parts:[{kind:"text",text:B.current}],taskId:P.taskId,isUser:!1,isStatusBubble:!0,isComplete:!1,metadata:{messageId:`status-${tn()}`,lastProcessedEventSequence:$}});else if(S){B.current=null;const be=pe.findLastIndex(ye=>!ye.isUser&&ye.taskId===ie);be!==-1&&(pe[be]={...pe[be],isComplete:!0,metadata:{...pe[be].metadata,lastProcessedEventSequence:$}})}return pe}),S&&(J.current&&(se("Task successfully cancelled."),G.current&&clearTimeout(G.current),j(!1)),ie&&i&&d(ke=>{var ae;const pe=ke.filter(Oe=>Oe.taskId===ie&&!Oe.isStatusBubble);if(pe.length>0){const Oe=pe.map(kt),He=pe.find(it=>it.isUser),Fe=((ae=He==null?void 0:He.parts)==null?void 0:ae.filter(it=>it.kind==="text").map(it=>it.text).join(""))||"",ye=pe.some(it=>it.isError)?"error":"completed";pt({task_id:ie,user_message:Fe,message_bubbles:Oe,task_metadata:{schema_version:To,status:ye,agent_name:y}})}return ke}),h(!1),Ue(),b(null),U.current=!0,R(),setTimeout(()=>{U.current=!1},100))},[se,Ue,R,i,y,pt,kt]),It=u.useCallback(async()=>{const M="ChatProvider.handleNewSession:";if(console.log(`${M} Starting new session process...`),Ue(),m&&v&&y&&!T){console.log(`${M} Cancelling current task ${v}`);try{const V={jsonrpc:"2.0",id:`req-${tn()}`,method:"tasks/cancel",params:{id:v}};Pe(`${s}/tasks/${v}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V),credentials:"include"})}catch(V){console.warn(`${M} Failed to cancel current task:`,V)}}G.current&&(clearTimeout(G.current),G.current=null),j(!1),console.log(`${M} Resetting session state - new session will be created when first message is sent`),l(""),ot(null),d(t?[{parts:[{kind:"text",text:t}],isUser:!1,isComplete:!0,role:"agent",metadata:{sessionId:"",lastProcessedEventSequence:0}}]:[]),p(""),h(!1),b(null),_(null),Le(null),U.current=!1,B.current=null,Z.current=0,console.log(`${M} Refreshing artifacts for new session...`),await R(),se("New session started successfully."),console.log(`${M} New session setup complete - session will be created on first message.`)},[s,m,v,y,T,t,se,R,Ue]),en=u.useCallback(async M=>{const $="ChatProvider.handleSwitchSession:";if(console.log(`${$} Switching to session ${M}...`),Ue(),m&&v&&y&&!T){console.log(`${$} Cancelling current task ${v}`);try{const V={jsonrpc:"2.0",id:`req-${tn()}`,method:"tasks/cancel",params:{id:v}};await Pe(`${s}/tasks/${v}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V),credentials:"include"})}catch(V){console.warn(`${$} Failed to cancel current task:`,V)}}G.current&&(clearTimeout(G.current),G.current=null),j(!1);try{await mt(M);const V=await Pe(`${s}/sessions/${M}`);if(V.ok){const P=await V.json();ot(P.name)}l(M),p(""),h(!1),b(null),_(null),Le(null),U.current=!1,B.current=null,Z.current=0}catch(V){console.error(`${$} Failed to fetch session history:`,V),se("Error switching session. Please try again.","error")}},[Ue,m,v,y,T,s,se,mt]),$t=u.useCallback(async(M,$,V=!0)=>{if(r)try{const P=await Pe(`${s}/sessions/${M}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})});if(!P.ok){const S=await P.json().catch(()=>({detail:"Failed to update session name"}));throw new Error(S.detail||`HTTP error ${P.status}`)}V&&se("Session name updated successfully."),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch(P){se(`Error updating session name: ${P instanceof Error?P.message:"Unknown error"}`)}},[s,r,se]),xe=u.useCallback(async M=>{try{const $=await Pe(`${s}/sessions/${M}`,{method:"DELETE"});if(!$.ok){const V=await $.json().catch(()=>({detail:"Failed to delete session"}));throw new Error(V.detail||`HTTP error ${$.status}`)}se("Session deleted successfully."),M===i&&It(),typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}catch($){se(`Error deleting session: ${$ instanceof Error?$.message:"Unknown error"}`)}},[s,se,It,i]),Ce=u.useCallback(M=>{Ot(M)},[]),Ie=u.useCallback(()=>{Ot(null)},[]),Te=u.useCallback(async()=>{st&&(await xe(st.id),Ot(null))},[st,xe]),tt=u.useCallback(async()=>{if(!m&&!T||!v){se("No active task to cancel.");return}if(T){se("Cancellation already in progress.");return}se(`Requesting cancellation for task ${v}...`),j(!0);try{const M={jsonrpc:"2.0",id:`req-${tn()}`,method:"tasks/cancel",params:{id:v}},$=await Pe(`${s}/tasks/${v}:cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)});if($.status===202)G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{se(`Cancellation for task ${v} timed out. Allowing new input.`),j(!1),h(!1),Ue(),b(null),G.current=null,d(V=>V.filter(P=>!P.isStatusBubble))},15e3);else{const V=await $.json().catch(()=>({detail:"Unknown cancellation error"}));se(`Failed to request cancellation: ${V.detail||$.statusText}`),j(!1)}}catch(M){se(`Error sending cancellation request: ${M instanceof Error?M.message:"Network error"}`),j(!1)}},[m,T,v,s,se,Ue]),Xe=u.useCallback(async(M,$,V)=>{if(!i){console.error("Cannot submit feedback without a session ID.");return}try{await Om({taskId:M,sessionId:i,feedbackType:$,feedbackText:V}),Wt(P=>({...P,[M]:{type:$,text:V}}))}catch(P){throw console.error("Failed to submit feedback:",P),se("Failed to submit feedback. Please try again.","error"),P}},[i,se]),Ge=u.useCallback(()=>{},[]),$e=u.useCallback(()=>{m&&!U.current&&!J.current&&se("Connection error with agent updates."),U.current||(h(!1),J.current||(Ue(),b(null)),B.current=null),d(M=>M.filter($=>!$.isStatusBubble).map(($,V,P)=>V===P.length-1&&!$.isUser?{...$,isComplete:!0}:$))},[se,Ue,m]),Be=u.useCallback(async(M,$,V)=>{M.preventDefault();const P=(V==null?void 0:V.trim())||f.trim(),S=$||[];if(!P&&S.length===0||m||T||!y){y||se("Please select an agent first."),T&&se("Cannot send new message while a task is being cancelled.");return}Ue(),U.current=!1,h(!0),b(null),B.current=null,Z.current=0;const L=!i;let H=i||void 0;const ie={role:"user",parts:[{kind:"text",text:P}],isUser:!0,uploadedFiles:S.length>0?S:void 0,metadata:{messageId:`msg-${tn()}`,sessionId:H,lastProcessedEventSequence:0}};B.current="Thinking",d(ge=>[...ge,ie]),p("");try{const ge=[];if(L)for(const Fe of S)if(Fe.size<Vl){const be=await Yl(Fe);ge.push({kind:"file",file:{bytes:be,name:Fe.name,mimeType:Fe.type}})}else{const be=await yt(Fe,H);be?(!H&&be.sessionId&&(H=be.sessionId,console.log(`Session created via artifact upload: ${H}`)),ge.push({kind:"file",file:{uri:be.uri,name:Fe.name,mimeType:Fe.type}})):se(`Failed to upload large file: ${Fe.name}`,"error")}else{const Fe=S.map(async ye=>{if(ye.size<Vl)return{kind:"file",file:{bytes:await Yl(ye),name:ye.name,mimeType:ye.type}};{const it=await yt(ye,H);return it?{kind:"file",file:{uri:it.uri,name:ye.name,mimeType:ye.type}}:(se(`Failed to upload large file: ${ye.name}`,"error"),null)}}),be=await Promise.all(Fe);ge.push(...be.filter(ye=>ye!==null))}L&&H&&H!==i&&(l(H),console.log(`Session created via artifact upload: ${H}`));const fe=[];if(P&&fe.push({kind:"text",text:P}),fe.push(...ge),fe.length===0)throw new Error("Cannot send an empty message.");const Ae={role:"user",parts:fe,messageId:`msg-${tn()}`,kind:"message",contextId:H,metadata:{agent_name:y}},ce={jsonrpc:"2.0",id:`req-${tn()}`,method:"message/stream",params:{message:Ae}},ke=await Pe(`${s}/message:stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ce)});if(!ke.ok){const Fe=await ke.json().catch(()=>({detail:"Unknown error"}));throw new Error(Fe.detail||`HTTP error ${ke.status}`)}const pe=await ke.json(),ae=pe==null?void 0:pe.result,Oe=ae==null?void 0:ae.id,He=ae==null?void 0:ae.contextId;if(!Oe)throw new Error("Backend did not return a valid taskId.");if(He&&He!==H&&(H?console.warn(`Backend returned a different session ID (${He}) than expected (${H}). Updating to: ${He}`):console.log(`Backend created new session: ${He}`),l(He),H=He),H&&await pt({task_id:Oe,user_message:P,message_bubbles:[kt(ie)],task_metadata:{schema_version:To,status:"pending",agent_name:y}}),L&&He){const be=ie.parts.filter(ye=>ye.kind==="text").map(ye=>ye.text).join(" ").trim();if(be){const ye=be.length>100?`${be.substring(0,100)}...`:be;ot(ye),$t(He,ye,!1)}typeof window<"u"&&window.dispatchEvent(new CustomEvent("new-chat-session"))}b(Oe),_(Oe),d(Fe=>Fe.map(be=>{var ye,it;return((ye=be.metadata)==null?void 0:ye.messageId)===((it=ie.metadata)==null?void 0:it.messageId)?{...be,taskId:Oe}:be}))}catch(ge){se(`Error: ${ge instanceof Error?ge.message:"Unknown error"}`),h(!1),d(fe=>fe.filter(Ae=>!Ae.isStatusBubble)),b(null),U.current=!1,B.current=null}},[i,f,m,T,y,Ue,se,s,yt,$t,pt,kt]);u.useEffect(()=>{if(v&&s){console.log(`ChatProvider Effect: currentTaskId is ${v}. Setting up EventSource.`);const M=Ni(),$=`${s}/sse/subscribe/${v}${M?`?token=${M}`:""}`,V=new EventSource($,{withCredentials:!0});return w.current=V,V.onopen=Ge,V.onerror=$e,V.addEventListener("status_update",et),V.addEventListener("artifact_update",et),V.addEventListener("final_response",et),V.addEventListener("error",et),()=>{console.log(`ChatProvider Effect Cleanup: currentTaskId was ${v}. Closing EventSource.`),V.removeEventListener("status_update",et),V.removeEventListener("artifact_update",et),V.removeEventListener("final_response",et),V.removeEventListener("error",et),Ue()}}else console.log("ChatProvider Effect: currentTaskId is null or apiPrefix missing. Ensuring EventSource is closed."),Ue()},[v,s,et,Ge,$e,Ue]);const Et={configCollectFeedback:o,submittedFeedback:Qt,handleFeedbackSubmit:Xe,sessionId:i,setSessionId:l,sessionName:At,setSessionName:ot,messages:c,setMessages:d,userInput:f,setUserInput:p,isResponding:m,currentTaskId:v,isCancelling:T,latestStatusText:B,agents:X,agentsLoading:Y,agentsError:A,agentsRefetch:C,handleNewSession:It,handleSwitchSession:en,handleSubmit:Be,handleCancel:tt,notifications:x,addNotification:se,selectedAgentName:y,setSelectedAgentName:E,artifacts:I,artifactsLoading:F,artifactsRefetch:R,uploadArtifactFile:yt,isSidePanelCollapsed:Q,activeSidePanelTab:W,setIsSidePanelCollapsed:O,setActiveSidePanelTab:z,openSidePanelTab:Ct,taskIdInSidePanel:k,setTaskIdInSidePanel:_,isDeleteModalOpen:q,artifactToDelete:K,openDeleteModal:fn,closeDeleteModal:St,confirmDelete:zt,openSessionDeleteModal:Ce,closeSessionDeleteModal:Ie,confirmSessionDelete:Te,sessionToDelete:st,isArtifactEditMode:te,setIsArtifactEditMode:le,selectedArtifactFilenames:ne,setSelectedArtifactFilenames:de,handleDeleteSelectedArtifacts:pn,confirmBatchDeleteArtifacts:_t,isBatchDeleteModalOpen:we,setIsBatchDeleteModalOpen:je,previewedArtifactAvailableVersions:Me,currentPreviewedVersionNumber:Lt,previewFileContent:Dt,openArtifactForPreview:mn,navigateArtifactVersion:hn,openMessageAttachmentForPreview:De,previewArtifact:Re,setPreviewArtifact:Le,updateSessionName:$t,deleteSession:xe};return a.jsx(ed.Provider,{value:Et,children:e})},mE=({children:e})=>{const{frontend_use_authorization:t,configAuthLoginUrl:n}=Jt(),{fetchCsrfToken:r,clearCsrfToken:o}=id(),[s,i]=u.useState(!1),[l,c]=u.useState(!0),[d,f]=u.useState(null);u.useEffect(()=>{let h=!0;const x=async()=>{if(!t){h&&(i(!0),c(!1));return}try{const v=await Pe("/api/v1/users/me",{credentials:"include",headers:{Accept:"application/json"}});if(v.ok){const b=await v.json();console.log("User is authenticated:",b),h&&(f(b),i(!0)),console.log("Fetching CSRF token for authenticated requests..."),await r()}else v.status===401?(console.log("User is not authenticated"),h&&i(!1)):(console.error("Unexpected response from /users/me:",v.status),h&&i(!1))}catch(v){console.error("Error checking authentication:",v),h&&i(!1)}finally{h&&c(!1)}};x();const g=v=>{v.key==="access_token"&&x()};return window.addEventListener("storage",g),()=>{h=!1,window.removeEventListener("storage",g)}},[t,n,r]);const p=()=>{window.location.href=n},m=()=>{i(!1),f(null),o()};return l?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"border-solace-green mx-auto mb-4 h-12 w-12 animate-spin rounded-full border-b-2"}),a.jsx("h1",{className:"text-2xl text-black dark:text-white",children:"Checking Authentication..."})]})}):a.jsx(Qu.Provider,{value:{isAuthenticated:s,useAuthorization:t,login:p,logout:m,userInfo:d},children:e})};function hE(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 gE=e=>new Promise(t=>setTimeout(t,e)),xE=async(e=5,t=50)=>{try{const n=await Pe("/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 s=hE("csrf_token");if(s)return console.log(`CSRF token found in cookie after ${o} retries:`,s),s;console.log(`CSRF token not found in cookie, attempt ${o+1}/${e}. Waiting ${t}ms...`),await gE(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 vE({children:e}){const[t,n]=u.useState(null),r=u.useCallback(async()=>{if(t)return t;const i=await xE();if(i)n(i);else throw new Error("Failed to obtain CSRF token after config fetch failed.");return i},[t]),o=u.useCallback(()=>{n(null)},[]),s={fetchCsrfToken:r,clearCsrfToken:o};return a.jsx(nd.Provider,{value:s,children:e})}const wE={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"}},bE={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"}},yE={"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 Kl(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 SE(e,t){const n={},r=bE[t];for(const[o,s]of Object.entries(r)){const i=Kl(e,s);n[`--${o}`]=i}for(const[o,s]of Object.entries(yE)){const i=Kl(e,s);n[`--color-${o}`]=i}return n}const Go="sam-theme";function CE(e){var n,r,o,s,i,l,c,d,f,p,m,h,x,g,v,b,w,y,E,T,j,k,_,G,U,B,Z,J,D,X,A,Y,C,I,F,R,Q,O,W,z,q,N,K,ee,te,le,ne,de,we,je,Re,Le,Me,We,Lt,qe,Dt,rt,At,ot,st,Ot,Qt,Wt,se,kt,pt,Nt,Qe,mt,yt,Ft,fn,St,zt,pn,_t,mn,hn,De,Ct,Ue,et,It,en,$t,xe,Ce,Ie,Te,tt,Xe,Ge,$e,Be,Et,M,$,V,P,S,L,H;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),(s=e.info)!=null&&s.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),(d=e.error)!=null&&d.w100&&(t["--color-error-w100"]=e.error.w100),(f=e.error)!=null&&f.w70&&(t["--color-error-w70"]=e.error.w70),(p=e.error)!=null&&p.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),(v=e.warning)!=null&&v.w70&&(t["--color-warning-w70"]=e.warning.w70),(b=e.warning)!=null&&b.w30&&(t["--color-warning-w30"]=e.warning.w30),(w=e.warning)!=null&&w.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),(j=e.success)!=null&&j.w70&&(t["--color-success-w70"]=e.success.w70),(k=e.success)!=null&&k.w30&&(t["--color-success-w30"]=e.success.w30),(_=e.success)!=null&&_.w20&&(t["--color-success-w20"]=e.success.w20),(G=e.success)!=null&&G.w10&&(t["--color-success-w10"]=e.success.w10),(U=e.stateLayer)!=null&&U.w10&&(t["--color-stateLayer-w10"]=e.stateLayer.w10),(B=e.stateLayer)!=null&&B.w20&&(t["--color-stateLayer-w20"]=e.stateLayer.w20),(J=(Z=e.accent)==null?void 0:Z.n0)!=null&&J.wMain&&(t["--color-accent-n0-wMain"]=e.accent.n0.wMain),(X=(D=e.accent)==null?void 0:D.n0)!=null&&X.w100&&(t["--color-accent-n0-w100"]=e.accent.n0.w100),(Y=(A=e.accent)==null?void 0:A.n0)!=null&&Y.w30&&(t["--color-accent-n0-w30"]=e.accent.n0.w30),(I=(C=e.accent)==null?void 0:C.n0)!=null&&I.w10&&(t["--color-accent-n0-w10"]=e.accent.n0.w10),(R=(F=e.accent)==null?void 0:F.n1)!=null&&R.wMain&&(t["--color-accent-n1-wMain"]=e.accent.n1.wMain),(O=(Q=e.accent)==null?void 0:Q.n1)!=null&&O.w100&&(t["--color-accent-n1-w100"]=e.accent.n1.w100),(z=(W=e.accent)==null?void 0:W.n1)!=null&&z.w60&&(t["--color-accent-n1-w60"]=e.accent.n1.w60),(N=(q=e.accent)==null?void 0:q.n1)!=null&&N.w30&&(t["--color-accent-n1-w30"]=e.accent.n1.w30),(ee=(K=e.accent)==null?void 0:K.n1)!=null&&ee.w20&&(t["--color-accent-n1-w20"]=e.accent.n1.w20),(le=(te=e.accent)==null?void 0:te.n1)!=null&&le.w10&&(t["--color-accent-n1-w10"]=e.accent.n1.w10),(de=(ne=e.accent)==null?void 0:ne.n2)!=null&&de.wMain&&(t["--color-accent-n2-wMain"]=e.accent.n2.wMain),(je=(we=e.accent)==null?void 0:we.n2)!=null&&je.w100&&(t["--color-accent-n2-w100"]=e.accent.n2.w100),(Le=(Re=e.accent)==null?void 0:Re.n2)!=null&&Le.w30&&(t["--color-accent-n2-w30"]=e.accent.n2.w30),(We=(Me=e.accent)==null?void 0:Me.n2)!=null&&We.w20&&(t["--color-accent-n2-w20"]=e.accent.n2.w20),(qe=(Lt=e.accent)==null?void 0:Lt.n2)!=null&&qe.w10&&(t["--color-accent-n2-w10"]=e.accent.n2.w10),(rt=(Dt=e.accent)==null?void 0:Dt.n3)!=null&&rt.wMain&&(t["--color-accent-n3-wMain"]=e.accent.n3.wMain),(ot=(At=e.accent)==null?void 0:At.n3)!=null&&ot.w100&&(t["--color-accent-n3-w100"]=e.accent.n3.w100),(Ot=(st=e.accent)==null?void 0:st.n3)!=null&&Ot.w30&&(t["--color-accent-n3-w30"]=e.accent.n3.w30),(Wt=(Qt=e.accent)==null?void 0:Qt.n3)!=null&&Wt.w10&&(t["--color-accent-n3-w10"]=e.accent.n3.w10),(kt=(se=e.accent)==null?void 0:se.n4)!=null&&kt.wMain&&(t["--color-accent-n4-wMain"]=e.accent.n4.wMain),(Nt=(pt=e.accent)==null?void 0:pt.n4)!=null&&Nt.w100&&(t["--color-accent-n4-w100"]=e.accent.n4.w100),(mt=(Qe=e.accent)==null?void 0:Qe.n4)!=null&&mt.w30&&(t["--color-accent-n4-w30"]=e.accent.n4.w30),(Ft=(yt=e.accent)==null?void 0:yt.n5)!=null&&Ft.wMain&&(t["--color-accent-n5-wMain"]=e.accent.n5.wMain),(St=(fn=e.accent)==null?void 0:fn.n5)!=null&&St.w100&&(t["--color-accent-n5-w100"]=e.accent.n5.w100),(pn=(zt=e.accent)==null?void 0:zt.n5)!=null&&pn.w60&&(t["--color-accent-n5-w60"]=e.accent.n5.w60),(mn=(_t=e.accent)==null?void 0:_t.n5)!=null&&mn.w30&&(t["--color-accent-n5-w30"]=e.accent.n5.w30),(De=(hn=e.accent)==null?void 0:hn.n6)!=null&&De.wMain&&(t["--color-accent-n6-wMain"]=e.accent.n6.wMain),(Ue=(Ct=e.accent)==null?void 0:Ct.n6)!=null&&Ue.w100&&(t["--color-accent-n6-w100"]=e.accent.n6.w100),(It=(et=e.accent)==null?void 0:et.n6)!=null&&It.w30&&(t["--color-accent-n6-w30"]=e.accent.n6.w30),($t=(en=e.accent)==null?void 0:en.n7)!=null&&$t.wMain&&(t["--color-accent-n7-wMain"]=e.accent.n7.wMain),(Ce=(xe=e.accent)==null?void 0:xe.n7)!=null&&Ce.w100&&(t["--color-accent-n7-w100"]=e.accent.n7.w100),(Te=(Ie=e.accent)==null?void 0:Ie.n7)!=null&&Te.w30&&(t["--color-accent-n7-w30"]=e.accent.n7.w30),(Xe=(tt=e.accent)==null?void 0:tt.n8)!=null&&Xe.wMain&&(t["--color-accent-n8-wMain"]=e.accent.n8.wMain),($e=(Ge=e.accent)==null?void 0:Ge.n8)!=null&&$e.w100&&(t["--color-accent-n8-w100"]=e.accent.n8.w100),(Et=(Be=e.accent)==null?void 0:Be.n8)!=null&&Et.w30&&(t["--color-accent-n8-w30"]=e.accent.n8.w30),($=(M=e.accent)==null?void 0:M.n9)!=null&&$.wMain&&(t["--color-accent-n9-wMain"]=e.accent.n9.wMain),(V=e.learning)!=null&&V.wMain&&(t["--color-learning-wMain"]=e.learning.wMain),(P=e.learning)!=null&&P.w100&&(t["--color-learning-w100"]=e.learning.w100),(S=e.learning)!=null&&S.w90&&(t["--color-learning-w90"]=e.learning.w90),(L=e.learning)!=null&&L.w20&&(t["--color-learning-w20"]=e.learning.w20),(H=e.learning)!=null&&H.w10&&(t["--color-learning-w10"]=e.learning.w10),t}function EE(e,t="light"){const n={};if(e){const o=CE(e);Object.assign(n,o)}const r=SE(e,t);return Object.assign(n,r),n}function TE(){const e=localStorage.getItem(Go);return e==="dark"||e==="light"?e:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function AE(e,t){const n=EE(e,t),r=document.documentElement;for(const[o,s]of Object.entries(n))r.style.setProperty(o,s);requestAnimationFrame(()=>{console.log(`Applying ${t} theme with palette`),r.classList.remove("light","dark"),r.classList.add(t),localStorage.setItem(Go,t)})}const kE=({children:e})=>{const t=u.useMemo(()=>wE,[]),[n,r]=u.useState(()=>TE()),o=u.useMemo(()=>({currentTheme:n,toggleTheme:()=>{const s=n==="light"?"dark":"light";r(s),localStorage.setItem(Go,s)}}),[n]);return u.useEffect(()=>{if(!(localStorage.getItem(Go)!==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)}}},[]),u.useEffect(()=>{document.documentElement.classList.remove("light","dark"),AE(t,n)},[n,t]),a.jsx(od.Provider,{value:o,children:e})};function NE(){const[e,t]=u.useState("chat"),{isAuthenticated:n,login:r,useAuthorization:o}=Pw();if(Lw(),o&&!n)return a.jsx("div",{className:"bg-background flex h-screen items-center justify-center",children:a.jsx(me,{onClick:r,children:"Login"})});const s=c=>{const d=Ul.find(f=>f.id===c)||Hl.find(f=>f.id===c);d!=null&&d.onClick&&c!=="settings"?d.onClick():c!=="settings"&&t(c)},i=()=>{t("chat")},l=()=>{switch(e){case"chat":return a.jsx(nE,{});case"agentMesh":return a.jsx(Q1,{})}};return a.jsxs("div",{className:"relative flex h-screen",children:[a.jsx(G1,{items:Ul,bottomItems:Hl,activeItem:e,onItemChange:s,onHeaderClick:i}),a.jsx("main",{className:"h-full w-full flex-1 overflow-auto",children:l()}),a.jsx(gb,{})]})}function _E(){return a.jsx(kE,{children:a.jsx(vE,{children:a.jsx(oE,{children:a.jsx(mE,{children:a.jsx(pE,{children:a.jsx(sE,{children:a.jsx(NE,{})})})})})})})}Bp.createRoot(document.getElementById("root")).render(a.jsx(u.StrictMode,{children:a.jsx(_E,{})}));