@decocms/mesh 2.1.0 → 2.1.2

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 (110) hide show
  1. package/dist/client/assets/{AlertCircle-CnILn3jx.js → AlertCircle-DiqlNboz.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-B6wScdzP.js → ArrowLeft-C4VtVMs2.js} +1 -1
  3. package/dist/client/assets/{ChevronDown-DTD8t00o.js → ChevronDown-CcUg3X_Y.js} +1 -1
  4. package/dist/client/assets/{ChevronRight-1OHI0CBI.js → ChevronRight-DoX6pxYj.js} +1 -1
  5. package/dist/client/assets/{Copy01-Uwb56ntU.js → Copy01-BJql3T8w.js} +1 -1
  6. package/dist/client/assets/{DotsHorizontal-B5ryaglt.js → DotsHorizontal-wWvFFsxa.js} +1 -1
  7. package/dist/client/assets/{DotsVertical-B-5TnXsG.js → DotsVertical-C_psDJy3.js} +1 -1
  8. package/dist/client/assets/{File06-DExBhm42.js → File06-CfmzgkCD.js} +1 -1
  9. package/dist/client/assets/{FilterLines-aAu13BQ5.js → FilterLines-MNaVyood.js} +1 -1
  10. package/dist/client/assets/{FlipBackward-DWy5EIwt.js → FlipBackward-qa1GrgeQ.js} +1 -1
  11. package/dist/client/assets/{GitBranch01-Dq29bc0o.js → GitBranch01-Cy-aTD__.js} +1 -1
  12. package/dist/client/assets/{Grid01-Bdi_lD58.js → Grid01-400pwqps.js} +1 -1
  13. package/dist/client/assets/{Inbox01-DMQr1yW_.js → Inbox01-DQ40if0u.js} +1 -1
  14. package/dist/client/assets/{InfoCircle-BTGq_g6o.js → InfoCircle-DbgHopMm.js} +1 -1
  15. package/dist/client/assets/{Key01-BM7IeiIC.js → Key01-CXPRpQE9.js} +1 -1
  16. package/dist/client/assets/{LinkExternal01-BbRknnAT.js → LinkExternal01-BJZvPGF2.js} +1 -1
  17. package/dist/client/assets/{Loading01-BhwGtEie.js → Loading01-DSWhKp36.js} +1 -1
  18. package/dist/client/assets/{Lock01-BjwJTO1K.js → Lock01-Cw5Gl3NV.js} +1 -1
  19. package/dist/client/assets/{Play-B_M1eygK.js → Play-18tBEZWZ.js} +1 -1
  20. package/dist/client/assets/{Plus-CUt-llJ2.js → Plus-SMn8MQ-H.js} +1 -1
  21. package/dist/client/assets/{Terminal-OwfTXSIc.js → Terminal-yR92omIF.js} +1 -1
  22. package/dist/client/assets/{Trash01-DvwxBHIe.js → Trash01-DaFJSHZu.js} +1 -1
  23. package/dist/client/assets/{X-DmB-XP-B.js → X-q_t7ZUi-.js} +1 -1
  24. package/dist/client/assets/{XClose-BfRKR4QX.js → XClose-2lFeEEkz.js} +1 -1
  25. package/dist/client/assets/{alert-dialog-CPgX_DbI.js → alert-dialog-BOjS3GrS.js} +1 -1
  26. package/dist/client/assets/{auth-C_7jwlCE.js → auth-BvEfLR40.js} +1 -1
  27. package/dist/client/assets/{auth-catchall-BsWBBbjQ.js → auth-catchall-qnrnPCT6.js} +1 -1
  28. package/dist/client/assets/{avatar-BfkYZ3Uk.js → avatar-D8KYLrun.js} +1 -1
  29. package/dist/client/assets/{badge-pmm0Bb0n.js → badge-DHFuTJNA.js} +1 -1
  30. package/dist/client/assets/{card-DX0N7QQe.js → card-CSWNwOPv.js} +1 -1
  31. package/dist/client/assets/{checkbox-CT0tct0O.js → checkbox-D6eJScSi.js} +1 -1
  32. package/dist/client/assets/{collection-detail-BB6Q1vQA.js → collection-detail-cLR1iiCF.js} +1 -1
  33. package/dist/client/assets/{collection-display-button-C6mkNMSZ.js → collection-display-button-DWBgVnY5.js} +1 -1
  34. package/dist/client/assets/{collection-header-B-OH92G_.js → collection-header-BYkZ9Trb.js} +1 -1
  35. package/dist/client/assets/{collection-page-BMM6TZo-.js → collection-page-BjyL0NfT.js} +1 -1
  36. package/dist/client/assets/{collection-search-Dspxl3Yz.js → collection-search-BhTsTIQF.js} +1 -1
  37. package/dist/client/assets/{collection-tab-CZVDVMRh.js → collection-tab-ByD_c7B5.js} +1 -1
  38. package/dist/client/assets/{collection-table-wrapper-QnkBhjXh.js → collection-table-wrapper-G4nlfvjF.js} +1 -1
  39. package/dist/client/assets/{connection-card-D80SBKTI.js → connection-card-BRub-GLZ.js} +1 -1
  40. package/dist/client/assets/{connection-detail-CQgpZSSc.js → connection-detail-DgCsw2FN.js} +1 -1
  41. package/dist/client/assets/{connections-D1odZRUO.js → connections-BEv7u43V.js} +1 -1
  42. package/dist/client/assets/constants-CxNag89_.js +1 -0
  43. package/dist/client/assets/{create-organization-dialog-Cz1rNGDv.js → create-organization-dialog-CahJq4TL.js} +1 -1
  44. package/dist/client/assets/{dialog-CC31EL0X.js → dialog-Ay6PD9W0.js} +1 -1
  45. package/dist/client/assets/{dropdown-menu-zbRnijT0.js → dropdown-menu-CX0_ej-t.js} +1 -1
  46. package/dist/client/assets/{empty-state-B5WHq2Wp.js → empty-state-DOXYCllo.js} +1 -1
  47. package/dist/client/assets/{env-vars-editor-BZ0EKsNv.js → env-vars-editor-DB_yBian.js} +1 -1
  48. package/dist/client/assets/{error-boundary-iei4NFmK.js → error-boundary-BITgBYMF.js} +1 -1
  49. package/dist/client/assets/extract-connection-data-CaZ0wil0.js +1 -0
  50. package/dist/client/assets/{form-B4rbGxTC.js → form-CTm5F5lc.js} +1 -1
  51. package/dist/client/assets/{formatDistanceToNow-B3eT5t4e.js → formatDistanceToNow-Da1WFNC1.js} +1 -1
  52. package/dist/client/assets/{gateway-detail-Cel29Jq6.js → gateway-detail-ZvOmrysO.js} +1 -1
  53. package/dist/client/assets/{gateway-selector-DrcyKhYX.js → gateway-selector-zAzGBjF_.js} +1 -1
  54. package/dist/client/assets/{gateways-BCUxb6V6.js → gateways-JihiLKrE.js} +1 -1
  55. package/dist/client/assets/{home-DjjIziN3.js → home-BCE1FamF.js} +1 -1
  56. package/dist/client/assets/{index-CJUkmkVw.js → index-DOV_cVSz.js} +5 -5
  57. package/dist/client/assets/{index-DhProoia.js → index-DskbBe5h.js} +1 -1
  58. package/dist/client/assets/{index-Be5s3BTd.js → index-Tg8Sdg8t.js} +21 -21
  59. package/dist/client/assets/{input-D5VmXtXA.js → input-DZxsngZP.js} +1 -1
  60. package/dist/client/assets/{layout-BtPLf8h9.js → layout-Brqmaefj.js} +1 -1
  61. package/dist/client/assets/{lazy-highlighter-CKguQGTj.js → lazy-highlighter-CiDPKksG.js} +1 -1
  62. package/dist/client/assets/{localstorage-keys-Cgns4y6c.js → localstorage-keys-Bmzia9Ql.js} +1 -1
  63. package/dist/client/assets/{login-BY9zzeLF.js → login-DTvg0d0e.js} +1 -1
  64. package/dist/client/assets/{mcp-oauth-JrBnP9ka.js → mcp-oauth-SMi_MNm0.js} +1 -1
  65. package/dist/client/assets/mcp-server-detail-Dp4c82jn.js +1 -0
  66. package/dist/client/assets/{members-BLsbQRx4.js → members-Antj9sp8.js} +1 -1
  67. package/dist/client/assets/{monaco-editor-BbkOCnUd.js → monaco-editor-DzF_l7qF.js} +1 -1
  68. package/dist/client/assets/{monitoring-DQGgnd4W.js → monitoring-CFWL1rLz.js} +1 -1
  69. package/dist/client/assets/{oauth-callback-CEdwKynD.js → oauth-callback-CG8hLD-b.js} +1 -1
  70. package/dist/client/assets/page-BvT1wvbD.js +1 -0
  71. package/dist/client/assets/{page-BXDOiUca.js → page-CBEZJuHw.js} +1 -1
  72. package/dist/client/assets/{pin-to-sidebar-button-Dw4GdfbU.js → pin-to-sidebar-button-fGogNndB.js} +1 -1
  73. package/dist/client/assets/{popover-t9-OkADH.js → popover-D8pPVQL_.js} +1 -1
  74. package/dist/client/assets/{project-context-provider-BS8o541A.js → project-context-provider-DzGl09z5.js} +1 -1
  75. package/dist/client/assets/{resizable-QJ-R9KRQ.js → resizable-RYzDqksM.js} +1 -1
  76. package/dist/client/assets/{resource-tabs-B-4VA98W.js → resource-tabs-Dx00akPb.js} +1 -1
  77. package/dist/client/assets/{select-e4C4SmKq.js → select-DXarH3zI.js} +1 -1
  78. package/dist/client/assets/server-name-C3ttWdyD.js +1 -0
  79. package/dist/client/assets/{settings-Dnv8fDox.js → settings-CppuOJKP.js} +1 -1
  80. package/dist/client/assets/{shell-layout-BlrxsMrN.js → shell-layout-9hZXlinq.js} +1 -1
  81. package/dist/client/assets/{spinner-BFS4gVsU.js → spinner-BlgPNYJ_.js} +1 -1
  82. package/dist/client/assets/{switch-CLvPCUaJ.js → switch-D8JX4qkY.js} +1 -1
  83. package/dist/client/assets/{textarea-4b5OG-tc.js → textarea-B4gwvsMJ.js} +1 -1
  84. package/dist/client/assets/{thread-history-popover-CdgY8TVV.js → thread-history-popover-BGdJj9Uf.js} +5 -5
  85. package/dist/client/assets/{tools-list-DYFK0YJ7.js → tools-list-PNSOJy0p.js} +1 -1
  86. package/dist/client/assets/{use-binding-4jFDqim2.js → use-binding-BrFwEM85.js} +1 -1
  87. package/dist/client/assets/{use-connection-BV17GXlx.js → use-connection-C0rtvbAv.js} +1 -1
  88. package/dist/client/assets/{use-connection-resources-CaFhYy-Y.js → use-connection-resources-85AsmF-4.js} +1 -1
  89. package/dist/client/assets/{use-gateway-B7sk5BUf.js → use-gateway-XK2Ec2c7.js} +1 -1
  90. package/dist/client/assets/{use-list-state-ClKTIM8C.js → use-list-state-CaOiitHv.js} +1 -1
  91. package/dist/client/assets/{use-mcp-BnUTTtgf.js → use-mcp-DP2e7Pak.js} +1 -1
  92. package/dist/client/assets/{use-members-Duard-8M.js → use-members-BZIlp51_.js} +1 -1
  93. package/dist/client/assets/{use-mobile-D6agNekL.js → use-mobile-C9ZrGbF1.js} +1 -1
  94. package/dist/client/assets/{use-organization-settings-BBRsFqJO.js → use-organization-settings-CpuYghUf.js} +1 -1
  95. package/dist/client/assets/{use-tool-call-CM2oq0rB.js → use-tool-call-BLCuCQA5.js} +1 -1
  96. package/dist/client/assets/useQuery-CDC7rIFj.js +1 -0
  97. package/dist/client/assets/{value-8MKGBmon.js → value-C6pOmVvH.js} +1 -1
  98. package/dist/client/assets/{view-mode-toggle-BTD72CUu.js → view-mode-toggle-BegVAMeC.js} +1 -1
  99. package/dist/client/assets/{workflow-6yVvsMos.js → workflow-ChKb4zdL.js} +1 -1
  100. package/dist/client/index.html +1 -1
  101. package/dist/server/cli.js +167 -167
  102. package/dist/server/migrate.js +67 -67
  103. package/dist/server/server.js +164 -164
  104. package/package.json +1 -1
  105. package/dist/client/assets/app-name-gTETL9So.js +0 -1
  106. package/dist/client/assets/constants-BvQJIhjO.js +0 -1
  107. package/dist/client/assets/extract-connection-data-RbshSMFT.js +0 -1
  108. package/dist/client/assets/mcp-server-detail-D1UUYOFR.js +0 -1
  109. package/dist/client/assets/page-CjfeHs2p.js +0 -1
  110. package/dist/client/assets/useQuery-DdiguCvR.js +0 -1
