@decocms/mesh 2.71.1 → 2.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/client/assets/{AlertCircle-3QR0y8W6.js → AlertCircle-BOIQEKjW.js} +1 -1
  2. package/dist/client/assets/{ArrowUp-BodxzbKG.js → ArrowUp-BRclUYsx.js} +1 -1
  3. package/dist/client/assets/{Calendar-DGYs9p01.js → Calendar-DydX5uRn.js} +1 -1
  4. package/dist/client/assets/{Check-DKxLmorI.js → Check-Bkb61eVw.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-DnCsS3JZ.js → CheckCircle-ZkjIkaWv.js} +1 -1
  6. package/dist/client/assets/{CheckDone01--TgQ6PuW.js → CheckDone01-BusS8ANA.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-D4GxGIq8.js → ChevronDown-DqJTvBdv.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-c9zV8moh.js → ChevronRight-BBcOJkyP.js} +1 -1
  9. package/dist/client/assets/{Code01--g0L9RTm.js → Code01-DEMYMNLO.js} +1 -1
  10. package/dist/client/assets/{Copy01-BA-Ix-Mb.js → Copy01-BvgMlJ5t.js} +1 -1
  11. package/dist/client/assets/{DotsHorizontal-DGECYgiW.js → DotsHorizontal-C3Pu-YCA.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-dEZsGaNC.js → DotsVertical-DMOP2SMU.js} +1 -1
  13. package/dist/client/assets/{Download01-D8K-ex_X.js → Download01-VwSgop8U.js} +1 -1
  14. package/dist/client/assets/{Edit01-CmR87Abc.js → Edit01-ByF-cYbh.js} +1 -1
  15. package/dist/client/assets/{File02-DQyurYit.js → File02-D6OcKUS4.js} +1 -1
  16. package/dist/client/assets/{File06-BVRF7sU6.js → File06-CkTcogsG.js} +1 -1
  17. package/dist/client/assets/{FilterLines-CU5-9_eJ.js → FilterLines-BL17m8OO.js} +1 -1
  18. package/dist/client/assets/{Globe02-kD5VSMhM.js → Globe02-CwdZK2H5.js} +1 -1
  19. package/dist/client/assets/{Grid01-1H_5bBEp.js → Grid01-zbmmdox0.js} +1 -1
  20. package/dist/client/assets/{Home02-CmimZ8ry.js → Home02-DPzckV1r.js} +1 -1
  21. package/dist/client/assets/{Image01-DvVQGg3o.js → Image01-BuXlAy8i.js} +1 -1
  22. package/dist/client/assets/{Inbox01-DaZjvBHq.js → Inbox01-Czow08Bp.js} +1 -1
  23. package/dist/client/assets/{InfoCircle-D88W6aZv.js → InfoCircle-C8GtqndP.js} +1 -1
  24. package/dist/client/assets/{LinkExternal01-BG70TvGv.js → LinkExternal01-DJasjN8P.js} +1 -1
  25. package/dist/client/assets/{List-3m_qAkQw.js → List-BvAv-Mbv.js} +1 -1
  26. package/dist/client/assets/{Loading01-OQLi83Gk.js → Loading01-DOPFYU4m.js} +1 -1
  27. package/dist/client/assets/{Lock01-CFroRX-P.js → Lock01-BALKEl0l.js} +1 -1
  28. package/dist/client/assets/{Pin01-BtF71mI4.js → Pin01-Dk_x7uai.js} +1 -1
  29. package/dist/client/assets/{Play-n3p2AwCc.js → Play-CjfPPVn_.js} +1 -1
  30. package/dist/client/assets/{Plus-CamZ25HZ.js → Plus-WaQ7hmj5.js} +1 -1
  31. package/dist/client/assets/{SearchMd-CMsT_ewj.js → SearchMd-Ds-ERWzq.js} +1 -1
  32. package/dist/client/assets/{Settings01-DLRo_g5I.js → Settings01-CMNXJNnf.js} +1 -1
  33. package/dist/client/assets/{Share07-DBSgibs_.js → Share07-w2-wABEW.js} +1 -1
  34. package/dist/client/assets/{Terminal-goRyLnyD.js → Terminal-CrrxpXUI.js} +1 -1
  35. package/dist/client/assets/{Tool01-C4uY_h3W.js → Tool01-Cn8FHCpZ.js} +1 -1
  36. package/dist/client/assets/{Trash01-DoayzMxM.js → Trash01-C-euKa34.js} +1 -1
  37. package/dist/client/assets/{Upload01-CMe4EY2M.js → Upload01-Dc0hOrKX.js} +1 -1
  38. package/dist/client/assets/{Users03-CPa8wyG0.js → Users03-zsvZ9QWQ.js} +1 -1
  39. package/dist/client/assets/{X-DjzWAzfl.js → X-DUGfq2_H.js} +1 -1
  40. package/dist/client/assets/{XClose-CsbmAiAF.js → XClose-Cv_qbaYN.js} +1 -1
  41. package/dist/client/assets/{agent-connections-preview-CvK0lrw7.js → agent-connections-preview-C15fpCN8.js} +1 -1
  42. package/dist/client/assets/agent-detail-BQXrWX9M.js +1 -0
  43. package/dist/client/assets/{agents-DcV0PAPt.js → agents-NgYS-NWl.js} +1 -1
  44. package/dist/client/assets/{alert-dialog-DvhR6MYa.js → alert-dialog-B4H6MrIT.js} +1 -1
  45. package/dist/client/assets/{auth-catchall-BULd9dc-.js → auth-catchall-GUc2KujY.js} +1 -1
  46. package/dist/client/assets/{avatar-BeOUM-c3.js → avatar-B-AS-16N.js} +1 -1
  47. package/dist/client/assets/{badge-CAqp4wuS.js → badge-BFm6jM0d.js} +1 -1
  48. package/dist/client/assets/{binder-Dl_fdkAq.js → binder-C4CQlgMb.js} +1 -1
  49. package/dist/client/assets/{breadcrumb-BPTkT5qZ.js → breadcrumb-Cvo4WJJ5.js} +1 -1
  50. package/dist/client/assets/{button-D5ZVigg9.js → button-Cl3WMTWk.js} +1 -1
  51. package/dist/client/assets/{card-SJC2htmM.js → card-B-73zAje.js} +1 -1
  52. package/dist/client/assets/{checkbox-DOqdhbrT.js → checkbox-kN_xGJfO.js} +1 -1
  53. package/dist/client/assets/{circle-alert-DALZt6Ia.js → circle-alert-BEtzK3t3.js} +1 -1
  54. package/dist/client/assets/collection-detail-C9AV2Fn9.js +26 -0
  55. package/dist/client/assets/{collection-search-CmrOSxkd.js → collection-search-Aeh0FXZR.js} +1 -1
  56. package/dist/client/assets/{collection-tab-DcWi6-VM.js → collection-tab-CgMRLj1Y.js} +1 -1
  57. package/dist/client/assets/{collection-table-wrapper-vBjYl8bL.js → collection-table-wrapper-CmBNNf0K.js} +1 -1
  58. package/dist/client/assets/{collection-tabs-CiJEhlnO.js → collection-tabs-2AUf3kZ2.js} +1 -1
  59. package/dist/client/assets/{command-C5xFKb_5.js → command-DICG2vo0.js} +1 -1
  60. package/dist/client/assets/{connect-ChjgF-sA.js → connect-DoxLTvbh.js} +1 -1
  61. package/dist/client/assets/{connection-card-D2tP3_Yy.js → connection-card-ChzuU2dT.js} +1 -1
  62. package/dist/client/assets/connection-detail-CVNpoyUm.js +1 -0
  63. package/dist/client/assets/{connections-tqhW_7Rc.js → connections-BHOwcUB0.js} +1 -1
  64. package/dist/client/assets/{constants-BUYb8__-.js → constants-1q3hobyw.js} +1 -1
  65. package/dist/client/assets/constants-DzWq-50V.js +1 -0
  66. package/dist/client/assets/{create-organization-dialog-XeEeOZAr.js → create-organization-dialog-DWV2eGAF.js} +1 -1
  67. package/dist/client/assets/{create-project-dialog-C_x3oW1v.js → create-project-dialog-49RtElmv.js} +1 -1
  68. package/dist/client/assets/{dialog-Cfe0BARl.js → dialog-BmGDp4UV.js} +1 -1
  69. package/dist/client/assets/{dropdown-menu-XJuOVNha.js → dropdown-menu-6IaHSzwJ.js} +1 -1
  70. package/dist/client/assets/{dynamic-plugin-layout-BoZB1FB7.js → dynamic-plugin-layout-C_HHJRk0.js} +1 -1
  71. package/dist/client/assets/{empty-state-DbaNRAmj.js → empty-state-DFIrBrC-.js} +1 -1
  72. package/dist/client/assets/{empty-state-Clfhj5oY.js → empty-state-oU8PNga_.js} +1 -1
  73. package/dist/client/assets/{env-vars-editor-B_Tiymrw.js → env-vars-editor-Bmnp2cvo.js} +1 -1
  74. package/dist/client/assets/{error-boundary-poUsbtfm.js → error-boundary-D7C5xzme.js} +1 -1
  75. package/dist/client/assets/{estree-BOE5AzoZ.js → estree-CwOGYdhi.js} +2 -2
  76. package/dist/client/assets/{extract-connection-data-C36Hgi4g.js → extract-connection-data-CQQ4ZZEG.js} +1 -1
  77. package/dist/client/assets/{file-browser-BfBDhEcz.js → file-browser-CHtfSNHu.js} +2 -2
  78. package/dist/client/assets/{form-9-Pb579i.js → form-qYB4UriD.js} +1 -1
  79. package/dist/client/assets/{grid-view-CUc2gxvk.js → grid-view-B4Eut3Xi.js} +1 -1
  80. package/dist/client/assets/{home-HnU6LY8q.js → home-BYm3DFU4.js} +1 -1
  81. package/dist/client/assets/index--g69ISoA.css +1 -0
  82. package/dist/client/assets/{index-DOa9Uc_j.js → index-5T3tdhiA.js} +1 -1
  83. package/dist/client/assets/index-9vOB29ZB.js +1 -0
  84. package/dist/client/assets/{index-BwOTcL_8.js → index-BA6gcyzW.js} +2 -2
  85. package/dist/client/assets/{index-D-FZcOMC.js → index-BV-rIyOx.js} +6 -6
  86. package/dist/client/assets/{index-CasvHInh.js → index-BYzsWn1B.js} +1 -1
  87. package/dist/client/assets/{index-BPTl2xOh.js → index-CxyQJKsK.js} +1 -1
  88. package/dist/client/assets/index-Dolyg0HI.js +25 -0
  89. package/dist/client/assets/{index-BuoWGjhI.js → index-Vp0uDDij.js} +1 -1
  90. package/dist/client/assets/{index-DcojMUwg.js → index-fCCl5Un_.js} +1 -1
  91. package/dist/client/assets/{infiniteQueryObserver-cPntdNLH.js → infiniteQueryObserver-CrYps4St.js} +1 -1
  92. package/dist/client/assets/{input-CLb5DS9b.js → input-Dv5qvD5N.js} +1 -1
  93. package/dist/client/assets/{integration-icon-Bf2CRysj.js → integration-icon-DKM9NBX1.js} +1 -1
  94. package/dist/client/assets/{layout-BP7942c0.js → layout-B7afTuaN.js} +1 -1
  95. package/dist/client/assets/{localstorage-keys-CiWIgky1.js → localstorage-keys-Ds2uOTRP.js} +1 -1
  96. package/dist/client/assets/{login-FiEBi4Or.js → login-BpnfmGBt.js} +1 -1
  97. package/dist/client/assets/{mcp-oauth-B9GgDKSF.js → mcp-oauth-C_XpjqFg.js} +1 -1
  98. package/dist/client/assets/{mcp-server-card-CFUMmBRv.js → mcp-server-card-CiGvO9aP.js} +1 -1
  99. package/dist/client/assets/{mcp-server-detail-BZppJ46W.js → mcp-server-detail-SQfpDpYc.js} +2 -2
  100. package/dist/client/assets/members-CQSBREQS.js +3 -0
  101. package/dist/client/assets/{monaco-editor-DTJpuLmN.js → monaco-editor-q53ZLBJ5.js} +2 -2
  102. package/dist/client/assets/{monitoring-CtjMBXjP.js → monitoring-CK4xcQzM.js} +3 -3
  103. package/dist/client/assets/{oauth-callback-B-K60EP0.js → oauth-callback-CeLfnx5m.js} +1 -1
  104. package/dist/client/assets/page-CrfNBuC7.js +1 -0
  105. package/dist/client/assets/{page-CPMOFPIV.js → page-jzi-88Nr.js} +1 -1
  106. package/dist/client/assets/{plugin-empty-state-CYA7cl1b.js → plugin-empty-state-Bnssy2Oj.js} +1 -1
  107. package/dist/client/assets/{plugin-header-DEroTZAh.js → plugin-header-DoQQAOys.js} +1 -1
  108. package/dist/client/assets/{popover-Cg1hAh9E.js → popover-DuZ2ZN5J.js} +1 -1
  109. package/dist/client/assets/{project-layout-DvvoQRcD.js → project-layout-CH4wXxX2.js} +1 -1
  110. package/dist/client/assets/{project-settings-BDNCo4Mf.js → project-settings-CKgnjrBp.js} +1 -1
  111. package/dist/client/assets/{projects-list-BJVOz5Jy.js → projects-list-D0sSao6e.js} +1 -1
  112. package/dist/client/assets/{registry-utils-DVSRHBf5.js → registry-utils-CqOx6XXE.js} +1 -1
  113. package/dist/client/assets/{resizable-jofggeTS.js → resizable-CZuYHBhW.js} +1 -1
  114. package/dist/client/assets/{select-DANNPdpC.js → select-ODRW9YrY.js} +1 -1
  115. package/dist/client/assets/{shell-layout-BCh3pu-1.js → shell-layout-BxNK1bDI.js} +2 -2
  116. package/dist/client/assets/{spinner-CJ9nslDm.js → spinner-BPZfVVyD.js} +1 -1
  117. package/dist/client/assets/{store-invite-Drr4aCfi.js → store-invite-ICTVmn8_.js} +1 -1
  118. package/dist/client/assets/{switch-DtIJc9SJ.js → switch-B-1QAIh-.js} +1 -1
  119. package/dist/client/assets/{table-DjucqeVe.js → table-BBnlXDKe.js} +1 -1
  120. package/dist/client/assets/{tasks-Bj_6qkxT.js → tasks-CpdqRpYU.js} +1 -1
  121. package/dist/client/assets/{textarea-DQgI4KTD.js → textarea-DK_SwVx9.js} +1 -1
  122. package/dist/client/assets/{tools-list-C3zbRtxa.js → tools-list-B5iaOgKy.js} +1 -1
  123. package/dist/client/assets/{typewriter-title-BINp1X1h.js → typewriter-title-C_OsyMAQ.js} +1 -1
  124. package/dist/client/assets/{use-binding-DYiJkibE.js → use-binding-BVOuBiur.js} +1 -1
  125. package/dist/client/assets/{use-connection-DR5puEok.js → use-connection-B8DnjeO8.js} +1 -1
  126. package/dist/client/assets/{use-create-virtual-mcp-ZYI04Bzi.js → use-create-virtual-mcp-7fubOknm.js} +1 -1
  127. package/dist/client/assets/use-deco-chat-open-cMRvRYVG.js +23 -0
  128. package/dist/client/assets/{use-install-from-registry-BjqK8J4_.js → use-install-from-registry-ClVbT6BY.js} +1 -1
  129. package/dist/client/assets/{use-list-state-Df5_sU1e.js → use-list-state-DjV5kR97.js} +1 -1
  130. package/dist/client/assets/use-llm-H-K3anTg.js +1 -0
  131. package/dist/client/assets/{use-mcp-prompts-BJj4NSvO.js → use-mcp-prompts-Chz_2-6S.js} +1 -1
  132. package/dist/client/assets/{use-mcp-tools-iPkyEuZS.js → use-mcp-tools-CXMetymP.js} +1 -1
  133. package/dist/client/assets/{use-mobile-CeOBxwLv.js → use-mobile-B2CDnK8i.js} +1 -1
  134. package/dist/client/assets/{use-organization-settings-Cujgjctm.js → use-organization-settings-Bu92wRjl.js} +1 -1
  135. package/dist/client/assets/{use-project-CxlPVRgR.js → use-project-CzroiUzj.js} +1 -1
  136. package/dist/client/assets/{use-virtual-mcp-Cygajn0x.js → use-virtual-mcp-ayu_K6US.js} +1 -1
  137. package/dist/client/assets/useInfiniteQuery-TqDHdib1.js +1 -0
  138. package/dist/client/assets/{useMutation-BKI7PbLi.js → useMutation-BOrtlNTb.js} +1 -1
  139. package/dist/client/assets/useQuery-DDYln2BW.js +1 -0
  140. package/dist/client/assets/utils-CfR4kXxZ.js +1 -0
  141. package/dist/client/assets/{view-mode-toggle-ShDby2Um.js → view-mode-toggle-CHHKGadJ.js} +1 -1
  142. package/dist/client/assets/{workflow-DYTiP3gR.js → workflow-BBKpGvON.js} +1 -1
  143. package/dist/client/index.html +2 -2
  144. package/dist/server/cli.js +163 -163
  145. package/dist/server/server.js +145 -145
  146. package/package.json +1 -1
  147. package/dist/client/assets/agent-detail-GC8VKbM-.js +0 -1
  148. package/dist/client/assets/collection-detail-DKzQTLe7.js +0 -26
  149. package/dist/client/assets/connection-detail-cZeO4ex7.js +0 -1
  150. package/dist/client/assets/constants-B1JboK54.js +0 -1
  151. package/dist/client/assets/index-C6nYoI1C.css +0 -1
  152. package/dist/client/assets/index-CVO_V2RR.js +0 -1
  153. package/dist/client/assets/index-De7qBXeW.js +0 -25
  154. package/dist/client/assets/members-BIQng2xK.js +0 -3
  155. package/dist/client/assets/page-AjDU3MsS.js +0 -1
  156. package/dist/client/assets/use-deco-chat-open-BYfYydiq.js +0 -23
  157. package/dist/client/assets/useInfiniteQuery-Bx4qsvMB.js +0 -1
  158. package/dist/client/assets/useQuery-DT5IkV6j.js +0 -1
  159. package/dist/client/assets/utils-Ot-eblW7.js +0 -1