@@ -1,15 +1,15 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lazy-highlighter-CKguQGTj.js","assets/index-Be5s3BTd.js","assets/index-DU53zBhA.css"])))=>i.map(i=>d[i]);
2
- import{r as V,c as W,j as m,B as Yi,p as qi,K as Me,d as Ac,t as Ei,E as kc,F as Cc,H as Ve,v as Y,_ as xr,I as Eu,J as Ic,L as Sc,M as Nc,Q as je,V as $n,W as Zn,s as Ee,X as G,Y as Ct,Z as wc,$ as ye,a0 as Rc,a1 as Vi,a2 as Oc,h as Lc}from"./index-Be5s3BTd.js";import{c as le,u as jt,B as We,I as Dc}from"./input-D5VmXtXA.js";import{u as Dt,c as dn,b as fn,T as hn,a as bu,i as sn}from"./project-context-provider-BS8o541A.js";import{E as vc,u as Pc}from"./use-binding-4jFDqim2.js";import{P as Tu,a as xu,b as _u}from"./popover-t9-OkADH.js";import{i as yu}from"./AlertCircle-CnILn3jx.js";import{i as Mc}from"./error-boundary-iei4NFmK.js";import{i as Bc}from"./X-DmB-XP-B.js";import{i as Fc,c as Uc}from"./Grid01-Bdi_lD58.js";import{i as Hc,R as jc,f as zc,g as $c,h as Yc}from"./gateway-selector-DrcyKhYX.js";import{T as qc}from"./textarea-4b5OG-tc.js";import{u as Vc,L as Wc}from"./localstorage-keys-Cgns4y6c.js";import{i as Au}from"./ChevronRight-1OHI0CBI.js";import{a as Wi}from"./Copy01-Uwb56ntU.js";import{i as Qc}from"./Terminal-OwfTXSIc.js";import{M as ku,s as Oa}from"./monaco-editor-BbkOCnUd.js";import{b as Gc,c as Xc,d as Zc,A as Kc,a as Jc,e as ed,g as td,f as nd}from"./alert-dialog-CPgX_DbI.js";import{i as rd}from"./File06-DExBhm42.js";import{i as id}from"./InfoCircle-BTGq_g6o.js";import{U as ad,a as sd,c as ud,u as od,i as Qi,b as ld,E as cd}from"./use-connection-BV17GXlx.js";import{O as dd,a as fd,g as hd}from"./well-known-mcp-D13f-8h2.js";import{g as pd}from"./generate-id-Dyweu44Y.js";import{s as md}from"./Trash01-DvwxBHIe.js";const Cu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));Cu.displayName="Coins01";const Iu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M9 14 4 9m0 0 5-5M4 9h6.4c3.36 0 5.04 0 6.324.654a6 6 0 0 1 2.622 2.622C20 13.56 20 15.24 20 18.6V20"}));Iu.displayName="CornerUpLeft";const Su=({size:t=24,color:e="currentColor",...n})=>V.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},V.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"}));Su.displayName="CurrencyDollar";const Nu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"m18 10-4-4M2.5 21.5l3.384-.376c.414-.046.62-.069.814-.131a2 2 0 0 0 .485-.234c.17-.111.317-.259.61-.553L21 7a2.828 2.828 0 1 0-4-4L3.794 16.206c-.294.294-.442.442-.553.611a2 2 0 0 0-.234.485c-.062.193-.085.4-.131.814L2.5 21.5Z"}));Nu.displayName="Edit02";const wu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M16.2 21H6.931c-.605 0-.908 0-1.049-.12a.5.5 0 0 1-.173-.42c.014-.183.228-.397.657-.826l8.503-8.503c.396-.396.594-.594.822-.668a1 1 0 0 1 .618 0c.228.074.426.272.822.668L21 15v1.2M16.2 21c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C21 18.72 21 17.88 21 16.2M16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4M10.5 8.5a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z"}));wu.displayName="Image01";const Ru=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));Ru.displayName="Lightbulb01";const Ou=({size:t=24,color:e="currentColor",...n})=>V.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},V.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"}));Ou.displayName="LogOut04";const Or=({size:t=24,color:e="currentColor",...n})=>V.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},V.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"}));Or.displayName="Stars01";const Lu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));Lu.displayName="Target04";function o_(){const t=W.c(7);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsxs("div",{className:"flex items-center gap-3",children:[e,m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),m.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:m.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,m.jsxs("div",{className:"flex items-end gap-2",children:[m.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),m.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:m.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[m.jsx(ur,{align:"right",width:"w-3/4"}),m.jsx(ur,{align:"left",width:"w-full",lines:3}),m.jsx(ur,{align:"right",width:"w-2/3"}),m.jsx(ur,{align:"left",width:"w-5/6",lines:2})]})}),t[3]=i):i=t[3];let a;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:m.jsx("div",{className:"relative flex-1",children:m.jsxs("div",{className:"space-y-2 p-2",children:[m.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),m.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),t[4]=a):a=t[4];let s;t[5]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("div",{className:"flex items-center gap-1",children:m.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),t[5]=s):s=t[5];let u;return t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsxs("div",{className:"flex h-full w-full flex-col bg-sidebar",children:[r,i,m.jsx("div",{className:"px-4 py-4",children:m.jsx("div",{className:"mx-auto w-full max-w-2xl",children:m.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl border border-border bg-background shadow-sm",children:[a,m.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[s,m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),m.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})})]}),t[6]=u):u=t[6],u}function ur(t){const e=W.c(22),{align:n,width:r,lines:i}=t,a=r===void 0?"w-full":r,s=i===void 0?1:i,u=n==="right"?"flex-row-reverse":"flex-row";let o;e[0]!==u?(o=le("flex w-full gap-4 px-4 py-2",u),e[0]=u,e[1]=o):o=e[1];const l=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let d;e[2]!==l?(d=le("flex min-w-0 flex-col gap-2",l),e[2]=l,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=f):f=e[4];const p=n==="right"?"bg-muted":"bg-transparent border border-border/40";let h;e[5]!==p||e[6]!==a?(h=le("min-w-0 rounded-2xl p-4",p,a),e[5]=p,e[6]=a,e[7]=h):h=e[7];let g;e[8]!==s?(g=Array.from({length:s}),e[8]=s,e[9]=g):g=e[9];let _;e[10]!==s||e[11]!==g?(_=m.jsx("div",{className:"space-y-2",children:g.map((E,R)=>m.jsx("div",{className:le("h-3 rounded bg-muted-foreground/20 animate-pulse",R===s-1?"w-3/4":"w-full"),style:{animationDelay:`${R*.1}s`}},R))}),e[10]=s,e[11]=g,e[12]=_):_=e[12];let y;e[13]!==_||e[14]!==h?(y=m.jsx("div",{className:h,children:_}),e[13]=_,e[14]=h,e[15]=y):y=e[15];let T;e[16]!==y||e[17]!==d?(T=m.jsxs("div",{className:d,children:[f,y]}),e[16]=y,e[17]=d,e[18]=T):T=e[18];let I;return e[19]!==T||e[20]!==o?(I=m.jsx("div",{className:o,children:T}),e[19]=T,e[20]=o,e[21]=I):I=e[21],I}var Yn;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),s={};for(const u of a)s[u]=i[u];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Yn||(Yn={}));var La;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(La||(La={}));Yn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Yn.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 _r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},r={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let u=r,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(u[l]=u[l]||{_errors:[]},u[l]._errors.push(n(s))):u[l]=u[l]||{_errors:[]},u=u[l],o++}}};return i(this),r}static assert(e){if(!(e instanceof _r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Yn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const a=i.path[0];n[a]=n[a]||[],n[a].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}_r.create=t=>new _r(t);var Da;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Da||(Da={}));var ee;(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"})(ee||(ee={}));function Yt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function gd(t,e){let n;const r=()=>{if(n)return n;const i=indexedDB.open(t);return i.onupgradeneeded=()=>i.result.createObjectStore(e),n=Yt(i),n.then(a=>{a.onclose=()=>n=void 0},()=>{}),n};return(i,a)=>r().then(s=>a(s.transaction(e,i).objectStore(e)))}let Qr;function Lr(){return Qr||(Qr=gd("keyval-store","keyval")),Qr}function Gi(t,e=Lr()){return e("readonly",n=>Yt(n.get(t)))}function Dn(t,e,n=Lr()){return n("readwrite",r=>(r.put(e,t),Yt(r.transaction)))}function Du(t,e=Lr()){return e("readwrite",n=>(n.delete(t),Yt(n.transaction)))}function Ed(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Yt(t.transaction)}function vu(t=Lr()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Yt(e.getAllKeys()),Yt(e.getAll())]).then(([r,i])=>r.map((a,s)=>[a,i[s]]));const n=[];return t("readonly",r=>Ed(r,i=>n.push([i.key,i.value])).then(()=>n))})}async function bd(t,e){const n=`${t}:threads:${e}`;return await Gi(n)??null}async function Td(t){const e=`${t}:threads:`;return(await vu()).filter(([i])=>typeof i=="string"&&i.startsWith(e)).map(([,i])=>i).filter(i=>!i.hidden).sort((i,a)=>String(a.updated_at).localeCompare(String(i.updated_at)))}function Pu(t,e){const n=`${t}:messages:`;return vu().then(r=>r.filter(([a])=>typeof a=="string"&&a.startsWith(n)).map(([,a])=>a).filter(a=>a.metadata?.thread_id===e||a.threadId===e).sort((a,s)=>{const u=a.metadata?.created_at||a.createdAt||"",o=s.metadata?.created_at||s.createdAt||"";return String(u).localeCompare(String(o))}))}function l_(t){const e=W.c(14),{locator:n}=Dt(),r=t?.gatewayId;let i;e[0]!==r||e[1]!==n?(i=Me.threads(n),e[0]=r,e[1]=n,e[2]=i):i=e[2];let a;e[3]!==r||e[4]!==n?(a=async()=>await Td(n),e[3]=r,e[4]=n,e[5]=a):a=e[5];let s;e[6]!==i||e[7]!==a?(s={queryKey:i,queryFn:a,staleTime:3e4},e[6]=i,e[7]=a,e[8]=s):s=e[8];const{data:u,refetch:o}=qi(s);let l;e[9]!==u?(l=u??[],e[9]=u,e[10]=l):l=e[10];let d;return e[11]!==o||e[12]!==l?(d={threads:l,refetch:o},e[11]=o,e[12]=l,e[13]=d):d=e[13],d}function xd(t){const e=W.c(11),{locator:n}=Dt();let r;e[0]!==n||e[1]!==t?(r=Me.threadMessages(n,t),e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;e[3]!==n||e[4]!==t?(i=()=>Pu(n,t),e[3]=n,e[4]=t,e[5]=i):i=e[5];let a;e[6]!==r||e[7]!==i?(a={queryKey:r,queryFn:i,staleTime:3e4},e[6]=r,e[7]=i,e[8]=a):a=e[8];const{data:s}=qi(a);let u;return e[9]!==s?(u=s??[],e[9]=s,e[10]=u):u=e[10],u}function Xi(){const t=W.c(28),{locator:e}=Dt(),n=Yi();let r;t[0]!==e?(r=async y=>{const T=`${e}:threads:${y.id}`;return await Dn(T,y),y},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=y=>{n.invalidateQueries({queryKey:Me.threads(e)}),y.gatewayId&&n.invalidateQueries({queryKey:Me.gatewayThreads(e,y.gatewayId)})},t[2]=e,t[3]=n,t[4]=i):i=t[4];let a;t[5]!==r||t[6]!==i?(a={mutationFn:r,onSuccess:i},t[5]=r,t[6]=i,t[7]=a):a=t[7];const s=jt(a);let u;t[8]!==e?(u=async y=>{const{id:T,updates:I}=y,E=`${e}:threads:${T}`,R=await Gi(E);if(!R)throw new Error(`Thread ${T} not found`);const O={...R,...I};return await Dn(E,O),O},t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=y=>{n.invalidateQueries({queryKey:Me.threads(e)}),n.invalidateQueries({queryKey:Me.thread(e,y.id)}),y.gatewayId&&n.invalidateQueries({queryKey:Me.gatewayThreads(e,y.gatewayId)})},t[10]=e,t[11]=n,t[12]=o):o=t[12];let l;t[13]!==u||t[14]!==o?(l={mutationFn:u,onSuccess:o},t[13]=u,t[14]=o,t[15]=l):l=t[15];const d=jt(l);let f;t[16]!==e?(f=async y=>{const T=`${e}:threads:${y}`;return await Du(T),y},t[16]=e,t[17]=f):f=t[17];let p;t[18]!==e||t[19]!==n?(p=()=>{n.invalidateQueries({queryKey:Me.threads(e)})},t[18]=e,t[19]=n,t[20]=p):p=t[20];let h;t[21]!==f||t[22]!==p?(h={mutationFn:f,onSuccess:p},t[21]=f,t[22]=p,t[23]=h):h=t[23];const g=jt(h);let _;return t[24]!==g||t[25]!==s||t[26]!==d?(_={insert:s,update:d,delete:g},t[24]=g,t[25]=s,t[26]=d,t[27]=_):_=t[27],_}function Mu(){const t=W.c(37),{locator:e}=Dt(),n=Yi();let r;t[0]!==e?(r=async R=>{const O=`${e}:messages:${R.id}`;return await Dn(O,R),R},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=R=>{const O=R.metadata?.thread_id||R.threadId;O&&n.invalidateQueries({queryKey:Me.threadMessages(e,O)}),n.invalidateQueries({queryKey:Me.messages(e)})},t[2]=e,t[3]=n,t[4]=i):i=t[4];let a;t[5]!==r||t[6]!==i?(a={mutationFn:r,onSuccess:i},t[5]=r,t[6]=i,t[7]=a):a=t[7];const s=jt(a);let u;t[8]!==e?(u=async R=>(await Promise.all(R.map(O=>{const S=`${e}:messages:${O.id}`;return Dn(S,O)})),R),t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=R=>{const O=new Set;for(const S of R){const v=S.metadata?.thread_id||S.threadId;v&&O.add(v)}for(const S of O)n.invalidateQueries({queryKey:Me.threadMessages(e,S)});n.invalidateQueries({queryKey:Me.messages(e)})},t[10]=e,t[11]=n,t[12]=o):o=t[12];let l;t[13]!==u||t[14]!==o?(l={mutationFn:u,onSuccess:o},t[13]=u,t[14]=o,t[15]=l):l=t[15];const d=jt(l);let f;t[16]!==e?(f=async R=>{const{id:O,updates:S}=R,v=`${e}:messages:${O}`,B=await Gi(v);if(!B)throw new Error(`Message ${O} not found`);const z={...B,...S};return await Dn(v,z),z},t[16]=e,t[17]=f):f=t[17];let p;t[18]!==e||t[19]!==n?(p=R=>{const O=R.metadata?.thread_id||R.threadId;O&&n.invalidateQueries({queryKey:Me.threadMessages(e,O)}),n.invalidateQueries({queryKey:Me.messages(e)})},t[18]=e,t[19]=n,t[20]=p):p=t[20];let h;t[21]!==f||t[22]!==p?(h={mutationFn:f,onSuccess:p},t[21]=f,t[22]=p,t[23]=h):h=t[23];const g=jt(h);let _;t[24]!==e?(_=async R=>{const O=`${e}:messages:${R}`;return await Du(O),R},t[24]=e,t[25]=_):_=t[25];let y;t[26]!==e||t[27]!==n?(y=()=>{n.invalidateQueries({queryKey:Me.messages(e)})},t[26]=e,t[27]=n,t[28]=y):y=t[28];let T;t[29]!==y||t[30]!==_?(T={mutationFn:_,onSuccess:y},t[29]=y,t[30]=_,t[31]=T):T=t[31];const I=jt(T);let E;return t[32]!==I||t[33]!==s||t[34]!==d||t[35]!==g?(E={insert:s,insertMany:d,update:g,delete:I},t[32]=I,t[33]=s,t[34]=d,t[35]=g,t[36]=E):E=t[36],E}function c_(){const t=W.c(5),e=Yi(),{org:n}=Dt();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const i=Ac(r);let a;return t[1]!==n||t[2]!==i||t[3]!==e?(a=s=>{const o=s.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!o||!o[1])return;const l=o[1],d=i.connectionId;if(!d)return;e.invalidateQueries({queryKey:Me.collection(n.slug,d,l)});const f=l.toLowerCase().replace(/_/g," ");Ei.success(`${f} updated`)},t[1]=n,t[2]=i,t[3]=e,t[4]=a):a=t[4],a}var Bu="vercel.ai.error",_d=Symbol.for(Bu),va,Pa,Lt=class Fu extends(Pa=Error,va=_d,Pa){constructor({name:e,message:n,cause:r}){super(n),this[va]=!0,this.name=e,this.cause=r}static isInstance(e){return Fu.hasMarker(e,Bu)}static hasMarker(e,n){const r=Symbol.for(n);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Uu(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Hu="AI_InvalidArgumentError",ju=`vercel.ai.error.${Hu}`,yd=Symbol.for(ju),Ma,Ba,Ad=class extends(Ba=Lt,Ma=yd,Ba){constructor({message:t,cause:e,argument:n}){super({name:Hu,message:t,cause:e}),this[Ma]=!0,this.argument=n}static isInstance(t){return Lt.hasMarker(t,ju)}},zu="AI_JSONParseError",$u=`vercel.ai.error.${zu}`,kd=Symbol.for($u),Fa,Ua,Ha=class extends(Ua=Lt,Fa=kd,Ua){constructor({text:t,cause:e}){super({name:zu,message:`JSON parsing failed: Text: ${t}.
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lazy-highlighter-CiDPKksG.js","assets/index-Tg8Sdg8t.js","assets/index-DU53zBhA.css"])))=>i.map(i=>d[i]);
2
+ import{r as V,c as W,j as m,B as Yi,p as qi,K as Me,d as Ac,t as Ei,E as kc,F as Cc,H as Ve,v as Y,_ as xr,I as Eu,J as Ic,L as Sc,M as Nc,Q as je,V as $n,W as Zn,s as Ee,X as G,Y as Ct,Z as wc,$ as ye,a0 as Rc,a1 as Vi,a2 as Oc,h as Lc}from"./index-Tg8Sdg8t.js";import{c as le,u as jt,B as We,I as Dc}from"./input-DZxsngZP.js";import{u as Dt,c as dn,b as fn,T as hn,a as bu,i as sn}from"./project-context-provider-DzGl09z5.js";import{E as vc,u as Pc}from"./use-binding-BrFwEM85.js";import{P as Tu,a as xu,b as _u}from"./popover-D8pPVQL_.js";import{i as yu}from"./AlertCircle-DiqlNboz.js";import{i as Mc}from"./error-boundary-BITgBYMF.js";import{i as Bc}from"./X-q_t7ZUi-.js";import{i as Fc,c as Uc}from"./Grid01-400pwqps.js";import{i as Hc,R as jc,f as zc,g as $c,h as Yc}from"./gateway-selector-zAzGBjF_.js";import{T as qc}from"./textarea-B4gwvsMJ.js";import{u as Vc,L as Wc}from"./localstorage-keys-Bmzia9Ql.js";import{i as Au}from"./ChevronRight-DoX6pxYj.js";import{a as Wi}from"./Copy01-BJql3T8w.js";import{i as Qc}from"./Terminal-yR92omIF.js";import{M as ku,s as Oa}from"./monaco-editor-DzF_l7qF.js";import{b as Gc,c as Xc,d as Zc,A as Kc,a as Jc,e as ed,g as td,f as nd}from"./alert-dialog-BOjS3GrS.js";import{i as rd}from"./File06-CfmzgkCD.js";import{i as id}from"./InfoCircle-DbgHopMm.js";import{U as ad,a as sd,c as ud,u as od,i as Qi,b as ld,E as cd}from"./use-connection-C0rtvbAv.js";import{O as dd,a as fd,g as hd}from"./well-known-mcp-D13f-8h2.js";import{g as pd}from"./generate-id-Dyweu44Y.js";import{s as md}from"./Trash01-DaFJSHZu.js";const Cu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));Cu.displayName="Coins01";const Iu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M9 14 4 9m0 0 5-5M4 9h6.4c3.36 0 5.04 0 6.324.654a6 6 0 0 1 2.622 2.622C20 13.56 20 15.24 20 18.6V20"}));Iu.displayName="CornerUpLeft";const Su=({size:t=24,color:e="currentColor",...n})=>V.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},V.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"}));Su.displayName="CurrencyDollar";const Nu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"m18 10-4-4M2.5 21.5l3.384-.376c.414-.046.62-.069.814-.131a2 2 0 0 0 .485-.234c.17-.111.317-.259.61-.553L21 7a2.828 2.828 0 1 0-4-4L3.794 16.206c-.294.294-.442.442-.553.611a2 2 0 0 0-.234.485c-.062.193-.085.4-.131.814L2.5 21.5Z"}));Nu.displayName="Edit02";const wu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M16.2 21H6.931c-.605 0-.908 0-1.049-.12a.5.5 0 0 1-.173-.42c.014-.183.228-.397.657-.826l8.503-8.503c.396-.396.594-.594.822-.668a1 1 0 0 1 .618 0c.228.074.426.272.822.668L21 15v1.2M16.2 21c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C21 18.72 21 17.88 21 16.2M16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4M10.5 8.5a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z"}));wu.displayName="Image01";const Ru=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));Ru.displayName="Lightbulb01";const Ou=({size:t=24,color:e="currentColor",...n})=>V.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},V.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"}));Ou.displayName="LogOut04";const Or=({size:t=24,color:e="currentColor",...n})=>V.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},V.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"}));Or.displayName="Stars01";const Lu=({size:t=24,color:e="currentColor",...n})=>V.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},V.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));Lu.displayName="Target04";function o_(){const t=W.c(7);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsxs("div",{className:"flex items-center gap-3",children:[e,m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),m.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),t[1]=n):n=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:m.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,m.jsxs("div",{className:"flex items-end gap-2",children:[m.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),m.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),t[2]=r):r=t[2];let i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:m.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[m.jsx(ur,{align:"right",width:"w-3/4"}),m.jsx(ur,{align:"left",width:"w-full",lines:3}),m.jsx(ur,{align:"right",width:"w-2/3"}),m.jsx(ur,{align:"left",width:"w-5/6",lines:2})]})}),t[3]=i):i=t[3];let a;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:m.jsx("div",{className:"relative flex-1",children:m.jsxs("div",{className:"space-y-2 p-2",children:[m.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),m.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),t[4]=a):a=t[4];let s;t[5]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("div",{className:"flex items-center gap-1",children:m.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),t[5]=s):s=t[5];let u;return t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsxs("div",{className:"flex h-full w-full flex-col bg-sidebar",children:[r,i,m.jsx("div",{className:"px-4 py-4",children:m.jsx("div",{className:"mx-auto w-full max-w-2xl",children:m.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl border border-border bg-background shadow-sm",children:[a,m.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[s,m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),m.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})})]}),t[6]=u):u=t[6],u}function ur(t){const e=W.c(22),{align:n,width:r,lines:i}=t,a=r===void 0?"w-full":r,s=i===void 0?1:i,u=n==="right"?"flex-row-reverse":"flex-row";let o;e[0]!==u?(o=le("flex w-full gap-4 px-4 py-2",u),e[0]=u,e[1]=o):o=e[1];const l=n==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let d;e[2]!==l?(d=le("flex min-w-0 flex-col gap-2",l),e[2]=l,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=m.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=f):f=e[4];const p=n==="right"?"bg-muted":"bg-transparent border border-border/40";let h;e[5]!==p||e[6]!==a?(h=le("min-w-0 rounded-2xl p-4",p,a),e[5]=p,e[6]=a,e[7]=h):h=e[7];let g;e[8]!==s?(g=Array.from({length:s}),e[8]=s,e[9]=g):g=e[9];let _;e[10]!==s||e[11]!==g?(_=m.jsx("div",{className:"space-y-2",children:g.map((E,R)=>m.jsx("div",{className:le("h-3 rounded bg-muted-foreground/20 animate-pulse",R===s-1?"w-3/4":"w-full"),style:{animationDelay:`${R*.1}s`}},R))}),e[10]=s,e[11]=g,e[12]=_):_=e[12];let y;e[13]!==_||e[14]!==h?(y=m.jsx("div",{className:h,children:_}),e[13]=_,e[14]=h,e[15]=y):y=e[15];let T;e[16]!==y||e[17]!==d?(T=m.jsxs("div",{className:d,children:[f,y]}),e[16]=y,e[17]=d,e[18]=T):T=e[18];let I;return e[19]!==T||e[20]!==o?(I=m.jsx("div",{className:o,children:T}),e[19]=T,e[20]=o,e[21]=I):I=e[21],I}var Yn;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),s={};for(const u of a)s[u]=i[u];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Yn||(Yn={}));var La;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(La||(La={}));Yn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Yn.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 _r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},r={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let u=r,o=0;for(;o<s.path.length;){const l=s.path[o];o===s.path.length-1?(u[l]=u[l]||{_errors:[]},u[l]._errors.push(n(s))):u[l]=u[l]||{_errors:[]},u=u[l],o++}}};return i(this),r}static assert(e){if(!(e instanceof _r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Yn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n=Object.create(null),r=[];for(const i of this.issues)if(i.path.length>0){const a=i.path[0];n[a]=n[a]||[],n[a].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}_r.create=t=>new _r(t);var Da;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Da||(Da={}));var ee;(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"})(ee||(ee={}));function Yt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function gd(t,e){let n;const r=()=>{if(n)return n;const i=indexedDB.open(t);return i.onupgradeneeded=()=>i.result.createObjectStore(e),n=Yt(i),n.then(a=>{a.onclose=()=>n=void 0},()=>{}),n};return(i,a)=>r().then(s=>a(s.transaction(e,i).objectStore(e)))}let Qr;function Lr(){return Qr||(Qr=gd("keyval-store","keyval")),Qr}function Gi(t,e=Lr()){return e("readonly",n=>Yt(n.get(t)))}function Dn(t,e,n=Lr()){return n("readwrite",r=>(r.put(e,t),Yt(r.transaction)))}function Du(t,e=Lr()){return e("readwrite",n=>(n.delete(t),Yt(n.transaction)))}function Ed(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Yt(t.transaction)}function vu(t=Lr()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Yt(e.getAllKeys()),Yt(e.getAll())]).then(([r,i])=>r.map((a,s)=>[a,i[s]]));const n=[];return t("readonly",r=>Ed(r,i=>n.push([i.key,i.value])).then(()=>n))})}async function bd(t,e){const n=`${t}:threads:${e}`;return await Gi(n)??null}async function Td(t){const e=`${t}:threads:`;return(await vu()).filter(([i])=>typeof i=="string"&&i.startsWith(e)).map(([,i])=>i).filter(i=>!i.hidden).sort((i,a)=>String(a.updated_at).localeCompare(String(i.updated_at)))}function Pu(t,e){const n=`${t}:messages:`;return vu().then(r=>r.filter(([a])=>typeof a=="string"&&a.startsWith(n)).map(([,a])=>a).filter(a=>a.metadata?.thread_id===e||a.threadId===e).sort((a,s)=>{const u=a.metadata?.created_at||a.createdAt||"",o=s.metadata?.created_at||s.createdAt||"";return String(u).localeCompare(String(o))}))}function l_(t){const e=W.c(14),{locator:n}=Dt(),r=t?.gatewayId;let i;e[0]!==r||e[1]!==n?(i=Me.threads(n),e[0]=r,e[1]=n,e[2]=i):i=e[2];let a;e[3]!==r||e[4]!==n?(a=async()=>await Td(n),e[3]=r,e[4]=n,e[5]=a):a=e[5];let s;e[6]!==i||e[7]!==a?(s={queryKey:i,queryFn:a,staleTime:3e4},e[6]=i,e[7]=a,e[8]=s):s=e[8];const{data:u,refetch:o}=qi(s);let l;e[9]!==u?(l=u??[],e[9]=u,e[10]=l):l=e[10];let d;return e[11]!==o||e[12]!==l?(d={threads:l,refetch:o},e[11]=o,e[12]=l,e[13]=d):d=e[13],d}function xd(t){const e=W.c(11),{locator:n}=Dt();let r;e[0]!==n||e[1]!==t?(r=Me.threadMessages(n,t),e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;e[3]!==n||e[4]!==t?(i=()=>Pu(n,t),e[3]=n,e[4]=t,e[5]=i):i=e[5];let a;e[6]!==r||e[7]!==i?(a={queryKey:r,queryFn:i,staleTime:3e4},e[6]=r,e[7]=i,e[8]=a):a=e[8];const{data:s}=qi(a);let u;return e[9]!==s?(u=s??[],e[9]=s,e[10]=u):u=e[10],u}function Xi(){const t=W.c(28),{locator:e}=Dt(),n=Yi();let r;t[0]!==e?(r=async y=>{const T=`${e}:threads:${y.id}`;return await Dn(T,y),y},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=y=>{n.invalidateQueries({queryKey:Me.threads(e)}),y.gatewayId&&n.invalidateQueries({queryKey:Me.gatewayThreads(e,y.gatewayId)})},t[2]=e,t[3]=n,t[4]=i):i=t[4];let a;t[5]!==r||t[6]!==i?(a={mutationFn:r,onSuccess:i},t[5]=r,t[6]=i,t[7]=a):a=t[7];const s=jt(a);let u;t[8]!==e?(u=async y=>{const{id:T,updates:I}=y,E=`${e}:threads:${T}`,R=await Gi(E);if(!R)throw new Error(`Thread ${T} not found`);const O={...R,...I};return await Dn(E,O),O},t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=y=>{n.invalidateQueries({queryKey:Me.threads(e)}),n.invalidateQueries({queryKey:Me.thread(e,y.id)}),y.gatewayId&&n.invalidateQueries({queryKey:Me.gatewayThreads(e,y.gatewayId)})},t[10]=e,t[11]=n,t[12]=o):o=t[12];let l;t[13]!==u||t[14]!==o?(l={mutationFn:u,onSuccess:o},t[13]=u,t[14]=o,t[15]=l):l=t[15];const d=jt(l);let f;t[16]!==e?(f=async y=>{const T=`${e}:threads:${y}`;return await Du(T),y},t[16]=e,t[17]=f):f=t[17];let p;t[18]!==e||t[19]!==n?(p=()=>{n.invalidateQueries({queryKey:Me.threads(e)})},t[18]=e,t[19]=n,t[20]=p):p=t[20];let h;t[21]!==f||t[22]!==p?(h={mutationFn:f,onSuccess:p},t[21]=f,t[22]=p,t[23]=h):h=t[23];const g=jt(h);let _;return t[24]!==g||t[25]!==s||t[26]!==d?(_={insert:s,update:d,delete:g},t[24]=g,t[25]=s,t[26]=d,t[27]=_):_=t[27],_}function Mu(){const t=W.c(37),{locator:e}=Dt(),n=Yi();let r;t[0]!==e?(r=async R=>{const O=`${e}:messages:${R.id}`;return await Dn(O,R),R},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=R=>{const O=R.metadata?.thread_id||R.threadId;O&&n.invalidateQueries({queryKey:Me.threadMessages(e,O)}),n.invalidateQueries({queryKey:Me.messages(e)})},t[2]=e,t[3]=n,t[4]=i):i=t[4];let a;t[5]!==r||t[6]!==i?(a={mutationFn:r,onSuccess:i},t[5]=r,t[6]=i,t[7]=a):a=t[7];const s=jt(a);let u;t[8]!==e?(u=async R=>(await Promise.all(R.map(O=>{const S=`${e}:messages:${O.id}`;return Dn(S,O)})),R),t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=R=>{const O=new Set;for(const S of R){const v=S.metadata?.thread_id||S.threadId;v&&O.add(v)}for(const S of O)n.invalidateQueries({queryKey:Me.threadMessages(e,S)});n.invalidateQueries({queryKey:Me.messages(e)})},t[10]=e,t[11]=n,t[12]=o):o=t[12];let l;t[13]!==u||t[14]!==o?(l={mutationFn:u,onSuccess:o},t[13]=u,t[14]=o,t[15]=l):l=t[15];const d=jt(l);let f;t[16]!==e?(f=async R=>{const{id:O,updates:S}=R,v=`${e}:messages:${O}`,B=await Gi(v);if(!B)throw new Error(`Message ${O} not found`);const z={...B,...S};return await Dn(v,z),z},t[16]=e,t[17]=f):f=t[17];let p;t[18]!==e||t[19]!==n?(p=R=>{const O=R.metadata?.thread_id||R.threadId;O&&n.invalidateQueries({queryKey:Me.threadMessages(e,O)}),n.invalidateQueries({queryKey:Me.messages(e)})},t[18]=e,t[19]=n,t[20]=p):p=t[20];let h;t[21]!==f||t[22]!==p?(h={mutationFn:f,onSuccess:p},t[21]=f,t[22]=p,t[23]=h):h=t[23];const g=jt(h);let _;t[24]!==e?(_=async R=>{const O=`${e}:messages:${R}`;return await Du(O),R},t[24]=e,t[25]=_):_=t[25];let y;t[26]!==e||t[27]!==n?(y=()=>{n.invalidateQueries({queryKey:Me.messages(e)})},t[26]=e,t[27]=n,t[28]=y):y=t[28];let T;t[29]!==y||t[30]!==_?(T={mutationFn:_,onSuccess:y},t[29]=y,t[30]=_,t[31]=T):T=t[31];const I=jt(T);let E;return t[32]!==I||t[33]!==s||t[34]!==d||t[35]!==g?(E={insert:s,insertMany:d,update:g,delete:I},t[32]=I,t[33]=s,t[34]=d,t[35]=g,t[36]=E):E=t[36],E}function c_(){const t=W.c(5),e=Yi(),{org:n}=Dt();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},t[0]=r):r=t[0];const i=Ac(r);let a;return t[1]!==n||t[2]!==i||t[3]!==e?(a=s=>{const o=s.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!o||!o[1])return;const l=o[1],d=i.connectionId;if(!d)return;e.invalidateQueries({queryKey:Me.collection(n.slug,d,l)});const f=l.toLowerCase().replace(/_/g," ");Ei.success(`${f} updated`)},t[1]=n,t[2]=i,t[3]=e,t[4]=a):a=t[4],a}var Bu="vercel.ai.error",_d=Symbol.for(Bu),va,Pa,Lt=class Fu extends(Pa=Error,va=_d,Pa){constructor({name:e,message:n,cause:r}){super(n),this[va]=!0,this.name=e,this.cause=r}static isInstance(e){return Fu.hasMarker(e,Bu)}static hasMarker(e,n){const r=Symbol.for(n);return e!=null&&typeof e=="object"&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function Uu(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Hu="AI_InvalidArgumentError",ju=`vercel.ai.error.${Hu}`,yd=Symbol.for(ju),Ma,Ba,Ad=class extends(Ba=Lt,Ma=yd,Ba){constructor({message:t,cause:e,argument:n}){super({name:Hu,message:t,cause:e}),this[Ma]=!0,this.argument=n}static isInstance(t){return Lt.hasMarker(t,ju)}},zu="AI_JSONParseError",$u=`vercel.ai.error.${zu}`,kd=Symbol.for($u),Fa,Ua,Ha=class extends(Ua=Lt,Fa=kd,Ua){constructor({text:t,cause:e}){super({name:zu,message:`JSON parsing failed: Text: ${t}.
3
3
  Error message: ${Uu(e)}`,cause:e}),this[Fa]=!0,this.text=t}static isInstance(t){return Lt.hasMarker(t,$u)}},Yu="AI_TypeValidationError",qu=`vercel.ai.error.${Yu}`,Cd=Symbol.for(qu),ja,za,un=class bi extends(za=Lt,ja=Cd,za){constructor({value:e,cause:n}){super({name:Yu,message:`Type validation failed: Value: ${JSON.stringify(e)}.
4
4
  Error message: ${Uu(n)}`,cause:n}),this[ja]=!0,this.value=e}static isInstance(e){return Lt.hasMarker(e,qu)}static wrap({value:e,cause:n}){return bi.isInstance(n)&&n.value===e?n:new bi({value:e,cause:n})}},Kn=({prefix:t,size:e=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const i=()=>{const a=n.length,s=new Array(e);for(let u=0;u<e;u++)s[u]=n[Math.random()*a|0];return s.join("")};if(t==null)return i;if(n.includes(r))throw new Ad({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${t}${r}${i()}`},Id=Kn();function $a(t=globalThis){var e,n,r;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(r=(n=t.process)==null?void 0:n.versions)!=null&&r.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function Ht(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((n,r)=>{e[r.toLowerCase()]=n});else{Array.isArray(t)||(t=Object.entries(t));for(const[n,r]of t)r!=null&&(e[n.toLowerCase()]=r)}return e}function Ya(t,...e){const n=new Headers(Ht(t)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...e].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var Sd=/"__proto__"\s*:/,Nd=/"constructor"\s*:/;function qa(t){const e=JSON.parse(t);return e===null||typeof e!="object"||Sd.test(t)===!1&&Nd.test(t)===!1?e:wd(e)}function wd(t){let e=[t];for(;e.length;){const n=e;e=[];for(const r of n){if(Object.prototype.hasOwnProperty.call(r,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(r,"constructor")&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in r){const a=r[i];a&&typeof a=="object"&&e.push(a)}}}return t}function Rd(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return qa(t)}try{return qa(t)}finally{Error.stackTraceLimit=e}}function Vu(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:n}=t;if(n!=null)for(const r of Object.keys(n))n[r]=Ft(n[r])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(Ft):Ft(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(Ft)),t.allOf!=null&&(t.allOf=t.allOf.map(Ft)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(Ft));const{definitions:e}=t;if(e!=null)for(const n of Object.keys(e))e[n]=Ft(e[n]);return t}function Ft(t){return typeof t=="boolean"?t:Vu(t)}var Od=Symbol("Let zodToJsonSchema decide on which parser to use"),Va={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"},Ld=t=>typeof t=="string"?{...Va,name:t}:{...Va,...t};function Ke(){return{}}function Dd(t,e){var n,r,i;const a={type:"array"};return(n=t.type)!=null&&n._def&&((i=(r=t.type)==null?void 0:r._def)==null?void 0:i.typeName)!==ee.ZodAny&&(a.items=pe(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(a.minItems=t.minLength.value),t.maxLength&&(a.maxItems=t.maxLength.value),t.exactLength&&(a.minItems=t.exactLength.value,a.maxItems=t.exactLength.value),a}function vd(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function Pd(){return{type:"boolean"}}function Wu(t,e){return pe(t.type._def,e)}var Md=(t,e)=>pe(t.innerType._def,e);function Qu(t,e,n){const r=n??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,a)=>Qu(t,e,i))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Bd(t)}}var Bd=t=>{const e={type:"integer",format:"unix-time"};for(const n of t.checks)switch(n.kind){case"min":e.minimum=n.value;break;case"max":e.maximum=n.value;break}return e};function Fd(t,e){return{...pe(t.innerType._def,e),default:t.defaultValue()}}function Ud(t,e){return e.effectStrategy==="input"?pe(t.schema._def,e):Ke()}function Hd(t){return{type:"string",enum:Array.from(t.values)}}var jd=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function zd(t,e){const n=[pe(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),pe(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(jd(i))r.push(...i.allOf);else{let a=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:s,...u}=i;a=u}r.push(a)}}),r.length?{allOf:r}:void 0}function $d(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 Gr=void 0,it={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:()=>(Gr===void 0&&(Gr=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Gr),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 Gu(t,e){const n={type:"string"};if(t.checks)for(const r of t.checks)switch(r.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"email":switch(e.emailStrategy){case"format:email":at(n,"email",r.message,e);break;case"format:idn-email":at(n,"idn-email",r.message,e);break;case"pattern:zod":He(n,it.email,r.message,e);break}break;case"url":at(n,"uri",r.message,e);break;case"uuid":at(n,"uuid",r.message,e);break;case"regex":He(n,r.regex,r.message,e);break;case"cuid":He(n,it.cuid,r.message,e);break;case"cuid2":He(n,it.cuid2,r.message,e);break;case"startsWith":He(n,RegExp(`^${Xr(r.value,e)}`),r.message,e);break;case"endsWith":He(n,RegExp(`${Xr(r.value,e)}$`),r.message,e);break;case"datetime":at(n,"date-time",r.message,e);break;case"date":at(n,"date",r.message,e);break;case"time":at(n,"time",r.message,e);break;case"duration":at(n,"duration",r.message,e);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value;break;case"includes":{He(n,RegExp(Xr(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&&at(n,"ipv4",r.message,e),r.version!=="v4"&&at(n,"ipv6",r.message,e);break}case"base64url":He(n,it.base64url,r.message,e);break;case"jwt":He(n,it.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&He(n,it.ipv4Cidr,r.message,e),r.version!=="v4"&&He(n,it.ipv6Cidr,r.message,e);break}case"emoji":He(n,it.emoji(),r.message,e);break;case"ulid":{He(n,it.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{at(n,"binary",r.message,e);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{He(n,it.base64,r.message,e);break}}break}case"nanoid":He(n,it.nanoid,r.message,e)}return n}function Xr(t,e){return e.patternStrategy==="escape"?qd(t):t}var Yd=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function qd(t){let e="";for(let n=0;n<t.length;n++)Yd.has(t[n])||(e+="\\"),e+=t[n];return e}function at(t,e,n,r){var i;t.format||(i=t.anyOf)!=null&&i.some(a=>a.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...n&&r.errorMessages&&{errorMessage:{format:n}}})):t.format=e}function He(t,e,n,r){var i;t.pattern||(i=t.allOf)!=null&&i.some(a=>a.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Wa(e,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):t.pattern=Wa(e,r)}function Wa(t,e){var n;if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source;let a="",s=!1,u=!1,o=!1;for(let l=0;l<i.length;l++){if(s){a+=i[l],s=!1;continue}if(r.i){if(u){if(i[l].match(/[a-z]/)){o?(a+=i[l],a+=`${i[l-2]}-${i[l]}`.toUpperCase(),o=!1):i[l+1]==="-"&&((n=i[l+2])!=null&&n.match(/[a-z]/))?(a+=i[l],o=!0):a+=`${i[l]}${i[l].toUpperCase()}`;continue}}else if(i[l].match(/[a-z]/)){a+=`[${i[l]}${i[l].toUpperCase()}]`;continue}}if(r.m){if(i[l]==="^"){a+=`(^|(?<=[\r
5
5
  ]))`;continue}else if(i[l]==="$"){a+=`($|(?=[\r
6
6
  ]))`;continue}}if(r.s&&i[l]==="."){a+=u?`${i[l]}\r
7
7
  `:`[${i[l]}\r
8
- ]`;continue}a+=i[l],i[l]==="\\"?s=!0:u&&i[l]==="]"?u=!1:!u&&i[l]==="["&&(u=!0)}try{new RegExp(a)}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 a}function Xu(t,e){var n,r,i,a,s,u;const o={type:"object",additionalProperties:(n=pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?n:e.allowedAdditionalProperties};if(((r=t.keyType)==null?void 0:r._def.typeName)===ee.ZodString&&((i=t.keyType._def.checks)!=null&&i.length)){const{type:l,...d}=Gu(t.keyType._def,e);return{...o,propertyNames:d}}else{if(((a=t.keyType)==null?void 0:a._def.typeName)===ee.ZodEnum)return{...o,propertyNames:{enum:t.keyType._def.values}};if(((s=t.keyType)==null?void 0:s._def.typeName)===ee.ZodBranded&&t.keyType._def.type._def.typeName===ee.ZodString&&((u=t.keyType._def.type._def.checks)!=null&&u.length)){const{type:l,...d}=Wu(t.keyType._def,e);return{...o,propertyNames:d}}}return o}function Vd(t,e){if(e.mapStrategy==="record")return Xu(t,e);const n=pe(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Ke(),r=pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Ke();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function Wd(t){const e=t.values,r=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),i=Array.from(new Set(r.map(a=>typeof a)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function Qd(){return{not:Ke()}}function Gd(){return{type:"null"}}var Ti={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Xd(t,e){const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Ti&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,a)=>{const s=Ti[a._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,a)=>{const s=typeof a._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(a._def.value===null)return[...i,"null"];default:return i}},[]);if(r.length===n.length){const i=r.filter((a,s,u)=>u.indexOf(a)===s);return{type:i.length>1?i:i[0],enum:n.reduce((a,s)=>a.includes(s._def.value)?a:[...a,s._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(a=>!r.includes(a))],[])};return Zd(t,e)}var Zd=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>pe(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function Kd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Ti[t.innerType._def.typeName],"null"]};const n=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function Jd(t){const e={type:"number"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"int":e.type="integer";break;case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function ef(t,e){const n={type:"object",properties:{}},r=[],i=t.shape();for(const s in i){let u=i[s];if(u===void 0||u._def===void 0)continue;const o=nf(u),l=pe(u._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,o||r.push(s))}r.length&&(n.required=r);const a=tf(t,e);return a!==void 0&&(n.additionalProperties=a),n}function tf(t,e){if(t.catchall._def.typeName!=="ZodNever")return pe(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 nf(t){try{return t.isOptional()}catch{return!0}}var rf=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return pe(t.innerType._def,e);const r=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ke()},r]}:Ke()},af=(t,e)=>{if(e.pipeStrategy==="input")return pe(t.in._def,e);if(e.pipeStrategy==="output")return pe(t.out._def,e);const n=pe(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=pe(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function sf(t,e){return pe(t.type._def,e)}function uf(t,e){const r={type:"array",uniqueItems:!0,items:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(r.minItems=t.minSize.value),t.maxSize&&(r.maxItems=t.maxSize.value),r}function of(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>pe(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:pe(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>pe(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function lf(){return{not:Ke()}}function cf(){return Ke()}var df=(t,e)=>pe(t.innerType._def,e),ff=(t,e,n)=>{switch(e){case ee.ZodString:return Gu(t,n);case ee.ZodNumber:return Jd(t);case ee.ZodObject:return ef(t,n);case ee.ZodBigInt:return vd(t);case ee.ZodBoolean:return Pd();case ee.ZodDate:return Qu(t,n);case ee.ZodUndefined:return lf();case ee.ZodNull:return Gd();case ee.ZodArray:return Dd(t,n);case ee.ZodUnion:case ee.ZodDiscriminatedUnion:return Xd(t,n);case ee.ZodIntersection:return zd(t,n);case ee.ZodTuple:return of(t,n);case ee.ZodRecord:return Xu(t,n);case ee.ZodLiteral:return $d(t);case ee.ZodEnum:return Hd(t);case ee.ZodNativeEnum:return Wd(t);case ee.ZodNullable:return Kd(t,n);case ee.ZodOptional:return rf(t,n);case ee.ZodMap:return Vd(t,n);case ee.ZodSet:return uf(t,n);case ee.ZodLazy:return()=>t.getter()._def;case ee.ZodPromise:return sf(t,n);case ee.ZodNaN:case ee.ZodNever:return Qd();case ee.ZodEffects:return Ud(t,n);case ee.ZodAny:return Ke();case ee.ZodUnknown:return cf();case ee.ZodDefault:return Fd(t,n);case ee.ZodBranded:return Wu(t,n);case ee.ZodReadonly:return df(t,n);case ee.ZodCatch:return Md(t,n);case ee.ZodPipeline:return af(t,n);case ee.ZodFunction:case ee.ZodVoid:case ee.ZodSymbol:return;default:return(r=>{})()}},hf=(t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")};function pe(t,e,n=!1){var r;const i=e.seen.get(t);if(e.override){const o=(r=e.override)==null?void 0:r.call(e,t,e,i,n);if(o!==Od)return o}if(i&&!n){const o=pf(i,e);if(o!==void 0)return o}const a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);const s=ff(t,t.typeName,e),u=typeof s=="function"?pe(s(),e):s;if(u&&mf(t,e,u),e.postProcess){const o=e.postProcess(u,t,e);return a.jsonSchema=u,o}return a.jsonSchema=u,u}var pf=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:hf(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Ke()):e.$refStrategy==="seen"?Ke():void 0}},mf=(t,e,n)=>(t.description&&(n.description=t.description),n),gf=t=>{const e=Ld(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}},Ef=(t,e)=>{var n;const r=gf(e);let i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[d,f])=>{var p;return{...l,[d]:(p=pe(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?p:Ke()}},{}):void 0;const a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=(n=pe(t._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))!=null?n:Ke(),u=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;u!==void 0&&(s.title=u);const o=a===void 0?i?{...s,[r.definitionPath]:i}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,a].join("/"),[r.definitionPath]:{...i,[a]:s}};return o.$schema="http://json-schema.org/draft-07/schema#",o},xi=Symbol.for("vercel.ai.schema");function bf(t){let e;return()=>(e==null&&(e=t()),e)}function Dr(t,{validate:e}={}){return{[xi]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function Tf(t){return typeof t=="object"&&t!==null&&xi in t&&t[xi]===!0&&"jsonSchema"in t&&"validate"in t}function Zi(t){return t==null?Dr({properties:{},additionalProperties:!1}):Tf(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Zu(t):xf(t):t()}function xf(t){return Dr(()=>t["~standard"].jsonSchema.input({target:"draft-07"}),{validate:async e=>{const n=await t["~standard"].validate(e);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new un({value:e,cause:n.issues})}}})}function _f(t,e){var n;const r=(n=void 0)!=null?n:!1;return Dr(()=>Ef(t,{$refStrategy:r?"root":"none"}),{validate:async i=>{const a=await t.safeParseAsync(i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function yf(t,e){var n;const r=(n=void 0)!=null?n:!1;return Dr(()=>Vu(Cc(t,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const a=await kc(t,i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function Af(t){return"_zod"in t}function Zu(t,e){return Af(t)?yf(t):_f(t)}async function Qa({value:t,schema:e}){const n=await qn({value:t,schema:e});if(!n.success)throw un.wrap({value:t,cause:n.error});return n.value}async function qn({value:t,schema:e}){const n=Zi(e);try{if(n.validate==null)return{success:!0,value:t,rawValue:t};const r=await n.validate(t);return r.success?{success:!0,value:r.value,rawValue:t}:{success:!1,error:un.wrap({value:t,cause:r.error}),rawValue:t}}catch(r){return{success:!1,error:un.wrap({value:t,cause:r}),rawValue:t}}}async function qt({text:t,schema:e}){try{const n=Rd(t);return e==null?{success:!0,value:n,rawValue:n}:await qn({value:n,schema:e})}catch(n){return{success:!1,error:Ha.isInstance(n)?n:new Ha({text:t,cause:n}),rawValue:void 0}}}function kf({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new vc).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await qt({text:n,schema:e}))}}))}async function wt(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var Cf=Object.defineProperty,If=(t,e)=>{for(var n in e)Cf(t,n,{get:e[n],enumerable:!0})},Ku="AI_NoObjectGeneratedError",Ju=`vercel.ai.error.${Ku}`,Sf=Symbol.for(Ju),eo,Ot=class extends Lt{constructor({message:t="No object generated.",cause:e,text:n,response:r,usage:i,finishReason:a}){super({name:Ku,message:t,cause:e}),this[eo]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Lt.hasMarker(t,Ju)}};eo=Sf;var Ga="6.0.23",to=Ve([Y(),xr(Uint8Array),xr(ArrayBuffer),Eu(t=>{var e,n;return(n=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?n:!1},{message:"Must be a Buffer"})]),Vn=Ic(()=>Ve([Sc(),Y(),Nc(),je(),$n(Y(),Vn.optional()),Zn(Vn)])),ue=$n(Y(),$n(Y(),Vn.optional())),no=Ee({type:G("text"),text:Y(),providerOptions:ue.optional()}),Nf=Ee({type:G("image"),image:Ve([to,xr(URL)]),mediaType:Y().optional(),providerOptions:ue.optional()}),ro=Ee({type:G("file"),data:Ve([to,xr(URL)]),filename:Y().optional(),mediaType:Y(),providerOptions:ue.optional()}),wf=Ee({type:G("reasoning"),text:Y(),providerOptions:ue.optional()}),Rf=Ee({type:G("tool-call"),toolCallId:Y(),toolName:Y(),input:Ct(),providerOptions:ue.optional(),providerExecuted:je().optional()}),Of=wc("type",[Ee({type:G("text"),value:Y(),providerOptions:ue.optional()}),Ee({type:G("json"),value:Vn,providerOptions:ue.optional()}),Ee({type:G("execution-denied"),reason:Y().optional(),providerOptions:ue.optional()}),Ee({type:G("error-text"),value:Y(),providerOptions:ue.optional()}),Ee({type:G("error-json"),value:Vn,providerOptions:ue.optional()}),Ee({type:G("content"),value:Zn(Ve([Ee({type:G("text"),text:Y(),providerOptions:ue.optional()}),Ee({type:G("media"),data:Y(),mediaType:Y()}),Ee({type:G("file-data"),data:Y(),mediaType:Y(),filename:Y().optional(),providerOptions:ue.optional()}),Ee({type:G("file-url"),url:Y(),providerOptions:ue.optional()}),Ee({type:G("file-id"),fileId:Ve([Y(),$n(Y(),Y())]),providerOptions:ue.optional()}),Ee({type:G("image-data"),data:Y(),mediaType:Y(),providerOptions:ue.optional()}),Ee({type:G("image-url"),url:Y(),providerOptions:ue.optional()}),Ee({type:G("image-file-id"),fileId:Ve([Y(),$n(Y(),Y())]),providerOptions:ue.optional()}),Ee({type:G("custom"),providerOptions:ue.optional()})]))})]),io=Ee({type:G("tool-result"),toolCallId:Y(),toolName:Y(),output:Of,providerOptions:ue.optional()}),Lf=Ee({type:G("tool-approval-request"),approvalId:Y(),toolCallId:Y()}),Df=Ee({type:G("tool-approval-response"),approvalId:Y(),approved:je(),reason:Y().optional()}),vf=Ee({role:G("system"),content:Y(),providerOptions:ue.optional()}),Pf=Ee({role:G("user"),content:Ve([Y(),Zn(Ve([no,Nf,ro]))]),providerOptions:ue.optional()}),Mf=Ee({role:G("assistant"),content:Ve([Y(),Zn(Ve([no,ro,wf,Rf,io,Lf]))]),providerOptions:ue.optional()}),Bf=Ee({role:G("tool"),content:Zn(Ve([io,Df])),providerOptions:ue.optional()});Ve([vf,Pf,Mf,Bf]);function ao(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const n={...t};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];if(i===void 0)continue;const a=r in t?t[r]:void 0,s=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),u=a!=null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);s&&u?n[r]=ao(a,i):n[r]=i}return n}var Ff={};If(Ff,{array:()=>zf,choice:()=>$f,json:()=>Yf,object:()=>jf,text:()=>Hf});function Uf(t){const e=["ROOT"];let n=-1,r=null;function i(o,l,d){switch(o){case'"':{n=l,e.pop(),e.push(d),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=l,r=l,e.pop(),e.push(d),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(d),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":{n=l,e.pop(),e.push(d),e.push("INSIDE_NUMBER");break}case"{":{n=l,e.pop(),e.push(d),e.push("INSIDE_OBJECT_START");break}case"[":{n=l,e.pop(),e.push(d),e.push("INSIDE_ARRAY_START");break}}}function a(o,l){switch(o){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=l,e.pop();break}}}function s(o,l){switch(o){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,e.pop();break}}}for(let o=0;o<t.length;o++){const l=t[o];switch(e[e.length-1]){case"ROOT":i(l,o,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{n=o,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{l===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(l,o,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{a(l,o);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),n=o;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:n=o}break}case"INSIDE_ARRAY_START":{l==="]"?(n=o,e.pop()):(n=o,i(l,o,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=o,e.pop();break}default:{n=o;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(l,o,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),n=o;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":{n=o;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(l,o),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(l,o);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(l,o);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(l,o);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const f=t.substring(r,o+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?a(l,o):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(l,o)):n=o;break}}}let u=t.slice(0,n+1);for(let o=e.length-1;o>=0;o--)switch(e[o]){case"INSIDE_STRING":{u+='"';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":{u+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{u+="]";break}case"INSIDE_LITERAL":{const d=t.substring(r,t.length);"true".startsWith(d)?u+="true".slice(d.length):"false".startsWith(d)?u+="false".slice(d.length):"null".startsWith(d)&&(u+="null".slice(d.length))}}return u}async function Jn(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await qt({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await qt({text:Uf(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Hf=()=>({responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}}}),jf=({schema:t,name:e,description:n})=>{const r=Zi(t);return{responseFormat:wt(r.jsonSchema).then(i=>({type:"json",schema:i,...e!=null&&{name:e},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},a){const s=await qt({text:i});if(!s.success)throw new Ot({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const u=await qn({value:s.value,schema:r});if(!u.success)throw new Ot({message:"No object generated: response did not match schema.",cause:u.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});return u.value},async parsePartialOutput({text:i}){const a=await Jn(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:a.value}}}}},zf=({element:t,name:e,description:n})=>{const r=Zi(t);return{responseFormat:wt(r.jsonSchema).then(i=>{const{$schema:a,...s}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:s}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},a){const s=await qt({text:i});if(!s.success)throw new Ot({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const u=s.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))throw new Ot({message:"No object generated: response did not match schema.",cause:new un({value:u,cause:"response must be an object with an elements array"}),text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});for(const o of u.elements){const l=await qn({value:o,schema:r});if(!l.success)throw new Ot({message:"No object generated: response did not match schema.",cause:l.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason})}return u.elements},async parsePartialOutput({text:i}){const a=await Jn(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=a.value;if(s==null||typeof s!="object"||!("elements"in s)||!Array.isArray(s.elements))return;const u=a.state==="repaired-parse"&&s.elements.length>0?s.elements.slice(0,-1):s.elements,o=[];for(const l of u){const d=await qn({value:l,schema:r});d.success&&o.push(d.value)}return{partial:o}}}}}},$f=({options:t,name:e,description:n})=>({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},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const a=await qt({text:r});if(!a.success)throw new Ot({message:"No object generated: could not parse the response.",cause:a.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const s=a.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string"||!t.includes(s.result))throw new Ot({message:"No object generated: response did not match schema.",cause:new un({value:s,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return s.result},async parsePartialOutput({text:r}){const i=await Jn(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=i.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string")return;const s=t.filter(u=>u.startsWith(a.result));return i.state==="successful-parse"?s.includes(a.result)?{partial:a.result}:void 0:s.length===1?{partial:s[0]}:void 0}}}}),Yf=({name:t,description:e}={})=>({responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:n},r){const i=await qt({text:n});if(!i.success)throw new Ot({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await Jn(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}}});Kn({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
8
+ ]`;continue}a+=i[l],i[l]==="\\"?s=!0:u&&i[l]==="]"?u=!1:!u&&i[l]==="["&&(u=!0)}try{new RegExp(a)}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 a}function Xu(t,e){var n,r,i,a,s,u;const o={type:"object",additionalProperties:(n=pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?n:e.allowedAdditionalProperties};if(((r=t.keyType)==null?void 0:r._def.typeName)===ee.ZodString&&((i=t.keyType._def.checks)!=null&&i.length)){const{type:l,...d}=Gu(t.keyType._def,e);return{...o,propertyNames:d}}else{if(((a=t.keyType)==null?void 0:a._def.typeName)===ee.ZodEnum)return{...o,propertyNames:{enum:t.keyType._def.values}};if(((s=t.keyType)==null?void 0:s._def.typeName)===ee.ZodBranded&&t.keyType._def.type._def.typeName===ee.ZodString&&((u=t.keyType._def.type._def.checks)!=null&&u.length)){const{type:l,...d}=Wu(t.keyType._def,e);return{...o,propertyNames:d}}}return o}function Vd(t,e){if(e.mapStrategy==="record")return Xu(t,e);const n=pe(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Ke(),r=pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Ke();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function Wd(t){const e=t.values,r=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),i=Array.from(new Set(r.map(a=>typeof a)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function Qd(){return{not:Ke()}}function Gd(){return{type:"null"}}var Ti={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Xd(t,e){const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Ti&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,a)=>{const s=Ti[a._def.typeName];return s&&!i.includes(s)?[...i,s]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,a)=>{const s=typeof a._def.value;switch(s){case"string":case"number":case"boolean":return[...i,s];case"bigint":return[...i,"integer"];case"object":if(a._def.value===null)return[...i,"null"];default:return i}},[]);if(r.length===n.length){const i=r.filter((a,s,u)=>u.indexOf(a)===s);return{type:i.length>1?i:i[0],enum:n.reduce((a,s)=>a.includes(s._def.value)?a:[...a,s._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(a=>!r.includes(a))],[])};return Zd(t,e)}var Zd=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>pe(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function Kd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Ti[t.innerType._def.typeName],"null"]};const n=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function Jd(t){const e={type:"number"};if(!t.checks)return e;for(const n of t.checks)switch(n.kind){case"int":e.type="integer";break;case"min":n.inclusive?e.minimum=n.value:e.exclusiveMinimum=n.value;break;case"max":n.inclusive?e.maximum=n.value:e.exclusiveMaximum=n.value;break;case"multipleOf":e.multipleOf=n.value;break}return e}function ef(t,e){const n={type:"object",properties:{}},r=[],i=t.shape();for(const s in i){let u=i[s];if(u===void 0||u._def===void 0)continue;const o=nf(u),l=pe(u._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,o||r.push(s))}r.length&&(n.required=r);const a=tf(t,e);return a!==void 0&&(n.additionalProperties=a),n}function tf(t,e){if(t.catchall._def.typeName!=="ZodNever")return pe(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 nf(t){try{return t.isOptional()}catch{return!0}}var rf=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return pe(t.innerType._def,e);const r=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ke()},r]}:Ke()},af=(t,e)=>{if(e.pipeStrategy==="input")return pe(t.in._def,e);if(e.pipeStrategy==="output")return pe(t.out._def,e);const n=pe(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=pe(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function sf(t,e){return pe(t.type._def,e)}function uf(t,e){const r={type:"array",uniqueItems:!0,items:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(r.minItems=t.minSize.value),t.maxSize&&(r.maxItems=t.maxSize.value),r}function of(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>pe(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:pe(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>pe(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function lf(){return{not:Ke()}}function cf(){return Ke()}var df=(t,e)=>pe(t.innerType._def,e),ff=(t,e,n)=>{switch(e){case ee.ZodString:return Gu(t,n);case ee.ZodNumber:return Jd(t);case ee.ZodObject:return ef(t,n);case ee.ZodBigInt:return vd(t);case ee.ZodBoolean:return Pd();case ee.ZodDate:return Qu(t,n);case ee.ZodUndefined:return lf();case ee.ZodNull:return Gd();case ee.ZodArray:return Dd(t,n);case ee.ZodUnion:case ee.ZodDiscriminatedUnion:return Xd(t,n);case ee.ZodIntersection:return zd(t,n);case ee.ZodTuple:return of(t,n);case ee.ZodRecord:return Xu(t,n);case ee.ZodLiteral:return $d(t);case ee.ZodEnum:return Hd(t);case ee.ZodNativeEnum:return Wd(t);case ee.ZodNullable:return Kd(t,n);case ee.ZodOptional:return rf(t,n);case ee.ZodMap:return Vd(t,n);case ee.ZodSet:return uf(t,n);case ee.ZodLazy:return()=>t.getter()._def;case ee.ZodPromise:return sf(t,n);case ee.ZodNaN:case ee.ZodNever:return Qd();case ee.ZodEffects:return Ud(t,n);case ee.ZodAny:return Ke();case ee.ZodUnknown:return cf();case ee.ZodDefault:return Fd(t,n);case ee.ZodBranded:return Wu(t,n);case ee.ZodReadonly:return df(t,n);case ee.ZodCatch:return Md(t,n);case ee.ZodPipeline:return af(t,n);case ee.ZodFunction:case ee.ZodVoid:case ee.ZodSymbol:return;default:return(r=>{})()}},hf=(t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")};function pe(t,e,n=!1){var r;const i=e.seen.get(t);if(e.override){const o=(r=e.override)==null?void 0:r.call(e,t,e,i,n);if(o!==Od)return o}if(i&&!n){const o=pf(i,e);if(o!==void 0)return o}const a={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,a);const s=ff(t,t.typeName,e),u=typeof s=="function"?pe(s(),e):s;if(u&&mf(t,e,u),e.postProcess){const o=e.postProcess(u,t,e);return a.jsonSchema=u,o}return a.jsonSchema=u,u}var pf=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:hf(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Ke()):e.$refStrategy==="seen"?Ke():void 0}},mf=(t,e,n)=>(t.description&&(n.description=t.description),n),gf=t=>{const e=Ld(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}},Ef=(t,e)=>{var n;const r=gf(e);let i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[d,f])=>{var p;return{...l,[d]:(p=pe(f._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0))!=null?p:Ke()}},{}):void 0;const a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=(n=pe(t._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))!=null?n:Ke(),u=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;u!==void 0&&(s.title=u);const o=a===void 0?i?{...s,[r.definitionPath]:i}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,a].join("/"),[r.definitionPath]:{...i,[a]:s}};return o.$schema="http://json-schema.org/draft-07/schema#",o},xi=Symbol.for("vercel.ai.schema");function bf(t){let e;return()=>(e==null&&(e=t()),e)}function Dr(t,{validate:e}={}){return{[xi]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function Tf(t){return typeof t=="object"&&t!==null&&xi in t&&t[xi]===!0&&"jsonSchema"in t&&"validate"in t}function Zi(t){return t==null?Dr({properties:{},additionalProperties:!1}):Tf(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Zu(t):xf(t):t()}function xf(t){return Dr(()=>t["~standard"].jsonSchema.input({target:"draft-07"}),{validate:async e=>{const n=await t["~standard"].validate(e);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new un({value:e,cause:n.issues})}}})}function _f(t,e){var n;const r=(n=void 0)!=null?n:!1;return Dr(()=>Ef(t,{$refStrategy:r?"root":"none"}),{validate:async i=>{const a=await t.safeParseAsync(i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function yf(t,e){var n;const r=(n=void 0)!=null?n:!1;return Dr(()=>Vu(Cc(t,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const a=await kc(t,i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function Af(t){return"_zod"in t}function Zu(t,e){return Af(t)?yf(t):_f(t)}async function Qa({value:t,schema:e}){const n=await qn({value:t,schema:e});if(!n.success)throw un.wrap({value:t,cause:n.error});return n.value}async function qn({value:t,schema:e}){const n=Zi(e);try{if(n.validate==null)return{success:!0,value:t,rawValue:t};const r=await n.validate(t);return r.success?{success:!0,value:r.value,rawValue:t}:{success:!1,error:un.wrap({value:t,cause:r.error}),rawValue:t}}catch(r){return{success:!1,error:un.wrap({value:t,cause:r}),rawValue:t}}}async function qt({text:t,schema:e}){try{const n=Rd(t);return e==null?{success:!0,value:n,rawValue:n}:await qn({value:n,schema:e})}catch(n){return{success:!1,error:Ha.isInstance(n)?n:new Ha({text:t,cause:n}),rawValue:void 0}}}function kf({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new vc).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await qt({text:n,schema:e}))}}))}async function wt(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var Cf=Object.defineProperty,If=(t,e)=>{for(var n in e)Cf(t,n,{get:e[n],enumerable:!0})},Ku="AI_NoObjectGeneratedError",Ju=`vercel.ai.error.${Ku}`,Sf=Symbol.for(Ju),eo,Ot=class extends Lt{constructor({message:t="No object generated.",cause:e,text:n,response:r,usage:i,finishReason:a}){super({name:Ku,message:t,cause:e}),this[eo]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Lt.hasMarker(t,Ju)}};eo=Sf;var Ga="6.0.24",to=Ve([Y(),xr(Uint8Array),xr(ArrayBuffer),Eu(t=>{var e,n;return(n=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?n:!1},{message:"Must be a Buffer"})]),Vn=Ic(()=>Ve([Sc(),Y(),Nc(),je(),$n(Y(),Vn.optional()),Zn(Vn)])),ue=$n(Y(),$n(Y(),Vn.optional())),no=Ee({type:G("text"),text:Y(),providerOptions:ue.optional()}),Nf=Ee({type:G("image"),image:Ve([to,xr(URL)]),mediaType:Y().optional(),providerOptions:ue.optional()}),ro=Ee({type:G("file"),data:Ve([to,xr(URL)]),filename:Y().optional(),mediaType:Y(),providerOptions:ue.optional()}),wf=Ee({type:G("reasoning"),text:Y(),providerOptions:ue.optional()}),Rf=Ee({type:G("tool-call"),toolCallId:Y(),toolName:Y(),input:Ct(),providerOptions:ue.optional(),providerExecuted:je().optional()}),Of=wc("type",[Ee({type:G("text"),value:Y(),providerOptions:ue.optional()}),Ee({type:G("json"),value:Vn,providerOptions:ue.optional()}),Ee({type:G("execution-denied"),reason:Y().optional(),providerOptions:ue.optional()}),Ee({type:G("error-text"),value:Y(),providerOptions:ue.optional()}),Ee({type:G("error-json"),value:Vn,providerOptions:ue.optional()}),Ee({type:G("content"),value:Zn(Ve([Ee({type:G("text"),text:Y(),providerOptions:ue.optional()}),Ee({type:G("media"),data:Y(),mediaType:Y()}),Ee({type:G("file-data"),data:Y(),mediaType:Y(),filename:Y().optional(),providerOptions:ue.optional()}),Ee({type:G("file-url"),url:Y(),providerOptions:ue.optional()}),Ee({type:G("file-id"),fileId:Ve([Y(),$n(Y(),Y())]),providerOptions:ue.optional()}),Ee({type:G("image-data"),data:Y(),mediaType:Y(),providerOptions:ue.optional()}),Ee({type:G("image-url"),url:Y(),providerOptions:ue.optional()}),Ee({type:G("image-file-id"),fileId:Ve([Y(),$n(Y(),Y())]),providerOptions:ue.optional()}),Ee({type:G("custom"),providerOptions:ue.optional()})]))})]),io=Ee({type:G("tool-result"),toolCallId:Y(),toolName:Y(),output:Of,providerOptions:ue.optional()}),Lf=Ee({type:G("tool-approval-request"),approvalId:Y(),toolCallId:Y()}),Df=Ee({type:G("tool-approval-response"),approvalId:Y(),approved:je(),reason:Y().optional()}),vf=Ee({role:G("system"),content:Y(),providerOptions:ue.optional()}),Pf=Ee({role:G("user"),content:Ve([Y(),Zn(Ve([no,Nf,ro]))]),providerOptions:ue.optional()}),Mf=Ee({role:G("assistant"),content:Ve([Y(),Zn(Ve([no,ro,wf,Rf,io,Lf]))]),providerOptions:ue.optional()}),Bf=Ee({role:G("tool"),content:Zn(Ve([io,Df])),providerOptions:ue.optional()});Ve([vf,Pf,Mf,Bf]);function ao(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const n={...t};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];if(i===void 0)continue;const a=r in t?t[r]:void 0,s=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),u=a!=null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);s&&u?n[r]=ao(a,i):n[r]=i}return n}var Ff={};If(Ff,{array:()=>zf,choice:()=>$f,json:()=>Yf,object:()=>jf,text:()=>Hf});function Uf(t){const e=["ROOT"];let n=-1,r=null;function i(o,l,d){switch(o){case'"':{n=l,e.pop(),e.push(d),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=l,r=l,e.pop(),e.push(d),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(d),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":{n=l,e.pop(),e.push(d),e.push("INSIDE_NUMBER");break}case"{":{n=l,e.pop(),e.push(d),e.push("INSIDE_OBJECT_START");break}case"[":{n=l,e.pop(),e.push(d),e.push("INSIDE_ARRAY_START");break}}}function a(o,l){switch(o){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=l,e.pop();break}}}function s(o,l){switch(o){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,e.pop();break}}}for(let o=0;o<t.length;o++){const l=t[o];switch(e[e.length-1]){case"ROOT":i(l,o,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{n=o,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{l===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{i(l,o,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{a(l,o);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),n=o;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:n=o}break}case"INSIDE_ARRAY_START":{l==="]"?(n=o,e.pop()):(n=o,i(l,o,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=o,e.pop();break}default:{n=o;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(l,o,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),n=o;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":{n=o;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(l,o),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(l,o);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(l,o);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(l,o);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const f=t.substring(r,o+1);!"false".startsWith(f)&&!"true".startsWith(f)&&!"null".startsWith(f)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?a(l,o):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&s(l,o)):n=o;break}}}let u=t.slice(0,n+1);for(let o=e.length-1;o>=0;o--)switch(e[o]){case"INSIDE_STRING":{u+='"';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":{u+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{u+="]";break}case"INSIDE_LITERAL":{const d=t.substring(r,t.length);"true".startsWith(d)?u+="true".slice(d.length):"false".startsWith(d)?u+="false".slice(d.length):"null".startsWith(d)&&(u+="null".slice(d.length))}}return u}async function Jn(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await qt({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await qt({text:Uf(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Hf=()=>({responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}}}),jf=({schema:t,name:e,description:n})=>{const r=Zi(t);return{responseFormat:wt(r.jsonSchema).then(i=>({type:"json",schema:i,...e!=null&&{name:e},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},a){const s=await qt({text:i});if(!s.success)throw new Ot({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const u=await qn({value:s.value,schema:r});if(!u.success)throw new Ot({message:"No object generated: response did not match schema.",cause:u.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});return u.value},async parsePartialOutput({text:i}){const a=await Jn(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:a.value}}}}},zf=({element:t,name:e,description:n})=>{const r=Zi(t);return{responseFormat:wt(r.jsonSchema).then(i=>{const{$schema:a,...s}=i;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:s}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...n!=null&&{description:n}}}),async parseCompleteOutput({text:i},a){const s=await qt({text:i});if(!s.success)throw new Ot({message:"No object generated: could not parse the response.",cause:s.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});const u=s.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))throw new Ot({message:"No object generated: response did not match schema.",cause:new un({value:u,cause:"response must be an object with an elements array"}),text:i,response:a.response,usage:a.usage,finishReason:a.finishReason});for(const o of u.elements){const l=await qn({value:o,schema:r});if(!l.success)throw new Ot({message:"No object generated: response did not match schema.",cause:l.error,text:i,response:a.response,usage:a.usage,finishReason:a.finishReason})}return u.elements},async parsePartialOutput({text:i}){const a=await Jn(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const s=a.value;if(s==null||typeof s!="object"||!("elements"in s)||!Array.isArray(s.elements))return;const u=a.state==="repaired-parse"&&s.elements.length>0?s.elements.slice(0,-1):s.elements,o=[];for(const l of u){const d=await qn({value:l,schema:r});d.success&&o.push(d.value)}return{partial:o}}}}}},$f=({options:t,name:e,description:n})=>({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},...n!=null&&{description:n}}),async parseCompleteOutput({text:r},i){const a=await qt({text:r});if(!a.success)throw new Ot({message:"No object generated: could not parse the response.",cause:a.error,text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});const s=a.value;if(s==null||typeof s!="object"||!("result"in s)||typeof s.result!="string"||!t.includes(s.result))throw new Ot({message:"No object generated: response did not match schema.",cause:new un({value:s,cause:"response must be an object that contains a choice value."}),text:r,response:i.response,usage:i.usage,finishReason:i.finishReason});return s.result},async parsePartialOutput({text:r}){const i=await Jn(r);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const a=i.value;if(a==null||typeof a!="object"||!("result"in a)||typeof a.result!="string")return;const s=t.filter(u=>u.startsWith(a.result));return i.state==="successful-parse"?s.includes(a.result)?{partial:a.result}:void 0:s.length===1?{partial:s[0]}:void 0}}}}),Yf=({name:t,description:e}={})=>({responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:n},r){const i=await qt({text:n});if(!i.success)throw new Ot({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.value},async parsePartialOutput({text:n}){const r=await Jn(n);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return r.value===void 0?void 0:{partial:r.value}}}});Kn({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
9
9
 
10
10
  `)},flush(t){t.enqueue(`data: [DONE]
11
11
 
12
- `)}})}});var qf=bf(()=>Zu(Ve([ye({type:G("text-start"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("text-delta"),id:Y(),delta:Y(),providerMetadata:ue.optional()}),ye({type:G("text-end"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("error"),errorText:Y()}),ye({type:G("tool-input-start"),toolCallId:Y(),toolName:Y(),providerExecuted:je().optional(),dynamic:je().optional(),title:Y().optional()}),ye({type:G("tool-input-delta"),toolCallId:Y(),inputTextDelta:Y()}),ye({type:G("tool-input-available"),toolCallId:Y(),toolName:Y(),input:Ct(),providerExecuted:je().optional(),providerMetadata:ue.optional(),dynamic:je().optional(),title:Y().optional()}),ye({type:G("tool-input-error"),toolCallId:Y(),toolName:Y(),input:Ct(),providerExecuted:je().optional(),providerMetadata:ue.optional(),dynamic:je().optional(),errorText:Y(),title:Y().optional()}),ye({type:G("tool-approval-request"),approvalId:Y(),toolCallId:Y()}),ye({type:G("tool-output-available"),toolCallId:Y(),output:Ct(),providerExecuted:je().optional(),dynamic:je().optional(),preliminary:je().optional()}),ye({type:G("tool-output-error"),toolCallId:Y(),errorText:Y(),providerExecuted:je().optional(),dynamic:je().optional()}),ye({type:G("tool-output-denied"),toolCallId:Y()}),ye({type:G("reasoning-start"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("reasoning-delta"),id:Y(),delta:Y(),providerMetadata:ue.optional()}),ye({type:G("reasoning-end"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("source-url"),sourceId:Y(),url:Y(),title:Y().optional(),providerMetadata:ue.optional()}),ye({type:G("source-document"),sourceId:Y(),mediaType:Y(),title:Y(),filename:Y().optional(),providerMetadata:ue.optional()}),ye({type:G("file"),url:Y(),mediaType:Y(),providerMetadata:ue.optional()}),ye({type:Eu(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:Y().optional(),data:Ct(),transient:je().optional()}),ye({type:G("start-step")}),ye({type:G("finish-step")}),ye({type:G("start"),messageId:Y().optional(),messageMetadata:Ct().optional()}),ye({type:G("finish"),finishReason:Rc(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Ct().optional()}),ye({type:G("abort"),reason:Y().optional()}),ye({type:G("message-metadata"),messageMetadata:Ct()})])));function Vf(t){return t.type.startsWith("data-")}function _i(t){return t.type.startsWith("tool-")}function Wf(t){return t.type==="dynamic-tool"}function yi(t){return _i(t)||Wf(t)}function Xa(t){return t.type.split("-").slice(1).join("-")}function Qf({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Gf({stream:t,messageMetadataSchema:e,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:s}){return t.pipeThrough(new TransformStream({async transform(u,o){await r(async({state:l,write:d})=>{var f,p,h,g;function _(E){const O=l.message.parts.filter(yi).find(S=>S.toolCallId===E);if(O==null)throw new Error(`no tool invocation found for tool call ${E}`);return O}function y(E){var R;const O=l.message.parts.find(B=>_i(B)&&B.toolCallId===E.toolCallId),S=E,v=O;O!=null?(O.state=E.state,v.input=S.input,v.output=S.output,v.errorText=S.errorText,v.rawInput=S.rawInput,v.preliminary=S.preliminary,E.title!==void 0&&(v.title=E.title),v.providerExecuted=(R=S.providerExecuted)!=null?R:O.providerExecuted,S.providerMetadata!=null&&O.state==="input-available"&&(O.callProviderMetadata=S.providerMetadata)):l.message.parts.push({type:`tool-${E.toolName}`,toolCallId:E.toolCallId,state:E.state,title:E.title,input:S.input,output:S.output,rawInput:S.rawInput,errorText:S.errorText,providerExecuted:S.providerExecuted,preliminary:S.preliminary,...S.providerMetadata!=null?{callProviderMetadata:S.providerMetadata}:{}})}function T(E){var R,O;const S=l.message.parts.find(z=>z.type==="dynamic-tool"&&z.toolCallId===E.toolCallId),v=E,B=S;S!=null?(S.state=E.state,B.toolName=E.toolName,B.input=v.input,B.output=v.output,B.errorText=v.errorText,B.rawInput=(R=v.rawInput)!=null?R:B.rawInput,B.preliminary=v.preliminary,E.title!==void 0&&(B.title=E.title),B.providerExecuted=(O=v.providerExecuted)!=null?O:S.providerExecuted,v.providerMetadata!=null&&S.state==="input-available"&&(S.callProviderMetadata=v.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:E.toolName,toolCallId:E.toolCallId,state:E.state,input:v.input,output:v.output,errorText:v.errorText,preliminary:v.preliminary,providerExecuted:v.providerExecuted,title:E.title,...v.providerMetadata!=null?{callProviderMetadata:v.providerMetadata}:{}})}async function I(E){if(E!=null){const R=l.message.metadata!=null?ao(l.message.metadata,E):E;e!=null&&await Qa({value:R,schema:e}),l.message.metadata=R}}switch(u.type){case"text-start":{const E={type:"text",text:"",providerMetadata:u.providerMetadata,state:"streaming"};l.activeTextParts[u.id]=E,l.message.parts.push(E),d();break}case"text-delta":{const E=l.activeTextParts[u.id];E.text+=u.delta,E.providerMetadata=(f=u.providerMetadata)!=null?f:E.providerMetadata,d();break}case"text-end":{const E=l.activeTextParts[u.id];E.state="done",E.providerMetadata=(p=u.providerMetadata)!=null?p:E.providerMetadata,delete l.activeTextParts[u.id],d();break}case"reasoning-start":{const E={type:"reasoning",text:"",providerMetadata:u.providerMetadata,state:"streaming"};l.activeReasoningParts[u.id]=E,l.message.parts.push(E),d();break}case"reasoning-delta":{const E=l.activeReasoningParts[u.id];E.text+=u.delta,E.providerMetadata=(h=u.providerMetadata)!=null?h:E.providerMetadata,d();break}case"reasoning-end":{const E=l.activeReasoningParts[u.id];E.providerMetadata=(g=u.providerMetadata)!=null?g:E.providerMetadata,E.state="done",delete l.activeReasoningParts[u.id],d();break}case"file":{l.message.parts.push({type:"file",mediaType:u.mediaType,url:u.url}),d();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:u.sourceId,url:u.url,title:u.title,providerMetadata:u.providerMetadata}),d();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:u.sourceId,mediaType:u.mediaType,title:u.title,filename:u.filename,providerMetadata:u.providerMetadata}),d();break}case"tool-input-start":{const E=l.message.parts.filter(_i);l.partialToolCalls[u.toolCallId]={text:"",toolName:u.toolName,index:E.length,dynamic:u.dynamic,title:u.title},u.dynamic?T({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}):y({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}),d();break}case"tool-input-delta":{const E=l.partialToolCalls[u.toolCallId];E.text+=u.inputTextDelta;const{value:R}=await Jn(E.text);E.dynamic?T({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:R,title:E.title}):y({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:R,title:E.title}),d();break}case"tool-input-available":{u.dynamic?T({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}):y({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}),d(),a&&!u.providerExecuted&&await a({toolCall:u});break}case"tool-input-error":{u.dynamic?T({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}):y({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:void 0,rawInput:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}),d();break}case"tool-approval-request":{const E=_(u.toolCallId);E.state="approval-requested",E.approval={id:u.approvalId},d();break}case"tool-output-denied":{const E=_(u.toolCallId);E.state="output-denied",d();break}case"tool-output-available":{const E=_(u.toolCallId);E.type==="dynamic-tool"?T({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-available",input:E.input,output:u.output,preliminary:u.preliminary,providerExecuted:u.providerExecuted,title:E.title}):y({toolCallId:u.toolCallId,toolName:Xa(E),state:"output-available",input:E.input,output:u.output,providerExecuted:u.providerExecuted,preliminary:u.preliminary,title:E.title}),d();break}case"tool-output-error":{const E=_(u.toolCallId);E.type==="dynamic-tool"?T({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-error",input:E.input,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}):y({toolCallId:u.toolCallId,toolName:Xa(E),state:"output-error",input:E.input,rawInput:E.rawInput,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}),d();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{u.messageId!=null&&(l.message.id=u.messageId),await I(u.messageMetadata),(u.messageId!=null||u.messageMetadata!=null)&&d();break}case"finish":{u.finishReason!=null&&(l.finishReason=u.finishReason),await I(u.messageMetadata),u.messageMetadata!=null&&d();break}case"message-metadata":{await I(u.messageMetadata),u.messageMetadata!=null&&d();break}case"error":{i?.(new Error(u.errorText));break}default:if(Vf(u)){n?.[u.type]!=null&&await Qa({value:u.data,schema:n[u.type]});const E=u;if(E.transient){s?.(E);break}const R=E.id!=null?l.message.parts.find(O=>E.type===O.type&&E.id===O.id):void 0;R!=null?R.data=E.data:l.message.parts.push(E),s?.(E),d()}}o.enqueue(u)})}}))}async function Xf({stream:t,onError:e}){const n=t.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){e?.(r)}finally{n.releaseLock()}}Kn({prefix:"aitxt",size:24});Kn({prefix:"aiobj",size:24});var Zf=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,n)=>{this.queue.push(async()=>{try{await t(),e()}catch(r){n(r)}}),this.processQueue()})}};Kn({prefix:"aiobj",size:24});async function Kf(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:n,type:r}=e,i=await new Promise((a,s)=>{const u=new FileReader;u.onload=o=>{var l;a((l=o.target)==null?void 0:l.result)},u.onerror=o=>s(o),u.readAsDataURL(e)});return{type:"file",mediaType:r,filename:n,url:i}}))}var Jf=class{constructor({api:t="/api/chat",credentials:e,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:s}){this.api=t,this.credentials=e,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=s}async sendMessages({abortSignal:t,...e}){var n,r,i,a,s;const u=await wt(this.body),o=await wt(this.headers),l=await wt(this.credentials),d={...Ht(o),...Ht(e.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...u,...e.body},headers:d,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),p=(r=f?.api)!=null?r:this.api,h=f?.headers!==void 0?Ht(f.headers):d,g=f?.body!==void 0?f.body:{...u,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},_=(i=f?.credentials)!=null?i:l,T=await((a=this.fetch)!=null?a:globalThis.fetch)(p,{method:"POST",headers:Ya({"Content-Type":"application/json",...h},`ai-sdk/${Ga}`,$a()),body:JSON.stringify(g),credentials:_,signal:t});if(!T.ok)throw new Error((s=await T.text())!=null?s:"Failed to fetch the chat response.");if(!T.body)throw new Error("The response body is empty.");return this.processResponseStream(T.body)}async reconnectToStream(t){var e,n,r,i,a;const s=await wt(this.body),u=await wt(this.headers),o=await wt(this.credentials),l={...Ht(u),...Ht(t.headers)},d=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...s,...t.body},headers:l,credentials:o,requestMetadata:t.metadata})),f=(n=d?.api)!=null?n:`${this.api}/${t.chatId}/stream`,p=d?.headers!==void 0?Ht(d.headers):l,h=(r=d?.credentials)!=null?r:o,_=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:Ya(p,`ai-sdk/${Ga}`,$a()),credentials:h});if(_.status===204)return null;if(!_.ok)throw new Error((a=await _.text())!=null?a:"Failed to fetch the chat response.");if(!_.body)throw new Error("The response body is empty.");return this.processResponseStream(_.body)}},so=class extends Jf{constructor(t={}){super(t)}processResponseStream(t){return kf({stream:t,schema:qf}).pipeThrough(new TransformStream({async transform(e,n){if(!e.success)throw e.error;n.enqueue(e.value)}}))}},eh=class{constructor({generateId:t=Id,id:e=t(),transport:n=new so,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:s,onToolCall:u,onFinish:o,onData:l,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new Zf,this.sendMessage=async(f,p)=>{var h,g,_,y;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let T;if("text"in f||"files"in f?T={parts:[...Array.isArray(f.files)?f.files:await Kf(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:T=f,f.messageId!=null){const I=this.state.messages.findIndex(E=>E.id===f.messageId);if(I===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[I].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,I+1),this.state.replaceMessage(I,{...T,id:f.messageId,role:(g=T.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...T,id:(_=T.id)!=null?_:this.generateId(),role:(y=T.role)!=null?y:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...p})},this.regenerate=async({messageId:f,...p}={})=>{const h=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(h===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...p})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:f,approved:p,reason:h})=>this.jobExecutor.run(async()=>{var g,_;const y=this.state.messages,T=y[y.length-1],I=E=>yi(E)&&E.state==="approval-requested"&&E.approval.id===f?{...E,state:"approval-responded",approval:{id:f,approved:p,reason:h}}:E;this.state.replaceMessage(y.length-1,{...T,parts:T.parts.map(I)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(I)),this.status!=="streaming"&&this.status!=="submitted"&&((g=this.sendAutomaticallyWhen)!=null&&g.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})}),this.addToolOutput=async({state:f="output-available",tool:p,toolCallId:h,output:g,errorText:_})=>this.jobExecutor.run(async()=>{var y,T;const I=this.state.messages,E=I[I.length-1],R=O=>yi(O)&&O.toolCallId===h?{...O,state:f,output:g,errorText:_}:O;this.state.replaceMessage(I.length-1,{...E,parts:E.parts.map(R)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(R)),this.status!=="streaming"&&this.status!=="submitted"&&((y=this.sendAutomaticallyWhen)!=null&&y.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(T=this.lastMessage)==null?void 0:T.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=n,this.generateId=t,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=s,this.onToolCall=u,this.onFinish=o,this.onData=l,this.sendAutomaticallyWhen=d}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 makeRequest({trigger:t,metadata:e,headers:n,body:r,messageId:i}){var a,s,u,o;this.setStatus({status:"submitted",error:void 0});const l=this.lastMessage;let d=!1,f=!1,p=!1;try{const h={state:Qf({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=h;let g;if(t==="resume-stream"){const y=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:n,body:r});if(y==null){this.setStatus({status:"ready"});return}g=y}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:e,headers:n,body:r,trigger:t,messageId:i});const _=y=>this.jobExecutor.run(()=>y({state:h.state,write:()=>{var T;this.setStatus({status:"streaming"}),h.state.message.id===((T=this.lastMessage)==null?void 0:T.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await Xf({stream:Gf({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:_,onError:y=>{throw y}}),onError:y=>{throw y}}),this.setStatus({status:"ready"})}catch(h){if(d||h.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(s=this.onFinish)==null||s.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:p,finishReason:(a=this.activeResponse)==null?void 0:a.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}(u=this.sendAutomaticallyWhen)!=null&&u.call(this,{messages:this.state.messages})&&!p&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:e,headers:n,body:r})}},Zr,Za;function th(){if(Za)return Zr;Za=1;function t(e,n){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,i=0;return function(...s){clearTimeout(r);const u=Date.now(),o=u-i,l=n-o;l<=0?(i=u,e.apply(this,s)):r=setTimeout(()=>{i=Date.now(),e.apply(this,s)},l)}}return Zr=t,Zr}var nh=th();const rh=Vi(nh);var uo=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},Ae=(t,e,n)=>(uo(t,e,"read from private field"),n?n.call(t):e.get(t)),lt=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},It=(t,e,n,r)=>(uo(t,e,"write to private field"),e.set(t,n),n);function ih(t,e){return e!=null?rh(t,e):t}var et,pr,mr,wn,Rn,On,en,Ai,ki,ah=class{constructor(t=[]){lt(this,et,void 0),lt(this,pr,"ready"),lt(this,mr,void 0),lt(this,wn,new Set),lt(this,Rn,new Set),lt(this,On,new Set),this.pushMessage=e=>{It(this,et,Ae(this,et).concat(e)),Ae(this,en).call(this)},this.popMessage=()=>{It(this,et,Ae(this,et).slice(0,-1)),Ae(this,en).call(this)},this.replaceMessage=(e,n)=>{It(this,et,[...Ae(this,et).slice(0,e),this.snapshot(n),...Ae(this,et).slice(e+1)]),Ae(this,en).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,n)=>{const r=n?ih(e,n):e;return Ae(this,wn).add(r),()=>{Ae(this,wn).delete(r)}},this["~registerStatusCallback"]=e=>(Ae(this,Rn).add(e),()=>{Ae(this,Rn).delete(e)}),this["~registerErrorCallback"]=e=>(Ae(this,On).add(e),()=>{Ae(this,On).delete(e)}),lt(this,en,()=>{Ae(this,wn).forEach(e=>e())}),lt(this,Ai,()=>{Ae(this,Rn).forEach(e=>e())}),lt(this,ki,()=>{Ae(this,On).forEach(e=>e())}),It(this,et,t)}get status(){return Ae(this,pr)}set status(t){It(this,pr,t),Ae(this,Ai).call(this)}get error(){return Ae(this,mr)}set error(t){It(this,mr,t),Ae(this,ki).call(this)}get messages(){return Ae(this,et)}set messages(t){It(this,et,[...t]),Ae(this,en).call(this)}};et=new WeakMap;pr=new WeakMap;mr=new WeakMap;wn=new WeakMap;Rn=new WeakMap;On=new WeakMap;en=new WeakMap;Ai=new WeakMap;ki=new WeakMap;var tn,Ka=class extends eh{constructor({messages:e,...n}){const r=new ah(e);super({...n,state:r}),lt(this,tn,void 0),this["~registerMessagesCallback"]=(i,a)=>Ae(this,tn)["~registerMessagesCallback"](i,a),this["~registerStatusCallback"]=i=>Ae(this,tn)["~registerStatusCallback"](i),this["~registerErrorCallback"]=i=>Ae(this,tn)["~registerErrorCallback"](i),It(this,tn,r)}};tn=new WeakMap;function sh({experimental_throttle:t,resume:e=!1,...n}={}){const r=V.useRef("chat"in n?n.chat:new Ka(n));("chat"in n&&n.chat!==r.current||"id"in n&&r.current.id!==n.id)&&(r.current="chat"in n?n.chat:new Ka(n));const a=V.useCallback(d=>r.current["~registerMessagesCallback"](d,t),[t,r.current.id]),s=V.useSyncExternalStore(a,()=>r.current.messages,()=>r.current.messages),u=V.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),o=V.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),l=V.useCallback(d=>{typeof d=="function"&&(d=d(r.current.messages)),r.current.messages=d},[r]);return V.useEffect(()=>{e&&r.current.resumeStream()},[e,r]),{id:r.current.id,messages:s,setMessages:l,sendMessage:r.current.sendMessage,regenerate:r.current.regenerate,clearError:r.current.clearError,stop:r.current.stop,error:o,resumeStream:r.current.resumeStream,status:u,addToolResult:r.current.addToolOutput,addToolOutput:r.current.addToolOutput,addToolApprovalResponse:r.current.addToolApprovalResponse}}const uh="You are a helpful assistant.",oh=t=>new so({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:n})=>({body:{messages:e,stream:!0,...n}})});function f_(t){const e=W.c(37),{threadId:n,systemPrompt:r,onCreateThread:i,onError:a,onToolCall:s}=t,{org:u,locator:o}=Dt(),{slug:l}=u,d=Xi(),f=Mu(),[p,h]=V.useState(null),g=xd(n),_=r||uh;let y;e[0]!==_?(y={id:"system",role:"system",parts:[{type:"text",text:_}]},e[0]=_,e[1]=y):y=e[1];const I=y;let E;e[2]!==g||e[3]!==I?(E=[I,...g],e[2]=g,e[3]=I,e[4]=E):E=e[4];const R=E,O=`${n}:${_}`;let S;e[5]!==l?(S=oh(l),e[5]=l,e[6]=S):S=e[6];const v=S;let B;e[7]!==o||e[8]!==f||e[9]!==i||e[10]!==d||e[11]!==n?(B=async ae=>{const{finishReason:xe,messages:C,isAbort:ke,isDisconnect:Ie,isError:me}=ae;if(h(xe??null),xe!=="stop"||ke||Ie||me)return;const Ne=C.slice(-2).filter(Boolean);if(Ne.length!==2){console.warn("[chat] Expected 2 messages, got",Ne.length);return}f.insertMany.mutate(Ne);const _e=Ne.find(ch)?.parts?.find(lh)?.text.slice(0,100)||"";if(!await bd(o,n)){if(i)i({id:n,title:_e});else{const Se=new Date().toISOString(),Oe={id:n,title:_e,created_at:Se,updated_at:Se,hidden:!1};d.insert.mutate(Oe)}return}d.update.mutate({id:n,updates:{updated_at:new Date().toISOString()}})},e[7]=o,e[8]=f,e[9]=i,e[10]=d,e[11]=n,e[12]=B):B=e[12];const z=B;let N;e[13]!==a?(N=ae=>{console.error("[chat] Chat error:",ae),a?.(ae)},e[13]=a,e[14]=N):N=e[14];let F;e[15]!==R||e[16]!==O||e[17]!==z||e[18]!==s||e[19]!==N||e[20]!==v?(F={id:O,messages:R,transport:v,onFinish:z,onToolCall:s,onError:N},e[15]=R,e[16]=O,e[17]=z,e[18]=s,e[19]=N,e[20]=v,e[21]=F):F=e[21];const P=sh(F);let X;e[22]!==P?(X=async(ae,xe)=>{!ae?.trim()||P.status==="submitted"||P.status==="streaming"||(h(null),await P.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:ae}],metadata:xe},{metadata:xe}))},e[22]=P,e[23]=X):X=e[23];const q=X,j=P.messages[0]?.role==="system"?P.messages.length===1:P.messages.length===0,Z=P.messages,te=P.status;let K;e[24]!==P?(K=P.stop.bind(P),e[24]=P,e[25]=K):K=e[25];let ce;e[26]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>h(null),e[26]=ce):ce=e[26];let k;return e[27]!==P.clearError||e[28]!==P.error||e[29]!==P.messages||e[30]!==P.setMessages||e[31]!==P.status||e[32]!==p||e[33]!==j||e[34]!==q||e[35]!==K?(k={messages:Z,status:te,sendMessage:q,stop:K,setMessages:P.setMessages,isEmpty:j,error:P.error,clearError:P.clearError,finishReason:p,clearFinishReason:ce},e[27]=P.clearError,e[28]=P.error,e[29]=P.messages,e[30]=P.setMessages,e[31]=P.status,e[32]=p,e[33]=j,e[34]=q,e[35]=K,e[36]=k):k=e[36],k}function lh(t){return t.type==="text"}function ch(t){return t.parts?.find(dh)}function dh(t){return t.type==="text"}const oo={inputValue:"",branchContext:null,pendingSubmit:!1};function fh(t,e){switch(e.type){case"SET_INPUT":return{...t,inputValue:e.payload};case"START_BRANCH":return{...t,branchContext:e.payload};case"CLEAR_BRANCH":return{...t,branchContext:null};case"SET_PENDING_SUBMIT":return{...t,pendingSubmit:e.payload};case"RESET":return oo;default:return t}}const lo=V.createContext(null),co=()=>crypto.randomUUID();function hh(t){const e=W.c(16),{children:n}=t,{locator:r}=Dt(),[i,a]=V.useReducer(fh,oo),s=Xi(),[u,o]=Vc(Wc.threadManagerState(r)+":active-id",ph);let l;e[0]!==o||e[1]!==s?(l=y=>{const T=y?.id||crypto.randomUUID(),I=new Date().toISOString(),E={id:T,title:y?.title||"",created_at:y?.created_at||I,updated_at:y?.updated_at||I,hidden:y?.hidden??!1,gatewayId:y?.gatewayId};return s.insert.mutate(E),o(T),E},e[0]=o,e[1]=s,e[2]=l):l=e[2];const d=l;let f;e[3]!==u||e[4]!==o||e[5]!==s?(f=y=>{s.update.mutate({id:y,updates:{hidden:!0,updated_at:new Date().toISOString()}}),u===y&&o(co())},e[3]=u,e[4]=o,e[5]=s,e[6]=f):f=e[6];const p=f;let h;e[7]!==u||e[8]!==d||e[9]!==p||e[10]!==i||e[11]!==o?(h={interactionState:i,interactionDispatch:a,activeThreadId:u,createThread:d,setActiveThreadId:o,hideThread:p},e[7]=u,e[8]=d,e[9]=p,e[10]=i,e[11]=o,e[12]=h):h=e[12];const g=h;let _;return e[13]!==n||e[14]!==g?(_=m.jsx(lo.Provider,{value:g,children:n}),e[13]=n,e[14]=g,e[15]=_):_=e[15],_}function ph(t){return t||co()}function mh(){const t=W.c(19),e=V.useContext(lo);if(!e)throw new Error("useChat must be used within a ChatProvider");const{interactionState:n,interactionDispatch:r}=e;let i,a,s,u,o;t[0]!==r?(i=d=>r({type:"SET_INPUT",payload:d}),a=d=>r({type:"START_BRANCH",payload:d}),s=()=>r({type:"CLEAR_BRANCH"}),u=d=>r({type:"SET_PENDING_SUBMIT",payload:d}),o=()=>r({type:"RESET"}),t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=u,t[5]=o):(i=t[1],a=t[2],s=t[3],u=t[4],o=t[5]);let l;return t[6]!==e.activeThreadId||t[7]!==e.createThread||t[8]!==e.hideThread||t[9]!==e.setActiveThreadId||t[10]!==n.branchContext||t[11]!==n.inputValue||t[12]!==n.pendingSubmit||t[13]!==i||t[14]!==a||t[15]!==s||t[16]!==u||t[17]!==o?(l={inputValue:n.inputValue,branchContext:n.branchContext,pendingSubmit:n.pendingSubmit,setInputValue:i,startBranch:a,clearBranch:s,setPendingSubmit:u,reset:o,activeThreadId:e.activeThreadId,createThread:e.createThread,setActiveThreadId:e.setActiveThreadId,hideThread:e.hideThread},t[6]=e.activeThreadId,t[7]=e.createThread,t[8]=e.hideThread,t[9]=e.setActiveThreadId,t[10]=n.branchContext,t[11]=n.inputValue,t[12]=n.pendingSubmit,t[13]=i,t[14]=a,t[15]=s,t[16]=u,t[17]=o,t[18]=l):l=t[18],l}const Ja=3;function gh(t){const e=W.c(14),{prompt:n,onSelect:r}=t,i=n.description??n.name;let a;e[0]!==r||e[1]!==n?(a=()=>r(n),e[0]=r,e[1]=n,e[2]=a):a=e[2];const s=n.title??n.name;let u;if(e[3]!==s){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=/_/g,e[5]=f):f=e[5],u=s.replace(f," "),e[3]=s,e[4]=u}else u=e[4];let o;e[6]!==a||e[7]!==u?(o=m.jsx(fn,{asChild:!0,children:m.jsx("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:u})}),e[6]=a,e[7]=u,e[8]=o):o=e[8];let l;e[9]!==i?(l=m.jsx(hn,{side:"bottom",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:i})}),e[9]=i,e[10]=l):l=e[10];let d;return e[11]!==o||e[12]!==l?(d=m.jsxs(dn,{children:[o,l]}),e[11]=o,e[12]=l,e[13]=d):d=e[13],d}function Eh(t){const e=W.c(20),{prompts:n,onSelect:r,className:i}=t;if(n.length===0)return null;let a,s,u,o,l;if(e[0]!==i||e[1]!==r||e[2]!==n){const p=n.slice(0,Ja),h=n.slice(Ja),g=h.length>0;a=bu,l=300,e[8]!==i?(s=le("flex flex-wrap items-center justify-center gap-2",i),e[8]=i,e[9]=s):s=e[9];let _;e[10]!==r?(_=y=>m.jsx(gh,{prompt:y,onSelect:r},y.name),e[10]=r,e[11]=_):_=e[11],u=p.map(_),o=g&&m.jsxs(Tu,{children:[m.jsx(xu,{asChild:!0,children:m.jsxs("button",{type:"button",className:"size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:["+",h.length]})}),m.jsx(_u,{side:"bottom",align:"center",className:"w-auto p-2",children:m.jsx("div",{className:"flex flex-col gap-1",children:h.map(y=>{const T=y.description??y.name;return m.jsxs(dn,{children:[m.jsx(fn,{asChild:!0,children:m.jsx("button",{type:"button",onClick:()=>r(y),className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left",children:(y.title??y.name).replace(/_/g," ")})}),m.jsx(hn,{side:"right",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:T})})]},y.name)})})})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=s,e[5]=u,e[6]=o,e[7]=l}else a=e[3],s=e[4],u=e[5],o=e[6],l=e[7];let d;e[12]!==s||e[13]!==u||e[14]!==o?(d=m.jsxs("div",{className:s,children:[u,o]}),e[12]=s,e[13]=u,e[14]=o,e[15]=d):d=e[15];let f;return e[16]!==a||e[17]!==l||e[18]!==d?(f=m.jsx(a,{delayDuration:l,children:d}),e[16]=a,e[17]=l,e[18]=d,e[19]=f):f=e[19],f}async function bh(t){const e=`/mcp/gateway/${t}`,n={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const r=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mesh-chat",version:"1.0.0"}}})});if(!r.ok)return[];if((await r.json()).error)return[];const a=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!a.ok)return[];const s=await a.json();return s.error?[]:s.result?.prompts||[]}catch{return[]}}function Th(t){const e=W.c(7);let n;e[0]!==t?(n=Me.gatewayPrompts(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t?(r=()=>bh(t),e[2]=t,e[3]=r):r=e[3];let i;return e[4]!==n||e[5]!==r?(i={queryKey:n,queryFn:r,staleTime:6e4,retry:!1},e[4]=n,e[5]=r,e[6]=i):i=e[6],qi(i)}function h_(t){const e=W.c(4),{gatewayId:n,onSelect:r,className:i}=t,a=i===void 0?"mt-6":i,{data:s}=Th(n);if(s.length===0)return null;let u;return e[0]!==a||e[1]!==r||e[2]!==s?(u=m.jsx(Eh,{prompts:s,onSelect:r,className:a}),e[0]=a,e[1]=r,e[2]=s,e[3]=u):u=e[3],u}function xh(t){const e=W.c(66),{value:n,onChange:r,onSubmit:i,onStop:a,disabled:s,isStreaming:u,placeholder:o,className:l,centered:d,contextContent:f,leftActions:p,rightActions:h,maxTextHeight:g,children:_}=t,y=o===void 0?"Ask anything or @ for context":o,T=g===void 0?"164px":g;let I;e[0]!==s||e[1]!==u||e[2]!==n?(I=!s&&!u&&n.trim().length>0,e[0]=s,e[1]=u,e[2]=n,e[3]=I):I=e[3];const E=I;let R;e[4]!==E||e[5]!==u||e[6]!==a||e[7]!==i?(R=De=>{De.preventDefault(),u&&a?a():E&&i()},e[4]=E,e[5]=u,e[6]=a,e[7]=i,e[8]=R):R=e[8];const O=R;let S;e[9]!==E||e[10]!==i?(S=De=>{De.key==="Enter"&&!De.shiftKey&&(De.preventDefault(),E&&i())},e[9]=E,e[10]=i,e[11]=S):S=e[11];const v=S;let B;e[12]!==l?(B=le("w-full",l),e[12]=l,e[13]=B):B=e[13];let z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=le("relative rounded-xl border border-border bg-background w-full min-h-[130px] flex flex-col"),e[14]=z):z=e[14];let N;e[15]!==f?(N=f&&m.jsx("div",{className:"mb-1",children:f}),e[15]=f,e[16]=N):N=e[16];let F;e[17]!==T?(F={maxHeight:T},e[17]=T,e[18]=F):F=e[18];let P;e[19]!==r?(P=De=>r(De.target.value),e[19]=r,e[20]=P):P=e[20];const X=s||u;let q;e[21]===Symbol.for("react.memo_cache_sentinel")?(q=le("placeholder:text-muted-foreground resize-none focus-visible:ring-0 border-0 p-2 text-sm min-h-[20px] w-full","rounded-none shadow-none"),e[21]=q):q=e[21];let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j={minHeight:"20px",height:"auto",overflow:"hidden"},e[22]=j):j=e[22];let Z;e[23]!==v||e[24]!==y||e[25]!==P||e[26]!==X||e[27]!==n?(Z=m.jsx(qc,{value:n,onChange:P,onKeyDown:v,placeholder:y,disabled:X,className:q,rows:1,style:j}),e[23]=v,e[24]=y,e[25]=P,e[26]=X,e[27]=n,e[28]=Z):Z=e[28];let te;e[29]!==F||e[30]!==Z?(te=m.jsx("div",{className:"overflow-y-auto relative flex-1",style:F,children:Z}),e[29]=F,e[30]=Z,e[31]=te):te=e[31];let K;e[32]!==te||e[33]!==N?(K=m.jsxs("div",{className:"relative flex flex-col gap-2 p-2.5 flex-1",children:[N,te]}),e[32]=te,e[33]=N,e[34]=K):K=e[34];let ce;e[35]!==_||e[36]!==p?(ce=m.jsxs("div",{className:"flex items-center overflow-hidden gap-2 min-w-0",children:[p,_]}),e[35]=_,e[36]=p,e[37]=ce):ce=e[37];const k=u?"button":"submit";let ae;e[38]!==u||e[39]!==a?(ae=De=>{u&&(De.preventDefault(),De.stopPropagation(),a?.())},e[38]=u,e[39]=a,e[40]=ae):ae=e[40];const xe=E||u?"default":"ghost",C=!E&&!u,ke=!E&&!u&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let Ie;e[41]!==ke?(Ie=le("size-8 rounded-full transition-all",ke),e[41]=ke,e[42]=Ie):Ie=e[42];const me=u?"Stop generating":"Send message (Enter)";let Ne;e[43]!==u?(Ne=u?m.jsx(Hc,{size:20}):m.jsx(Fc,{size:20}),e[43]=u,e[44]=Ne):Ne=e[44];let _e;e[45]!==k||e[46]!==ae||e[47]!==xe||e[48]!==C||e[49]!==Ie||e[50]!==me||e[51]!==Ne?(_e=m.jsx(We,{type:k,onClick:ae,variant:xe,size:"icon",disabled:C,className:Ie,title:me,children:Ne}),e[45]=k,e[46]=ae,e[47]=xe,e[48]=C,e[49]=Ie,e[50]=me,e[51]=Ne,e[52]=_e):_e=e[52];let we;e[53]!==h||e[54]!==_e?(we=m.jsxs("div",{className:"flex items-center gap-1",children:[h,_e]}),e[53]=h,e[54]=_e,e[55]=we):we=e[55];let Se;e[56]!==ce||e[57]!==we?(Se=m.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[ce,we]}),e[56]=ce,e[57]=we,e[58]=Se):Se=e[58];let Oe;e[59]!==K||e[60]!==Se?(Oe=m.jsxs("div",{className:z,children:[K,Se]}),e[59]=K,e[60]=Se,e[61]=Oe):Oe=e[61];let ot;return e[62]!==O||e[63]!==Oe||e[64]!==B?(ot=m.jsx("form",{onSubmit:O,className:B,children:Oe}),e[62]=O,e[63]=Oe,e[64]=B,e[65]=ot):ot=e[65],ot}function _h(){const t=W.c(3),[e,n]=V.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async s=>{await navigator.clipboard.writeText(s),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let a;return t[1]!==e?(a={handleCopy:i,copied:e},t[1]=e,t[2]=a):a=t[2],a}function Ki(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Qt=Ki();function fo(t){Qt=t}var vn={exec:()=>null};function de(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace($e.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var $e={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},yh=/^(?:[ \t]*(?:\n|$))+/,Ah=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kh=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,er=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ch=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ji=/(?:[*+-]|\d{1,9}[.)])/,ho=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,po=de(ho).replace(/bull/g,Ji).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ih=de(ho).replace(/bull/g,Ji).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ea=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Sh=/^[^\n]+/,ta=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Nh=de(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ta).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wh=de(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ji).getRegex(),vr="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",na=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Rh=de("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",na).replace("tag",vr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mo=de(ea).replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vr).getRegex(),Oh=de(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mo).getRegex(),ra={blockquote:Oh,code:Ah,def:Nh,fences:kh,heading:Ch,hr:er,html:Rh,lheading:po,list:wh,newline:yh,paragraph:mo,table:vn,text:Sh},es=de("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vr).getRegex(),Lh={...ra,lheading:Ih,table:es,paragraph:de(ea).replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",es).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vr).getRegex()},Dh={...ra,html:de(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",na).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:vn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:de(ea).replace("hr",er).replace("heading",` *#{1,6} *[^
12
+ `)}})}});var qf=bf(()=>Zu(Ve([ye({type:G("text-start"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("text-delta"),id:Y(),delta:Y(),providerMetadata:ue.optional()}),ye({type:G("text-end"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("error"),errorText:Y()}),ye({type:G("tool-input-start"),toolCallId:Y(),toolName:Y(),providerExecuted:je().optional(),dynamic:je().optional(),title:Y().optional()}),ye({type:G("tool-input-delta"),toolCallId:Y(),inputTextDelta:Y()}),ye({type:G("tool-input-available"),toolCallId:Y(),toolName:Y(),input:Ct(),providerExecuted:je().optional(),providerMetadata:ue.optional(),dynamic:je().optional(),title:Y().optional()}),ye({type:G("tool-input-error"),toolCallId:Y(),toolName:Y(),input:Ct(),providerExecuted:je().optional(),providerMetadata:ue.optional(),dynamic:je().optional(),errorText:Y(),title:Y().optional()}),ye({type:G("tool-approval-request"),approvalId:Y(),toolCallId:Y()}),ye({type:G("tool-output-available"),toolCallId:Y(),output:Ct(),providerExecuted:je().optional(),dynamic:je().optional(),preliminary:je().optional()}),ye({type:G("tool-output-error"),toolCallId:Y(),errorText:Y(),providerExecuted:je().optional(),dynamic:je().optional()}),ye({type:G("tool-output-denied"),toolCallId:Y()}),ye({type:G("reasoning-start"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("reasoning-delta"),id:Y(),delta:Y(),providerMetadata:ue.optional()}),ye({type:G("reasoning-end"),id:Y(),providerMetadata:ue.optional()}),ye({type:G("source-url"),sourceId:Y(),url:Y(),title:Y().optional(),providerMetadata:ue.optional()}),ye({type:G("source-document"),sourceId:Y(),mediaType:Y(),title:Y(),filename:Y().optional(),providerMetadata:ue.optional()}),ye({type:G("file"),url:Y(),mediaType:Y(),providerMetadata:ue.optional()}),ye({type:Eu(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:Y().optional(),data:Ct(),transient:je().optional()}),ye({type:G("start-step")}),ye({type:G("finish-step")}),ye({type:G("start"),messageId:Y().optional(),messageMetadata:Ct().optional()}),ye({type:G("finish"),finishReason:Rc(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Ct().optional()}),ye({type:G("abort"),reason:Y().optional()}),ye({type:G("message-metadata"),messageMetadata:Ct()})])));function Vf(t){return t.type.startsWith("data-")}function _i(t){return t.type.startsWith("tool-")}function Wf(t){return t.type==="dynamic-tool"}function yi(t){return _i(t)||Wf(t)}function Xa(t){return t.type.split("-").slice(1).join("-")}function Qf({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Gf({stream:t,messageMetadataSchema:e,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:s}){return t.pipeThrough(new TransformStream({async transform(u,o){await r(async({state:l,write:d})=>{var f,p,h,g;function _(E){const O=l.message.parts.filter(yi).find(S=>S.toolCallId===E);if(O==null)throw new Error(`no tool invocation found for tool call ${E}`);return O}function y(E){var R;const O=l.message.parts.find(B=>_i(B)&&B.toolCallId===E.toolCallId),S=E,v=O;O!=null?(O.state=E.state,v.input=S.input,v.output=S.output,v.errorText=S.errorText,v.rawInput=S.rawInput,v.preliminary=S.preliminary,E.title!==void 0&&(v.title=E.title),v.providerExecuted=(R=S.providerExecuted)!=null?R:O.providerExecuted,S.providerMetadata!=null&&O.state==="input-available"&&(O.callProviderMetadata=S.providerMetadata)):l.message.parts.push({type:`tool-${E.toolName}`,toolCallId:E.toolCallId,state:E.state,title:E.title,input:S.input,output:S.output,rawInput:S.rawInput,errorText:S.errorText,providerExecuted:S.providerExecuted,preliminary:S.preliminary,...S.providerMetadata!=null?{callProviderMetadata:S.providerMetadata}:{}})}function T(E){var R,O;const S=l.message.parts.find(z=>z.type==="dynamic-tool"&&z.toolCallId===E.toolCallId),v=E,B=S;S!=null?(S.state=E.state,B.toolName=E.toolName,B.input=v.input,B.output=v.output,B.errorText=v.errorText,B.rawInput=(R=v.rawInput)!=null?R:B.rawInput,B.preliminary=v.preliminary,E.title!==void 0&&(B.title=E.title),B.providerExecuted=(O=v.providerExecuted)!=null?O:S.providerExecuted,v.providerMetadata!=null&&S.state==="input-available"&&(S.callProviderMetadata=v.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:E.toolName,toolCallId:E.toolCallId,state:E.state,input:v.input,output:v.output,errorText:v.errorText,preliminary:v.preliminary,providerExecuted:v.providerExecuted,title:E.title,...v.providerMetadata!=null?{callProviderMetadata:v.providerMetadata}:{}})}async function I(E){if(E!=null){const R=l.message.metadata!=null?ao(l.message.metadata,E):E;e!=null&&await Qa({value:R,schema:e}),l.message.metadata=R}}switch(u.type){case"text-start":{const E={type:"text",text:"",providerMetadata:u.providerMetadata,state:"streaming"};l.activeTextParts[u.id]=E,l.message.parts.push(E),d();break}case"text-delta":{const E=l.activeTextParts[u.id];E.text+=u.delta,E.providerMetadata=(f=u.providerMetadata)!=null?f:E.providerMetadata,d();break}case"text-end":{const E=l.activeTextParts[u.id];E.state="done",E.providerMetadata=(p=u.providerMetadata)!=null?p:E.providerMetadata,delete l.activeTextParts[u.id],d();break}case"reasoning-start":{const E={type:"reasoning",text:"",providerMetadata:u.providerMetadata,state:"streaming"};l.activeReasoningParts[u.id]=E,l.message.parts.push(E),d();break}case"reasoning-delta":{const E=l.activeReasoningParts[u.id];E.text+=u.delta,E.providerMetadata=(h=u.providerMetadata)!=null?h:E.providerMetadata,d();break}case"reasoning-end":{const E=l.activeReasoningParts[u.id];E.providerMetadata=(g=u.providerMetadata)!=null?g:E.providerMetadata,E.state="done",delete l.activeReasoningParts[u.id],d();break}case"file":{l.message.parts.push({type:"file",mediaType:u.mediaType,url:u.url}),d();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:u.sourceId,url:u.url,title:u.title,providerMetadata:u.providerMetadata}),d();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:u.sourceId,mediaType:u.mediaType,title:u.title,filename:u.filename,providerMetadata:u.providerMetadata}),d();break}case"tool-input-start":{const E=l.message.parts.filter(_i);l.partialToolCalls[u.toolCallId]={text:"",toolName:u.toolName,index:E.length,dynamic:u.dynamic,title:u.title},u.dynamic?T({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}):y({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}),d();break}case"tool-input-delta":{const E=l.partialToolCalls[u.toolCallId];E.text+=u.inputTextDelta;const{value:R}=await Jn(E.text);E.dynamic?T({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:R,title:E.title}):y({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:R,title:E.title}),d();break}case"tool-input-available":{u.dynamic?T({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}):y({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}),d(),a&&!u.providerExecuted&&await a({toolCall:u});break}case"tool-input-error":{u.dynamic?T({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}):y({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:void 0,rawInput:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}),d();break}case"tool-approval-request":{const E=_(u.toolCallId);E.state="approval-requested",E.approval={id:u.approvalId},d();break}case"tool-output-denied":{const E=_(u.toolCallId);E.state="output-denied",d();break}case"tool-output-available":{const E=_(u.toolCallId);E.type==="dynamic-tool"?T({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-available",input:E.input,output:u.output,preliminary:u.preliminary,providerExecuted:u.providerExecuted,title:E.title}):y({toolCallId:u.toolCallId,toolName:Xa(E),state:"output-available",input:E.input,output:u.output,providerExecuted:u.providerExecuted,preliminary:u.preliminary,title:E.title}),d();break}case"tool-output-error":{const E=_(u.toolCallId);E.type==="dynamic-tool"?T({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-error",input:E.input,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}):y({toolCallId:u.toolCallId,toolName:Xa(E),state:"output-error",input:E.input,rawInput:E.rawInput,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}),d();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{u.messageId!=null&&(l.message.id=u.messageId),await I(u.messageMetadata),(u.messageId!=null||u.messageMetadata!=null)&&d();break}case"finish":{u.finishReason!=null&&(l.finishReason=u.finishReason),await I(u.messageMetadata),u.messageMetadata!=null&&d();break}case"message-metadata":{await I(u.messageMetadata),u.messageMetadata!=null&&d();break}case"error":{i?.(new Error(u.errorText));break}default:if(Vf(u)){n?.[u.type]!=null&&await Qa({value:u.data,schema:n[u.type]});const E=u;if(E.transient){s?.(E);break}const R=E.id!=null?l.message.parts.find(O=>E.type===O.type&&E.id===O.id):void 0;R!=null?R.data=E.data:l.message.parts.push(E),s?.(E),d()}}o.enqueue(u)})}}))}async function Xf({stream:t,onError:e}){const n=t.getReader();try{for(;;){const{done:r}=await n.read();if(r)break}}catch(r){e?.(r)}finally{n.releaseLock()}}Kn({prefix:"aitxt",size:24});Kn({prefix:"aiobj",size:24});var Zf=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,n)=>{this.queue.push(async()=>{try{await t(),e()}catch(r){n(r)}}),this.processQueue()})}};Kn({prefix:"aiobj",size:24});async function Kf(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:n,type:r}=e,i=await new Promise((a,s)=>{const u=new FileReader;u.onload=o=>{var l;a((l=o.target)==null?void 0:l.result)},u.onerror=o=>s(o),u.readAsDataURL(e)});return{type:"file",mediaType:r,filename:n,url:i}}))}var Jf=class{constructor({api:t="/api/chat",credentials:e,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:s}){this.api=t,this.credentials=e,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=s}async sendMessages({abortSignal:t,...e}){var n,r,i,a,s;const u=await wt(this.body),o=await wt(this.headers),l=await wt(this.credentials),d={...Ht(o),...Ht(e.headers)},f=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...u,...e.body},headers:d,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),p=(r=f?.api)!=null?r:this.api,h=f?.headers!==void 0?Ht(f.headers):d,g=f?.body!==void 0?f.body:{...u,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},_=(i=f?.credentials)!=null?i:l,T=await((a=this.fetch)!=null?a:globalThis.fetch)(p,{method:"POST",headers:Ya({"Content-Type":"application/json",...h},`ai-sdk/${Ga}`,$a()),body:JSON.stringify(g),credentials:_,signal:t});if(!T.ok)throw new Error((s=await T.text())!=null?s:"Failed to fetch the chat response.");if(!T.body)throw new Error("The response body is empty.");return this.processResponseStream(T.body)}async reconnectToStream(t){var e,n,r,i,a;const s=await wt(this.body),u=await wt(this.headers),o=await wt(this.credentials),l={...Ht(u),...Ht(t.headers)},d=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...s,...t.body},headers:l,credentials:o,requestMetadata:t.metadata})),f=(n=d?.api)!=null?n:`${this.api}/${t.chatId}/stream`,p=d?.headers!==void 0?Ht(d.headers):l,h=(r=d?.credentials)!=null?r:o,_=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"GET",headers:Ya(p,`ai-sdk/${Ga}`,$a()),credentials:h});if(_.status===204)return null;if(!_.ok)throw new Error((a=await _.text())!=null?a:"Failed to fetch the chat response.");if(!_.body)throw new Error("The response body is empty.");return this.processResponseStream(_.body)}},so=class extends Jf{constructor(t={}){super(t)}processResponseStream(t){return kf({stream:t,schema:qf}).pipeThrough(new TransformStream({async transform(e,n){if(!e.success)throw e.error;n.enqueue(e.value)}}))}},eh=class{constructor({generateId:t=Id,id:e=t(),transport:n=new so,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:s,onToolCall:u,onFinish:o,onData:l,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new Zf,this.sendMessage=async(f,p)=>{var h,g,_,y;if(f==null){await this.makeRequest({trigger:"submit-message",messageId:(h=this.lastMessage)==null?void 0:h.id,...p});return}let T;if("text"in f||"files"in f?T={parts:[...Array.isArray(f.files)?f.files:await Kf(f.files),..."text"in f&&f.text!=null?[{type:"text",text:f.text}]:[]]}:T=f,f.messageId!=null){const I=this.state.messages.findIndex(E=>E.id===f.messageId);if(I===-1)throw new Error(`message with id ${f.messageId} not found`);if(this.state.messages[I].role!=="user")throw new Error(`message with id ${f.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,I+1),this.state.replaceMessage(I,{...T,id:f.messageId,role:(g=T.role)!=null?g:"user",metadata:f.metadata})}else this.state.pushMessage({...T,id:(_=T.id)!=null?_:this.generateId(),role:(y=T.role)!=null?y:"user",metadata:f.metadata});await this.makeRequest({trigger:"submit-message",messageId:f.messageId,...p})},this.regenerate=async({messageId:f,...p}={})=>{const h=f==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===f);if(h===-1)throw new Error(`message ${f} not found`);this.state.messages=this.state.messages.slice(0,this.messages[h].role==="assistant"?h:h+1),await this.makeRequest({trigger:"regenerate-message",messageId:f,...p})},this.resumeStream=async(f={})=>{await this.makeRequest({trigger:"resume-stream",...f})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:f,approved:p,reason:h})=>this.jobExecutor.run(async()=>{var g,_;const y=this.state.messages,T=y[y.length-1],I=E=>yi(E)&&E.state==="approval-requested"&&E.approval.id===f?{...E,state:"approval-responded",approval:{id:f,approved:p,reason:h}}:E;this.state.replaceMessage(y.length-1,{...T,parts:T.parts.map(I)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(I)),this.status!=="streaming"&&this.status!=="submitted"&&((g=this.sendAutomaticallyWhen)!=null&&g.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(_=this.lastMessage)==null?void 0:_.id})}),this.addToolOutput=async({state:f="output-available",tool:p,toolCallId:h,output:g,errorText:_})=>this.jobExecutor.run(async()=>{var y,T;const I=this.state.messages,E=I[I.length-1],R=O=>yi(O)&&O.toolCallId===h?{...O,state:f,output:g,errorText:_}:O;this.state.replaceMessage(I.length-1,{...E,parts:E.parts.map(R)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(R)),this.status!=="streaming"&&this.status!=="submitted"&&((y=this.sendAutomaticallyWhen)!=null&&y.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(T=this.lastMessage)==null?void 0:T.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var f;this.status!=="streaming"&&this.status!=="submitted"||(f=this.activeResponse)!=null&&f.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=n,this.generateId=t,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=s,this.onToolCall=u,this.onFinish=o,this.onData=l,this.sendAutomaticallyWhen=d}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 makeRequest({trigger:t,metadata:e,headers:n,body:r,messageId:i}){var a,s,u,o;this.setStatus({status:"submitted",error:void 0});const l=this.lastMessage;let d=!1,f=!1,p=!1;try{const h={state:Qf({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};h.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=h;let g;if(t==="resume-stream"){const y=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:n,body:r});if(y==null){this.setStatus({status:"ready"});return}g=y}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:h.abortController.signal,metadata:e,headers:n,body:r,trigger:t,messageId:i});const _=y=>this.jobExecutor.run(()=>y({state:h.state,write:()=>{var T;this.setStatus({status:"streaming"}),h.state.message.id===((T=this.lastMessage)==null?void 0:T.id)?this.state.replaceMessage(this.state.messages.length-1,h.state.message):this.state.pushMessage(h.state.message)}}));await Xf({stream:Gf({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:_,onError:y=>{throw y}}),onError:y=>{throw y}}),this.setStatus({status:"ready"})}catch(h){if(d||h.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;p=!0,h instanceof TypeError&&(h.message.toLowerCase().includes("fetch")||h.message.toLowerCase().includes("network"))&&(f=!0),this.onError&&h instanceof Error&&this.onError(h),this.setStatus({status:"error",error:h})}finally{try{(s=this.onFinish)==null||s.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:f,isError:p,finishReason:(a=this.activeResponse)==null?void 0:a.state.finishReason})}catch(h){console.error(h)}this.activeResponse=void 0}(u=this.sendAutomaticallyWhen)!=null&&u.call(this,{messages:this.state.messages})&&!p&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:e,headers:n,body:r})}},Zr,Za;function th(){if(Za)return Zr;Za=1;function t(e,n){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,i=0;return function(...s){clearTimeout(r);const u=Date.now(),o=u-i,l=n-o;l<=0?(i=u,e.apply(this,s)):r=setTimeout(()=>{i=Date.now(),e.apply(this,s)},l)}}return Zr=t,Zr}var nh=th();const rh=Vi(nh);var uo=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},Ae=(t,e,n)=>(uo(t,e,"read from private field"),n?n.call(t):e.get(t)),lt=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},It=(t,e,n,r)=>(uo(t,e,"write to private field"),e.set(t,n),n);function ih(t,e){return e!=null?rh(t,e):t}var et,pr,mr,wn,Rn,On,en,Ai,ki,ah=class{constructor(t=[]){lt(this,et,void 0),lt(this,pr,"ready"),lt(this,mr,void 0),lt(this,wn,new Set),lt(this,Rn,new Set),lt(this,On,new Set),this.pushMessage=e=>{It(this,et,Ae(this,et).concat(e)),Ae(this,en).call(this)},this.popMessage=()=>{It(this,et,Ae(this,et).slice(0,-1)),Ae(this,en).call(this)},this.replaceMessage=(e,n)=>{It(this,et,[...Ae(this,et).slice(0,e),this.snapshot(n),...Ae(this,et).slice(e+1)]),Ae(this,en).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,n)=>{const r=n?ih(e,n):e;return Ae(this,wn).add(r),()=>{Ae(this,wn).delete(r)}},this["~registerStatusCallback"]=e=>(Ae(this,Rn).add(e),()=>{Ae(this,Rn).delete(e)}),this["~registerErrorCallback"]=e=>(Ae(this,On).add(e),()=>{Ae(this,On).delete(e)}),lt(this,en,()=>{Ae(this,wn).forEach(e=>e())}),lt(this,Ai,()=>{Ae(this,Rn).forEach(e=>e())}),lt(this,ki,()=>{Ae(this,On).forEach(e=>e())}),It(this,et,t)}get status(){return Ae(this,pr)}set status(t){It(this,pr,t),Ae(this,Ai).call(this)}get error(){return Ae(this,mr)}set error(t){It(this,mr,t),Ae(this,ki).call(this)}get messages(){return Ae(this,et)}set messages(t){It(this,et,[...t]),Ae(this,en).call(this)}};et=new WeakMap;pr=new WeakMap;mr=new WeakMap;wn=new WeakMap;Rn=new WeakMap;On=new WeakMap;en=new WeakMap;Ai=new WeakMap;ki=new WeakMap;var tn,Ka=class extends eh{constructor({messages:e,...n}){const r=new ah(e);super({...n,state:r}),lt(this,tn,void 0),this["~registerMessagesCallback"]=(i,a)=>Ae(this,tn)["~registerMessagesCallback"](i,a),this["~registerStatusCallback"]=i=>Ae(this,tn)["~registerStatusCallback"](i),this["~registerErrorCallback"]=i=>Ae(this,tn)["~registerErrorCallback"](i),It(this,tn,r)}};tn=new WeakMap;function sh({experimental_throttle:t,resume:e=!1,...n}={}){const r=V.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(r.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:p=>{var h,g;return(g=(h=r.current).onToolCall)==null?void 0:g.call(h,p)},onData:p=>{var h,g;return(g=(h=r.current).onData)==null?void 0:g.call(h,p)},onFinish:p=>{var h,g;return(g=(h=r.current).onFinish)==null?void 0:g.call(h,p)},onError:p=>{var h,g;return(g=(h=r.current).onError)==null?void 0:g.call(h,p)},sendAutomaticallyWhen:p=>{var h,g,_;return(_=(g=(h=r.current).sendAutomaticallyWhen)==null?void 0:g.call(h,p))!=null?_:!1}},a=V.useRef("chat"in n?n.chat:new Ka(i));("chat"in n&&n.chat!==a.current||"id"in n&&a.current.id!==n.id)&&(a.current="chat"in n?n.chat:new Ka(i));const u=V.useCallback(p=>a.current["~registerMessagesCallback"](p,t),[t,a.current.id]),o=V.useSyncExternalStore(u,()=>a.current.messages,()=>a.current.messages),l=V.useSyncExternalStore(a.current["~registerStatusCallback"],()=>a.current.status,()=>a.current.status),d=V.useSyncExternalStore(a.current["~registerErrorCallback"],()=>a.current.error,()=>a.current.error),f=V.useCallback(p=>{typeof p=="function"&&(p=p(a.current.messages)),a.current.messages=p},[a]);return V.useEffect(()=>{e&&a.current.resumeStream()},[e,a]),{id:a.current.id,messages:o,setMessages:f,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:d,resumeStream:a.current.resumeStream,status:l,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}const uh="You are a helpful assistant.",oh=t=>new so({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:n})=>({body:{messages:e,stream:!0,...n}})});function f_(t){const e=W.c(37),{threadId:n,systemPrompt:r,onCreateThread:i,onError:a,onToolCall:s}=t,{org:u,locator:o}=Dt(),{slug:l}=u,d=Xi(),f=Mu(),[p,h]=V.useState(null),g=xd(n),_=r||uh;let y;e[0]!==_?(y={id:"system",role:"system",parts:[{type:"text",text:_}]},e[0]=_,e[1]=y):y=e[1];const I=y;let E;e[2]!==g||e[3]!==I?(E=[I,...g],e[2]=g,e[3]=I,e[4]=E):E=e[4];const R=E,O=`${n}:${_}`;let S;e[5]!==l?(S=oh(l),e[5]=l,e[6]=S):S=e[6];const v=S;let B;e[7]!==o||e[8]!==f||e[9]!==i||e[10]!==d||e[11]!==n?(B=async ae=>{const{finishReason:xe,messages:C,isAbort:ke,isDisconnect:Ie,isError:me}=ae;if(h(xe??null),xe!=="stop"||ke||Ie||me)return;const Ne=C.slice(-2).filter(Boolean);if(Ne.length!==2){console.warn("[chat] Expected 2 messages, got",Ne.length);return}f.insertMany.mutate(Ne);const _e=Ne.find(ch)?.parts?.find(lh)?.text.slice(0,100)||"";if(!await bd(o,n)){if(i)i({id:n,title:_e});else{const Se=new Date().toISOString(),Oe={id:n,title:_e,created_at:Se,updated_at:Se,hidden:!1};d.insert.mutate(Oe)}return}d.update.mutate({id:n,updates:{updated_at:new Date().toISOString()}})},e[7]=o,e[8]=f,e[9]=i,e[10]=d,e[11]=n,e[12]=B):B=e[12];const z=B;let N;e[13]!==a?(N=ae=>{console.error("[chat] Chat error:",ae),a?.(ae)},e[13]=a,e[14]=N):N=e[14];let F;e[15]!==R||e[16]!==O||e[17]!==z||e[18]!==s||e[19]!==N||e[20]!==v?(F={id:O,messages:R,transport:v,onFinish:z,onToolCall:s,onError:N},e[15]=R,e[16]=O,e[17]=z,e[18]=s,e[19]=N,e[20]=v,e[21]=F):F=e[21];const P=sh(F);let X;e[22]!==P?(X=async(ae,xe)=>{!ae?.trim()||P.status==="submitted"||P.status==="streaming"||(h(null),await P.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:ae}],metadata:xe},{metadata:xe}))},e[22]=P,e[23]=X):X=e[23];const q=X,j=P.messages[0]?.role==="system"?P.messages.length===1:P.messages.length===0,Z=P.messages,te=P.status;let K;e[24]!==P?(K=P.stop.bind(P),e[24]=P,e[25]=K):K=e[25];let ce;e[26]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>h(null),e[26]=ce):ce=e[26];let k;return e[27]!==P.clearError||e[28]!==P.error||e[29]!==P.messages||e[30]!==P.setMessages||e[31]!==P.status||e[32]!==p||e[33]!==j||e[34]!==q||e[35]!==K?(k={messages:Z,status:te,sendMessage:q,stop:K,setMessages:P.setMessages,isEmpty:j,error:P.error,clearError:P.clearError,finishReason:p,clearFinishReason:ce},e[27]=P.clearError,e[28]=P.error,e[29]=P.messages,e[30]=P.setMessages,e[31]=P.status,e[32]=p,e[33]=j,e[34]=q,e[35]=K,e[36]=k):k=e[36],k}function lh(t){return t.type==="text"}function ch(t){return t.parts?.find(dh)}function dh(t){return t.type==="text"}const oo={inputValue:"",branchContext:null,pendingSubmit:!1};function fh(t,e){switch(e.type){case"SET_INPUT":return{...t,inputValue:e.payload};case"START_BRANCH":return{...t,branchContext:e.payload};case"CLEAR_BRANCH":return{...t,branchContext:null};case"SET_PENDING_SUBMIT":return{...t,pendingSubmit:e.payload};case"RESET":return oo;default:return t}}const lo=V.createContext(null),co=()=>crypto.randomUUID();function hh(t){const e=W.c(16),{children:n}=t,{locator:r}=Dt(),[i,a]=V.useReducer(fh,oo),s=Xi(),[u,o]=Vc(Wc.threadManagerState(r)+":active-id",ph);let l;e[0]!==o||e[1]!==s?(l=y=>{const T=y?.id||crypto.randomUUID(),I=new Date().toISOString(),E={id:T,title:y?.title||"",created_at:y?.created_at||I,updated_at:y?.updated_at||I,hidden:y?.hidden??!1,gatewayId:y?.gatewayId};return s.insert.mutate(E),o(T),E},e[0]=o,e[1]=s,e[2]=l):l=e[2];const d=l;let f;e[3]!==u||e[4]!==o||e[5]!==s?(f=y=>{s.update.mutate({id:y,updates:{hidden:!0,updated_at:new Date().toISOString()}}),u===y&&o(co())},e[3]=u,e[4]=o,e[5]=s,e[6]=f):f=e[6];const p=f;let h;e[7]!==u||e[8]!==d||e[9]!==p||e[10]!==i||e[11]!==o?(h={interactionState:i,interactionDispatch:a,activeThreadId:u,createThread:d,setActiveThreadId:o,hideThread:p},e[7]=u,e[8]=d,e[9]=p,e[10]=i,e[11]=o,e[12]=h):h=e[12];const g=h;let _;return e[13]!==n||e[14]!==g?(_=m.jsx(lo.Provider,{value:g,children:n}),e[13]=n,e[14]=g,e[15]=_):_=e[15],_}function ph(t){return t||co()}function mh(){const t=W.c(19),e=V.useContext(lo);if(!e)throw new Error("useChat must be used within a ChatProvider");const{interactionState:n,interactionDispatch:r}=e;let i,a,s,u,o;t[0]!==r?(i=d=>r({type:"SET_INPUT",payload:d}),a=d=>r({type:"START_BRANCH",payload:d}),s=()=>r({type:"CLEAR_BRANCH"}),u=d=>r({type:"SET_PENDING_SUBMIT",payload:d}),o=()=>r({type:"RESET"}),t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=u,t[5]=o):(i=t[1],a=t[2],s=t[3],u=t[4],o=t[5]);let l;return t[6]!==e.activeThreadId||t[7]!==e.createThread||t[8]!==e.hideThread||t[9]!==e.setActiveThreadId||t[10]!==n.branchContext||t[11]!==n.inputValue||t[12]!==n.pendingSubmit||t[13]!==i||t[14]!==a||t[15]!==s||t[16]!==u||t[17]!==o?(l={inputValue:n.inputValue,branchContext:n.branchContext,pendingSubmit:n.pendingSubmit,setInputValue:i,startBranch:a,clearBranch:s,setPendingSubmit:u,reset:o,activeThreadId:e.activeThreadId,createThread:e.createThread,setActiveThreadId:e.setActiveThreadId,hideThread:e.hideThread},t[6]=e.activeThreadId,t[7]=e.createThread,t[8]=e.hideThread,t[9]=e.setActiveThreadId,t[10]=n.branchContext,t[11]=n.inputValue,t[12]=n.pendingSubmit,t[13]=i,t[14]=a,t[15]=s,t[16]=u,t[17]=o,t[18]=l):l=t[18],l}const Ja=3;function gh(t){const e=W.c(14),{prompt:n,onSelect:r}=t,i=n.description??n.name;let a;e[0]!==r||e[1]!==n?(a=()=>r(n),e[0]=r,e[1]=n,e[2]=a):a=e[2];const s=n.title??n.name;let u;if(e[3]!==s){let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=/_/g,e[5]=f):f=e[5],u=s.replace(f," "),e[3]=s,e[4]=u}else u=e[4];let o;e[6]!==a||e[7]!==u?(o=m.jsx(fn,{asChild:!0,children:m.jsx("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:u})}),e[6]=a,e[7]=u,e[8]=o):o=e[8];let l;e[9]!==i?(l=m.jsx(hn,{side:"bottom",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:i})}),e[9]=i,e[10]=l):l=e[10];let d;return e[11]!==o||e[12]!==l?(d=m.jsxs(dn,{children:[o,l]}),e[11]=o,e[12]=l,e[13]=d):d=e[13],d}function Eh(t){const e=W.c(20),{prompts:n,onSelect:r,className:i}=t;if(n.length===0)return null;let a,s,u,o,l;if(e[0]!==i||e[1]!==r||e[2]!==n){const p=n.slice(0,Ja),h=n.slice(Ja),g=h.length>0;a=bu,l=300,e[8]!==i?(s=le("flex flex-wrap items-center justify-center gap-2",i),e[8]=i,e[9]=s):s=e[9];let _;e[10]!==r?(_=y=>m.jsx(gh,{prompt:y,onSelect:r},y.name),e[10]=r,e[11]=_):_=e[11],u=p.map(_),o=g&&m.jsxs(Tu,{children:[m.jsx(xu,{asChild:!0,children:m.jsxs("button",{type:"button",className:"size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:["+",h.length]})}),m.jsx(_u,{side:"bottom",align:"center",className:"w-auto p-2",children:m.jsx("div",{className:"flex flex-col gap-1",children:h.map(y=>{const T=y.description??y.name;return m.jsxs(dn,{children:[m.jsx(fn,{asChild:!0,children:m.jsx("button",{type:"button",onClick:()=>r(y),className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left",children:(y.title??y.name).replace(/_/g," ")})}),m.jsx(hn,{side:"right",className:"max-w-xs",children:m.jsx("p",{className:"text-xs",children:T})})]},y.name)})})})]}),e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=s,e[5]=u,e[6]=o,e[7]=l}else a=e[3],s=e[4],u=e[5],o=e[6],l=e[7];let d;e[12]!==s||e[13]!==u||e[14]!==o?(d=m.jsxs("div",{className:s,children:[u,o]}),e[12]=s,e[13]=u,e[14]=o,e[15]=d):d=e[15];let f;return e[16]!==a||e[17]!==l||e[18]!==d?(f=m.jsx(a,{delayDuration:l,children:d}),e[16]=a,e[17]=l,e[18]=d,e[19]=f):f=e[19],f}async function bh(t){const e=`/mcp/gateway/${t}`,n={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const r=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mesh-chat",version:"1.0.0"}}})});if(!r.ok)return[];if((await r.json()).error)return[];const a=await fetch(e,{method:"POST",headers:n,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!a.ok)return[];const s=await a.json();return s.error?[]:s.result?.prompts||[]}catch{return[]}}function Th(t){const e=W.c(7);let n;e[0]!==t?(n=Me.gatewayPrompts(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t?(r=()=>bh(t),e[2]=t,e[3]=r):r=e[3];let i;return e[4]!==n||e[5]!==r?(i={queryKey:n,queryFn:r,staleTime:6e4,retry:!1},e[4]=n,e[5]=r,e[6]=i):i=e[6],qi(i)}function h_(t){const e=W.c(4),{gatewayId:n,onSelect:r,className:i}=t,a=i===void 0?"mt-6":i,{data:s}=Th(n);if(s.length===0)return null;let u;return e[0]!==a||e[1]!==r||e[2]!==s?(u=m.jsx(Eh,{prompts:s,onSelect:r,className:a}),e[0]=a,e[1]=r,e[2]=s,e[3]=u):u=e[3],u}function xh(t){const e=W.c(66),{value:n,onChange:r,onSubmit:i,onStop:a,disabled:s,isStreaming:u,placeholder:o,className:l,centered:d,contextContent:f,leftActions:p,rightActions:h,maxTextHeight:g,children:_}=t,y=o===void 0?"Ask anything or @ for context":o,T=g===void 0?"164px":g;let I;e[0]!==s||e[1]!==u||e[2]!==n?(I=!s&&!u&&n.trim().length>0,e[0]=s,e[1]=u,e[2]=n,e[3]=I):I=e[3];const E=I;let R;e[4]!==E||e[5]!==u||e[6]!==a||e[7]!==i?(R=De=>{De.preventDefault(),u&&a?a():E&&i()},e[4]=E,e[5]=u,e[6]=a,e[7]=i,e[8]=R):R=e[8];const O=R;let S;e[9]!==E||e[10]!==i?(S=De=>{De.key==="Enter"&&!De.shiftKey&&(De.preventDefault(),E&&i())},e[9]=E,e[10]=i,e[11]=S):S=e[11];const v=S;let B;e[12]!==l?(B=le("w-full",l),e[12]=l,e[13]=B):B=e[13];let z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=le("relative rounded-xl border border-border bg-background w-full min-h-[130px] flex flex-col"),e[14]=z):z=e[14];let N;e[15]!==f?(N=f&&m.jsx("div",{className:"mb-1",children:f}),e[15]=f,e[16]=N):N=e[16];let F;e[17]!==T?(F={maxHeight:T},e[17]=T,e[18]=F):F=e[18];let P;e[19]!==r?(P=De=>r(De.target.value),e[19]=r,e[20]=P):P=e[20];const X=s||u;let q;e[21]===Symbol.for("react.memo_cache_sentinel")?(q=le("placeholder:text-muted-foreground resize-none focus-visible:ring-0 border-0 p-2 text-sm min-h-[20px] w-full","rounded-none shadow-none"),e[21]=q):q=e[21];let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j={minHeight:"20px",height:"auto",overflow:"hidden"},e[22]=j):j=e[22];let Z;e[23]!==v||e[24]!==y||e[25]!==P||e[26]!==X||e[27]!==n?(Z=m.jsx(qc,{value:n,onChange:P,onKeyDown:v,placeholder:y,disabled:X,className:q,rows:1,style:j}),e[23]=v,e[24]=y,e[25]=P,e[26]=X,e[27]=n,e[28]=Z):Z=e[28];let te;e[29]!==F||e[30]!==Z?(te=m.jsx("div",{className:"overflow-y-auto relative flex-1",style:F,children:Z}),e[29]=F,e[30]=Z,e[31]=te):te=e[31];let K;e[32]!==te||e[33]!==N?(K=m.jsxs("div",{className:"relative flex flex-col gap-2 p-2.5 flex-1",children:[N,te]}),e[32]=te,e[33]=N,e[34]=K):K=e[34];let ce;e[35]!==_||e[36]!==p?(ce=m.jsxs("div",{className:"flex items-center overflow-hidden gap-2 min-w-0",children:[p,_]}),e[35]=_,e[36]=p,e[37]=ce):ce=e[37];const k=u?"button":"submit";let ae;e[38]!==u||e[39]!==a?(ae=De=>{u&&(De.preventDefault(),De.stopPropagation(),a?.())},e[38]=u,e[39]=a,e[40]=ae):ae=e[40];const xe=E||u?"default":"ghost",C=!E&&!u,ke=!E&&!u&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let Ie;e[41]!==ke?(Ie=le("size-8 rounded-full transition-all",ke),e[41]=ke,e[42]=Ie):Ie=e[42];const me=u?"Stop generating":"Send message (Enter)";let Ne;e[43]!==u?(Ne=u?m.jsx(Hc,{size:20}):m.jsx(Fc,{size:20}),e[43]=u,e[44]=Ne):Ne=e[44];let _e;e[45]!==k||e[46]!==ae||e[47]!==xe||e[48]!==C||e[49]!==Ie||e[50]!==me||e[51]!==Ne?(_e=m.jsx(We,{type:k,onClick:ae,variant:xe,size:"icon",disabled:C,className:Ie,title:me,children:Ne}),e[45]=k,e[46]=ae,e[47]=xe,e[48]=C,e[49]=Ie,e[50]=me,e[51]=Ne,e[52]=_e):_e=e[52];let we;e[53]!==h||e[54]!==_e?(we=m.jsxs("div",{className:"flex items-center gap-1",children:[h,_e]}),e[53]=h,e[54]=_e,e[55]=we):we=e[55];let Se;e[56]!==ce||e[57]!==we?(Se=m.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[ce,we]}),e[56]=ce,e[57]=we,e[58]=Se):Se=e[58];let Oe;e[59]!==K||e[60]!==Se?(Oe=m.jsxs("div",{className:z,children:[K,Se]}),e[59]=K,e[60]=Se,e[61]=Oe):Oe=e[61];let ot;return e[62]!==O||e[63]!==Oe||e[64]!==B?(ot=m.jsx("form",{onSubmit:O,className:B,children:Oe}),e[62]=O,e[63]=Oe,e[64]=B,e[65]=ot):ot=e[65],ot}function _h(){const t=W.c(3),[e,n]=V.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async s=>{await navigator.clipboard.writeText(s),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let a;return t[1]!==e?(a={handleCopy:i,copied:e},t[1]=e,t[2]=a):a=t[2],a}function Ki(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Qt=Ki();function fo(t){Qt=t}var vn={exec:()=>null};function de(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace($e.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var $e={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},yh=/^(?:[ \t]*(?:\n|$))+/,Ah=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kh=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,er=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ch=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ji=/(?:[*+-]|\d{1,9}[.)])/,ho=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,po=de(ho).replace(/bull/g,Ji).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ih=de(ho).replace(/bull/g,Ji).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ea=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Sh=/^[^\n]+/,ta=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Nh=de(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ta).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wh=de(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ji).getRegex(),vr="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",na=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Rh=de("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",na).replace("tag",vr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),mo=de(ea).replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vr).getRegex(),Oh=de(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",mo).getRegex(),ra={blockquote:Oh,code:Ah,def:Nh,fences:kh,heading:Ch,hr:er,html:Rh,lheading:po,list:wh,newline:yh,paragraph:mo,table:vn,text:Sh},es=de("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vr).getRegex(),Lh={...ra,lheading:Ih,table:es,paragraph:de(ea).replace("hr",er).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",es).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vr).getRegex()},Dh={...ra,html:de(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",na).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:vn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:de(ea).replace("hr",er).replace("heading",` *#{1,6} *[^
13
13
  ]`).replace("lheading",po).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},vh=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ph=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,go=/^( {2,}|\\)\n(?!\s*$)/,Mh=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Pr=/[\p{P}\p{S}]/u,ia=/[\s\p{P}\p{S}]/u,Eo=/[^\s\p{P}\p{S}]/u,Bh=de(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ia).getRegex(),bo=/(?!~)[\p{P}\p{S}]/u,Fh=/(?!~)[\s\p{P}\p{S}]/u,Uh=/(?:[^\s\p{P}\p{S}]|~)/u,Hh=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,To=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,jh=de(To,"u").replace(/punct/g,Pr).getRegex(),zh=de(To,"u").replace(/punct/g,bo).getRegex(),xo="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",$h=de(xo,"gu").replace(/notPunctSpace/g,Eo).replace(/punctSpace/g,ia).replace(/punct/g,Pr).getRegex(),Yh=de(xo,"gu").replace(/notPunctSpace/g,Uh).replace(/punctSpace/g,Fh).replace(/punct/g,bo).getRegex(),qh=de("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Eo).replace(/punctSpace/g,ia).replace(/punct/g,Pr).getRegex(),Vh=de(/\\(punct)/,"gu").replace(/punct/g,Pr).getRegex(),Wh=de(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Qh=de(na).replace("(?:-->|$)","-->").getRegex(),Gh=de("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Qh).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Xh=de(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",yr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_o=de(/^!?\[(label)\]\[(ref)\]/).replace("label",yr).replace("ref",ta).getRegex(),yo=de(/^!?\[(ref)\](?:\[\])?/).replace("ref",ta).getRegex(),Zh=de("reflink|nolink(?!\\()","g").replace("reflink",_o).replace("nolink",yo).getRegex(),aa={_backpedal:vn,anyPunctuation:Vh,autolink:Wh,blockSkip:Hh,br:go,code:Ph,del:vn,emStrongLDelim:jh,emStrongRDelimAst:$h,emStrongRDelimUnd:qh,escape:vh,link:Xh,nolink:yo,punctuation:Bh,reflink:_o,reflinkSearch:Zh,tag:Gh,text:Mh,url:vn},Kh={...aa,link:de(/^!?\[(label)\]\((.*?)\)/).replace("label",yr).getRegex(),reflink:de(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yr).getRegex()},Ci={...aa,emStrongRDelimAst:Yh,emStrongLDelim:zh,url:de(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Jh={...Ci,br:de(go).replace("{2,}","*").getRegex(),text:de(Ci.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},or={normal:ra,gfm:Lh,pedantic:Dh},_n={normal:aa,gfm:Ci,breaks:Jh,pedantic:Kh},e0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ts=t=>e0[t];function ct(t,e){if(e){if($e.escapeTest.test(t))return t.replace($e.escapeReplace,ts)}else if($e.escapeTestNoEncode.test(t))return t.replace($e.escapeReplaceNoEncode,ts);return t}function ns(t){try{t=encodeURI(t).replace($e.percentDecode,"%")}catch{return null}return t}function rs(t,e){const n=t.replace($e.findPipe,(a,s,u)=>{let o=!1,l=s;for(;--l>=0&&u[l]==="\\";)o=!o;return o?"|":" |"}),r=n.split($e.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace($e.slashPipe,"|");return r}function yn(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function t0(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function is(t,e,n,r,i){const a=e.href,s=e.title||null,u=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const o={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:s,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,o}function n0(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
14
14
  `).map(a=>{const s=a.match(n.other.beginningSpace);if(s===null)return a;const[u]=s;return u.length>=i.length?a.slice(i.length):a}).join(`
15
15
  `)}var Ar=class{options;rules;lexer;constructor(t){this.options=t||Qt}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:yn(n,`
@@ -93,6 +93,6 @@ Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An err
93
93
  `))+1))}const s="#".repeat(i),u=n.enter("headingAtx"),o=n.enter("phrasing");a.move(s+" ");let l=n.containerPhrasing(t,{before:"# ",after:`
94
94
  `,...a.current()});return/^[\t ]/.test(l)&&(l=Xn(l.charCodeAt(0))+l.slice(1)),l=l?s+" "+l:s,n.options.closeAtx&&(l+=" "+s),o(),u(),l}Vl.peek=kT;function Vl(t){return t.value||""}function kT(){return"<"}Wl.peek=CT;function Wl(t,e,n,r){const i=Ca(n),a=i==='"'?"Quote":"Apostrophe",s=n.enter("image");let u=n.enter("label");const o=n.createTracker(r);let l=o.move("![");return l+=o.move(n.safe(t.alt,{before:l,after:"]",...o.current()})),l+=o.move("]("),u(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(u=n.enter("destinationLiteral"),l+=o.move("<"),l+=o.move(n.safe(t.url,{before:l,after:">",...o.current()})),l+=o.move(">")):(u=n.enter("destinationRaw"),l+=o.move(n.safe(t.url,{before:l,after:t.title?" ":")",...o.current()}))),u(),t.title&&(u=n.enter(`title${a}`),l+=o.move(" "+i),l+=o.move(n.safe(t.title,{before:l,after:i,...o.current()})),l+=o.move(i),u()),l+=o.move(")"),s(),l}function CT(){return"!"}Ql.peek=IT;function Ql(t,e,n,r){const i=t.referenceType,a=n.enter("imageReference");let s=n.enter("label");const u=n.createTracker(r);let o=u.move("![");const l=n.safe(t.alt,{before:o,after:"]",...u.current()});o+=u.move(l+"]["),s();const d=n.stack;n.stack=[],s=n.enter("reference");const f=n.safe(n.associationId(t),{before:o,after:"]",...u.current()});return s(),n.stack=d,a(),i==="full"||!l||l!==f?o+=u.move(f+"]"):i==="shortcut"?o=o.slice(0,-1):o+=u.move("]"),o}function IT(){return"!"}Gl.peek=ST;function Gl(t,e,n){let r=t.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const s=n.unsafe[a],u=n.compilePattern(s);let o;if(s.atBreak)for(;o=u.exec(r);){let l=o.index;r.charCodeAt(l)===10&&r.charCodeAt(l-1)===13&&l--,r=r.slice(0,l)+" "+r.slice(o.index+1)}}return i+r+i}function ST(){return"`"}function Xl(t,e){const n=da(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Zl.peek=NT;function Zl(t,e,n,r){const i=Ca(n),a=i==='"'?"Quote":"Apostrophe",s=n.createTracker(r);let u,o;if(Xl(t,n)){const d=n.stack;n.stack=[],u=n.enter("autolink");let f=s.move("<");return f+=s.move(n.containerPhrasing(t,{before:f,after:">",...s.current()})),f+=s.move(">"),u(),n.stack=d,f}u=n.enter("link"),o=n.enter("label");let l=s.move("[");return l+=s.move(n.containerPhrasing(t,{before:l,after:"](",...s.current()})),l+=s.move("]("),o(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(o=n.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(n.safe(t.url,{before:l,after:">",...s.current()})),l+=s.move(">")):(o=n.enter("destinationRaw"),l+=s.move(n.safe(t.url,{before:l,after:t.title?" ":")",...s.current()}))),o(),t.title&&(o=n.enter(`title${a}`),l+=s.move(" "+i),l+=s.move(n.safe(t.title,{before:l,after:i,...s.current()})),l+=s.move(i),o()),l+=s.move(")"),u(),l}function NT(t,e,n){return Xl(t,n)?"<":"["}Kl.peek=wT;function Kl(t,e,n,r){const i=t.referenceType,a=n.enter("linkReference");let s=n.enter("label");const u=n.createTracker(r);let o=u.move("[");const l=n.containerPhrasing(t,{before:o,after:"]",...u.current()});o+=u.move(l+"]["),s();const d=n.stack;n.stack=[],s=n.enter("reference");const f=n.safe(n.associationId(t),{before:o,after:"]",...u.current()});return s(),n.stack=d,a(),i==="full"||!l||l!==f?o+=u.move(f+"]"):i==="shortcut"?o=o.slice(0,-1):o+=u.move("]"),o}function wT(){return"["}function Ia(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function RT(t){const e=Ia(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function OT(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Jl(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function LT(t,e,n,r){const i=n.enter("list"),a=n.bulletCurrent;let s=t.ordered?OT(n):Ia(n);const u=t.ordered?s==="."?")":".":RT(n);let o=e&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!t.ordered){const d=t.children?t.children[0]:void 0;if((s==="*"||s==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(o=!0),Jl(n)===s&&d){let f=-1;for(;++f<t.children.length;){const p=t.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){o=!0;break}}}}o&&(s=u),n.bulletCurrent=s;const l=n.containerFlow(t,r);return n.bulletLastUsed=s,n.bulletCurrent=a,i(),l}function DT(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function vT(t,e,n,r){const i=DT(n);let a=n.bulletCurrent||Ia(n);e&&e.type==="list"&&e.ordered&&(a=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+a);let s=a.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(s=Math.ceil(s/4)*4);const u=n.createTracker(r);u.move(a+" ".repeat(s-a.length)),u.shift(s);const o=n.enter("listItem"),l=n.indentLines(n.containerFlow(t,u.current()),d);return o(),l;function d(f,p,h){return p?(h?"":" ".repeat(s))+f:(h?a:a+" ".repeat(s-a.length))+f}}function PT(t,e,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),s=n.containerPhrasing(t,r);return a(),i(),s}const MT=jr(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function BT(t,e,n,r){return(t.children.some(function(s){return MT(s)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function FT(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}ec.peek=UT;function ec(t,e,n,r){const i=FT(n),a=n.enter("strong"),s=n.createTracker(r),u=s.move(i+i);let o=s.move(n.containerPhrasing(t,{after:i,before:u,...s.current()}));const l=o.charCodeAt(0),d=Rr(r.before.charCodeAt(r.before.length-1),l,i);d.inside&&(o=Xn(l)+o.slice(1));const f=o.charCodeAt(o.length-1),p=Rr(r.after.charCodeAt(0),f,i);p.inside&&(o=o.slice(0,-1)+Xn(f));const h=s.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},u+o+h}function UT(t,e,n){return n.options.strong||"*"}function HT(t,e,n,r){return n.safe(t.value,r)}function jT(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function zT(t,e,n){const r=(Jl(n)+(n.options.ruleSpaces?" ":"")).repeat(jT(n));return n.options.ruleSpaces?r.slice(0,-1):r}const tc={blockquote:dT,break:cu,code:ET,definition:TT,emphasis:ql,hardBreak:cu,heading:AT,html:Vl,image:Wl,imageReference:Ql,inlineCode:Gl,link:Zl,linkReference:Kl,list:LT,listItem:vT,paragraph:PT,root:BT,strong:ec,text:HT,thematicBreak:zT};function $T(){return{enter:{table:YT,tableData:du,tableHeader:du,tableRow:VT},exit:{codeText:WT,table:qT,tableData:gi,tableHeader:gi,tableRow:gi}}}function YT(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function qT(t){this.exit(t),this.data.inTable=void 0}function VT(t){this.enter({type:"tableRow",children:[]},t)}function gi(t){this.exit(t)}function du(t){this.enter({type:"tableCell",children:[]},t)}function WT(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,QT));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function QT(t,e){return e==="|"?e:t}function GT(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
95
95
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:s,tableCell:o,tableRow:u}};function s(h,g,_,y){return l(d(h,_,y),h.align)}function u(h,g,_,y){const T=f(h,_,y),I=l([T]);return I.slice(0,I.indexOf(`
96
- `))}function o(h,g,_,y){const T=_.enter("tableCell"),I=_.enter("phrasing"),E=_.containerPhrasing(h,{...y,before:a,after:a});return I(),T(),E}function l(h,g){return lT(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(h,g,_){const y=h.children;let T=-1;const I=[],E=g.enter("table");for(;++T<y.length;)I[T]=f(y[T],g,_);return E(),I}function f(h,g,_){const y=h.children;let T=-1;const I=[],E=g.enter("tableRow");for(;++T<y.length;)I[T]=o(y[T],h,g,_);return E(),I}function p(h,g,_){let y=tc.inlineCode(h,g,_);return _.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function XT(){return{exit:{taskListCheckValueChecked:fu,taskListCheckValueUnchecked:fu,paragraph:KT}}}function ZT(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:JT}}}function fu(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function KT(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let a=-1,s;for(;++a<i.length;){const u=i[a];if(u.type==="paragraph"){s=u;break}}s===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function JT(t,e,n,r){const i=t.children[0],a=typeof t.checked=="boolean"&&i&&i.type==="paragraph",s="["+(t.checked?"x":" ")+"] ",u=n.createTracker(r);a&&u.move(s);let o=tc.listItem(t,e,n,{...r,...u.current()});return a&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),o;function l(d){return d+s}}function ex(){return[L2(),J2(),rT(),$T(),XT()]}function tx(t){return{extensions:[D2(),eT(t),iT(),GT(t),ZT()]}}const nx={tokenize:ox,partial:!0},nc={tokenize:lx,partial:!0},rc={tokenize:cx,partial:!0},ic={tokenize:dx,partial:!0},rx={tokenize:fx,partial:!0},ac={name:"wwwAutolink",tokenize:sx,previous:uc},sc={name:"protocolAutolink",tokenize:ux,previous:oc},_t={name:"emailAutolink",tokenize:ax,previous:lc},pt={};function ix(){return{text:pt}}let Ut=48;for(;Ut<123;)pt[Ut]=_t,Ut++,Ut===58?Ut=65:Ut===91&&(Ut=97);pt[43]=_t;pt[45]=_t;pt[46]=_t;pt[95]=_t;pt[72]=[_t,sc];pt[104]=[_t,sc];pt[87]=[_t,ac];pt[119]=[_t,ac];function ax(t,e,n){const r=this;let i,a;return s;function s(f){return!zi(f)||!lc.call(r,r.previous)||Sa(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(f))}function u(f){return zi(f)?(t.consume(f),u):f===64?(t.consume(f),o):n(f)}function o(f){return f===46?t.check(rx,d,l)(f):f===45||f===95||Be(f)?(a=!0,t.consume(f),o):d(f)}function l(f){return t.consume(f),i=!0,o}function d(f){return a&&i&&ze(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function sx(t,e,n){const r=this;return i;function i(s){return s!==87&&s!==119||!uc.call(r,r.previous)||Sa(r.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(nx,t.attempt(nc,t.attempt(rc,a),n),n)(s))}function a(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}}function ux(t,e,n){const r=this;let i="",a=!1;return s;function s(f){return(f===72||f===104)&&oc.call(r,r.previous)&&!Sa(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),u):n(f)}function u(f){if(ze(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),u;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(f),o}return n(f)}function o(f){return f===47?(t.consume(f),a?l:(a=!0,o)):n(f)}function l(f){return f===null||Cr(f)||be(f)||Wt(f)||Fr(f)?n(f):t.attempt(nc,t.attempt(rc,d),n)(f)}function d(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function ox(t,e,n){let r=0;return i;function i(s){return(s===87||s===119)&&r<3?(r++,t.consume(s),i):s===46&&r===3?(t.consume(s),a):n(s)}function a(s){return s===null?n(s):e(s)}}function lx(t,e,n){let r,i,a;return s;function s(l){return l===46||l===95?t.check(ic,o,u)(l):l===null||be(l)||Wt(l)||l!==45&&Fr(l)?o(l):(a=!0,t.consume(l),s)}function u(l){return l===95?r=!0:(i=r,r=void 0),t.consume(l),s}function o(l){return i||r||!a?n(l):e(l)}}function cx(t,e){let n=0,r=0;return i;function i(s){return s===40?(n++,t.consume(s),i):s===41&&r<n?a(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?t.check(ic,e,a)(s):s===null||be(s)||Wt(s)?e(s):(t.consume(s),i)}function a(s){return s===41&&r++,t.consume(s),i}}function dx(t,e,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(t.consume(u),r):u===38?(t.consume(u),a):u===93?(t.consume(u),i):u===60||u===null||be(u)||Wt(u)?e(u):n(u)}function i(u){return u===null||u===40||u===91||be(u)||Wt(u)?e(u):r(u)}function a(u){return ze(u)?s(u):n(u)}function s(u){return u===59?(t.consume(u),r):ze(u)?(t.consume(u),s):n(u)}}function fx(t,e,n){return r;function r(a){return t.consume(a),i}function i(a){return Be(a)?n(a):e(a)}}function uc(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||be(t)}function oc(t){return!ze(t)}function lc(t){return!(t===47||zi(t))}function zi(t){return t===43||t===45||t===46||t===95||Be(t)}function Sa(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const hx={tokenize:_x,partial:!0};function px(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:bx,continuation:{tokenize:Tx},exit:xx}},text:{91:{name:"gfmFootnoteCall",tokenize:Ex},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:mx,resolveTo:gx}}}}function mx(t,e,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;i--;){const o=r.events[i][1];if(o.type==="labelImage"){s=o;break}if(o.type==="gfmFootnoteCall"||o.type==="labelLink"||o.type==="label"||o.type==="image"||o.type==="link")break}return u;function u(o){if(!s||!s._balanced)return n(o);const l=st(r.sliceSerialize({start:s.end,end:r.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(o):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(o),t.exit("gfmFootnoteCallLabelMarker"),e(o))}}function gx(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},u=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",a,e],["enter",s,e],["exit",s,e],["exit",a,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...u),t}function Ex(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return u;function u(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),o}function o(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",l)}function l(f){if(a>999||f===93&&!s||f===null||f===91||be(f))return n(f);if(f===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(st(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return be(f)||(s=!0),a++,t.consume(f),f===92?d:l}function d(f){return f===91||f===92||f===93?(t.consume(f),a++,l):l(f)}}function bx(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,s=0,u;return o;function o(g){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(g){return g===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):n(g)}function d(g){if(s>999||g===93&&!u||g===null||g===91||be(g))return n(g);if(g===93){t.exit("chunkString");const _=t.exit("gfmFootnoteDefinitionLabelString");return a=st(r.sliceSerialize(_)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return be(g)||(u=!0),s++,t.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(t.consume(g),s++,d):d(g)}function p(g){return g===58?(t.enter("definitionMarker"),t.consume(g),t.exit("definitionMarker"),i.includes(a)||i.push(a),oe(t,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return e(g)}}function Tx(t,e,n){return t.check(rr,e,t.attempt(hx,e,n))}function xx(t){t.exit("gfmFootnoteDefinition")}function _x(t,e,n){const r=this;return oe(t,i,"gfmFootnoteDefinitionIndent",5);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?e(a):n(a)}}function yx(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,u){let o=-1;for(;++o<s.length;)if(s[o][0]==="enter"&&s[o][1].type==="strikethroughSequenceTemporary"&&s[o][1]._close){let l=o;for(;l--;)if(s[l][0]==="exit"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._open&&s[o][1].end.offset-s[o][1].start.offset===s[l][1].end.offset-s[l][1].start.offset){s[o][1].type="strikethroughSequence",s[l][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},s[l][1].start),end:Object.assign({},s[o][1].end)},f={type:"strikethroughText",start:Object.assign({},s[l][1].end),end:Object.assign({},s[o][1].start)},p=[["enter",d,u],["enter",s[l][1],u],["exit",s[l][1],u],["enter",f,u]],h=u.parser.constructs.insideSpan.null;h&&Ze(p,p.length,0,Ur(h,s.slice(l+1,o),u)),Ze(p,p.length,0,[["exit",f,u],["enter",s[o][1],u],["exit",s[o][1],u],["exit",d,u]]),Ze(s,l-1,o-l+3,p),o=l+p.length-2;break}}for(o=-1;++o<s.length;)s[o][1].type==="strikethroughSequenceTemporary"&&(s[o][1].type="data");return s}function a(s,u,o){const l=this.previous,d=this.events;let f=0;return p;function p(g){return l===126&&d[d.length-1][1].type!=="characterEscape"?o(g):(s.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const _=on(l);if(g===126)return f>1?o(g):(s.consume(g),f++,h);if(f<2&&!n)return o(g);const y=s.exit("strikethroughSequenceTemporary"),T=on(g);return y._open=!T||T===2&&!!_,y._close=!_||_===2&&!!T,u(g)}}}class Ax{constructor(){this.map=[]}add(e,n,r){kx(this,e,n,r)}consume(e){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const a of i)e.push(a);i=r.pop()}this.map.length=0}}function kx(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function Cx(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function Ix(){return{flow:{null:{name:"table",tokenize:Sx,resolveAll:Nx}}}}function Sx(t,e,n){const r=this;let i=0,a=0,s;return u;function u(N){let F=r.events.length-1;for(;F>-1;){const q=r.events[F][1].type;if(q==="lineEnding"||q==="linePrefix")F--;else break}const P=F>-1?r.events[F][1].type:null,X=P==="tableHead"||P==="tableRow"?S:o;return X===S&&r.parser.lazy[r.now().line]?n(N):X(N)}function o(N){return t.enter("tableHead"),t.enter("tableRow"),l(N)}function l(N){return N===124||(s=!0,a+=1),d(N)}function d(N){return N===null?n(N):Q(N)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),h):n(N):ie(N)?oe(t,d,"whitespace")(N):(a+=1,s&&(s=!1,i+=1),N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),s=!0,d):(t.enter("data"),f(N)))}function f(N){return N===null||N===124||be(N)?(t.exit("data"),d(N)):(t.consume(N),N===92?p:f)}function p(N){return N===92||N===124?(t.consume(N),f):f(N)}function h(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(t.enter("tableDelimiterRow"),s=!1,ie(N)?oe(t,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?y(N):N===124?(s=!0,t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),_):O(N)}function _(N){return ie(N)?oe(t,y,"whitespace")(N):y(N)}function y(N){return N===58?(a+=1,s=!0,t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),T):N===45?(a+=1,T(N)):N===null||Q(N)?R(N):O(N)}function T(N){return N===45?(t.enter("tableDelimiterFiller"),I(N)):O(N)}function I(N){return N===45?(t.consume(N),I):N===58?(s=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),E):(t.exit("tableDelimiterFiller"),E(N))}function E(N){return ie(N)?oe(t,R,"whitespace")(N):R(N)}function R(N){return N===124?g(N):N===null||Q(N)?!s||i!==a?O(N):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(N)):O(N)}function O(N){return n(N)}function S(N){return t.enter("tableRow"),v(N)}function v(N){return N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),v):N===null||Q(N)?(t.exit("tableRow"),e(N)):ie(N)?oe(t,v,"whitespace")(N):(t.enter("data"),B(N))}function B(N){return N===null||N===124||be(N)?(t.exit("data"),v(N)):(t.consume(N),N===92?z:B)}function z(N){return N===92||N===124?(t.consume(N),B):B(N)}}function Nx(t,e){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],u=!1,o=0,l,d,f;const p=new Ax;for(;++n<t.length;){const h=t[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(u=!1,o!==0&&(hu(p,e,o,l,d),d=void 0,o=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",l,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,a=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,e]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],f=hr(p,e,a,i,void 0,f),a=[0,0,0,0]),s[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],f=hr(p,e,a,i,void 0,f)),a=s,s=[a[1],n,0,0])):g.type==="tableHead"?(u=!0,o=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(o=n,a[1]!==0?(s[0]=s[1],f=hr(p,e,a,i,n,f)):s[1]!==0&&(f=hr(p,e,s,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(s[3]=n)}for(o!==0&&hu(p,e,o,l,d),p.consume(e.events),n=-1;++n<e.events.length;){const h=e.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Cx(e.events,n))}return t}function hr(t,e,n,r,i,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(a.end=Object.assign({},nn(e.events,n[0])),t.add(n[0],0,[["exit",a,e]]));const o=nn(e.events,n[1]);if(a={type:s,start:Object.assign({},o),end:Object.assign({},o)},t.add(n[1],0,[["enter",a,e]]),n[2]!==0){const l=nn(e.events,n[2]),d=nn(e.events,n[3]),f={type:u,start:Object.assign({},l),end:Object.assign({},d)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const p=e.events[n[2]],h=e.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,_=n[3]-n[2]-1;t.add(g,_,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(a.end=Object.assign({},nn(e.events,i)),t.add(i,0,[["exit",a,e]]),a=void 0),a}function hu(t,e,n,r,i){const a=[],s=nn(e.events,n);i&&(i.end=Object.assign({},s),a.push(["exit",i,e])),r.end=Object.assign({},s),a.push(["exit",r,e]),t.add(n+1,0,a)}function nn(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const wx={name:"tasklistCheck",tokenize:Ox};function Rx(){return{text:{91:wx}}}function Ox(t,e,n){const r=this;return i;function i(o){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(o):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(o),t.exit("taskListCheckMarker"),a)}function a(o){return be(o)?(t.enter("taskListCheckValueUnchecked"),t.consume(o),t.exit("taskListCheckValueUnchecked"),s):o===88||o===120?(t.enter("taskListCheckValueChecked"),t.consume(o),t.exit("taskListCheckValueChecked"),s):n(o)}function s(o){return o===93?(t.enter("taskListCheckMarker"),t.consume(o),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),u):n(o)}function u(o){return Q(o)?e(o):ie(o)?t.check({tokenize:Lx},e,n)(o):n(o)}}function Lx(t,e,n){return oe(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Dx(t){return Fo([ix(),px(),yx(t),Ix(),Rx()])}const vx={};function Px(t){const e=this,n=t||vx,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Dx(n)),a.push(ex()),s.push(tx(n))}const Mx=V.lazy(()=>Oc(()=>import("./lazy-highlighter-CKguQGTj.js"),__vite__mapDeps([0,1,2])));function cc(){const t=W.c(3),[e,n]=V.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async s=>{await navigator.clipboard.writeText(s),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let a;return t[1]!==e?(a={handleCopy:i,copied:e},t[1]=e,t[2]=a):a=t[2],a}function Bx(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[85,70],t[0]=e):e=t[0];const n=e;let r;return t[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"p-4 font-mono text-sm",style:{background:"#2d2d2d",borderRadius:"0 0 0.5rem 0.5rem",overflow:"auto",minHeight:"4rem"},children:n.map(Fx)}),t[1]=r):r=t[1],r}function Fx(t,e){return m.jsxs("div",{className:"flex gap-2 items-center my-1",children:[e>2&&e<7&&m.jsx("div",{className:"w-4 h-4 rounded-sm opacity-40 animate-pulse",style:{background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.1}s`}}),e%4===0&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"3rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.12}s`}}),e%3===1&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"2.5rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.14}s`}}),m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:`${t}%`,background:"rgba(255, 255, 255, 0.1)",animationDelay:`${e*.1}s`}}),e%5===2&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"4rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.16}s`}})]},e)}function Ux(t){const e=W.c(12),n=V.useRef(null),{handleCopy:r,copied:i}=cc(),a=Hx;let s;e[0]!==r?(s=async()=>{const p=a(n.current);await r(p)},e[0]=r,e[1]=s):s=e[1];const u=s;let o;e[2]!==i?(o=i?m.jsx(sn,{size:12}):m.jsx(Wi,{size:12}),e[2]=i,e[3]=o):o=e[3];let l;e[4]!==u||e[5]!==o?(l=m.jsx("div",{className:"flex justify-end items-center",children:m.jsxs(We,{variant:"ghost",onClick:u,"aria-label":"Copy as CSV",className:"text-muted-foreground hover:text-foreground h-6 text-[10px]",type:"button",children:["Copy as CSV",o]})}),e[4]=u,e[5]=o,e[6]=l):l=e[6];let d;e[7]!==t?(d=m.jsx("div",{className:"overflow-x-auto mb-4 rounded-lg border border-border",children:m.jsx("table",{ref:n,...t,className:"min-w-full border-collapse text-sm",children:t.children})}),e[7]=t,e[8]=d):d=e[8];let f;return e[9]!==l||e[10]!==d?(f=m.jsxs(m.Fragment,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=f):f=e[11],f}function Hx(t){return t?Array.from(t.querySelectorAll("tr")).map(jx).join(`
96
+ `))}function o(h,g,_,y){const T=_.enter("tableCell"),I=_.enter("phrasing"),E=_.containerPhrasing(h,{...y,before:a,after:a});return I(),T(),E}function l(h,g){return lT(h,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function d(h,g,_){const y=h.children;let T=-1;const I=[],E=g.enter("table");for(;++T<y.length;)I[T]=f(y[T],g,_);return E(),I}function f(h,g,_){const y=h.children;let T=-1;const I=[],E=g.enter("tableRow");for(;++T<y.length;)I[T]=o(y[T],h,g,_);return E(),I}function p(h,g,_){let y=tc.inlineCode(h,g,_);return _.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function XT(){return{exit:{taskListCheckValueChecked:fu,taskListCheckValueUnchecked:fu,paragraph:KT}}}function ZT(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:JT}}}function fu(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function KT(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let a=-1,s;for(;++a<i.length;){const u=i[a];if(u.type==="paragraph"){s=u;break}}s===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function JT(t,e,n,r){const i=t.children[0],a=typeof t.checked=="boolean"&&i&&i.type==="paragraph",s="["+(t.checked?"x":" ")+"] ",u=n.createTracker(r);a&&u.move(s);let o=tc.listItem(t,e,n,{...r,...u.current()});return a&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),o;function l(d){return d+s}}function ex(){return[L2(),J2(),rT(),$T(),XT()]}function tx(t){return{extensions:[D2(),eT(t),iT(),GT(t),ZT()]}}const nx={tokenize:ox,partial:!0},nc={tokenize:lx,partial:!0},rc={tokenize:cx,partial:!0},ic={tokenize:dx,partial:!0},rx={tokenize:fx,partial:!0},ac={name:"wwwAutolink",tokenize:sx,previous:uc},sc={name:"protocolAutolink",tokenize:ux,previous:oc},_t={name:"emailAutolink",tokenize:ax,previous:lc},pt={};function ix(){return{text:pt}}let Ut=48;for(;Ut<123;)pt[Ut]=_t,Ut++,Ut===58?Ut=65:Ut===91&&(Ut=97);pt[43]=_t;pt[45]=_t;pt[46]=_t;pt[95]=_t;pt[72]=[_t,sc];pt[104]=[_t,sc];pt[87]=[_t,ac];pt[119]=[_t,ac];function ax(t,e,n){const r=this;let i,a;return s;function s(f){return!zi(f)||!lc.call(r,r.previous)||Sa(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(f))}function u(f){return zi(f)?(t.consume(f),u):f===64?(t.consume(f),o):n(f)}function o(f){return f===46?t.check(rx,d,l)(f):f===45||f===95||Be(f)?(a=!0,t.consume(f),o):d(f)}function l(f){return t.consume(f),i=!0,o}function d(f){return a&&i&&ze(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function sx(t,e,n){const r=this;return i;function i(s){return s!==87&&s!==119||!uc.call(r,r.previous)||Sa(r.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(nx,t.attempt(nc,t.attempt(rc,a),n),n)(s))}function a(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}}function ux(t,e,n){const r=this;let i="",a=!1;return s;function s(f){return(f===72||f===104)&&oc.call(r,r.previous)&&!Sa(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),u):n(f)}function u(f){if(ze(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),u;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return t.consume(f),o}return n(f)}function o(f){return f===47?(t.consume(f),a?l:(a=!0,o)):n(f)}function l(f){return f===null||Cr(f)||be(f)||Wt(f)||Fr(f)?n(f):t.attempt(nc,t.attempt(rc,d),n)(f)}function d(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function ox(t,e,n){let r=0;return i;function i(s){return(s===87||s===119)&&r<3?(r++,t.consume(s),i):s===46&&r===3?(t.consume(s),a):n(s)}function a(s){return s===null?n(s):e(s)}}function lx(t,e,n){let r,i,a;return s;function s(l){return l===46||l===95?t.check(ic,o,u)(l):l===null||be(l)||Wt(l)||l!==45&&Fr(l)?o(l):(a=!0,t.consume(l),s)}function u(l){return l===95?r=!0:(i=r,r=void 0),t.consume(l),s}function o(l){return i||r||!a?n(l):e(l)}}function cx(t,e){let n=0,r=0;return i;function i(s){return s===40?(n++,t.consume(s),i):s===41&&r<n?a(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?t.check(ic,e,a)(s):s===null||be(s)||Wt(s)?e(s):(t.consume(s),i)}function a(s){return s===41&&r++,t.consume(s),i}}function dx(t,e,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(t.consume(u),r):u===38?(t.consume(u),a):u===93?(t.consume(u),i):u===60||u===null||be(u)||Wt(u)?e(u):n(u)}function i(u){return u===null||u===40||u===91||be(u)||Wt(u)?e(u):r(u)}function a(u){return ze(u)?s(u):n(u)}function s(u){return u===59?(t.consume(u),r):ze(u)?(t.consume(u),s):n(u)}}function fx(t,e,n){return r;function r(a){return t.consume(a),i}function i(a){return Be(a)?n(a):e(a)}}function uc(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||be(t)}function oc(t){return!ze(t)}function lc(t){return!(t===47||zi(t))}function zi(t){return t===43||t===45||t===46||t===95||Be(t)}function Sa(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const hx={tokenize:_x,partial:!0};function px(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:bx,continuation:{tokenize:Tx},exit:xx}},text:{91:{name:"gfmFootnoteCall",tokenize:Ex},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:mx,resolveTo:gx}}}}function mx(t,e,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;i--;){const o=r.events[i][1];if(o.type==="labelImage"){s=o;break}if(o.type==="gfmFootnoteCall"||o.type==="labelLink"||o.type==="label"||o.type==="image"||o.type==="link")break}return u;function u(o){if(!s||!s._balanced)return n(o);const l=st(r.sliceSerialize({start:s.end,end:r.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(o):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(o),t.exit("gfmFootnoteCallLabelMarker"),e(o))}}function gx(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},u=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",a,e],["enter",s,e],["exit",s,e],["exit",a,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...u),t}function Ex(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return u;function u(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),o}function o(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",l)}function l(f){if(a>999||f===93&&!s||f===null||f===91||be(f))return n(f);if(f===93){t.exit("chunkString");const p=t.exit("gfmFootnoteCallString");return i.includes(st(r.sliceSerialize(p)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return be(f)||(s=!0),a++,t.consume(f),f===92?d:l}function d(f){return f===91||f===92||f===93?(t.consume(f),a++,l):l(f)}}function bx(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,s=0,u;return o;function o(g){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(g){return g===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):n(g)}function d(g){if(s>999||g===93&&!u||g===null||g===91||be(g))return n(g);if(g===93){t.exit("chunkString");const _=t.exit("gfmFootnoteDefinitionLabelString");return a=st(r.sliceSerialize(_)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),p}return be(g)||(u=!0),s++,t.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(t.consume(g),s++,d):d(g)}function p(g){return g===58?(t.enter("definitionMarker"),t.consume(g),t.exit("definitionMarker"),i.includes(a)||i.push(a),oe(t,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return e(g)}}function Tx(t,e,n){return t.check(rr,e,t.attempt(hx,e,n))}function xx(t){t.exit("gfmFootnoteDefinition")}function _x(t,e,n){const r=this;return oe(t,i,"gfmFootnoteDefinitionIndent",5);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?e(a):n(a)}}function yx(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,u){let o=-1;for(;++o<s.length;)if(s[o][0]==="enter"&&s[o][1].type==="strikethroughSequenceTemporary"&&s[o][1]._close){let l=o;for(;l--;)if(s[l][0]==="exit"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._open&&s[o][1].end.offset-s[o][1].start.offset===s[l][1].end.offset-s[l][1].start.offset){s[o][1].type="strikethroughSequence",s[l][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},s[l][1].start),end:Object.assign({},s[o][1].end)},f={type:"strikethroughText",start:Object.assign({},s[l][1].end),end:Object.assign({},s[o][1].start)},p=[["enter",d,u],["enter",s[l][1],u],["exit",s[l][1],u],["enter",f,u]],h=u.parser.constructs.insideSpan.null;h&&Ze(p,p.length,0,Ur(h,s.slice(l+1,o),u)),Ze(p,p.length,0,[["exit",f,u],["enter",s[o][1],u],["exit",s[o][1],u],["exit",d,u]]),Ze(s,l-1,o-l+3,p),o=l+p.length-2;break}}for(o=-1;++o<s.length;)s[o][1].type==="strikethroughSequenceTemporary"&&(s[o][1].type="data");return s}function a(s,u,o){const l=this.previous,d=this.events;let f=0;return p;function p(g){return l===126&&d[d.length-1][1].type!=="characterEscape"?o(g):(s.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const _=on(l);if(g===126)return f>1?o(g):(s.consume(g),f++,h);if(f<2&&!n)return o(g);const y=s.exit("strikethroughSequenceTemporary"),T=on(g);return y._open=!T||T===2&&!!_,y._close=!_||_===2&&!!T,u(g)}}}class Ax{constructor(){this.map=[]}add(e,n,r){kx(this,e,n,r)}consume(e){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const a of i)e.push(a);i=r.pop()}this.map.length=0}}function kx(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function Cx(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function Ix(){return{flow:{null:{name:"table",tokenize:Sx,resolveAll:Nx}}}}function Sx(t,e,n){const r=this;let i=0,a=0,s;return u;function u(N){let F=r.events.length-1;for(;F>-1;){const q=r.events[F][1].type;if(q==="lineEnding"||q==="linePrefix")F--;else break}const P=F>-1?r.events[F][1].type:null,X=P==="tableHead"||P==="tableRow"?S:o;return X===S&&r.parser.lazy[r.now().line]?n(N):X(N)}function o(N){return t.enter("tableHead"),t.enter("tableRow"),l(N)}function l(N){return N===124||(s=!0,a+=1),d(N)}function d(N){return N===null?n(N):Q(N)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),h):n(N):ie(N)?oe(t,d,"whitespace")(N):(a+=1,s&&(s=!1,i+=1),N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),s=!0,d):(t.enter("data"),f(N)))}function f(N){return N===null||N===124||be(N)?(t.exit("data"),d(N)):(t.consume(N),N===92?p:f)}function p(N){return N===92||N===124?(t.consume(N),f):f(N)}function h(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(t.enter("tableDelimiterRow"),s=!1,ie(N)?oe(t,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?y(N):N===124?(s=!0,t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),_):O(N)}function _(N){return ie(N)?oe(t,y,"whitespace")(N):y(N)}function y(N){return N===58?(a+=1,s=!0,t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),T):N===45?(a+=1,T(N)):N===null||Q(N)?R(N):O(N)}function T(N){return N===45?(t.enter("tableDelimiterFiller"),I(N)):O(N)}function I(N){return N===45?(t.consume(N),I):N===58?(s=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),E):(t.exit("tableDelimiterFiller"),E(N))}function E(N){return ie(N)?oe(t,R,"whitespace")(N):R(N)}function R(N){return N===124?g(N):N===null||Q(N)?!s||i!==a?O(N):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(N)):O(N)}function O(N){return n(N)}function S(N){return t.enter("tableRow"),v(N)}function v(N){return N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),v):N===null||Q(N)?(t.exit("tableRow"),e(N)):ie(N)?oe(t,v,"whitespace")(N):(t.enter("data"),B(N))}function B(N){return N===null||N===124||be(N)?(t.exit("data"),v(N)):(t.consume(N),N===92?z:B)}function z(N){return N===92||N===124?(t.consume(N),B):B(N)}}function Nx(t,e){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],u=!1,o=0,l,d,f;const p=new Ax;for(;++n<t.length;){const h=t[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(u=!1,o!==0&&(hu(p,e,o,l,d),d=void 0,o=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",l,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,a=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,e]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],f=hr(p,e,a,i,void 0,f),a=[0,0,0,0]),s[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],f=hr(p,e,a,i,void 0,f)),a=s,s=[a[1],n,0,0])):g.type==="tableHead"?(u=!0,o=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(o=n,a[1]!==0?(s[0]=s[1],f=hr(p,e,a,i,n,f)):s[1]!==0&&(f=hr(p,e,s,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(s[3]=n)}for(o!==0&&hu(p,e,o,l,d),p.consume(e.events),n=-1;++n<e.events.length;){const h=e.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=Cx(e.events,n))}return t}function hr(t,e,n,r,i,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(a.end=Object.assign({},nn(e.events,n[0])),t.add(n[0],0,[["exit",a,e]]));const o=nn(e.events,n[1]);if(a={type:s,start:Object.assign({},o),end:Object.assign({},o)},t.add(n[1],0,[["enter",a,e]]),n[2]!==0){const l=nn(e.events,n[2]),d=nn(e.events,n[3]),f={type:u,start:Object.assign({},l),end:Object.assign({},d)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const p=e.events[n[2]],h=e.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,_=n[3]-n[2]-1;t.add(g,_,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(a.end=Object.assign({},nn(e.events,i)),t.add(i,0,[["exit",a,e]]),a=void 0),a}function hu(t,e,n,r,i){const a=[],s=nn(e.events,n);i&&(i.end=Object.assign({},s),a.push(["exit",i,e])),r.end=Object.assign({},s),a.push(["exit",r,e]),t.add(n+1,0,a)}function nn(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const wx={name:"tasklistCheck",tokenize:Ox};function Rx(){return{text:{91:wx}}}function Ox(t,e,n){const r=this;return i;function i(o){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(o):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(o),t.exit("taskListCheckMarker"),a)}function a(o){return be(o)?(t.enter("taskListCheckValueUnchecked"),t.consume(o),t.exit("taskListCheckValueUnchecked"),s):o===88||o===120?(t.enter("taskListCheckValueChecked"),t.consume(o),t.exit("taskListCheckValueChecked"),s):n(o)}function s(o){return o===93?(t.enter("taskListCheckMarker"),t.consume(o),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),u):n(o)}function u(o){return Q(o)?e(o):ie(o)?t.check({tokenize:Lx},e,n)(o):n(o)}}function Lx(t,e,n){return oe(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Dx(t){return Fo([ix(),px(),yx(t),Ix(),Rx()])}const vx={};function Px(t){const e=this,n=t||vx,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Dx(n)),a.push(ex()),s.push(tx(n))}const Mx=V.lazy(()=>Oc(()=>import("./lazy-highlighter-CiDPKksG.js"),__vite__mapDeps([0,1,2])));function cc(){const t=W.c(3),[e,n]=V.useState(!1);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=async s=>{await navigator.clipboard.writeText(s),n(!0),setTimeout(()=>n(!1),2e3)},t[0]=r):r=t[0];const i=r;let a;return t[1]!==e?(a={handleCopy:i,copied:e},t[1]=e,t[2]=a):a=t[2],a}function Bx(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[85,70],t[0]=e):e=t[0];const n=e;let r;return t[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"p-4 font-mono text-sm",style:{background:"#2d2d2d",borderRadius:"0 0 0.5rem 0.5rem",overflow:"auto",minHeight:"4rem"},children:n.map(Fx)}),t[1]=r):r=t[1],r}function Fx(t,e){return m.jsxs("div",{className:"flex gap-2 items-center my-1",children:[e>2&&e<7&&m.jsx("div",{className:"w-4 h-4 rounded-sm opacity-40 animate-pulse",style:{background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.1}s`}}),e%4===0&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"3rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.12}s`}}),e%3===1&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"2.5rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.14}s`}}),m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:`${t}%`,background:"rgba(255, 255, 255, 0.1)",animationDelay:`${e*.1}s`}}),e%5===2&&m.jsx("div",{className:"h-4 rounded animate-pulse",style:{width:"4rem",background:"rgba(128, 128, 128, 0.3)",animationDelay:`${e*.16}s`}})]},e)}function Ux(t){const e=W.c(12),n=V.useRef(null),{handleCopy:r,copied:i}=cc(),a=Hx;let s;e[0]!==r?(s=async()=>{const p=a(n.current);await r(p)},e[0]=r,e[1]=s):s=e[1];const u=s;let o;e[2]!==i?(o=i?m.jsx(sn,{size:12}):m.jsx(Wi,{size:12}),e[2]=i,e[3]=o):o=e[3];let l;e[4]!==u||e[5]!==o?(l=m.jsx("div",{className:"flex justify-end items-center",children:m.jsxs(We,{variant:"ghost",onClick:u,"aria-label":"Copy as CSV",className:"text-muted-foreground hover:text-foreground h-6 text-[10px]",type:"button",children:["Copy as CSV",o]})}),e[4]=u,e[5]=o,e[6]=l):l=e[6];let d;e[7]!==t?(d=m.jsx("div",{className:"overflow-x-auto mb-4 rounded-lg border border-border",children:m.jsx("table",{ref:n,...t,className:"min-w-full border-collapse text-sm",children:t.children})}),e[7]=t,e[8]=d):d=e[8];let f;return e[9]!==l||e[10]!==d?(f=m.jsxs(m.Fragment,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=f):f=e[11],f}function Hx(t){return t?Array.from(t.querySelectorAll("tr")).map(jx).join(`
97
97
  `):""}function jx(t){return Array.from(t.querySelectorAll("th,td")).map(zx).join(",")}function zx(t){let e=t.textContent||"";return e=e.replace(/"/g,'""'),e.search(/([",\n])/g)>=0&&(e=`"${e}"`),e}const $x=[Px],Yx=[I2],qx={p:t=>m.jsx("p",{...t,className:"leading-relaxed text-sm mb-2 last:mb-0"}),strong:t=>m.jsx("strong",{...t,className:"font-bold"}),em:t=>m.jsx("em",{...t,className:"italic"}),a:t=>m.jsx("a",{...t,target:"_blank",rel:"noopener noreferrer",className:"text-primary-dark hover:underline break-all font-medium"}),ul:t=>m.jsx("ul",{...t,className:"list-disc ml-6 my-4 space-y-2"}),ol:t=>m.jsx("ol",{...t,className:"list-decimal ml-6 my-4 space-y-2"}),li:t=>m.jsx("li",{...t,className:"leading-relaxed text-sm"}),code:t=>m.jsx("code",{...t,className:"px-1 py-0.5 bg-muted rounded text-sm font-mono break-all"}),pre:t=>m.jsx("pre",{...t,className:"flex w-full min-w-0 my-4 bg-muted rounded overflow-hidden",children:m.jsx("code",{className:"flex-1 min-w-0 p-4 text-sm font-mono whitespace-pre overflow-x-auto",children:t.children})}),table:t=>m.jsx(Ux,{...t}),thead:t=>m.jsx("thead",{...t,className:"bg-muted",children:t.children}),tr:t=>m.jsx("tr",{...t,className:"even:bg-muted/50 border-b border-border last:border-0"}),th:t=>m.jsx("th",{...t,className:"px-4 py-2 text-left font-semibold text-muted-foreground border-b border-border"}),td:t=>m.jsx("td",{...t,className:"px-4 py-2 border-b border-border"})},dc=V.memo(t=>{const e=W.c(2),{content:n}=t;let r;return e[0]!==n?(r=m.jsx(cg,{remarkPlugins:$x,rehypePlugins:Yx,components:qx,children:n}),e[0]=n,e[1]=r):r=e[1],r},(t,e)=>t.content===e.content);function Vx(t){const e=W.c(20),{language:n,content:r}=t,{handleCopy:i,copied:a}=cc(),s=n||"text";let u;e[0]!==s?(u=m.jsx("span",{className:"text-xs font-mono uppercase text-muted-foreground tracking-widest select-none",children:s}),e[0]=s,e[1]=u):u=e[1];let o;e[2]!==r||e[3]!==i?(o=()=>i(r),e[2]=r,e[3]=i,e[4]=o):o=e[4];let l;e[5]!==a?(l=a?m.jsx(sn,{size:14}):m.jsx(Wi,{size:14}),e[5]=a,e[6]=l):l=e[6];let d;e[7]!==o||e[8]!==l?(d=m.jsx(We,{size:"icon",variant:"ghost",onClick:o,"aria-label":"Copy code",className:"text-muted-foreground hover:text-foreground rounded-lg h-8 w-8",children:l}),e[7]=o,e[8]=l,e[9]=d):d=e[9];let f;e[10]!==u||e[11]!==d?(f=m.jsxs("div",{className:"flex items-center justify-between p-1 pl-4 bg-muted border-b border-border",children:[u,d]}),e[10]=u,e[11]=d,e[12]=f):f=e[12];let p;e[13]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Bx,{}),e[13]=p):p=e[13];let h;e[14]!==r||e[15]!==n?(h=m.jsx(V.Suspense,{fallback:p,children:m.jsx(Mx,{language:n,content:r})}),e[14]=r,e[15]=n,e[16]=h):h=e[16];let g;return e[17]!==f||e[18]!==h?(g=m.jsxs("div",{className:"my-4 rounded-lg bg-muted overflow-hidden border border-border grid min-w-0",children:[f,h]}),e[17]=f,e[18]=h,e[19]=g):g=e[19],g}dc.displayName="MemoizedMarkdownBlock";const Na=t=>{const e=W.c(7),{id:n,text:r}=t;let i;e[0]!==r?(i=he.lexer(r),e[0]=r,e[1]=i):i=e[1];const a=i;let s;if(e[2]!==a||e[3]!==n){let u;e[5]!==n?(u=(o,l)=>o.type==="code"?m.jsx(Vx,{language:o.lang,content:o.text},`${n}-block_${l}`):m.jsx(dc,{content:o.raw},`${n}-block_${l}`),e[5]=n,e[6]=u):u=e[6],s=a.map(u),e[2]=a,e[3]=n,e[4]=s}else s=e[4];return s};Na.displayName="MemoizedMarkdown";function fc(t){const e=W.c(18),{id:n,part:r,copyable:i,extraActions:a,hasToolCallAfter:s}=t,u=i===void 0?!1:i,o=s===void 0?!1:s,{handleCopy:l}=_h(),[d,f]=V.useState(!1);let p;e[0]!==l||e[1]!==r.text?(p=async()=>{await l(r.text),f(!0),setTimeout(()=>f(!1),2e3)},e[0]=l,e[1]=r.text,e[2]=p):p=e[2];const h=p,g=u&&a,_=g||a,y=!o&&"mb-2";let T;e[3]!==y?(T=le("group/part relative",y),e[3]=y,e[4]=T):T=e[4];let I;e[5]!==n||e[6]!==r.text?(I=m.jsx(Na,{id:n,text:r.text}),e[5]=n,e[6]=r.text,e[7]=I):I=e[7];let E;e[8]!==a||e[9]!==h||e[10]!==d||e[11]!==_||e[12]!==g?(E=_&&m.jsx("div",{className:"flex w-full items-center text-xs text-muted-foreground opacity-0 pointer-events-none transition-all duration-200 group-hover/part:opacity-100 group-hover/part:pointer-events-auto mt-2",children:m.jsxs("div",{className:"flex items-center gap-1",children:[g&&m.jsx(We,{onClick:h,variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground size-6 whitespace-nowrap",children:d?m.jsx(sn,{size:12}):m.jsx(Wi,{size:12})}),a]})}),e[8]=a,e[9]=h,e[10]=d,e[11]=_,e[12]=g,e[13]=E):E=e[13];let R;return e[14]!==T||e[15]!==I||e[16]!==E?(R=m.jsxs("div",{className:T,children:[I,E]}),e[14]=T,e[15]=I,e[16]=E,e[17]=R):R=e[17],R}function Wx(t){const e=W.c(4),{output:n}=t;let r;if(e[0]!==n){const s=JSON.stringify(n,null,2);r=s.length>2e3?s.slice(0,2e3)+"...[TRUNCATED]":s,e[0]=n,e[1]=r}else r=e[1];const i=r;let a;return e[2]!==i?(a=m.jsx("div",{className:"h-full",children:m.jsx(ku,{code:i,language:"json",height:"100%",readOnly:!0})}),e[2]=i,e[3]=a):a=e[3],a}function pu(t){const e=W.c(35),{part:n}=t,{state:r}=n;let i;e[0]!==n?(i="toolName"in n?n.toolName:n.type.replace("tool-",""),e[0]=n,e[1]=i):i=e[1];const a=i,[s,u]=V.useState(!1),o=(r==="input-streaming"||r==="input-available"||r==="output-available")&&!!n.input,l=r==="output-available",d=r==="output-error";let f;e[2]!==s?(f=()=>u(!s),e[2]=s,e[3]=f):f=e[3];let p;e[4]!==r?(p=r==="output-error"?m.jsx(yu,{className:"size-4 text-destructive shrink-0"}):m.jsx(Qc,{className:le("size-4 text-muted-foreground shrink-0",(r==="input-streaming"||r==="input-available")&&"shimmer")}),e[4]=r,e[5]=p):p=e[5];const h=r==="output-error"&&"text-destructive/90",g=(r==="input-streaming"||r==="input-available")&&"shimmer";let _;e[6]!==h||e[7]!==g?(_=le("text-xs font-medium text-muted-foreground truncate",h,g),e[6]=h,e[7]=g,e[8]=_):_=e[8];const y=r==="input-streaming"&&`Streaming ${a} arguments`,T=r==="input-available"&&`Calling ${a}`,I=r==="output-available"&&`Called ${a}`,E=r==="output-error"&&`Error calling ${a}`;let R;e[9]!==E||e[10]!==_||e[11]!==y||e[12]!==T||e[13]!==I?(R=m.jsxs("span",{className:_,children:[y,T,I,E]}),e[9]=E,e[10]=_,e[11]=y,e[12]=T,e[13]=I,e[14]=R):R=e[14];let O;e[15]!==R||e[16]!==p?(O=m.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[p,R]}),e[15]=R,e[16]=p,e[17]=O):O=e[17];const S=s&&"rotate-90";let v;e[18]!==S?(v=le("size-4 text-muted-foreground transition-transform",S),e[18]=S,e[19]=v):v=e[19];let B;e[20]!==v?(B=m.jsx("div",{className:"flex items-center gap-2 shrink-0",children:m.jsx(Au,{className:v})}),e[20]=v,e[21]=B):B=e[21];let z;e[22]!==O||e[23]!==B||e[24]!==f?(z=m.jsxs("button",{type:"button",onClick:f,className:"flex items-center gap-2 w-full cursor-pointer p-3",children:[O,B]}),e[22]=O,e[23]=B,e[24]=f,e[25]=z):z=e[25];let N;e[26]!==s||e[27]!==n||e[28]!==d||e[29]!==o||e[30]!==l?(N=s&&m.jsxs("div",{className:"flex ml-[7px] px-3 pb-3",children:[m.jsx("div",{className:"w-4 relative shrink-0",children:m.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-0.25 bg-border"})}),m.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-w-0 pt-2",children:[o&&m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("div",{className:"px-1 h-5 flex items-center",children:m.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Input"})}),m.jsx("div",{className:"border border-border rounded-lg p-2 h-full max-h-[200px]",children:m.jsx(ku,{code:JSON.stringify(n.input,null,2),language:"json",foldOnMount:!0,height:"100%",readOnly:!0})})]}),l&&m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("div",{className:"px-1 h-5 flex items-center",children:m.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Output"})}),m.jsx("div",{className:"border border-border rounded-lg max-h-[200px] overflow-auto p-2 h-full",children:m.jsx(Wx,{output:n.output})})]}),d&&m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("div",{className:"px-1 h-5 flex items-center",children:m.jsx("span",{className:"text-xs font-medium text-destructive/90",children:"Error"})}),m.jsx("div",{className:"border border-destructive/20 rounded-lg max-h-[200px] overflow-auto p-2 bg-destructive/10",children:m.jsx("pre",{className:"text-xs font-mono text-destructive whitespace-pre-wrap wrap-break-word",children:"errorText"in n&&typeof n.errorText=="string"?n.errorText:"An unknown error occurred"})})]})]})]}),e[26]=s,e[27]=n,e[28]=d,e[29]=o,e[30]=l,e[31]=N):N=e[31];let F;return e[32]!==z||e[33]!==N?(F=m.jsx("div",{className:"flex flex-col my-4 w-full min-w-0",children:m.jsxs("div",{className:"border border-border/75 rounded-lg flex flex-col bg-background w-full min-w-0 overflow-hidden",children:[z,N]})}),e[32]=z,e[33]=N,e[34]=F):F=e[34],F}const Qx={openrouter:t=>{const e=t?.openrouter;return typeof e=="object"&&e!==null&&"usage"in e&&typeof e.usage=="object"&&e.usage!==null&&"cost"in e.usage&&typeof e.usage.cost=="number"?e.usage.cost:null}};function Gx(t){if(!t?.providerMetadata)return null;for(const e of Object.values(Qx)){const n=e(t.providerMetadata);if(n!==null)return n}return null}function Xx(t){return t.reduce((e,n)=>{const r=n.metadata?.usage;return r?{inputTokens:e.inputTokens+(r.inputTokens??0),outputTokens:e.outputTokens+(r.outputTokens??0),totalTokens:e.totalTokens+(r.totalTokens??0),cost:e.cost+(Gx(r)??0)}:e},{inputTokens:0,outputTokens:0,totalTokens:0,cost:0})}function Zx(t){const e=W.c(38),{messages:n}=t;let r,i,a,s,u,o,l,d,f,p,h,g;if(e[0]!==n){g=Symbol.for("react.early_return_sentinel");e:{const R=Xx(n);if(!R){g=null;break e}const{totalTokens:O,inputTokens:S,outputTokens:v,cost:B}=R;if(a=B,!O&&!S&&!v){g=null;break e}i=dn;let z;e[13]===Symbol.for("react.memo_cache_sentinel")?(z=m.jsx(Cu,{size:12}),e[13]=z):z=e[13];const N=m.jsxs(We,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap",children:[z,m.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:O.toLocaleString()})]});e[14]!==N?(h=m.jsx(fn,{asChild:!0,children:N}),e[14]=N,e[15]=h):h=e[15],r=hn,f="top",p="font-mono text-[11px]",u="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("span",{className:"text-muted",children:"in"}),e[16]=o):o=e[16],l=m.jsx("span",{children:S.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("span",{className:"text-muted",children:"out"}),e[17]=d):d=e[17],s=v.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=s,e[5]=u,e[6]=o,e[7]=l,e[8]=d,e[9]=f,e[10]=p,e[11]=h,e[12]=g}else r=e[1],i=e[2],a=e[3],s=e[4],u=e[5],o=e[6],l=e[7],d=e[8],f=e[9],p=e[10],h=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let _;e[18]!==s?(_=m.jsx("span",{children:s}),e[18]=s,e[19]=_):_=e[19];let y;e[20]!==a?(y=a>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted",children:"cost"}),m.jsxs("span",{children:["$",a.toFixed(4)]})]}),e[20]=a,e[21]=y):y=e[21];let T;e[22]!==_||e[23]!==y||e[24]!==u||e[25]!==o||e[26]!==l||e[27]!==d?(T=m.jsxs("div",{className:u,children:[o,l,d,_,y]}),e[22]=_,e[23]=y,e[24]=u,e[25]=o,e[26]=l,e[27]=d,e[28]=T):T=e[28];let I;e[29]!==r||e[30]!==T||e[31]!==f||e[32]!==p?(I=m.jsx(r,{side:f,className:p,children:T}),e[29]=r,e[30]=T,e[31]=f,e[32]=p,e[33]=I):I=e[33];let E;return e[34]!==i||e[35]!==I||e[36]!==h?(E=m.jsxs(i,{children:[h,I]}),e[34]=i,e[35]=I,e[36]=h,e[37]=E):E=e[37],E}const Kx={planning:{icon:m.jsx(Lu,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves"},thinking:{icon:m.jsx(Or,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking"}},Jx=1200;function e3(){const t=W.c(7),[e,n]=V.useState("planning");let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setTimeout(()=>{n("thinking")},Jx);return()=>{clearTimeout(o)}},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),V.useEffect(r,i);const a=Kx[e];let s;t[2]!==a.label?(s=m.jsxs("span",{className:"text-xs text-muted-foreground shimmer",children:[a.label,"..."]}),t[2]=a.label,t[3]=s):s=t[3];let u;return t[4]!==a.icon||t[5]!==s?(u=m.jsx("div",{className:"flex items-center gap-1.5 py-2 opacity-60",children:m.jsxs("span",{className:"flex items-center gap-1.5",children:[a.icon,s]})}),t[4]=a.icon,t[5]=s,t[6]=u):u=t[6],u}function t3(t){const e=W.c(10),{duration:n,parts:r,id:i}=t,a=n/1e3;let s;e[0]!==a?(s=a.toFixed(1),e[0]=a,e[1]=s):s=e[1];const u=s,[o,l]=V.useState(!1),[d,f]=V.useState(!1);let p;if(e[2]!==i||e[3]!==d||e[4]!==o||e[5]!==r||e[6]!==u){const h=r.filter(r3),g=h.some(n3),_=g||d;let y,T;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>l(!0),T=()=>l(!1),e[8]=y,e[9]=T):(y=e[8],T=e[9]),p=m.jsxs("div",{className:"flex flex-col mb-2",children:[m.jsx("button",{type:"button",onClick:()=>!g&&f(!d),onMouseEnter:y,onMouseLeave:T,className:le("flex items-center gap-1.5 py-2 opacity-60 transition-opacity",!g&&"cursor-pointer hover:opacity-100",g&&"cursor-default"),children:m.jsxs("span",{className:"flex items-center gap-1.5",children:[g?m.jsx(Or,{className:"text-muted-foreground shrink-0 shimmer",size:14}):o?m.jsx(Au,{className:le("text-muted-foreground transition-transform shrink-0",d&&"rotate-90"),size:14}):m.jsx(Ru,{className:"text-muted-foreground shrink-0",size:14}),m.jsx("span",{className:le("text-xs text-muted-foreground",g&&"shimmer"),children:g?"Thinking...":`Thought for ${u}s`})]})}),_&&m.jsx("div",{className:"ml-[6px] border-l-2 pl-4 mt-1 mb-2 max-h-[300px] overflow-y-auto",children:h.map((I,E)=>m.jsx("div",{className:"text-muted-foreground markdown-sm pb-2",children:m.jsx(Na,{id:`${i}-reasoning-${E}`,text:I.text})},`${i}-reasoning-${E}`))})]}),e[2]=i,e[3]=d,e[4]=o,e[5]=r,e[6]=u,e[7]=p}else p=e[7];return p}function n3(t){return t.state==="streaming"}function r3(t){return t.type==="reasoning"}function i3(t){const e=W.c(11),{part:n,id:r,usageStats:i,isFollowedByToolCall:a}=t;switch(n.type){case"dynamic-tool":{let s;return e[0]!==r||e[1]!==n?(s=m.jsx(pu,{part:n,id:r}),e[0]=r,e[1]=n,e[2]=s):s=e[2],s}case"text":{let s;return e[3]!==r||e[4]!==a||e[5]!==n||e[6]!==i?(s=m.jsx(fc,{id:r,part:n,extraActions:i,copyable:!0,hasToolCallAfter:a}),e[3]=r,e[4]=a,e[5]=n,e[6]=i,e[7]=s):s=e[7],s}case"reasoning":return null;case"step-start":case"file":case"source-url":case"source-document":return null;default:if(n.type.startsWith("tool-")){const s=n;let u;return e[8]!==r||e[9]!==s?(u=m.jsx(pu,{part:s,id:r}),e[8]=r,e[9]=s,e[10]=u):u=e[10],u}}throw new Error(`Unknown part type: ${n.type}`)}function a3(t){const e=W.c(32),{message:n,status:r,className:i}=t,{id:a,parts:s}=n,l=r==="streaming"||r==="submitted",d=V.useRef(null);let f;e[0]!==a?(f=()=>{const q=localStorage.getItem(`msg-duration-${a}`);return q?Number(q):null},e[0]=a,e[1]=f):f=e[1];const[p,h]=V.useState(f);let g,_;e[2]!==l?(g=()=>{l&&d.current===null&&(d.current=Date.now())},_=[l],e[2]=l,e[3]=g,e[4]=_):(g=e[3],_=e[4]),V.useEffect(g,_);let y,T;e[5]!==p||e[6]!==a||e[7]!==s.length?(y=()=>{if(s.length>0&&p===null&&d.current!==null){const q=Date.now()-d.current;h(q),localStorage.setItem(`msg-duration-${a}`,q.toString())}},T=[s.length,p,a],e[5]=p,e[6]=a,e[7]=s.length,e[8]=y,e[9]=T):(y=e[8],T=e[9]),V.useEffect(y,T);const I=s.length>0;let E;e[10]!==s?(E=s.some(u3),e[10]=s,e[11]=E):E=e[11];const R=E;let O;e[12]!==l||e[13]!==s?(O=l&&s.some(s3),e[12]=l,e[13]=s,e[14]=O):O=e[14];const v=I&&(R||O)&&p!==null;let B;e[15]!==n?(B=m.jsx(Zx,{messages:[n]}),e[15]=n,e[16]=B):B=e[16];const z=B;let N;e[17]!==i?(N=le("w-full min-w-0 group relative flex items-start gap-4 px-4 z-20 text-foreground flex-row",i),e[17]=i,e[18]=N):N=e[18];let F;e[19]!==p||e[20]!==I||e[21]!==a||e[22]!==l||e[23]!==s||e[24]!==v||e[25]!==z?(F=I?m.jsxs(m.Fragment,{children:[v&&m.jsx(t3,{duration:p,parts:s,id:a}),s.map((q,j)=>{const Z=s[j+1],te=Z&&(Z.type==="dynamic-tool"||Z.type.startsWith("tool-"));return m.jsx(i3,{part:q,id:a,usageStats:j===s.length-1?z:void 0,isFollowedByToolCall:te},`${a}-${j}`)})]}):l?m.jsx(e3,{}):null,e[19]=p,e[20]=I,e[21]=a,e[22]=l,e[23]=s,e[24]=v,e[25]=z,e[26]=F):F=e[26];let P;e[27]!==F?(P=m.jsx("div",{className:"flex flex-col min-w-0 w-full items-start",children:m.jsx("div",{className:"w-full min-w-0 not-only:rounded-2xl text-sm wrap-break-word overflow-wrap-anywhere bg-transparent",children:F})}),e[27]=F,e[28]=P):P=e[28];let X;return e[29]!==P||e[30]!==N?(X=m.jsx("div",{className:N,children:P}),e[29]=P,e[30]=N,e[31]=X):X=e[31],X}function s3(t){return t.type==="reasoning"&&t.state==="streaming"}function u3(t){return t.type==="reasoning"}const hc=V.createContext(null);function pc(t){const e=W.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx(m.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r}function o3(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!V.isValidElement(r))continue;if(r.props?.message?.role==="assistant"){const a=t[n-1],s=V.isValidElement(a)&&a.props?.message?.role,u=a&&V.isValidElement(a)&&s==="user"?a:null;e.push({user:u,assistant:r})}}return e}function l3(t){const e=W.c(27),{children:n,className:r,minHeightOffset:i}=t,a=V.useRef(null);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const u=V.useRef(s);let o,l,d,f,p,h,g;if(e[1]!==n||e[2]!==r||e[3]!==i){const I=V.Children.toArray(n),E=I[I.length-1];l=E&&V.isValidElement(E)&&E.type===pc?E:null;const R=l?I.slice(0,-1):I,O=o3(R);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=B=>{const z=u.current[B];if(z&&a.current){const N=a.current.offsetTop,F=z.offsetTop;a.current.scrollTo({top:F-N,behavior:"smooth"})}},e[11]=S):S=e[11];const v=S;o=hc.Provider,e[12]===Symbol.for("react.memo_cache_sentinel")?(g={scrollToPair:v},e[12]=g):g=e[12],p=a,e[13]!==r?(h=le("w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",r),e[13]=r,e[14]=h):h=e[14],d="flex flex-col min-w-0 max-w-2xl mx-auto w-full",f=O.map((B,z)=>{const N=z===O.length-1;return m.jsxs("div",{ref:F=>{u.current[z]=F},className:"flex flex-col pb-2",style:N&&i?{minHeight:`calc(100vh - ${i}px)`}:void 0,children:[m.jsx("div",{className:"sticky top-0 z-50 bg-background w-full h-4"}),m.jsx("div",{className:"sticky mb-3 top-4 z-50",children:B.user&&V.isValidElement(B.user)?V.cloneElement(B.user,{pairIndex:z}):B.user}),B.assistant]},z)}),e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=l,e[6]=d,e[7]=f,e[8]=p,e[9]=h,e[10]=g}else o=e[4],l=e[5],d=e[6],f=e[7],p=e[8],h=e[9],g=e[10];let _;e[15]!==l||e[16]!==d||e[17]!==f?(_=m.jsxs("div",{className:d,children:[f,l]}),e[15]=l,e[16]=d,e[17]=f,e[18]=_):_=e[18];let y;e[19]!==p||e[20]!==h||e[21]!==_?(y=m.jsx("div",{ref:p,className:h,children:_}),e[19]=p,e[20]=h,e[21]=_,e[22]=y):y=e[22];let T;return e[23]!==o||e[24]!==g||e[25]!==y?(T=m.jsx(o,{value:g,children:y}),e[23]=o,e[24]=g,e[25]=y,e[26]=T):T=e[26],T}function c3(t){const e=W.c(5),{locator:n}=Dt(),r=Mu(),i=Xi();let a;return e[0]!==n||e[1]!==r||e[2]!==t||e[3]!==i?(a=async(u,o,l)=>{const d=await Pu(n,l),f=d.findIndex(y=>y.id===u);if(f===-1){console.warn(`[branch] Message ${u} not found in thread ${l}`);return}const p=d.slice(0,f).filter(d3),h=crypto.randomUUID(),g=new Date().toISOString(),_={id:h,title:"",created_at:g,updated_at:g,hidden:!1};if(await i.insert.mutateAsync(_),p.length>0){const y=p.map(T=>({...T,id:crypto.randomUUID(),metadata:{...T.metadata,thread_id:h,created_at:T.metadata?.created_at||g}}));await r.insertMany.mutateAsync(y)}t(h)},e[0]=n,e[1]=r,e[2]=t,e[3]=i,e[4]=a):a=e[4],a}function d3(t){return t.role!=="system"}function f3(t){const e=W.c(18),{messageId:n,parts:r}=t,[i,a]=V.useState(!1),{setInputValue:s,startBranch:u,setActiveThreadId:o,activeThreadId:l}=mh(),d=c3(o);let f;e[0]!==r?(f=r.filter(p3).map(h3).join(`
98
98
  `),e[0]=r,e[1]=f):f=e[1];const p=f;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{S.stopPropagation(),a(!0)},e[2]=h):h=e[2];const g=h;let _;e[3]!==l||e[4]!==d||e[5]!==n||e[6]!==p||e[7]!==s||e[8]!==u?(_=async()=>{await d(n,p,l),s(p),u({originalThreadId:l,originalMessageId:n,originalMessageText:p}),a(!1)},e[3]=l,e[4]=d,e[5]=n,e[6]=p,e[7]=s,e[8]=u,e[9]=_):_=e[9];const y=_;let T;e[10]===Symbol.for("react.memo_cache_sentinel")?(T=m.jsx("div",{className:"flex justify-center items-end px-2 pb-1",children:m.jsxs(dn,{children:[m.jsx(fn,{asChild:!0,children:m.jsx(We,{onClick:g,variant:"ghost",size:"xs",className:"opacity-0 group-hover:opacity-100 hover:bg-gray-200/70 rounded-md transition-opacity text-muted-foreground hover:text-foreground aspect-square w-6 h-6 p-0",children:m.jsx(Nu,{size:16,className:"p-0.5"})})}),m.jsx(hn,{side:"bottom",children:"Edit message"})]})}),e[10]=T):T=e[10];let I;e[11]===Symbol.for("react.memo_cache_sentinel")?(I=m.jsxs(Gc,{children:[m.jsx(Xc,{children:"Edit message?"}),m.jsx(Zc,{children:"This will create a new conversation branch from this point. The original conversation will remain unchanged."})]}),e[11]=I):I=e[11];let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx(Kc,{children:"Cancel"}),e[12]=E):E=e[12];let R;e[13]!==y?(R=m.jsxs(Jc,{children:[I,m.jsxs(ed,{children:[E,m.jsx(td,{onClick:y,children:"Confirm"})]})]}),e[13]=y,e[14]=R):R=e[14];let O;return e[15]!==i||e[16]!==R?(O=m.jsxs(m.Fragment,{children:[T,m.jsx(nd,{open:i,onOpenChange:a,children:R})]}),e[15]=i,e[16]=R,e[17]=O):O=e[17],O}function h3(t){return t.text}function p3(t){return t.type==="text"}function m3(t){const e=W.c(29),{message:n,className:r,pairIndex:i}=t,{id:a,parts:s}=n,u=V.useContext(hc),[o,l]=V.useState(!1);if(!s||s.length===0)return null;let d;e[0]!==u||e[1]!==i?(d=()=>{l(!0),i!==void 0&&u?.scrollToPair(i)},e[0]=u,e[1]=i,e[2]=d):d=e[2];const f=d;let p;e[3]!==r?(p=le("message-block w-full min-w-0 group relative flex items-start gap-4 px-2.5 text-foreground flex-row-reverse",r),e[3]=r,e[4]=p):p=e[4];let h,g;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>l(!0),g=()=>l(!1),e[5]=h,e[6]=g):(h=e[5],g=e[6]);const _=o?"overflow-auto opacity-100":"overflow-hidden opacity-99 mask-b-from-1%";let y;e[7]!==_?(y=le("z-10 px-4 py-2 transition-opacity max-h-[120px] flex-1",_),e[7]=_,e[8]=y):y=e[8];let T;if(e[9]!==a||e[10]!==s){let v;e[12]!==a?(v=(B,z)=>B.type==="text"?m.jsx(fc,{id:a,part:B},`${a}-${z}`):null,e[12]=a,e[13]=v):v=e[13],T=s.map(v),e[9]=a,e[10]=s,e[11]=T}else T=e[11];let I;e[14]!==T?(I=m.jsx("div",{children:T}),e[14]=T,e[15]=I):I=e[15];let E;e[16]!==y||e[17]!==I?(E=m.jsx("div",{className:y,children:I}),e[16]=y,e[17]=I,e[18]=E):E=e[18];let R;e[19]!==a||e[20]!==s?(R=m.jsx(f3,{messageId:a,parts:s}),e[19]=a,e[20]=s,e[21]=R):R=e[21];let O;e[22]!==f||e[23]!==R||e[24]!==E?(O=m.jsxs("div",{tabIndex:0,onClick:f,onFocus:h,onBlur:g,className:"w-full border min-w-0 shadow-xs rounded-lg text-[0.9375rem] wrap-break-word overflow-wrap-anywhere bg-background cursor-pointer transition-colors relative flex outline-none",children:[E,R]}),e[22]=f,e[23]=R,e[24]=E,e[25]=O):O=e[25];let S;return e[26]!==O||e[27]!==p?(S=m.jsx(m.Fragment,{children:m.jsx("div",{className:p,children:O})}),e[26]=O,e[27]=p,e[28]=S):S=e[28],S}function g3(t,e){const n=W.c(4);let r;n[0]!==e?(r=e===void 0?{}:e,n[0]=e,n[1]=r):r=n[1];const i=r,a=t??ad;let s;return n[2]!==a?(s=ud(a),n[2]=a,n[3]=s):s=n[3],sd(a,"LLM",s,i)}const E3=["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"],$i=new Map;E3.forEach((t,e)=>{$i.set(t,e)});function b3(){const t=W.c(9),e=od();let n;t[0]!==e?(n={connections:e,binding:"LLMS"},t[0]=e,t[1]=n):n=t[1];const[r]=Pc(n);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i={pageSize:999},t[2]=i):i=t[2];const a=g3(r?.id,i);if(!a||!r){let o;return t[3]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[3]=o):o=t[3],o}let s;if(t[4]!==r||t[5]!==a){let o;t[7]!==r?(o=l=>({...l,name:l.title,contextWindow:l.limits?.contextWindow,outputLimit:l.limits?.maxOutputTokens,inputCost:l.costs?.input,outputCost:l.costs?.output,provider:l.provider,connectionId:r.id,connectionName:r.title}),t[7]=r,t[8]=o):o=t[8],s=a.filter(x3).map(o).sort(T3),t[4]=r,t[5]=a,t[6]=s}else s=t[6];return s}function T3(t,e){const n=$i.get(t.id),r=$i.get(e.id);return n!==void 0&&r!==void 0?n-r:n!==void 0?-1:r!==void 0?1:t.name.localeCompare(e.name)}function x3(t){return t.limits?.contextWindow&&t.limits?.maxOutputTokens}const _3={reasoning:{icon:m.jsx(Or,{className:"size-4"}),bg:"bg-purple-100",text:"text-purple-700",label:"Reasoning"},"image-upload":{icon:m.jsx(wu,{className:"size-4"}),bg:"bg-teal-100",text:"text-teal-700",label:"Can analyze images"},"file-upload":{icon:m.jsx(rd,{className:"size-4"}),bg:"bg-blue-100",text:"text-blue-700",label:"Can analyze files"},"web-search":{icon:m.jsx(Qi,{className:"size-4"}),bg:"bg-amber-100",text:"text-amber-700",label:"Can search the web to answer questions"}},mc=V.memo(function(e){const n=W.c(11),{capability:r}=e,i=_3[r];let a;n[0]!==r||n[1]!==i?(a=i||{icon:m.jsx(sn,{className:"size-4"}),bg:"bg-slate-200",text:"text-slate-700",label:r},n[0]=r,n[1]=i,n[2]=a):a=n[2];const s=a,u=`flex items-center justify-center h-6 w-6 rounded-sm ${s.bg} ${s.text}`;let o;n[3]!==s.icon||n[4]!==u?(o=m.jsx(fn,{asChild:!0,children:m.jsx("div",{className:u,children:s.icon})}),n[3]=s.icon,n[4]=u,n[5]=o):o=n[5];let l;n[6]!==s.label?(l=m.jsx(hn,{children:m.jsx("p",{children:s.label})}),n[6]=s.label,n[7]=l):l=n[7];let d;return n[8]!==o||n[9]!==l?(d=m.jsxs(dn,{children:[o,l]}),n[8]=o,n[9]=l,n[10]=d):d=n[10],d}),mu=V.memo(function(e){const n=W.c(54),{model:r,compact:i}=e,a=i===void 0?!1:i;if(!r){let T;return n[0]===Symbol.for("react.memo_cache_sentinel")?(T=m.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Hover to preview"}),n[0]=T):T=n[0],T}const s=r.contextWindow||r.inputCost||r.outputCost||r.outputLimit;if(!s&&!a){let T;n[1]!==r.logo||n[2]!==r.name?(T=r.logo&&m.jsx("img",{src:r.logo,className:"w-6 h-6",alt:r.name}),n[1]=r.logo,n[2]=r.name,n[3]=T):T=n[3];let I;n[4]!==r.name?(I=m.jsx("p",{className:"text-lg font-medium leading-7",children:r.name}),n[4]=r.name,n[5]=I):I=n[5];let E;n[6]!==T||n[7]!==I?(E=m.jsxs("div",{className:"flex items-center gap-3 py-2 px-0",children:[T,I]}),n[6]=T,n[7]=I,n[8]=E):E=n[8];let R;n[9]!==r.description?(R=r.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:r.description}),n[9]=r.description,n[10]=R):R=n[10];let O;return n[11]!==E||n[12]!==R?(O=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[E,R]}),n[11]=E,n[12]=R,n[13]=O):O=n[13],O}if(!s&&a)return null;if(a){let T;n[14]!==r.contextWindow?(T=r.contextWindow&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Context"}),m.jsxs("span",{className:"text-foreground font-medium",children:[r.contextWindow.toLocaleString()," tokens"]})]}),n[14]=r.contextWindow,n[15]=T):T=n[15];let I;n[16]!==r.inputCost?(I=r.inputCost&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Input cost"}),m.jsxs("span",{className:"text-foreground font-medium",children:["$",r.inputCost.toFixed(2)," / 1M"]})]}),n[16]=r.inputCost,n[17]=I):I=n[17];let E;n[18]!==r.outputCost?(E=r.outputCost&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Output cost"}),m.jsxs("span",{className:"text-foreground font-medium",children:["$",r.outputCost.toFixed(2)," / 1M"]})]}),n[18]=r.outputCost,n[19]=E):E=n[19];let R;n[20]!==r.outputLimit?(R=r.outputLimit&&m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),m.jsxs("span",{className:"text-foreground font-medium",children:[r.outputLimit.toLocaleString()," tokens"]})]}),n[20]=r.outputLimit,n[21]=R):R=n[21];let O;return n[22]!==T||n[23]!==I||n[24]!==E||n[25]!==R?(O=m.jsxs("div",{className:"flex flex-col gap-2.5 pt-3 pb-3 px-3 rounded-b-lg text-xs",children:[T,I,E,R]}),n[22]=T,n[23]=I,n[24]=E,n[25]=R,n[26]=O):O=n[26],O}let u;n[27]!==r.logo||n[28]!==r.name?(u=r.logo&&m.jsx("img",{src:r.logo,className:"w-6 h-6",alt:r.name}),n[27]=r.logo,n[28]=r.name,n[29]=u):u=n[29];let o;n[30]!==r.name?(o=m.jsx("p",{className:"text-lg font-medium leading-7",children:r.name}),n[30]=r.name,n[31]=o):o=n[31];let l;n[32]!==u||n[33]!==o?(l=m.jsxs("div",{className:"flex items-center gap-3",children:[u,o]}),n[32]=u,n[33]=o,n[34]=l):l=n[34];let d;n[35]!==r.capabilities?(d=r.capabilities&&r.capabilities.length>0&&m.jsx("div",{className:"flex items-center gap-2",children:r.capabilities.map(k3)}),n[35]=r.capabilities,n[36]=d):d=n[36];let f;n[37]!==l||n[38]!==d?(f=m.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[l,d]}),n[37]=l,n[38]=d,n[39]=f):f=n[39];let p;n[40]!==r.contextWindow?(p=r.contextWindow&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Uc,{className:"w-3.5 h-3.5 text-muted-foreground"}),m.jsx("p",{className:"text-sm text-foreground",children:"Context window"})]}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.contextWindow.toLocaleString()," tokens"]})]}),n[40]=r.contextWindow,n[41]=p):p=n[41];let h;n[42]!==r.inputCost||n[43]!==r.outputCost?(h=(r.inputCost||r.outputCost)&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Su,{className:"w-3.5 h-3.5 text-muted-foreground"}),m.jsx("p",{className:"text-sm text-foreground",children:"Costs"})]}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.inputCost!==null&&r.inputCost!==void 0&&m.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",r.inputCost.toFixed(2)," / 1M tokens (input)"]}),r.outputCost!==null&&r.outputCost!==void 0&&m.jsxs("p",{className:"text-sm text-muted-foreground",children:["$",r.outputCost.toFixed(2)," / 1M tokens (output)"]})]})]}),n[42]=r.inputCost,n[43]=r.outputCost,n[44]=h):h=n[44];let g;n[45]!==r.outputLimit?(g=r.outputLimit&&m.jsxs("div",{className:"flex flex-col gap-1.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Ou,{className:"w-4.5 h-4.5 text-muted-foreground/70"}),m.jsx("p",{className:"text-sm text-foreground",children:"Output limit"})]}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.outputLimit.toLocaleString()," token limit"]})]}),n[45]=r.outputLimit,n[46]=g):g=n[46];let _;n[47]!==p||n[48]!==h||n[49]!==g?(_=m.jsxs("div",{className:"flex flex-col gap-4",children:[p,h,g]}),n[47]=p,n[48]=h,n[49]=g,n[50]=_):_=n[50];let y;return n[51]!==_||n[52]!==f?(y=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[f,_]}),n[51]=_,n[52]=f,n[53]=y):y=n[53],y}),y3=V.memo(function(e){const n=W.c(27),{model:r,onHover:i,isSelected:a,hasExpandedInfo:s}=e,u=s?"rounded-t-lg":"rounded-lg";let o;n[0]!==u?(o=le("flex items-center gap-2 h-10 py-4 px-3 hover:bg-accent cursor-pointer",u),n[0]=u,n[1]=o):o=n[1];let l;n[2]!==r||n[3]!==i?(l=()=>i(r),n[2]=r,n[3]=i,n[4]=l):l=n[4];let d;n[5]!==r.logo||n[6]!==r.name?(d=r.logo&&m.jsx("img",{src:r.logo,className:"w-5 h-5 shrink-0",alt:r.name}),n[5]=r.logo,n[6]=r.name,n[7]=d):d=n[7];let f;n[8]!==r.name?(f=m.jsx("span",{className:"text-sm text-foreground",children:r.name}),n[8]=r.name,n[9]=f):f=n[9];let p;n[10]!==s||n[11]!==r.capabilities?(p=s&&r.capabilities&&r.capabilities.length>0&&m.jsx("div",{className:"md:hidden flex items-center gap-1.5 ml-auto",children:r.capabilities.map(C3)}),n[10]=s,n[11]=r.capabilities,n[12]=p):p=n[12];let h;n[13]!==s||n[14]!==a?(h=a&&!s&&m.jsx(sn,{className:"w-4 h-4 text-foreground ml-auto"}),n[13]=s,n[14]=a,n[15]=h):h=n[15];let g;n[16]!==s||n[17]!==a?(g=a&&s&&m.jsx(sn,{className:"w-4 h-4 text-foreground ml-2 shrink-0"}),n[16]=s,n[17]=a,n[18]=g):g=n[18];let _;return n[19]!==o||n[20]!==l||n[21]!==d||n[22]!==f||n[23]!==p||n[24]!==h||n[25]!==g?(_=m.jsxs("div",{className:o,onMouseEnter:l,children:[d,f,p,h,g]}),n[19]=o,n[20]=l,n[21]=d,n[22]=f,n[23]=p,n[24]=h,n[25]=g,n[26]=_):_=n[26],_});function A3(t){const e=W.c(9),{model:n}=t;if(!n){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("span",{className:"text-sm text-muted-foreground",children:"Select model"}),e[0]=s):s=e[0],s}let r;e[1]!==n.logo||e[2]!==n.name?(r=n.logo&&m.jsx("img",{src:n.logo,className:"w-5 h-5 shrink-0 rounded-sm",alt:n.name}),e[1]=n.logo,e[2]=n.name,e[3]=r):r=e[3];let i;e[4]!==n.name?(i=m.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors truncate min-w-0 max-w-[200px] hidden sm:inline-block",children:n.name}),e[4]=n.name,e[5]=i):i=e[5];let a;return e[6]!==r||e[7]!==i?(a=m.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-w-full",children:[r,i]}),e[6]=r,e[7]=i,e[8]=a):a=e[8],a}function p_(t){const e=W.c(67),{selectedModel:n,onModelChange:r,variant:i,className:a,placeholder:s}=t,u=i===void 0?"borderless":i,o=s===void 0?"Select model":s,[l,d]=V.useState(!1),[f,p]=V.useState(null),[h,g]=V.useState(!1),[_,y]=V.useState(""),T=V.useRef(null),I=b3();let E,R;e[0]!==l?(E=()=>{l&&setTimeout(()=>{T.current?.focus()},0)},R=[l],e[0]=l,e[1]=E,e[2]=R):(E=e[1],R=e[2]),V.useEffect(E,R);let O;e[3]!==I||e[4]!==n?(O=n?I.find(fe=>fe.id===n.id&&fe.connectionId===n.connectionId)?.id:void 0,e[3]=I,e[4]=n,e[5]=O):O=e[5];const S=O;let v;if(e[6]!==I||e[7]!==S){let fe;e[9]!==S?(fe=Je=>Je.id===S,e[9]=S,e[10]=fe):fe=e[10],v=I.find(fe),e[6]=I,e[7]=S,e[8]=v}else v=e[8];const B=v;let z;e:{if(!_.trim()){z=I;break e}let fe;if(e[11]!==I||e[12]!==_){const Je=_.toLowerCase();fe=I.filter(At=>At.name.toLowerCase().includes(Je)||At.provider?.toLowerCase().includes(Je)||At.description?.toLowerCase().includes(Je)),e[11]=I,e[12]=_,e[13]=fe}else fe=e[13];z=fe}const N=z;let F;e[14]!==I||e[15]!==r?(F=fe=>{const Je=I.find(At=>At.id===fe);Je&&(r({id:Je.id,connectionId:Je.connectionId,provider:Je.provider??void 0}),y(""),d(!1))},e[14]=I,e[15]=r,e[16]=F):F=e[16];const P=F;let X;e[17]===Symbol.for("react.memo_cache_sentinel")?(X=fe=>{d(fe),fe||y("")},e[17]=X):X=e[17];const q=X;if(I.length===0)return null;const j=S||"",Z=u==="borderless"&&"md:border-none";let te;e[18]!==a||e[19]!==Z?(te=le("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 max-w-full",Z,a),e[18]=a,e[19]=Z,e[20]=te):te=e[20];let K;e[21]!==B?(K=m.jsx(A3,{model:B}),e[21]=B,e[22]=K):K=e[22];let ce;e[23]!==o||e[24]!==K?(ce=m.jsx(jc,{placeholder:o,className:"min-w-0 max-w-full",children:K}),e[23]=o,e[24]=K,e[25]=ce):ce=e[25];let k;e[26]!==te||e[27]!==ce?(k=m.jsx(zc,{size:"sm",className:te,children:ce}),e[26]=te,e[27]=ce,e[28]=k):k=e[28];let ae;e[29]!==h?(ae=()=>g(!h),e[29]=h,e[30]=ae):ae=e[30];const xe=h?"text-foreground":"text-muted-foreground";let C;e[31]!==xe?(C=le("w-5 h-5 transition-colors",xe),e[31]=xe,e[32]=C):C=e[32];let ke;e[33]!==C?(ke=m.jsx(id,{className:C}),e[33]=C,e[34]=ke):ke=e[34];let Ie;e[35]!==ae||e[36]!==ke?(Ie=m.jsx("button",{type:"button",onClick:ae,className:"md:hidden flex items-center justify-center h-8 w-8 rounded-lg hover:bg-accent transition-colors","aria-label":"Toggle model info",children:ke}),e[35]=ae,e[36]=ke,e[37]=Ie):Ie=e[37];let me;e[38]===Symbol.for("react.memo_cache_sentinel")?(me=m.jsx(Qi,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[38]=me):me=e[38];let Ne;e[39]===Symbol.for("react.memo_cache_sentinel")?(Ne=fe=>y(fe.target.value),e[39]=Ne):Ne=e[39];let _e;e[40]!==_?(_e=m.jsx("div",{className:"border-b px-4 py-3 bg-background/95 backdrop-blur sticky top-0 z-10",children:m.jsxs("div",{className:"relative",children:[me,m.jsx(Dc,{ref:T,type:"text",placeholder:"Search for a model...",value:_,onChange:Ne,className:"pl-9 h-9 text-sm border-0 focus-visible:ring-0 focus-visible:ring-offset-0 shadow-none"})]})}),e[40]=_,e[41]=_e):_e=e[41];let we;e[42]!==N||e[43]!==P||e[44]!==S||e[45]!==h?(we=N.length>0?N.map(fe=>m.jsxs("div",{onClick:()=>P(fe.id),className:le("rounded-lg mb-1",fe.id===S&&"bg-accent"),children:[m.jsx(y3,{model:fe,onHover:p,isSelected:fe.id===S,hasExpandedInfo:h}),h&&m.jsx("div",{className:"md:hidden",children:m.jsx(mu,{model:fe,compact:!0})})]},fe.id)):m.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No models found"}),e[42]=N,e[43]=P,e[44]=S,e[45]=h,e[46]=we):we=e[46];let Se;e[47]!==we?(Se=m.jsx("div",{className:"flex-1 overflow-y-auto px-0.5",children:we}),e[47]=we,e[48]=Se):Se=e[48];let Oe;e[49]!==_e||e[50]!==Se?(Oe=m.jsxs("div",{className:"flex-1 flex flex-col md:border-r",children:[_e,Se]}),e[49]=_e,e[50]=Se,e[51]=Oe):Oe=e[51];const ot=f||B||null;let De;e[52]!==ot?(De=m.jsx("div",{className:"hidden md:block md:w-[300px] p-3",children:m.jsx(mu,{model:ot})}),e[52]=ot,e[53]=De):De=e[53];let yt;e[54]!==Oe||e[55]!==De?(yt=m.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[Oe,De]}),e[54]=Oe,e[55]=De,e[56]=yt):yt=e[56];let mt;e[57]!==o||e[58]!==Ie||e[59]!==yt?(mt=m.jsx($c,{title:o,className:"w-full md:w-auto md:min-w-[600px] [&_button[aria-label='Scroll down']]:!hidden [&_button[aria-label='Scroll up']]:!hidden",headerActions:Ie,children:yt}),e[57]=o,e[58]=Ie,e[59]=yt,e[60]=mt):mt=e[60];let Mt;return e[61]!==P||e[62]!==l||e[63]!==j||e[64]!==k||e[65]!==mt?(Mt=m.jsxs(Yc,{open:l,onOpenChange:q,value:j,onValueChange:P,children:[k,mt]}),e[61]=P,e[62]=l,e[63]=j,e[64]=k,e[65]=mt,e[66]=Mt):Mt=e[66],Mt}function k3(t){return m.jsx(mc,{capability:t},t)}function C3(t){return m.jsx(mc,{capability:t},t)}function I3({messageCount:t,sentinelRef:e}){const n=V.useRef(t),r=V.useRef(0);t>n.current&&r.current!==t&&queueMicrotask(()=>{e.current?.scrollIntoView({behavior:"smooth",block:"start"}),r.current=t}),n.current=t}function gu(t,e){const n=V.Children.toArray(t);for(const r of n)if(V.isValidElement(r)&&r.type===e)return r;return null}function S3(t){const e=W.c(5),{className:n,children:r}=t;let i;e[0]!==n?(i=le("flex flex-col h-full w-full bg-sidebar transform-[translateZ(0)]",n),e[0]=n,e[1]=i):i=e[1];let a;return e[2]!==r||e[3]!==i?(a=m.jsx("div",{className:i,children:r}),e[2]=r,e[3]=i,e[4]=a):a=e[4],a}function N3(t){const e=W.c(11),{children:n}=t;let r;e[0]!==n?(r=gu(n,gc),e[0]=n,e[1]=r):r=e[1];const i=r;let a;e[2]!==n?(a=gu(n,Ec),e[2]=n,e[3]=a):a=e[3];const s=a,u=i?.props.children;let o;e[4]!==u?(o=m.jsx("div",{className:"flex items-center gap-2",children:u}),e[4]=u,e[5]=o):o=e[5];const l=s?.props.children;let d;e[6]!==l?(d=m.jsx("div",{className:"flex items-center gap-1",children:l}),e[6]=l,e[7]=d):d=e[7];let f;return e[8]!==o||e[9]!==d?(f=m.jsxs("div",{className:"flex h-12 items-center justify-between border-b border-border px-4 flex-none",children:[o,d]}),e[8]=o,e[9]=d,e[10]=f):f=e[10],f}function gc(t){const e=W.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx(m.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r}function Ec(t){const e=W.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx(m.Fragment,{children:n}),e[0]=n,e[1]=r):r=e[1],r}function w3(t){const e=W.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=le("flex-1 min-h-0 overflow-y-auto",r),e[0]=r,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==i?(a=m.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a}function R3(t){const e=W.c(2),{children:n}=t;let r;return e[0]!==n?(r=m.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:n}),e[0]=n,e[1]=r):r=e[1],r}function O3(t){const e=W.c(12),{messages:n,status:r,minHeightOffset:i}=t,a=i===void 0?240:i,s=V.useRef(null);let u;e[0]!==n.length?(u={messageCount:n.length,sentinelRef:s},e[0]=n.length,e[1]=u):u=e[1],I3(u);let o;if(e[2]!==n||e[3]!==r){let f;e[5]!==n.length||e[6]!==r?(f=(p,h)=>p.role==="user"?m.jsx(m3,{message:p},p.id):p.role==="assistant"?m.jsx(a3,{message:p,status:h===n.length-1?r:void 0},p.id):null,e[5]=n.length,e[6]=r,e[7]=f):f=e[7],o=n.map(f),e[2]=n,e[3]=r,e[4]=o}else o=e[4];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx(pc,{children:m.jsx("div",{ref:s,className:"h-0"})}),e[8]=l):l=e[8];let d;return e[9]!==a||e[10]!==o?(d=m.jsxs(l3,{minHeightOffset:a,children:[o,l]}),e[9]=a,e[10]=o,e[11]=d):d=e[11],d}function L3(t){const e=W.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=le("flex-none w-full mx-auto p-2","max-w-2xl min-w-0",r),e[0]=r,e[1]=i):i=e[1];let a;return e[2]!==n||e[3]!==i?(a=m.jsx("div",{className:i,children:n}),e[2]=n,e[3]=i,e[4]=a):a=e[4],a}function wa(t){const e=W.c(24),{title:n,description:r,icon:i,variant:a,onDismiss:s,children:u}=t,o=a===void 0?"default":a;let l,d,f,p,h;if(e[0]!==u||e[1]!==r||e[2]!==i||e[3]!==n||e[4]!==o){const E={default:{container:"border-muted-foreground/30 bg-muted/50 hover:bg-muted transition-colors",icon:"text-muted-foreground",title:"text-muted-foreground",description:"text-muted-foreground/70"},danger:{container:"border-destructive/30 bg-destructive/5",icon:"text-destructive",title:"text-destructive font-medium",description:"text-muted-foreground"},warning:{container:"border-amber-500/30 bg-amber-500/5",icon:"text-amber-600 dark:text-amber-500",title:"text-amber-600 dark:text-amber-500 font-medium",description:"text-muted-foreground"}}[o];p=le("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full",E.container),h=i&&m.jsx("div",{className:le("mt-0.5 shrink-0",E.icon),children:i}),l="flex-1 min-w-0",d=n&&m.jsx("div",{className:le("text-xs mb-1",E.title),children:n}),f=r&&m.jsx("div",{className:le("text-xs line-clamp-2",E.description,u?"mb-2":""),children:r}),e[0]=u,e[1]=r,e[2]=i,e[3]=n,e[4]=o,e[5]=l,e[6]=d,e[7]=f,e[8]=p,e[9]=h}else l=e[5],d=e[6],f=e[7],p=e[8],h=e[9];let g;e[10]!==u?(g=u&&m.jsx("div",{className:"flex gap-2",children:u}),e[10]=u,e[11]=g):g=e[11];let _;e[12]!==l||e[13]!==d||e[14]!==f||e[15]!==g?(_=m.jsxs("div",{className:l,children:[d,f,g]}),e[12]=l,e[13]=d,e[14]=f,e[15]=g,e[16]=_):_=e[16];let y;e[17]!==s?(y=s&&m.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:m.jsx(Bc,{size:14})}),e[17]=s,e[18]=y):y=e[18];let T;return e[19]!==p||e[20]!==h||e[21]!==_||e[22]!==y?(T=m.jsxs("div",{className:p,children:[h,_,y]}),e[19]=p,e[20]=h,e[21]=_,e[22]=y,e[23]=T):T=e[23],T}function D3(t){const e=W.c(10),{branchContext:n,clearBranchContext:r,onGoToOriginalMessage:i,setInputValue:a}=t;if(!n)return null;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx(Iu,{size:14}),e[0]=s):s=e[0];let u;e[1]!==r||e[2]!==a?(u=()=>{r(),a("")},e[1]=r,e[2]=a,e[3]=u):u=e[3];let o;e[4]!==i?(o=m.jsx(We,{size:"sm",variant:"outline",onClick:i,className:"h-7 text-xs",children:"View original"}),e[4]=i,e[5]=o):o=e[5];let l;return e[6]!==n.originalMessageText||e[7]!==u||e[8]!==o?(l=m.jsx(wa,{variant:"default",title:"Editing message (click to view original)",description:n.originalMessageText,icon:s,onDismiss:u,children:o}),e[6]=n.originalMessageText,e[7]=u,e[8]=o,e[9]=l):l=e[9],l}function v3(t){const e=W.c(8),{error:n,onFixInChat:r,onDismiss:i}=t;if(!n)return null;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx(yu,{size:16}),e[0]=a):a=e[0];let s;e[1]!==r?(s=m.jsx(We,{size:"sm",variant:"outline",onClick:r,className:"h-7 text-xs",children:"Fix in chat"}),e[1]=r,e[2]=s):s=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(We,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"}),e[3]=u):u=e[3];let o;return e[4]!==n.message||e[5]!==i||e[6]!==s?(o=m.jsxs(wa,{variant:"danger",title:"Error occurred",description:n.message,icon:a,onDismiss:i,children:[s,u]}),e[4]=n.message,e[5]=i,e[6]=s,e[7]=o):o=e[7],o}function P3(t){const e=W.c(7),{finishReason:n,onContinue:r,onDismiss:i}=t;if(!n||n==="stop")return null;const s=M3(n);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(Mc,{size:16}),e[0]=u):u=e[0];let o;e[1]!==r?(o=m.jsx(We,{size:"sm",variant:"outline",onClick:r,className:"h-7 text-xs",children:"Continue"}),e[1]=r,e[2]=o):o=e[2];let l;return e[3]!==i||e[4]!==s||e[5]!==o?(l=m.jsx(wa,{variant:"warning",title:"Response incomplete",description:s,icon:u,onDismiss:i,children:o}),e[3]=i,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function M3(t){switch(t){case"length":return"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.";case"content-filter":return"Response was filtered due to content policy.";case"tool-calls":return"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working.";default:return`Response stopped unexpectedly: ${t}`}}const m_=Object.assign(S3,{Header:Object.assign(N3,{Left:gc,Right:Ec}),Main:w3,Messages:O3,EmptyState:R3,Footer:L3,Input:xh,BranchPreview:D3,ErrorBanner:v3,FinishReasonWarning:P3,Provider:hh});function g_({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",orgSlug:n,orgId:r,userId:i,allConnections:a,onInstallMcpServer:s}){const[u,o]=V.useState(!1),l=ld(),d=Lc(),f=async()=>{if(!r||!i){Ei.error("Not authenticated");return}o(!0);try{const p=a?.find(_=>_.connection_url===fd);if(p){d({to:"/$org/mcps/$connectionId",params:{org:n,connectionId:p.id}});return}const h=hd({id:pd("conn")}),g=await l.create.mutateAsync(h);d({to:"/$org/mcps/$connectionId",params:{org:n,connectionId:g.id}})}catch(p){Ei.error(`Failed to connect OpenRouter: ${p instanceof Error?p.message:String(p)}`)}finally{o(!1)}};return m.jsx(cd,{image:m.jsx("img",{src:"/empty-state-openrouter.svg",alt:"",width:336,height:320,"aria-hidden":"true",className:"w-xs h-auto mask-radial-[100%_100%] mask-radial-from-20% mask-radial-to-50% mask-radial-at-center"}),title:t,description:e,actions:m.jsxs(m.Fragment,{children:[m.jsxs(We,{variant:"outline",onClick:f,disabled:u,children:[m.jsx("img",{src:dd,alt:"OpenRouter",className:"size-4"}),u?"Installing...":"Install OpenRouter"]}),m.jsx(We,{variant:"outline",onClick:s,children:"Install Connection"})]})})}function B3(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5);return i<1?"now":i<60?`${i}m`:`${a}h`}function F3(t){const e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-7*864e5),a=new Date(n.getTime()-30*864e5),s=[],u=[],o=[],l=[],d=[];for(const p of t){const h=new Date(p.updated_at);h>=n?s.push(p):h>=r?u.push(p):h>=i?o.push(p):h>=a?l.push(p):d.push(p)}const f=[];return s.length>0&&f.push({label:"Today",threads:s,showRelativeTime:!0}),u.length>0&&f.push({label:"Yesterday",threads:u,showRelativeTime:!1}),o.length>0&&f.push({label:"7 days ago",threads:o,showRelativeTime:!1}),l.length>0&&f.push({label:"30 days ago",threads:l,showRelativeTime:!1}),d.length>0&&f.push({label:"Older",threads:d,showRelativeTime:!1}),f}function E_(t){const e=W.c(49),{threads:n,activeThreadId:r,onSelectThread:i,onRemoveThread:a,onOpen:s,variant:u}=t,o=u===void 0?"icon":u,[l,d]=V.useState("");let f,p,h,g,_,y,T,I,E,R,O,S;if(e[0]!==r||e[1]!==s||e[2]!==a||e[3]!==i||e[4]!==l||e[5]!==n||e[6]!==o){const P=l.trim()?n.filter(K=>(K.title||"New chat").toLowerCase().includes(l.toLowerCase())):n,X=F3(P);let q;e[19]!==s?(q=K=>{K?s?.():d("")},e[19]=s,e[20]=q):q=e[20];const j=q;g=bu,h=dn,p=Tu,R=j,e[21]!==o?(O=m.jsx(fn,{asChild:!0,children:m.jsx(xu,{asChild:!0,children:o==="outline"?m.jsx(We,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:m.jsx(Oa,{size:16})}):m.jsx(We,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:m.jsx(Oa,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[21]=o,e[22]=O):O=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx(hn,{children:"Chat history"}),e[23]=S):S=e[23],f=_u,T="end",I="w-80 p-0";let Z;e[24]===Symbol.for("react.memo_cache_sentinel")?(Z=m.jsx(Qi,{size:16,className:"text-muted-foreground shrink-0"}),e[24]=Z):Z=e[24];let te;e[25]===Symbol.for("react.memo_cache_sentinel")?(te=K=>d(K.target.value),e[25]=te):te=e[25],e[26]!==l?(E=m.jsx("div",{className:"border-b",children:m.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[Z,m.jsx("input",{type:"text",placeholder:"Search chats...",value:l,onChange:te,className:"flex-1 border-0 shadow-none focus:outline-none px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[26]=l,e[27]=E):E=e[27],_="max-h-[300px] overflow-y-auto",y=P.length===0?m.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:l.trim()?"No chats found":"No chats yet"}):X.map((K,ce)=>m.jsxs("div",{children:[ce>0&&m.jsx("div",{className:"border-t mx-3"}),m.jsx("div",{className:"px-3 py-1",children:m.jsx("span",{className:"text-xs font-medium text-muted-foreground tracking-wide",children:K.label})}),K.threads.map(k=>{const ae=k.id===r;return m.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group ${ae?"bg-accent/50":""}`,onClick:()=>i(k.id),children:[m.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[m.jsx("span",{className:"text-sm truncate",children:k.title||"New chat"}),m.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:ae?"current":K.showRelativeTime?B3(k.updated_at):null})]}),m.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),a(k.id)},className:"opacity-0 cursor-pointer group/trash group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",title:"Remove chat",children:m.jsx(md,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},k.id)})]},K.label)),e[0]=r,e[1]=s,e[2]=a,e[3]=i,e[4]=l,e[5]=n,e[6]=o,e[7]=f,e[8]=p,e[9]=h,e[10]=g,e[11]=_,e[12]=y,e[13]=T,e[14]=I,e[15]=E,e[16]=R,e[17]=O,e[18]=S}else f=e[7],p=e[8],h=e[9],g=e[10],_=e[11],y=e[12],T=e[13],I=e[14],E=e[15],R=e[16],O=e[17],S=e[18];let v;e[28]!==_||e[29]!==y?(v=m.jsx("div",{className:_,children:y}),e[28]=_,e[29]=y,e[30]=v):v=e[30];let B;e[31]!==f||e[32]!==v||e[33]!==T||e[34]!==I||e[35]!==E?(B=m.jsxs(f,{align:T,className:I,children:[E,v]}),e[31]=f,e[32]=v,e[33]=T,e[34]=I,e[35]=E,e[36]=B):B=e[36];let z;e[37]!==p||e[38]!==B||e[39]!==R||e[40]!==O||e[41]!==S?(z=m.jsxs(p,{onOpenChange:R,children:[O,S,B]}),e[37]=p,e[38]=B,e[39]=R,e[40]=O,e[41]=S,e[42]=z):z=e[42];let N;e[43]!==h||e[44]!==z?(N=m.jsx(h,{children:z}),e[43]=h,e[44]=z,e[45]=N):N=e[45];let F;return e[46]!==g||e[47]!==N?(F=m.jsx(g,{children:N}),e[46]=g,e[47]=N,e[48]=F):F=e[48],F}export{m_ as C,o_ as D,h_ as G,p_ as M,g_ as N,E_ as T,Zx as U,l_ as a,b3 as b,c_ as c,f_ as d,hh as e,xh as f,mh as u};