@@ -1,3 +0,0 @@
1
- import{r as D,c as le,j as s,p as Jt,u as Ce,g as ae,K as ce,o as Et,ae as at,s as ve,ba as Yt,bg as Xt,v as _e,k as Dt,h as Wt,t as ne,q as es}from"./index-D-FZcOMC.js";import{C as ts,a as ss}from"./collection-table-wrapper-vBjYl8bL.js";import{C as Ke}from"./collection-search-CmrOSxkd.js";import{P as Ne}from"./index-CVO_V2RR.js";import{B as ns,a as rs,b as is,c as os}from"./breadcrumb-BPTkT5qZ.js";import{I as zt,c as Le,b as Re,T as Pe,a as Me}from"./integration-icon-Bf2CRysj.js";import{C as De}from"./checkbox-DOqdhbrT.js";import{B as ie}from"./button-D5ZVigg9.js";import{c as Y}from"./utils-Ot-eblW7.js";import{h as kt}from"./use-connection-DR5puEok.js";import{u as bt,C as ct,a as dt,b as yt,c as ls,d as as,e as cs,f as ds}from"./command-C5xFKb_5.js";import{u as it}from"./useQuery-DT5IkV6j.js";import{u as Te}from"./useMutation-BKI7PbLi.js";import{A as Ae}from"./avatar-BeOUM-c3.js";import{B as Ee}from"./badge-CAqp4wuS.js";import{f as ze,a as ke,b as Ue,c as Ve,d as Ge,e as Be,A as $e,g as Fe}from"./alert-dialog-DvhR6MYa.js";import{D as Ut,f as Vt,a as Gt,b as ms,c as us,e as fs}from"./dialog-Cfe0BARl.js";import{D as Ct,a as jt,b as Tt,c as tt,d as hs,e as gs,f as xs,g as ps}from"./dropdown-menu-XJuOVNha.js";import{i as bs}from"./DotsHorizontal-DGECYgiW.js";import{i as st}from"./Loading01-OQLi83Gk.js";import{i as Cs}from"./Lock01-CFroRX-P.js";import{s as nt}from"./Plus-CamZ25HZ.js";import{s as Bt}from"./Trash01-DoayzMxM.js";import{i as St}from"./X-DjzWAzfl.js";import{I as js}from"./input-CLb5DS9b.js";import{S as Ye}from"./switch-DtIJc9SJ.js";import{E as mt}from"./empty-state-Clfhj5oY.js";import{E as Ts}from"./error-boundary-poUsbtfm.js";import{a as vs,F as It,b as Ot,c as Ns,d as At,f as _t}from"./form-9-Pb579i.js";import{S as ft,a as ht,b as gt,c as xt,d as pt}from"./select-DANNPdpC.js";import{T as Es}from"./textarea-DQgI4KTD.js";import{a as qe,u as Qe}from"./constants-BUYb8__-.js";import{C as wt}from"./card-SJC2htmM.js";import{i as $t}from"./DotsVertical-dEZsGaNC.js";import{i as ys}from"./index-DOa9Uc_j.js";import{s as Ft}from"./XClose-CsbmAiAF.js";import{a as Ss,b as Is,P as Os}from"./popover-Cg1hAh9E.js";import{t as As}from"./ChevronDown-D4GxGIq8.js";import"./ArrowUp-BodxzbKG.js";import"./Check-DKxLmorI.js";import"./Grid01-1H_5bBEp.js";import"./List-3m_qAkQw.js";import"./view-mode-toggle-ShDby2Um.js";import"./table-DjucqeVe.js";import"./SearchMd-CMsT_ewj.js";import"./ChevronRight-c9zV8moh.js";import"./index-CasvHInh.js";const Kt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M19 12H5m0 0 7 7m-7-7 7-7"}));Kt.displayName="ArrowLeft";const vt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M11.302 21.615c.221.129.332.194.488.227.122.026.298.026.42 0 .156-.034.267-.098.488-.227C14.646 20.478 20 16.908 20 12V7.217c0-.799 0-1.199-.13-1.542a2 2 0 0 0-.548-.79c-.275-.243-.65-.383-1.398-.664l-5.362-2.01c-.208-.078-.312-.117-.419-.133a1 1 0 0 0-.286 0c-.107.016-.21.055-.419.133L6.076 4.22c-.748.28-1.122.421-1.398.664a2 2 0 0 0-.547.79C4 6.018 4 6.418 4 7.217V12c0 4.908 5.354 8.478 7.302 9.615Z"}));vt.displayName="Shield01";const qt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M20 17H4m0 0 4-4m-4 4 4 4M4 7h16m0 0-4-4m4 4-4 4"}));qt.displayName="SwitchHorizontal01";const Qt=[{name:"ORGANIZATION_CREATE",description:"Create a new organization",category:"Organizations"},{name:"ORGANIZATION_LIST",description:"List organizations",category:"Organizations"},{name:"ORGANIZATION_GET",description:"View organization details",category:"Organizations"},{name:"ORGANIZATION_UPDATE",description:"Update organization",category:"Organizations"},{name:"ORGANIZATION_DELETE",description:"Delete organization",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_SETTINGS_GET",description:"View organization settings",category:"Organizations"},{name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization settings",category:"Organizations"},{name:"ORGANIZATION_MEMBER_ADD",description:"Add members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove members",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_MEMBER_LIST",description:"List members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update member roles",category:"Organizations"},{name:"COLLECTION_CONNECTIONS_CREATE",description:"Create connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_LIST",description:"List connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_GET",description:"View connection details",category:"Connections"},{name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete connections",category:"Connections",dangerous:!0},{name:"CONNECTION_TEST",description:"Test connections",category:"Connections"},{name:"DATABASES_RUN_SQL",description:"Run SQL queries",category:"Connections",dangerous:!0},{name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_GET",description:"View virtual MCP details",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete virtual MCPs",category:"Virtual MCPs",dangerous:!0},{name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create virtual tools on Virtual MCPs",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List virtual tools",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"View virtual tool details",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update virtual tools",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete virtual tools",category:"Virtual Tools",dangerous:!0},{name:"MONITORING_LOGS_LIST",description:"List monitoring logs",category:"Monitoring"},{name:"MONITORING_STATS",description:"View monitoring statistics",category:"Monitoring"},{name:"API_KEY_CREATE",description:"Create API key",category:"API Keys"},{name:"API_KEY_LIST",description:"List API keys",category:"API Keys"},{name:"API_KEY_UPDATE",description:"Update API key",category:"API Keys"},{name:"API_KEY_DELETE",description:"Delete API key",category:"API Keys",dangerous:!0},{name:"EVENT_PUBLISH",description:"Publish events",category:"Event Bus"},{name:"EVENT_SUBSCRIBE",description:"Subscribe to events",category:"Event Bus"},{name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events",category:"Event Bus"},{name:"EVENT_CANCEL",description:"Cancel recurring events",category:"Event Bus"},{name:"EVENT_ACK",description:"Acknowledge event delivery",category:"Event Bus"},{name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions",category:"Event Bus"},{name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state",category:"Event Bus"},{name:"USER_GET",description:"Get a user by id",category:"Users"},{name:"CODE_EXECUTION_SEARCH_TOOLS",description:"Search available tools by name or description",category:"Code Execution"},{name:"CODE_EXECUTION_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools",category:"Code Execution"},{name:"CODE_EXECUTION_RUN_CODE",description:"Run JavaScript code in a sandbox with tool access",category:"Code Execution",dangerous:!0},{name:"COLLECTION_THREADS_CREATE",description:"Create threads",category:"Threads"},{name:"COLLECTION_THREADS_LIST",description:"List threads",category:"Threads"},{name:"COLLECTION_THREADS_GET",description:"View thread details",category:"Threads"},{name:"COLLECTION_THREADS_UPDATE",description:"Update threads",category:"Threads"},{name:"COLLECTION_THREADS_DELETE",description:"Delete threads",category:"Threads",dangerous:!0},{name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List thread messages",category:"Threads"},{name:"TAGS_LIST",description:"List organization tags",category:"Tags"},{name:"TAGS_CREATE",description:"Create organization tag",category:"Tags"},{name:"TAGS_DELETE",description:"Delete organization tag",category:"Tags",dangerous:!0},{name:"MEMBER_TAGS_GET",description:"Get member tags",category:"Tags"},{name:"MEMBER_TAGS_SET",description:"Set member tags",category:"Tags"},{name:"PROJECT_LIST",description:"List projects in organization",category:"Projects"},{name:"PROJECT_GET",description:"View project details",category:"Projects"},{name:"PROJECT_CREATE",description:"Create new project",category:"Projects"},{name:"PROJECT_UPDATE",description:"Update project",category:"Projects"},{name:"PROJECT_DELETE",description:"Delete project",category:"Projects",dangerous:!0},{name:"PROJECT_PLUGIN_CONFIG_GET",description:"View project plugin configuration",category:"Projects"},{name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update project plugin configuration",category:"Projects"}],_s={ORGANIZATION_CREATE:"Create organization",ORGANIZATION_LIST:"List organizations",ORGANIZATION_GET:"View organization details",ORGANIZATION_UPDATE:"Update organization",ORGANIZATION_DELETE:"Delete organization",ORGANIZATION_SETTINGS_GET:"View organization settings",ORGANIZATION_SETTINGS_UPDATE:"Update organization settings",ORGANIZATION_MEMBER_LIST:"List members",ORGANIZATION_MEMBER_ADD:"Add members",ORGANIZATION_MEMBER_REMOVE:"Remove members",ORGANIZATION_MEMBER_UPDATE_ROLE:"Update member roles",COLLECTION_CONNECTIONS_LIST:"List connections",COLLECTION_CONNECTIONS_GET:"View connection details",COLLECTION_CONNECTIONS_CREATE:"Create connections",COLLECTION_CONNECTIONS_UPDATE:"Update connections",COLLECTION_CONNECTIONS_DELETE:"Delete connections",CONNECTION_TEST:"Test connections",DATABASES_RUN_SQL:"Run SQL queries",COLLECTION_VIRTUAL_MCP_CREATE:"Create virtual MCPs",COLLECTION_VIRTUAL_MCP_LIST:"List virtual MCPs",COLLECTION_VIRTUAL_MCP_GET:"View virtual MCP details",COLLECTION_VIRTUAL_MCP_UPDATE:"Update virtual MCPs",COLLECTION_VIRTUAL_MCP_DELETE:"Delete virtual MCPs",COLLECTION_VIRTUAL_TOOLS_CREATE:"Create virtual tools",COLLECTION_VIRTUAL_TOOLS_LIST:"List virtual tools",COLLECTION_VIRTUAL_TOOLS_GET:"View virtual tool details",COLLECTION_VIRTUAL_TOOLS_UPDATE:"Update virtual tools",COLLECTION_VIRTUAL_TOOLS_DELETE:"Delete virtual tools",MONITORING_LOGS_LIST:"List monitoring logs",MONITORING_STATS:"View monitoring statistics",API_KEY_CREATE:"Create API key",API_KEY_LIST:"List API keys",API_KEY_UPDATE:"Update API key",API_KEY_DELETE:"Delete API key",EVENT_PUBLISH:"Publish events",EVENT_SUBSCRIBE:"Subscribe to events",EVENT_UNSUBSCRIBE:"Unsubscribe from events",EVENT_CANCEL:"Cancel recurring events",EVENT_ACK:"Acknowledge event delivery",EVENT_SUBSCRIPTION_LIST:"List event subscriptions",EVENT_SYNC_SUBSCRIPTIONS:"Sync subscriptions to desired state",USER_GET:"Get user by id",CODE_EXECUTION_SEARCH_TOOLS:"Search tools",CODE_EXECUTION_DESCRIBE_TOOLS:"Describe tools",CODE_EXECUTION_RUN_CODE:"Run code",COLLECTION_THREADS_CREATE:"Create threads",COLLECTION_THREADS_LIST:"List threads",COLLECTION_THREADS_GET:"View thread details",COLLECTION_THREADS_UPDATE:"Update threads",COLLECTION_THREADS_DELETE:"Delete threads",COLLECTION_THREAD_MESSAGES_LIST:"List thread messages",TAGS_LIST:"List organization tags",TAGS_CREATE:"Create organization tag",TAGS_DELETE:"Delete organization tag",MEMBER_TAGS_GET:"Get member tags",MEMBER_TAGS_SET:"Set member tags",PROJECT_LIST:"List projects",PROJECT_GET:"View project details",PROJECT_CREATE:"Create project",PROJECT_UPDATE:"Update project",PROJECT_DELETE:"Delete project",PROJECT_PLUGIN_CONFIG_GET:"View plugin config",PROJECT_PLUGIN_CONFIG_UPDATE:"Update plugin config"};function ws(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],"Virtual Tools":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],"Code Execution":[],Tags:[],Projects:[]};for(const e of Qt)t[e.category]?.push(e);return t}function Ls(){return Qt.map(t=>({value:t.name,label:_s[t.name],dangerous:t.dangerous}))}const Rs=D.memo(function(e){const n=le.c(21),{connection:r,isSelected:l,hasToolsEnabled:o,activeToolsCount:c,totalToolsCount:i,onSelect:u,onToggle:x}=e,m=l?"bg-accent/50":"hover:bg-muted/50";let C;n[0]!==m?(C=Y("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",m),n[0]=m,n[1]=C):C=n[1];let d;n[2]!==r.icon||n[3]!==r.title?(d=s.jsx(zt,{icon:r.icon,name:r.title,size:"xs"}),n[2]=r.icon,n[3]=r.title,n[4]=d):d=n[4];let v;n[5]!==r.title?(v=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:r.title})}),n[5]=r.title,n[6]=v):v=n[6];let g;n[7]!==u||n[8]!==d||n[9]!==v?(g=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:u,children:[d,v]}),n[7]=u,n[8]=d,n[9]=v,n[10]=g):g=n[10];let j;n[11]!==c||n[12]!==r.tools||n[13]!==o||n[14]!==x||n[15]!==i?(j=r.tools&&r.tools.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[c,"/",i]}),s.jsx(De,{checked:o,onCheckedChange:x,onClick:Ds})]}),n[11]=c,n[12]=r.tools,n[13]=o,n[14]=x,n[15]=i,n[16]=j):j=n[16];let b;return n[17]!==C||n[18]!==g||n[19]!==j?(b=s.jsxs("div",{className:C,children:[g,j]}),n[17]=C,n[18]=g,n[19]=j,n[20]=b):b=n[20],b}),Ps=D.memo(function(e){const n=le.c(18),{connectionId:r,tool:l,isSelected:o,onToggle:c}=e,i=`tool-${r}-${l.name}`,u=o?"text-foreground":"text-muted-foreground";let x;n[0]!==u?(x=Y("text-sm font-medium",u),n[0]=u,n[1]=x):x=n[1];let m;n[2]!==x||n[3]!==l.name?(m=s.jsx("div",{className:"flex items-center gap-2 mb-1",children:s.jsx("span",{className:x,children:l.name})}),n[2]=x,n[3]=l.name,n[4]=m):m=n[4];let C;n[5]!==l.description?(C=l.description&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l.description}),n[5]=l.description,n[6]=C):C=n[6];let d;n[7]!==m||n[8]!==C?(d=s.jsxs("div",{className:"flex-1 min-w-0",children:[m,C]}),n[7]=m,n[8]=C,n[9]=d):d=n[9];const v=`tool-${r}-${l.name}`;let g;n[10]!==o||n[11]!==c||n[12]!==v?(g=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(De,{id:v,checked:o,onCheckedChange:c,onClick:zs})}),n[10]=o,n[11]=c,n[12]=v,n[13]=g):g=n[13];let j;return n[14]!==i||n[15]!==d||n[16]!==g?(j=s.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:i,children:[d,g]}),n[14]=i,n[15]=d,n[16]=g,n[17]=j):j=n[17],j});function Ms({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n}){const[r,l]=D.useState(""),o=D.useDeferredValue(r),[c,i]=D.useState("all"),[u,x]=D.useState(!1),m=D.useRef(new Set(Object.keys(t))),C=kt({searchTerm:o.trim()||void 0}),d=n?C.filter(h=>h.connection_type!=="VIRTUAL"?!0:Jt(h.connection_url)!==n):C,v=m.current,g=[...v.values()].map(h=>d.find(S=>S.id===h)).filter(h=>h!==void 0),j=d.filter(h=>!v.has(h.id)),b=[...g,...j],I=h=>{const S=t[h];return S!==void 0&&S.length>0},T=b.filter(h=>{if(c==="all")return!0;const S=I(h.id);return c==="selected"?S:c==="unselected"?!S:!0}),[f,O]=D.useState(b[0]?.id??null),N=f?b.find(h=>h.id===f)??null:null,P=N?.tools??[],A=(h,S)=>t[h]?.includes(S)??!1,R=(h,S)=>{const E=t[h]??[],p=E.includes(S),L={...t};if(p){const k=E.filter(G=>G!==S);k.length===0?delete L[h]:L[h]=k}else L[h]=[...E,S];e(L)},w=h=>{const S=b.find(G=>G.id===h);if(!S?.tools)return;const E=t[h]??[],p=S.tools.map(G=>G.name),L=E.length>0&&p.every(G=>E.includes(G)),k={...t};L?delete k[h]:(k[h]=p,O(h)),e(k)},M=h=>{O(h),x(!0)},_=()=>{x(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:Y("w-full md:w-80 border-r border-border flex flex-col",u&&"hidden md:flex"),children:[s.jsx(Ke,{value:r,onChange:l,placeholder:"Search MCP Servers..."}),s.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[s.jsx("button",{onClick:()=>i("all"),className:Y("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",c==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),s.jsx("button",{onClick:()=>i("selected"),className:Y("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",c==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),s.jsx("button",{onClick:()=>i("unselected"),className:Y("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",c==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:T.length===0?s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:r?"No connections found":c==="selected"?"No servers selected":c==="unselected"?"No unselected servers":"No connections available"}):s.jsx("div",{className:"p-2 space-y-1",children:T.map(h=>{const S=h.tools?.length??0,E=t[h.id]?.length??0;return s.jsx(Rs,{connection:h,isSelected:f===h.id,hasToolsEnabled:I(h.id),activeToolsCount:E,totalToolsCount:S,onSelect:()=>M(h.id),onToggle:()=>w(h.id)},h.id)})})})]}),s.jsx("div",{className:Y("flex-1 flex-col",u?"flex":"hidden md:flex"),children:N?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[s.jsx(ie,{variant:"ghost",size:"sm",onClick:_,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(Kt,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(zt,{icon:N.icon,name:N.title,size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:N.title}),N.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:N.description})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:P.length===0?s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):s.jsx("div",{className:"space-y-2",children:P.map(h=>s.jsx(Ps,{connectionId:N.id,tool:h,isSelected:A(N.id,h.name),onToggle:()=>R(N.id,h.name)},h.name))})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function Ds(t){return t.stopPropagation()}function zs(t){return t.stopPropagation()}const Lt=[{value:"owner",label:"Owner",isBuiltin:!0},{value:"admin",label:"Admin",isBuiltin:!0},{value:"user",label:"User",isBuiltin:!0}];function ks(t){return t.replace(/-/g," ")}function Us(t){if(!t)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1};const e=[];let n=!1;const r=[];let l=!1;const o=new Set;let c=!1;for(const[i,u]of Object.entries(t)){if(i==="self"){u.includes("*")?n=!0:e.push(...u);continue}if(i==="*"){if(l=!0,u.includes("*"))c=!0;else for(const x of u)o.add(x);continue}if(r.push(i),u.includes("*"))c=!0;else for(const x of u)o.add(x)}return{staticPermissions:e,allowsAllStaticPermissions:n,connectionIds:r,allowsAllConnections:l,toolNames:Array.from(o),allowsAllTools:c}}function Nt(){const{locator:t}=Ce(),{data:e,isLoading:n,error:r,refetch:l}=it({queryKey:ce.organizationRoles(t),queryFn:async()=>{try{const i=await ae.organization.listRoles();return i?.error?(console.error("[useOrganizationRoles] API error:",i.error),[]):i?.data??[]}catch(i){return console.error("[useOrganizationRoles] Fetch error:",i),[]}},staleTime:3e4}),o=Lt.map(i=>({role:i.value,label:i.label,isBuiltin:i.isBuiltin}));if(e&&Array.isArray(e))for(const i of e){const u=i.role;if(!u||Lt.some(j=>j.value===u))continue;const{staticPermissions:x,allowsAllStaticPermissions:m,connectionIds:C,allowsAllConnections:d,toolNames:v,allowsAllTools:g}=Us(i.permission);o.push({id:i.id,role:u,label:ks(u),isBuiltin:!1,permission:i.permission??void 0,staticPermissionCount:m?-1:x.length,allowsAllStaticPermissions:m,connectionCount:d?-1:C.length,allowsAllConnections:d,toolCount:g?-1:v.length,allowsAllTools:g})}const c=o.filter(i=>!i.isBuiltin);return{roles:o,customRoles:c,builtinRoles:o.filter(i=>i.isBuiltin),isLoading:n,error:r,refetch:l}}const Vs=Et({role:Et({id:ve().optional(),slug:ve().optional(),label:ve()}),allowAllStaticPermissions:Xt(),staticPermissions:at(ve()),toolSet:Yt(ve(),at(ve())),memberIds:at(ve())});function Ht(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}const Gs=[{role:"owner",label:"Owner",color:"bg-red-500"},{role:"admin",label:"Admin",color:"bg-blue-500"},{role:"user",label:"User",color:"bg-green-500"}],ut=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"];function Bs(t){if(!t)return"bg-neutral-400";let e=0;for(let r=0;r<t.length;r++){const l=t.charCodeAt(r);e=(e<<5)-e+l,e=e&e}const n=Math.abs(e)%ut.length;return ut[n]??ut[0]}function Xe(){return{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},memberIds:[]}}function $s(t){const e=le.c(39),{allowAllStaticPermissions:n,staticPermissions:r,onAllowAllChange:l,onPermissionsChange:o,readOnly:c}=t,i=c===void 0?!1:c,[u,x]=D.useState(""),m=D.useDeferredValue(u);let C,d,v,g,j;if(e[0]!==n||e[1]!==m||e[2]!==l||e[3]!==o||e[4]!==i||e[5]!==u||e[6]!==r){const T=ws(),f=Ls(),O=f.filter(_=>_.label.toLowerCase().includes(m.toLowerCase())),N=_=>{if(r.includes(_))o(r.filter(h=>h!==_));else{const h=[...r,_];h.length===f.length?(l(!0),o([])):o(h)}};v="flex flex-col h-full",e[12]!==u?(g=s.jsx("div",{className:"border-b border-border",children:s.jsx(Ke,{value:u,onChange:x,placeholder:"Search permissions...",className:"border-b-0"})}),e[12]=u,e[13]=g):g=e[13];const P=!i&&"hover:bg-muted/50 cursor-pointer";let A;e[14]!==P?(A=Y("flex items-center justify-between px-4 py-3 rounded-lg",P),e[14]=P,e[15]=A):A=e[15];let R;e[16]!==n||e[17]!==l||e[18]!==o||e[19]!==i?(R=()=>{if(i)return;l(!n),o([])},e[16]=n,e[17]=l,e[18]=o,e[19]=i,e[20]=R):R=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[21]=w):w=e[21];let M;e[22]!==n||e[23]!==l||e[24]!==o||e[25]!==i?(M=s.jsx("div",{onClick:Hs,children:i?s.jsx(Le,{children:s.jsxs(Re,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(Ye,{checked:n,disabled:i,onCheckedChange:_=>{i||(l(_),o([]))}})})}),s.jsx(Me,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Ye,{checked:n,disabled:i,onCheckedChange:_=>{i||(l(_),o([]))}})}),e[22]=n,e[23]=l,e[24]=o,e[25]=i,e[26]=M):M=e[26],e[27]!==M||e[28]!==A||e[29]!==R?(j=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:A,onClick:R,children:[w,M]})}),e[27]=M,e[28]=A,e[29]=R,e[30]=j):j=e[30],C="flex-1 overflow-auto",d=Object.entries(T).map(_=>{const[h,S]=_,E=O.filter(p=>S.some(L=>L.name===p.value));return E.length===0?null:s.jsxs("div",{className:"mb-6 last:mb-0",children:[s.jsx("h4",{className:"text-sm font-medium p-3 pb-1.5 text-muted-foreground/75",children:h}),s.jsx("div",{className:"space-y-1",children:E.map(p=>s.jsxs("div",{className:Y("flex items-center justify-between gap-3 px-4 py-3",!i&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{if(!i)if(n){l(!1);const L=f.map(Qs);o(L.filter(k=>k!==p.value))}else N(p.value)},children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("span",{className:"text-sm",children:p.label})}),s.jsx("div",{onClick:qs,children:i?s.jsx(Le,{children:s.jsxs(Re,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(Ye,{checked:n||r.includes(p.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const L=f.map(Ks);o(L.filter(k=>k!==p.value))}else N(p.value)}})})}),s.jsx(Me,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Ye,{checked:n||r.includes(p.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const L=f.map(Fs);o(L.filter(k=>k!==p.value))}else N(p.value)}})})]},p.value))})]},h)}),e[0]=n,e[1]=m,e[2]=l,e[3]=o,e[4]=i,e[5]=u,e[6]=r,e[7]=C,e[8]=d,e[9]=v,e[10]=g,e[11]=j}else C=e[7],d=e[8],v=e[9],g=e[10],j=e[11];let b;e[31]!==C||e[32]!==d?(b=s.jsx("div",{className:C,children:d}),e[31]=C,e[32]=d,e[33]=b):b=e[33];let I;return e[34]!==v||e[35]!==g||e[36]!==j||e[37]!==b?(I=s.jsxs("div",{className:v,children:[g,j,b]}),e[34]=v,e[35]=g,e[36]=j,e[37]=b,e[38]=I):I=e[38],I}function Fs(t){return t.value}function Ks(t){return t.value}function qs(t){return t.stopPropagation()}function Qs(t){return t.value}function Hs(t){return t.stopPropagation()}function Zs(t){const e=le.c(56),{open:n,onOpenChange:r,selectedMemberIds:l,onAddMembers:o}=t,[c,i]=D.useState(""),u=D.useDeferredValue(c);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0];const[m,C]=D.useState(x),{data:d}=bt();let v,g,j,b,I,T,f,O,N,P,A;if(e[1]!==d?.data?.members||e[2]!==u||e[3]!==o||e[4]!==r||e[5]!==n||e[6]!==m||e[7]!==c||e[8]!==l){const L=d?.data?.members??[];let k;e[20]!==u?(k=U=>{const a=u.toLowerCase();return U.user?.name?.toLowerCase().includes(a)||U.user?.email?.toLowerCase().includes(a)},e[20]=u,e[21]=k):k=e[21];const G=L.filter(k),q=Js;let Q;e[22]!==l?(Q=U=>l.includes(U),e[22]=l,e[23]=Q):Q=e[23];const H=Q;let Z;e[24]!==m?(Z=U=>{m.includes(U)?C(m.filter(a=>a!==U)):C([...m,U])},e[24]=m,e[25]=Z):Z=e[25];const se=Z;let X;e[26]!==o||e[27]!==r||e[28]!==m?(X=()=>{o(m),C([]),r(!1)},e[26]=o,e[27]=r,e[28]=m,e[29]=X):X=e[29],j=X,g=ze,P=n,A=r,v=ke,O="sm:max-w-md p-0 overflow-hidden",e[30]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsxs(Ue,{className:"px-6 pt-6",children:[s.jsx(Ve,{children:"Add Members to Role"}),s.jsx(Ge,{children:"Select members to add to this role."})]}),e[30]=N):N=e[30],T="flex flex-col h-80",e[31]!==c?(f=s.jsx(Ke,{value:c,onChange:i,placeholder:"Search members...",className:"border-b border-t-0 border-x-0 rounded-none"}),e[31]=c,e[32]=f):f=e[32],b="flex-1 overflow-auto",I=G.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:c?"No members found":"No members available"})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:G.map(U=>{const a=q(U),y=H(U.id),F=m.includes(U.id);return s.jsxs("label",{className:Y("flex items-center gap-3 p-2 rounded-lg",!a||y?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(De,{checked:F||y,onCheckedChange:()=>{a&&!y&&se(U.id)},disabled:!a||y}),s.jsx(Ae,{url:U.user?.image??void 0,fallback:Ht(U.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:U.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.user?.email})]}),!a&&s.jsx(Ee,{variant:"secondary",className:"shrink-0",children:"Owner"}),y&&a&&s.jsx(Ee,{variant:"outline",className:"shrink-0",children:"Added"})]},U.id)})}),e[1]=d?.data?.members,e[2]=u,e[3]=o,e[4]=r,e[5]=n,e[6]=m,e[7]=c,e[8]=l,e[9]=v,e[10]=g,e[11]=j,e[12]=b,e[13]=I,e[14]=T,e[15]=f,e[16]=O,e[17]=N,e[18]=P,e[19]=A}else v=e[9],g=e[10],j=e[11],b=e[12],I=e[13],T=e[14],f=e[15],O=e[16],N=e[17],P=e[18],A=e[19];let R;e[33]!==b||e[34]!==I?(R=s.jsx("div",{className:b,children:I}),e[33]=b,e[34]=I,e[35]=R):R=e[35];let w;e[36]!==R||e[37]!==T||e[38]!==f?(w=s.jsxs("div",{className:T,children:[f,R]}),e[36]=R,e[37]=T,e[38]=f,e[39]=w):w=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx($e,{children:"Cancel"}),e[40]=M):M=e[40];const _=m.length===0,h=m.length>0&&`(${m.length})`;let S;e[41]!==j||e[42]!==_||e[43]!==h?(S=s.jsxs(Be,{className:"px-6 pb-6",children:[M,s.jsxs(Fe,{onClick:j,disabled:_,children:["Add ",h]})]}),e[41]=j,e[42]=_,e[43]=h,e[44]=S):S=e[44];let E;e[45]!==v||e[46]!==w||e[47]!==S||e[48]!==O||e[49]!==N?(E=s.jsxs(v,{className:O,children:[N,w,S]}),e[45]=v,e[46]=w,e[47]=S,e[48]=O,e[49]=N,e[50]=E):E=e[50];let p;return e[51]!==g||e[52]!==E||e[53]!==P||e[54]!==A?(p=s.jsx(g,{open:P,onOpenChange:A,children:E}),e[51]=g,e[52]=E,e[53]=P,e[54]=A,e[55]=p):p=e[55],p}function Js(t){return t.role!=="owner"}function Ys(t){const e=le.c(40),{memberIds:n,onMemberIdsChange:r,readOnly:l}=t,o=l===void 0?!1:l,[c,i]=D.useState(""),u=D.useDeferredValue(c),[x,m]=D.useState(!1),{data:C}=bt();let d,v,g,j,b;if(e[0]!==C?.data?.members||e[1]!==u||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==c){const O=C?.data?.members??[];let N;e[11]!==n?(N=E=>n.includes(E.id),e[11]=n,e[12]=N):N=e[12];const P=O.filter(N);let A;e[13]!==u?(A=E=>{const p=u.toLowerCase();return E.user?.name?.toLowerCase().includes(p)||E.user?.email?.toLowerCase().includes(p)},e[13]=u,e[14]=A):A=e[14];const R=P.filter(A);let w;e[15]!==n||e[16]!==r?(w=E=>{r(n.filter(p=>p!==E))},e[15]=n,e[16]=r,e[17]=w):w=e[17];const M=w;let _;e[18]!==n||e[19]!==r?(_=E=>{r([...n,...E])},e[18]=n,e[19]=r,e[20]=_):_=e[20],d=_,j="flex flex-col h-full";let h;e[21]!==c?(h=s.jsx(Ke,{value:c,onChange:i,placeholder:"Search members...",className:"flex-1 border-b-0"}),e[21]=c,e[22]=h):h=e[22];let S;e[23]!==o?(S=o?s.jsx("div",{className:"pr-4",children:s.jsx(Le,{children:s.jsxs(Re,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(nt,{size:16}),"Add Member"]})})}),s.jsx(Me,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})})}):s.jsx("div",{className:"pr-4",children:s.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[s.jsx(nt,{size:16}),"Add Member"]})}),e[23]=o,e[24]=S):S=e[24],e[25]!==h||e[26]!==S?(b=s.jsxs("div",{className:"flex items-center border-b border-border",children:[h,S]}),e[25]=h,e[26]=S,e[27]=b):b=e[27],v="flex-1 overflow-auto",g=P.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No members"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Add members to this role to grant them the configured permissions."})]})}):R.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("p",{className:"text-sm text-muted-foreground",children:['No members match "',c,'"']})}):s.jsx("div",{className:"p-4 space-y-2",children:R.map(E=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(Ae,{url:E.user?.image??void 0,fallback:Ht(E.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:E.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:E.user?.email})]}),o?s.jsx(Le,{children:s.jsxs(Re,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(ie,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(St,{size:16})})})}),s.jsx(Me,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>M(E.id),children:s.jsx(St,{size:16})})]},E.id))}),e[0]=C?.data?.members,e[1]=u,e[2]=n,e[3]=r,e[4]=o,e[5]=c,e[6]=d,e[7]=v,e[8]=g,e[9]=j,e[10]=b}else d=e[6],v=e[7],g=e[8],j=e[9],b=e[10];let I;e[28]!==v||e[29]!==g?(I=s.jsx("div",{className:v,children:g}),e[28]=v,e[29]=g,e[30]=I):I=e[30];let T;e[31]!==x||e[32]!==d||e[33]!==n?(T=s.jsx(Zs,{open:x,onOpenChange:m,selectedMemberIds:n,onAddMembers:d}),e[31]=x,e[32]=d,e[33]=n,e[34]=T):T=e[34];let f;return e[35]!==j||e[36]!==b||e[37]!==I||e[38]!==T?(f=s.jsxs("div",{className:j,children:[b,I,T]}),e[35]=j,e[36]=b,e[37]=I,e[38]=T,e[39]=f):f=e[39],f}function Xs(t){const e=le.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(st,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let r;return e[1]!==t?(r=s.jsx(D.Suspense,{fallback:n,children:s.jsx(Ys,{...t})}),e[1]=t,e[2]=r):r=e[2],r}const Ws={owner:[],admin:[],user:[]};function We(t,e){const n=t==="owner"||t==="admin",r=e.filter(l=>l.role===t);return{role:{slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:n,staticPermissions:Ws[t],toolSet:{},memberIds:r.map(l=>l.id)}}function en({trigger:t,onSuccess:e}){const[n,r]=D.useState(!1),[l,o]=D.useState("mcp"),{locator:c}=Ce(),i=_e(),u=kt()??[],{customRoles:x,refetch:m}=Nt(),{data:C}=it({queryKey:ce.members(c),queryFn:()=>ae.organization.listMembers()}),d=Dt({resolver:Wt(Vs),defaultValues:Xe()}),v=d.formState.isValid,g=d.formState.isDirty,[j,b]=D.useState(null),[I,T]=D.useState(null),f=!d.watch("role.id")&&!d.watch("role.slug")&&!I,[O,N]=D.useState(null),[P,A]=D.useState(!1),[R,w]=D.useState(null),M=a=>{const y=a.permission||{},F=y.self||[],me=F.includes("*"),te=me?[]:F.filter(V=>V!=="*"),W={};for(const[V,B]of Object.entries(y))if(V!=="self")if(V==="*")for(const J of u)B.includes("*")?W[J.id]=J.tools?.map(re=>re.name)??[]:W[J.id]=B;else{const J=u.find(re=>re.id===V);J&&(B.includes("*")?W[V]=J.tools?.map(re=>re.name)??[]:W[V]=B)}const de=(C?.data?.members??[]).filter(V=>V.role===a.role).map(V=>V.id);return{role:{id:a.id,slug:a.role,label:a.label},allowAllStaticPermissions:me,staticPermissions:te,toolSet:W,memberIds:de}},_=a=>{const y=M(a);d.reset(y),b(a.id??null),T(null)},h=()=>{d.reset(Xe()),b(null),T(null),o("mcp")},S=a=>{g&&v?(w(()=>()=>_(a)),A(!0)):_(a)},E=async()=>{g&&v&&await Z(),h()},p=a=>{if(g&&v)w(()=>()=>{const y=We(a,C?.data?.members??[]);d.reset(y),T(a),b(null),o("org")}),A(!0);else{const y=We(a,C?.data?.members??[]);d.reset(y),T(a),b(null),o("org")}},L=a=>{if(!a&&d.formState.isDirty&&v){w(()=>()=>{r(!1),d.reset(Xe()),T(null)}),A(!0);return}if(r(a),!a)d.reset(Xe()),T(null),b(null);else{const y=x[0];if(y)_(y);else{const F=We("user",C?.data?.members??[]);d.reset(F),T("user"),b(null),o("org")}}},k=()=>{A(!1),R&&(R(),w(null))},G=a=>{const y={};a.allowAllStaticPermissions?y.self=["*"]:a.staticPermissions.length>0&&(y.self=a.staticPermissions);for(const[F,me]of Object.entries(a.toolSet))if(me.length>0){const W=u.find(ee=>ee.id===F)?.tools?.map(ee=>ee.name)??[];W.length>0&&W.every(ee=>me.includes(ee))?y[F]=["*"]:y[F]=me}return y},q=Te({mutationFn:async a=>{const y=G(a),F=a.role.slug||a.role.label.toLowerCase().replace(/\s+/g,"-");if(a.role.slug&&!a.role.id){const W=(C?.data?.members??[]).filter(V=>V.role===a.role.slug).map(V=>V.id),ee=a.memberIds.filter(V=>!W.includes(V)),de=W.filter(V=>!a.memberIds.includes(V));for(const V of ee){const B=await ae.organization.updateMemberRole({memberId:V,role:[a.role.slug]});if(B?.error)throw new Error(B.error.message)}for(const V of de){const B=await ae.organization.updateMemberRole({memberId:V,role:["user"]});if(B?.error)throw new Error(B.error.message)}return a}else if(a.role.id){const te=await ae.organization.updateRole({roleId:a.role.id,data:{permission:y}});if(te?.error)throw new Error(te.error.message);const ee=(C?.data?.members??[]).filter(B=>B.role===a.role.slug).map(B=>B.id),de=a.memberIds.filter(B=>!ee.includes(B)),V=ee.filter(B=>!a.memberIds.includes(B));for(const B of de){const J=await ae.organization.updateMemberRole({memberId:B,role:[a.role.slug]});if(J?.error)throw new Error(J.error.message)}for(const B of V){const J=await ae.organization.updateMemberRole({memberId:B,role:["user"]});if(J?.error)throw new Error(J.error.message)}return a}else{const te=await ae.organization.createRole({role:F,permission:y});if(te?.error)throw new Error(te.error.message);for(const W of a.memberIds){const ee=await ae.organization.updateMemberRole({memberId:W,role:[F]});if(ee?.error)throw new Error(ee.error.message)}return{...a,role:{...a.role,id:te.data?.roleData?.id,slug:F}}}},onSuccess:(a,y)=>{i.invalidateQueries({queryKey:ce.members(c)}),i.invalidateQueries({queryKey:ce.organizationRoles(c)});const F=!y.role.id&&!y.role.slug,me=y.role.slug&&!y.role.id;ne.success(me?"Members updated successfully!":F?"Role created successfully!":"Role updated successfully!"),m(),d.reset(a),a.role.id&&b(a.role.id),e?.()},onError:a=>{ne.error(a instanceof Error?a.message:"Failed to save role")}}),Q=Te({mutationFn:async a=>{const y=await ae.organization.deleteRole({roleId:a});if(y?.error)throw new Error(y.error.message);return y?.data},onSuccess:()=>{if(i.invalidateQueries({queryKey:ce.members(c)}),i.invalidateQueries({queryKey:ce.organizationRoles(c)}),ne.success("Role deleted successfully!"),m(),O?.id===j){const a=x.filter(y=>y.id!==O?.id);if(a[0])_(a[0]);else{const y=We("user",C?.data?.members??[]);d.reset(y),T("user"),b(null),o("org")}}},onError:a=>{ne.error(a instanceof Error?a.message:"Failed to delete role")}}),H=q.isPending||Q.isPending,Z=async()=>{const a=d.getValues();if(!a.role.label.trim()){ne.error("Role name is required"),d.setFocus("role.label");return}await q.mutateAsync(a)},se=d.handleSubmit(a=>{if(!a.role.label.trim()){ne.error("Role name is required"),d.setFocus("role.label");return}q.mutate(a)}),X=a=>{a.id&&N({id:a.id,label:a.label})},U=()=>{O?.id&&Q.mutate(O.id),N(null)};return s.jsxs(Ut,{open:n,onOpenChange:L,children:[s.jsx(Vt,{asChild:!0,children:t}),s.jsx(Gt,{className:"sm:max-w-5xl h-[80vh] max-h-[80vh] flex flex-col p-0 overflow-hidden w-[95vw]",children:s.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 flex-col sm:flex-row",children:[s.jsxs("div",{className:"w-full sm:w-64 sm:border-r border-b sm:border-b-0 border-border flex flex-col bg-background sm:h-full max-h-[40vh] sm:max-h-full",children:[s.jsx("div",{className:"flex-1 overflow-auto px-3.5 py-3.5 pt-3.5",children:s.jsxs("div",{className:"flex flex-col gap-1",children:[Gs.map(a=>{const y=I===a.role;return s.jsxs("div",{className:Y("flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden cursor-pointer transition-colors",y?"bg-accent":"hover:bg-muted/50"),onClick:()=>p(a.role),children:[s.jsx("div",{className:Y("shrink-0 size-3 rounded-full",a.color)}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:a.label}),s.jsx(Cs,{size:14,className:"text-muted-foreground shrink-0"})]},a.role)}),x.map(a=>{const y=j===a.id;return s.jsxs("div",{className:Y("group flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden transition-colors cursor-pointer",y?"bg-accent":"hover:bg-muted/50"),onClick:()=>S(a),children:[s.jsx("div",{className:Y("shrink-0 size-3 rounded-full",Bs(a.label))}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:a.label}),s.jsxs(Ct,{children:[s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"icon",className:Y("size-5 shrink-0 transition-opacity opacity-0 pointer-events-none","group-hover:opacity-100 group-hover:pointer-events-auto",y&&"opacity-100 pointer-events-auto"),onClick:F=>F.stopPropagation(),children:s.jsx(bs,{size:14})})}),s.jsx(Tt,{align:"end",children:s.jsxs(tt,{className:"text-destructive",onClick:F=>{F.stopPropagation(),X(a)},children:[s.jsx(Bt,{size:16}),"Delete"]})})]})]},a.id)}),f&&s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden bg-accent",children:[s.jsx("div",{className:"shrink-0 size-3 rounded-full bg-neutral-400"}),s.jsx(js,{...d.register("role.label"),placeholder:"Enter role name",className:"flex-1 text-sm font-medium border-0 shadow-none h-auto px-0 py-0 focus-visible:ring-0 bg-transparent",autoFocus:!0}),s.jsx(Ee,{variant:"secondary",className:"shrink-0 text-xs px-1.5 py-0",children:"New"})]})]})}),s.jsx("div",{className:"px-3.5 pb-3.5",children:s.jsxs(ie,{variant:"outline",size:"default",onClick:E,disabled:H||g,className:"w-full h-10",children:[s.jsx(nt,{size:16}),"Create new role"]})})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.jsxs("div",{className:"h-12 border-b border-border px-4 py-3.5 flex items-center gap-2 shrink-0",children:[!I&&s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("mcp"),className:Y("h-7 rounded-lg px-2 border border-input transition-colors",l==="mcp"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"MCP Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("org"),className:Y("h-7 rounded-lg px-2 border border-input transition-colors",l==="org"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Organization Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("members"),className:Y("h-7 rounded-lg px-2 border border-input transition-colors",l==="members"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Members"})]}),s.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[l==="mcp"&&!I&&s.jsx(Ms,{toolSet:d.watch("toolSet"),onToolSetChange:a=>d.setValue("toolSet",a,{shouldDirty:!0})}),l==="org"&&s.jsx($s,{allowAllStaticPermissions:d.watch("allowAllStaticPermissions"),staticPermissions:d.watch("staticPermissions"),onAllowAllChange:a=>d.setValue("allowAllStaticPermissions",a,{shouldDirty:!0}),onPermissionsChange:a=>d.setValue("staticPermissions",a,{shouldDirty:!0}),readOnly:!!I}),l==="members"&&s.jsx(Xs,{memberIds:d.watch("memberIds"),onMemberIdsChange:a=>d.setValue("memberIds",a,{shouldDirty:!0}),readOnly:I==="owner"})]}),(!I||I!=="owner")&&s.jsxs("div",{className:"border-t border-border px-5 py-5 flex items-center justify-end gap-2.5 shrink-0",children:[s.jsx(ie,{variant:"outline",onClick:()=>L(!1),disabled:H,className:"h-10",children:"Cancel"}),s.jsx(ie,{onClick:se,disabled:H||!v||!d.formState.isDirty,className:"h-10",children:q.isPending?"Saving...":f?"Create Role":"Save Changes"})]})]})]})}),s.jsx(ze,{open:O!==null,onOpenChange:a=>!a&&N(null),children:s.jsxs(ke,{children:[s.jsxs(Ue,{children:[s.jsx(Ve,{children:"Delete Role"}),s.jsxs(Ge,{children:['Are you sure you want to delete the "',O?.label,'" role? This action cannot be undone.']})]}),s.jsxs(Be,{children:[s.jsx($e,{children:"Cancel"}),s.jsx(Fe,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s.jsx(ze,{open:P,onOpenChange:A,children:s.jsxs(ke,{children:[s.jsxs(Ue,{children:[s.jsx(Ve,{children:"Discard Changes"}),s.jsx(Ge,{children:"You have unsaved changes. Are you sure you want to discard them?"})]}),s.jsxs(Be,{children:[s.jsx($e,{onClick:()=>w(null),children:"Keep Editing"}),s.jsx(Fe,{onClick:k,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Discard"})]})]})})]})}const tn=ve().email("Invalid email address");function sn(t){if(!t.trim())return[];const e=t.split(/[,;\n]/).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(e))}function nn({trigger:t}){const[e,n]=D.useState(!1),{locator:r}=Ce(),l=_e(),{data:o}=ae.useSession(),c=o?.user?.email,{roles:i,isLoading:u}=Nt(),x=i.filter(T=>T.role!=="owner"),m=Dt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),C=m.watch("emailsText"),d=m.watch("role"),g=sn(C).filter(T=>{const f=tn.safeParse(T).success,O=!c||T!==c.toLowerCase();return f&&O}),j=Te({mutationFn:async({emails:T,role:f})=>{if(!f)throw new Error("Please select a role");const O=await Promise.allSettled(T.map(async P=>{const A=await ae.organization.inviteMember({email:P,role:f});if(A.error)throw new Error(A.error.message);return A.data})),N=O.filter(P=>P.status==="rejected");if(N.length>0)throw new Error(`Failed to invite ${N.length} member${N.length>1?"s":""}`);return O},onSuccess:(T,{emails:f})=>{l.invalidateQueries({queryKey:ce.members(r)}),l.invalidateQueries({queryKey:ce.invitations(r)}),ne.success(f.length===1?"Member invited successfully!":`${f.length} members invited successfully!`),m.reset({emailsText:"",role:"user"}),n(!1)},onError:T=>{ne.error(T instanceof Error?T.message:"Failed to invite members")}}),b=T=>{if(g.length===0){ne.error("Please enter at least one valid email address");return}if(!T.role){ne.error("Please select a role");return}j.mutate({emails:g,role:T.role})},I=g.length>0&&!!d;return s.jsxs(Ut,{open:e,onOpenChange:n,children:[s.jsx(Vt,{asChild:!0,children:t}),s.jsxs(Gt,{className:"sm:max-w-lg",children:[s.jsx(ms,{children:s.jsx(us,{children:"Invite members"})}),s.jsx(vs,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(b),className:"space-y-4",children:[s.jsx(It,{control:m.control,name:"emailsText",render:({field:T})=>s.jsxs(Ot,{children:[s.jsx(Ns,{children:"Email addresses"}),s.jsx(At,{children:s.jsx(Es,{...T,disabled:j.isPending,placeholder:`Enter email addresses separated by commas or new lines
2
- e.g. user1@example.com, user2@example.com
3
- or one per line`,className:"min-h-[120px] resize-none"})}),s.jsx(_t,{})]})}),s.jsx(It,{control:m.control,name:"role",render:({field:T})=>s.jsxs(Ot,{children:[s.jsx(At,{children:s.jsxs(ft,{value:T.value,onValueChange:T.onChange,disabled:j.isPending||u,children:[s.jsx(ht,{className:"w-full",children:s.jsx(gt,{placeholder:"Select a role"})}),s.jsx(xt,{children:x.map(f=>{const O=[];return f.isBuiltin||(f.allowsAllStaticPermissions?O.push("Full org access"):f.staticPermissionCount&&f.staticPermissionCount>0&&O.push(`${f.staticPermissionCount} org perm${f.staticPermissionCount!==1?"s":""}`),f.allowsAllConnections?O.push("All connections"):f.connectionCount&&f.connectionCount>0&&O.push(`${f.connectionCount} connection${f.connectionCount!==1?"s":""}`),(f.connectionCount!==0||f.allowsAllConnections)&&(f.allowsAllTools?O.push("all tools"):f.toolCount&&f.toolCount>0&&O.push(`${f.toolCount} tool${f.toolCount!==1?"s":""}`))),s.jsx(pt,{value:f.role,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:f.label}),!f.isBuiltin&&O.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:O.join(", ")})]})},f.role)})})]})}),s.jsx(_t,{})]})}),s.jsxs(fs,{children:[s.jsx(ie,{variant:"outline",onClick:()=>{m.reset({emailsText:"",role:"user"}),n(!1)},type:"button",disabled:j.isPending,children:"Cancel"}),s.jsx(ie,{type:"submit",disabled:j.isPending||!I,children:j.isPending?"Inviting...":`Invite ${g.length||0} Member${g.length!==1?"s":""}`})]})]})})]})]})}function rn(){const t=le.c(9),{org:e,locator:n}=Ce();let r;t[0]!==e.id?(r={connectionId:qe,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const l=Qe(r);let o;t[2]!==n?(o=ce.invitations(n),t[2]=n,t[3]=o):o=t[3];let c;t[4]!==l?(c=async()=>{const u=await l.callTool({name:"ORGANIZATION_GET",arguments:{}});return(u.structuredContent??u)?.invitations??[]},t[4]=l,t[5]=c):c=t[5];let i;return t[6]!==o||t[7]!==c?(i={queryKey:o,queryFn:c},t[6]=o,t[7]=c,t[8]=i):i=t[8],es(i)}function on(){const t=le.c(5),{locator:e}=Ce(),n=_e();let r;t[0]!==e||t[1]!==n?(r={mutationFn:an,onSuccess:()=>{n.invalidateQueries({queryKey:ce.invitations(e)}),ne.success("Invitation cancelled")},onError:ln},t[0]=e,t[1]=n,t[2]=r):r=t[2];const l=Te(r);let o;return t[3]!==l?(o={cancel:l},t[3]=l,t[4]=o):o=t[4],o}function ln(t){ne.error(t instanceof Error?t.message:"Failed to cancel invitation")}async function an(t){const e=await ae.organization.cancelInvitation({invitationId:t});if(e?.error)throw new Error(e.error.message);return e.data}function cn(){const t=le.c(9),{org:e,locator:n}=Ce();let r;t[0]!==e.id?(r={connectionId:qe,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const l=Qe(r);let o;t[2]!==n?(o=ce.tags(n),t[2]=n,t[3]=o):o=t[3];let c;t[4]!==l?(c=async()=>{const u=await l.callTool({name:"TAGS_LIST",arguments:{}});return(u.structuredContent??u).tags},t[4]=l,t[5]=c):c=t[5];let i;return t[6]!==o||t[7]!==c?(i={queryKey:o,queryFn:c,staleTime:3e4},t[6]=o,t[7]=c,t[8]=i):i=t[8],it(i)}function dn(){const t=le.c(10),e=_e(),{org:n,locator:r}=Ce();let l;t[0]!==n.id?(l={connectionId:qe,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const o=Qe(l);let c;t[2]!==o?(c=async x=>{const m=await o.callTool({name:"TAGS_CREATE",arguments:{name:x}});return(m.structuredContent??m).tag},t[2]=o,t[3]=c):c=t[3];let i;t[4]!==r||t[5]!==e?(i=()=>{e.invalidateQueries({queryKey:ce.tags(r)})},t[4]=r,t[5]=e,t[6]=i):i=t[6];let u;return t[7]!==c||t[8]!==i?(u={mutationFn:c,onSuccess:i,onError:mn},t[7]=c,t[8]=i,t[9]=u):u=t[9],Te(u)}function mn(t){ne.error(t instanceof Error?t.message:"Failed to create tag")}function un(t){const e=le.c(12),{org:n,locator:r}=Ce();let l;e[0]!==n.id?(l={connectionId:qe,orgId:n.id},e[0]=n.id,e[1]=l):l=e[1];const o=Qe(l);let c;e[2]!==r||e[3]!==t?(c=ce.memberTags(r,t),e[2]=r,e[3]=t,e[4]=c):c=e[4];let i;e[5]!==o||e[6]!==t?(i=async()=>{const m=await o.callTool({name:"MEMBER_TAGS_GET",arguments:{memberId:t}});return(m.structuredContent??m).tags},e[5]=o,e[6]=t,e[7]=i):i=e[7];const u=!!t;let x;return e[8]!==c||e[9]!==i||e[10]!==u?(x={queryKey:c,queryFn:i,staleTime:3e4,enabled:u},e[8]=c,e[9]=i,e[10]=u,e[11]=x):x=e[11],it(x)}function fn(){const t=le.c(10),e=_e(),{org:n,locator:r}=Ce();let l;t[0]!==n.id?(l={connectionId:qe,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const o=Qe(l);let c;t[2]!==o?(c=async x=>{const{memberId:m,tagIds:C}=x,d=await o.callTool({name:"MEMBER_TAGS_SET",arguments:{memberId:m,tagIds:C}});return d.structuredContent??d},t[2]=o,t[3]=c):c=t[3];let i;t[4]!==r||t[5]!==e?(i=(x,m)=>{e.invalidateQueries({queryKey:ce.memberTags(r,m.memberId)})},t[4]=r,t[5]=e,t[6]=i):i=t[6];let u;return t[7]!==c||t[8]!==i?(u={mutationFn:c,onSuccess:i,onError:hn},t[7]=c,t[8]=i,t[9]=u):u=t[9],Te(u)}function hn(t){ne.error(t instanceof Error?t.message:"Failed to update member tags")}function Zt(t){const e=le.c(44),{memberId:n,className:r,disabled:l,placeholder:o,maxDisplay:c}=t,i=l===void 0?!1:l,u=o===void 0?"Add tags...":o,x=c===void 0?2:c,[m,C]=D.useState(!1),[d,v]=D.useState(""),{data:g,isLoading:j}=cn(),b=g===void 0?[]:g,{data:I,isLoading:T}=un(n),f=I===void 0?[]:I,O=dn(),N=fn(),P=j||T,A=f.map(xn);let R;e[0]!==d?(R=K=>K.name.toLowerCase().includes(d.toLowerCase()),e[0]=d,e[1]=R):R=e[1];const w=b.filter(R);let M;e[2]!==d?(M=K=>K.name.toLowerCase()===d.toLowerCase(),e[2]=d,e[3]=M):M=e[3];const _=b.find(M),h=d.trim()&&!_,S=async K=>{const be=A.includes(K.id)?A.filter(ye=>ye!==K.id):[...A,K.id];await N.mutateAsync({memberId:n,tagIds:be})},E=async()=>{if(!d.trim())return;const K=await O.mutateAsync(d.trim());await N.mutateAsync({memberId:n,tagIds:[...A,K.id]}),v("")},p=async K=>{const ge=A.filter(be=>be!==K);await N.mutateAsync({memberId:n,tagIds:ge})},L=O.isPending||N.isPending,k=Is;let G;e[4]!==m?(G=()=>C(!m),e[4]=m,e[5]=G):G=e[5];let q;e[6]!==r?(q=Y("h-auto min-h-8 px-2 py-1 justify-start font-normal","hover:bg-accent/50",r),e[6]=r,e[7]=q):q=e[7];const Q=i||P,H=P?s.jsx(st,{size:14,className:"animate-spin text-muted-foreground"}):f.length>0?s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[f.slice(0,x).map(gn),f.length>x&&s.jsxs(Ee,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:["+",f.length-x]})]}):s.jsx("span",{className:"text-muted-foreground text-xs",children:u});let Z;e[8]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(As,{size:14,className:"ml-1 shrink-0 opacity-50"}),e[8]=Z):Z=e[8];let se;e[9]!==Q||e[10]!==H||e[11]!==G||e[12]!==q?(se=s.jsx(Os,{asChild:!0,children:s.jsxs(ie,{variant:"ghost",size:"sm",onClick:G,className:q,disabled:Q,children:[H,Z]})}),e[9]=Q,e[10]=H,e[11]=G,e[12]=q,e[13]=se):se=e[13];const X=Ss,U="w-56 p-0",a="start";let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=()=>C(!1),e[14]=y):y=e[14];const F=cs,me=!1;let te;e[15]!==d?(te=s.jsx(ds,{placeholder:"Search or create...",value:d,onValueChange:v,className:"h-9"}),e[15]=d,e[16]=te):te=e[16];const W=as,ee=f.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{heading:"Selected",children:f.map(K=>s.jsx(dt,{onSelect:()=>S(K),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(De,{checked:!0,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:K.name})]}),s.jsx("button",{onClick:ge=>{ge.stopPropagation(),p(K.id)},className:"opacity-50 hover:opacity-100",disabled:L,children:s.jsx(Ft,{size:14})})]})},K.id))}),s.jsx(yt,{})]}),de=ct,V="Available",B=w.length===0&&!h&&s.jsx(ls,{children:"No tags found."}),J=w.filter(K=>!A.includes(K.id)).map(K=>s.jsx(dt,{onSelect:()=>S(K),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(De,{checked:!1,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:K.name})]})},K.id));let re;e[17]!==de||e[18]!==B||e[19]!==J?(re=s.jsxs(de,{heading:V,children:[B,J]}),e[17]=de,e[18]=B,e[19]=J,e[20]=re):re=e[20];let ue;e[21]!==E||e[22]!==L||e[23]!==d||e[24]!==h?(ue=h&&s.jsxs(s.Fragment,{children:[s.jsx(yt,{}),s.jsx(ct,{children:s.jsx(dt,{onSelect:E,className:"cursor-pointer",disabled:L,children:s.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[L?s.jsx(st,{size:14,className:"animate-spin"}):s.jsx(nt,{size:14}),s.jsxs("span",{children:['Create "',d.trim(),'"']})]})})})]}),e[21]=E,e[22]=L,e[23]=d,e[24]=h,e[25]=ue):ue=e[25];let pe;e[26]!==W||e[27]!==ee||e[28]!==re||e[29]!==ue?(pe=s.jsxs(W,{children:[ee,re,ue]}),e[26]=W,e[27]=ee,e[28]=re,e[29]=ue,e[30]=pe):pe=e[30];let fe;e[31]!==F||e[32]!==te||e[33]!==pe?(fe=s.jsxs(F,{shouldFilter:me,children:[te,pe]}),e[31]=F,e[32]=te,e[33]=pe,e[34]=fe):fe=e[34];let he;e[35]!==X||e[36]!==y||e[37]!==fe?(he=s.jsx(X,{className:U,align:a,onEscapeKeyDown:y,children:fe}),e[35]=X,e[36]=y,e[37]=fe,e[38]=he):he=e[38];let je;return e[39]!==k||e[40]!==m||e[41]!==se||e[42]!==he?(je=s.jsxs(k,{open:m,onOpenChange:C,children:[se,he]}),e[39]=k,e[40]=m,e[41]=se,e[42]=he,e[43]=je):je=e[43],je}function gn(t){return s.jsx(Ee,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:t.name},t.id)}function xn(t){return t.id}const Rt=["bg-neutral-400","bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500","bg-slate-500"],pn={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function rt(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function bn(t){const e=new Map;for(const[n,r]of Object.entries(pn))e.set(n,r);for(let n=0;n<t.length;n++){const r=t[n];r&&!e.has(r.role)&&e.set(r.role,Rt[n%Rt.length]??"bg-neutral-400")}return e}function Cn(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function et(t){const e=le.c(79),{role:n,memberId:r,isOwner:l,roleColorMap:o,selectableRoles:c,onRoleChange:i,size:u,className:x}=t,m=u===void 0?"xs":u;let C,d,v,g,j,b,I,T,f,O,N;if(e[0]!==x||e[1]!==l||e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==c||e[7]!==m){N=Symbol.for("react.early_return_sentinel");e:{const E=o.get(n)??"bg-neutral-400";if(l){let p;e[19]!==r||e[20]!==i?(p=U=>i(r,U),e[19]=r,e[20]=i,e[21]=p):p=e[21];let L;e[22]!==n?(L=s.jsx("span",{className:"capitalize truncate",children:n}),e[22]=n,e[23]=L):L=e[23];const k=s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:Y("size-2 rounded-full shrink-0",E)}),L]});let G;e[24]!==k?(G=s.jsx(gt,{children:k}),e[24]=k,e[25]=G):G=e[25];let q;e[26]!==x||e[27]!==m||e[28]!==G?(q=s.jsx(ht,{size:m,className:x,children:G}),e[26]=x,e[27]=m,e[28]=G,e[29]=q):q=e[29];let Q;if(e[30]!==o||e[31]!==c){let U;e[33]!==o?(U=a=>{const y=o.get(a.role)??"bg-neutral-400";return s.jsx(pt,{value:a.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:Y("size-3 rounded-full",y)}),s.jsx("span",{className:"capitalize",children:a.label})]})},a.role)},e[33]=o,e[34]=U):U=e[34],Q=c.map(U),e[30]=o,e[31]=c,e[32]=Q}else Q=e[32];let H;e[35]!==Q?(H=s.jsx(xt,{children:Q}),e[35]=Q,e[36]=H):H=e[36];let Z;e[37]!==l||e[38]!==n||e[39]!==p||e[40]!==q||e[41]!==H?(Z=s.jsx(Pe,{asChild:!0,children:s.jsx("div",{className:"w-fit",children:s.jsxs(ft,{value:n,onValueChange:p,disabled:l,children:[q,H]})})}),e[37]=l,e[38]=n,e[39]=p,e[40]=q,e[41]=H,e[42]=Z):Z=e[42];let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(Me,{children:s.jsx("p",{children:"The owner role cannot be changed"})}),e[43]=se):se=e[43];let X;e[44]!==Z?(X=s.jsx(Le,{children:s.jsxs(Re,{children:[Z,se]})}),e[44]=Z,e[45]=X):X=e[45],N=X;break e}v=ft,T=n,e[46]!==r||e[47]!==i?(f=p=>i(r,p),e[46]=r,e[47]=i,e[48]=f):f=e[48],O=l,d=ht,b=m,I=x,C=gt,j="flex items-center gap-2 min-w-0",g=Y("size-2 rounded-full shrink-0",E)}e[0]=x,e[1]=l,e[2]=r,e[3]=i,e[4]=n,e[5]=o,e[6]=c,e[7]=m,e[8]=C,e[9]=d,e[10]=v,e[11]=g,e[12]=j,e[13]=b,e[14]=I,e[15]=T,e[16]=f,e[17]=O,e[18]=N}else C=e[8],d=e[9],v=e[10],g=e[11],j=e[12],b=e[13],I=e[14],T=e[15],f=e[16],O=e[17],N=e[18];if(N!==Symbol.for("react.early_return_sentinel"))return N;let P;e[49]!==g?(P=s.jsx("div",{className:g}),e[49]=g,e[50]=P):P=e[50];let A;e[51]!==n?(A=s.jsx("span",{className:"capitalize truncate",children:n}),e[51]=n,e[52]=A):A=e[52];let R;e[53]!==P||e[54]!==A||e[55]!==j?(R=s.jsxs("div",{className:j,children:[P,A]}),e[53]=P,e[54]=A,e[55]=j,e[56]=R):R=e[56];let w;e[57]!==C||e[58]!==R?(w=s.jsx(C,{children:R}),e[57]=C,e[58]=R,e[59]=w):w=e[59];let M;e[60]!==d||e[61]!==w||e[62]!==b||e[63]!==I?(M=s.jsx(d,{size:b,className:I,children:w}),e[60]=d,e[61]=w,e[62]=b,e[63]=I,e[64]=M):M=e[64];let _;if(e[65]!==o||e[66]!==c){let E;e[68]!==o?(E=p=>{const L=o.get(p.role)??"bg-neutral-400";return s.jsx(pt,{value:p.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:Y("size-3 rounded-full",L)}),s.jsx("span",{className:"capitalize",children:p.label})]})},p.role)},e[68]=o,e[69]=E):E=e[69],_=c.map(E),e[65]=o,e[66]=c,e[67]=_}else _=e[67];let h;e[70]!==_?(h=s.jsx(xt,{children:_}),e[70]=_,e[71]=h):h=e[71];let S;return e[72]!==v||e[73]!==M||e[74]!==h||e[75]!==T||e[76]!==f||e[77]!==O?(S=s.jsxs(v,{value:T,onValueChange:f,disabled:O,children:[M,h]}),e[72]=v,e[73]=M,e[74]=h,e[75]=T,e[76]=f,e[77]=O,e[78]=S):S=e[78],S}function Pt(t){const e=le.c(51),{member:n,roles:r,onChangeRole:l,onRemove:o,isUpdating:c}=t,i=c===void 0?!1:c,u=n.role==="owner";let x,m,C,d,v,g,j,b,I;if(e[0]!==u||e[1]!==i||e[2]!==n.id||e[3]!==n.role||e[4]!==l||e[5]!==r){let M;e[15]!==n.role?(M=p=>p.role!==n.role&&p.role!=="owner",e[15]=n.role,e[16]=M):M=e[16];const _=r.filter(M);d=Ct;let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx($t,{size:20}),e[17]=h):h=e[17],e[18]!==u?(I=s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:u,onClick:Tn,children:h})}),e[18]=u,e[19]=I):I=e[19],C=Tt,j="end",b=jn,m=hs;let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(qt,{size:16}),e[20]=S):S=e[20],e[21]!==i?(g=s.jsxs(gs,{disabled:i,children:[S,"Change Role"]}),e[21]=i,e[22]=g):g=e[22],x=xs;let E;e[23]!==i||e[24]!==n.id||e[25]!==l?(E=p=>{const L=[];return p.isBuiltin||(p.allowsAllStaticPermissions?L.push("Full org access"):p.staticPermissionCount&&p.staticPermissionCount>0&&L.push(`${p.staticPermissionCount} org perm${p.staticPermissionCount!==1?"s":""}`),p.allowsAllConnections?L.push("All connections"):p.connectionCount&&p.connectionCount>0&&L.push(`${p.connectionCount} connection${p.connectionCount!==1?"s":""}`),(p.connectionCount!==0||p.allowsAllConnections)&&(p.allowsAllTools?L.push("all tools"):p.toolCount&&p.toolCount>0&&L.push(`${p.toolCount} tool${p.toolCount!==1?"s":""}`))),s.jsxs(tt,{onClick:k=>{k.stopPropagation(),l(n.id,p.role)},disabled:i,children:[p.isBuiltin?s.jsx(vt,{size:16}):s.jsx(ys,{size:16}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:p.label}),!p.isBuiltin&&L.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:L.join(", ")})]})]},p.role)},e[23]=i,e[24]=n.id,e[25]=l,e[26]=E):E=e[26],v=_.map(E),e[0]=u,e[1]=i,e[2]=n.id,e[3]=n.role,e[4]=l,e[5]=r,e[6]=x,e[7]=m,e[8]=C,e[9]=d,e[10]=v,e[11]=g,e[12]=j,e[13]=b,e[14]=I}else x=e[6],m=e[7],C=e[8],d=e[9],v=e[10],g=e[11],j=e[12],b=e[13],I=e[14];let T;e[27]!==x||e[28]!==v?(T=s.jsx(x,{children:v}),e[27]=x,e[28]=v,e[29]=T):T=e[29];let f;e[30]!==m||e[31]!==g||e[32]!==T?(f=s.jsxs(m,{children:[g,T]}),e[30]=m,e[31]=g,e[32]=T,e[33]=f):f=e[33];let O;e[34]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(ps,{}),e[34]=O):O=e[34];let N;e[35]!==n.id||e[36]!==o?(N=M=>{M.stopPropagation(),o(n.id)},e[35]=n.id,e[36]=o,e[37]=N):N=e[37];let P;e[38]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(Bt,{size:16}),e[38]=P):P=e[38];let A;e[39]!==N?(A=s.jsxs(tt,{variant:"destructive",onClick:N,children:[P,"Remove Member"]}),e[39]=N,e[40]=A):A=e[40];let R;e[41]!==C||e[42]!==A||e[43]!==j||e[44]!==b||e[45]!==f?(R=s.jsxs(C,{align:j,onClick:b,children:[f,O,A]}),e[41]=C,e[42]=A,e[43]=j,e[44]=b,e[45]=f,e[46]=R):R=e[46];let w;return e[47]!==d||e[48]!==R||e[49]!==I?(w=s.jsxs(d,{children:[I,R]}),e[47]=d,e[48]=R,e[49]=I,e[50]=w):w=e[50],w}function jn(t){return t.stopPropagation()}function Tn(t){return t.stopPropagation()}function Mt(t){const e=le.c(8),{invitationId:n,onCancel:r,isCancelling:l}=t,o=l===void 0?!1:l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Nn,children:s.jsx($t,{size:20})})}),e[0]=c):c=e[0];let i;e[1]!==n||e[2]!==r?(i=m=>{m.stopPropagation(),r(n)},e[1]=n,e[2]=r,e[3]=i):i=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ft,{size:16}),e[4]=u):u=e[4];let x;return e[5]!==o||e[6]!==i?(x=s.jsxs(Ct,{children:[c,s.jsx(Tt,{align:"end",onClick:vn,children:s.jsxs(tt,{variant:"destructive",onClick:i,disabled:o,children:[u,"Cancel Invitation"]})})]}),e[5]=o,e[6]=i,e[7]=x):x=e[7],x}function vn(t){return t.stopPropagation()}function Nn(t){return t.stopPropagation()}function En(){const t=le.c(79),{data:e}=bt(),{data:n}=rn(),r=on(),l=_e(),{locator:o}=Ce(),[c,i]=D.useState(null),[u,x]=D.useState(null),[m,C]=D.useState(""),[d,v]=D.useState("table"),[g,j]=D.useState("member"),[b,I]=D.useState("asc"),T=e?.data?.members;let f;t[0]!==g?(f=z=>{g===z?I(kn):(j(z),I("asc"))},t[0]=g,t[1]=f):f=t[1];const O=f;let N=T??[],P=n??[];if(m){const z=m.toLowerCase();N=N.filter($=>$.user?.name?.toLowerCase().includes(z)||$.user?.email?.toLowerCase().includes(z)||$.role?.toLowerCase().includes(z)),P=P.filter($=>$.email?.toLowerCase().includes(z)||$.role?.toLowerCase().includes(z))}if(g&&b){let z;t[2]!==b||t[3]!==g?(z=($,oe)=>{let xe,we;e:switch(g){case"member":{xe=$.user?.name||"",we=oe.user?.name||"";break e}case"role":{xe=$.role||"",we=oe.role||"";break e}case"joined":{xe=$.createdAt?typeof $.createdAt=="string"?$.createdAt:$.createdAt.toISOString():"",we=oe.createdAt?typeof oe.createdAt=="string"?oe.createdAt:oe.createdAt.toISOString():"";break e}default:return 0}return b==="asc"?xe.localeCompare(we):we.localeCompare(xe)},t[2]=b,t[3]=g,t[4]=z):z=t[4],N=[...N].sort(z)}const A=N;let R;t[5]!==o||t[6]!==l?(R={mutationFn:zn,onSuccess:()=>{l.invalidateQueries({queryKey:ce.members(o)}),ne.success("Member has been removed from the organization"),i(null)},onError:Dn},t[5]=o,t[6]=l,t[7]=R):R=t[7];const w=Te(R);let M;t[8]!==o||t[9]!==l?(M={mutationFn:Mn,onSuccess:()=>{l.invalidateQueries({queryKey:ce.members(o)}),ne.success("Member's role has been updated")},onError:Pn},t[8]=o,t[9]=l,t[10]=M):M=t[10];const _=Te(M);let h;t[11]!==o||t[12]!==l?(h={mutationFn:Rn,onSuccess:()=>{l.invalidateQueries({queryKey:ce.invitations(o)}),ne.success("Invitation role has been updated")},onError:Ln},t[11]=o,t[12]=l,t[13]=h):h=t[13];const S=Te(h),{roles:E,customRoles:p}=Nt();let L;t[14]!==p?(L=bn(p),t[14]=p,t[15]=L):L=t[15];const k=L;let G;t[16]!==E?(G=E.filter(wn),t[16]=E,t[17]=G):G=t[17];const q=G;let Q;t[18]===Symbol.for("react.memo_cache_sentinel")?(Q={id:"member",header:"Member",render:_n,cellClassName:"flex-1 min-w-0",sortable:!0},t[18]=Q):Q=t[18];let H;t[19]!==k||t[20]!==q||t[21]!==S||t[22]!==_?(H={id:"role",header:"Role",render:z=>z.type==="member"?s.jsx(et,{role:z.data.role,memberId:z.data.id,isOwner:z.data.role==="owner",roleColorMap:k,selectableRoles:q,onRoleChange:($,oe)=>_.mutate({memberId:$,role:oe}),className:"w-36"}):s.jsx(et,{role:z.data.role,memberId:z.data.id,isOwner:!1,roleColorMap:k,selectableRoles:q,onRoleChange:($,oe)=>S.mutate({invitationId:$,role:oe,email:z.data.email}),className:"w-36"}),cellClassName:"w-36 shrink-0",sortable:!0},t[19]=k,t[20]=q,t[21]=S,t[22]=_,t[23]=H):H=t[23];let Z,se;t[24]===Symbol.for("react.memo_cache_sentinel")?(Z={id:"tags",header:"Tags",render:An,cellClassName:"w-40 shrink-0"},se={id:"joined",header:"Joined",render:On,cellClassName:"w-48 shrink-0",sortable:!0},t[24]=Z,t[25]=se):(Z=t[24],se=t[25]);let X;t[26]!==r.cancel.isPending||t[27]!==E||t[28]!==_?(X={id:"actions",header:"",render:z=>z.type==="member"?s.jsx(Pt,{member:z.data,roles:E,onChangeRole:($,oe)=>_.mutate({memberId:$,role:oe}),onRemove:i,isUpdating:_.isPending}):s.jsx(Mt,{invitationId:z.data.id,onCancel:x,isCancelling:r.cancel.isPending}),cellClassName:"w-12 shrink-0"},t[26]=r.cancel.isPending,t[27]=E,t[28]=_,t[29]=X):X=t[29];let U;t[30]!==X||t[31]!==H?(U=[Q,H,Z,se,X],t[30]=X,t[31]=H,t[32]=U):U=t[32];const a=U;let y;t[33]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(en,{trigger:s.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:[s.jsx(vt,{size:16}),"Manage Roles"]})}),t[33]=y):y=t[33];let F;t[34]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx(nn,{trigger:s.jsx(ie,{size:"sm",children:"Invite Member"})})]}),t[34]=F):F=t[34];const me=F,te=[...A.map(In),...P.filter(Sn).map(yn)],W=Ne,ee=!!u;let de;t[35]===Symbol.for("react.memo_cache_sentinel")?(de=()=>x(null),t[35]=de):de=t[35];let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsxs(Ue,{children:[s.jsx(Ve,{children:"Cancel Invitation"}),s.jsx(Ge,{children:"Are you sure you want to cancel this invitation? The invitee will no longer be able to join the organization with this invitation."})]}),t[36]=V):V=t[36];let B;t[37]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx($e,{children:"Keep Invitation"}),t[37]=B):B=t[37];let J;t[38]!==r.cancel||t[39]!==u?(J=()=>{u&&(r.cancel.mutate(u),x(null))},t[38]=r.cancel,t[39]=u,t[40]=J):J=t[40];let re;t[41]!==r.cancel.isPending||t[42]!==J?(re=s.jsxs(ke,{children:[V,s.jsxs(Be,{children:[B,s.jsx(Fe,{onClick:J,disabled:r.cancel.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Invitation"})]})]}),t[41]=r.cancel.isPending,t[42]=J,t[43]=re):re=t[43];let ue;t[44]!==ee||t[45]!==re?(ue=s.jsx(ze,{open:ee,onOpenChange:de,children:re}),t[44]=ee,t[45]=re,t[46]=ue):ue=t[46];const pe=!!c;let fe;t[47]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>i(null),t[47]=fe):fe=t[47];let he;t[48]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsxs(Ue,{children:[s.jsx(Ve,{children:"Remove Member"}),s.jsx(Ge,{children:"Are you sure you want to remove this member from the organization? This action cannot be undone."})]}),t[48]=he):he=t[48];let je;t[49]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx($e,{children:"Cancel"}),t[49]=je):je=t[49];let K;t[50]!==c||t[51]!==w?(K=()=>c&&w.mutate(c),t[50]=c,t[51]=w,t[52]=K):K=t[52];let ge;t[53]!==w.isPending||t[54]!==K?(ge=s.jsxs(ke,{children:[he,s.jsxs(Be,{children:[je,s.jsx(Fe,{onClick:K,disabled:w.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),t[53]=w.isPending,t[54]=K,t[55]=ge):ge=t[55];let be;t[56]!==pe||t[57]!==ge?(be=s.jsx(ze,{open:pe,onOpenChange:fe,children:ge}),t[56]=pe,t[57]=ge,t[58]=be):be=t[58];let ye;t[59]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(Ne.Header.Left,{children:s.jsx(ns,{children:s.jsx(rs,{children:s.jsx(is,{children:s.jsx(os,{children:"Members"})})})})}),t[59]=ye):ye=t[59];let He;t[60]===Symbol.for("react.memo_cache_sentinel")?(He=[{id:"member",label:"Name"},{id:"role",label:"Role"},{id:"joined",label:"Joined"}],t[60]=He):He=t[60];let Se;t[61]!==O||t[62]!==b||t[63]!==g||t[64]!==d?(Se=s.jsxs(Ne.Header,{children:[ye,s.jsxs(Ne.Header.Right,{children:[s.jsx(ts,{viewMode:d,onViewModeChange:v,sortKey:g,sortDirection:b,onSort:O,sortOptions:He}),me]})]}),t[61]=O,t[62]=b,t[63]=g,t[64]=d,t[65]=Se):Se=t[65];let Ze;t[66]===Symbol.for("react.memo_cache_sentinel")?(Ze=z=>{z.key==="Escape"&&(C(""),z.target.blur())},t[66]=Ze):Ze=t[66];let Ie;t[67]!==m?(Ie=s.jsx(Ke,{value:m,onChange:C,placeholder:"Search members...",onKeyDown:Ze}),t[67]=m,t[68]=Ie):Ie=t[68];const ot=Ne,lt=d==="cards"?s.jsx("div",{className:"flex-1 overflow-auto p-5",children:te.length===0?s.jsx(mt,{title:"No members found",description:m?`No members match "${m}"`:"Invite members to get started."}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:te.map(z=>{if(z.type==="invitation")return s.jsxs(wt,{className:"transition-colors relative opacity-75",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Mt,{invitationId:z.data.id,onCancel:x,isCancelling:r.cancel.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Ae,{fallback:rt(z.data.email),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:z.data.email}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(Ee,{variant:"outline",className:"w-fit text-amber-600 border-amber-400",children:"Pending"})}),s.jsx(et,{role:z.data.role,memberId:z.data.id,isOwner:!1,roleColorMap:k,selectableRoles:q,onRoleChange:(oe,xe)=>S.mutate({invitationId:oe,role:xe,email:z.data.email}),className:"w-fit"})]})]})]},`inv-${z.data.id}`);const $=z.data;return s.jsxs(wt,{className:"transition-colors relative",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Pt,{member:$,roles:E,onChangeRole:(oe,xe)=>_.mutate({memberId:oe,role:xe}),onRemove:i,isUpdating:_.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Ae,{url:$.user?.image??void 0,fallback:rt($.user?.name),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:$.user?.name||"Unknown"}),s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:$.user?.email}),s.jsx(et,{role:$.role,memberId:$.id,isOwner:$.role==="owner",roleColorMap:k,selectableRoles:q,onRoleChange:(oe,xe)=>_.mutate({memberId:oe,role:xe}),className:"w-fit"}),s.jsx(Zt,{memberId:$.id,maxDisplay:3})]})]})]},$.id)})})}):s.jsx(ss,{columns:a,data:te,isLoading:!1,sortKey:g,sortDirection:b,onSort:O,emptyState:m?s.jsx(mt,{title:"No members found",description:`No members match "${m}"`}):s.jsx(mt,{title:"No members found",description:"Invite members to get started."})});let Oe;t[69]!==ot.Content||t[70]!==lt?(Oe=s.jsx(ot.Content,{children:lt}),t[69]=ot.Content,t[70]=lt,t[71]=Oe):Oe=t[71];let Je;return t[72]!==W||t[73]!==ue||t[74]!==be||t[75]!==Se||t[76]!==Ie||t[77]!==Oe?(Je=s.jsxs(W,{children:[ue,be,Se,Ie,Oe]}),t[72]=W,t[73]=ue,t[74]=be,t[75]=Se,t[76]=Ie,t[77]=Oe,t[78]=Je):Je=t[78],Je}function yn(t){return{type:"invitation",data:t}}function Sn(t){return t.status==="pending"}function In(t){return{type:"member",data:t}}function On(t){return t.type==="member"?s.jsx("span",{className:"text-sm text-foreground",children:t.data.createdAt?Cn(t.data.createdAt):"N/A"}):s.jsx(Ee,{variant:"outline",children:"Pending"})}function An(t){return t.type==="member"?s.jsx(Zt,{memberId:t.data.id,maxDisplay:2}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}function _n(t){return t.type==="member"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{url:t.data.user?.image??void 0,fallback:rt(t.data.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.user?.name||"Unknown"}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.data.user?.email})]})]}):s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{fallback:rt(t.data.email),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.email}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:"Invitation sent"})]})]})}function wn(t){return t.role!=="owner"}function Ln(t){ne.error(t instanceof Error?t.message:"Failed to update invitation role")}async function Rn(t){const{invitationId:e,role:n,email:r}=t,l=await ae.organization.cancelInvitation({invitationId:e});if(l?.error)throw new Error(l.error.message);const o=await ae.organization.inviteMember({email:r,role:n});if(o?.error)throw new Error(o.error.message)}function Pn(t){ne.error(t instanceof Error?t.message:"Failed to update role")}async function Mn(t){const{memberId:e,role:n}=t,r=await ae.organization.updateMemberRole({memberId:e,role:[n]});if(r?.error)throw new Error(r.error.message)}function Dn(t){ne.error(t instanceof Error?t.message:"Failed to remove member")}async function zn(t){const e=await ae.organization.removeMember({memberIdOrEmail:t});if(e?.error)throw new Error(e.error.message)}function kn(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Lr(){const t=le.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Ne,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:"Failed to load members"})})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Ts,{fallback:e,children:s.jsx(D.Suspense,{fallback:s.jsx(Ne,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(st,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(En,{})})}),t[1]=n):n=t[1],n}export{Lr as default};
@@ -1 +0,0 @@
1
- import{c as b,j as s,r as A,u as ne,g as oe,t as ee}from"./index-D-FZcOMC.js";import{V as ae,C as g}from"./index-BwOTcL_8.js";import{T as ce,i as me,a as de,t as fe}from"./typewriter-title-BINp1X1h.js";import{E as ue}from"./error-boundary-poUsbtfm.js";import{u as Z,S as Y}from"./use-deco-chat-open-BYfYydiq.js";import{I as te,T as J,a as Q,b as X}from"./integration-icon-Bf2CRysj.js";import{P as pe,a as he,b as xe}from"./popover-Cg1hAh9E.js";import{c as se}from"./utils-Ot-eblW7.js";import{i as ge,d as je}from"./constants-BUYb8__-.js";import{b as be}from"./use-virtual-mcp-Cygajn0x.js";import{i as ye}from"./ChevronRight-c9zV8moh.js";import{t as le}from"./Users03-CPa8wyG0.js";import{P as E}from"./index-CVO_V2RR.js";import{B as H}from"./button-D5ZVigg9.js";import{c as Ne}from"./Pin01-BtF71mI4.js";import{s as _e}from"./Plus-CamZ25HZ.js";import{i as Se}from"./Share07-DBSgibs_.js";import"./X-DjzWAzfl.js";import"./spinner-CJ9nslDm.js";import"./use-mcp-prompts-BJj4NSvO.js";import"./useQuery-DT5IkV6j.js";import"./dialog-Cfe0BARl.js";import"./form-9-Pb579i.js";import"./input-CLb5DS9b.js";import"./AlertCircle-3QR0y8W6.js";import"./ArrowUp-BodxzbKG.js";import"./ChevronDown-D4GxGIq8.js";import"./Edit01-CmR87Abc.js";import"./Check-DKxLmorI.js";import"./Copy01-BA-Ix-Mb.js";import"./Terminal-goRyLnyD.js";import"./monaco-editor-DTJpuLmN.js";import"./localstorage-keys-CiWIgky1.js";import"./useMutation-BKI7PbLi.js";import"./empty-state-Clfhj5oY.js";import"./use-connection-DR5puEok.js";import"./generate-id-Dyweu44Y.js";import"./SearchMd-CMsT_ewj.js";import"./Trash01-DoayzMxM.js";import"./badge-CAqp4wuS.js";import"./Code01--g0L9RTm.js";import"./infiniteQueryObserver-cPntdNLH.js";import"./use-create-virtual-mcp-ZYI04Bzi.js";import"./use-binding-DYiJkibE.js";import"./binder-Dl_fdkAq.js";import"./select-DANNPdpC.js";import"./index-CasvHInh.js";import"./File06-BVRF7sU6.js";import"./Grid01-1H_5bBEp.js";import"./Image01-DvVQGg3o.js";function ve(e){const t=b.c(15),{agent:l}=e,{setVirtualMcpId:p}=Z();let r;t[0]!==l.id||t[1]!==p?(r=()=>{p(l.id)},t[0]=l.id,t[1]=p,t[2]=r):r=t[2];const i=r;let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=se("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors hover:bg-accent/30","cursor-pointer","self-stretch"),t[3]=m):m=t[3];const d=`Select agent ${l.title}`;let n;t[4]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(le,{size:20}),t[4]=n):n=t[4];let c;t[5]!==l.icon||t[6]!==l.title?(c=s.jsx(te,{icon:l.icon,name:l.title,fallbackIcon:n}),t[5]=l.icon,t[6]=l.title,t[7]=c):c=t[7];let o;t[8]!==l.title?(o=s.jsx("p",{className:"text-sm text-foreground text-center leading-tight line-clamp-2",children:l.title}),t[8]=l.title,t[9]=o):o=t[9];let a;return t[10]!==i||t[11]!==d||t[12]!==c||t[13]!==o?(a=s.jsxs("button",{type:"button",onClick:i,className:m,"aria-label":d,children:[c,o]}),t[10]=i,t[11]=d,t[12]=c,t[13]=o,t[14]=a):a=t[14],a}function Ce(e){const t=b.c(14),{virtualMcps:l,selectedVirtualMcpId:p,onVirtualMcpChange:r}=e,[i,m]=A.useState(!1),d=A.useRef(null);let n,c;t[0]!==i?(n=()=>{i&&setTimeout(()=>{d.current?.focus()},0)},c=[i],t[0]=i,t[1]=n,t[2]=c):(n=t[1],c=t[2]),A.useEffect(n,c);let o;t[3]!==r?(o=y=>{r(y),m(!1)},t[3]=r,t[4]=o):o=t[4];const a=o;let f;t[5]===Symbol.for("react.memo_cache_sentinel")?(f=se("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors hover:bg-accent/30","cursor-pointer","self-stretch"),t[5]=f):f=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(pe,{asChild:!0,children:s.jsxs("button",{type:"button",className:f,"aria-label":"See all agents",children:[s.jsx("div",{className:"size-12 rounded-lg bg-accent flex items-center justify-center shrink-0",children:s.jsx(ye,{size:24,className:"text-foreground"})}),s.jsx("p",{className:"text-sm text-foreground text-center leading-tight",children:"See all"})]})}),t[6]=u):u=t[6];let h;t[7]!==a||t[8]!==p||t[9]!==l?(h=s.jsx(he,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:s.jsx(ae,{virtualMcps:l,selectedVirtualMcpId:p,onVirtualMcpChange:a,searchInputRef:d})}),t[7]=a,t[8]=p,t[9]=l,t[10]=h):h=t[10];let j;return t[11]!==i||t[12]!==h?(j=s.jsxs(xe,{open:i,onOpenChange:m,children:[u,h]}),t[11]=i,t[12]=h,t[13]=j):j=t[13],j}function we(){const e=b.c(20),t=be(),{selectedVirtualMcp:l,setVirtualMcpId:p}=Z();let r,i,m,d,n,c;if(e[0]!==t){n=Symbol.for("react.early_return_sentinel");e:{const h=t.filter(ze).slice(0,6);if(h.length===0){n=null;break e}c=t.map(Te),m="w-full max-w-[800px]",e[7]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-4",children:"Recently used agents"}),e[7]=d):d=e[7],r="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-7 gap-2",i=h.map(ke)}e[0]=t,e[1]=r,e[2]=i,e[3]=m,e[4]=d,e[5]=n,e[6]=c}else r=e[1],i=e[2],m=e[3],d=e[4],n=e[5],c=e[6];if(n!==Symbol.for("react.early_return_sentinel"))return n;const o=l?.id??null;let a;e[8]!==p||e[9]!==o||e[10]!==c?(a=s.jsx(Ce,{virtualMcps:c,selectedVirtualMcpId:o,onVirtualMcpChange:p}),e[8]=p,e[9]=o,e[10]=c,e[11]=a):a=e[11];let f;e[12]!==r||e[13]!==i||e[14]!==a?(f=s.jsxs("div",{className:r,children:[i,a]}),e[12]=r,e[13]=i,e[14]=a,e[15]=f):f=e[15];let u;return e[16]!==m||e[17]!==d||e[18]!==f?(u=s.jsxs("div",{className:m,children:[d,f]}),e[16]=m,e[17]=d,e[18]=f,e[19]=u):u=e[19],u}function ke(e){return s.jsx(ve,{agent:e},e.id??"default")}function Te(e){return{id:e.id,title:e.title,description:e.description,icon:e.icon}}function ze(e){return e.id!==null&&!ge(e.id)}function Me(){const e=b.c(2);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(Y,{className:"h-5 w-40 mb-4"}),e[0]=t):t=e[0];let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsxs("div",{className:"w-full max-w-[800px]",children:[t,s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-7 gap-2",children:Array.from({length:7}).map(Ie)})]}),e[1]=l):l=e[1],l}function Ie(e,t){return s.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 self-stretch",children:[s.jsx(Y,{className:"size-6 rounded-md shrink-0"}),s.jsx(Y,{className:"h-4 w-full"})]},t)}function Pe(){const e=b.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(A.Suspense,{fallback:s.jsx(Me,{}),children:s.jsx(we,{})}),e[0]=t):t=e[0],t}function $e(){const e=new Date().getHours();return e>=5&&e<12?"Morning":e>=12&&e<17?"Afternoon":e>=17&&e<22?"Evening":"Night"}function Ve(){const e=b.c(61),{org:t}=ne(),{data:l}=oe.useSession(),{modelsConnections:p,isChatEmpty:r,activeThreadId:i,createThread:m,switchToThread:d,threads:n,selectedVirtualMcp:c}=Z();let o;if(e[0]!==i||e[1]!==n){let x;e[3]!==i?(x=re=>re.id===i,e[3]=i,e[4]=x):x=e[4],o=n.find(x),e[0]=i,e[1]=n,e[2]=o}else o=e[2];const a=o,[f,u]=A.useState(!1);let h;e[5]!==l?.user?.name?(h=l?.user?.name?.split(" ")[0]||"there",e[5]=l?.user?.name,e[6]=h):h=e[6];const j=h;let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y=$e(),e[7]=y):y=e[7];const ie=y;let R;e[8]!==t.id?(R=je(t.id),e[8]=t.id,e[9]=R):R=e[9];const B=c??R;if(p.length===0){let x;return e[10]!==t?(x=s.jsx("div",{className:"flex flex-col size-full bg-background items-center justify-center",children:s.jsx(g.NoLlmBindingEmptyState,{org:t})}),e[10]=t,e[11]=x):x=e[11],x}let N;e[12]!==a?(N=a?.title&&s.jsx(ce,{text:a.title,className:"text-sm font-medium text-foreground"}),e[12]=a,e[13]=N):N=e[13];let _;e[14]!==N?(_=s.jsx(E.Header.Left,{className:"gap-2",children:N}),e[14]=N,e[15]=_):_=e[15];let S;e[16]!==m?(S=()=>m(),e[16]=m,e[17]=S):S=e[17];let L;e[18]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(_e,{size:16}),e[18]=L):L=e[18];let v;e[19]!==r||e[20]!==S?(v=s.jsx(J,{asChild:!0,children:s.jsx(H,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input",onClick:S,disabled:r,"aria-label":"New chat",children:L})}),e[19]=r,e[20]=S,e[21]=v):v=e[21];let O;e[22]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Q,{children:"New chat"}),e[22]=O):O=e[22];let C;e[23]!==v?(C=s.jsxs(X,{children:[v,O]}),e[23]=v,e[24]=C):C=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=()=>u(!0),e[25]=D):D=e[25];let F;e[26]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsxs(X,{children:[s.jsx(J,{asChild:!0,children:s.jsx(H,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input",onClick:D,"aria-label":"Chat history",children:s.jsx(me,{size:16})})}),s.jsx(Q,{children:"Chat history"})]}),e[26]=F):F=e[26];let W;e[27]===Symbol.for("react.memo_cache_sentinel")?(W=s.jsx(Ne,{size:16}),e[27]=W):W=e[27];let w;e[28]!==r?(w=s.jsx(J,{asChild:!0,children:s.jsx(H,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input",onClick:Ee,disabled:r,"aria-label":"Pin chat",children:W})}),e[28]=r,e[29]=w):w=e[29];let q;e[30]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(Q,{children:"Pin chat"}),e[30]=q):q=e[30];let k;e[31]!==w?(k=s.jsxs(X,{children:[w,q]}),e[31]=w,e[32]=k):k=e[32];let G;e[33]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx(Se,{size:16}),e[33]=G):G=e[33];let T;e[34]!==r?(T=s.jsx(J,{asChild:!0,children:s.jsx(H,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input",onClick:Ae,disabled:r,"aria-label":"Share chat",children:G})}),e[34]=r,e[35]=T):T=e[35];let K;e[36]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Q,{children:"Share chat"}),e[36]=K):K=e[36];let z;e[37]!==T?(z=s.jsxs(X,{children:[T,K]}),e[37]=T,e[38]=z):z=e[38];let M;e[39]!==C||e[40]!==k||e[41]!==z?(M=s.jsxs(E.Header.Right,{className:"gap-1",children:[C,F,k,z]}),e[39]=C,e[40]=k,e[41]=z,e[42]=M):M=e[42];let I;e[43]!==M||e[44]!==_?(I=s.jsxs(E.Header,{className:"flex-none z-10 bg-background",children:[_,M]}),e[43]=M,e[44]=_,e[45]=I):I=e[45];let P;e[46]!==B||e[47]!==r||e[48]!==j?(P=r?s.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center px-10 pb-32 pt-10",children:[s.jsxs("div",{className:"flex flex-col items-center gap-3 w-full max-w-[600px]",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(te,{icon:B.icon,name:B.title,size:"md",fallbackIcon:s.jsx(le,{size:20}),className:"size-12 rounded-xl border border-stone-200/60 shadow-sm aspect-square transition-opacity duration-200"})}),s.jsxs("div",{className:"text-center",children:[s.jsxs("p",{className:"text-lg font-medium text-foreground",children:[ie," ",j,","]}),s.jsx("p",{className:"text-base text-muted-foreground opacity-50 mb-0",children:"What are we building today?"})]}),s.jsx("div",{className:"w-full -mt-1",children:s.jsx(g.Input,{})}),s.jsx(g.IceBreakers,{className:"w-full"})]}),s.jsx("div",{className:"flex flex-col items-center w-full mt-4",children:s.jsx(Pe,{})})]}):s.jsxs(s.Fragment,{children:[s.jsx(g.Main,{children:s.jsx(g.Messages,{})}),s.jsx(g.Footer,{children:s.jsx(g.Input,{})})]}),e[46]=B,e[47]=r,e[48]=j,e[49]=P):P=e[49];let $;e[50]!==d?($=async x=>{await d(x),u(!1)},e[50]=d,e[51]=$):$=e[51];let V;e[52]!==i||e[53]!==f||e[54]!==$||e[55]!==n?(V=s.jsx(de,{open:f,onOpenChange:u,threads:n,activeThreadId:i,onThreadSelect:$}),e[52]=i,e[53]=f,e[54]=$,e[55]=n,e[56]=V):V=e[56];let U;return e[57]!==I||e[58]!==P||e[59]!==V?(U=s.jsxs(g,{className:"bg-background",children:[I,P,V]}),e[57]=I,e[58]=P,e[59]=V,e[60]=U):U=e[60],U}function Ae(){ee.info("Share feature coming soon")}function Ee(){ee.info("Pin feature coming soon")}function He(e){const t=b.c(14),{error:l,onRetry:p}=e,r=l?.message?.includes("401")||l?.message?.toLowerCase().includes("unauthorized");let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsxs(E.Header,{className:"flex-none",children:[s.jsx(E.Header.Left,{className:"gap-2"}),s.jsx(E.Header.Right,{className:"gap-1"})]}),t[0]=i):i=t[0];let m;t[1]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx("div",{className:"bg-destructive/10 p-3 rounded-full mx-auto w-fit",children:s.jsx(fe,{className:"h-6 w-6 text-destructive"})}),t[1]=m):m=t[1];const d=r?"Unable to load models":"Something went wrong";let n;t[2]!==d?(n=s.jsx("h3",{className:"text-lg font-medium",children:d}),t[2]=d,t[3]=n):n=t[3];const c=r?"There was an authentication error while loading the models. This might be due to an expired session or invalid API key.":l?.message||"An unexpected error occurred";let o;t[4]!==c?(o=s.jsx("p",{className:"text-sm text-muted-foreground",children:c}),t[4]=c,t[5]=o):o=t[5];let a;t[6]!==n||t[7]!==o?(a=s.jsxs("div",{className:"space-y-2",children:[n,o]}),t[6]=n,t[7]=o,t[8]=a):a=t[8];let f;t[9]!==p?(f=s.jsx(H,{variant:"outline",onClick:p,children:"Try again"}),t[9]=p,t[10]=f):f=t[10];let u;return t[11]!==a||t[12]!==f?(u=s.jsxs(g,{className:"bg-background",children:[i,s.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:s.jsxs("div",{className:"max-w-sm space-y-4",children:[m,a,f]})})]}),t[11]=a,t[12]=f,t[13]=u):u=t[13],u}function Et(){const e=b.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsx(ue,{fallback:Re,children:s.jsx(A.Suspense,{fallback:s.jsx(g.Skeleton,{className:"bg-background"}),children:s.jsx(Ve,{})})}),e[0]=t):t=e[0],t}function Re(e){const{error:t,resetError:l}=e;return s.jsx(He,{error:t,onRetry:l})}export{Et as default};
@@ -1,23 +0,0 @@
1
- import{r as N,bw as Ga,bx as Ya,F as Qa,bf as B,s as g,by as Ve,bz as ra,bj as Xa,bk as Ka,be as es,bg as U,ba as Ie,ae as Te,o as P,bh as E,bi as ne,bA as ts,bB as O,af as as,b5 as ss,c as D,u as ve,a as oa,v as ht,K as He,t as gt,j as d,g as rs,am as os,_ as vt,at as ns,an as is,aq as ls,av as cs,al as us,b0 as ds}from"./index-D-FZcOMC.js";import{j as ps,u as yt,a as xt,d as ms}from"./constants-BUYb8__-.js";import{b as fs}from"./use-virtual-mcp-Cygajn0x.js";import{h as hs,e as na,b as bt,c as gs,a as vs}from"./use-connection-DR5puEok.js";import{a as ys}from"./use-binding-DYiJkibE.js";import{u as xs}from"./Code01--g0L9RTm.js";import{u as Se,L as We}from"./localstorage-keys-CiWIgky1.js";import{B as bs}from"./button-D5ZVigg9.js";import{I as _s}from"./input-CLb5DS9b.js";import{P as Es,a as Is,b as Ss}from"./popover-Cg1hAh9E.js";import{S as ws,a as Cs,b as Ns,c as Ts,d as As}from"./select-DANNPdpC.js";import{c as _t}from"./utils-Ot-eblW7.js";import{t as Ot}from"./ChevronDown-D4GxGIq8.js";import{i as Ms}from"./File06-BVRF7sU6.js";import{c as Rs}from"./Grid01-1H_5bBEp.js";import{a as js}from"./Image01-DvVQGg3o.js";import{i as ia}from"./SearchMd-CMsT_ewj.js";var we;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function a(r){throw new Error}t.assertNever=a,t.arrayToEnum=r=>{const o={};for(const i of r)o[i]=i;return o},t.getValidEnumValues=r=>{const o=t.objectKeys(r).filter(n=>typeof r[r[n]]!="number"),i={};for(const n of o)i[n]=r[n];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(o){return r[o]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&o.push(i);return o},t.find=(r,o)=>{for(const i of r)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=s,t.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(we||(we={}));var kt;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(kt||(kt={}));we.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);we.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class qe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(o){return o.message},s={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(a(i));else{let n=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(n[l]=n[l]||{_errors:[]},n[l]._errors.push(a(i))):n[l]=n[l]||{_errors:[]},n=n[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof qe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,we.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),s=[];for(const r of this.issues)if(r.path.length>0){const o=r.path[0];a[o]=a[o]||[],a[o].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}}qe.create=t=>new qe(t);var Dt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Dt||(Dt={}));var C;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(C||(C={}));const Ps=({size:t=24,color:e="currentColor",...a})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},N.createElement("path",{d:"M4 7h11m0 0-4 4m4-4-4-4M4 17h16m0 0-4 4m4-4-4-4"}));Ps.displayName="ArrowsRight";const la=({size:t=24,color:e="currentColor",...a})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},N.createElement("path",{d:"m7 15 5 5 5-5M7 9l5-5 5 5"}));la.displayName="ChevronSelectorVertical";const ca=({size:t=24,color:e="currentColor",...a})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},N.createElement("path",{d:"M6 16a4 4 0 0 0 4 4h4a4 4 0 0 0 0-8h-4a4 4 0 0 1 0-8h4a4 4 0 0 1 4 4m-6-6v20"}));ca.displayName="CurrencyDollar";const Os=({size:t=24,color:e="currentColor",...a})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},N.createElement("path",{d:"M10 17.659V20a2 2 0 1 0 4 0v-2.341M12 2v1m-9 9H2m3.5-6.5-.6-.6m13.6.6.6-.6M22 12h-1m-3 0a6 6 0 1 1-12 0 6 6 0 0 1 12 0Z"}));Os.displayName="Lightbulb02";const ua=({size:t=24,color:e="currentColor",...a})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},N.createElement("path",{d:"m18 8 4 4m0 0-4 4m4-4H9m6-7.796A8.383 8.383 0 0 0 10.667 3C5.88 3 2 7.03 2 12s3.88 9 8.667 9A8.384 8.384 0 0 0 15 19.796"}));ua.displayName="LogOut04";const da=({size:t=24,color:e="currentColor",...a})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},N.createElement("path",{d:"m6.5 13 .784 1.569c.266.53.399.796.576 1.026a3 3 0 0 0 .545.545c.23.177.495.31 1.026.575L11 17.5l-1.569.785c-.53.265-.796.398-1.026.575a3 3 0 0 0-.545.545c-.177.23-.31.495-.576 1.026L6.5 22l-.784-1.569c-.266-.53-.399-.796-.576-1.026a3 3 0 0 0-.545-.545c-.23-.177-.495-.31-1.026-.575L2 17.5l1.569-.785c.53-.265.796-.398 1.026-.575a3 3 0 0 0 .545-.545c.177-.23.31-.495.576-1.026L6.5 13ZM15 2l1.179 3.064c.282.734.423 1.1.642 1.409a3 3 0 0 0 .706.706c.309.22.675.36 1.409.642L22 9l-3.064 1.179c-.734.282-1.1.423-1.409.642a3 3 0 0 0-.706.706c-.22.309-.36.675-.642 1.409L15 16l-1.179-3.064c-.282-.734-.423-1.1-.642-1.409a3 3 0 0 0-.706-.706c-.309-.22-.675-.36-1.409-.642L8 9l3.064-1.179c.734-.282 1.1-.423 1.409-.642a3 3 0 0 0 .706-.706c.22-.309.36-.675.642-1.409L15 2Z"}));da.displayName="Stars01";var pa="vercel.ai.error",ks=Symbol.for(pa),$t,Lt,ae=class ma extends(Lt=Error,$t=ks,Lt){constructor({name:e,message:a,cause:s}){super(a),this[$t]=!0,this.name=e,this.cause=s}static isInstance(e){return ma.hasMarker(e,pa)}static hasMarker(e,a){const s=Symbol.for(a);return e!=null&&typeof e=="object"&&s in e&&typeof e[s]=="boolean"&&e[s]===!0}};function fa(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var ha="AI_InvalidArgumentError",ga=`vercel.ai.error.${ha}`,Ds=Symbol.for(ga),Zt,Ft,$s=class extends(Ft=ae,Zt=Ds,Ft){constructor({message:t,cause:e,argument:a}){super({name:ha,message:t,cause:e}),this[Zt]=!0,this.argument=a}static isInstance(t){return ae.hasMarker(t,ga)}},va="AI_JSONParseError",ya=`vercel.ai.error.${va}`,Ls=Symbol.for(ya),Ut,zt,Bt=class extends(zt=ae,Ut=Ls,zt){constructor({text:t,cause:e}){super({name:va,message:`JSON parsing failed: Text: ${t}.
2
- Error message: ${fa(e)}`,cause:e}),this[Ut]=!0,this.text=t}static isInstance(t){return ae.hasMarker(t,ya)}},xa="AI_TypeValidationError",ba=`vercel.ai.error.${xa}`,Zs=Symbol.for(ba),Vt,qt,ge=class it extends(qt=ae,Vt=Zs,qt){constructor({value:e,cause:a,context:s}){let r="Type validation failed";if(s?.field&&(r+=` for ${s.field}`),s?.entityName||s?.entityId){r+=" (";const o=[];s.entityName&&o.push(s.entityName),s.entityId&&o.push(`id: "${s.entityId}"`),r+=o.join(", "),r+=")"}super({name:xa,message:`${r}: Value: ${JSON.stringify(e)}.
3
- Error message: ${fa(a)}`,cause:a}),this[Vt]=!0,this.value=e,this.context=s}static isInstance(e){return ae.hasMarker(e,ba)}static wrap({value:e,cause:a,context:s}){var r,o,i;return it.isInstance(a)&&a.value===e&&((r=a.context)==null?void 0:r.field)===s?.field&&((o=a.context)==null?void 0:o.entityName)===s?.entityName&&((i=a.context)==null?void 0:i.entityId)===s?.entityId?a:new it({value:e,cause:a,context:s})}},Ae=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const r=()=>{const o=a.length,i=new Array(e);for(let n=0;n<e;n++)i[n]=a[Math.random()*o|0];return i.join("")};if(t==null)return r;if(a.includes(s))throw new $s({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${a}".`});return()=>`${t}${s}${r()}`},Fs=Ae();function Ht(t=globalThis){var e,a,s;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(s=(a=t.process)==null?void 0:a.versions)!=null&&s.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function de(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((a,s)=>{e[s.toLowerCase()]=a});else{Array.isArray(t)||(t=Object.entries(t));for(const[a,s]of t)s!=null&&(e[a.toLowerCase()]=s)}return e}function Wt(t,...e){const a=new Headers(de(t)),s=a.get("user-agent")||"";return a.set("user-agent",[s,...e].filter(Boolean).join(" ")),Object.fromEntries(a.entries())}var Us=/"__proto__"\s*:/,zs=/"constructor"\s*:/;function Jt(t){const e=JSON.parse(t);return e===null||typeof e!="object"||Us.test(t)===!1&&zs.test(t)===!1?e:Bs(e)}function Bs(t){let e=[t];for(;e.length;){const a=e;e=[];for(const s of a){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in s){const o=s[r];o&&typeof o=="object"&&e.push(o)}}}return t}function Vs(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return Jt(t)}try{return Jt(t)}finally{Error.stackTraceLimit=e}}function Et(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const s of Object.keys(a))a[s]=ue(a[s])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(ue):ue(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(ue)),t.allOf!=null&&(t.allOf=t.allOf.map(ue)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(ue));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=ue(e[a]);return t}function ue(t){return typeof t=="boolean"?t:Et(t)}var qs=Symbol("Let zodToJsonSchema decide on which parser to use"),Gt={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Hs=t=>typeof t=="string"?{...Gt,name:t}:{...Gt,...t};function H(){return{}}function Ws(t,e){var a,s,r;const o={type:"array"};return(a=t.type)!=null&&a._def&&((r=(s=t.type)==null?void 0:s._def)==null?void 0:r.typeName)!==C.ZodAny&&(o.items=R(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(o.minItems=t.minLength.value),t.maxLength&&(o.maxItems=t.maxLength.value),t.exactLength&&(o.minItems=t.exactLength.value,o.maxItems=t.exactLength.value),o}function Js(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function Gs(){return{type:"boolean"}}function _a(t,e){return R(t.type._def,e)}var Ys=(t,e)=>R(t.innerType._def,e);function Ea(t,e,a){const s=a??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,o)=>Ea(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Qs(t)}}var Qs=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function Xs(t,e){return{...R(t.innerType._def,e),default:t.defaultValue()}}function Ks(t,e){return e.effectStrategy==="input"?R(t.schema._def,e):H()}function er(t){return{type:"string",enum:Array.from(t.values)}}var tr=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ar(t,e){const a=[R(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),R(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(r=>!!r),s=[];return a.forEach(r=>{if(tr(r))s.push(...r.allOf);else{let o=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:i,...n}=r;o=n}s.push(o)}}),s.length?{allOf:s}:void 0}function sr(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var rt=void 0,Q={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(rt===void 0&&(rt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),rt),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Ia(t,e){const a={type:"string"};if(t.checks)for(const s of t.checks)switch(s.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"email":switch(e.emailStrategy){case"format:email":X(a,"email",s.message,e);break;case"format:idn-email":X(a,"idn-email",s.message,e);break;case"pattern:zod":F(a,Q.email,s.message,e);break}break;case"url":X(a,"uri",s.message,e);break;case"uuid":X(a,"uuid",s.message,e);break;case"regex":F(a,s.regex,s.message,e);break;case"cuid":F(a,Q.cuid,s.message,e);break;case"cuid2":F(a,Q.cuid2,s.message,e);break;case"startsWith":F(a,RegExp(`^${ot(s.value,e)}`),s.message,e);break;case"endsWith":F(a,RegExp(`${ot(s.value,e)}$`),s.message,e);break;case"datetime":X(a,"date-time",s.message,e);break;case"date":X(a,"date",s.message,e);break;case"time":X(a,"time",s.message,e);break;case"duration":X(a,"duration",s.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"includes":{F(a,RegExp(ot(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&X(a,"ipv4",s.message,e),s.version!=="v4"&&X(a,"ipv6",s.message,e);break}case"base64url":F(a,Q.base64url,s.message,e);break;case"jwt":F(a,Q.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&F(a,Q.ipv4Cidr,s.message,e),s.version!=="v4"&&F(a,Q.ipv6Cidr,s.message,e);break}case"emoji":F(a,Q.emoji(),s.message,e);break;case"ulid":{F(a,Q.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{X(a,"binary",s.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{F(a,Q.base64,s.message,e);break}}break}case"nanoid":F(a,Q.nanoid,s.message,e)}return a}function ot(t,e){return e.patternStrategy==="escape"?or(t):t}var rr=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function or(t){let e="";for(let a=0;a<t.length;a++)rr.has(t[a])||(e+="\\"),e+=t[a];return e}function X(t,e,a,s){var r;t.format||(r=t.anyOf)!=null&&r.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&s.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function F(t,e,a,s){var r;t.pattern||(r=t.allOf)!=null&&r.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Yt(e,s),...a&&s.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=Yt(e,s)}function Yt(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const s={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=s.i?t.source.toLowerCase():t.source;let o="",i=!1,n=!1,c=!1;for(let l=0;l<r.length;l++){if(i){o+=r[l],i=!1;continue}if(s.i){if(n){if(r[l].match(/[a-z]/)){c?(o+=r[l],o+=`${r[l-2]}-${r[l]}`.toUpperCase(),c=!1):r[l+1]==="-"&&((a=r[l+2])!=null&&a.match(/[a-z]/))?(o+=r[l],c=!0):o+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){o+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){o+=`(^|(?<=[\r
4
- ]))`;continue}else if(r[l]==="$"){o+=`($|(?=[\r
5
- ]))`;continue}}if(s.s&&r[l]==="."){o+=n?`${r[l]}\r
6
- `:`[${r[l]}\r
7
- ]`;continue}o+=r[l],r[l]==="\\"?i=!0:n&&r[l]==="]"?n=!1:!n&&r[l]==="["&&(n=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}function Sa(t,e){var a,s,r,o,i,n;const c={type:"object",additionalProperties:(a=R(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?a:e.allowedAdditionalProperties};if(((s=t.keyType)==null?void 0:s._def.typeName)===C.ZodString&&((r=t.keyType._def.checks)!=null&&r.length)){const{type:l,...p}=Ia(t.keyType._def,e);return{...c,propertyNames:p}}else{if(((o=t.keyType)==null?void 0:o._def.typeName)===C.ZodEnum)return{...c,propertyNames:{enum:t.keyType._def.values}};if(((i=t.keyType)==null?void 0:i._def.typeName)===C.ZodBranded&&t.keyType._def.type._def.typeName===C.ZodString&&((n=t.keyType._def.type._def.checks)!=null&&n.length)){const{type:l,...p}=_a(t.keyType._def,e);return{...c,propertyNames:p}}}return c}function nr(t,e){if(e.mapStrategy==="record")return Sa(t,e);const a=R(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||H(),s=R(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||H();return{type:"array",maxItems:125,items:{type:"array",items:[a,s],minItems:2,maxItems:2}}}function ir(t){const e=t.values,s=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),r=Array.from(new Set(s.map(o=>typeof o)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function lr(){return{not:H()}}function cr(){return{type:"null"}}var lt={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ur(t,e){const a=t.options instanceof Map?Array.from(t.options.values()):t.options;if(a.every(s=>s._def.typeName in lt&&(!s._def.checks||!s._def.checks.length))){const s=a.reduce((r,o)=>{const i=lt[o._def.typeName];return i&&!r.includes(i)?[...r,i]:r},[]);return{type:s.length>1?s:s[0]}}else if(a.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=a.reduce((r,o)=>{const i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...r,i];case"bigint":return[...r,"integer"];case"object":if(o._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(s.length===a.length){const r=s.filter((o,i,n)=>n.indexOf(o)===i);return{type:r.length>1?r:r[0],enum:a.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(a.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:a.reduce((s,r)=>[...s,...r._def.values.filter(o=>!s.includes(o))],[])};return dr(t,e)}var dr=(t,e)=>{const a=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,r)=>R(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return a.length?{anyOf:a}:void 0};function pr(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[lt[t.innerType._def.typeName],"null"]};const a=R(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}function mr(t){const e={type:"number"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"int":e.type="integer";break;case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function fr(t,e){const a={type:"object",properties:{}},s=[],r=t.shape();for(const i in r){let n=r[i];if(n===void 0||n._def===void 0)continue;const c=gr(n),l=R(n._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});l!==void 0&&(a.properties[i]=l,c||s.push(i))}s.length&&(a.required=s);const o=hr(t,e);return o!==void 0&&(a.additionalProperties=o),a}function hr(t,e){if(t.catchall._def.typeName!=="ZodNever")return R(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function gr(t){try{return t.isOptional()}catch{return!0}}var vr=(t,e)=>{var a;if(e.currentPath.toString()===((a=e.propertyPath)==null?void 0:a.toString()))return R(t.innerType._def,e);const s=R(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return s?{anyOf:[{not:H()},s]}:H()},yr=(t,e)=>{if(e.pipeStrategy==="input")return R(t.in._def,e);if(e.pipeStrategy==="output")return R(t.out._def,e);const a=R(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=R(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",a?"1":"0"]});return{allOf:[a,s].filter(r=>r!==void 0)}};function xr(t,e){return R(t.type._def,e)}function br(t,e){const s={type:"array",uniqueItems:!0,items:R(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(s.minItems=t.minSize.value),t.maxSize&&(s.maxItems=t.maxSize.value),s}function _r(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((a,s)=>R(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[]),additionalItems:R(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((a,s)=>R(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[])}}function Er(){return{not:H()}}function Ir(){return H()}var Sr=(t,e)=>R(t.innerType._def,e),wr=(t,e,a)=>{switch(e){case C.ZodString:return Ia(t,a);case C.ZodNumber:return mr(t);case C.ZodObject:return fr(t,a);case C.ZodBigInt:return Js(t);case C.ZodBoolean:return Gs();case C.ZodDate:return Ea(t,a);case C.ZodUndefined:return Er();case C.ZodNull:return cr();case C.ZodArray:return Ws(t,a);case C.ZodUnion:case C.ZodDiscriminatedUnion:return ur(t,a);case C.ZodIntersection:return ar(t,a);case C.ZodTuple:return _r(t,a);case C.ZodRecord:return Sa(t,a);case C.ZodLiteral:return sr(t);case C.ZodEnum:return er(t);case C.ZodNativeEnum:return ir(t);case C.ZodNullable:return pr(t,a);case C.ZodOptional:return vr(t,a);case C.ZodMap:return nr(t,a);case C.ZodSet:return br(t,a);case C.ZodLazy:return()=>t.getter()._def;case C.ZodPromise:return xr(t,a);case C.ZodNaN:case C.ZodNever:return lr();case C.ZodEffects:return Ks(t,a);case C.ZodAny:return H();case C.ZodUnknown:return Ir();case C.ZodDefault:return Xs(t,a);case C.ZodBranded:return _a(t,a);case C.ZodReadonly:return Sr(t,a);case C.ZodCatch:return Ys(t,a);case C.ZodPipeline:return yr(t,a);case C.ZodFunction:case C.ZodVoid:case C.ZodSymbol:return;default:return(s=>{})()}},Cr=(t,e)=>{let a=0;for(;a<t.length&&a<e.length&&t[a]===e[a];a++);return[(t.length-a).toString(),...e.slice(a)].join("/")};function R(t,e,a=!1){var s;const r=e.seen.get(t);if(e.override){const c=(s=e.override)==null?void 0:s.call(e,t,e,r,a);if(c!==qs)return c}if(r&&!a){const c=Nr(r,e);if(c!==void 0)return c}const o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);const i=wr(t,t.typeName,e),n=typeof i=="function"?R(i(),e):i;if(n&&Tr(t,e,n),e.postProcess){const c=e.postProcess(n,t,e);return o.jsonSchema=n,c}return o.jsonSchema=n,n}var Nr=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Cr(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((a,s)=>e.currentPath[s]===a)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),H()):e.$refStrategy==="seen"?H():void 0}},Tr=(t,e,a)=>(t.description&&(a.description=t.description),a),Ar=t=>{const e=Hs(t),a=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}},Mr=(t,e)=>{var a;const s=Ar(e);let r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[p,m])=>{var h;return{...l,[p]:(h=R(m._def,{...s,currentPath:[...s.basePath,s.definitionPath,p]},!0))!=null?h:H()}},{}):void 0;const o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=(a=R(t._def,o===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,o]},!1))!=null?a:H(),n=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;n!==void 0&&(i.title=n);const c=o===void 0?r?{...i,[s.definitionPath]:r}:i:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,o].join("/"),[s.definitionPath]:{...r,[o]:i}};return c.$schema="http://json-schema.org/draft-07/schema#",c},ct=Symbol.for("vercel.ai.schema");function Rr(t){let e;return()=>(e==null&&(e=t()),e)}function Je(t,{validate:e}={}){return{[ct]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function jr(t){return typeof t=="object"&&t!==null&&ct in t&&t[ct]===!0&&"jsonSchema"in t&&"validate"in t}function It(t){return t==null?Je({properties:{},additionalProperties:!1}):jr(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?wa(t):Pr(t):t()}function Pr(t){return Je(()=>Et(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const a=await t["~standard"].validate(e);return"value"in a?{success:!0,value:a.value}:{success:!1,error:new ge({value:e,cause:a.issues})}}})}function Or(t,e){var a;const s=(a=void 0)!=null?a:!1;return Je(()=>Mr(t,{$refStrategy:s?"root":"none"}),{validate:async r=>{const o=await t.safeParseAsync(r);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function kr(t,e){var a;const s=(a=void 0)!=null?a:!1;return Je(()=>Et(Qa(t,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async r=>{const o=await Ya(t,r);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function Dr(t){return"_zod"in t}function wa(t,e){return Dr(t)?kr(t):Or(t)}async function Qt({value:t,schema:e,context:a}){const s=await Ce({value:t,schema:e,context:a});if(!s.success)throw ge.wrap({value:t,cause:s.error,context:a});return s.value}async function Ce({value:t,schema:e,context:a}){const s=It(e);try{if(s.validate==null)return{success:!0,value:t,rawValue:t};const r=await s.validate(t);return r.success?{success:!0,value:r.value,rawValue:t}:{success:!1,error:ge.wrap({value:t,cause:r.error,context:a}),rawValue:t}}catch(r){return{success:!1,error:ge.wrap({value:t,cause:r,context:a}),rawValue:t}}}async function pe({text:t,schema:e}){try{const a=Vs(t);return e==null?{success:!0,value:a,rawValue:a}:await Ce({value:a,schema:e})}catch(a){return{success:!1,error:Bt.isInstance(a)?a:new Bt({text:t,cause:a}),rawValue:void 0}}}function $r({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new Ga).pipeThrough(new TransformStream({async transform({data:a},s){a!=="[DONE]"&&s.enqueue(await pe({text:a,schema:e}))}}))}async function le(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var Lr=Object.defineProperty,Zr=(t,e)=>{for(var a in e)Lr(t,a,{get:e[a],enumerable:!0})},Ca="AI_NoObjectGeneratedError",Na=`vercel.ai.error.${Ca}`,Fr=Symbol.for(Na),Ta,ce=class extends ae{constructor({message:t="No object generated.",cause:e,text:a,response:s,usage:r,finishReason:o}){super({name:Ca,message:t,cause:e}),this[Ta]=!0,this.text=a,this.response=s,this.usage=r,this.finishReason=o}static isInstance(t){return ae.hasMarker(t,Na)}};Ta=Fr;var Aa="AI_UIMessageStreamError",Ma=`vercel.ai.error.${Aa}`,Ur=Symbol.for(Ma),Ra,me=class extends ae{constructor({chunkType:t,chunkId:e,message:a}){super({name:Aa,message:a}),this[Ra]=!0,this.chunkType=t,this.chunkId=e}static isInstance(t){return ae.hasMarker(t,Ma)}};Ra=Ur;var Xt="6.0.72",ja=B([g(),Ve(Uint8Array),Ve(ArrayBuffer),ra(t=>{var e,a;return(a=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?a:!1},{message:"Must be a Buffer"})]),Ne=Xa(()=>B([Ka(),g(),es(),U(),Ie(g(),Ne.optional()),Te(Ne)])),T=Ie(g(),Ie(g(),Ne.optional())),Pa=P({type:E("text"),text:g(),providerOptions:T.optional()}),zr=P({type:E("image"),image:B([ja,Ve(URL)]),mediaType:g().optional(),providerOptions:T.optional()}),Oa=P({type:E("file"),data:B([ja,Ve(URL)]),filename:g().optional(),mediaType:g(),providerOptions:T.optional()}),Br=P({type:E("reasoning"),text:g(),providerOptions:T.optional()}),Vr=P({type:E("tool-call"),toolCallId:g(),toolName:g(),input:ne(),providerOptions:T.optional(),providerExecuted:U().optional()}),qr=ts("type",[P({type:E("text"),value:g(),providerOptions:T.optional()}),P({type:E("json"),value:Ne,providerOptions:T.optional()}),P({type:E("execution-denied"),reason:g().optional(),providerOptions:T.optional()}),P({type:E("error-text"),value:g(),providerOptions:T.optional()}),P({type:E("error-json"),value:Ne,providerOptions:T.optional()}),P({type:E("content"),value:Te(B([P({type:E("text"),text:g(),providerOptions:T.optional()}),P({type:E("media"),data:g(),mediaType:g()}),P({type:E("file-data"),data:g(),mediaType:g(),filename:g().optional(),providerOptions:T.optional()}),P({type:E("file-url"),url:g(),providerOptions:T.optional()}),P({type:E("file-id"),fileId:B([g(),Ie(g(),g())]),providerOptions:T.optional()}),P({type:E("image-data"),data:g(),mediaType:g(),providerOptions:T.optional()}),P({type:E("image-url"),url:g(),providerOptions:T.optional()}),P({type:E("image-file-id"),fileId:B([g(),Ie(g(),g())]),providerOptions:T.optional()}),P({type:E("custom"),providerOptions:T.optional()})]))})]),ka=P({type:E("tool-result"),toolCallId:g(),toolName:g(),output:qr,providerOptions:T.optional()}),Hr=P({type:E("tool-approval-request"),approvalId:g(),toolCallId:g()}),Wr=P({type:E("tool-approval-response"),approvalId:g(),approved:U(),reason:g().optional()}),Jr=P({role:E("system"),content:g(),providerOptions:T.optional()}),Gr=P({role:E("user"),content:B([g(),Te(B([Pa,zr,Oa]))]),providerOptions:T.optional()}),Yr=P({role:E("assistant"),content:B([g(),Te(B([Pa,Oa,Br,Vr,ka,Hr]))]),providerOptions:T.optional()}),Qr=P({role:E("tool"),content:Te(B([ka,Wr])),providerOptions:T.optional()});B([Jr,Gr,Yr,Qr]);function Da(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const a={...t};for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(r===void 0)continue;const o=s in t?t[s]:void 0,i=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),n=o!=null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp);i&&n?a[s]=Da(o,r):a[s]=r}return a}var Xr={};Zr(Xr,{array:()=>ao,choice:()=>so,json:()=>ro,object:()=>to,text:()=>eo});function Kr(t){const e=["ROOT"];let a=-1,s=null;function r(c,l,p){switch(c){case'"':{a=l,e.pop(),e.push(p),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{a=l,s=l,e.pop(),e.push(p),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=l,e.pop(),e.push(p),e.push("INSIDE_NUMBER");break}case"{":{a=l,e.pop(),e.push(p),e.push("INSIDE_OBJECT_START");break}case"[":{a=l,e.pop(),e.push(p),e.push("INSIDE_ARRAY_START");break}}}function o(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{a=l,e.pop();break}}}function i(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=l,e.pop();break}}}for(let c=0;c<t.length;c++){const l=t[c];switch(e[e.length-1]){case"ROOT":r(l,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{a=c,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(l){case":":{e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(l,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{o(l,c);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),a=c;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:a=c}break}case"INSIDE_ARRAY_START":{switch(l){case"]":{a=c,e.pop();break}default:{a=c,r(l,c,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=c,e.pop();break}default:{a=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(l,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),a=c;break}case"INSIDE_NUMBER":{switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=c;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(l,c);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(l,c);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const m=t.substring(s,c+1);!"false".startsWith(m)&&!"true".startsWith(m)&&!"null".startsWith(m)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?o(l,c):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c)):a=c;break}}}let n=t.slice(0,a+1);for(let c=e.length-1;c>=0;c--)switch(e[c]){case"INSIDE_STRING":{n+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{n+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{n+="]";break}case"INSIDE_LITERAL":{const p=t.substring(s,t.length);"true".startsWith(p)?n+="true".slice(p.length):"false".startsWith(p)?n+="false".slice(p.length):"null".startsWith(p)&&(n+="null".slice(p.length))}}return n}async function Me(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await pe({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await pe({text:Kr(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var eo=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),to=({schema:t,name:e,description:a})=>{const s=It(t);return{name:"object",responseFormat:le(s.jsonSchema).then(r=>({type:"json",schema:r,...e!=null&&{name:e},...a!=null&&{description:a}})),async parseCompleteOutput({text:r},o){const i=await pe({text:r});if(!i.success)throw new ce({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const n=await Ce({value:i.value,schema:s});if(!n.success)throw new ce({message:"No object generated: response did not match schema.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return n.value},async parsePartialOutput({text:r}){const o=await Me(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value}}},createElementStreamTransform(){}}},ao=({element:t,name:e,description:a})=>{const s=It(t);return{name:"array",responseFormat:le(s.jsonSchema).then(r=>{const{$schema:o,...i}=r;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:i}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}}),async parseCompleteOutput({text:r},o){const i=await pe({text:r});if(!i.success)throw new ce({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const n=i.value;if(n==null||typeof n!="object"||!("elements"in n)||!Array.isArray(n.elements))throw new ce({message:"No object generated: response did not match schema.",cause:new ge({value:n,cause:"response must be an object with an elements array"}),text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});for(const c of n.elements){const l=await Ce({value:c,schema:s});if(!l.success)throw new ce({message:"No object generated: response did not match schema.",cause:l.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason})}return n.elements},async parsePartialOutput({text:r}){const o=await Me(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const i=o.value;if(i==null||typeof i!="object"||!("elements"in i)||!Array.isArray(i.elements))return;const n=o.state==="repaired-parse"&&i.elements.length>0?i.elements.slice(0,-1):i.elements,c=[];for(const l of n){const p=await Ce({value:l,schema:s});p.success&&c.push(p.value)}return{partial:c}}}},createElementStreamTransform(){let r=0;return new TransformStream({transform({partialOutput:o},i){if(o!=null)for(;r<o.length;r++)i.enqueue(o[r])}})}}},so=({options:t,name:e,description:a})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}),async parseCompleteOutput({text:s},r){const o=await pe({text:s});if(!o.success)throw new ce({message:"No object generated: could not parse the response.",cause:o.error,text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=o.value;if(i==null||typeof i!="object"||!("result"in i)||typeof i.result!="string"||!t.includes(i.result))throw new ce({message:"No object generated: response did not match schema.",cause:new ge({value:i,cause:"response must be an object that contains a choice value."}),text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.result},async parsePartialOutput({text:s}){const r=await Me(s);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=r.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string")return;const i=t.filter(n=>n.startsWith(o.result));return r.state==="successful-parse"?i.includes(o.result)?{partial:o.result}:void 0:i.length===1?{partial:i[0]}:void 0}}},createElementStreamTransform(){}}),ro=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:a},s){const r=await pe({text:a});if(!r.success)throw new ce({message:"No object generated: could not parse the response.",cause:r.error,text:a,response:s.response,usage:s.usage,finishReason:s.finishReason});return r.value},async parsePartialOutput({text:a}){const s=await Me(a);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Ae({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
8
-
9
- `)},flush(t){t.enqueue(`data: [DONE]
10
-
11
- `)}})}});var oo=Rr(()=>wa(B([O({type:E("text-start"),id:g(),providerMetadata:T.optional()}),O({type:E("text-delta"),id:g(),delta:g(),providerMetadata:T.optional()}),O({type:E("text-end"),id:g(),providerMetadata:T.optional()}),O({type:E("error"),errorText:g()}),O({type:E("tool-input-start"),toolCallId:g(),toolName:g(),providerExecuted:U().optional(),providerMetadata:T.optional(),dynamic:U().optional(),title:g().optional()}),O({type:E("tool-input-delta"),toolCallId:g(),inputTextDelta:g()}),O({type:E("tool-input-available"),toolCallId:g(),toolName:g(),input:ne(),providerExecuted:U().optional(),providerMetadata:T.optional(),dynamic:U().optional(),title:g().optional()}),O({type:E("tool-input-error"),toolCallId:g(),toolName:g(),input:ne(),providerExecuted:U().optional(),providerMetadata:T.optional(),dynamic:U().optional(),errorText:g(),title:g().optional()}),O({type:E("tool-approval-request"),approvalId:g(),toolCallId:g()}),O({type:E("tool-output-available"),toolCallId:g(),output:ne(),providerExecuted:U().optional(),dynamic:U().optional(),preliminary:U().optional()}),O({type:E("tool-output-error"),toolCallId:g(),errorText:g(),providerExecuted:U().optional(),dynamic:U().optional()}),O({type:E("tool-output-denied"),toolCallId:g()}),O({type:E("reasoning-start"),id:g(),providerMetadata:T.optional()}),O({type:E("reasoning-delta"),id:g(),delta:g(),providerMetadata:T.optional()}),O({type:E("reasoning-end"),id:g(),providerMetadata:T.optional()}),O({type:E("source-url"),sourceId:g(),url:g(),title:g().optional(),providerMetadata:T.optional()}),O({type:E("source-document"),sourceId:g(),mediaType:g(),title:g(),filename:g().optional(),providerMetadata:T.optional()}),O({type:E("file"),url:g(),mediaType:g(),providerMetadata:T.optional()}),O({type:ra(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:g().optional(),data:ne(),transient:U().optional()}),O({type:E("start-step")}),O({type:E("finish-step")}),O({type:E("start"),messageId:g().optional(),messageMetadata:ne().optional()}),O({type:E("finish"),finishReason:as(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:ne().optional()}),O({type:E("abort"),reason:g().optional()}),O({type:E("message-metadata"),messageMetadata:ne()})])));function no(t){return t.type.startsWith("data-")}function ut(t){return t.type.startsWith("tool-")}function io(t){return t.type==="dynamic-tool"}function dt(t){return ut(t)||io(t)}function Kt(t){return t.type.split("-").slice(1).join("-")}function lo({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function co({stream:t,messageMetadataSchema:e,dataPartSchemas:a,runUpdateMessageJob:s,onError:r,onToolCall:o,onData:i}){return t.pipeThrough(new TransformStream({async transform(n,c){await s(async({state:l,write:p})=>{var m,h,y,v;function x(u){const A=l.message.parts.filter(dt).find(w=>w.toolCallId===u);if(A==null)throw new me({chunkType:"tool-invocation",chunkId:u,message:`No tool invocation found for tool call ID "${u}".`});return A}function _(u){var I;const A=l.message.parts.find(j=>ut(j)&&j.toolCallId===u.toolCallId),w=u,S=A;A!=null?(A.state=u.state,S.input=w.input,S.output=w.output,S.errorText=w.errorText,S.rawInput=w.rawInput,S.preliminary=w.preliminary,u.title!==void 0&&(S.title=u.title),S.providerExecuted=(I=w.providerExecuted)!=null?I:A.providerExecuted,w.providerMetadata!=null&&(A.callProviderMetadata=w.providerMetadata)):l.message.parts.push({type:`tool-${u.toolName}`,toolCallId:u.toolCallId,state:u.state,title:u.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null?{callProviderMetadata:w.providerMetadata}:{}})}function f(u){var I,A;const w=l.message.parts.find(L=>L.type==="dynamic-tool"&&L.toolCallId===u.toolCallId),S=u,j=w;w!=null?(w.state=u.state,j.toolName=u.toolName,j.input=S.input,j.output=S.output,j.errorText=S.errorText,j.rawInput=(I=S.rawInput)!=null?I:j.rawInput,j.preliminary=S.preliminary,u.title!==void 0&&(j.title=u.title),j.providerExecuted=(A=S.providerExecuted)!=null?A:w.providerExecuted,S.providerMetadata!=null&&(w.callProviderMetadata=S.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:u.toolName,toolCallId:u.toolCallId,state:u.state,input:S.input,output:S.output,errorText:S.errorText,preliminary:S.preliminary,providerExecuted:S.providerExecuted,title:u.title,...S.providerMetadata!=null?{callProviderMetadata:S.providerMetadata}:{}})}async function b(u){if(u!=null){const I=l.message.metadata!=null?Da(l.message.metadata,u):u;e!=null&&await Qt({value:I,schema:e,context:{field:"message.metadata",entityId:l.message.id}}),l.message.metadata=I}}switch(n.type){case"text-start":{const u={type:"text",text:"",providerMetadata:n.providerMetadata,state:"streaming"};l.activeTextParts[n.id]=u,l.message.parts.push(u),p();break}case"text-delta":{const u=l.activeTextParts[n.id];if(u==null)throw new me({chunkType:"text-delta",chunkId:n.id,message:`Received text-delta for missing text part with ID "${n.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});u.text+=n.delta,u.providerMetadata=(m=n.providerMetadata)!=null?m:u.providerMetadata,p();break}case"text-end":{const u=l.activeTextParts[n.id];if(u==null)throw new me({chunkType:"text-end",chunkId:n.id,message:`Received text-end for missing text part with ID "${n.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});u.state="done",u.providerMetadata=(h=n.providerMetadata)!=null?h:u.providerMetadata,delete l.activeTextParts[n.id],p();break}case"reasoning-start":{const u={type:"reasoning",text:"",providerMetadata:n.providerMetadata,state:"streaming"};l.activeReasoningParts[n.id]=u,l.message.parts.push(u),p();break}case"reasoning-delta":{const u=l.activeReasoningParts[n.id];if(u==null)throw new me({chunkType:"reasoning-delta",chunkId:n.id,message:`Received reasoning-delta for missing reasoning part with ID "${n.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});u.text+=n.delta,u.providerMetadata=(y=n.providerMetadata)!=null?y:u.providerMetadata,p();break}case"reasoning-end":{const u=l.activeReasoningParts[n.id];if(u==null)throw new me({chunkType:"reasoning-end",chunkId:n.id,message:`Received reasoning-end for missing reasoning part with ID "${n.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});u.providerMetadata=(v=n.providerMetadata)!=null?v:u.providerMetadata,u.state="done",delete l.activeReasoningParts[n.id],p();break}case"file":{l.message.parts.push({type:"file",mediaType:n.mediaType,url:n.url}),p();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:n.sourceId,url:n.url,title:n.title,providerMetadata:n.providerMetadata}),p();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:n.sourceId,mediaType:n.mediaType,title:n.title,filename:n.filename,providerMetadata:n.providerMetadata}),p();break}case"tool-input-start":{const u=l.message.parts.filter(ut);l.partialToolCalls[n.toolCallId]={text:"",toolName:n.toolName,index:u.length,dynamic:n.dynamic,title:n.title},n.dynamic?f({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-streaming",input:void 0,providerExecuted:n.providerExecuted,title:n.title,providerMetadata:n.providerMetadata}):_({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-streaming",input:void 0,providerExecuted:n.providerExecuted,title:n.title,providerMetadata:n.providerMetadata}),p();break}case"tool-input-delta":{const u=l.partialToolCalls[n.toolCallId];if(u==null)throw new me({chunkType:"tool-input-delta",chunkId:n.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${n.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});u.text+=n.inputTextDelta;const{value:I}=await Me(u.text);u.dynamic?f({toolCallId:n.toolCallId,toolName:u.toolName,state:"input-streaming",input:I,title:u.title}):_({toolCallId:n.toolCallId,toolName:u.toolName,state:"input-streaming",input:I,title:u.title}),p();break}case"tool-input-available":{n.dynamic?f({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-available",input:n.input,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata,title:n.title}):_({toolCallId:n.toolCallId,toolName:n.toolName,state:"input-available",input:n.input,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata,title:n.title}),p(),o&&!n.providerExecuted&&await o({toolCall:n});break}case"tool-input-error":{n.dynamic?f({toolCallId:n.toolCallId,toolName:n.toolName,state:"output-error",input:n.input,errorText:n.errorText,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata}):_({toolCallId:n.toolCallId,toolName:n.toolName,state:"output-error",input:void 0,rawInput:n.input,errorText:n.errorText,providerExecuted:n.providerExecuted,providerMetadata:n.providerMetadata}),p();break}case"tool-approval-request":{const u=x(n.toolCallId);u.state="approval-requested",u.approval={id:n.approvalId},p();break}case"tool-output-denied":{const u=x(n.toolCallId);u.state="output-denied",p();break}case"tool-output-available":{const u=x(n.toolCallId);u.type==="dynamic-tool"?f({toolCallId:n.toolCallId,toolName:u.toolName,state:"output-available",input:u.input,output:n.output,preliminary:n.preliminary,providerExecuted:n.providerExecuted,title:u.title}):_({toolCallId:n.toolCallId,toolName:Kt(u),state:"output-available",input:u.input,output:n.output,providerExecuted:n.providerExecuted,preliminary:n.preliminary,title:u.title}),p();break}case"tool-output-error":{const u=x(n.toolCallId);u.type==="dynamic-tool"?f({toolCallId:n.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:n.errorText,providerExecuted:n.providerExecuted,title:u.title}):_({toolCallId:n.toolCallId,toolName:Kt(u),state:"output-error",input:u.input,rawInput:u.rawInput,errorText:n.errorText,providerExecuted:n.providerExecuted,title:u.title}),p();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{n.messageId!=null&&(l.message.id=n.messageId),await b(n.messageMetadata),(n.messageId!=null||n.messageMetadata!=null)&&p();break}case"finish":{n.finishReason!=null&&(l.finishReason=n.finishReason),await b(n.messageMetadata),n.messageMetadata!=null&&p();break}case"message-metadata":{await b(n.messageMetadata),n.messageMetadata!=null&&p();break}case"error":{r?.(new Error(n.errorText));break}default:if(no(n)){if(a?.[n.type]!=null){const A=l.message.parts.findIndex(S=>"id"in S&&"data"in S&&S.id===n.id&&S.type===n.type),w=A>=0?A:l.message.parts.length;await Qt({value:n.data,schema:a[n.type],context:{field:`message.parts[${w}].data`,entityName:n.type,entityId:n.id}})}const u=n;if(u.transient){i?.(u);break}const I=u.id!=null?l.message.parts.find(A=>u.type===A.type&&u.id===A.id):void 0;I!=null?I.data=u.data:l.message.parts.push(u),i?.(u),p()}}c.enqueue(n)})}}))}async function uo({stream:t,onError:e}){const a=t.getReader();try{for(;;){const{done:s}=await a.read();if(s)break}}catch(s){e?.(s)}finally{a.releaseLock()}}Ae({prefix:"aitxt",size:24});Ae({prefix:"aiobj",size:24});var po=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,a)=>{this.queue.push(async()=>{try{await t(),e()}catch(s){a(s)}}),this.processQueue()})}};Ae({prefix:"aiobj",size:24});async function mo(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:a,type:s}=e,r=await new Promise((o,i)=>{const n=new FileReader;n.onload=c=>{var l;o((l=c.target)==null?void 0:l.result)},n.onerror=c=>i(c),n.readAsDataURL(e)});return{type:"file",mediaType:s,filename:a,url:r}}))}var fo=class{constructor({api:t="/api/chat",credentials:e,headers:a,body:s,fetch:r,prepareSendMessagesRequest:o,prepareReconnectToStreamRequest:i}){this.api=t,this.credentials=e,this.headers=a,this.body=s,this.fetch=r,this.prepareSendMessagesRequest=o,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:t,...e}){var a,s,r,o,i;const n=await le(this.body),c=await le(this.headers),l=await le(this.credentials),p={...de(c),...de(e.headers)},m=await((a=this.prepareSendMessagesRequest)==null?void 0:a.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...n,...e.body},headers:p,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),h=(s=m?.api)!=null?s:this.api,y=m?.headers!==void 0?de(m.headers):p,v=m?.body!==void 0?m.body:{...n,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},x=(r=m?.credentials)!=null?r:l,f=await((o=this.fetch)!=null?o:globalThis.fetch)(h,{method:"POST",headers:Wt({"Content-Type":"application/json",...y},`ai-sdk/${Xt}`,Ht()),body:JSON.stringify(v),credentials:x,signal:t});if(!f.ok)throw new Error((i=await f.text())!=null?i:"Failed to fetch the chat response.");if(!f.body)throw new Error("The response body is empty.");return this.processResponseStream(f.body)}async reconnectToStream(t){var e,a,s,r,o;const i=await le(this.body),n=await le(this.headers),c=await le(this.credentials),l={...de(n),...de(t.headers)},p=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...i,...t.body},headers:l,credentials:c,requestMetadata:t.metadata})),m=(a=p?.api)!=null?a:`${this.api}/${t.chatId}/stream`,h=p?.headers!==void 0?de(p.headers):l,y=(s=p?.credentials)!=null?s:c,x=await((r=this.fetch)!=null?r:globalThis.fetch)(m,{method:"GET",headers:Wt(h,`ai-sdk/${Xt}`,Ht()),credentials:y});if(x.status===204)return null;if(!x.ok)throw new Error((o=await x.text())!=null?o:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}},$a=class extends fo{constructor(t={}){super(t)}processResponseStream(t){return $r({stream:t,schema:oo}).pipeThrough(new TransformStream({async transform(e,a){if(!e.success)throw e.error;a.enqueue(e.value)}}))}},ho=class{constructor({generateId:t=Fs,id:e=t(),transport:a=new $a,messageMetadataSchema:s,dataPartSchemas:r,state:o,onError:i,onToolCall:n,onFinish:c,onData:l,sendAutomaticallyWhen:p}){this.activeResponse=void 0,this.jobExecutor=new po,this.sendMessage=async(m,h)=>{var y,v,x,_;if(m==null){await this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id,...h});return}let f;if("text"in m||"files"in m?f={parts:[...Array.isArray(m.files)?m.files:await mo(m.files),..."text"in m&&m.text!=null?[{type:"text",text:m.text}]:[]]}:f=m,m.messageId!=null){const b=this.state.messages.findIndex(u=>u.id===m.messageId);if(b===-1)throw new Error(`message with id ${m.messageId} not found`);if(this.state.messages[b].role!=="user")throw new Error(`message with id ${m.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,b+1),this.state.replaceMessage(b,{...f,id:m.messageId,role:(v=f.role)!=null?v:"user",metadata:m.metadata})}else this.state.pushMessage({...f,id:(x=f.id)!=null?x:this.generateId(),role:(_=f.role)!=null?_:"user",metadata:m.metadata});await this.makeRequest({trigger:"submit-message",messageId:m.messageId,...h})},this.regenerate=async({messageId:m,...h}={})=>{const y=m==null?this.state.messages.length-1:this.state.messages.findIndex(v=>v.id===m);if(y===-1)throw new Error(`message ${m} not found`);this.state.messages=this.state.messages.slice(0,this.messages[y].role==="assistant"?y:y+1),await this.makeRequest({trigger:"regenerate-message",messageId:m,...h})},this.resumeStream=async(m={})=>{await this.makeRequest({trigger:"resume-stream",...m})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:m,approved:h,reason:y})=>this.jobExecutor.run(async()=>{const v=this.state.messages,x=v[v.length-1],_=f=>dt(f)&&f.state==="approval-requested"&&f.approval.id===m?{...f,state:"approval-responded",approval:{id:m,approved:h,reason:y}}:f;this.state.replaceMessage(v.length-1,{...x,parts:x.parts.map(_)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(_)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(f=>{var b;f&&this.makeRequest({trigger:"submit-message",messageId:(b=this.lastMessage)==null?void 0:b.id})})}),this.addToolOutput=async({state:m="output-available",tool:h,toolCallId:y,output:v,errorText:x})=>this.jobExecutor.run(async()=>{const _=this.state.messages,f=_[_.length-1],b=u=>dt(u)&&u.toolCallId===y?{...u,state:m,output:v,errorText:x}:u;this.state.replaceMessage(_.length-1,{...f,parts:f.parts.map(b)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(b)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(u=>{var I;u&&this.makeRequest({trigger:"submit-message",messageId:(I=this.lastMessage)==null?void 0:I.id})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var m;this.status!=="streaming"&&this.status!=="submitted"||(m=this.activeResponse)!=null&&m.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=a,this.generateId=t,this.messageMetadataSchema=s,this.dataPartSchemas=r,this.state=o,this.onError=i,this.onToolCall=n,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=p}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const t=this.sendAutomaticallyWhen({messages:this.state.messages});return t&&typeof t=="object"&&"then"in t?await t:t}async makeRequest({trigger:t,metadata:e,headers:a,body:s,messageId:r}){var o,i,n;this.setStatus({status:"submitted",error:void 0});const c=this.lastMessage;let l=!1,p=!1,m=!1;try{const h={state:lo({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{l=!0}),this.activeResponse=h;let y;if(t==="resume-stream"){const x=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:a,body:s});if(x==null){this.setStatus({status:"ready"});return}y=x}else y=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:e,headers:a,body:s,trigger:t,messageId:r});const v=x=>this.jobExecutor.run(()=>x({state:h.state,write:()=>{var _;this.setStatus({status:"streaming"}),h.state.message.id===((_=this.lastMessage)==null?void 0:_.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await uo({stream:co({stream:y,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:v,onError:x=>{throw x}}),onError:x=>{throw x}}),this.setStatus({status:"ready"})}catch(h){if(l||h.name==="AbortError")return l=!0,this.setStatus({status:"ready"}),null;m=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(p=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:l,isDisconnect:p,isError:m,finishReason:(o=this.activeResponse)==null?void 0:o.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}!m&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(n=this.lastMessage)==null?void 0:n.id,metadata:e,headers:a,body:s})}},nt,ea;function go(){if(ea)return nt;ea=1;function t(e,a){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let s,r=0;return function(...i){clearTimeout(s);const n=Date.now(),c=n-r,l=a-c;l<=0?(r=n,e.apply(this,i)):s=setTimeout(()=>{r=Date.now(),e.apply(this,i)},l)}}return nt=t,nt}var vo=go();const yo=ss(vo);var La=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)},k=(t,e,a)=>(La(t,e,"read from private field"),a?a.call(t):e.get(t)),te=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},ie=(t,e,a,s)=>(La(t,e,"write to private field"),e.set(t,a),a);function xo(t,e){return e!=null?yo(t,e):t}var J,ze,Be,be,_e,Ee,fe,pt,mt,bo=class{constructor(t=[]){te(this,J,void 0),te(this,ze,"ready"),te(this,Be,void 0),te(this,be,new Set),te(this,_e,new Set),te(this,Ee,new Set),this.pushMessage=e=>{ie(this,J,k(this,J).concat(e)),k(this,fe).call(this)},this.popMessage=()=>{ie(this,J,k(this,J).slice(0,-1)),k(this,fe).call(this)},this.replaceMessage=(e,a)=>{ie(this,J,[...k(this,J).slice(0,e),this.snapshot(a),...k(this,J).slice(e+1)]),k(this,fe).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,a)=>{const s=a?xo(e,a):e;return k(this,be).add(s),()=>{k(this,be).delete(s)}},this["~registerStatusCallback"]=e=>(k(this,_e).add(e),()=>{k(this,_e).delete(e)}),this["~registerErrorCallback"]=e=>(k(this,Ee).add(e),()=>{k(this,Ee).delete(e)}),te(this,fe,()=>{k(this,be).forEach(e=>e())}),te(this,pt,()=>{k(this,_e).forEach(e=>e())}),te(this,mt,()=>{k(this,Ee).forEach(e=>e())}),ie(this,J,t)}get status(){return k(this,ze)}set status(t){ie(this,ze,t),k(this,pt).call(this)}get error(){return k(this,Be)}set error(t){ie(this,Be,t),k(this,mt).call(this)}get messages(){return k(this,J)}set messages(t){ie(this,J,[...t]),k(this,fe).call(this)}};J=new WeakMap;ze=new WeakMap;Be=new WeakMap;be=new WeakMap;_e=new WeakMap;Ee=new WeakMap;fe=new WeakMap;pt=new WeakMap;mt=new WeakMap;var he,ta=class extends ho{constructor({messages:t,...e}){const a=new bo(t);super({...e,state:a}),te(this,he,void 0),this["~registerMessagesCallback"]=(s,r)=>k(this,he)["~registerMessagesCallback"](s,r),this["~registerStatusCallback"]=s=>k(this,he)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>k(this,he)["~registerErrorCallback"](s),ie(this,he,a)}};he=new WeakMap;function _o({experimental_throttle:t,resume:e=!1,...a}={}){const s=N.useRef("chat"in a?{}:{onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});"chat"in a||(s.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});const r={...a,onToolCall:h=>{var y,v;return(v=(y=s.current).onToolCall)==null?void 0:v.call(y,h)},onData:h=>{var y,v;return(v=(y=s.current).onData)==null?void 0:v.call(y,h)},onFinish:h=>{var y,v;return(v=(y=s.current).onFinish)==null?void 0:v.call(y,h)},onError:h=>{var y,v;return(v=(y=s.current).onError)==null?void 0:v.call(y,h)},sendAutomaticallyWhen:h=>{var y,v,x;return(x=(v=(y=s.current).sendAutomaticallyWhen)==null?void 0:v.call(y,h))!=null?x:!1}},o=N.useRef("chat"in a?a.chat:new ta(r));("chat"in a&&a.chat!==o.current||"id"in a&&o.current.id!==a.id)&&(o.current="chat"in a?a.chat:new ta(r));const n=N.useCallback(h=>o.current["~registerMessagesCallback"](h,t),[t,o.current.id]),c=N.useSyncExternalStore(n,()=>o.current.messages,()=>o.current.messages),l=N.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),p=N.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),m=N.useCallback(h=>{typeof h=="function"&&(h=h(o.current.messages)),o.current.messages=h},[o]);return N.useEffect(()=>{e&&o.current.resumeStream()},[e,o]),{id:o.current.id,messages:c,setMessages:m,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:p,resumeStream:o.current.resumeStream,status:l,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput,addToolApprovalResponse:o.current.addToolApprovalResponse}}function Eo(t,e){const a=D.c(5);let s;a[0]!==e?(s=e===void 0?{}:e,a[0]=e,a[1]=s):s=a[1];const r=s,{org:o}=ve();let i;a[2]!==t||a[3]!==o.id?(i={connectionId:t,orgId:o.id},a[2]=t,a[3]=o.id,a[4]=i):i=a[4];const n=ps(i);return na(t??"no-connection","LLM",n,r)}function St(){const t=D.c(2),e=hs();let a;return t[0]!==e?(a={connections:e,binding:"LLMS"},t[0]=e,t[1]=a):a=t[1],ys(a)}function Io(t){const e=D.c(10);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const s=oa(a);let r;if(e[1]!==s.collectionName||e[2]!==s.connectionId||e[3]!==s.itemId||e[4]!==t){r=[],t&&r.push(`### Selected Agent
12
- - ID: ${t}`);let o;e[6]!==s.collectionName||e[7]!==s.connectionId||e[8]!==s.itemId?(o=[],s.connectionId&&o.push(`- Connection ID: ${s.connectionId}`),s.collectionName&&o.push(`- Collection: ${s.collectionName}`),s.itemId&&o.push(`- Item ID: ${s.itemId}`),e[6]=s.collectionName,e[7]=s.connectionId,e[8]=s.itemId,e[9]=o):o=e[9],o.length>0&&r.push(`### Current Resource
13
- The user is viewing the following resource:
14
- ${o.join(`
15
- `)}
16
-
17
- Help the user understand and work with this resource.`),e[1]=s.collectionName,e[2]=s.connectionId,e[3]=s.itemId,e[4]=t,e[5]=r}else r=e[5];return r.join(`
18
-
19
- `)}function So(){const t=D.c(2),e=ht();let a;return t[0]!==e?(a={prefillCollectionCache:(r,o,i,n)=>{if(!r)return;const c=bt(r,o,i,n);if(e.getQueryData(c))return;const p={structuredContent:{items:[]},isError:!1};e.setQueryData(c,p)}},t[0]=e,t[1]=a):a=t[1],a}const se={THREAD_MESSAGES_PAGE_SIZE:100,THREADS_PAGE_SIZE:50,QUERY_STALE_TIME:3e4};function aa(t,e,a,s){const r=He.threads(e),o=t.getQueryData(r);if(!o)return;const i=o.pages.map(c=>{const l=c.items.findIndex(y=>y.id===a);if(l===-1)return c;const p=[...c.items],m=p[l];if(!m)return c;const h={id:m.id,title:s.title??m.title,createdAt:m.createdAt,updatedAt:s.updatedAt??m.updatedAt,hidden:s.hidden??m.hidden};return p[l]=h,{...c,items:p}});i.some((c,l)=>c.items.length!==o.pages[l]?.items.length||c.items.some((p,m)=>p.id===a&&p!==o.pages[l]?.items[m]))&&t.setQueryData(r,{...o,pages:i})}function wo(t,e,a){const s=He.threads(e),r=t.getQueryData(s);if(!r){t.setQueryData(s,{pages:[{items:[a],hasMore:!1,totalCount:1}],pageParams:[0]});return}if(r.pages.some(n=>n.items.some(c=>c.id===a.id)))return;const i=r.pages[0];if(i){const n={...i,items:[a,...i.items],totalCount:(i.totalCount??i.items.length)+1};t.setQueryData(s,{...r,pages:[n,...r.pages.slice(1)]})}else t.setQueryData(s,{...r,pages:[{items:[a],hasMore:!1,totalCount:1}]})}async function Co(t,e,a,s){if(!e)return;const r=bt(e,"THREAD_MESSAGES",a,{filters:[{column:"threadId",value:s}],pageSize:se.THREAD_MESSAGES_PAGE_SIZE});if(!r||t.getQueryData(r))return;const i="COLLECTION_THREAD_MESSAGES_LIST",n=gs(void 0,[{column:"threadId",value:s}],[]),c=vs(void 0,void 0,"updated_at"),l={...n&&{where:n},...c&&{orderBy:c},limit:se.THREAD_MESSAGES_PAGE_SIZE,offset:0};await t.fetchQuery({queryKey:r,queryFn:async()=>await e.callTool({name:i,arguments:l}),staleTime:se.QUERY_STALE_TIME,retry:!1})}function No(t,e,a,s,r){if(!e)return;const o=bt(e,"THREAD_MESSAGES",a,{filters:[{column:"threadId",value:s}],pageSize:se.THREAD_MESSAGES_PAGE_SIZE});o&&t.setQueryData(o,{structuredContent:{items:r},isError:!1})}async function To(t,e,a){if(!t)throw new Error("MCP client is not available");const s=await t.callTool({name:"COLLECTION_THREADS_UPDATE",arguments:{id:e,data:a}});return(s.structuredContent??s).item}function Ao(t){const e=new Date().toISOString();return{id:t,title:"New chat",createdAt:e,updatedAt:e}}function Mo(t,e){return t.find(a=>a.id!==e)??null}function Ro(){const t=D.c(17),{locator:e,org:a}=ve();let s;t[0]!==a.id?(s={connectionId:xt,orgId:a.id},t[0]=a.id,t[1]=s):s=t[1];const r=yt(s);let o;t[2]!==e?(o=He.threads(e),t[2]=e,t[3]=o):o=t[3];let i;t[4]!==r?(i=async _=>{const{pageParam:f}=_,b=f===void 0?0:f;if(!r)throw new Error("MCP client is not available");const u={limit:se.THREADS_PAGE_SIZE,offset:b},I=await r.callTool({name:"COLLECTION_THREADS_LIST",arguments:u}),A=I.structuredContent??I;return{items:A.items??[],hasMore:A.hasMore??!1,totalCount:A.totalCount}},t[4]=r,t[5]=i):i=t[5];let n;t[6]!==o||t[7]!==i?(n={queryKey:o,queryFn:i,getNextPageParam:Po,initialPageParam:0,staleTime:se.QUERY_STALE_TIME},t[6]=o,t[7]=i,t[8]=n):n=t[8];const{data:c,fetchNextPage:l,hasNextPage:p,isFetchingNextPage:m,refetch:h}=xs(n);let y;t[9]!==c?.pages?(y=c?.pages.flatMap(jo)??[],t[9]=c?.pages,t[10]=y):y=t[10];const v=y;let x;return t[11]!==l||t[12]!==p||t[13]!==m||t[14]!==h||t[15]!==v?(x={threads:v,refetch:h,hasNextPage:p,isFetchingNextPage:m,fetchNextPage:l},t[11]=l,t[12]=p,t[13]=m,t[14]=h,t[15]=v,t[16]=x):x=t[16],x}function jo(t){return t.items}function Po(t,e){if(t.hasMore)return e.length*se.THREADS_PAGE_SIZE}function Oo(t){const e=D.c(6),{org:a}=ve();let s;e[0]!==a.id?(s={connectionId:xt,orgId:a.id},e[0]=a.id,e[1]=s):s=e[1];const r=yt(s);let o;e[2]!==t?(o={filters:t?[{column:"threadId",value:t}]:[],pageSize:se.THREAD_MESSAGES_PAGE_SIZE},e[2]=t,e[3]=o):o=e[3];const i=na(a.id,"THREAD_MESSAGES",r,o);let n;return e[4]!==i?(n=i??[],e[4]=i,e[5]=n):n=e[5],n}function ko(){const{locator:t,org:e}=ve(),a=ht(),{prefillCollectionCache:s}=So(),{threads:r,hasNextPage:o,isFetchingNextPage:i,fetchNextPage:n}=Ro(),c=yt({connectionId:xt,orgId:e.id}),[l,p]=Se(We.assistantChatActiveThread(t),r[0]?.id??crypto.randomUUID()),m=Oo(l),h=()=>{const f=crypto.randomUUID(),b=Ao(f);wo(a,t,b),c&&s(c,"THREAD_MESSAGES",e.id,{filters:[{column:"threadId",value:f}],pageSize:se.THREAD_MESSAGES_PAGE_SIZE}),p(f)},y=async f=>{await Co(a,c,e.id,f),p(f)};return{threads:r,activeThreadId:l,messages:m,hasNextPage:o,isFetchingNextPage:i,fetchNextPage:n,createThread:h,switchThread:y,updateThread:(f,b)=>{aa(a,t,f,b)},hideThread:async f=>{try{const b=await To(c,f,{hidden:!0});if(b){if(f===l){const I=Mo(r,f);I?await y(I.id):h()}aa(a,t,f,{hidden:!0,updatedAt:b.updatedAt??new Date().toISOString()})}}catch(b){const u=b;gt.error(`Failed to update thread: ${u.message}`),console.error("[chat] Failed to update thread:",b)}},updateMessagesCache:(f,b)=>{No(a,c,e.id,f,b)}}}function Do(){const t=D.c(5),e=ht(),{org:a}=ve();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=oa(s);let o;return t[1]!==a||t[2]!==r||t[3]!==e?(o=i=>{const c=i.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!c||!c[1])return;const l=c[1],p=r.connectionId;if(!p)return;e.invalidateQueries({queryKey:He.collection(a.slug,p,l)});const m=l.toLowerCase().replace(/_/g," ");gt.success(`${m} updated`)},t[1]=a,t[2]=r,t[3]=e,t[4]=o):o=t[4],o}function z(t){const e=D.c(8);let a,s;e[0]!==t?({className:a,...s}=t,e[0]=t,e[1]=a,e[2]=s):(a=e[1],s=e[2]);let r;e[3]!==a?(r=_t("bg-accent animate-pulse rounded-md",a),e[3]=a,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=d.jsx("div",{"data-slot":"skeleton",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const $o=["x-ai/grok-code-fast-1","anthropic/claude-sonnet-4.5","google/gemini-2.5-flash","xiaomi/mimo-v2-flash:free","google/gemini-3-flash-preview","deepseek/deepseek-v3.2","anthropic/claude-opus-4.5","x-ai/grok-4.1-fast","google/gemini-2.5-flash-lite","google/gemini-2.0-flash-001"],ft=new Map;$o.forEach((t,e)=>{ft.set(t,e)});function wt(t){const e=D.c(3);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={pageSize:999},e[0]=a):a=e[0];const s=Eo(t??void 0,a);let r;return e[1]!==s?(r=s.filter(Zo).sort(Lo),e[1]=s,e[2]=r):r=e[2],r}function Lo(t,e){const a=ft.get(t.id),s=ft.get(e.id);return a!==void 0&&s!==void 0?a-s:a!==void 0?-1:s!==void 0?1:t.title.localeCompare(e.title)}function Zo(t){return t.limits?.contextWindow&&t.limits?.maxOutputTokens}const Fo={reasoning:{icon:d.jsx(da,{className:"size-4"}),label:"Reasoning"},"image-upload":{icon:d.jsx(js,{className:"size-4"}),label:"Can analyze images"},"file-upload":{icon:d.jsx(Ms,{className:"size-4"}),label:"Can analyze files"},"web-search":{icon:d.jsx(ia,{className:"size-4"}),label:"Can search the web to answer questions"}};function Za(t){const e=D.c(10),{capability:a}=t,s=Fo[a];let r,o;e[0]!==a||e[1]!==s?(r=s||{icon:null,label:a},o=r.label.split("-").map(Uo).join(" "),e[0]=a,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]);const i=o;let n;e[4]===Symbol.for("react.memo_cache_sentinel")?(n={backgroundColor:"color-mix(in oklch, var(--chart-1) 15%, transparent)",color:"var(--chart-1)"},e[4]=n):n=e[4];let c;e[5]!==i?(c=d.jsx("span",{children:i}),e[5]=i,e[6]=c):c=e[6];let l;return e[7]!==r.icon||e[8]!==c?(l=d.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 px-1.5 rounded-md text-xs font-medium",style:n,children:[r.icon,c]}),e[7]=r.icon,e[8]=c,e[9]=l):l=e[9],l}function Uo(t){return t.charAt(0).toUpperCase()+t.slice(1)}function zo(t){const e=D.c(53),{model:a,compact:s}=t,r=s===void 0?!1:s;if(!a){let _;return e[0]===Symbol.for("react.memo_cache_sentinel")?(_=d.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Hover to preview"}),e[0]=_):_=e[0],_}const o=a.limits?.contextWindow||a.costs?.input||a.costs?.output||a.limits?.maxOutputTokens;if(!o&&!r){let _;e[1]!==a.logo||e[2]!==a.title?(_=a.logo&&d.jsx("img",{src:a.logo,className:"w-6 h-6",alt:a.title}),e[1]=a.logo,e[2]=a.title,e[3]=_):_=e[3];let f;e[4]!==a.title?(f=d.jsx("p",{className:"text-lg font-medium leading-7",children:a.title}),e[4]=a.title,e[5]=f):f=e[5];let b;e[6]!==_||e[7]!==f?(b=d.jsxs("div",{className:"flex items-center gap-3 py-2 px-0",children:[_,f]}),e[6]=_,e[7]=f,e[8]=b):b=e[8];let u;e[9]!==a.description?(u=a.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),e[9]=a.description,e[10]=u):u=e[10];let I;return e[11]!==b||e[12]!==u?(I=d.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[b,u]}),e[11]=b,e[12]=u,e[13]=I):I=e[13],I}if(!o&&r)return null;if(r){let _;e[14]!==a.limits?(_=a.limits?.contextWindow&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Context"}),d.jsxs("span",{className:"text-foreground font-medium",children:[a.limits.contextWindow.toLocaleString()," tokens"]})]}),e[14]=a.limits,e[15]=_):_=e[15];let f;e[16]!==a.costs?(f=a.costs?.input&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Input cost"}),d.jsxs("span",{className:"text-foreground font-medium",children:["$",a.costs.input.toFixed(2)," / 1M"]})]}),e[16]=a.costs,e[17]=f):f=e[17];let b;e[18]!==a.costs?(b=a.costs?.output&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Output cost"}),d.jsxs("span",{className:"text-foreground font-medium",children:["$",a.costs.output.toFixed(2)," / 1M"]})]}),e[18]=a.costs,e[19]=b):b=e[19];let u;e[20]!==a.limits?(u=a.limits?.maxOutputTokens&&d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),d.jsxs("span",{className:"text-foreground font-medium",children:[a.limits.maxOutputTokens.toLocaleString()," tokens"]})]}),e[20]=a.limits,e[21]=u):u=e[21];let I;return e[22]!==_||e[23]!==f||e[24]!==b||e[25]!==u?(I=d.jsxs("div",{className:"flex flex-col gap-2.5 pt-3 pb-3 px-3 rounded-b-lg text-xs",children:[_,f,b,u]}),e[22]=_,e[23]=f,e[24]=b,e[25]=u,e[26]=I):I=e[26],I}let i;e[27]!==a.logo||e[28]!==a.title?(i=a.logo&&d.jsx("img",{src:a.logo,className:"w-6 h-6 shrink-0",alt:a.title}),e[27]=a.logo,e[28]=a.title,e[29]=i):i=e[29];let n;e[30]!==a.title?(n=d.jsx("p",{className:"text-lg font-medium leading-7 wrap-break-word min-w-0",children:a.title}),e[30]=a.title,e[31]=n):n=e[31];let c;e[32]!==i||e[33]!==n?(c=d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i,n]}),e[32]=i,e[33]=n,e[34]=c):c=e[34];let l;e[35]!==a.capabilities?(l=a.capabilities&&a.capabilities.length>0&&d.jsx("div",{className:"flex items-center gap-2",children:a.capabilities.map(Bo)}),e[35]=a.capabilities,e[36]=l):l=e[36];let p;e[37]!==c||e[38]!==l?(p=d.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[c,l]}),e[37]=c,e[38]=l,e[39]=p):p=e[39];let m;e[40]!==a.limits?(m=a.limits?.contextWindow&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Rs,{className:"w-3.5 h-3.5 text-muted-foreground"}),d.jsx("p",{className:"text-sm text-foreground",children:"Context window"})]}),d.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.limits.contextWindow.toLocaleString()," tokens"]})]}),e[40]=a.limits,e[41]=m):m=e[41];let h;e[42]!==a.costs?(h=(a.costs?.input||a.costs?.output)&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(ca,{className:"w-3.5 h-3.5 text-muted-foreground"}),d.jsx("p",{className:"text-sm text-foreground",children:"Costs"})]}),d.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.costs?.input!==null&&a.costs?.input!==void 0&&d.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",a.costs.input.toFixed(2)," / 1M tokens (input)"]}),a.costs?.output!==null&&a.costs?.output!==void 0&&d.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",a.costs.output.toFixed(2)," / 1M tokens (output)"]})]})]}),e[42]=a.costs,e[43]=h):h=e[43];let y;e[44]!==a.limits?(y=a.limits?.maxOutputTokens&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(ua,{className:"w-4.5 h-4.5 text-muted-foreground/70"}),d.jsx("p",{className:"text-sm text-foreground",children:"Output limit"})]}),d.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.limits.maxOutputTokens.toLocaleString()," token limit"]})]}),e[44]=a.limits,e[45]=y):y=e[45];let v;e[46]!==m||e[47]!==h||e[48]!==y?(v=d.jsxs("div",{className:"flex flex-col gap-4",children:[m,h,y]}),e[46]=m,e[47]=h,e[48]=y,e[49]=v):v=e[49];let x;return e[50]!==v||e[51]!==p?(x=d.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[p,v]}),e[50]=v,e[51]=p,e[52]=x):x=e[52],x}function Bo(t){return d.jsx(Za,{capability:t},t)}function Vo(t){const e=D.c(15),{model:a,onHover:s}=t;let r;e[0]!==a||e[1]!==s?(r=()=>s(a),e[0]=a,e[1]=s,e[2]=r):r=e[2];let o;e[3]!==a.logo||e[4]!==a.title?(o=a.logo&&d.jsx("img",{src:a.logo,className:"w-5 h-5 shrink-0",alt:a.title}),e[3]=a.logo,e[4]=a.title,e[5]=o):o=e[5];let i;e[6]!==a.title?(i=d.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:a.title}),e[6]=a.title,e[7]=i):i=e[7];let n;e[8]!==a.capabilities?(n=a.capabilities&&a.capabilities.length>0&&d.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:a.capabilities.slice(0,2).map(qo)}),e[8]=a.capabilities,e[9]=n):n=e[9];let c;return e[10]!==r||e[11]!==o||e[12]!==i||e[13]!==n?(c=d.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:r,children:[o,i,n]}),e[10]=r,e[11]=o,e[12]=i,e[13]=n,e[14]=c):c=e[14],c}function qo(t){return d.jsx(Za,{capability:t},t)}function Ho(t){const e=D.c(14),{model:a,placeholder:s}=t,r=s===void 0?"Select model":s;if(!a){let l;e[0]!==r?(l=d.jsx("span",{className:"text-sm text-muted-foreground",children:r}),e[0]=r,e[1]=l):l=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=d.jsx(Ot,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[2]=p):p=e[2];let m;return e[3]!==l?(m=d.jsxs("div",{className:"flex items-center gap-1.5",children:[l,p]}),e[3]=l,e[4]=m):m=e[4],m}let o;e[5]!==a.logo||e[6]!==a.title?(o=a.logo&&d.jsx("img",{src:a.logo,className:"w-5 h-5 shrink-0 rounded-sm",alt:a.title}),e[5]=a.logo,e[6]=a.title,e[7]=o):o=e[7];let i;e[8]!==a.title?(i=d.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground group-data-[state=open]:text-foreground truncate whitespace-nowrap max-w-0 opacity-0 group-hover:max-w-[150px] group-hover:opacity-100 group-data-[state=open]:max-w-[150px] group-data-[state=open]:opacity-100 transition-all duration-200 ease-in-out overflow-hidden",children:a.title}),e[8]=a.title,e[9]=i):i=e[9];let n;e[10]===Symbol.for("react.memo_cache_sentinel")?(n=d.jsx(Ot,{size:14,className:"text-muted-foreground opacity-0 max-w-0 group-hover:opacity-50 group-hover:max-w-[14px] group-data-[state=open]:opacity-50 group-data-[state=open]:max-w-[14px] shrink-0 transition-all duration-200 ease-in-out overflow-hidden"}),e[10]=n):n=e[10];let c;return e[11]!==o||e[12]!==i?(c=d.jsxs("div",{className:"flex items-center gap-0 group-hover:gap-2 group-data-[state=open]:gap-2 min-w-0 overflow-hidden transition-all duration-200",children:[o,i,n]}),e[11]=o,e[12]=i,e[13]=c):c=e[13],c}function Rn(t){return t?.capabilities?.includes("vision")===!0}function Wo(){const t=D.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=d.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:d.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[d.jsx(z,{className:"size-4 shrink-0"}),d.jsx(z,{className:"flex-1 h-6"}),d.jsx(z,{className:"w-[140px] h-8 shrink-0"})]})}),t[0]=e):e=t[0];let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=d.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[e,d.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2 space-y-1",children:Array.from({length:6}).map(Jo)})]}),t[1]=a):a=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=d.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[d.jsx(z,{className:"size-6 shrink-0"}),d.jsx(z,{className:"h-6 w-32"})]}),t[2]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=d.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[s,d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(z,{className:"h-6 w-20 rounded-md"}),d.jsx(z,{className:"h-6 w-24 rounded-md"})]})]}),t[3]=r):r=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx(z,{className:"h-4 w-24"}),d.jsx(z,{className:"h-4 w-32"})]}),t[4]=o):o=t[4];let i;return t[5]===Symbol.for("react.memo_cache_sentinel")?(i=d.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[a,d.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:d.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[r,d.jsxs("div",{className:"flex flex-col gap-4",children:[o,d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx(z,{className:"h-4 w-16"}),d.jsx(z,{className:"h-4 w-40"})]})]})]})})]}),t[5]=i):i=t[5],i}function Jo(t,e){return d.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[d.jsx(z,{className:"size-5 shrink-0 rounded-sm"}),d.jsx(z,{className:"flex-1 h-4"}),d.jsx(z,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function Go(t){const e=D.c(39),{selectedModel:a,onModelChange:s,onClose:r,modelsConnections:o}=t,[i,n]=N.useState(null),[c,l]=N.useState(""),p=N.useRef(null),[m,h]=N.useState(a?.connectionId??null),y=St(),v=o??y,x=wt(m??void 0);let _,f;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{setTimeout(()=>{p.current?.focus()},0)},f=[],e[0]=_,e[1]=f):(_=e[0],f=e[1]),N.useEffect(_,f);let b;e[2]!==x||e[3]!==c?(b=c.trim()?x.filter($=>{const V=c.toLowerCase();return $.title.toLowerCase().includes(V)||$.provider?.toLowerCase().includes(V)||$.description?.toLowerCase().includes(V)}):x,e[2]=x,e[3]=c,e[4]=b):b=e[4];const u=b;let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=$=>{h($)},e[5]=I):I=e[5];const A=I;let w;e[6]!==x||e[7]!==r||e[8]!==s||e[9]!==m?(w=$=>{const V=x.find(ye=>ye.id===$);!V||!m||(s({id:V.id,connectionId:m,provider:V.provider??void 0}),l(""),r())},e[6]=x,e[7]=r,e[8]=s,e[9]=m,e[10]=w):w=e[10];const S=w;let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=d.jsx(ia,{size:16,className:"text-muted-foreground shrink-0"}),e[11]=j):j=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=$=>l($.target.value),e[12]=L):L=e[12];let Z;e[13]!==c?(Z=d.jsx(_s,{ref:p,type:"text",placeholder:"Search for a model...",value:c,onChange:L,className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[13]=c,e[14]=Z):Z=e[14];let W;e[15]!==v||e[16]!==m?(W=v.length>0&&d.jsxs(ws,{value:m??"",onValueChange:A,children:[d.jsxs(Cs,{size:"sm",className:"w-auto min-w-[140px] h-8 shrink-0 [&>svg:last-child]:hidden",onClick:Qo,children:[d.jsx(Ns,{placeholder:"Select connection"}),d.jsx(la,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),d.jsx(Ts,{children:v.map(Yo)})]}),e[15]=v,e[16]=m,e[17]=W):W=e[17];let G;e[18]!==Z||e[19]!==W?(G=d.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:d.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[j,Z,W]})}),e[18]=Z,e[19]=W,e[20]=G):G=e[20];let K;e[21]!==u||e[22]!==S||e[23]!==a?.id?(K=u.length>0?u.map($=>{const V=$.id===a?.id;return d.jsx("div",{onClick:()=>S($.id),className:_t("rounded-lg mb-1",V&&"bg-accent"),children:d.jsx(Vo,{model:$,onHover:n})},$.id)}):d.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No models found"}),e[21]=u,e[22]=S,e[23]=a?.id,e[24]=K):K=e[24];let re;e[25]!==K?(re=d.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 pt-2",children:K}),e[25]=K,e[26]=re):re=e[26];let Y;e[27]!==G||e[28]!==re?(Y=d.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[400px] md:min-w-[400px]",children:[G,re]}),e[27]=G,e[28]=re,e[29]=Y):Y=e[29];let M;e[30]!==i||e[31]!==x||e[32]!==a?(M=i||(a?x.find($=>$.id===a.id):null)||null,e[30]=i,e[31]=x,e[32]=a,e[33]=M):M=e[33];let ee;e[34]!==M?(ee=d.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:d.jsx(zo,{model:M})}),e[34]=M,e[35]=ee):ee=e[35];let oe;return e[36]!==Y||e[37]!==ee?(oe=d.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[Y,ee]}),e[36]=Y,e[37]=ee,e[38]=oe):oe=e[38],oe}function Yo(t){return d.jsx(As,{value:t.id,children:d.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?d.jsx("img",{src:t.icon,alt:t.title,className:"w-4 h-4 rounded"}):d.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:t.title.slice(0,1).toUpperCase()}),d.jsx("span",{children:t.title})]})},t.id)}function Qo(t){return t.stopPropagation()}function jn(t){const e=D.c(23),{selectedModel:a,onModelChange:s,modelsConnections:r,variant:o,className:i,placeholder:n}=t,c=o===void 0?"borderless":o,l=n===void 0?"Select model":n,[p,m]=N.useState(!1),h=St(),y=r??h,v=a?.connectionId??null,x=wt(v??void 0);let _;e[0]!==x||e[1]!==a?(_=a?x.find(W=>W.id===a.id):void 0,e[0]=x,e[1]=a,e[2]=_):_=e[2];const f=_;if(y.length===0)return null;const b=c==="borderless"?"ghost":"outline",u=c==="borderless"&&"md:border-none";let I;e[3]!==i||e[4]!==u?(I=_t("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer border-0 group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 shrink justify-start overflow-hidden",u,i),e[3]=i,e[4]=u,e[5]=I):I=e[5];let A;e[6]!==f||e[7]!==l?(A=d.jsx(Ho,{model:f,placeholder:l}),e[6]=f,e[7]=l,e[8]=A):A=e[8];let w;e[9]!==b||e[10]!==I||e[11]!==A?(w=d.jsx(Es,{asChild:!0,children:d.jsx(bs,{variant:b,size:"sm",className:I,children:A})}),e[9]=b,e[10]=I,e[11]=A,e[12]=w):w=e[12];let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=d.jsx(Wo,{}),e[13]=S):S=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=()=>m(!1),e[14]=j):j=e[14];let L;e[15]!==y||e[16]!==s||e[17]!==a?(L=d.jsx(Is,{className:"w-full md:w-auto p-0",align:"start",side:"bottom",sideOffset:8,children:d.jsx(N.Suspense,{fallback:S,children:d.jsx(Go,{selectedModel:a,onModelChange:s,onClose:j,modelsConnections:y})})}),e[15]=y,e[16]=s,e[17]=a,e[18]=L):L=e[18];let Z;return e[19]!==p||e[20]!==L||e[21]!==w?(Z=d.jsxs(Ss,{open:p,onOpenChange:m,children:[w,L]}),e[19]=p,e[20]=L,e[21]=w,e[22]=Z):Z=e[22],Z}const Xo=t=>new $a({api:`/api/${t}/decopilot/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:a={}})=>{const{system:s,tiptapDoc:r,...o}=a,i=s?{id:crypto.randomUUID(),role:"system",parts:[{type:"text",text:s}]}:null,n=e.slice(-1).filter(Boolean);return{body:{messages:i?[i,...n]:n,...o}}}}),sa=(t,e)=>t?.find(a=>a.id===e)??t?.[0]??null,Ko=(t,e)=>{const a=D.c(17);let s;a[0]!==t?(s=We.chatSelectedModel(t),a[0]=t,a[1]=s):s=a[1];const[r,o]=Se(s,null),i=r?.connectionId;let n;a[2]!==e||a[3]!==i?(n=sa(e,i),a[2]=e,a[3]=i,a[4]=n):n=a[4];const c=n,l=wt(c?.id);let p;a[5]!==l?(p=l.filter(nn).reduce(ln,void 0),a[5]=l,a[6]=p):p=a[6];const m=p,h=r?.id;let y;a[7]!==l||a[8]!==h?(y=sa(l,h),a[7]=l,a[8]=h,a[9]=y):y=a[9];const v=y;let x;a[10]!==m?.id||a[11]!==c||a[12]!==v?(x=v&&c?.id?{id:v.id,provider:v.provider,limits:v.limits,capabilities:v.capabilities,connectionId:c.id,fastId:m?.id}:null,a[10]=m?.id,a[11]=c,a[12]=v,a[13]=x):x=a[13];const _=x;let f;return a[14]!==_||a[15]!==o?(f=[_,o],a[14]=_,a[15]=o,a[16]=f):f=a[16],f},Fa={tiptapDoc:void 0,parentThread:null,finishReason:null};function en(t,e){switch(e.type){case"SET_TIPTAP_DOC":return{...t,tiptapDoc:e.payload};case"CLEAR_TIPTAP_DOC":return{...t,tiptapDoc:void 0};case"START_BRANCH":return{...t,parentThread:e.payload};case"CLEAR_BRANCH":return{...t,parentThread:null};case"SET_FINISH_REASON":return{...t,finishReason:e.payload};case"CLEAR_FINISH_REASON":return{...t,finishReason:null};case"RESET":return Fa;default:return t}}function tn(t,e){const a=[];for(const s of t)"text"in s&&s.text?a.push({type:"text",text:`[${e}]
20
- ${s.text}`}):"blob"in s&&s.blob&&s.mimeType&&a.push({type:"file",url:`data:${s.mimeType};base64,${s.blob}`,filename:String(s.uri),mediaType:String(s.mimeType)});return a}function an(t,e){const a=[];for(const s of t){if(s.role!=="user"||!s.content)continue;const r=Array.isArray(s.content)?s.content:[s.content];for(const o of r)switch(o.type){case"text":{const i=o.text?.trim();if(!i)continue;a.push({type:"text",text:`[${e}]
21
- ${i}`});break}case"image":case"audio":{if(!o.data||!o.mimeType)continue;a.push({type:"file",url:`data:${o.mimeType};base64,${o.data}`,mediaType:o.mimeType});break}case"resource":{const i=o.resource;if(!i||!i.mimeType)continue;i&&("text"in i&&i.text?a.push({type:"text",text:`[${e}]
22
- ${i.text}`}):"blob"in i&&i.blob&&i.mimeType&&a.push({type:"file",url:`data:${i.mimeType};base64,${i.blob}`,filename:String(i.uri),mediaType:String(i.mimeType)}));break}}}return a}function sn(t,e){const{mimeType:a,data:s}=t;if(a.startsWith("text/"))try{const r=atob(s);return[{type:"text",text:`${e}
23
- ${r}`}]}catch(r){console.error("Failed to decode text file:",r)}return[{type:"file",url:`data:${a};base64,${s}`,filename:e,mediaType:a}]}function rn(t){if(!t)return[];const e=[];let a="";const s=r=>{if(r){if(r.type==="text"&&"text"in r&&typeof r.text=="string")a+=r.text;else if(r.type==="mention"&&r.attrs){const o=r.attrs.char??"/",i=`${o}${r.attrs.name}`;if(a+=i,o==="@"){const n=r.attrs.metadata||[];e.push(...tn(n,i))}else{const n=r.attrs.metadata||r.attrs.prompts||[];e.push(...an(n,i))}}else if(r.type==="file"&&r.attrs){const o=r.attrs,i=`[file:://${encodeURIComponent(o.name)}]`;a+=i,e.push(...sn(o,i))}if("content"in r&&Array.isArray(r.content))for(const o of r.content)s(o)}};return s(t),a.trim()&&e.unshift({type:"text",text:a.trim()}),e}const Ua=N.createContext(null);function Pn(t){const e=D.c(68),{children:a}=t,{locator:s,org:r}=ve(),o=ko(),{data:i}=rs.useSession(),n=i?.user??null,[c,l]=N.useReducer(en,Fa),p=fs(),[m,h]=Se(`${s}:selected-virtual-mcp-id`,null),y=St(),[v,x]=Ko(s,y);let _;e[0]!==s?(_=We.chatSelectedMode(s),e[0]=s,e[1]=_):_=e[1];const[f,b]=Se(_,"code_execution"),u=o.messages,I=Io(m),A=Do();let w;e[2]!==m||e[3]!==p?(w=m?p.find(q=>q.id===m)??null:null,e[2]=m,e[3]=p,e[4]=w):w=e[4];const S=w;let j;e[5]!==r.id?(j=ms(r.id),e[5]=r.id,e[6]=j):j=e[6];const L=j.id;let Z;e[7]!==r.slug?(Z=Xo(r.slug),e[7]=r.slug,e[8]=Z):Z=e[8];const W=Z;let G;e[9]!==o?(G=async q=>{const{finishReason:xe,isAbort:Ue,isDisconnect:tt,isError:at,message:Wa,messages:Ja}=q;if(l({type:"SET_FINISH_REASON",payload:xe??null}),xe!=="stop"||Ue||tt||at)return;const{title:jt,thread_id:st,created_at:Pt}=Wa.metadata??{};!st||!jt||!Pt||(o.updateMessagesCache(st,Ja),o.updateThread(st,{title:jt,updatedAt:new Date(Pt).toISOString()}))},e[9]=o,e[10]=G):G=e[10];const K=G,re=on;let Y;e[11]!==u||e[12]!==K||e[13]!==A||e[14]!==o.activeThreadId||e[15]!==W?(Y={id:o.activeThreadId,messages:u,transport:W,onFinish:K,onToolCall:A,onError:re},e[11]=u,e[12]=K,e[13]=A,e[14]=o.activeThreadId,e[15]=W,e[16]=Y):Y=e[16];const M=_o(Y),ee=M.status==="submitted"||M.status==="streaming",oe=M.messages.length===0,$=o.createThread,V=o.switchThread,ye=o.hideThread;let Re;e[17]===Symbol.for("react.memo_cache_sentinel")?(Re=q=>l({type:"SET_TIPTAP_DOC",payload:q}),e[17]=Re):Re=e[17];const Va=Re;let je;e[18]===Symbol.for("react.memo_cache_sentinel")?(je=()=>l({type:"CLEAR_TIPTAP_DOC"}),e[18]=je):je=e[18];const qa=je;let Pe;e[19]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>l({type:"RESET"}),e[19]=Pe):Pe=e[19];const Rt=Pe;let Oe;e[20]!==h?(Oe=q=>{h(q)},e[20]=h,e[21]=Oe):Oe=e[21];const Ye=Oe;let ke;e[22]!==x?(ke=q=>{x({id:q.id,connectionId:q.connectionId})},e[22]=x,e[23]=ke):ke=e[23];const Qe=ke;let De;e[24]!==M||e[25]!==I||e[26]!==L||e[27]!==f||e[28]!==v||e[29]!==S?.id||e[30]!==o.activeThreadId||e[31]!==n?.image||e[32]!==n?.name?(De=async q=>{if(!v){gt.error("No model configured");return}const xe=rn(q);if(xe.length===0)return;Rt();const Ue={tiptapDoc:q,created_at:new Date().toISOString(),thread_id:o.activeThreadId,agent:{id:S?.id??L,mode:f},user:{avatar:n?.image??void 0,name:n?.name??"you"}},tt={...Ue,system:I,model:{id:v.id,connectionId:v.connectionId,provider:v.provider??void 0,limits:v.limits??void 0,capabilities:{vision:v.capabilities?.includes("vision")??void 0,text:v.capabilities?.includes("text")??void 0,tools:v.capabilities?.includes("tools")??void 0},fastId:v.fastId}},at={id:crypto.randomUUID(),role:"user",parts:xe,metadata:Ue};await M.sendMessage(at,{metadata:tt})},e[24]=M,e[25]=I,e[26]=L,e[27]=f,e[28]=v,e[29]=S?.id,e[30]=o.activeThreadId,e[31]=n?.image,e[32]=n?.name,e[33]=De):De=e[33];const Xe=De;let $e;e[34]!==M?($e=()=>M.stop(),e[34]=M,e[35]=$e):$e=e[35];const Ke=$e;let Le;e[36]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>l({type:"CLEAR_FINISH_REASON"}),e[36]=Le):Le=e[36];const Ha=Le;let Ze;e[37]!==M.clearError||e[38]!==M.error||e[39]!==M.messages||e[40]!==M.setMessages||e[41]!==M.status||e[42]!==c.finishReason||e[43]!==c.tiptapDoc||e[44]!==$||e[45]!==ye||e[46]!==oe||e[47]!==ee||e[48]!==y||e[49]!==f||e[50]!==v||e[51]!==S||e[52]!==Xe||e[53]!==b||e[54]!==Qe||e[55]!==Ye||e[56]!==Ke||e[57]!==V||e[58]!==o.activeThreadId||e[59]!==o.fetchNextPage||e[60]!==o.hasNextPage||e[61]!==o.isFetchingNextPage||e[62]!==o.threads||e[63]!==p?(Ze={tiptapDoc:c.tiptapDoc,setTiptapDoc:Va,clearTiptapDoc:qa,resetInteraction:Rt,activeThreadId:o.activeThreadId,threads:o.threads,createThread:$,switchToThread:V,hideThread:ye,hasNextPage:o.hasNextPage,isFetchingNextPage:o.isFetchingNextPage,fetchNextPage:o.fetchNextPage,virtualMcps:p,selectedVirtualMcp:S,setVirtualMcpId:Ye,modelsConnections:y,selectedModel:v,setSelectedModel:Qe,selectedMode:f,setSelectedMode:b,messages:M.messages,chatStatus:M.status,isStreaming:ee,isChatEmpty:oe,sendMessage:Xe,stopStreaming:Ke,setMessages:M.setMessages,chatError:M.error,clearChatError:M.clearError,finishReason:c.finishReason,clearFinishReason:Ha},e[37]=M.clearError,e[38]=M.error,e[39]=M.messages,e[40]=M.setMessages,e[41]=M.status,e[42]=c.finishReason,e[43]=c.tiptapDoc,e[44]=$,e[45]=ye,e[46]=oe,e[47]=ee,e[48]=y,e[49]=f,e[50]=v,e[51]=S,e[52]=Xe,e[53]=b,e[54]=Qe,e[55]=Ye,e[56]=Ke,e[57]=V,e[58]=o.activeThreadId,e[59]=o.fetchNextPage,e[60]=o.hasNextPage,e[61]=o.isFetchingNextPage,e[62]=o.threads,e[63]=p,e[64]=Ze):Ze=e[64];const et=Ze;let Fe;return e[65]!==a||e[66]!==et?(Fe=d.jsx(Ua.Provider,{value:et,children:a}),e[65]=a,e[66]=et,e[67]=Fe):Fe=e[67],Fe}function on(t){console.error("[chat] Error",t)}function On(){const t=N.useContext(Ua);if(!t)throw new Error("useChat must be used within a ChatProvider");return t}function nn(t){return(t.costs?.input??0)+(t.costs?.output??0)>0}function ln(t,e){const a=e.costs?.input??0,s=e.costs?.output??0,r=(t?.costs?.input??0)+(t?.costs?.output??0);return!t||r===0||a+s<r?e:t}var Ge="Collapsible",[cn,kn]=ls(Ge),[un,Ct]=cn(Ge),za=N.forwardRef((t,e)=>{const{__scopeCollapsible:a,open:s,defaultOpen:r,disabled:o,onOpenChange:i,...n}=t,[c,l]=os({prop:s,defaultProp:r??!1,onChange:i,caller:Ge});return d.jsx(un,{scope:a,disabled:o,contentId:ns(),open:c,onOpenToggle:N.useCallback(()=>l(p=>!p),[l]),children:d.jsx(vt.div,{"data-state":Mt(c),"data-disabled":o?"":void 0,...n,ref:e})})});za.displayName=Ge;var Ba="CollapsibleTrigger",Nt=N.forwardRef((t,e)=>{const{__scopeCollapsible:a,...s}=t,r=Ct(Ba,a);return d.jsx(vt.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":Mt(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...s,ref:e,onClick:is(t.onClick,r.onOpenToggle)})});Nt.displayName=Ba;var Tt="CollapsibleContent",At=N.forwardRef((t,e)=>{const{forceMount:a,...s}=t,r=Ct(Tt,t.__scopeCollapsible);return d.jsx(cs,{present:a||r.open,children:({present:o})=>d.jsx(dn,{...s,ref:e,present:o})})});At.displayName=Tt;var dn=N.forwardRef((t,e)=>{const{__scopeCollapsible:a,present:s,children:r,...o}=t,i=Ct(Tt,a),[n,c]=N.useState(s),l=N.useRef(null),p=us(e,l),m=N.useRef(0),h=m.current,y=N.useRef(0),v=y.current,x=i.open||n,_=N.useRef(x),f=N.useRef(void 0);return N.useEffect(()=>{const b=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(b)},[]),ds(()=>{const b=l.current;if(b){f.current=f.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const u=b.getBoundingClientRect();m.current=u.height,y.current=u.width,_.current||(b.style.transitionDuration=f.current.transitionDuration,b.style.animationName=f.current.animationName),c(s)}},[i.open,s]),d.jsx(vt.div,{"data-state":Mt(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...o,ref:p,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...t.style},children:x&&r})});function Mt(t){return t?"open":"closed"}var pn=za,Dn=Nt,$n=At;function Ln(t){const e=D.c(4);let a;e[0]!==t?({...a}=t,e[0]=t,e[1]=a):a=e[1];let s;return e[2]!==a?(s=d.jsx(pn,{"data-slot":"collapsible",...a}),e[2]=a,e[3]=s):s=e[3],s}function Zn(t){const e=D.c(4);let a;e[0]!==t?({...a}=t,e[0]=t,e[1]=a):a=e[1];let s;return e[2]!==a?(s=d.jsx(Nt,{"data-slot":"collapsible-trigger",...a}),e[2]=a,e[3]=s):s=e[3],s}function Fn(t){const e=D.c(4);let a;e[0]!==t?({...a}=t,e[0]=t,e[1]=a):a=e[1];let s;return e[2]!==a?(s=d.jsx(At,{"data-slot":"collapsible-content",...a}),e[2]=a,e[3]=s):s=e[3],s}function Un(){const t=D.c(4);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=We.decoChatOpen(),t[0]=e):e=t[0];const[a,s]=Se(e,mn);let r;return t[1]!==a||t[2]!==s?(r=[a,s],t[1]=a,t[2]=s,t[3]=r):r=t[3],r}function mn(t){return!!(t??!0)}export{Ln as C,jn as M,pn as R,z as S,Dn as T,Os as a,Un as b,Zn as c,la as d,$n as e,kn as f,Fn as g,Pn as h,Ps as i,Rn as m,da as t,On as u};
@@ -1 +0,0 @@
1
- import{I as u}from"./infiniteQueryObserver-cPntdNLH.js";import{a0 as i}from"./index-D-FZcOMC.js";function t(e,r){return i(e,u,r)}export{t as u};
@@ -1 +0,0 @@
1
- import{a0 as u,a3 as s}from"./index-D-FZcOMC.js";function o(e,r){return u(e,s,r)}export{o as u};
@@ -1 +0,0 @@
1
- import{a7 as a,a8 as t}from"./index-D-FZcOMC.js";function e(...r){return a(t(r))}export{e as c};