@decocms/mesh 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-beBfBGLE.js → AlertCircle-DoPcYOmu.js} +1 -1
- package/dist/client/assets/{ArrowLeft-CroYwrK6.js → ArrowLeft-Cho91gJm.js} +1 -1
- package/dist/client/assets/{ChevronDown-DXHLdlIt.js → ChevronDown--_znWqhO.js} +1 -1
- package/dist/client/assets/{Clock-C6mLHJve.js → Clock-OrKCoBnu.js} +1 -1
- package/dist/client/assets/{Code01-BDWiikWg.js → Code01-COExI_48.js} +1 -1
- package/dist/client/assets/{Copy01-BVT45tzW.js → Copy01-CdCXGmeI.js} +1 -1
- package/dist/client/assets/{CpuChip02-CGJDeKm0.js → CpuChip02-D26L6TWX.js} +1 -1
- package/dist/client/assets/{DotsVertical-CSDPmiif.js → DotsVertical-kYh71Jmo.js} +1 -1
- package/dist/client/assets/{File06-CZuMuvHc.js → File06-D4-QxuCL.js} +1 -1
- package/dist/client/assets/{GitBranch01-BKnlEtpX.js → GitBranch01-irv8ZOt4.js} +1 -1
- package/dist/client/assets/{Inbox01-mFkubxJS.js → Inbox01-CEpI9Sk9.js} +1 -1
- package/dist/client/assets/{InfoCircle-DVoXsuXL.js → InfoCircle-BH6ukjrt.js} +1 -1
- package/dist/client/assets/{Key01-oEI5T85a.js → Key01-BvGYoGe8.js} +1 -1
- package/dist/client/assets/{LinkExternal01-D3EWn3rZ.js → LinkExternal01-C8zs3bR9.js} +1 -1
- package/dist/client/assets/{Loading01-9Hh2mqjl.js → Loading01-DcFBMaXj.js} +1 -1
- package/dist/client/assets/{Lock01-vdbtpZWU.js → Lock01-IqrEd301.js} +1 -1
- package/dist/client/assets/{Play-BkEnJGbk.js → Play-0EPVk_yg.js} +1 -1
- package/dist/client/assets/{Plus-A0qZ38lG.js → Plus-C--SWih9.js} +1 -1
- package/dist/client/assets/{SearchMd-B2Mied73.js → SearchMd-DiJjEUCs.js} +1 -1
- package/dist/client/assets/{Terminal-DNwxBd-K.js → Terminal-Fx0j4vYu.js} +1 -1
- package/dist/client/assets/{Trash01-BVisgA_C.js → Trash01-ClQp3SU7.js} +1 -1
- package/dist/client/assets/{Upload01-BNLnIEeB.js → Upload01-qHdORxg4.js} +1 -1
- package/dist/client/assets/{X-CW8Q6Hi1.js → X-tggfklJn.js} +1 -1
- package/dist/client/assets/{XClose-D4ufvWFX.js → XClose-8ptd0_kG.js} +1 -1
- package/dist/client/assets/{alert-dialog-D0Otr79_.js → alert-dialog-BTnJ6w_s.js} +1 -1
- package/dist/client/assets/{auth-B_BpwYqd.js → auth-DaJav-_Q.js} +1 -1
- package/dist/client/assets/{auth-catchall-prcd9z--.js → auth-catchall-Bi1SQUCA.js} +1 -1
- package/dist/client/assets/{avatar-dpJuYLys.js → avatar-CuTiSc9V.js} +1 -1
- package/dist/client/assets/{badge-Ds7goYWu.js → badge-pWud7F0k.js} +1 -1
- package/dist/client/assets/{button-BbjU_NKb.js → button-DoEGRp1U.js} +1 -1
- package/dist/client/assets/{card-D9f4h5S9.js → card-CJ-1atZv.js} +1 -1
- package/dist/client/assets/{checkbox-CUS4CiNX.js → checkbox-Bh9rcCG9.js} +1 -1
- package/dist/client/assets/{collection-detail-mLXEaOe0.js → collection-detail-7RgcpBz4.js} +42 -43
- package/dist/client/assets/{collection-display-button-B_EFuq7z.js → collection-display-button-B5AAU4Bw.js} +1 -1
- package/dist/client/assets/{collection-header-DFvb6Ef0.js → collection-header-Buxr9MZE.js} +1 -1
- package/dist/client/assets/{collection-page-Cunj8xPH.js → collection-page-BUbDWask.js} +1 -1
- package/dist/client/assets/{collection-search-D19W9v7Y.js → collection-search-DivVKI30.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-DSet3zEH.js → collection-table-wrapper-lGkt7E0b.js} +1 -1
- package/dist/client/assets/{connection-card-CcYDwY5t.js → connection-card-BQhG2Xa_.js} +1 -1
- package/dist/client/assets/{connection-detail-MOJ3Db8S.js → connection-detail-DWS__uKs.js} +1 -1
- package/dist/client/assets/connections-BASUKxPo.js +1 -0
- package/dist/client/assets/{core-BDM8rtDE.js → core-DL7Okp2L.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-CO80uKUt.js → create-organization-dialog-Dds34l1N.js} +1 -1
- package/dist/client/assets/{dialog-5yoaI2WR.js → dialog-DzOmePFm.js} +1 -1
- package/dist/client/assets/{dropdown-menu-PYBNirRh.js → dropdown-menu-B9LS1Ke-.js} +1 -1
- package/dist/client/assets/env-vars-editor-D8jKdEG-.js +1 -0
- package/dist/client/assets/{error-boundary-RgLKNrmL.js → error-boundary-BAtxRJ1Q.js} +1 -1
- package/dist/client/assets/{extract-connection-data-B09VwLtz.js → extract-connection-data-lX5EQrvR.js} +1 -1
- package/dist/client/assets/{form-CGGIFcxK.js → form-9MqLiR_v.js} +1 -1
- package/dist/client/assets/{formatDistanceToNow-xi-mLo5Z.js → formatDistanceToNow-D7en5Npb.js} +1 -1
- package/dist/client/assets/{gateway-detail-DHZ0gZ71.js → gateway-detail-CxcoEeja.js} +1 -1
- package/dist/client/assets/{gateways-qmG2-3Sf.js → gateways-Z3eqRHG3.js} +1 -1
- package/dist/client/assets/{home-BCr1iUv8.js → home-CKPwY7YW.js} +1 -1
- package/dist/client/assets/{index-BbIWyzkd.js → index-Bp5sMtgd.js} +1 -1
- package/dist/client/assets/index-BtfNSYYi.css +1 -0
- package/dist/client/assets/{index-C7lN1dsY.js → index-Cu-lUDuQ.js} +1 -1
- package/dist/client/assets/{index-DU47EoEL.js → index-IkrlX4J3.js} +2 -2
- package/dist/client/assets/{index-CBQyxSI0.js → index-v-MZw8Iv.js} +1 -1
- package/dist/client/assets/{input-CSA6GaZE.js → input-BiKrjh13.js} +1 -1
- package/dist/client/assets/json-C3gxFz3i.js +1 -0
- package/dist/client/assets/{json-syntax-highlighter-Bb7MVmaL.js → json-syntax-highlighter-DKWpZiaG.js} +2 -2
- package/dist/client/assets/{layout-EUreOGAt.js → layout-DnHkkkij.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-Dqvq1Dex.js → lazy-highlighter-B7M4_4X7.js} +1 -1
- package/dist/client/assets/{localstorage-keys-vDKpUgdy.js → localstorage-keys-C9gCmhF_.js} +1 -1
- package/dist/client/assets/{login-CzE52HWB.js → login-CAWaGgdX.js} +1 -1
- package/dist/client/assets/{mcp-oauth-gyqdNKRD.js → mcp-oauth-BeIYwRKY.js} +1 -1
- package/dist/client/assets/{members-BZoVbKBG.js → members-DuEm4VkF.js} +1 -1
- package/dist/client/assets/{monitoring-C0Gr_97h.js → monitoring-m_4t86_p.js} +1 -1
- package/dist/client/assets/{oauth-callback-D36RRfdh.js → oauth-callback-CDIYayLa.js} +1 -1
- package/dist/client/assets/{page-BFTT3kbU.js → page-C3RAYK9Q.js} +1 -1
- package/dist/client/assets/{popover-6ifnvWbA.js → popover-DtVun_-z.js} +1 -1
- package/dist/client/assets/prism-light-BDjQ_TVh.js +1 -0
- package/dist/client/assets/{resizable-CkJ_FaQ-.js → resizable-ADGi5uO6.js} +5 -5
- package/dist/client/assets/{resource-tabs-Bv0wNZtO.js → resource-tabs-B0Wxp2Cw.js} +1 -1
- package/dist/client/assets/{select-ChksjGRZ.js → select-C6oJSPpc.js} +1 -1
- package/dist/client/assets/{settings-C9hGHVWZ.js → settings-DpVdsR8r.js} +1 -1
- package/dist/client/assets/{shell-layout-DOXPwXj9.js → shell-layout-UFhBDwon.js} +1 -1
- package/dist/client/assets/{spinner-Cs-GmOB9.js → spinner-BI2cvb0U.js} +1 -1
- package/dist/client/assets/{store-BOO8Fhr3.js → store-RumD0h8V.js} +1 -1
- package/dist/client/assets/{store-app-detail-CQB-B4O3.js → store-app-detail-C0Bjj1dL.js} +1 -1
- package/dist/client/assets/{switch-CwYp8lP1.js → switch-CICUEk-x.js} +1 -1
- package/dist/client/assets/{textarea-CWQdz33l.js → textarea-DYZxZLq1.js} +1 -1
- package/dist/client/assets/{tools-list-Co8Rk4pO.js → tools-list-B1pdeGzm.js} +1 -1
- package/dist/client/assets/{tooltip-Gq6W5fPh.js → tooltip-DsFBYF2A.js} +1 -1
- package/dist/client/assets/{types-DQkJYd0Q.js → types-BwKekgcj.js} +1 -1
- package/dist/client/assets/{use-binding-BGkxaDoR.js → use-binding-CQxg2gSi.js} +1 -1
- package/dist/client/assets/{use-connection-Bn6WVBbm.js → use-connection-B7SaX83w.js} +1 -1
- package/dist/client/assets/{use-connection-resources-DND8wyIl.js → use-connection-resources-B6GNOl9A.js} +1 -1
- package/dist/client/assets/{use-gateway-CYtxhiPk.js → use-gateway-BlseD0Sx.js} +1 -1
- package/dist/client/assets/{use-list-state-BEiO0GNn.js → use-list-state-BU6IyL55.js} +1 -1
- package/dist/client/assets/{use-mcp-7iEh5pw7.js → use-mcp-C2f_uqzY.js} +1 -1
- package/dist/client/assets/{use-members-CUq7T8-j.js → use-members-CWSu_Z-H.js} +1 -1
- package/dist/client/assets/{use-mobile-tMB1uro8.js → use-mobile-CdiMQ9En.js} +1 -1
- package/dist/client/assets/{use-organization-settings-BSomsUO5.js → use-organization-settings-Cnjs0OiP.js} +1 -1
- package/dist/client/assets/{use-tool-call-beervPUN.js → use-tool-call-BpBoE-Mi.js} +1 -1
- package/dist/client/assets/useQuery-9D_KMlJN.js +1 -0
- package/dist/client/assets/{useSuspenseInfiniteQuery-DZtCeoe_.js → useSuspenseInfiniteQuery-0wQdaodf.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-D0NK_AH0.js → view-mode-toggle-Dq1mWwHt.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +134 -134
- package/dist/server/server.js +130 -130
- package/package.json +1 -1
- package/dist/client/assets/connections-IqHRsIKL.js +0 -1
- package/dist/client/assets/env-vars-editor-SJW34K77.js +0 -1
- package/dist/client/assets/index-CJOFuQi9.css +0 -1
- package/dist/client/assets/json-CEOPWuPd.js +0 -1
- package/dist/client/assets/prism-light-CZXiehjY.js +0 -1
- package/dist/client/assets/useQuery-DATbk-OS.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lazy-highlighter-
|
|
2
|
-
import{r as D,c as Z,e as fo,K as Ge,q as ka,aF as jd,aG as $d,aH as Qe,w as V,aI as jr,aJ as ho,aK as Yd,aL as qd,aM as Vd,Y as $e,X as ir,W as pr,v as ke,aN as ne,aO as Nt,aP as Wd,aQ as Ne,_ as Gd,a3 as Sa,j as m,ax as Qd,f as Xd,t as Ci,aR as kn,a0 as po,a6 as Zd}from"./index-DU47EoEL.js";import{E as Kd,u as Jd}from"./use-binding-BGkxaDoR.js";import{u as Bt,i as Kt,c as Ia,b as Na,T as wa}from"./tooltip-Gq6W5fPh.js";import{u as Gt,c as ue,B as st}from"./button-BbjU_NKb.js";import{i as Ra}from"./CpuChip02-CGJDeKm0.js";import{i as mo}from"./SearchMd-B2Mied73.js";import{b as ef,I as go,U as tf,e as nf,c as rf,u as af}from"./use-connection-Bn6WVBbm.js";import{u as sf}from"./use-gateway-CYtxhiPk.js";import{i as bo}from"./AlertCircle-beBfBGLE.js";import{i as uf}from"./error-boundary-RgLKNrmL.js";import{i as of}from"./X-CW8Q6Hi1.js";import{j as lf,i as Eo,c as cf}from"./dropdown-menu-PYBNirRh.js";import{T as df}from"./textarea-CWQdz33l.js";import{u as ff,L as hf}from"./localstorage-keys-vDKpUgdy.js";import{a as ti}from"./Copy01-BVT45tzW.js";import{i as pf}from"./Terminal-DNwxBd-K.js";import{C as mf}from"./connection-card-CcYDwY5t.js";import{n as gf}from"./LinkExternal01-D3EWn3rZ.js";import{J as Dr}from"./json-syntax-highlighter-Bb7MVmaL.js";import{b as bf,c as Ef,d as Tf,A as xf,a as _f,e as yf,g as Af,f as Cf}from"./alert-dialog-D0Otr79_.js";import{b as kf,a as Sf,c as If,S as Nf}from"./select-ChksjGRZ.js";import{u as wf}from"./use-mobile-tMB1uro8.js";import{i as Rf}from"./File06-CZuMuvHc.js";import{i as Lf}from"./InfoCircle-DVoXsuXL.js";const To=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));To.displayName="Coins01";const xo=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));xo.displayName="CornerUpLeft";const _o=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));_o.displayName="CurrencyDollar";const yo=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M12 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm7-14a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM5 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}));yo.displayName="DotsGrid";const Ao=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));Ao.displayName="Edit02";const Co=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));Co.displayName="Image01";const ko=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));ko.displayName="Lightbulb01";const So=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));So.displayName="LogOut04";const Io=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"m10 15-3.075 3.114c-.43.434-.644.651-.828.666a.5.5 0 0 1-.421-.172c-.12-.14-.12-.446-.12-1.056v-1.56c0-.548-.449-.944-.99-1.024v0a3 3 0 0 1-2.534-2.533C2 12.219 2 11.96 2 11.445V6.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C4.28 2 5.12 2 6.8 2h7.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C19 4.28 19 5.12 19 6.8V11m0 11-2.176-1.513c-.306-.213-.46-.32-.626-.395a2.002 2.002 0 0 0-.462-.145c-.18-.033-.367-.033-.74-.033H13.2c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C10 18.394 10 17.834 10 16.714V14.2c0-1.12 0-1.68.218-2.108a2 2 0 0 1 .874-.874C11.52 11 12.08 11 13.2 11h5.6c1.12 0 1.68 0 2.108.218a2 2 0 0 1 .874.874C22 12.52 22 13.08 22 14.2v2.714c0 .932 0 1.398-.152 1.766a2 2 0 0 1-1.083 1.082c-.367.152-.833.152-1.765.152V22Z"}));Io.displayName="MessageChatSquare";const ni=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));ni.displayName="Stars01";const No=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M3 7.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.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.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.8Z"}));No.displayName="Stop";const wo=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));wo.displayName="Target04";var ar;(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})(ar||(ar={}));var bs;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(bs||(bs={}));ar.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);ar.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,ar.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 Es;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Es||(Es={}));var se;(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"})(se||(se={}));function Jt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function Of(t,e){let n;const r=()=>{if(n)return n;const i=indexedDB.open(t);return i.onupgradeneeded=()=>i.result.createObjectStore(e),n=Jt(i),n.then(a=>{a.onclose=()=>n=void 0},()=>{}),n};return(i,a)=>r().then(s=>a(s.transaction(e,i).objectStore(e)))}let ki;function ri(){return ki||(ki=Of("keyval-store","keyval")),ki}function La(t,e=ri()){return e("readonly",n=>Jt(n.get(t)))}function Gn(t,e,n=ri()){return n("readwrite",r=>(r.put(e,t),Jt(r.transaction)))}function Ro(t,e=ri()){return e("readwrite",n=>(n.delete(t),Jt(n.transaction)))}function vf(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Jt(t.transaction)}function Lo(t=ri()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Jt(e.getAllKeys()),Jt(e.getAll())]).then(([r,i])=>r.map((a,s)=>[a,i[s]]));const n=[];return t("readonly",r=>vf(r,i=>n.push([i.key,i.value])).then(()=>n))})}async function Df(t,e){const n=`${t}:threads:${e}`;return await La(n)??null}async function Pf(t){const e=`${t}:threads:`;return(await Lo()).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 Oo(t,e){const n=`${t}:messages:`;return Lo().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 rA(){const t=Z.c(12),{locator:e}=Bt();let n;t[0]!==e?(n=Ge.threads(e),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=()=>Pf(e),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==n||t[5]!==r?(i={queryKey:n,queryFn:r,staleTime:3e4},t[4]=n,t[5]=r,t[6]=i):i=t[6];const{data:a,refetch:s}=ka(i);let u;t[7]!==a?(u=a??[],t[7]=a,t[8]=u):u=t[8];let o;return t[9]!==s||t[10]!==u?(o={threads:u,refetch:s},t[9]=s,t[10]=u,t[11]=o):o=t[11],o}function Mf(t){const e=Z.c(11),{locator:n}=Bt();let r;e[0]!==n||e[1]!==t?(r=Ge.threadMessages(n,t),e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;e[3]!==n||e[4]!==t?(i=()=>Oo(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}=ka(a);let u;return e[9]!==s?(u=s??[],e[9]=s,e[10]=u):u=e[10],u}function Oa(){const t=Z.c(28),{locator:e}=Bt(),n=fo();let r;t[0]!==e?(r=async _=>{const b=`${e}:threads:${_.id}`;return await Gn(b,_),_},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=()=>{n.invalidateQueries({queryKey:Ge.threads(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=Gt(a);let u;t[8]!==e?(u=async _=>{const{id:b,updates:k}=_,E=`${e}:threads:${b}`,w=await La(E);if(!w)throw new Error(`Thread ${b} not found`);const R={...w,...k};return await Gn(E,R),R},t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=_=>{n.invalidateQueries({queryKey:Ge.threads(e)}),n.invalidateQueries({queryKey:Ge.thread(e,_.id)})},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 f=Gt(l);let d;t[16]!==e?(d=async _=>{const b=`${e}:threads:${_}`;return await Ro(b),_},t[16]=e,t[17]=d):d=t[17];let h;t[18]!==e||t[19]!==n?(h=()=>{n.invalidateQueries({queryKey:Ge.threads(e)})},t[18]=e,t[19]=n,t[20]=h):h=t[20];let p;t[21]!==d||t[22]!==h?(p={mutationFn:d,onSuccess:h},t[21]=d,t[22]=h,t[23]=p):p=t[23];const g=Gt(p);let x;return t[24]!==g||t[25]!==s||t[26]!==f?(x={insert:s,update:f,delete:g},t[24]=g,t[25]=s,t[26]=f,t[27]=x):x=t[27],x}function vo(){const t=Z.c(37),{locator:e}=Bt(),n=fo();let r;t[0]!==e?(r=async w=>{const R=`${e}:messages:${w.id}`;return await Gn(R,w),w},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=w=>{const R=w.metadata?.thread_id||w.threadId;R&&n.invalidateQueries({queryKey:Ge.threadMessages(e,R)}),n.invalidateQueries({queryKey:Ge.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=Gt(a);let u;t[8]!==e?(u=async w=>(await Promise.all(w.map(R=>{const S=`${e}:messages:${R.id}`;return Gn(S,R)})),w),t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=w=>{const R=new Set;for(const S of w){const O=S.metadata?.thread_id||S.threadId;O&&R.add(O)}for(const S of R)n.invalidateQueries({queryKey:Ge.threadMessages(e,S)});n.invalidateQueries({queryKey:Ge.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 f=Gt(l);let d;t[16]!==e?(d=async w=>{const{id:R,updates:S}=w,O=`${e}:messages:${R}`,H=await La(O);if(!H)throw new Error(`Message ${R} not found`);const $={...H,...S};return await Gn(O,$),$},t[16]=e,t[17]=d):d=t[17];let h;t[18]!==e||t[19]!==n?(h=w=>{const R=w.metadata?.thread_id||w.threadId;R&&n.invalidateQueries({queryKey:Ge.threadMessages(e,R)}),n.invalidateQueries({queryKey:Ge.messages(e)})},t[18]=e,t[19]=n,t[20]=h):h=t[20];let p;t[21]!==d||t[22]!==h?(p={mutationFn:d,onSuccess:h},t[21]=d,t[22]=h,t[23]=p):p=t[23];const g=Gt(p);let x;t[24]!==e?(x=async w=>{const R=`${e}:messages:${w}`;return await Ro(R),w},t[24]=e,t[25]=x):x=t[25];let _;t[26]!==e||t[27]!==n?(_=()=>{n.invalidateQueries({queryKey:Ge.messages(e)})},t[26]=e,t[27]=n,t[28]=_):_=t[28];let b;t[29]!==_||t[30]!==x?(b={mutationFn:x,onSuccess:_},t[29]=_,t[30]=x,t[31]=b):b=t[31];const k=Gt(b);let E;return t[32]!==k||t[33]!==s||t[34]!==f||t[35]!==g?(E={insert:s,insertMany:f,update:g,delete:k},t[32]=k,t[33]=s,t[34]=f,t[35]=g,t[36]=E):E=t[36],E}async function Bf(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 iA(t){const e=Z.c(7);let n;e[0]!==t?(n=Ge.gatewayPrompts(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t?(r=()=>Bf(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],ka(i)}var Do="vercel.ai.error",Ff=Symbol.for(Do),Ts,xs,Mt=class Po extends(xs=Error,Ts=Ff,xs){constructor({name:e,message:n,cause:r}){super(n),this[Ts]=!0,this.name=e,this.cause=r}static isInstance(e){return Po.hasMarker(e,Do)}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 Mo(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Bo="AI_InvalidArgumentError",Fo=`vercel.ai.error.${Bo}`,Hf=Symbol.for(Fo),_s,ys,Uf=class extends(ys=Mt,_s=Hf,ys){constructor({message:t,cause:e,argument:n}){super({name:Bo,message:t,cause:e}),this[_s]=!0,this.argument=n}static isInstance(t){return Mt.hasMarker(t,Fo)}},Ho="AI_JSONParseError",Uo=`vercel.ai.error.${Ho}`,zf=Symbol.for(Uo),As,Cs,ks=class extends(Cs=Mt,As=zf,Cs){constructor({text:t,cause:e}){super({name:Ho,message:`JSON parsing failed: Text: ${t}.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lazy-highlighter-B7M4_4X7.js","assets/index-IkrlX4J3.js","assets/index-BtfNSYYi.css","assets/core-DL7Okp2L.js","assets/json-BESjz4hO.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as D,c as Z,e as fo,K as Ge,q as ka,aF as jd,aG as $d,aH as Qe,w as V,aI as jr,aJ as ho,aK as Yd,aL as qd,aM as Vd,Y as $e,X as ir,W as pr,v as ke,aN as ne,aO as Nt,aP as Wd,aQ as Ne,_ as Gd,a3 as Sa,j as m,ax as Qd,f as Xd,t as Ci,aR as kn,a0 as po,a6 as Zd}from"./index-IkrlX4J3.js";import{E as Kd,u as Jd}from"./use-binding-CQxg2gSi.js";import{u as Bt,i as Kt,c as Ia,b as Na,T as wa}from"./tooltip-DsFBYF2A.js";import{u as Gt,c as ue,B as st}from"./button-DoEGRp1U.js";import{i as Ra}from"./CpuChip02-D26L6TWX.js";import{i as mo}from"./SearchMd-DiJjEUCs.js";import{b as ef,I as go,U as tf,e as nf,c as rf,u as af}from"./use-connection-B7SaX83w.js";import{u as sf}from"./use-gateway-BlseD0Sx.js";import{i as bo}from"./AlertCircle-DoPcYOmu.js";import{i as uf}from"./error-boundary-BAtxRJ1Q.js";import{i as of}from"./X-tggfklJn.js";import{j as lf,i as Eo,c as cf}from"./dropdown-menu-B9LS1Ke-.js";import{T as df}from"./textarea-DYZxZLq1.js";import{u as ff,L as hf}from"./localstorage-keys-C9gCmhF_.js";import{a as ti}from"./Copy01-CdCXGmeI.js";import{i as pf}from"./Terminal-Fx0j4vYu.js";import{C as mf}from"./connection-card-BQhG2Xa_.js";import{n as gf}from"./LinkExternal01-C8zs3bR9.js";import{J as Dr}from"./json-syntax-highlighter-DKWpZiaG.js";import{b as bf,c as Ef,d as Tf,A as xf,a as _f,e as yf,g as Af,f as Cf}from"./alert-dialog-BTnJ6w_s.js";import{b as kf,a as Sf,c as If,S as Nf}from"./select-C6oJSPpc.js";import{u as wf}from"./use-mobile-CdiMQ9En.js";import{i as Rf}from"./File06-D4-QxuCL.js";import{i as Lf}from"./InfoCircle-BH6ukjrt.js";const To=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));To.displayName="Coins01";const xo=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));xo.displayName="CornerUpLeft";const _o=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));_o.displayName="CurrencyDollar";const yo=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M12 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm7-14a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM5 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm0 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}));yo.displayName="DotsGrid";const Ao=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));Ao.displayName="Edit02";const Co=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));Co.displayName="Image01";const ko=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));ko.displayName="Lightbulb01";const So=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));So.displayName="LogOut04";const Io=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"m10 15-3.075 3.114c-.43.434-.644.651-.828.666a.5.5 0 0 1-.421-.172c-.12-.14-.12-.446-.12-1.056v-1.56c0-.548-.449-.944-.99-1.024v0a3 3 0 0 1-2.534-2.533C2 12.219 2 11.96 2 11.445V6.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C4.28 2 5.12 2 6.8 2h7.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C19 4.28 19 5.12 19 6.8V11m0 11-2.176-1.513c-.306-.213-.46-.32-.626-.395a2.002 2.002 0 0 0-.462-.145c-.18-.033-.367-.033-.74-.033H13.2c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C10 18.394 10 17.834 10 16.714V14.2c0-1.12 0-1.68.218-2.108a2 2 0 0 1 .874-.874C11.52 11 12.08 11 13.2 11h5.6c1.12 0 1.68 0 2.108.218a2 2 0 0 1 .874.874C22 12.52 22 13.08 22 14.2v2.714c0 .932 0 1.398-.152 1.766a2 2 0 0 1-1.083 1.082c-.367.152-.833.152-1.765.152V22Z"}));Io.displayName="MessageChatSquare";const ni=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));ni.displayName="Stars01";const No=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M3 7.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.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.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.8Z"}));No.displayName="Stop";const wo=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"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"}));wo.displayName="Target04";var ar;(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})(ar||(ar={}));var bs;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(bs||(bs={}));ar.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);ar.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,ar.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 Es;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Es||(Es={}));var se;(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"})(se||(se={}));function Jt(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function Of(t,e){let n;const r=()=>{if(n)return n;const i=indexedDB.open(t);return i.onupgradeneeded=()=>i.result.createObjectStore(e),n=Jt(i),n.then(a=>{a.onclose=()=>n=void 0},()=>{}),n};return(i,a)=>r().then(s=>a(s.transaction(e,i).objectStore(e)))}let ki;function ri(){return ki||(ki=Of("keyval-store","keyval")),ki}function La(t,e=ri()){return e("readonly",n=>Jt(n.get(t)))}function Gn(t,e,n=ri()){return n("readwrite",r=>(r.put(e,t),Jt(r.transaction)))}function Ro(t,e=ri()){return e("readwrite",n=>(n.delete(t),Jt(n.transaction)))}function vf(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Jt(t.transaction)}function Lo(t=ri()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Jt(e.getAllKeys()),Jt(e.getAll())]).then(([r,i])=>r.map((a,s)=>[a,i[s]]));const n=[];return t("readonly",r=>vf(r,i=>n.push([i.key,i.value])).then(()=>n))})}async function Df(t,e){const n=`${t}:threads:${e}`;return await La(n)??null}async function Pf(t){const e=`${t}:threads:`;return(await Lo()).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 Oo(t,e){const n=`${t}:messages:`;return Lo().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 rA(){const t=Z.c(12),{locator:e}=Bt();let n;t[0]!==e?(n=Ge.threads(e),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=()=>Pf(e),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==n||t[5]!==r?(i={queryKey:n,queryFn:r,staleTime:3e4},t[4]=n,t[5]=r,t[6]=i):i=t[6];const{data:a,refetch:s}=ka(i);let u;t[7]!==a?(u=a??[],t[7]=a,t[8]=u):u=t[8];let o;return t[9]!==s||t[10]!==u?(o={threads:u,refetch:s},t[9]=s,t[10]=u,t[11]=o):o=t[11],o}function Mf(t){const e=Z.c(11),{locator:n}=Bt();let r;e[0]!==n||e[1]!==t?(r=Ge.threadMessages(n,t),e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;e[3]!==n||e[4]!==t?(i=()=>Oo(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}=ka(a);let u;return e[9]!==s?(u=s??[],e[9]=s,e[10]=u):u=e[10],u}function Oa(){const t=Z.c(28),{locator:e}=Bt(),n=fo();let r;t[0]!==e?(r=async _=>{const b=`${e}:threads:${_.id}`;return await Gn(b,_),_},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=()=>{n.invalidateQueries({queryKey:Ge.threads(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=Gt(a);let u;t[8]!==e?(u=async _=>{const{id:b,updates:k}=_,E=`${e}:threads:${b}`,w=await La(E);if(!w)throw new Error(`Thread ${b} not found`);const R={...w,...k};return await Gn(E,R),R},t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=_=>{n.invalidateQueries({queryKey:Ge.threads(e)}),n.invalidateQueries({queryKey:Ge.thread(e,_.id)})},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 f=Gt(l);let d;t[16]!==e?(d=async _=>{const b=`${e}:threads:${_}`;return await Ro(b),_},t[16]=e,t[17]=d):d=t[17];let h;t[18]!==e||t[19]!==n?(h=()=>{n.invalidateQueries({queryKey:Ge.threads(e)})},t[18]=e,t[19]=n,t[20]=h):h=t[20];let p;t[21]!==d||t[22]!==h?(p={mutationFn:d,onSuccess:h},t[21]=d,t[22]=h,t[23]=p):p=t[23];const g=Gt(p);let x;return t[24]!==g||t[25]!==s||t[26]!==f?(x={insert:s,update:f,delete:g},t[24]=g,t[25]=s,t[26]=f,t[27]=x):x=t[27],x}function vo(){const t=Z.c(37),{locator:e}=Bt(),n=fo();let r;t[0]!==e?(r=async w=>{const R=`${e}:messages:${w.id}`;return await Gn(R,w),w},t[0]=e,t[1]=r):r=t[1];let i;t[2]!==e||t[3]!==n?(i=w=>{const R=w.metadata?.thread_id||w.threadId;R&&n.invalidateQueries({queryKey:Ge.threadMessages(e,R)}),n.invalidateQueries({queryKey:Ge.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=Gt(a);let u;t[8]!==e?(u=async w=>(await Promise.all(w.map(R=>{const S=`${e}:messages:${R.id}`;return Gn(S,R)})),w),t[8]=e,t[9]=u):u=t[9];let o;t[10]!==e||t[11]!==n?(o=w=>{const R=new Set;for(const S of w){const O=S.metadata?.thread_id||S.threadId;O&&R.add(O)}for(const S of R)n.invalidateQueries({queryKey:Ge.threadMessages(e,S)});n.invalidateQueries({queryKey:Ge.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 f=Gt(l);let d;t[16]!==e?(d=async w=>{const{id:R,updates:S}=w,O=`${e}:messages:${R}`,H=await La(O);if(!H)throw new Error(`Message ${R} not found`);const $={...H,...S};return await Gn(O,$),$},t[16]=e,t[17]=d):d=t[17];let h;t[18]!==e||t[19]!==n?(h=w=>{const R=w.metadata?.thread_id||w.threadId;R&&n.invalidateQueries({queryKey:Ge.threadMessages(e,R)}),n.invalidateQueries({queryKey:Ge.messages(e)})},t[18]=e,t[19]=n,t[20]=h):h=t[20];let p;t[21]!==d||t[22]!==h?(p={mutationFn:d,onSuccess:h},t[21]=d,t[22]=h,t[23]=p):p=t[23];const g=Gt(p);let x;t[24]!==e?(x=async w=>{const R=`${e}:messages:${w}`;return await Ro(R),w},t[24]=e,t[25]=x):x=t[25];let _;t[26]!==e||t[27]!==n?(_=()=>{n.invalidateQueries({queryKey:Ge.messages(e)})},t[26]=e,t[27]=n,t[28]=_):_=t[28];let b;t[29]!==_||t[30]!==x?(b={mutationFn:x,onSuccess:_},t[29]=_,t[30]=x,t[31]=b):b=t[31];const k=Gt(b);let E;return t[32]!==k||t[33]!==s||t[34]!==f||t[35]!==g?(E={insert:s,insertMany:f,update:g,delete:k},t[32]=k,t[33]=s,t[34]=f,t[35]=g,t[36]=E):E=t[36],E}async function Bf(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 iA(t){const e=Z.c(7);let n;e[0]!==t?(n=Ge.gatewayPrompts(t),e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t?(r=()=>Bf(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],ka(i)}var Do="vercel.ai.error",Ff=Symbol.for(Do),Ts,xs,Mt=class Po extends(xs=Error,Ts=Ff,xs){constructor({name:e,message:n,cause:r}){super(n),this[Ts]=!0,this.name=e,this.cause=r}static isInstance(e){return Po.hasMarker(e,Do)}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 Mo(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Bo="AI_InvalidArgumentError",Fo=`vercel.ai.error.${Bo}`,Hf=Symbol.for(Fo),_s,ys,Uf=class extends(ys=Mt,_s=Hf,ys){constructor({message:t,cause:e,argument:n}){super({name:Bo,message:t,cause:e}),this[_s]=!0,this.argument=n}static isInstance(t){return Mt.hasMarker(t,Fo)}},Ho="AI_JSONParseError",Uo=`vercel.ai.error.${Ho}`,zf=Symbol.for(Uo),As,Cs,ks=class extends(Cs=Mt,As=zf,Cs){constructor({text:t,cause:e}){super({name:Ho,message:`JSON parsing failed: Text: ${t}.
|
|
3
3
|
Error message: ${Mo(e)}`,cause:e}),this[As]=!0,this.text=t}static isInstance(t){return Mt.hasMarker(t,Uo)}},zo="AI_TypeValidationError",jo=`vercel.ai.error.${zo}`,jf=Symbol.for(jo),Ss,Is,_n=class Ji extends(Is=Mt,Ss=jf,Is){constructor({value:e,cause:n}){super({name:zo,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
4
4
|
Error message: ${Mo(n)}`,cause:n}),this[Ss]=!0,this.value=e}static isInstance(e){return Mt.hasMarker(e,jo)}static wrap({value:e,cause:n}){return Ji.isInstance(n)&&n.value===e?n:new Ji({value:e,cause:n})}},mr=({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 Uf({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${t}${r}${i()}`},$f=mr();function Ns(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 Vt(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 ws(t,...e){const n=new Headers(Vt(t)),r=n.get("user-agent")||"";return n.set("user-agent",[r,...e].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var Yf=/"__proto__"\s*:/,qf=/"constructor"\s*:/;function Rs(t){const e=JSON.parse(t);return e===null||typeof e!="object"||Yf.test(t)===!1&&qf.test(t)===!1?e:Vf(e)}function Vf(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 Wf(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return Rs(t)}try{return Rs(t)}finally{Error.stackTraceLimit=e}}function $o(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]=$t(n[r])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map($t):$t(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map($t)),t.allOf!=null&&(t.allOf=t.allOf.map($t)),t.oneOf!=null&&(t.oneOf=t.oneOf.map($t));const{definitions:e}=t;if(e!=null)for(const n of Object.keys(e))e[n]=$t(e[n]);return t}function $t(t){return typeof t=="boolean"?t:$o(t)}var Gf=Symbol("Let zodToJsonSchema decide on which parser to use"),Ls={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"},Qf=t=>typeof t=="string"?{...Ls,name:t}:{...Ls,...t};function nt(){return{}}function Xf(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)!==se.ZodAny&&(a.items=Ae(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 Zf(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 Kf(){return{type:"boolean"}}function Yo(t,e){return Ae(t.type._def,e)}var Jf=(t,e)=>Ae(t.innerType._def,e);function qo(t,e,n){const r=n??e.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((i,a)=>qo(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 eh(t)}}var eh=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 th(t,e){return{...Ae(t.innerType._def,e),default:t.defaultValue()}}function nh(t,e){return e.effectStrategy==="input"?Ae(t.schema._def,e):nt()}function rh(t){return{type:"string",enum:Array.from(t.values)}}var ih=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ah(t,e){const n=[Ae(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Ae(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(i=>!!i),r=[];return n.forEach(i=>{if(ih(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 sh(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 Si=void 0,ot={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:()=>(Si===void 0&&(Si=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Si),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 Vo(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":lt(n,"email",r.message,e);break;case"format:idn-email":lt(n,"idn-email",r.message,e);break;case"pattern:zod":je(n,ot.email,r.message,e);break}break;case"url":lt(n,"uri",r.message,e);break;case"uuid":lt(n,"uuid",r.message,e);break;case"regex":je(n,r.regex,r.message,e);break;case"cuid":je(n,ot.cuid,r.message,e);break;case"cuid2":je(n,ot.cuid2,r.message,e);break;case"startsWith":je(n,RegExp(`^${Ii(r.value,e)}`),r.message,e);break;case"endsWith":je(n,RegExp(`${Ii(r.value,e)}$`),r.message,e);break;case"datetime":lt(n,"date-time",r.message,e);break;case"date":lt(n,"date",r.message,e);break;case"time":lt(n,"time",r.message,e);break;case"duration":lt(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":{je(n,RegExp(Ii(r.value,e)),r.message,e);break}case"ip":{r.version!=="v6"&<(n,"ipv4",r.message,e),r.version!=="v4"&<(n,"ipv6",r.message,e);break}case"base64url":je(n,ot.base64url,r.message,e);break;case"jwt":je(n,ot.jwt,r.message,e);break;case"cidr":{r.version!=="v6"&&je(n,ot.ipv4Cidr,r.message,e),r.version!=="v4"&&je(n,ot.ipv6Cidr,r.message,e);break}case"emoji":je(n,ot.emoji(),r.message,e);break;case"ulid":{je(n,ot.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{lt(n,"binary",r.message,e);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{je(n,ot.base64,r.message,e);break}}break}case"nanoid":je(n,ot.nanoid,r.message,e)}return n}function Ii(t,e){return e.patternStrategy==="escape"?oh(t):t}var uh=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function oh(t){let e="";for(let n=0;n<t.length;n++)uh.has(t[n])||(e+="\\"),e+=t[n];return e}function lt(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 je(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:Os(e,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):t.pattern=Os(e,r)}function Os(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 Wo(t,e){var n,r,i,a,s,u;const o={type:"object",additionalProperties:(n=Ae(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?n:e.allowedAdditionalProperties};if(((r=t.keyType)==null?void 0:r._def.typeName)===se.ZodString&&((i=t.keyType._def.checks)!=null&&i.length)){const{type:l,...f}=Vo(t.keyType._def,e);return{...o,propertyNames:f}}else{if(((a=t.keyType)==null?void 0:a._def.typeName)===se.ZodEnum)return{...o,propertyNames:{enum:t.keyType._def.values}};if(((s=t.keyType)==null?void 0:s._def.typeName)===se.ZodBranded&&t.keyType._def.type._def.typeName===se.ZodString&&((u=t.keyType._def.type._def.checks)!=null&&u.length)){const{type:l,...f}=Yo(t.keyType._def,e);return{...o,propertyNames:f}}}return o}function lh(t,e){if(e.mapStrategy==="record")return Wo(t,e);const n=Ae(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||nt(),r=Ae(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||nt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function ch(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 dh(){return{not:nt()}}function fh(){return{type:"null"}}var ea={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hh(t,e){const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in ea&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,a)=>{const s=ea[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 ph(t,e)}var ph=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>Ae(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 mh(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[ea[t.innerType._def.typeName],"null"]};const n=Ae(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function gh(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 bh(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=Th(u),l=Ae(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=Eh(t,e);return a!==void 0&&(n.additionalProperties=a),n}function Eh(t,e){if(t.catchall._def.typeName!=="ZodNever")return Ae(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 Th(t){try{return t.isOptional()}catch{return!0}}var xh=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return Ae(t.innerType._def,e);const r=Ae(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:nt()},r]}:nt()},_h=(t,e)=>{if(e.pipeStrategy==="input")return Ae(t.in._def,e);if(e.pipeStrategy==="output")return Ae(t.out._def,e);const n=Ae(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=Ae(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function yh(t,e){return Ae(t.type._def,e)}function Ah(t,e){const r={type:"array",uniqueItems:!0,items:Ae(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 Ch(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Ae(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Ae(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Ae(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function kh(){return{not:nt()}}function Sh(){return nt()}var Ih=(t,e)=>Ae(t.innerType._def,e),Nh=(t,e,n)=>{switch(e){case se.ZodString:return Vo(t,n);case se.ZodNumber:return gh(t);case se.ZodObject:return bh(t,n);case se.ZodBigInt:return Zf(t);case se.ZodBoolean:return Kf();case se.ZodDate:return qo(t,n);case se.ZodUndefined:return kh();case se.ZodNull:return fh();case se.ZodArray:return Xf(t,n);case se.ZodUnion:case se.ZodDiscriminatedUnion:return hh(t,n);case se.ZodIntersection:return ah(t,n);case se.ZodTuple:return Ch(t,n);case se.ZodRecord:return Wo(t,n);case se.ZodLiteral:return sh(t);case se.ZodEnum:return rh(t);case se.ZodNativeEnum:return ch(t);case se.ZodNullable:return mh(t,n);case se.ZodOptional:return xh(t,n);case se.ZodMap:return lh(t,n);case se.ZodSet:return Ah(t,n);case se.ZodLazy:return()=>t.getter()._def;case se.ZodPromise:return yh(t,n);case se.ZodNaN:case se.ZodNever:return dh();case se.ZodEffects:return nh(t,n);case se.ZodAny:return nt();case se.ZodUnknown:return Sh();case se.ZodDefault:return th(t,n);case se.ZodBranded:return Yo(t,n);case se.ZodReadonly:return Ih(t,n);case se.ZodCatch:return Jf(t,n);case se.ZodPipeline:return _h(t,n);case se.ZodFunction:case se.ZodVoid:case se.ZodSymbol:return;default:return(r=>{})()}},wh=(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 Ae(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!==Gf)return o}if(i&&!n){const o=Rh(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=Nh(t,t.typeName,e),u=typeof s=="function"?Ae(s(),e):s;if(u&&Lh(t,e,u),e.postProcess){const o=e.postProcess(u,t,e);return a.jsonSchema=u,o}return a.jsonSchema=u,u}var Rh=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:wh(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`),nt()):e.$refStrategy==="seen"?nt():void 0}},Lh=(t,e,n)=>(t.description&&(n.description=t.description),n),Oh=t=>{const e=Qf(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}]))}},vh=(t,e)=>{var n;const r=Oh(e);let i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[f,d])=>{var h;return{...l,[f]:(h=Ae(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?h:nt()}},{}):void 0;const a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=(n=Ae(t._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))!=null?n:nt(),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},ta=Symbol.for("vercel.ai.schema");function Dh(t){let e;return()=>(e==null&&(e=t()),e)}function ii(t,{validate:e}={}){return{[ta]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function Ph(t){return typeof t=="object"&&t!==null&&ta in t&&t[ta]===!0&&"jsonSchema"in t&&"validate"in t}function va(t){return t==null?ii({properties:{},additionalProperties:!1}):Ph(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Go(t):Mh(t):t()}function Mh(t){return ii(()=>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 _n({value:e,cause:n.issues})}}})}function Bh(t,e){var n;const r=(n=void 0)!=null?n:!1;return ii(()=>vh(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 Fh(t,e){var n;const r=(n=void 0)!=null?n:!1;return ii(()=>$o($d(t,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const a=await jd(t,i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function Hh(t){return"_zod"in t}function Go(t,e){return Hh(t)?Fh(t):Bh(t)}async function vs({value:t,schema:e}){const n=await sr({value:t,schema:e});if(!n.success)throw _n.wrap({value:t,cause:n.error});return n.value}async function sr({value:t,schema:e}){const n=va(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:_n.wrap({value:t,cause:r.error}),rawValue:t}}catch(r){return{success:!1,error:_n.wrap({value:t,cause:r}),rawValue:t}}}async function en({text:t,schema:e}){try{const n=Wf(t);return e==null?{success:!0,value:n,rawValue:n}:await sr({value:n,schema:e})}catch(n){return{success:!1,error:ks.isInstance(n)?n:new ks({text:t,cause:n}),rawValue:void 0}}}function Uh({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new Kd).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await en({text:n,schema:e}))}}))}async function Ot(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var zh=Object.defineProperty,jh=(t,e)=>{for(var n in e)zh(t,n,{get:e[n],enumerable:!0})},Qo="AI_NoObjectGeneratedError",Xo=`vercel.ai.error.${Qo}`,$h=Symbol.for(Xo),Zo,Pt=class extends Mt{constructor({message:t="No object generated.",cause:e,text:n,response:r,usage:i,finishReason:a}){super({name:Qo,message:t,cause:e}),this[Zo]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Mt.hasMarker(t,Xo)}};Zo=$h;var Ds="6.0.13",Ko=Qe([V(),jr(Uint8Array),jr(ArrayBuffer),ho(t=>{var e,n;return(n=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?n:!1},{message:"Must be a Buffer"})]),ur=Yd(()=>Qe([qd(),V(),Vd(),$e(),ir(V(),ur.optional()),pr(ur)])),be=ir(V(),ir(V(),ur.optional())),Jo=ke({type:ne("text"),text:V(),providerOptions:be.optional()}),Yh=ke({type:ne("image"),image:Qe([Ko,jr(URL)]),mediaType:V().optional(),providerOptions:be.optional()}),el=ke({type:ne("file"),data:Qe([Ko,jr(URL)]),filename:V().optional(),mediaType:V(),providerOptions:be.optional()}),qh=ke({type:ne("reasoning"),text:V(),providerOptions:be.optional()}),Vh=ke({type:ne("tool-call"),toolCallId:V(),toolName:V(),input:Nt(),providerOptions:be.optional(),providerExecuted:$e().optional()}),Wh=Wd("type",[ke({type:ne("text"),value:V(),providerOptions:be.optional()}),ke({type:ne("json"),value:ur,providerOptions:be.optional()}),ke({type:ne("execution-denied"),reason:V().optional(),providerOptions:be.optional()}),ke({type:ne("error-text"),value:V(),providerOptions:be.optional()}),ke({type:ne("error-json"),value:ur,providerOptions:be.optional()}),ke({type:ne("content"),value:pr(Qe([ke({type:ne("text"),text:V(),providerOptions:be.optional()}),ke({type:ne("media"),data:V(),mediaType:V()}),ke({type:ne("file-data"),data:V(),mediaType:V(),filename:V().optional(),providerOptions:be.optional()}),ke({type:ne("file-url"),url:V(),providerOptions:be.optional()}),ke({type:ne("file-id"),fileId:Qe([V(),ir(V(),V())]),providerOptions:be.optional()}),ke({type:ne("image-data"),data:V(),mediaType:V(),providerOptions:be.optional()}),ke({type:ne("image-url"),url:V(),providerOptions:be.optional()}),ke({type:ne("image-file-id"),fileId:Qe([V(),ir(V(),V())]),providerOptions:be.optional()}),ke({type:ne("custom"),providerOptions:be.optional()})]))})]),tl=ke({type:ne("tool-result"),toolCallId:V(),toolName:V(),output:Wh,providerOptions:be.optional()}),Gh=ke({type:ne("tool-approval-request"),approvalId:V(),toolCallId:V()}),Qh=ke({type:ne("tool-approval-response"),approvalId:V(),approved:$e(),reason:V().optional()}),Xh=ke({role:ne("system"),content:V(),providerOptions:be.optional()}),Zh=ke({role:ne("user"),content:Qe([V(),pr(Qe([Jo,Yh,el]))]),providerOptions:be.optional()}),Kh=ke({role:ne("assistant"),content:Qe([V(),pr(Qe([Jo,el,qh,Vh,tl,Gh]))]),providerOptions:be.optional()}),Jh=ke({role:ne("tool"),content:pr(Qe([tl,Qh])),providerOptions:be.optional()});Qe([Xh,Zh,Kh,Jh]);function nl(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]=nl(a,i):n[r]=i}return n}var e0={};jh(e0,{array:()=>i0,choice:()=>a0,json:()=>s0,object:()=>r0,text:()=>n0});function t0(t){const e=["ROOT"];let n=-1,r=null;function i(o,l,f){switch(o){case'"':{n=l,e.pop(),e.push(f),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=l,r=l,e.pop(),e.push(f),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(f),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(f),e.push("INSIDE_NUMBER");break}case"{":{n=l,e.pop(),e.push(f),e.push("INSIDE_OBJECT_START");break}case"[":{n=l,e.pop(),e.push(f),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 d=t.substring(r,o+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(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 f=t.substring(r,t.length);"true".startsWith(f)?u+="true".slice(f.length):"false".startsWith(f)?u+="false".slice(f.length):"null".startsWith(f)&&(u+="null".slice(f.length))}}return u}async function gr(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await en({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await en({text:t0(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var n0=()=>({responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}}}),r0=({schema:t,name:e,description:n})=>{const r=va(t);return{responseFormat:Ot(r.jsonSchema).then(i=>({type:"json",schema:i,...e!=null&&{name:e},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},a){const s=await en({text:i});if(!s.success)throw new Pt({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 sr({value:s.value,schema:r});if(!u.success)throw new Pt({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 gr(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:a.value}}}}},i0=({element:t,name:e,description:n})=>{const r=va(t);return{responseFormat:Ot(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 en({text:i});if(!s.success)throw new Pt({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 Pt({message:"No object generated: response did not match schema.",cause:new _n({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 sr({value:o,schema:r});if(!l.success)throw new Pt({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 gr(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 f=await sr({value:l,schema:r});f.success&&o.push(f.value)}return{partial:o}}}}}},a0=({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 en({text:r});if(!a.success)throw new Pt({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 Pt({message:"No object generated: response did not match schema.",cause:new _n({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 gr(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}}}}),s0=({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 en({text:n});if(!i.success)throw new Pt({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 gr(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}}}});mr({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 Wo(t,e){var n,r,i,a,s,u;const o={type:"object",additionalProperties:(n=Ae(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?n:e.allowedAdditionalProperties};if(((r=t.keyType)==null?void 0:r._def.typeName)===se.ZodString&&((i=t.keyType._def.checks)!=null&&i.length)){const{type:l,...f}=Vo(t.keyType._def,e);return{...o,propertyNames:f}}else{if(((a=t.keyType)==null?void 0:a._def.typeName)===se.ZodEnum)return{...o,propertyNames:{enum:t.keyType._def.values}};if(((s=t.keyType)==null?void 0:s._def.typeName)===se.ZodBranded&&t.keyType._def.type._def.typeName===se.ZodString&&((u=t.keyType._def.type._def.checks)!=null&&u.length)){const{type:l,...f}=Yo(t.keyType._def,e);return{...o,propertyNames:f}}}return o}function lh(t,e){if(e.mapStrategy==="record")return Wo(t,e);const n=Ae(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||nt(),r=Ae(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||nt();return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function ch(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 dh(){return{not:nt()}}function fh(){return{type:"null"}}var ea={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hh(t,e){const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in ea&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,a)=>{const s=ea[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 ph(t,e)}var ph=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>Ae(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 mh(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[ea[t.innerType._def.typeName],"null"]};const n=Ae(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function gh(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 bh(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=Th(u),l=Ae(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=Eh(t,e);return a!==void 0&&(n.additionalProperties=a),n}function Eh(t,e){if(t.catchall._def.typeName!=="ZodNever")return Ae(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 Th(t){try{return t.isOptional()}catch{return!0}}var xh=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return Ae(t.innerType._def,e);const r=Ae(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:nt()},r]}:nt()},_h=(t,e)=>{if(e.pipeStrategy==="input")return Ae(t.in._def,e);if(e.pipeStrategy==="output")return Ae(t.out._def,e);const n=Ae(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=Ae(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function yh(t,e){return Ae(t.type._def,e)}function Ah(t,e){const r={type:"array",uniqueItems:!0,items:Ae(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 Ch(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Ae(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Ae(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Ae(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function kh(){return{not:nt()}}function Sh(){return nt()}var Ih=(t,e)=>Ae(t.innerType._def,e),Nh=(t,e,n)=>{switch(e){case se.ZodString:return Vo(t,n);case se.ZodNumber:return gh(t);case se.ZodObject:return bh(t,n);case se.ZodBigInt:return Zf(t);case se.ZodBoolean:return Kf();case se.ZodDate:return qo(t,n);case se.ZodUndefined:return kh();case se.ZodNull:return fh();case se.ZodArray:return Xf(t,n);case se.ZodUnion:case se.ZodDiscriminatedUnion:return hh(t,n);case se.ZodIntersection:return ah(t,n);case se.ZodTuple:return Ch(t,n);case se.ZodRecord:return Wo(t,n);case se.ZodLiteral:return sh(t);case se.ZodEnum:return rh(t);case se.ZodNativeEnum:return ch(t);case se.ZodNullable:return mh(t,n);case se.ZodOptional:return xh(t,n);case se.ZodMap:return lh(t,n);case se.ZodSet:return Ah(t,n);case se.ZodLazy:return()=>t.getter()._def;case se.ZodPromise:return yh(t,n);case se.ZodNaN:case se.ZodNever:return dh();case se.ZodEffects:return nh(t,n);case se.ZodAny:return nt();case se.ZodUnknown:return Sh();case se.ZodDefault:return th(t,n);case se.ZodBranded:return Yo(t,n);case se.ZodReadonly:return Ih(t,n);case se.ZodCatch:return Jf(t,n);case se.ZodPipeline:return _h(t,n);case se.ZodFunction:case se.ZodVoid:case se.ZodSymbol:return;default:return(r=>{})()}},wh=(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 Ae(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!==Gf)return o}if(i&&!n){const o=Rh(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=Nh(t,t.typeName,e),u=typeof s=="function"?Ae(s(),e):s;if(u&&Lh(t,e,u),e.postProcess){const o=e.postProcess(u,t,e);return a.jsonSchema=u,o}return a.jsonSchema=u,u}var Rh=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:wh(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`),nt()):e.$refStrategy==="seen"?nt():void 0}},Lh=(t,e,n)=>(t.description&&(n.description=t.description),n),Oh=t=>{const e=Qf(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}]))}},vh=(t,e)=>{var n;const r=Oh(e);let i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[f,d])=>{var h;return{...l,[f]:(h=Ae(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,f]},!0))!=null?h:nt()}},{}):void 0;const a=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=(n=Ae(t._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))!=null?n:nt(),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},ta=Symbol.for("vercel.ai.schema");function Dh(t){let e;return()=>(e==null&&(e=t()),e)}function ii(t,{validate:e}={}){return{[ta]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function Ph(t){return typeof t=="object"&&t!==null&&ta in t&&t[ta]===!0&&"jsonSchema"in t&&"validate"in t}function va(t){return t==null?ii({properties:{},additionalProperties:!1}):Ph(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Go(t):Mh(t):t()}function Mh(t){return ii(()=>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 _n({value:e,cause:n.issues})}}})}function Bh(t,e){var n;const r=(n=void 0)!=null?n:!1;return ii(()=>vh(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 Fh(t,e){var n;const r=(n=void 0)!=null?n:!1;return ii(()=>$o($d(t,{target:"draft-7",io:"input",reused:r?"ref":"inline"})),{validate:async i=>{const a=await jd(t,i);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}function Hh(t){return"_zod"in t}function Go(t,e){return Hh(t)?Fh(t):Bh(t)}async function vs({value:t,schema:e}){const n=await sr({value:t,schema:e});if(!n.success)throw _n.wrap({value:t,cause:n.error});return n.value}async function sr({value:t,schema:e}){const n=va(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:_n.wrap({value:t,cause:r.error}),rawValue:t}}catch(r){return{success:!1,error:_n.wrap({value:t,cause:r}),rawValue:t}}}async function en({text:t,schema:e}){try{const n=Wf(t);return e==null?{success:!0,value:n,rawValue:n}:await sr({value:n,schema:e})}catch(n){return{success:!1,error:ks.isInstance(n)?n:new ks({text:t,cause:n}),rawValue:void 0}}}function Uh({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new Kd).pipeThrough(new TransformStream({async transform({data:n},r){n!=="[DONE]"&&r.enqueue(await en({text:n,schema:e}))}}))}async function Ot(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var zh=Object.defineProperty,jh=(t,e)=>{for(var n in e)zh(t,n,{get:e[n],enumerable:!0})},Qo="AI_NoObjectGeneratedError",Xo=`vercel.ai.error.${Qo}`,$h=Symbol.for(Xo),Zo,Pt=class extends Mt{constructor({message:t="No object generated.",cause:e,text:n,response:r,usage:i,finishReason:a}){super({name:Qo,message:t,cause:e}),this[Zo]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Mt.hasMarker(t,Xo)}};Zo=$h;var Ds="6.0.16",Ko=Qe([V(),jr(Uint8Array),jr(ArrayBuffer),ho(t=>{var e,n;return(n=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?n:!1},{message:"Must be a Buffer"})]),ur=Yd(()=>Qe([qd(),V(),Vd(),$e(),ir(V(),ur.optional()),pr(ur)])),be=ir(V(),ir(V(),ur.optional())),Jo=ke({type:ne("text"),text:V(),providerOptions:be.optional()}),Yh=ke({type:ne("image"),image:Qe([Ko,jr(URL)]),mediaType:V().optional(),providerOptions:be.optional()}),el=ke({type:ne("file"),data:Qe([Ko,jr(URL)]),filename:V().optional(),mediaType:V(),providerOptions:be.optional()}),qh=ke({type:ne("reasoning"),text:V(),providerOptions:be.optional()}),Vh=ke({type:ne("tool-call"),toolCallId:V(),toolName:V(),input:Nt(),providerOptions:be.optional(),providerExecuted:$e().optional()}),Wh=Wd("type",[ke({type:ne("text"),value:V(),providerOptions:be.optional()}),ke({type:ne("json"),value:ur,providerOptions:be.optional()}),ke({type:ne("execution-denied"),reason:V().optional(),providerOptions:be.optional()}),ke({type:ne("error-text"),value:V(),providerOptions:be.optional()}),ke({type:ne("error-json"),value:ur,providerOptions:be.optional()}),ke({type:ne("content"),value:pr(Qe([ke({type:ne("text"),text:V(),providerOptions:be.optional()}),ke({type:ne("media"),data:V(),mediaType:V()}),ke({type:ne("file-data"),data:V(),mediaType:V(),filename:V().optional(),providerOptions:be.optional()}),ke({type:ne("file-url"),url:V(),providerOptions:be.optional()}),ke({type:ne("file-id"),fileId:Qe([V(),ir(V(),V())]),providerOptions:be.optional()}),ke({type:ne("image-data"),data:V(),mediaType:V(),providerOptions:be.optional()}),ke({type:ne("image-url"),url:V(),providerOptions:be.optional()}),ke({type:ne("image-file-id"),fileId:Qe([V(),ir(V(),V())]),providerOptions:be.optional()}),ke({type:ne("custom"),providerOptions:be.optional()})]))})]),tl=ke({type:ne("tool-result"),toolCallId:V(),toolName:V(),output:Wh,providerOptions:be.optional()}),Gh=ke({type:ne("tool-approval-request"),approvalId:V(),toolCallId:V()}),Qh=ke({type:ne("tool-approval-response"),approvalId:V(),approved:$e(),reason:V().optional()}),Xh=ke({role:ne("system"),content:V(),providerOptions:be.optional()}),Zh=ke({role:ne("user"),content:Qe([V(),pr(Qe([Jo,Yh,el]))]),providerOptions:be.optional()}),Kh=ke({role:ne("assistant"),content:Qe([V(),pr(Qe([Jo,el,qh,Vh,tl,Gh]))]),providerOptions:be.optional()}),Jh=ke({role:ne("tool"),content:pr(Qe([tl,Qh])),providerOptions:be.optional()});Qe([Xh,Zh,Kh,Jh]);function nl(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]=nl(a,i):n[r]=i}return n}var e0={};jh(e0,{array:()=>i0,choice:()=>a0,json:()=>s0,object:()=>r0,text:()=>n0});function t0(t){const e=["ROOT"];let n=-1,r=null;function i(o,l,f){switch(o){case'"':{n=l,e.pop(),e.push(f),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=l,r=l,e.pop(),e.push(f),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(f),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(f),e.push("INSIDE_NUMBER");break}case"{":{n=l,e.pop(),e.push(f),e.push("INSIDE_OBJECT_START");break}case"[":{n=l,e.pop(),e.push(f),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 d=t.substring(r,o+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(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 f=t.substring(r,t.length);"true".startsWith(f)?u+="true".slice(f.length):"false".startsWith(f)?u+="false".slice(f.length):"null".startsWith(f)&&(u+="null".slice(f.length))}}return u}async function gr(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await en({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await en({text:t0(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var n0=()=>({responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}}}),r0=({schema:t,name:e,description:n})=>{const r=va(t);return{responseFormat:Ot(r.jsonSchema).then(i=>({type:"json",schema:i,...e!=null&&{name:e},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},a){const s=await en({text:i});if(!s.success)throw new Pt({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 sr({value:s.value,schema:r});if(!u.success)throw new Pt({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 gr(i);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:a.value}}}}},i0=({element:t,name:e,description:n})=>{const r=va(t);return{responseFormat:Ot(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 en({text:i});if(!s.success)throw new Pt({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 Pt({message:"No object generated: response did not match schema.",cause:new _n({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 sr({value:o,schema:r});if(!l.success)throw new Pt({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 gr(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 f=await sr({value:l,schema:r});f.success&&o.push(f.value)}return{partial:o}}}}}},a0=({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 en({text:r});if(!a.success)throw new Pt({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 Pt({message:"No object generated: response did not match schema.",cause:new _n({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 gr(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}}}}),s0=({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 en({text:n});if(!i.success)throw new Pt({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 gr(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}}}});mr({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 u0=Dh(()=>Go(Qe([Ne({type:ne("text-start"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("text-delta"),id:V(),delta:V(),providerMetadata:be.optional()}),Ne({type:ne("text-end"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("error"),errorText:V()}),Ne({type:ne("tool-input-start"),toolCallId:V(),toolName:V(),providerExecuted:$e().optional(),dynamic:$e().optional(),title:V().optional()}),Ne({type:ne("tool-input-delta"),toolCallId:V(),inputTextDelta:V()}),Ne({type:ne("tool-input-available"),toolCallId:V(),toolName:V(),input:Nt(),providerExecuted:$e().optional(),providerMetadata:be.optional(),dynamic:$e().optional(),title:V().optional()}),Ne({type:ne("tool-input-error"),toolCallId:V(),toolName:V(),input:Nt(),providerExecuted:$e().optional(),providerMetadata:be.optional(),dynamic:$e().optional(),errorText:V(),title:V().optional()}),Ne({type:ne("tool-approval-request"),approvalId:V(),toolCallId:V()}),Ne({type:ne("tool-output-available"),toolCallId:V(),output:Nt(),providerExecuted:$e().optional(),dynamic:$e().optional(),preliminary:$e().optional()}),Ne({type:ne("tool-output-error"),toolCallId:V(),errorText:V(),providerExecuted:$e().optional(),dynamic:$e().optional()}),Ne({type:ne("tool-output-denied"),toolCallId:V()}),Ne({type:ne("reasoning-start"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("reasoning-delta"),id:V(),delta:V(),providerMetadata:be.optional()}),Ne({type:ne("reasoning-end"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("source-url"),sourceId:V(),url:V(),title:V().optional(),providerMetadata:be.optional()}),Ne({type:ne("source-document"),sourceId:V(),mediaType:V(),title:V(),filename:V().optional(),providerMetadata:be.optional()}),Ne({type:ne("file"),url:V(),mediaType:V(),providerMetadata:be.optional()}),Ne({type:ho(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:V().optional(),data:Nt(),transient:$e().optional()}),Ne({type:ne("start-step")}),Ne({type:ne("finish-step")}),Ne({type:ne("start"),messageId:V().optional(),messageMetadata:Nt().optional()}),Ne({type:ne("finish"),finishReason:Gd(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Nt().optional()}),Ne({type:ne("abort")}),Ne({type:ne("message-metadata"),messageMetadata:Nt()})])));function o0(t){return t.type.startsWith("data-")}function na(t){return t.type.startsWith("tool-")}function l0(t){return t.type==="dynamic-tool"}function ra(t){return na(t)||l0(t)}function Ps(t){return t.type.split("-").slice(1).join("-")}function c0({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function d0({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:f})=>{var d,h,p,g;function x(E){const R=l.message.parts.filter(ra).find(S=>S.toolCallId===E);if(R==null)throw new Error(`no tool invocation found for tool call ${E}`);return R}function _(E){var w;const R=l.message.parts.find(H=>na(H)&&H.toolCallId===E.toolCallId),S=E,O=R;R!=null?(R.state=E.state,O.input=S.input,O.output=S.output,O.errorText=S.errorText,O.rawInput=S.rawInput,O.preliminary=S.preliminary,E.title!==void 0&&(O.title=E.title),O.providerExecuted=(w=S.providerExecuted)!=null?w:R.providerExecuted,S.providerMetadata!=null&&R.state==="input-available"&&(R.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 b(E){var w,R;const S=l.message.parts.find($=>$.type==="dynamic-tool"&&$.toolCallId===E.toolCallId),O=E,H=S;S!=null?(S.state=E.state,H.toolName=E.toolName,H.input=O.input,H.output=O.output,H.errorText=O.errorText,H.rawInput=(w=O.rawInput)!=null?w:H.rawInput,H.preliminary=O.preliminary,E.title!==void 0&&(H.title=E.title),H.providerExecuted=(R=O.providerExecuted)!=null?R:S.providerExecuted,O.providerMetadata!=null&&S.state==="input-available"&&(S.callProviderMetadata=O.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:E.toolName,toolCallId:E.toolCallId,state:E.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,title:E.title,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function k(E){if(E!=null){const w=l.message.metadata!=null?nl(l.message.metadata,E):E;e!=null&&await vs({value:w,schema:e}),l.message.metadata=w}}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),f();break}case"text-delta":{const E=l.activeTextParts[u.id];E.text+=u.delta,E.providerMetadata=(d=u.providerMetadata)!=null?d:E.providerMetadata,f();break}case"text-end":{const E=l.activeTextParts[u.id];E.state="done",E.providerMetadata=(h=u.providerMetadata)!=null?h:E.providerMetadata,delete l.activeTextParts[u.id],f();break}case"reasoning-start":{const E={type:"reasoning",text:"",providerMetadata:u.providerMetadata,state:"streaming"};l.activeReasoningParts[u.id]=E,l.message.parts.push(E),f();break}case"reasoning-delta":{const E=l.activeReasoningParts[u.id];E.text+=u.delta,E.providerMetadata=(p=u.providerMetadata)!=null?p:E.providerMetadata,f();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],f();break}case"file":{l.message.parts.push({type:"file",mediaType:u.mediaType,url:u.url}),f();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:u.sourceId,url:u.url,title:u.title,providerMetadata:u.providerMetadata}),f();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}),f();break}case"tool-input-start":{const E=l.message.parts.filter(na);l.partialToolCalls[u.toolCallId]={text:"",toolName:u.toolName,index:E.length,dynamic:u.dynamic,title:u.title},u.dynamic?b({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}):_({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}),f();break}case"tool-input-delta":{const E=l.partialToolCalls[u.toolCallId];E.text+=u.inputTextDelta;const{value:w}=await gr(E.text);E.dynamic?b({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:w,title:E.title}):_({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:w,title:E.title}),f();break}case"tool-input-available":{u.dynamic?b({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}):_({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}),f(),a&&!u.providerExecuted&&await a({toolCall:u});break}case"tool-input-error":{u.dynamic?b({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}):_({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:void 0,rawInput:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}),f();break}case"tool-approval-request":{const E=x(u.toolCallId);E.state="approval-requested",E.approval={id:u.approvalId},f();break}case"tool-output-denied":{const E=x(u.toolCallId);E.state="output-denied",f();break}case"tool-output-available":{const E=x(u.toolCallId);E.type==="dynamic-tool"?b({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-available",input:E.input,output:u.output,preliminary:u.preliminary,providerExecuted:u.providerExecuted,title:E.title}):_({toolCallId:u.toolCallId,toolName:Ps(E),state:"output-available",input:E.input,output:u.output,providerExecuted:u.providerExecuted,preliminary:u.preliminary,title:E.title}),f();break}case"tool-output-error":{const E=x(u.toolCallId);E.type==="dynamic-tool"?b({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-error",input:E.input,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}):_({toolCallId:u.toolCallId,toolName:Ps(E),state:"output-error",input:E.input,rawInput:E.rawInput,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}),f();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 k(u.messageMetadata),(u.messageId!=null||u.messageMetadata!=null)&&f();break}case"finish":{u.finishReason!=null&&(l.finishReason=u.finishReason),await k(u.messageMetadata),u.messageMetadata!=null&&f();break}case"message-metadata":{await k(u.messageMetadata),u.messageMetadata!=null&&f();break}case"error":{i?.(new Error(u.errorText));break}default:if(o0(u)){n?.[u.type]!=null&&await vs({value:u.data,schema:n[u.type]});const E=u;if(E.transient){s?.(E);break}const w=E.id!=null?l.message.parts.find(R=>E.type===R.type&&E.id===R.id):void 0;w!=null?w.data=E.data:l.message.parts.push(E),s?.(E),f()}}o.enqueue(u)})}}))}async function f0({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()}}mr({prefix:"aitxt",size:24});mr({prefix:"aiobj",size:24});var h0=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()})}};mr({prefix:"aiobj",size:24});async function p0(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 m0=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 Ot(this.body),o=await Ot(this.headers),l=await Ot(this.credentials),f={...Vt(o),...Vt(e.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...u,...e.body},headers:f,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),h=(r=d?.api)!=null?r:this.api,p=d?.headers!==void 0?Vt(d.headers):f,g=d?.body!==void 0?d.body:{...u,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},x=(i=d?.credentials)!=null?i:l,b=await((a=this.fetch)!=null?a:globalThis.fetch)(h,{method:"POST",headers:ws({"Content-Type":"application/json",...p},`ai-sdk/${Ds}`,Ns()),body:JSON.stringify(g),credentials:x,signal:t});if(!b.ok)throw new Error((s=await b.text())!=null?s:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}async reconnectToStream(t){var e,n,r,i,a;const s=await Ot(this.body),u=await Ot(this.headers),o=await Ot(this.credentials),l={...Vt(u),...Vt(t.headers)},f=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})),d=(n=f?.api)!=null?n:`${this.api}/${t.chatId}/stream`,h=f?.headers!==void 0?Vt(f.headers):l,p=(r=f?.credentials)!=null?r:o,x=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:ws(h,`ai-sdk/${Ds}`,Ns()),credentials:p});if(x.status===204)return null;if(!x.ok)throw new Error((a=await x.text())!=null?a:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}},rl=class extends m0{constructor(t={}){super(t)}processResponseStream(t){return Uh({stream:t,schema:u0}).pipeThrough(new TransformStream({async transform(e,n){if(!e.success)throw e.error;n.enqueue(e.value)}}))}},g0=class{constructor({generateId:t=$f,id:e=t(),transport:n=new rl,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:s,onToolCall:u,onFinish:o,onData:l,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new h0,this.sendMessage=async(d,h)=>{var p,g,x,_;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let b;if("text"in d||"files"in d?b={parts:[...Array.isArray(d.files)?d.files:await p0(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:b=d,d.messageId!=null){const k=this.state.messages.findIndex(E=>E.id===d.messageId);if(k===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[k].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,k+1),this.state.replaceMessage(k,{...b,id:d.messageId,role:(g=b.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...b,id:(x=b.id)!=null?x:this.generateId(),role:(_=b.role)!=null?_:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...h})},this.regenerate=async({messageId:d,...h}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...h})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:h,reason:p})=>this.jobExecutor.run(async()=>{var g,x;const _=this.state.messages,b=_[_.length-1],k=E=>ra(E)&&E.state==="approval-requested"&&E.approval.id===d?{...E,state:"approval-responded",approval:{id:d,approved:h,reason:p}}:E;this.state.replaceMessage(_.length-1,{...b,parts:b.parts.map(k)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(k)),this.status!=="streaming"&&this.status!=="submitted"&&((g=this.sendAutomaticallyWhen)!=null&&g.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(x=this.lastMessage)==null?void 0:x.id})}),this.addToolOutput=async({state:d="output-available",tool:h,toolCallId:p,output:g,errorText:x})=>this.jobExecutor.run(async()=>{var _,b;const k=this.state.messages,E=k[k.length-1],w=R=>ra(R)&&R.toolCallId===p?{...R,state:d,output:g,errorText:x}:R;this.state.replaceMessage(k.length-1,{...E,parts:E.parts.map(w)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(w)),this.status!=="streaming"&&this.status!=="submitted"&&((_=this.sendAutomaticallyWhen)!=null&&_.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(b=this.lastMessage)==null?void 0:b.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.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=f}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 f=!1,d=!1,h=!1;try{const p={state:c0({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=p;let g;if(t==="resume-stream"){const _=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:n,body:r});if(_==null){this.setStatus({status:"ready"});return}g=_}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:e,headers:n,body:r,trigger:t,messageId:i});const x=_=>this.jobExecutor.run(()=>_({state:p.state,write:()=>{var b;this.setStatus({status:"streaming"}),p.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await f0({stream:d0({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:x,onError:_=>{throw _}}),onError:_=>{throw _}}),this.setStatus({status:"ready"})}catch(p){if(f||p.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(s=this.onFinish)==null||s.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,isError:h,finishReason:(a=this.activeResponse)==null?void 0:a.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}(u=this.sendAutomaticallyWhen)!=null&&u.call(this,{messages:this.state.messages})&&!h&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:e,headers:n,body:r})}},Ni,Ms;function b0(){if(Ms)return Ni;Ms=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 Ni=t,Ni}var E0=b0();const T0=Sa(E0);var il=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},we=(t,e,n)=>(il(t,e,"read from private field"),n?n.call(t):e.get(t)),ht=(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)},wt=(t,e,n,r)=>(il(t,e,"write to private field"),e.set(t,n),n);function x0(t,e){return e!=null?T0(t,e):t}var rt,Pr,Mr,jn,$n,Yn,hn,ia,aa,_0=class{constructor(t=[]){ht(this,rt,void 0),ht(this,Pr,"ready"),ht(this,Mr,void 0),ht(this,jn,new Set),ht(this,$n,new Set),ht(this,Yn,new Set),this.pushMessage=e=>{wt(this,rt,we(this,rt).concat(e)),we(this,hn).call(this)},this.popMessage=()=>{wt(this,rt,we(this,rt).slice(0,-1)),we(this,hn).call(this)},this.replaceMessage=(e,n)=>{wt(this,rt,[...we(this,rt).slice(0,e),this.snapshot(n),...we(this,rt).slice(e+1)]),we(this,hn).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,n)=>{const r=n?x0(e,n):e;return we(this,jn).add(r),()=>{we(this,jn).delete(r)}},this["~registerStatusCallback"]=e=>(we(this,$n).add(e),()=>{we(this,$n).delete(e)}),this["~registerErrorCallback"]=e=>(we(this,Yn).add(e),()=>{we(this,Yn).delete(e)}),ht(this,hn,()=>{we(this,jn).forEach(e=>e())}),ht(this,ia,()=>{we(this,$n).forEach(e=>e())}),ht(this,aa,()=>{we(this,Yn).forEach(e=>e())}),wt(this,rt,t)}get status(){return we(this,Pr)}set status(t){wt(this,Pr,t),we(this,ia).call(this)}get error(){return we(this,Mr)}set error(t){wt(this,Mr,t),we(this,aa).call(this)}get messages(){return we(this,rt)}set messages(t){wt(this,rt,[...t]),we(this,hn).call(this)}};rt=new WeakMap;Pr=new WeakMap;Mr=new WeakMap;jn=new WeakMap;$n=new WeakMap;Yn=new WeakMap;hn=new WeakMap;ia=new WeakMap;aa=new WeakMap;var pn,Bs=class extends g0{constructor({messages:e,...n}){const r=new _0(e);super({...n,state:r}),ht(this,pn,void 0),this["~registerMessagesCallback"]=(i,a)=>we(this,pn)["~registerMessagesCallback"](i,a),this["~registerStatusCallback"]=i=>we(this,pn)["~registerStatusCallback"](i),this["~registerErrorCallback"]=i=>we(this,pn)["~registerErrorCallback"](i),wt(this,pn,r)}};pn=new WeakMap;function y0({experimental_throttle:t,resume:e=!1,...n}={}){const r=D.useRef("chat"in n?n.chat:new Bs(n));("chat"in n&&n.chat!==r.current||"id"in n&&r.current.id!==n.id)&&(r.current="chat"in n?n.chat:new Bs(n));const a=D.useCallback(f=>r.current["~registerMessagesCallback"](f,t),[t,r.current.id]),s=D.useSyncExternalStore(a,()=>r.current.messages,()=>r.current.messages),u=D.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),o=D.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),l=D.useCallback(f=>{typeof f=="function"&&(f=f(r.current.messages)),r.current.messages=f},[r]);return D.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 A0="You are a helpful assistant.",C0=t=>new rl({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:n})=>({body:{messages:e,stream:!0,...n}})});function sA(t){const e=Z.c(37),{threadId:n,systemPrompt:r,onCreateThread:i,onError:a,onToolCall:s}=t,{org:u,locator:o}=Bt(),{slug:l}=u,f=Oa(),d=vo(),[h,p]=D.useState(null),g=Mf(n),x=r||A0;let _;e[0]!==x?(_={id:"system",role:"system",parts:[{type:"text",text:x}]},e[0]=x,e[1]=_):_=e[1];const k=_;let E;e[2]!==g||e[3]!==k?(E=[k,...g],e[2]=g,e[3]=k,e[4]=E):E=e[4];const w=E,R=`${n}:${x}`;let S;e[5]!==l?(S=C0(l),e[5]=l,e[6]=S):S=e[6];const O=S;let H;e[7]!==o||e[8]!==d||e[9]!==i||e[10]!==f||e[11]!==n?(H=async le=>{const{finishReason:Te,messages:y,isAbort:W,isDisconnect:Q,isError:X}=le;if(p(Te??null),Te!=="stop"||W||Q||X)return;const G=y.slice(-2).filter(Boolean);if(G.length!==2){console.warn("[chat] Expected 2 messages, got",G.length);return}d.insertMany.mutate(G);const ee=G.find(S0)?.parts?.find(k0)?.text.slice(0,100)||"",re=await Df(o,n);if(!re){if(i)i({id:n,title:ee});else{const he=new Date().toISOString(),Re={id:n,title:ee,created_at:he,updated_at:he,hidden:!1};f.insert.mutate(Re)}return}f.update.mutate({id:n,updates:{title:re.title||ee,updated_at:new Date().toISOString()}})},e[7]=o,e[8]=d,e[9]=i,e[10]=f,e[11]=n,e[12]=H):H=e[12];const $=H;let N;e[13]!==a?(N=le=>{console.error("[chat] Chat error:",le),a?.(le)},e[13]=a,e[14]=N):N=e[14];let M;e[15]!==w||e[16]!==R||e[17]!==$||e[18]!==s||e[19]!==N||e[20]!==O?(M={id:R,messages:w,transport:O,onFinish:$,onToolCall:s,onError:N},e[15]=w,e[16]=R,e[17]=$,e[18]=s,e[19]=N,e[20]=O,e[21]=M):M=e[21];const v=y0(M);let J;e[22]!==v?(J=async(le,Te)=>{!le?.trim()||v.status==="submitted"||v.status==="streaming"||(p(null),await v.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:le}],metadata:Te},{metadata:Te}))},e[22]=v,e[23]=J):J=e[23];const z=J,F=v.messages[0]?.role==="system"?v.messages.length===1:v.messages.length===0,K=v.messages,ie=v.status;let de;e[24]!==v?(de=v.stop.bind(v),e[24]=v,e[25]=de):de=e[25];let xe;e[26]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>p(null),e[26]=xe):xe=e[26];let I;return e[27]!==v.clearError||e[28]!==v.error||e[29]!==v.messages||e[30]!==v.setMessages||e[31]!==v.status||e[32]!==h||e[33]!==F||e[34]!==z||e[35]!==de?(I={messages:K,status:ie,sendMessage:z,stop:de,setMessages:v.setMessages,isEmpty:F,error:v.error,clearError:v.clearError,finishReason:h,clearFinishReason:xe},e[27]=v.clearError,e[28]=v.error,e[29]=v.messages,e[30]=v.setMessages,e[31]=v.status,e[32]=h,e[33]=F,e[34]=z,e[35]=de,e[36]=I):I=e[36],I}function k0(t){return t.type==="text"}function S0(t){return t.parts?.find(I0)}function I0(t){return t.type==="text"}const al={inputValue:"",branchContext:null};function N0(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"RESET":return al;default:return t}}const sl=D.createContext(null),ul=()=>crypto.randomUUID();function w0(t){const e=Z.c(16),{children:n}=t,{locator:r}=Bt(),[i,a]=D.useReducer(N0,al),s=Oa(),[u,o]=ff(hf.threadManagerState(r)+":active-id",R0);let l;e[0]!==o||e[1]!==s?(l=_=>{const b=_?.id||crypto.randomUUID(),k=new Date().toISOString(),E={id:b,title:_?.title||"",created_at:_?.created_at||k,updated_at:_?.updated_at||k,hidden:_?.hidden??!1};return s.insert.mutate(E),o(b),E},e[0]=o,e[1]=s,e[2]=l):l=e[2];const f=l;let d;e[3]!==u||e[4]!==o||e[5]!==s?(d=_=>{s.update.mutate({id:_,updates:{hidden:!0,updated_at:new Date().toISOString()}}),u===_&&o(ul())},e[3]=u,e[4]=o,e[5]=s,e[6]=d):d=e[6];const h=d;let p;e[7]!==u||e[8]!==f||e[9]!==h||e[10]!==i||e[11]!==o?(p={interactionState:i,interactionDispatch:a,activeThreadId:u,createThread:f,setActiveThreadId:o,hideThread:h},e[7]=u,e[8]=f,e[9]=h,e[10]=i,e[11]=o,e[12]=p):p=e[12];const g=p;let x;return e[13]!==n||e[14]!==g?(x=m.jsx(sl.Provider,{value:g,children:n}),e[13]=n,e[14]=g,e[15]=x):x=e[15],x}function R0(t){return t||ul()}function L0(){const t=Z.c(16),e=D.useContext(sl);if(!e)throw new Error("useChat must be used within a ChatProvider");const{interactionState:n,interactionDispatch:r}=e;let i,a,s,u;t[0]!==r?(i=l=>r({type:"SET_INPUT",payload:l}),a=l=>r({type:"START_BRANCH",payload:l}),s=()=>r({type:"CLEAR_BRANCH"}),u=()=>r({type:"RESET"}),t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=u):(i=t[1],a=t[2],s=t[3],u=t[4]);let o;return t[5]!==e.activeThreadId||t[6]!==e.createThread||t[7]!==e.hideThread||t[8]!==e.setActiveThreadId||t[9]!==n.branchContext||t[10]!==n.inputValue||t[11]!==i||t[12]!==a||t[13]!==s||t[14]!==u?(o={inputValue:n.inputValue,branchContext:n.branchContext,setInputValue:i,startBranch:a,clearBranch:s,reset:u,activeThreadId:e.activeThreadId,createThread:e.createThread,setActiveThreadId:e.setActiveThreadId,hideThread:e.hideThread},t[5]=e.activeThreadId,t[6]=e.createThread,t[7]=e.hideThread,t[8]=e.setActiveThreadId,t[9]=n.branchContext,t[10]=n.inputValue,t[11]=i,t[12]=a,t[13]=s,t[14]=u,t[15]=o):o=t[15],o}function uA(t){const e=Z.c(19),{prompts:n,onSelect:r,className:i}=t;if(n.length===0)return null;let a,s,u,o;if(e[0]!==i||e[1]!==r||e[2]!==n){const d=n.slice(0,4);e[7]!==i?(u=ue("flex flex-col gap-3 flex-1",i),e[7]=i,e[8]=u):u=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Try asking"}),e[9]=o):o=e[9],a="grid grid-cols-1 sm:grid-cols-2 gap-2";let h;e[10]!==r?(h=p=>m.jsxs("button",{type:"button",onClick:()=>r(p),className:ue("flex items-start gap-3 p-3 rounded-xl","bg-muted/50 hover:bg-muted transition-colors","text-left cursor-pointer group","border border-transparent hover:border-border"),children:[m.jsx("div",{className:"shrink-0 mt-0.5",children:m.jsx(Io,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors"})}),m.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:(p.title??p.name).replace(/_/g," ")}),p.description&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:p.description})]})]},p.name),e[10]=r,e[11]=h):h=e[11],s=d.map(h),e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=s,e[5]=u,e[6]=o}else a=e[3],s=e[4],u=e[5],o=e[6];let l;e[12]!==a||e[13]!==s?(l=m.jsx("div",{className:a,children:s}),e[12]=a,e[13]=s,e[14]=l):l=e[14];let f;return e[15]!==u||e[16]!==o||e[17]!==l?(f=m.jsxs("div",{className:u,children:[o,l]}),e[15]=u,e[16]=o,e[17]=l,e[18]=f):f=e[18],f}function O0(t){const e=Z.c(66),{value:n,onChange:r,onSubmit:i,onStop:a,disabled:s,isStreaming:u,placeholder:o,className:l,centered:f,contextContent:d,leftActions:h,rightActions:p,maxTextHeight:g,children:x}=t,_=o===void 0?"Ask anything or @ for context":o,b=g===void 0?"164px":g;let k;e[0]!==s||e[1]!==u||e[2]!==n?(k=!s&&!u&&n.trim().length>0,e[0]=s,e[1]=u,e[2]=n,e[3]=k):k=e[3];const E=k;let w;e[4]!==E||e[5]!==u||e[6]!==a||e[7]!==i?(w=me=>{me.preventDefault(),u&&a?a():E&&i()},e[4]=E,e[5]=u,e[6]=a,e[7]=i,e[8]=w):w=e[8];const R=w;let S;e[9]!==E||e[10]!==i?(S=me=>{me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),E&&i())},e[9]=E,e[10]=i,e[11]=S):S=e[11];const O=S;let H;e[12]!==l?(H=ue("w-full",l),e[12]=l,e[13]=H):H=e[13];let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=ue("relative rounded-xl border border-border bg-background w-full min-h-[130px] flex flex-col"),e[14]=$):$=e[14];let N;e[15]!==d?(N=d&&m.jsx("div",{className:"mb-1",children:d}),e[15]=d,e[16]=N):N=e[16];let M;e[17]!==b?(M={maxHeight:b},e[17]=b,e[18]=M):M=e[18];let v;e[19]!==r?(v=me=>r(me.target.value),e[19]=r,e[20]=v):v=e[20];const J=s||u;let z;e[21]===Symbol.for("react.memo_cache_sentinel")?(z=ue("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]=z):z=e[21];let F;e[22]===Symbol.for("react.memo_cache_sentinel")?(F={minHeight:"20px",height:"auto",overflow:"hidden"},e[22]=F):F=e[22];let K;e[23]!==O||e[24]!==_||e[25]!==v||e[26]!==J||e[27]!==n?(K=m.jsx(df,{value:n,onChange:v,onKeyDown:O,placeholder:_,disabled:J,className:z,rows:1,style:F}),e[23]=O,e[24]=_,e[25]=v,e[26]=J,e[27]=n,e[28]=K):K=e[28];let ie;e[29]!==M||e[30]!==K?(ie=m.jsx("div",{className:"overflow-y-auto relative flex-1",style:M,children:K}),e[29]=M,e[30]=K,e[31]=ie):ie=e[31];let de;e[32]!==ie||e[33]!==N?(de=m.jsxs("div",{className:"relative flex flex-col gap-2 p-2.5 flex-1",children:[N,ie]}),e[32]=ie,e[33]=N,e[34]=de):de=e[34];let xe;e[35]!==x||e[36]!==h?(xe=m.jsxs("div",{className:"flex items-center overflow-hidden gap-2 min-w-0",children:[h,x]}),e[35]=x,e[36]=h,e[37]=xe):xe=e[37];const I=u?"button":"submit";let le;e[38]!==u||e[39]!==a?(le=me=>{u&&(me.preventDefault(),me.stopPropagation(),a?.())},e[38]=u,e[39]=a,e[40]=le):le=e[40];const Te=E||u?"default":"ghost",y=!E&&!u,W=!E&&!u&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let Q;e[41]!==W?(Q=ue("size-8 rounded-full transition-all",W),e[41]=W,e[42]=Q):Q=e[42];const X=u?"Stop generating":"Send message (Enter)";let G;e[43]!==u?(G=u?m.jsx(No,{size:20}):m.jsx(lf,{size:20}),e[43]=u,e[44]=G):G=e[44];let ee;e[45]!==I||e[46]!==le||e[47]!==Te||e[48]!==y||e[49]!==Q||e[50]!==X||e[51]!==G?(ee=m.jsx(st,{type:I,onClick:le,variant:Te,size:"icon",disabled:y,className:Q,title:X,children:G}),e[45]=I,e[46]=le,e[47]=Te,e[48]=y,e[49]=Q,e[50]=X,e[51]=G,e[52]=ee):ee=e[52];let re;e[53]!==p||e[54]!==ee?(re=m.jsxs("div",{className:"flex items-center gap-1",children:[p,ee]}),e[53]=p,e[54]=ee,e[55]=re):re=e[55];let he;e[56]!==xe||e[57]!==re?(he=m.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[xe,re]}),e[56]=xe,e[57]=re,e[58]=he):he=e[58];let Re;e[59]!==de||e[60]!==he?(Re=m.jsxs("div",{className:$,children:[de,he]}),e[59]=de,e[60]=he,e[61]=Re):Re=e[61];let Be;return e[62]!==R||e[63]!==Re||e[64]!==H?(Be=m.jsx("form",{onSubmit:R,className:H,children:Re}),e[62]=R,e[63]=Re,e[64]=H,e[65]=Be):Be=e[65],Be}function v0(){const t=Z.c(3),[e,n]=D.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 Da(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var an=Da();function ol(t){an=t}var Qn={exec:()=>null};function _e(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(qe.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var qe={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")},D0=/^(?:[ \t]*(?:\n|$))+/,P0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,M0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,br=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,B0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pa=/(?:[*+-]|\d{1,9}[.)])/,ll=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cl=_e(ll).replace(/bull/g,Pa).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(),F0=_e(ll).replace(/bull/g,Pa).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(),Ma=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,H0=/^[^\n]+/,Ba=/(?!\s*\])(?:\\.|[^\[\]\\])+/,U0=_e(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ba).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),z0=_e(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pa).getRegex(),ai="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",Fa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,j0=_e("^ {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",Fa).replace("tag",ai).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dl=_e(Ma).replace("hr",br).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",ai).getRegex(),$0=_e(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",dl).getRegex(),Ha={blockquote:$0,code:P0,def:U0,fences:M0,heading:B0,hr:br,html:j0,lheading:cl,list:z0,newline:D0,paragraph:dl,table:Qn,text:H0},Fs=_e("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",br).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",ai).getRegex(),Y0={...Ha,lheading:F0,table:Fs,paragraph:_e(Ma).replace("hr",br).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fs).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",ai).getRegex()},q0={...Ha,html:_e(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Fa).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:Qn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_e(Ma).replace("hr",br).replace("heading",` *#{1,6} *[^
|
|
12
|
+
`)}})}});var u0=Dh(()=>Go(Qe([Ne({type:ne("text-start"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("text-delta"),id:V(),delta:V(),providerMetadata:be.optional()}),Ne({type:ne("text-end"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("error"),errorText:V()}),Ne({type:ne("tool-input-start"),toolCallId:V(),toolName:V(),providerExecuted:$e().optional(),dynamic:$e().optional(),title:V().optional()}),Ne({type:ne("tool-input-delta"),toolCallId:V(),inputTextDelta:V()}),Ne({type:ne("tool-input-available"),toolCallId:V(),toolName:V(),input:Nt(),providerExecuted:$e().optional(),providerMetadata:be.optional(),dynamic:$e().optional(),title:V().optional()}),Ne({type:ne("tool-input-error"),toolCallId:V(),toolName:V(),input:Nt(),providerExecuted:$e().optional(),providerMetadata:be.optional(),dynamic:$e().optional(),errorText:V(),title:V().optional()}),Ne({type:ne("tool-approval-request"),approvalId:V(),toolCallId:V()}),Ne({type:ne("tool-output-available"),toolCallId:V(),output:Nt(),providerExecuted:$e().optional(),dynamic:$e().optional(),preliminary:$e().optional()}),Ne({type:ne("tool-output-error"),toolCallId:V(),errorText:V(),providerExecuted:$e().optional(),dynamic:$e().optional()}),Ne({type:ne("tool-output-denied"),toolCallId:V()}),Ne({type:ne("reasoning-start"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("reasoning-delta"),id:V(),delta:V(),providerMetadata:be.optional()}),Ne({type:ne("reasoning-end"),id:V(),providerMetadata:be.optional()}),Ne({type:ne("source-url"),sourceId:V(),url:V(),title:V().optional(),providerMetadata:be.optional()}),Ne({type:ne("source-document"),sourceId:V(),mediaType:V(),title:V(),filename:V().optional(),providerMetadata:be.optional()}),Ne({type:ne("file"),url:V(),mediaType:V(),providerMetadata:be.optional()}),Ne({type:ho(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:V().optional(),data:Nt(),transient:$e().optional()}),Ne({type:ne("start-step")}),Ne({type:ne("finish-step")}),Ne({type:ne("start"),messageId:V().optional(),messageMetadata:Nt().optional()}),Ne({type:ne("finish"),finishReason:Gd(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Nt().optional()}),Ne({type:ne("abort"),reason:V().optional()}),Ne({type:ne("message-metadata"),messageMetadata:Nt()})])));function o0(t){return t.type.startsWith("data-")}function na(t){return t.type.startsWith("tool-")}function l0(t){return t.type==="dynamic-tool"}function ra(t){return na(t)||l0(t)}function Ps(t){return t.type.split("-").slice(1).join("-")}function c0({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function d0({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:f})=>{var d,h,p,g;function x(E){const R=l.message.parts.filter(ra).find(S=>S.toolCallId===E);if(R==null)throw new Error(`no tool invocation found for tool call ${E}`);return R}function _(E){var w;const R=l.message.parts.find(H=>na(H)&&H.toolCallId===E.toolCallId),S=E,O=R;R!=null?(R.state=E.state,O.input=S.input,O.output=S.output,O.errorText=S.errorText,O.rawInput=S.rawInput,O.preliminary=S.preliminary,E.title!==void 0&&(O.title=E.title),O.providerExecuted=(w=S.providerExecuted)!=null?w:R.providerExecuted,S.providerMetadata!=null&&R.state==="input-available"&&(R.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 b(E){var w,R;const S=l.message.parts.find($=>$.type==="dynamic-tool"&&$.toolCallId===E.toolCallId),O=E,H=S;S!=null?(S.state=E.state,H.toolName=E.toolName,H.input=O.input,H.output=O.output,H.errorText=O.errorText,H.rawInput=(w=O.rawInput)!=null?w:H.rawInput,H.preliminary=O.preliminary,E.title!==void 0&&(H.title=E.title),H.providerExecuted=(R=O.providerExecuted)!=null?R:S.providerExecuted,O.providerMetadata!=null&&S.state==="input-available"&&(S.callProviderMetadata=O.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:E.toolName,toolCallId:E.toolCallId,state:E.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,title:E.title,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function k(E){if(E!=null){const w=l.message.metadata!=null?nl(l.message.metadata,E):E;e!=null&&await vs({value:w,schema:e}),l.message.metadata=w}}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),f();break}case"text-delta":{const E=l.activeTextParts[u.id];E.text+=u.delta,E.providerMetadata=(d=u.providerMetadata)!=null?d:E.providerMetadata,f();break}case"text-end":{const E=l.activeTextParts[u.id];E.state="done",E.providerMetadata=(h=u.providerMetadata)!=null?h:E.providerMetadata,delete l.activeTextParts[u.id],f();break}case"reasoning-start":{const E={type:"reasoning",text:"",providerMetadata:u.providerMetadata,state:"streaming"};l.activeReasoningParts[u.id]=E,l.message.parts.push(E),f();break}case"reasoning-delta":{const E=l.activeReasoningParts[u.id];E.text+=u.delta,E.providerMetadata=(p=u.providerMetadata)!=null?p:E.providerMetadata,f();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],f();break}case"file":{l.message.parts.push({type:"file",mediaType:u.mediaType,url:u.url}),f();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:u.sourceId,url:u.url,title:u.title,providerMetadata:u.providerMetadata}),f();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}),f();break}case"tool-input-start":{const E=l.message.parts.filter(na);l.partialToolCalls[u.toolCallId]={text:"",toolName:u.toolName,index:E.length,dynamic:u.dynamic,title:u.title},u.dynamic?b({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}):_({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title}),f();break}case"tool-input-delta":{const E=l.partialToolCalls[u.toolCallId];E.text+=u.inputTextDelta;const{value:w}=await gr(E.text);E.dynamic?b({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:w,title:E.title}):_({toolCallId:u.toolCallId,toolName:E.toolName,state:"input-streaming",input:w,title:E.title}),f();break}case"tool-input-available":{u.dynamic?b({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}):_({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}),f(),a&&!u.providerExecuted&&await a({toolCall:u});break}case"tool-input-error":{u.dynamic?b({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}):_({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:void 0,rawInput:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}),f();break}case"tool-approval-request":{const E=x(u.toolCallId);E.state="approval-requested",E.approval={id:u.approvalId},f();break}case"tool-output-denied":{const E=x(u.toolCallId);E.state="output-denied",f();break}case"tool-output-available":{const E=x(u.toolCallId);E.type==="dynamic-tool"?b({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-available",input:E.input,output:u.output,preliminary:u.preliminary,providerExecuted:u.providerExecuted,title:E.title}):_({toolCallId:u.toolCallId,toolName:Ps(E),state:"output-available",input:E.input,output:u.output,providerExecuted:u.providerExecuted,preliminary:u.preliminary,title:E.title}),f();break}case"tool-output-error":{const E=x(u.toolCallId);E.type==="dynamic-tool"?b({toolCallId:u.toolCallId,toolName:E.toolName,state:"output-error",input:E.input,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}):_({toolCallId:u.toolCallId,toolName:Ps(E),state:"output-error",input:E.input,rawInput:E.rawInput,errorText:u.errorText,providerExecuted:u.providerExecuted,title:E.title}),f();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 k(u.messageMetadata),(u.messageId!=null||u.messageMetadata!=null)&&f();break}case"finish":{u.finishReason!=null&&(l.finishReason=u.finishReason),await k(u.messageMetadata),u.messageMetadata!=null&&f();break}case"message-metadata":{await k(u.messageMetadata),u.messageMetadata!=null&&f();break}case"error":{i?.(new Error(u.errorText));break}default:if(o0(u)){n?.[u.type]!=null&&await vs({value:u.data,schema:n[u.type]});const E=u;if(E.transient){s?.(E);break}const w=E.id!=null?l.message.parts.find(R=>E.type===R.type&&E.id===R.id):void 0;w!=null?w.data=E.data:l.message.parts.push(E),s?.(E),f()}}o.enqueue(u)})}}))}async function f0({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()}}mr({prefix:"aitxt",size:24});mr({prefix:"aiobj",size:24});var h0=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()})}};mr({prefix:"aiobj",size:24});async function p0(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 m0=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 Ot(this.body),o=await Ot(this.headers),l=await Ot(this.credentials),f={...Vt(o),...Vt(e.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...u,...e.body},headers:f,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),h=(r=d?.api)!=null?r:this.api,p=d?.headers!==void 0?Vt(d.headers):f,g=d?.body!==void 0?d.body:{...u,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},x=(i=d?.credentials)!=null?i:l,b=await((a=this.fetch)!=null?a:globalThis.fetch)(h,{method:"POST",headers:ws({"Content-Type":"application/json",...p},`ai-sdk/${Ds}`,Ns()),body:JSON.stringify(g),credentials:x,signal:t});if(!b.ok)throw new Error((s=await b.text())!=null?s:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}async reconnectToStream(t){var e,n,r,i,a;const s=await Ot(this.body),u=await Ot(this.headers),o=await Ot(this.credentials),l={...Vt(u),...Vt(t.headers)},f=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})),d=(n=f?.api)!=null?n:`${this.api}/${t.chatId}/stream`,h=f?.headers!==void 0?Vt(f.headers):l,p=(r=f?.credentials)!=null?r:o,x=await((i=this.fetch)!=null?i:globalThis.fetch)(d,{method:"GET",headers:ws(h,`ai-sdk/${Ds}`,Ns()),credentials:p});if(x.status===204)return null;if(!x.ok)throw new Error((a=await x.text())!=null?a:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}},rl=class extends m0{constructor(t={}){super(t)}processResponseStream(t){return Uh({stream:t,schema:u0}).pipeThrough(new TransformStream({async transform(e,n){if(!e.success)throw e.error;n.enqueue(e.value)}}))}},g0=class{constructor({generateId:t=$f,id:e=t(),transport:n=new rl,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:s,onToolCall:u,onFinish:o,onData:l,sendAutomaticallyWhen:f}){this.activeResponse=void 0,this.jobExecutor=new h0,this.sendMessage=async(d,h)=>{var p,g,x,_;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...h});return}let b;if("text"in d||"files"in d?b={parts:[...Array.isArray(d.files)?d.files:await p0(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:b=d,d.messageId!=null){const k=this.state.messages.findIndex(E=>E.id===d.messageId);if(k===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[k].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,k+1),this.state.replaceMessage(k,{...b,id:d.messageId,role:(g=b.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...b,id:(x=b.id)!=null?x:this.generateId(),role:(_=b.role)!=null?_:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...h})},this.regenerate=async({messageId:d,...h}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...h})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:d,approved:h,reason:p})=>this.jobExecutor.run(async()=>{var g,x;const _=this.state.messages,b=_[_.length-1],k=E=>ra(E)&&E.state==="approval-requested"&&E.approval.id===d?{...E,state:"approval-responded",approval:{id:d,approved:h,reason:p}}:E;this.state.replaceMessage(_.length-1,{...b,parts:b.parts.map(k)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(k)),this.status!=="streaming"&&this.status!=="submitted"&&((g=this.sendAutomaticallyWhen)!=null&&g.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(x=this.lastMessage)==null?void 0:x.id})}),this.addToolOutput=async({state:d="output-available",tool:h,toolCallId:p,output:g,errorText:x})=>this.jobExecutor.run(async()=>{var _,b;const k=this.state.messages,E=k[k.length-1],w=R=>ra(R)&&R.toolCallId===p?{...R,state:d,output:g,errorText:x}:R;this.state.replaceMessage(k.length-1,{...E,parts:E.parts.map(w)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(w)),this.status!=="streaming"&&this.status!=="submitted"&&((_=this.sendAutomaticallyWhen)!=null&&_.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(b=this.lastMessage)==null?void 0:b.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.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=f}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 f=!1,d=!1,h=!1;try{const p={state:c0({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{f=!0}),this.activeResponse=p;let g;if(t==="resume-stream"){const _=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:n,body:r});if(_==null){this.setStatus({status:"ready"});return}g=_}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:e,headers:n,body:r,trigger:t,messageId:i});const x=_=>this.jobExecutor.run(()=>_({state:p.state,write:()=>{var b;this.setStatus({status:"streaming"}),p.state.message.id===((b=this.lastMessage)==null?void 0:b.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await f0({stream:d0({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:x,onError:_=>{throw _}}),onError:_=>{throw _}}),this.setStatus({status:"ready"})}catch(p){if(f||p.name==="AbortError")return f=!0,this.setStatus({status:"ready"}),null;h=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(s=this.onFinish)==null||s.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:f,isDisconnect:d,isError:h,finishReason:(a=this.activeResponse)==null?void 0:a.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}(u=this.sendAutomaticallyWhen)!=null&&u.call(this,{messages:this.state.messages})&&!h&&await this.makeRequest({trigger:"submit-message",messageId:(o=this.lastMessage)==null?void 0:o.id,metadata:e,headers:n,body:r})}},Ni,Ms;function b0(){if(Ms)return Ni;Ms=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 Ni=t,Ni}var E0=b0();const T0=Sa(E0);var il=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)},we=(t,e,n)=>(il(t,e,"read from private field"),n?n.call(t):e.get(t)),ht=(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)},wt=(t,e,n,r)=>(il(t,e,"write to private field"),e.set(t,n),n);function x0(t,e){return e!=null?T0(t,e):t}var rt,Pr,Mr,jn,$n,Yn,hn,ia,aa,_0=class{constructor(t=[]){ht(this,rt,void 0),ht(this,Pr,"ready"),ht(this,Mr,void 0),ht(this,jn,new Set),ht(this,$n,new Set),ht(this,Yn,new Set),this.pushMessage=e=>{wt(this,rt,we(this,rt).concat(e)),we(this,hn).call(this)},this.popMessage=()=>{wt(this,rt,we(this,rt).slice(0,-1)),we(this,hn).call(this)},this.replaceMessage=(e,n)=>{wt(this,rt,[...we(this,rt).slice(0,e),this.snapshot(n),...we(this,rt).slice(e+1)]),we(this,hn).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,n)=>{const r=n?x0(e,n):e;return we(this,jn).add(r),()=>{we(this,jn).delete(r)}},this["~registerStatusCallback"]=e=>(we(this,$n).add(e),()=>{we(this,$n).delete(e)}),this["~registerErrorCallback"]=e=>(we(this,Yn).add(e),()=>{we(this,Yn).delete(e)}),ht(this,hn,()=>{we(this,jn).forEach(e=>e())}),ht(this,ia,()=>{we(this,$n).forEach(e=>e())}),ht(this,aa,()=>{we(this,Yn).forEach(e=>e())}),wt(this,rt,t)}get status(){return we(this,Pr)}set status(t){wt(this,Pr,t),we(this,ia).call(this)}get error(){return we(this,Mr)}set error(t){wt(this,Mr,t),we(this,aa).call(this)}get messages(){return we(this,rt)}set messages(t){wt(this,rt,[...t]),we(this,hn).call(this)}};rt=new WeakMap;Pr=new WeakMap;Mr=new WeakMap;jn=new WeakMap;$n=new WeakMap;Yn=new WeakMap;hn=new WeakMap;ia=new WeakMap;aa=new WeakMap;var pn,Bs=class extends g0{constructor({messages:e,...n}){const r=new _0(e);super({...n,state:r}),ht(this,pn,void 0),this["~registerMessagesCallback"]=(i,a)=>we(this,pn)["~registerMessagesCallback"](i,a),this["~registerStatusCallback"]=i=>we(this,pn)["~registerStatusCallback"](i),this["~registerErrorCallback"]=i=>we(this,pn)["~registerErrorCallback"](i),wt(this,pn,r)}};pn=new WeakMap;function y0({experimental_throttle:t,resume:e=!1,...n}={}){const r=D.useRef("chat"in n?n.chat:new Bs(n));("chat"in n&&n.chat!==r.current||"id"in n&&r.current.id!==n.id)&&(r.current="chat"in n?n.chat:new Bs(n));const a=D.useCallback(f=>r.current["~registerMessagesCallback"](f,t),[t,r.current.id]),s=D.useSyncExternalStore(a,()=>r.current.messages,()=>r.current.messages),u=D.useSyncExternalStore(r.current["~registerStatusCallback"],()=>r.current.status,()=>r.current.status),o=D.useSyncExternalStore(r.current["~registerErrorCallback"],()=>r.current.error,()=>r.current.error),l=D.useCallback(f=>{typeof f=="function"&&(f=f(r.current.messages)),r.current.messages=f},[r]);return D.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 A0="You are a helpful assistant.",C0=t=>new rl({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:n})=>({body:{messages:e,stream:!0,...n}})});function sA(t){const e=Z.c(37),{threadId:n,systemPrompt:r,onCreateThread:i,onError:a,onToolCall:s}=t,{org:u,locator:o}=Bt(),{slug:l}=u,f=Oa(),d=vo(),[h,p]=D.useState(null),g=Mf(n),x=r||A0;let _;e[0]!==x?(_={id:"system",role:"system",parts:[{type:"text",text:x}]},e[0]=x,e[1]=_):_=e[1];const k=_;let E;e[2]!==g||e[3]!==k?(E=[k,...g],e[2]=g,e[3]=k,e[4]=E):E=e[4];const w=E,R=`${n}:${x}`;let S;e[5]!==l?(S=C0(l),e[5]=l,e[6]=S):S=e[6];const O=S;let H;e[7]!==o||e[8]!==d||e[9]!==i||e[10]!==f||e[11]!==n?(H=async le=>{const{finishReason:Te,messages:y,isAbort:W,isDisconnect:Q,isError:X}=le;if(p(Te??null),Te!=="stop"||W||Q||X)return;const G=y.slice(-2).filter(Boolean);if(G.length!==2){console.warn("[chat] Expected 2 messages, got",G.length);return}d.insertMany.mutate(G);const ee=G.find(S0)?.parts?.find(k0)?.text.slice(0,100)||"",re=await Df(o,n);if(!re){if(i)i({id:n,title:ee});else{const he=new Date().toISOString(),Re={id:n,title:ee,created_at:he,updated_at:he,hidden:!1};f.insert.mutate(Re)}return}f.update.mutate({id:n,updates:{title:re.title||ee,updated_at:new Date().toISOString()}})},e[7]=o,e[8]=d,e[9]=i,e[10]=f,e[11]=n,e[12]=H):H=e[12];const $=H;let N;e[13]!==a?(N=le=>{console.error("[chat] Chat error:",le),a?.(le)},e[13]=a,e[14]=N):N=e[14];let M;e[15]!==w||e[16]!==R||e[17]!==$||e[18]!==s||e[19]!==N||e[20]!==O?(M={id:R,messages:w,transport:O,onFinish:$,onToolCall:s,onError:N},e[15]=w,e[16]=R,e[17]=$,e[18]=s,e[19]=N,e[20]=O,e[21]=M):M=e[21];const v=y0(M);let J;e[22]!==v?(J=async(le,Te)=>{!le?.trim()||v.status==="submitted"||v.status==="streaming"||(p(null),await v.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:le}],metadata:Te},{metadata:Te}))},e[22]=v,e[23]=J):J=e[23];const z=J,F=v.messages[0]?.role==="system"?v.messages.length===1:v.messages.length===0,K=v.messages,ie=v.status;let de;e[24]!==v?(de=v.stop.bind(v),e[24]=v,e[25]=de):de=e[25];let xe;e[26]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>p(null),e[26]=xe):xe=e[26];let I;return e[27]!==v.clearError||e[28]!==v.error||e[29]!==v.messages||e[30]!==v.setMessages||e[31]!==v.status||e[32]!==h||e[33]!==F||e[34]!==z||e[35]!==de?(I={messages:K,status:ie,sendMessage:z,stop:de,setMessages:v.setMessages,isEmpty:F,error:v.error,clearError:v.clearError,finishReason:h,clearFinishReason:xe},e[27]=v.clearError,e[28]=v.error,e[29]=v.messages,e[30]=v.setMessages,e[31]=v.status,e[32]=h,e[33]=F,e[34]=z,e[35]=de,e[36]=I):I=e[36],I}function k0(t){return t.type==="text"}function S0(t){return t.parts?.find(I0)}function I0(t){return t.type==="text"}const al={inputValue:"",branchContext:null};function N0(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"RESET":return al;default:return t}}const sl=D.createContext(null),ul=()=>crypto.randomUUID();function w0(t){const e=Z.c(16),{children:n}=t,{locator:r}=Bt(),[i,a]=D.useReducer(N0,al),s=Oa(),[u,o]=ff(hf.threadManagerState(r)+":active-id",R0);let l;e[0]!==o||e[1]!==s?(l=_=>{const b=_?.id||crypto.randomUUID(),k=new Date().toISOString(),E={id:b,title:_?.title||"",created_at:_?.created_at||k,updated_at:_?.updated_at||k,hidden:_?.hidden??!1};return s.insert.mutate(E),o(b),E},e[0]=o,e[1]=s,e[2]=l):l=e[2];const f=l;let d;e[3]!==u||e[4]!==o||e[5]!==s?(d=_=>{s.update.mutate({id:_,updates:{hidden:!0,updated_at:new Date().toISOString()}}),u===_&&o(ul())},e[3]=u,e[4]=o,e[5]=s,e[6]=d):d=e[6];const h=d;let p;e[7]!==u||e[8]!==f||e[9]!==h||e[10]!==i||e[11]!==o?(p={interactionState:i,interactionDispatch:a,activeThreadId:u,createThread:f,setActiveThreadId:o,hideThread:h},e[7]=u,e[8]=f,e[9]=h,e[10]=i,e[11]=o,e[12]=p):p=e[12];const g=p;let x;return e[13]!==n||e[14]!==g?(x=m.jsx(sl.Provider,{value:g,children:n}),e[13]=n,e[14]=g,e[15]=x):x=e[15],x}function R0(t){return t||ul()}function L0(){const t=Z.c(16),e=D.useContext(sl);if(!e)throw new Error("useChat must be used within a ChatProvider");const{interactionState:n,interactionDispatch:r}=e;let i,a,s,u;t[0]!==r?(i=l=>r({type:"SET_INPUT",payload:l}),a=l=>r({type:"START_BRANCH",payload:l}),s=()=>r({type:"CLEAR_BRANCH"}),u=()=>r({type:"RESET"}),t[0]=r,t[1]=i,t[2]=a,t[3]=s,t[4]=u):(i=t[1],a=t[2],s=t[3],u=t[4]);let o;return t[5]!==e.activeThreadId||t[6]!==e.createThread||t[7]!==e.hideThread||t[8]!==e.setActiveThreadId||t[9]!==n.branchContext||t[10]!==n.inputValue||t[11]!==i||t[12]!==a||t[13]!==s||t[14]!==u?(o={inputValue:n.inputValue,branchContext:n.branchContext,setInputValue:i,startBranch:a,clearBranch:s,reset:u,activeThreadId:e.activeThreadId,createThread:e.createThread,setActiveThreadId:e.setActiveThreadId,hideThread:e.hideThread},t[5]=e.activeThreadId,t[6]=e.createThread,t[7]=e.hideThread,t[8]=e.setActiveThreadId,t[9]=n.branchContext,t[10]=n.inputValue,t[11]=i,t[12]=a,t[13]=s,t[14]=u,t[15]=o):o=t[15],o}function uA(t){const e=Z.c(19),{prompts:n,onSelect:r,className:i}=t;if(n.length===0)return null;let a,s,u,o;if(e[0]!==i||e[1]!==r||e[2]!==n){const d=n.slice(0,4);e[7]!==i?(u=ue("flex flex-col gap-3 flex-1",i),e[7]=i,e[8]=u):u=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Try asking"}),e[9]=o):o=e[9],a="grid grid-cols-1 sm:grid-cols-2 gap-2";let h;e[10]!==r?(h=p=>m.jsxs("button",{type:"button",onClick:()=>r(p),className:ue("flex items-start gap-3 p-3 rounded-xl","bg-muted/50 hover:bg-muted transition-colors","text-left cursor-pointer group","border border-transparent hover:border-border"),children:[m.jsx("div",{className:"shrink-0 mt-0.5",children:m.jsx(Io,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors"})}),m.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:(p.title??p.name).replace(/_/g," ")}),p.description&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:p.description})]})]},p.name),e[10]=r,e[11]=h):h=e[11],s=d.map(h),e[0]=i,e[1]=r,e[2]=n,e[3]=a,e[4]=s,e[5]=u,e[6]=o}else a=e[3],s=e[4],u=e[5],o=e[6];let l;e[12]!==a||e[13]!==s?(l=m.jsx("div",{className:a,children:s}),e[12]=a,e[13]=s,e[14]=l):l=e[14];let f;return e[15]!==u||e[16]!==o||e[17]!==l?(f=m.jsxs("div",{className:u,children:[o,l]}),e[15]=u,e[16]=o,e[17]=l,e[18]=f):f=e[18],f}function O0(t){const e=Z.c(66),{value:n,onChange:r,onSubmit:i,onStop:a,disabled:s,isStreaming:u,placeholder:o,className:l,centered:f,contextContent:d,leftActions:h,rightActions:p,maxTextHeight:g,children:x}=t,_=o===void 0?"Ask anything or @ for context":o,b=g===void 0?"164px":g;let k;e[0]!==s||e[1]!==u||e[2]!==n?(k=!s&&!u&&n.trim().length>0,e[0]=s,e[1]=u,e[2]=n,e[3]=k):k=e[3];const E=k;let w;e[4]!==E||e[5]!==u||e[6]!==a||e[7]!==i?(w=me=>{me.preventDefault(),u&&a?a():E&&i()},e[4]=E,e[5]=u,e[6]=a,e[7]=i,e[8]=w):w=e[8];const R=w;let S;e[9]!==E||e[10]!==i?(S=me=>{me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),E&&i())},e[9]=E,e[10]=i,e[11]=S):S=e[11];const O=S;let H;e[12]!==l?(H=ue("w-full",l),e[12]=l,e[13]=H):H=e[13];let $;e[14]===Symbol.for("react.memo_cache_sentinel")?($=ue("relative rounded-xl border border-border bg-background w-full min-h-[130px] flex flex-col"),e[14]=$):$=e[14];let N;e[15]!==d?(N=d&&m.jsx("div",{className:"mb-1",children:d}),e[15]=d,e[16]=N):N=e[16];let M;e[17]!==b?(M={maxHeight:b},e[17]=b,e[18]=M):M=e[18];let v;e[19]!==r?(v=me=>r(me.target.value),e[19]=r,e[20]=v):v=e[20];const J=s||u;let z;e[21]===Symbol.for("react.memo_cache_sentinel")?(z=ue("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]=z):z=e[21];let F;e[22]===Symbol.for("react.memo_cache_sentinel")?(F={minHeight:"20px",height:"auto",overflow:"hidden"},e[22]=F):F=e[22];let K;e[23]!==O||e[24]!==_||e[25]!==v||e[26]!==J||e[27]!==n?(K=m.jsx(df,{value:n,onChange:v,onKeyDown:O,placeholder:_,disabled:J,className:z,rows:1,style:F}),e[23]=O,e[24]=_,e[25]=v,e[26]=J,e[27]=n,e[28]=K):K=e[28];let ie;e[29]!==M||e[30]!==K?(ie=m.jsx("div",{className:"overflow-y-auto relative flex-1",style:M,children:K}),e[29]=M,e[30]=K,e[31]=ie):ie=e[31];let de;e[32]!==ie||e[33]!==N?(de=m.jsxs("div",{className:"relative flex flex-col gap-2 p-2.5 flex-1",children:[N,ie]}),e[32]=ie,e[33]=N,e[34]=de):de=e[34];let xe;e[35]!==x||e[36]!==h?(xe=m.jsxs("div",{className:"flex items-center overflow-hidden gap-2 min-w-0",children:[h,x]}),e[35]=x,e[36]=h,e[37]=xe):xe=e[37];const I=u?"button":"submit";let le;e[38]!==u||e[39]!==a?(le=me=>{u&&(me.preventDefault(),me.stopPropagation(),a?.())},e[38]=u,e[39]=a,e[40]=le):le=e[40];const Te=E||u?"default":"ghost",y=!E&&!u,W=!E&&!u&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let Q;e[41]!==W?(Q=ue("size-8 rounded-full transition-all",W),e[41]=W,e[42]=Q):Q=e[42];const X=u?"Stop generating":"Send message (Enter)";let G;e[43]!==u?(G=u?m.jsx(No,{size:20}):m.jsx(lf,{size:20}),e[43]=u,e[44]=G):G=e[44];let ee;e[45]!==I||e[46]!==le||e[47]!==Te||e[48]!==y||e[49]!==Q||e[50]!==X||e[51]!==G?(ee=m.jsx(st,{type:I,onClick:le,variant:Te,size:"icon",disabled:y,className:Q,title:X,children:G}),e[45]=I,e[46]=le,e[47]=Te,e[48]=y,e[49]=Q,e[50]=X,e[51]=G,e[52]=ee):ee=e[52];let re;e[53]!==p||e[54]!==ee?(re=m.jsxs("div",{className:"flex items-center gap-1",children:[p,ee]}),e[53]=p,e[54]=ee,e[55]=re):re=e[55];let he;e[56]!==xe||e[57]!==re?(he=m.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[xe,re]}),e[56]=xe,e[57]=re,e[58]=he):he=e[58];let Re;e[59]!==de||e[60]!==he?(Re=m.jsxs("div",{className:$,children:[de,he]}),e[59]=de,e[60]=he,e[61]=Re):Re=e[61];let Be;return e[62]!==R||e[63]!==Re||e[64]!==H?(Be=m.jsx("form",{onSubmit:R,className:H,children:Re}),e[62]=R,e[63]=Re,e[64]=H,e[65]=Be):Be=e[65],Be}function v0(){const t=Z.c(3),[e,n]=D.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 Da(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var an=Da();function ol(t){an=t}var Qn={exec:()=>null};function _e(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(qe.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var qe={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")},D0=/^(?:[ \t]*(?:\n|$))+/,P0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,M0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,br=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,B0=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Pa=/(?:[*+-]|\d{1,9}[.)])/,ll=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cl=_e(ll).replace(/bull/g,Pa).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(),F0=_e(ll).replace(/bull/g,Pa).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(),Ma=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,H0=/^[^\n]+/,Ba=/(?!\s*\])(?:\\.|[^\[\]\\])+/,U0=_e(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ba).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),z0=_e(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Pa).getRegex(),ai="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",Fa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,j0=_e("^ {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",Fa).replace("tag",ai).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dl=_e(Ma).replace("hr",br).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",ai).getRegex(),$0=_e(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",dl).getRegex(),Ha={blockquote:$0,code:P0,def:U0,fences:M0,heading:B0,hr:br,html:j0,lheading:cl,list:z0,newline:D0,paragraph:dl,table:Qn,text:H0},Fs=_e("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",br).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",ai).getRegex(),Y0={...Ha,lheading:F0,table:Fs,paragraph:_e(Ma).replace("hr",br).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Fs).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",ai).getRegex()},q0={...Ha,html:_e(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Fa).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:Qn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_e(Ma).replace("hr",br).replace("heading",` *#{1,6} *[^
|
|
13
13
|
]`).replace("lheading",cl).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},V0=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,W0=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,fl=/^( {2,}|\\)\n(?!\s*$)/,G0=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,si=/[\p{P}\p{S}]/u,Ua=/[\s\p{P}\p{S}]/u,hl=/[^\s\p{P}\p{S}]/u,Q0=_e(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ua).getRegex(),pl=/(?!~)[\p{P}\p{S}]/u,X0=/(?!~)[\s\p{P}\p{S}]/u,Z0=/(?:[^\s\p{P}\p{S}]|~)/u,K0=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ml=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,J0=_e(ml,"u").replace(/punct/g,si).getRegex(),ep=_e(ml,"u").replace(/punct/g,pl).getRegex(),gl="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",tp=_e(gl,"gu").replace(/notPunctSpace/g,hl).replace(/punctSpace/g,Ua).replace(/punct/g,si).getRegex(),np=_e(gl,"gu").replace(/notPunctSpace/g,Z0).replace(/punctSpace/g,X0).replace(/punct/g,pl).getRegex(),rp=_e("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,hl).replace(/punctSpace/g,Ua).replace(/punct/g,si).getRegex(),ip=_e(/\\(punct)/,"gu").replace(/punct/g,si).getRegex(),ap=_e(/^<(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(),sp=_e(Fa).replace("(?:-->|$)","-->").getRegex(),up=_e("^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",sp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Yr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,op=_e(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Yr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),bl=_e(/^!?\[(label)\]\[(ref)\]/).replace("label",Yr).replace("ref",Ba).getRegex(),El=_e(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ba).getRegex(),lp=_e("reflink|nolink(?!\\()","g").replace("reflink",bl).replace("nolink",El).getRegex(),za={_backpedal:Qn,anyPunctuation:ip,autolink:ap,blockSkip:K0,br:fl,code:W0,del:Qn,emStrongLDelim:J0,emStrongRDelimAst:tp,emStrongRDelimUnd:rp,escape:V0,link:op,nolink:El,punctuation:Q0,reflink:bl,reflinkSearch:lp,tag:up,text:G0,url:Qn},cp={...za,link:_e(/^!?\[(label)\]\((.*?)\)/).replace("label",Yr).getRegex(),reflink:_e(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Yr).getRegex()},sa={...za,emStrongRDelimAst:np,emStrongLDelim:ep,url:_e(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},dp={...sa,br:_e(fl).replace("{2,}","*").getRegex(),text:_e(sa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Sr={normal:Ha,gfm:Y0,pedantic:q0},Dn={normal:za,gfm:sa,breaks:dp,pedantic:cp},fp={"&":"&","<":"<",">":">",'"':""","'":"'"},Hs=t=>fp[t];function pt(t,e){if(e){if(qe.escapeTest.test(t))return t.replace(qe.escapeReplace,Hs)}else if(qe.escapeTestNoEncode.test(t))return t.replace(qe.escapeReplaceNoEncode,Hs);return t}function Us(t){try{t=encodeURI(t).replace(qe.percentDecode,"%")}catch{return null}return t}function zs(t,e){const n=t.replace(qe.findPipe,(a,s,u)=>{let o=!1,l=s;for(;--l>=0&&u[l]==="\\";)o=!o;return o?"|":" |"}),r=n.split(qe.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(qe.slashPipe,"|");return r}function Pn(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 hp(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 js(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 pp(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 qr=class{options;rules;lexer;constructor(t){this.options=t||an}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:Pn(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=dr(l.charCodeAt(0))+l.slice(1)),l=l?s+" "+l:s,n.options.closeAtx&&(l+=" "+s),o(),u(),l}jc.peek=Mx;function jc(t){return t.value||""}function Mx(){return"<"}$c.peek=Bx;function $c(t,e,n,r){const i=us(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 Bx(){return"!"}Yc.peek=Fx;function Yc(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 f=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(t),{before:o,after:"]",...u.current()});return s(),n.stack=f,a(),i==="full"||!l||l!==d?o+=u.move(d+"]"):i==="shortcut"?o=o.slice(0,-1):o+=u.move("]"),o}function Fx(){return"!"}qc.peek=Hx;function qc(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 Hx(){return"`"}function Vc(t,e){const n=Wa(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))}Wc.peek=Ux;function Wc(t,e,n,r){const i=us(n),a=i==='"'?"Quote":"Apostrophe",s=n.createTracker(r);let u,o;if(Vc(t,n)){const f=n.stack;n.stack=[],u=n.enter("autolink");let d=s.move("<");return d+=s.move(n.containerPhrasing(t,{before:d,after:">",...s.current()})),d+=s.move(">"),u(),n.stack=f,d}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 Ux(t,e,n){return Vc(t,n)?"<":"["}Gc.peek=zx;function Gc(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 f=n.stack;n.stack=[],s=n.enter("reference");const d=n.safe(n.associationId(t),{before:o,after:"]",...u.current()});return s(),n.stack=f,a(),i==="full"||!l||l!==d?o+=u.move(d+"]"):i==="shortcut"?o=o.slice(0,-1):o+=u.move("]"),o}function zx(){return"["}function os(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 jx(t){const e=os(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 $x(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 Qc(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 Yx(t,e,n,r){const i=n.enter("list"),a=n.bulletCurrent;let s=t.ordered?$x(n):os(n);const u=t.ordered?s==="."?")":".":jx(n);let o=e&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!t.ordered){const f=t.children?t.children[0]:void 0;if((s==="*"||s==="-")&&f&&(!f.children||!f.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),Qc(n)===s&&f){let d=-1;for(;++d<t.children.length;){const h=t.children[d];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.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 qx(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 Vx(t,e,n,r){const i=qx(n);let a=n.bulletCurrent||os(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()),f);return o(),l;function f(d,h,p){return h?(p?"":" ".repeat(s))+d:(p?a:a+" ".repeat(s-a.length))+d}}function Wx(t,e,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),s=n.containerPhrasing(t,r);return a(),i(),s}const Gx=fi(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Qx(t,e,n,r){return(t.children.some(function(s){return Gx(s)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function Xx(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Xc.peek=Zx;function Xc(t,e,n,r){const i=Xx(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),f=Kr(r.before.charCodeAt(r.before.length-1),l,i);f.inside&&(o=dr(l)+o.slice(1));const d=o.charCodeAt(o.length-1),h=Kr(r.after.charCodeAt(0),d,i);h.inside&&(o=o.slice(0,-1)+dr(d));const p=s.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:h.outside,before:f.outside},u+o+p}function Zx(t,e,n){return n.options.strong||"*"}function Kx(t,e,n,r){return n.safe(t.value,r)}function Jx(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 e3(t,e,n){const r=(Qc(n)+(n.options.ruleSpaces?" ":"")).repeat(Jx(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Zc={blockquote:Ax,break:Gu,code:wx,definition:Lx,emphasis:zc,hardBreak:Gu,heading:Px,html:jc,image:$c,imageReference:Yc,inlineCode:qc,link:Wc,linkReference:Gc,list:Yx,listItem:Vx,paragraph:Wx,root:Qx,strong:Xc,text:Kx,thematicBreak:e3};function t3(){return{enter:{table:n3,tableData:Qu,tableHeader:Qu,tableRow:i3},exit:{codeText:a3,table:r3,tableData:Wi,tableHeader:Wi,tableRow:Wi}}}function n3(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 r3(t){this.exit(t),this.data.inTable=void 0}function i3(t){this.enter({type:"tableRow",children:[]},t)}function Wi(t){this.exit(t)}function Qu(t){this.enter({type:"tableCell",children:[]},t)}function a3(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,s3));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function s3(t,e){return e==="|"?e:t}function u3(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:h,table:s,tableCell:o,tableRow:u}};function s(p,g,x,_){return l(f(p,x,_),p.align)}function u(p,g,x,_){const b=d(p,x,_),k=l([b]);return k.slice(0,k.indexOf(`
|
|
96
|
-
`))}function o(p,g,x,_){const b=x.enter("tableCell"),k=x.enter("phrasing"),E=x.containerPhrasing(p,{..._,before:a,after:a});return k(),b(),E}function l(p,g){return _x(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function f(p,g,x){const _=p.children;let b=-1;const k=[],E=g.enter("table");for(;++b<_.length;)k[b]=d(_[b],g,x);return E(),k}function d(p,g,x){const _=p.children;let b=-1;const k=[],E=g.enter("tableRow");for(;++b<_.length;)k[b]=o(_[b],p,g,x);return E(),k}function h(p,g,x){let _=Zc.inlineCode(p,g,x);return x.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function o3(){return{exit:{taskListCheckValueChecked:Xu,taskListCheckValueUnchecked:Xu,paragraph:c3}}}function l3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:d3}}}function Xu(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function c3(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 d3(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=Zc.listItem(t,e,n,{...r,...u.current()});return a&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),o;function l(f){return f+s}}function f3(){return[YT(),dx(),mx(),t3(),o3()]}function h3(t){return{extensions:[qT(),fx(t),gx(),u3(t),l3()]}}const p3={tokenize:x3,partial:!0},Kc={tokenize:_3,partial:!0},Jc={tokenize:y3,partial:!0},ed={tokenize:A3,partial:!0},m3={tokenize:C3,partial:!0},td={name:"wwwAutolink",tokenize:E3,previous:rd},nd={name:"protocolAutolink",tokenize:T3,previous:id},kt={name:"emailAutolink",tokenize:b3,previous:ad},Et={};function g3(){return{text:Et}}let Yt=48;for(;Yt<123;)Et[Yt]=kt,Yt++,Yt===58?Yt=65:Yt===91&&(Yt=97);Et[43]=kt;Et[45]=kt;Et[46]=kt;Et[95]=kt;Et[72]=[kt,nd];Et[104]=[kt,nd];Et[87]=[kt,td];Et[119]=[kt,td];function b3(t,e,n){const r=this;let i,a;return s;function s(d){return!Aa(d)||!ad.call(r,r.previous)||ls(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(d))}function u(d){return Aa(d)?(t.consume(d),u):d===64?(t.consume(d),o):n(d)}function o(d){return d===46?t.check(m3,f,l)(d):d===45||d===95||He(d)?(a=!0,t.consume(d),o):f(d)}function l(d){return t.consume(d),i=!0,o}function f(d){return a&&i&&Ye(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function E3(t,e,n){const r=this;return i;function i(s){return s!==87&&s!==119||!rd.call(r,r.previous)||ls(r.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(p3,t.attempt(Kc,t.attempt(Jc,a),n),n)(s))}function a(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}}function T3(t,e,n){const r=this;let i="",a=!1;return s;function s(d){return(d===72||d===104)&&id.call(r,r.previous)&&!ls(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),u):n(d)}function u(d){if(Ye(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),u;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="https")return t.consume(d),o}return n(d)}function o(d){return d===47?(t.consume(d),a?l:(a=!0,o)):n(d)}function l(d){return d===null||Wr(d)||Se(d)||nn(d)||li(d)?n(d):t.attempt(Kc,t.attempt(Jc,f),n)(d)}function f(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function x3(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 _3(t,e,n){let r,i,a;return s;function s(l){return l===46||l===95?t.check(ed,o,u)(l):l===null||Se(l)||nn(l)||l!==45&&li(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 y3(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(ed,e,a)(s):s===null||Se(s)||nn(s)?e(s):(t.consume(s),i)}function a(s){return s===41&&r++,t.consume(s),i}}function A3(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||Se(u)||nn(u)?e(u):n(u)}function i(u){return u===null||u===40||u===91||Se(u)||nn(u)?e(u):r(u)}function a(u){return Ye(u)?s(u):n(u)}function s(u){return u===59?(t.consume(u),r):Ye(u)?(t.consume(u),s):n(u)}}function C3(t,e,n){return r;function r(a){return t.consume(a),i}function i(a){return He(a)?n(a):e(a)}}function rd(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Se(t)}function id(t){return!Ye(t)}function ad(t){return!(t===47||Aa(t))}function Aa(t){return t===43||t===45||t===46||t===95||He(t)}function ls(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 k3={tokenize:v3,partial:!0};function S3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:R3,continuation:{tokenize:L3},exit:O3}},text:{91:{name:"gfmFootnoteCall",tokenize:w3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:I3,resolveTo:N3}}}}function I3(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=ct(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 N3(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 w3(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return u;function u(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),o}function o(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",l)}function l(d){if(a>999||d===93&&!s||d===null||d===91||Se(d))return n(d);if(d===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return i.includes(ct(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Se(d)||(s=!0),a++,t.consume(d),d===92?f:l}function f(d){return d===91||d===92||d===93?(t.consume(d),a++,l):l(d)}}function R3(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",f):n(g)}function f(g){if(s>999||g===93&&!u||g===null||g===91||Se(g))return n(g);if(g===93){t.exit("chunkString");const x=t.exit("gfmFootnoteDefinitionLabelString");return a=ct(r.sliceSerialize(x)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return Se(g)||(u=!0),s++,t.consume(g),g===92?d:f}function d(g){return g===91||g===92||g===93?(t.consume(g),s++,f):f(g)}function h(g){return g===58?(t.enter("definitionMarker"),t.consume(g),t.exit("definitionMarker"),i.includes(a)||i.push(a),Ee(t,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return e(g)}}function L3(t,e,n){return t.check(xr,e,t.attempt(k3,e,n))}function O3(t){t.exit("gfmFootnoteDefinition")}function v3(t,e,n){const r=this;return Ee(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 D3(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 f={type:"strikethrough",start:Object.assign({},s[l][1].start),end:Object.assign({},s[o][1].end)},d={type:"strikethroughText",start:Object.assign({},s[l][1].end),end:Object.assign({},s[o][1].start)},h=[["enter",f,u],["enter",s[l][1],u],["exit",s[l][1],u],["enter",d,u]],p=u.parser.constructs.insideSpan.null;p&&tt(h,h.length,0,ci(p,s.slice(l+1,o),u)),tt(h,h.length,0,[["exit",d,u],["enter",s[o][1],u],["exit",s[o][1],u],["exit",f,u]]),tt(s,l-1,o-l+3,h),o=l+h.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,f=this.events;let d=0;return h;function h(g){return l===126&&f[f.length-1][1].type!=="characterEscape"?o(g):(s.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const x=yn(l);if(g===126)return d>1?o(g):(s.consume(g),d++,p);if(d<2&&!n)return o(g);const _=s.exit("strikethroughSequenceTemporary"),b=yn(g);return _._open=!b||b===2&&!!x,_._close=!x||x===2&&!!b,u(g)}}}class P3{constructor(){this.map=[]}add(e,n,r){M3(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 M3(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 B3(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 F3(){return{flow:{null:{name:"table",tokenize:H3,resolveAll:U3}}}}function H3(t,e,n){const r=this;let i=0,a=0,s;return u;function u(N){let M=r.events.length-1;for(;M>-1;){const z=r.events[M][1].type;if(z==="lineEnding"||z==="linePrefix")M--;else break}const v=M>-1?r.events[M][1].type:null,J=v==="tableHead"||v==="tableRow"?S:o;return J===S&&r.parser.lazy[r.now().line]?n(N):J(N)}function o(N){return t.enter("tableHead"),t.enter("tableRow"),l(N)}function l(N){return N===124||(s=!0,a+=1),f(N)}function f(N){return N===null?n(N):te(N)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),p):n(N):pe(N)?Ee(t,f,"whitespace")(N):(a+=1,s&&(s=!1,i+=1),N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),s=!0,f):(t.enter("data"),d(N)))}function d(N){return N===null||N===124||Se(N)?(t.exit("data"),f(N)):(t.consume(N),N===92?h:d)}function h(N){return N===92||N===124?(t.consume(N),d):d(N)}function p(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(t.enter("tableDelimiterRow"),s=!1,pe(N)?Ee(t,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?_(N):N===124?(s=!0,t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),x):R(N)}function x(N){return pe(N)?Ee(t,_,"whitespace")(N):_(N)}function _(N){return N===58?(a+=1,s=!0,t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),b):N===45?(a+=1,b(N)):N===null||te(N)?w(N):R(N)}function b(N){return N===45?(t.enter("tableDelimiterFiller"),k(N)):R(N)}function k(N){return N===45?(t.consume(N),k):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 pe(N)?Ee(t,w,"whitespace")(N):w(N)}function w(N){return N===124?g(N):N===null||te(N)?!s||i!==a?R(N):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(N)):R(N)}function R(N){return n(N)}function S(N){return t.enter("tableRow"),O(N)}function O(N){return N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),O):N===null||te(N)?(t.exit("tableRow"),e(N)):pe(N)?Ee(t,O,"whitespace")(N):(t.enter("data"),H(N))}function H(N){return N===null||N===124||Se(N)?(t.exit("data"),O(N)):(t.consume(N),N===92?$:H)}function $(N){return N===92||N===124?(t.consume(N),H):H(N)}}function U3(t,e){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],u=!1,o=0,l,f,d;const h=new P3;for(;++n<t.length;){const p=t[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(u=!1,o!==0&&(Zu(h,e,o,l,f),f=void 0,o=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",l,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,f={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",f,e]])),i=g.type==="tableDelimiterRow"?2:f?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],d=Lr(h,e,a,i,void 0,d),a=[0,0,0,0]),s[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],d=Lr(h,e,a,i,void 0,d)),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],d=Lr(h,e,a,i,n,d)):s[1]!==0&&(d=Lr(h,e,s,i,n,d)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(s[3]=n)}for(o!==0&&Zu(h,e,o,l,f),h.consume(e.events),n=-1;++n<e.events.length;){const p=e.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=B3(e.events,n))}return t}function Lr(t,e,n,r,i,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(a.end=Object.assign({},mn(e.events,n[0])),t.add(n[0],0,[["exit",a,e]]));const o=mn(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=mn(e.events,n[2]),f=mn(e.events,n[3]),d={type:u,start:Object.assign({},l),end:Object.assign({},f)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const h=e.events[n[2]],p=e.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,x=n[3]-n[2]-1;t.add(g,x,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(a.end=Object.assign({},mn(e.events,i)),t.add(i,0,[["exit",a,e]]),a=void 0),a}function Zu(t,e,n,r,i){const a=[],s=mn(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 mn(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const z3={name:"tasklistCheck",tokenize:$3};function j3(){return{text:{91:z3}}}function $3(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 Se(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 te(o)?e(o):pe(o)?t.check({tokenize:Y3},e,n)(o):n(o)}}function Y3(t,e,n){return Ee(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function q3(t){return Dl([g3(),S3(),D3(t),F3(),j3()])}const V3={};function W3(t){const e=this,n=t||V3,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(q3(n)),a.push(f3()),s.push(h3(n))}const G3=D.lazy(()=>Qd(()=>import("./lazy-highlighter-Dqvq1Dex.js"),__vite__mapDeps([0,1,2,3,4])));function sd(){const t=Z.c(3),[e,n]=D.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 Q3(){const t=Z.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(X3)}),t[1]=r):r=t[1],r}function X3(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 Z3(t){const e=Z.c(12),n=D.useRef(null),{handleCopy:r,copied:i}=sd(),a=K3;let s;e[0]!==r?(s=async()=>{const h=a(n.current);await r(h)},e[0]=r,e[1]=s):s=e[1];const u=s;let o;e[2]!==i?(o=i?m.jsx(Kt,{size:12}):m.jsx(ti,{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(st,{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 f;e[7]!==t?(f=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]=f):f=e[8];let d;return e[9]!==l||e[10]!==f?(d=m.jsxs(m.Fragment,{children:[l,f]}),e[9]=l,e[10]=f,e[11]=d):d=e[11],d}function K3(t){return t?Array.from(t.querySelectorAll("tr")).map(J3).join(`
|
|
96
|
+
`))}function o(p,g,x,_){const b=x.enter("tableCell"),k=x.enter("phrasing"),E=x.containerPhrasing(p,{..._,before:a,after:a});return k(),b(),E}function l(p,g){return _x(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function f(p,g,x){const _=p.children;let b=-1;const k=[],E=g.enter("table");for(;++b<_.length;)k[b]=d(_[b],g,x);return E(),k}function d(p,g,x){const _=p.children;let b=-1;const k=[],E=g.enter("tableRow");for(;++b<_.length;)k[b]=o(_[b],p,g,x);return E(),k}function h(p,g,x){let _=Zc.inlineCode(p,g,x);return x.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function o3(){return{exit:{taskListCheckValueChecked:Xu,taskListCheckValueUnchecked:Xu,paragraph:c3}}}function l3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:d3}}}function Xu(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function c3(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 d3(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=Zc.listItem(t,e,n,{...r,...u.current()});return a&&(o=o.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),o;function l(f){return f+s}}function f3(){return[YT(),dx(),mx(),t3(),o3()]}function h3(t){return{extensions:[qT(),fx(t),gx(),u3(t),l3()]}}const p3={tokenize:x3,partial:!0},Kc={tokenize:_3,partial:!0},Jc={tokenize:y3,partial:!0},ed={tokenize:A3,partial:!0},m3={tokenize:C3,partial:!0},td={name:"wwwAutolink",tokenize:E3,previous:rd},nd={name:"protocolAutolink",tokenize:T3,previous:id},kt={name:"emailAutolink",tokenize:b3,previous:ad},Et={};function g3(){return{text:Et}}let Yt=48;for(;Yt<123;)Et[Yt]=kt,Yt++,Yt===58?Yt=65:Yt===91&&(Yt=97);Et[43]=kt;Et[45]=kt;Et[46]=kt;Et[95]=kt;Et[72]=[kt,nd];Et[104]=[kt,nd];Et[87]=[kt,td];Et[119]=[kt,td];function b3(t,e,n){const r=this;let i,a;return s;function s(d){return!Aa(d)||!ad.call(r,r.previous)||ls(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),u(d))}function u(d){return Aa(d)?(t.consume(d),u):d===64?(t.consume(d),o):n(d)}function o(d){return d===46?t.check(m3,f,l)(d):d===45||d===95||He(d)?(a=!0,t.consume(d),o):f(d)}function l(d){return t.consume(d),i=!0,o}function f(d){return a&&i&&Ye(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function E3(t,e,n){const r=this;return i;function i(s){return s!==87&&s!==119||!rd.call(r,r.previous)||ls(r.events)?n(s):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(p3,t.attempt(Kc,t.attempt(Jc,a),n),n)(s))}function a(s){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(s)}}function T3(t,e,n){const r=this;let i="",a=!1;return s;function s(d){return(d===72||d===104)&&id.call(r,r.previous)&&!ls(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),u):n(d)}function u(d){if(Ye(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),u;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="https")return t.consume(d),o}return n(d)}function o(d){return d===47?(t.consume(d),a?l:(a=!0,o)):n(d)}function l(d){return d===null||Wr(d)||Se(d)||nn(d)||li(d)?n(d):t.attempt(Kc,t.attempt(Jc,f),n)(d)}function f(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function x3(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 _3(t,e,n){let r,i,a;return s;function s(l){return l===46||l===95?t.check(ed,o,u)(l):l===null||Se(l)||nn(l)||l!==45&&li(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 y3(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(ed,e,a)(s):s===null||Se(s)||nn(s)?e(s):(t.consume(s),i)}function a(s){return s===41&&r++,t.consume(s),i}}function A3(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||Se(u)||nn(u)?e(u):n(u)}function i(u){return u===null||u===40||u===91||Se(u)||nn(u)?e(u):r(u)}function a(u){return Ye(u)?s(u):n(u)}function s(u){return u===59?(t.consume(u),r):Ye(u)?(t.consume(u),s):n(u)}}function C3(t,e,n){return r;function r(a){return t.consume(a),i}function i(a){return He(a)?n(a):e(a)}}function rd(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Se(t)}function id(t){return!Ye(t)}function ad(t){return!(t===47||Aa(t))}function Aa(t){return t===43||t===45||t===46||t===95||He(t)}function ls(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 k3={tokenize:v3,partial:!0};function S3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:R3,continuation:{tokenize:L3},exit:O3}},text:{91:{name:"gfmFootnoteCall",tokenize:w3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:I3,resolveTo:N3}}}}function I3(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=ct(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 N3(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 w3(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return u;function u(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),o}function o(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",l)}function l(d){if(a>999||d===93&&!s||d===null||d===91||Se(d))return n(d);if(d===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return i.includes(ct(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Se(d)||(s=!0),a++,t.consume(d),d===92?f:l}function f(d){return d===91||d===92||d===93?(t.consume(d),a++,l):l(d)}}function R3(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",f):n(g)}function f(g){if(s>999||g===93&&!u||g===null||g===91||Se(g))return n(g);if(g===93){t.exit("chunkString");const x=t.exit("gfmFootnoteDefinitionLabelString");return a=ct(r.sliceSerialize(x)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(g),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return Se(g)||(u=!0),s++,t.consume(g),g===92?d:f}function d(g){return g===91||g===92||g===93?(t.consume(g),s++,f):f(g)}function h(g){return g===58?(t.enter("definitionMarker"),t.consume(g),t.exit("definitionMarker"),i.includes(a)||i.push(a),Ee(t,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return e(g)}}function L3(t,e,n){return t.check(xr,e,t.attempt(k3,e,n))}function O3(t){t.exit("gfmFootnoteDefinition")}function v3(t,e,n){const r=this;return Ee(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 D3(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 f={type:"strikethrough",start:Object.assign({},s[l][1].start),end:Object.assign({},s[o][1].end)},d={type:"strikethroughText",start:Object.assign({},s[l][1].end),end:Object.assign({},s[o][1].start)},h=[["enter",f,u],["enter",s[l][1],u],["exit",s[l][1],u],["enter",d,u]],p=u.parser.constructs.insideSpan.null;p&&tt(h,h.length,0,ci(p,s.slice(l+1,o),u)),tt(h,h.length,0,[["exit",d,u],["enter",s[o][1],u],["exit",s[o][1],u],["exit",f,u]]),tt(s,l-1,o-l+3,h),o=l+h.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,f=this.events;let d=0;return h;function h(g){return l===126&&f[f.length-1][1].type!=="characterEscape"?o(g):(s.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const x=yn(l);if(g===126)return d>1?o(g):(s.consume(g),d++,p);if(d<2&&!n)return o(g);const _=s.exit("strikethroughSequenceTemporary"),b=yn(g);return _._open=!b||b===2&&!!x,_._close=!x||x===2&&!!b,u(g)}}}class P3{constructor(){this.map=[]}add(e,n,r){M3(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 M3(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 B3(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 F3(){return{flow:{null:{name:"table",tokenize:H3,resolveAll:U3}}}}function H3(t,e,n){const r=this;let i=0,a=0,s;return u;function u(N){let M=r.events.length-1;for(;M>-1;){const z=r.events[M][1].type;if(z==="lineEnding"||z==="linePrefix")M--;else break}const v=M>-1?r.events[M][1].type:null,J=v==="tableHead"||v==="tableRow"?S:o;return J===S&&r.parser.lazy[r.now().line]?n(N):J(N)}function o(N){return t.enter("tableHead"),t.enter("tableRow"),l(N)}function l(N){return N===124||(s=!0,a+=1),f(N)}function f(N){return N===null?n(N):te(N)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),p):n(N):pe(N)?Ee(t,f,"whitespace")(N):(a+=1,s&&(s=!1,i+=1),N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),s=!0,f):(t.enter("data"),d(N)))}function d(N){return N===null||N===124||Se(N)?(t.exit("data"),f(N)):(t.consume(N),N===92?h:d)}function h(N){return N===92||N===124?(t.consume(N),d):d(N)}function p(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(t.enter("tableDelimiterRow"),s=!1,pe(N)?Ee(t,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?_(N):N===124?(s=!0,t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),x):R(N)}function x(N){return pe(N)?Ee(t,_,"whitespace")(N):_(N)}function _(N){return N===58?(a+=1,s=!0,t.enter("tableDelimiterMarker"),t.consume(N),t.exit("tableDelimiterMarker"),b):N===45?(a+=1,b(N)):N===null||te(N)?w(N):R(N)}function b(N){return N===45?(t.enter("tableDelimiterFiller"),k(N)):R(N)}function k(N){return N===45?(t.consume(N),k):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 pe(N)?Ee(t,w,"whitespace")(N):w(N)}function w(N){return N===124?g(N):N===null||te(N)?!s||i!==a?R(N):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(N)):R(N)}function R(N){return n(N)}function S(N){return t.enter("tableRow"),O(N)}function O(N){return N===124?(t.enter("tableCellDivider"),t.consume(N),t.exit("tableCellDivider"),O):N===null||te(N)?(t.exit("tableRow"),e(N)):pe(N)?Ee(t,O,"whitespace")(N):(t.enter("data"),H(N))}function H(N){return N===null||N===124||Se(N)?(t.exit("data"),O(N)):(t.consume(N),N===92?$:H)}function $(N){return N===92||N===124?(t.consume(N),H):H(N)}}function U3(t,e){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],u=!1,o=0,l,f,d;const h=new P3;for(;++n<t.length;){const p=t[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(u=!1,o!==0&&(Zu(h,e,o,l,f),f=void 0,o=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",l,e]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,f={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},h.add(n,0,[["enter",f,e]])),i=g.type==="tableDelimiterRow"?2:f?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],d=Lr(h,e,a,i,void 0,d),a=[0,0,0,0]),s[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],d=Lr(h,e,a,i,void 0,d)),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],d=Lr(h,e,a,i,n,d)):s[1]!==0&&(d=Lr(h,e,s,i,n,d)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(s[3]=n)}for(o!==0&&Zu(h,e,o,l,f),h.consume(e.events),n=-1;++n<e.events.length;){const p=e.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=B3(e.events,n))}return t}function Lr(t,e,n,r,i,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(a.end=Object.assign({},mn(e.events,n[0])),t.add(n[0],0,[["exit",a,e]]));const o=mn(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=mn(e.events,n[2]),f=mn(e.events,n[3]),d={type:u,start:Object.assign({},l),end:Object.assign({},f)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const h=e.events[n[2]],p=e.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,x=n[3]-n[2]-1;t.add(g,x,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(a.end=Object.assign({},mn(e.events,i)),t.add(i,0,[["exit",a,e]]),a=void 0),a}function Zu(t,e,n,r,i){const a=[],s=mn(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 mn(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const z3={name:"tasklistCheck",tokenize:$3};function j3(){return{text:{91:z3}}}function $3(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 Se(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 te(o)?e(o):pe(o)?t.check({tokenize:Y3},e,n)(o):n(o)}}function Y3(t,e,n){return Ee(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function q3(t){return Dl([g3(),S3(),D3(t),F3(),j3()])}const V3={};function W3(t){const e=this,n=t||V3,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(q3(n)),a.push(f3()),s.push(h3(n))}const G3=D.lazy(()=>Qd(()=>import("./lazy-highlighter-B7M4_4X7.js"),__vite__mapDeps([0,1,2,3,4])));function sd(){const t=Z.c(3),[e,n]=D.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 Q3(){const t=Z.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(X3)}),t[1]=r):r=t[1],r}function X3(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 Z3(t){const e=Z.c(12),n=D.useRef(null),{handleCopy:r,copied:i}=sd(),a=K3;let s;e[0]!==r?(s=async()=>{const h=a(n.current);await r(h)},e[0]=r,e[1]=s):s=e[1];const u=s;let o;e[2]!==i?(o=i?m.jsx(Kt,{size:12}):m.jsx(ti,{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(st,{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 f;e[7]!==t?(f=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]=f):f=e[8];let d;return e[9]!==l||e[10]!==f?(d=m.jsxs(m.Fragment,{children:[l,f]}),e[9]=l,e[10]=f,e[11]=d):d=e[11],d}function K3(t){return t?Array.from(t.querySelectorAll("tr")).map(J3).join(`
|
|
97
97
|
`):""}function J3(t){return Array.from(t.querySelectorAll("th,td")).map(e_).join(",")}function e_(t){let e=t.textContent||"";return e=e.replace(/"/g,'""'),e.search(/([",\n])/g)>=0&&(e=`"${e}"`),e}const t_=[W3],n_=[FT],r_={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(Z3,{...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"})},ud=D.memo(t=>{const e=Z.c(2),{content:n}=t;let r;return e[0]!==n?(r=m.jsx(yb,{remarkPlugins:t_,rehypePlugins:n_,components:r_,children:n}),e[0]=n,e[1]=r):r=e[1],r},(t,e)=>t.content===e.content);function i_(t){const e=Z.c(20),{language:n,content:r}=t,{handleCopy:i,copied:a}=sd(),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(Kt,{size:14}):m.jsx(ti,{size:14}),e[5]=a,e[6]=l):l=e[6];let f;e[7]!==o||e[8]!==l?(f=m.jsx(st,{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]=f):f=e[9];let d;e[10]!==u||e[11]!==f?(d=m.jsxs("div",{className:"flex items-center justify-between p-1 pl-4 bg-muted border-b border-border",children:[u,f]}),e[10]=u,e[11]=f,e[12]=d):d=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx(Q3,{}),e[13]=h):h=e[13];let p;e[14]!==r||e[15]!==n?(p=m.jsx(D.Suspense,{fallback:h,children:m.jsx(G3,{language:n,content:r})}),e[14]=r,e[15]=n,e[16]=p):p=e[16];let g;return e[17]!==d||e[18]!==p?(g=m.jsxs("div",{className:"my-4 rounded-lg bg-muted overflow-hidden border border-border grid min-w-0",children:[d,p]}),e[17]=d,e[18]=p,e[19]=g):g=e[19],g}ud.displayName="MemoizedMarkdownBlock";const cs=t=>{const e=Z.c(7),{id:n,text:r}=t;let i;e[0]!==r?(i=ye.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(i_,{language:o.lang,content:o.text},`${n}-block_${l}`):m.jsx(ud,{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};cs.displayName="MemoizedMarkdown";function od(t){const e=Z.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}=v0(),[f,d]=D.useState(!1);let h;e[0]!==l||e[1]!==r.text?(h=async()=>{await l(r.text),d(!0),setTimeout(()=>d(!1),2e3)},e[0]=l,e[1]=r.text,e[2]=h):h=e[2];const p=h,g=u&&a,x=g||a,_=!o&&"mb-2";let b;e[3]!==_?(b=ue("group/part relative",_),e[3]=_,e[4]=b):b=e[4];let k;e[5]!==n||e[6]!==r.text?(k=m.jsx(cs,{id:n,text:r.text}),e[5]=n,e[6]=r.text,e[7]=k):k=e[7];let E;e[8]!==a||e[9]!==p||e[10]!==f||e[11]!==x||e[12]!==g?(E=x&&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(st,{onClick:p,variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground size-6 whitespace-nowrap",children:f?m.jsx(Kt,{size:12}):m.jsx(ti,{size:12})}),a]})}),e[8]=a,e[9]=p,e[10]=f,e[11]=x,e[12]=g,e[13]=E):E=e[13];let w;return e[14]!==b||e[15]!==k||e[16]!==E?(w=m.jsxs("div",{className:b,children:[k,E]}),e[14]=b,e[15]=k,e[16]=E,e[17]=w):w=e[17],w}function a_(t){const e=Z.c(27),{toolName:n,input:r,output:i}=t;let a;if(e[0]!==i){const o=JSON.stringify(i,null,2);a=o.length>2e3?o.slice(0,2e3)+"...[TRUNCATED]":o,e[0]=i,e[1]=a}else a=e[1];const s=a;if(n==="READ_MCP_TOOLS"){const o=r?.id;if(o){let l;return e[2]!==o?(l=m.jsx(Ku,{connectionId:o}),e[2]=o,e[3]=l):l=e[3],l}}if(n==="CALL_MCP_TOOL"){const o=r?.connectionId;let l;e[4]!==o?(l=o&&m.jsx(Ku,{connectionId:o,compact:!0}),e[4]=o,e[5]=l):l=e[5];let f;e[6]!==i?(f=JSON.stringify(i,null,2),e[6]=i,e[7]=f):f=e[7];let d;e[8]!==f?(d=m.jsx("div",{className:"absolute top-1 right-1 z-10",children:m.jsx(s_,{text:f})}),e[8]=f,e[9]=d):d=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx("div",{className:"font-semibold text-muted-foreground mb-0.5 text-[10px] uppercase tracking-wider px-2 pt-2",children:"Input"}),e[10]=h):h=e[10];let p;e[11]!==r?(p=JSON.stringify(r,null,2),e[11]=r,e[12]=p):p=e[12];let g;e[13]!==p?(g=m.jsx("div",{className:"mb-2",children:m.jsx(Dr,{jsonString:p,padding:"0.5rem"})}),e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=m.jsx("div",{className:"font-semibold text-muted-foreground mb-0.5 text-[10px] uppercase tracking-wider px-2",children:"Output"}),e[15]=x):x=e[15];let _;e[16]!==s?(_=m.jsx("div",{children:m.jsx(Dr,{jsonString:s,padding:"0.5rem"})}),e[16]=s,e[17]=_):_=e[17];let b;e[18]!==d||e[19]!==g||e[20]!==_?(b=m.jsxs("div",{className:"relative bg-muted rounded-md overflow-auto max-h-[200px]",children:[d,h,g,x,_]}),e[18]=d,e[19]=g,e[20]=_,e[21]=b):b=e[21];let k;return e[22]!==b||e[23]!==l?(k=m.jsxs("div",{className:"flex flex-col gap-2",children:[l,b]}),e[22]=b,e[23]=l,e[24]=k):k=e[24],k}let u;return e[25]!==s?(u=m.jsx(Dr,{jsonString:s,padding:"0"}),e[25]=s,e[26]=u):u=e[26],u}function Ku(t){const e=Z.c(15),{connectionId:n,compact:r}=t,i=ef(n),{org:a}=Bt(),{slug:s}=a,u=Xd();if(!i)return null;let o;e[0]!==i.id||e[1]!==u||e[2]!==s?(o=()=>{u({to:"/$org/mcps/$connectionId",params:{org:s,connectionId:i.id}})},e[0]=i.id,e[1]=u,e[2]=s,e[3]=o):o=e[3];const l=o;if(r){let d;e[4]!==i.title?(d=m.jsx("span",{className:"font-medium text-foreground",children:i.title}),e[4]=i.title,e[5]=d):d=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=m.jsx(gf,{size:12}),e[6]=h):h=e[6];let p;e[7]!==l?(p=m.jsx("button",{type:"button",onClick:l,className:"hover:text-foreground transition-colors",title:"Open connection",children:h}),e[7]=l,e[8]=p):p=e[8];let g;return e[9]!==d||e[10]!==p?(g=m.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/50 px-2 py-1 rounded-md w-fit",children:[d,p]}),e[9]=d,e[10]=p,e[11]=g):g=e[11],g}let f;return e[12]!==i||e[13]!==l?(f=m.jsx(mf,{connection:i,onClick:l}),e[12]=i,e[13]=l,e[14]=f):f=e[14],f}function s_({text:t}){const e=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(t),Ci.success("Copied to clipboard");else throw new Error("Clipboard API unavailable")}catch(n){try{const r=document.createElement("textarea");r.value=t,r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const i=document.execCommand("copy");if(document.body.removeChild(r),i)Ci.success("Copied to clipboard");else throw new Error("Fallback copy failed")}catch(r){console.error("Copy failed",n,r),Ci.error("Failed to copy to clipboard")}}};return m.jsx(st,{size:"icon",variant:"ghost",className:"h-5 w-5 hover:bg-background/50",onClick:e,children:m.jsx(ti,{size:12})})}function Ju(t){const e=Z.c(50),{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]=D.useState(!1);let o;e[2]!==s?(o=()=>u(!s),e[2]=s,e[3]=o):o=e[3];let l;e[4]!==r?(l=r==="output-error"?m.jsx(bo,{className:"size-4 text-destructive shrink-0"}):m.jsx(pf,{className:ue("size-4 text-muted-foreground shrink-0",(r==="input-streaming"||r==="input-available")&&"shimmer")}),e[4]=r,e[5]=l):l=e[5];const f=r==="output-error"&&"text-destructive/90",d=(r==="input-streaming"||r==="input-available")&&"shimmer";let h;e[6]!==f||e[7]!==d?(h=ue("text-xs font-medium text-muted-foreground truncate",f,d),e[6]=f,e[7]=d,e[8]=h):h=e[8];const p=r==="input-streaming"&&`Streaming ${a} arguments`,g=r==="input-available"&&`Calling ${a}`,x=r==="output-available"&&`Called ${a}`,_=r==="output-error"&&`Error calling ${a}`;let b;e[9]!==_||e[10]!==h||e[11]!==p||e[12]!==g||e[13]!==x?(b=m.jsxs("span",{className:h,children:[p,g,x,_]}),e[9]=_,e[10]=h,e[11]=p,e[12]=g,e[13]=x,e[14]=b):b=e[14];let k;e[15]!==b||e[16]!==l?(k=m.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[l,b]}),e[15]=b,e[16]=l,e[17]=k):k=e[17];const E=s&&"rotate-90";let w;e[18]!==E?(w=ue("size-4 text-muted-foreground transition-transform",E),e[18]=E,e[19]=w):w=e[19];let R;e[20]!==w?(R=m.jsx("div",{className:"flex items-center gap-2 shrink-0",children:m.jsx(Eo,{className:w})}),e[20]=w,e[21]=R):R=e[21];let S;e[22]!==k||e[23]!==R||e[24]!==o?(S=m.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-2 w-full cursor-pointer p-3",children:[k,R]}),e[22]=k,e[23]=R,e[24]=o,e[25]=S):S=e[25];const O=s?"max-h-[1000px] opacity-100":"max-h-0 opacity-0";let H;e[26]!==O?(H=ue("transition-all duration-200 ease-in-out overflow-hidden",O),e[26]=O,e[27]=H):H=e[27];let $;e[28]===Symbol.for("react.memo_cache_sentinel")?($=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"})}),e[28]=$):$=e[28];let N;e[29]!==n.input||e[30]!==r?(N=(r==="input-streaming"||r==="input-available"||r==="output-available")&&!!n.input&&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 max-h-[200px] overflow-auto p-2",children:m.jsx(Dr,{jsonString:JSON.stringify(n.input,null,2),padding:"0"})})]}),e[29]=n.input,e[30]=r,e[31]=N):N=e[31];let M;e[32]!==n.input||e[33]!==n.output||e[34]!==r||e[35]!==a?(M=r==="output-available"&&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",children:m.jsx(a_,{toolName:a,input:n.input,output:n.output})})]}),e[32]=n.input,e[33]=n.output,e[34]=r,e[35]=a,e[36]=M):M=e[36];let v;e[37]!==n||e[38]!==r?(v=r==="output-error"&&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[37]=n,e[38]=r,e[39]=v):v=e[39];let J;e[40]!==N||e[41]!==M||e[42]!==v?(J=m.jsxs("div",{className:"flex ml-[7px] px-3 pb-3",children:[$,m.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-w-0 pt-2",children:[N,M,v]})]}),e[40]=N,e[41]=M,e[42]=v,e[43]=J):J=e[43];let z;e[44]!==H||e[45]!==J?(z=m.jsx("div",{className:H,children:J}),e[44]=H,e[45]=J,e[46]=z):z=e[46];let F;return e[47]!==S||e[48]!==z?(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:[S,z]})}),e[47]=S,e[48]=z,e[49]=F):F=e[49],F}const u_={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 o_(t){if(!t?.providerMetadata)return null;for(const e of Object.values(u_)){const n=e(t.providerMetadata);if(n!==null)return n}return null}function l_(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+(o_(r)??0)}:e},{inputTokens:0,outputTokens:0,totalTokens:0,cost:0})}function c_(t){const e=Z.c(38),{messages:n}=t;let r,i,a,s,u,o,l,f,d,h,p,g;if(e[0]!==n){g=Symbol.for("react.early_return_sentinel");e:{const w=l_(n);if(!w){g=null;break e}const{totalTokens:R,inputTokens:S,outputTokens:O,cost:H}=w;if(a=H,!R&&!S&&!O){g=null;break e}i=Ia;let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=m.jsx(To,{size:12}),e[13]=$):$=e[13];const N=m.jsxs(st,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap",children:[$,m.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:R.toLocaleString()})]});e[14]!==N?(p=m.jsx(Na,{asChild:!0,children:N}),e[14]=N,e[15]=p):p=e[15],r=wa,d="top",h="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")?(f=m.jsx("span",{className:"text-muted",children:"out"}),e[17]=f):f=e[17],s=O.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]=f,e[9]=d,e[10]=h,e[11]=p,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],f=e[8],d=e[9],h=e[10],p=e[11],g=e[12];if(g!==Symbol.for("react.early_return_sentinel"))return g;let x;e[18]!==s?(x=m.jsx("span",{children:s}),e[18]=s,e[19]=x):x=e[19];let _;e[20]!==a?(_=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]=_):_=e[21];let b;e[22]!==x||e[23]!==_||e[24]!==u||e[25]!==o||e[26]!==l||e[27]!==f?(b=m.jsxs("div",{className:u,children:[o,l,f,x,_]}),e[22]=x,e[23]=_,e[24]=u,e[25]=o,e[26]=l,e[27]=f,e[28]=b):b=e[28];let k;e[29]!==r||e[30]!==b||e[31]!==d||e[32]!==h?(k=m.jsx(r,{side:d,className:h,children:b}),e[29]=r,e[30]=b,e[31]=d,e[32]=h,e[33]=k):k=e[33];let E;return e[34]!==i||e[35]!==k||e[36]!==p?(E=m.jsxs(i,{children:[p,k]}),e[34]=i,e[35]=k,e[36]=p,e[37]=E):E=e[37],E}const d_={planning:{icon:m.jsx(wo,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Planning next moves"},thinking:{icon:m.jsx(ni,{className:"text-muted-foreground shrink-0 animate-pulse",size:14}),label:"Thinking"}},f_=1200;function h_(){const t=Z.c(7),[e,n]=D.useState("planning");let r,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{const o=setTimeout(()=>{n("thinking")},f_);return()=>{clearTimeout(o)}},i=[],t[0]=r,t[1]=i):(r=t[0],i=t[1]),D.useEffect(r,i);const a=d_[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 p_(t){const e=Z.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]=D.useState(!1),[f,d]=D.useState(!1);let h;if(e[2]!==i||e[3]!==f||e[4]!==o||e[5]!==r||e[6]!==u){const p=r.filter(g_),g=p.some(m_),x=g||f;let _,b;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=()=>l(!0),b=()=>l(!1),e[8]=_,e[9]=b):(_=e[8],b=e[9]),h=m.jsxs("div",{className:"flex flex-col mb-2",children:[m.jsx("button",{type:"button",onClick:()=>!g&&d(!f),onMouseEnter:_,onMouseLeave:b,className:ue("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(ni,{className:"text-muted-foreground shrink-0 shimmer",size:14}):o?m.jsx(Eo,{className:ue("text-muted-foreground transition-transform shrink-0",f&&"rotate-90"),size:14}):m.jsx(ko,{className:"text-muted-foreground shrink-0",size:14}),m.jsx("span",{className:ue("text-xs text-muted-foreground",g&&"shimmer"),children:g?"Thinking...":`Thought for ${u}s`})]})}),x&&m.jsx("div",{className:"ml-[6px] border-l-2 pl-4 mt-1 mb-2 max-h-[300px] overflow-y-auto",children:p.map((k,E)=>m.jsx("div",{className:"text-muted-foreground markdown-sm pb-2",children:m.jsx(cs,{id:`${i}-reasoning-${E}`,text:k.text})},`${i}-reasoning-${E}`))})]}),e[2]=i,e[3]=f,e[4]=o,e[5]=r,e[6]=u,e[7]=h}else h=e[7];return h}function m_(t){return t.state==="streaming"}function g_(t){return t.type==="reasoning"}function b_(t){const e=Z.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(Ju,{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(od,{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(Ju,{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 E_(t){const e=Z.c(32),{message:n,status:r,className:i}=t,{id:a,parts:s}=n,l=r==="streaming"||r==="submitted",f=D.useRef(null);let d;e[0]!==a?(d=()=>{const z=localStorage.getItem(`msg-duration-${a}`);return z?Number(z):null},e[0]=a,e[1]=d):d=e[1];const[h,p]=D.useState(d);let g,x;e[2]!==l?(g=()=>{l&&f.current===null&&(f.current=Date.now())},x=[l],e[2]=l,e[3]=g,e[4]=x):(g=e[3],x=e[4]),D.useEffect(g,x);let _,b;e[5]!==h||e[6]!==a||e[7]!==s.length?(_=()=>{if(s.length>0&&h===null&&f.current!==null){const z=Date.now()-f.current;p(z),localStorage.setItem(`msg-duration-${a}`,z.toString())}},b=[s.length,h,a],e[5]=h,e[6]=a,e[7]=s.length,e[8]=_,e[9]=b):(_=e[8],b=e[9]),D.useEffect(_,b);const k=s.length>0;let E;e[10]!==s?(E=s.some(x_),e[10]=s,e[11]=E):E=e[11];const w=E;let R;e[12]!==l||e[13]!==s?(R=l&&s.some(T_),e[12]=l,e[13]=s,e[14]=R):R=e[14];const O=k&&(w||R)&&h!==null;let H;e[15]!==n?(H=m.jsx(c_,{messages:[n]}),e[15]=n,e[16]=H):H=e[16];const $=H;let N;e[17]!==i?(N=ue("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 M;e[19]!==h||e[20]!==k||e[21]!==a||e[22]!==l||e[23]!==s||e[24]!==O||e[25]!==$?(M=k?m.jsxs(m.Fragment,{children:[O&&m.jsx(p_,{duration:h,parts:s,id:a}),s.map((z,F)=>{const K=s[F+1],ie=K&&(K.type==="dynamic-tool"||K.type.startsWith("tool-"));return m.jsx(b_,{part:z,id:a,usageStats:F===s.length-1?$:void 0,isFollowedByToolCall:ie},`${a}-${F}`)})]}):l?m.jsx(h_,{}):null,e[19]=h,e[20]=k,e[21]=a,e[22]=l,e[23]=s,e[24]=O,e[25]=$,e[26]=M):M=e[26];let v;e[27]!==M?(v=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:M})}),e[27]=M,e[28]=v):v=e[28];let J;return e[29]!==v||e[30]!==N?(J=m.jsx("div",{className:N,children:v}),e[29]=v,e[30]=N,e[31]=J):J=e[31],J}function T_(t){return t.type==="reasoning"&&t.state==="streaming"}function x_(t){return t.type==="reasoning"}const ld=D.createContext(null);function cd(t){const e=Z.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 __(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!D.isValidElement(r))continue;if(r.props?.message?.role==="assistant"){const a=t[n-1],s=D.isValidElement(a)&&a.props?.message?.role,u=a&&D.isValidElement(a)&&s==="user"?a:null;e.push({user:u,assistant:r})}}return e}function y_(t){const e=Z.c(27),{children:n,className:r,minHeightOffset:i}=t,a=D.useRef(null);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const u=D.useRef(s);let o,l,f,d,h,p,g;if(e[1]!==n||e[2]!==r||e[3]!==i){const k=D.Children.toArray(n),E=k[k.length-1];l=E&&D.isValidElement(E)&&E.type===cd?E:null;const w=l?k.slice(0,-1):k,R=__(w);let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=H=>{const $=u.current[H];if($&&a.current){const N=a.current.offsetTop,M=$.offsetTop;a.current.scrollTo({top:M-N,behavior:"smooth"})}},e[11]=S):S=e[11];const O=S;o=ld.Provider,e[12]===Symbol.for("react.memo_cache_sentinel")?(g={scrollToPair:O},e[12]=g):g=e[12],h=a,e[13]!==r?(p=ue("w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",r),e[13]=r,e[14]=p):p=e[14],f="flex flex-col min-w-0 max-w-2xl mx-auto w-full",d=R.map((H,$)=>{const N=$===R.length-1;return m.jsxs("div",{ref:M=>{u.current[$]=M},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:H.user&&D.isValidElement(H.user)?D.cloneElement(H.user,{pairIndex:$}):H.user}),H.assistant]},$)}),e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=l,e[6]=f,e[7]=d,e[8]=h,e[9]=p,e[10]=g}else o=e[4],l=e[5],f=e[6],d=e[7],h=e[8],p=e[9],g=e[10];let x;e[15]!==l||e[16]!==f||e[17]!==d?(x=m.jsxs("div",{className:f,children:[d,l]}),e[15]=l,e[16]=f,e[17]=d,e[18]=x):x=e[18];let _;e[19]!==h||e[20]!==p||e[21]!==x?(_=m.jsx("div",{ref:h,className:p,children:x}),e[19]=h,e[20]=p,e[21]=x,e[22]=_):_=e[22];let b;return e[23]!==o||e[24]!==g||e[25]!==_?(b=m.jsx(o,{value:g,children:_}),e[23]=o,e[24]=g,e[25]=_,e[26]=b):b=e[26],b}function A_(t){const e=Z.c(5),{locator:n}=Bt(),r=vo(),i=Oa();let a;return e[0]!==n||e[1]!==r||e[2]!==t||e[3]!==i?(a=async(u,o,l)=>{const f=await Oo(n,l),d=f.findIndex(_=>_.id===u);if(d===-1){console.warn(`[branch] Message ${u} not found in thread ${l}`);return}const h=f.slice(0,d).filter(C_),p=crypto.randomUUID(),g=new Date().toISOString(),x={id:p,title:"",created_at:g,updated_at:g,hidden:!1};if(await i.insert.mutateAsync(x),h.length>0){const _=h.map(b=>({...b,id:crypto.randomUUID(),metadata:{...b.metadata,thread_id:p,created_at:b.metadata?.created_at||g}}));await r.insertMany.mutateAsync(_)}t(p)},e[0]=n,e[1]=r,e[2]=t,e[3]=i,e[4]=a):a=e[4],a}function C_(t){return t.role!=="system"}function k_(t){const e=Z.c(18),{messageId:n,parts:r}=t,[i,a]=D.useState(!1),{setInputValue:s,startBranch:u,setActiveThreadId:o,activeThreadId:l}=L0(),f=A_(o);let d;e[0]!==r?(d=r.filter(I_).map(S_).join(`
|
|
98
98
|
`),e[0]=r,e[1]=d):d=e[1];const h=d;let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=S=>{S.stopPropagation(),a(!0)},e[2]=p):p=e[2];const g=p;let x;e[3]!==l||e[4]!==f||e[5]!==n||e[6]!==h||e[7]!==s||e[8]!==u?(x=async()=>{await f(n,h,l),s(h),u({originalThreadId:l,originalMessageId:n,originalMessageText:h}),a(!1)},e[3]=l,e[4]=f,e[5]=n,e[6]=h,e[7]=s,e[8]=u,e[9]=x):x=e[9];const _=x;let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx("div",{className:"flex justify-center items-end px-2 pb-1",children:m.jsxs(Ia,{children:[m.jsx(Na,{asChild:!0,children:m.jsx(st,{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(Ao,{size:16,className:"p-0.5"})})}),m.jsx(wa,{side:"bottom",children:"Edit message"})]})}),e[10]=b):b=e[10];let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=m.jsxs(bf,{children:[m.jsx(Ef,{children:"Edit message?"}),m.jsx(Tf,{children:"This will create a new conversation branch from this point. The original conversation will remain unchanged."})]}),e[11]=k):k=e[11];let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=m.jsx(xf,{children:"Cancel"}),e[12]=E):E=e[12];let w;e[13]!==_?(w=m.jsxs(_f,{children:[k,m.jsxs(yf,{children:[E,m.jsx(Af,{onClick:_,children:"Confirm"})]})]}),e[13]=_,e[14]=w):w=e[14];let R;return e[15]!==i||e[16]!==w?(R=m.jsxs(m.Fragment,{children:[b,m.jsx(Cf,{open:i,onOpenChange:a,children:w})]}),e[15]=i,e[16]=w,e[17]=R):R=e[17],R}function S_(t){return t.text}function I_(t){return t.type==="text"}function N_(t){const e=Z.c(29),{message:n,className:r,pairIndex:i}=t,{id:a,parts:s}=n,u=D.useContext(ld),[o,l]=D.useState(!1);if(!s||s.length===0)return null;let f;e[0]!==u||e[1]!==i?(f=()=>{l(!0),i!==void 0&&u?.scrollToPair(i)},e[0]=u,e[1]=i,e[2]=f):f=e[2];const d=f;let h;e[3]!==r?(h=ue("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]=h):h=e[4];let p,g;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=()=>l(!0),g=()=>l(!1),e[5]=p,e[6]=g):(p=e[5],g=e[6]);const x=o?"overflow-auto opacity-100":"overflow-hidden opacity-99 mask-b-from-1%";let _;e[7]!==x?(_=ue("z-10 px-4 py-2 transition-opacity max-h-[120px] flex-1",x),e[7]=x,e[8]=_):_=e[8];let b;if(e[9]!==a||e[10]!==s){let O;e[12]!==a?(O=(H,$)=>H.type==="text"?m.jsx(od,{id:a,part:H},`${a}-${$}`):null,e[12]=a,e[13]=O):O=e[13],b=s.map(O),e[9]=a,e[10]=s,e[11]=b}else b=e[11];let k;e[14]!==b?(k=m.jsx("div",{children:b}),e[14]=b,e[15]=k):k=e[15];let E;e[16]!==_||e[17]!==k?(E=m.jsx("div",{className:_,children:k}),e[16]=_,e[17]=k,e[18]=E):E=e[18];let w;e[19]!==a||e[20]!==s?(w=m.jsx(k_,{messageId:a,parts:s}),e[19]=a,e[20]=s,e[21]=w):w=e[21];let R;e[22]!==d||e[23]!==w||e[24]!==E?(R=m.jsxs("div",{tabIndex:0,onClick:d,onFocus:p,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,w]}),e[22]=d,e[23]=w,e[24]=E,e[25]=R):R=e[25];let S;return e[26]!==R||e[27]!==h?(S=m.jsx(m.Fragment,{children:m.jsx("div",{className:h,children:R})}),e[26]=R,e[27]=h,e[28]=S):S=e[28],S}function w_(t){const e=Z.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(kn.Root,{"data-slot":"drawer",...n}),e[2]=n,e[3]=r):r=e[3],r}function R_(t){const e=Z.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(kn.Trigger,{"data-slot":"drawer-trigger",...n}),e[2]=n,e[3]=r):r=e[3],r}function L_(t){const e=Z.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(kn.Portal,{"data-slot":"drawer-portal",...n}),e[2]=n,e[3]=r):r=e[3],r}function O_(t){const e=Z.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=ue("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",n),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==i?(a=m.jsx(kn.Overlay,{"data-slot":"drawer-overlay",className:i,...r}),e[5]=r,e[6]=i,e[7]=a):a=e[7],a}function v_(t){const e=Z.c(12);let n,r,i;e[0]!==t?({className:r,children:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx(O_,{}),e[4]=a):a=e[4];let s;e[5]!==r?(s=ue("group/drawer-content bg-background fixed z-50 flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",r),e[5]=r,e[6]=s):s=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx("div",{className:"bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),e[7]=u):u=e[7];let o;return e[8]!==n||e[9]!==i||e[10]!==s?(o=m.jsxs(L_,{"data-slot":"drawer-portal",children:[a,m.jsxs(kn.Content,{"data-slot":"drawer-content",className:s,...i,children:[u,n]})]}),e[8]=n,e[9]=i,e[10]=s,e[11]=o):o=e[11],o}function D_(t){const e=Z.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=ue("flex flex-col gap-1.5 px-4 py-2",n),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==i?(a=m.jsx("div",{"data-slot":"drawer-header",className:i,...r}),e[5]=r,e[6]=i,e[7]=a):a=e[7],a}function P_(t){const e=Z.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=ue("text-foreground font-semibold",n),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==i?(a=m.jsx(kn.Title,{"data-slot":"drawer-title",className:i,...r}),e[5]=r,e[6]=i,e[7]=a):a=e[7],a}function eo({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=M_({defaultProp:e,onChange:n}),a=t!==void 0,s=a?t:r,u=po(n),o=D.useCallback(l=>{if(a){const d=typeof l=="function"?l(t):l;d!==t&&u(d)}else i(l)},[a,t,i,u]);return[s,o]}function M_({defaultProp:t,onChange:e}){const n=D.useState(t),[r]=n,i=D.useRef(r),a=po(e);return D.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}const dd=D.createContext({isMobile:!1,setValue:()=>{}}),ds=()=>D.useContext(dd),fd=t=>{const e=Z.c(37);let n,r,i,a,s,u,o,l;e[0]!==t?({children:n,defaultOpen:r,open:u,onOpenChange:a,defaultValue:i,value:l,onValueChange:s,...o}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=a,e[5]=s,e[6]=u,e[7]=o,e[8]=l):(n=e[1],r=e[2],i=e[3],a=e[4],s=e[5],u=e[6],o=e[7],l=e[8]);const f=wf(),d=r??!1;let h;e[9]!==a||e[10]!==u||e[11]!==d?(h={prop:u,defaultProp:d,onChange:a},e[9]=a,e[10]=u,e[11]=d,e[12]=h):h=e[12];const[p,g]=eo(h);let x;e[13]!==i||e[14]!==s||e[15]!==l?(x={prop:l,defaultProp:i,onChange:s},e[13]=i,e[14]=s,e[15]=l,e[16]=x):x=e[16];const[_,b]=eo(x);let k;e[17]!==b?(k=H=>{H&&b(H)},e[17]=b,e[18]=k):k=e[18];const E=k;let w;e[19]!==f||e[20]!==E?(w={isMobile:f,setValue:E},e[19]=f,e[20]=E,e[21]=w):w=e[21];let R;e[22]!==n||e[23]!==p||e[24]!==o||e[25]!==g?(R=m.jsx(w_,{open:p,onOpenChange:g,...o,children:n}),e[22]=n,e[23]=p,e[24]=o,e[25]=g,e[26]=R):R=e[26];let S;e[27]!==p||e[28]!==o||e[29]!==g||e[30]!==E||e[31]!==R||e[32]!==_?(S=m.jsx(Nf,{open:p,onOpenChange:g,value:_,onValueChange:E,...o,children:R}),e[27]=p,e[28]=o,e[29]=g,e[30]=E,e[31]=R,e[32]=_,e[33]=S):S=e[33];let O;return e[34]!==w||e[35]!==S?(O=m.jsx(dd.Provider,{value:w,children:S}),e[34]=w,e[35]=S,e[36]=O):O=e[36],O},hd=t=>{const{children:e,title:n,headerActions:r,...i}=t,{isMobile:a}=ds(),{className:s,...u}=i;return a?m.jsxs(v_,{...u,children:[m.jsxs(D_,{className:ue(r?"flex flex-row items-center justify-between":"hidden"),children:[m.jsx(P_,{children:n}),r]}),m.jsx("div",{className:ue("flex flex-col gap-2 p-2 py-4",s),children:e})]}):m.jsx(If,{...i,children:e})},pd=t=>{const e=Z.c(7);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const{isMobile:i}=ds();let a;return e[3]!==n||e[4]!==i||e[5]!==r?(a=i?m.jsx(R_,{asChild:!0,children:m.jsx(st,{variant:"outline",...r,children:n})}):m.jsx(Sf,{...r,children:n}),e[3]=n,e[4]=i,e[5]=r,e[6]=a):a=e[6],a},md=t=>{const e=Z.c(7);let n,r;e[0]!==t?({children:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);const{isMobile:i}=ds();let a;return e[3]!==n||e[4]!==i||e[5]!==r?(a=i?m.jsx("span",{...r,children:n}):m.jsx(kf,{...r,children:n}),e[3]=n,e[4]=i,e[5]=r,e[6]=a):a=e[6],a};function B_(){const t=Z.c(4),e=sf();let n;t[0]!==e?(n=e??[],t[0]=e,t[1]=n):n=t[1];let r;return t[2]!==n?(r=n.map(F_),t[2]=n,t[3]=r):r=t[3],r}function F_(t){return{id:t.id,title:t.title,description:t.description??null,icon:t.icon??null,fallbackIcon:m.jsx(Ra,{})}}function H_(t){const e=Z.c(24),{gateway:n,isSelected:r}=t,i=r&&"bg-accent";let a;e[0]!==i?(a=ue("flex items-start gap-3 py-3 px-3 hover:bg-accent cursor-pointer rounded-lg",i),e[0]=i,e[1]=a):a=e[1];let s;e[2]!==n.fallbackIcon?(s=n.fallbackIcon??m.jsx(Ra,{}),e[2]=n.fallbackIcon,e[3]=s):s=e[3];let u;e[4]!==n.icon||e[5]!==n.title||e[6]!==s?(u=m.jsx(go,{icon:n.icon,name:n.title,size:"sm",fallbackIcon:s,className:"size-10"}),e[4]=n.icon,e[5]=n.title,e[6]=s,e[7]=u):u=e[7];let o;e[8]!==n.title?(o=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n.title}),e[8]=n.title,e[9]=o):o=e[9];let l;e[10]!==r?(l=r&&m.jsx(Kt,{size:16,className:"text-foreground shrink-0"}),e[10]=r,e[11]=l):l=e[11];let f;e[12]!==o||e[13]!==l?(f=m.jsxs("div",{className:"flex items-center justify-between",children:[o,l]}),e[12]=o,e[13]=l,e[14]=f):f=e[14];let d;e[15]!==n.description?(d=n.description&&m.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 leading-relaxed",children:n.description}),e[15]=n.description,e[16]=d):d=e[16];let h;e[17]!==f||e[18]!==d?(h=m.jsxs("div",{className:"flex flex-col flex-1 min-w-0 gap-0.5",children:[f,d]}),e[17]=f,e[18]=d,e[19]=h):h=e[19];let p;return e[20]!==a||e[21]!==u||e[22]!==h?(p=m.jsxs("div",{className:a,children:[u,h]}),e[20]=a,e[21]=u,e[22]=h,e[23]=p):p=e[23],p}function U_(t){const e=Z.c(12),{gateway:n}=t;if(!n){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx("span",{className:"text-sm text-muted-foreground",children:"Select gateway"}),e[0]=u):u=e[0],u}let r;e[1]!==n.fallbackIcon?(r=n.fallbackIcon??m.jsx(Ra,{}),e[1]=n.fallbackIcon,e[2]=r):r=e[2];let i;e[3]!==n.icon||e[4]!==n.title||e[5]!==r?(i=m.jsx(go,{icon:n.icon,name:n.title,size:"xs",fallbackIcon:r,className:"w-5! h-5! min-w-5! shrink-0 rounded-sm"}),e[3]=n.icon,e[4]=n.title,e[5]=r,e[6]=i):i=e[6];let a;e[7]!==n.title?(a=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.title}),e[7]=n.title,e[8]=a):a=e[8];let s;return e[9]!==i||e[10]!==a?(s=m.jsxs("div",{className:"flex items-center gap-2 min-w-0 max-w-full",children:[i,a]}),e[9]=i,e[10]=a,e[11]=s):s=e[11],s}function oA(t){const e=Z.c(37),{selectedGatewayId:n,onGatewayChange:r,variant:i,className:a,placeholder:s}=t,u=i===void 0?"bordered":i,o=s===void 0?"Select gateway":s,[l,f]=D.useState(!1),d=B_();let h;if(e[0]!==d||e[1]!==n){let M;e[3]!==n?(M=v=>v.id===n,e[3]=n,e[4]=M):M=e[4],h=d.find(M),e[0]=d,e[1]=n,e[2]=h}else h=e[2];const p=h;let g;e[5]!==r?(g=M=>{r(M),f(!1)},e[5]=r,e[6]=g):g=e[6];const x=g,_=n||"",b=u==="borderless"&&"border-0 md:border-none";let k;e[7]!==a||e[8]!==b?(k=ue("text-sm hover:bg-accent rounded-lg py-0.5 px-1 gap-1 shadow-none cursor-pointer group focus-visible:ring-0 focus-visible:ring-offset-0 min-w-0 max-w-full",b,a),e[7]=a,e[8]=b,e[9]=k):k=e[9];let E;e[10]!==p?(E=m.jsx(U_,{gateway:p}),e[10]=p,e[11]=E):E=e[11];let w;e[12]!==o||e[13]!==E?(w=m.jsx(md,{placeholder:o,className:"min-w-0 max-w-full",children:E}),e[12]=o,e[13]=E,e[14]=w):w=e[14];let R;e[15]!==k||e[16]!==w?(R=m.jsx(pd,{size:"sm",className:k,children:w}),e[15]=k,e[16]=w,e[17]=R):R=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=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:"flex items-center gap-2 text-muted-foreground",children:[m.jsx(mo,{size:16}),m.jsx("span",{className:"text-sm",children:"Search for a gateway..."})]})}),e[18]=S):S=e[18];let O;if(e[19]!==d||e[20]!==x||e[21]!==n){let M;e[23]!==x||e[24]!==n?(M=v=>m.jsx("div",{onClick:()=>x(v.id),className:"outline-none",children:m.jsx(H_,{gateway:v,isSelected:v.id===n})},v.id),e[23]=x,e[24]=n,e[25]=M):M=e[25],O=d.map(M),e[19]=d,e[20]=x,e[21]=n,e[22]=O}else O=e[22];let H;e[26]!==O?(H=m.jsxs("div",{className:"flex flex-col max-h-[400px]",children:[S,m.jsx("div",{className:"overflow-y-auto p-2 flex flex-col gap-1",children:O})]}),e[26]=O,e[27]=H):H=e[27];let $;e[28]!==o||e[29]!==H?($=m.jsx(hd,{title:o,className:"w-full md:w-[400px] p-0",children:H}),e[28]=o,e[29]=H,e[30]=$):$=e[30];let N;return e[31]!==x||e[32]!==l||e[33]!==R||e[34]!==$||e[35]!==_?(N=m.jsxs(fd,{open:l,onOpenChange:f,value:_,onValueChange:x,children:[R,$]}),e[31]=x,e[32]=l,e[33]=R,e[34]=$,e[35]=_,e[36]=N):N=e[36],N}function z_(t,e){const n=Z.c(4);let r;n[0]!==e?(r={},n[0]=e,n[1]=r):r=n[1];const i=r,a=t??tf;let s;return n[2]!==a?(s=rf(a),n[2]=a,n[3]=s):s=n[3],nf(a,"LLM",s,i)}function j_(){const t=Z.c(8),e=af();let n;t[0]!==e?(n={connections:e,binding:"LLMS"},t[0]=e,t[1]=n):n=t[1];const[r]=Jd(n),i=z_(r?.id);if(!i||!r){let s;return t[2]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[2]=s):s=t[2],s}let a;if(t[3]!==r||t[4]!==i){let s;t[6]!==r?(s=u=>({...u,name:u.title,contextWindow:u.limits?.contextWindow,outputLimit:u.limits?.maxOutputTokens,inputCost:u.costs?.input,outputCost:u.costs?.output,provider:u.provider,connectionId:r.id,connectionName:r.title}),t[6]=r,t[7]=s):s=t[7],a=i.map(s).sort($_),t[3]=r,t[4]=i,t[5]=a}else a=t[5];return a}function $_(t,e){return t.name.localeCompare(e.name)}const Y_={reasoning:{icon:m.jsx(ni,{className:"size-4"}),bg:"bg-purple-100",text:"text-purple-700",label:"Reasoning"},"image-upload":{icon:m.jsx(Co,{className:"size-4"}),bg:"bg-teal-100",text:"text-teal-700",label:"Can analyze images"},"file-upload":{icon:m.jsx(Rf,{className:"size-4"}),bg:"bg-blue-100",text:"text-blue-700",label:"Can analyze files"},"web-search":{icon:m.jsx(mo,{className:"size-4"}),bg:"bg-amber-100",text:"text-amber-700",label:"Can search the web to answer questions"}},gd=D.memo(function(e){const n=Z.c(11),{capability:r}=e,i=Y_[r];let a;n[0]!==r||n[1]!==i?(a=i||{icon:m.jsx(Kt,{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(Na,{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(wa,{children:m.jsx("p",{children:s.label})}),n[6]=s.label,n[7]=l):l=n[7];let f;return n[8]!==o||n[9]!==l?(f=m.jsxs(Ia,{children:[o,l]}),n[8]=o,n[9]=l,n[10]=f):f=n[10],f}),to=D.memo(function(e){const n=Z.c(54),{model:r,compact:i}=e,a=i===void 0?!1:i;if(!r){let b;return n[0]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Hover to preview"}),n[0]=b):b=n[0],b}const s=r.contextWindow||r.inputCost||r.outputCost||r.outputLimit;if(!s&&!a){let b;n[1]!==r.logo||n[2]!==r.name?(b=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]=b):b=n[3];let k;n[4]!==r.name?(k=m.jsx("p",{className:"text-lg font-medium leading-7",children:r.name}),n[4]=r.name,n[5]=k):k=n[5];let E;n[6]!==b||n[7]!==k?(E=m.jsxs("div",{className:"flex items-center gap-3 py-2 px-0",children:[b,k]}),n[6]=b,n[7]=k,n[8]=E):E=n[8];let w;n[9]!==r.description?(w=r.description&&m.jsx("p",{className:"text-sm text-muted-foreground",children:r.description}),n[9]=r.description,n[10]=w):w=n[10];let R;return n[11]!==E||n[12]!==w?(R=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[E,w]}),n[11]=E,n[12]=w,n[13]=R):R=n[13],R}if(!s&&a)return null;if(a){let b;n[14]!==r.contextWindow?(b=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]=b):b=n[15];let k;n[16]!==r.inputCost?(k=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]=k):k=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 w;n[20]!==r.outputLimit?(w=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]=w):w=n[21];let R;return n[22]!==b||n[23]!==k||n[24]!==E||n[25]!==w?(R=m.jsxs("div",{className:"flex flex-col gap-2.5 pt-3 pb-3 px-3 rounded-b-lg text-xs",children:[b,k,E,w]}),n[22]=b,n[23]=k,n[24]=E,n[25]=w,n[26]=R):R=n[26],R}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 f;n[35]!==r.capabilities?(f=r.capabilities&&r.capabilities.length>0&&m.jsx("div",{className:"flex items-center gap-2",children:r.capabilities.map(W_)}),n[35]=r.capabilities,n[36]=f):f=n[36];let d;n[37]!==l||n[38]!==f?(d=m.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[l,f]}),n[37]=l,n[38]=f,n[39]=d):d=n[39];let h;n[40]!==r.contextWindow?(h=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(cf,{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]=h):h=n[41];let p;n[42]!==r.inputCost||n[43]!==r.outputCost?(p=(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(_o,{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]=p):p=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(So,{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 x;n[47]!==h||n[48]!==p||n[49]!==g?(x=m.jsxs("div",{className:"flex flex-col gap-4",children:[h,p,g]}),n[47]=h,n[48]=p,n[49]=g,n[50]=x):x=n[50];let _;return n[51]!==x||n[52]!==d?(_=m.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[d,x]}),n[51]=x,n[52]=d,n[53]=_):_=n[53],_}),q_=D.memo(function(e){const n=Z.c(27),{model:r,onHover:i,isSelected:a,hasExpandedInfo:s}=e,u=s?"rounded-t-lg":"rounded-lg";let o;n[0]!==u?(o=ue("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 f;n[5]!==r.logo||n[6]!==r.name?(f=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]=f):f=n[7];let d;n[8]!==r.name?(d=m.jsx("span",{className:"text-sm text-foreground",children:r.name}),n[8]=r.name,n[9]=d):d=n[9];let h;n[10]!==s||n[11]!==r.capabilities?(h=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(G_)}),n[10]=s,n[11]=r.capabilities,n[12]=h):h=n[12];let p;n[13]!==s||n[14]!==a?(p=a&&!s&&m.jsx(Kt,{className:"w-4 h-4 text-foreground ml-auto"}),n[13]=s,n[14]=a,n[15]=p):p=n[15];let g;n[16]!==s||n[17]!==a?(g=a&&s&&m.jsx(Kt,{className:"w-4 h-4 text-foreground ml-2 shrink-0"}),n[16]=s,n[17]=a,n[18]=g):g=n[18];let x;return n[19]!==o||n[20]!==l||n[21]!==f||n[22]!==d||n[23]!==h||n[24]!==p||n[25]!==g?(x=m.jsxs("div",{className:o,onMouseEnter:l,children:[f,d,h,p,g]}),n[19]=o,n[20]=l,n[21]=f,n[22]=d,n[23]=h,n[24]=p,n[25]=g,n[26]=x):x=n[26],x});function V_(t){const e=Z.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 lA(t){const e=Z.c(57),{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,f]=D.useState(!1),[d,h]=D.useState(null),[p,g]=D.useState(!1),x=j_();let _;e[0]!==x||e[1]!==n?(_=n?x.find(W=>W.id===n.id&&W.connectionId===n.connectionId)?.id:void 0,e[0]=x,e[1]=n,e[2]=_):_=e[2];const b=_;let k;if(e[3]!==x||e[4]!==b){let W;e[6]!==b?(W=Q=>Q.id===b,e[6]=b,e[7]=W):W=e[7],k=x.find(W),e[3]=x,e[4]=b,e[5]=k}else k=e[5];const E=k;let w;e[8]!==x||e[9]!==r?(w=W=>{const Q=x.find(X=>X.id===W);Q&&(r({id:Q.id,connectionId:Q.connectionId,provider:Q.provider??void 0}),f(!1))},e[8]=x,e[9]=r,e[10]=w):w=e[10];const R=w;if(x.length===0)return null;const S=b||"",O=u==="borderless"&&"md:border-none";let H;e[11]!==a||e[12]!==O?(H=ue("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",O,a),e[11]=a,e[12]=O,e[13]=H):H=e[13];let $;e[14]!==E?($=m.jsx(V_,{model:E}),e[14]=E,e[15]=$):$=e[15];let N;e[16]!==o||e[17]!==$?(N=m.jsx(md,{placeholder:o,className:"min-w-0 max-w-full",children:$}),e[16]=o,e[17]=$,e[18]=N):N=e[18];let M;e[19]!==N||e[20]!==H?(M=m.jsx(pd,{size:"sm",className:H,children:N}),e[19]=N,e[20]=H,e[21]=M):M=e[21];let v;e[22]!==p?(v=()=>g(!p),e[22]=p,e[23]=v):v=e[23];const J=p?"text-foreground":"text-muted-foreground";let z;e[24]!==J?(z=ue("w-5 h-5 transition-colors",J),e[24]=J,e[25]=z):z=e[25];let F;e[26]!==z?(F=m.jsx(Lf,{className:z}),e[26]=z,e[27]=F):F=e[27];let K;e[28]!==v||e[29]!==F?(K=m.jsx("button",{type:"button",onClick:v,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:F}),e[28]=v,e[29]=F,e[30]=K):K=e[30];let ie;if(e[31]!==R||e[32]!==x||e[33]!==b||e[34]!==p){let W;e[36]!==R||e[37]!==b||e[38]!==p?(W=Q=>m.jsxs("div",{onClick:()=>R(Q.id),className:ue("rounded-lg mb-1",Q.id===b&&"bg-accent"),children:[m.jsx(q_,{model:Q,onHover:h,isSelected:Q.id===b,hasExpandedInfo:p}),p&&m.jsx("div",{className:"md:hidden",children:m.jsx(to,{model:Q,compact:!0})})]},Q.id),e[36]=R,e[37]=b,e[38]=p,e[39]=W):W=e[39],ie=x.map(W),e[31]=R,e[32]=x,e[33]=b,e[34]=p,e[35]=ie}else ie=e[35];let de;e[40]!==ie?(de=m.jsx("div",{className:"flex-1 overflow-y-auto px-0.5 md:border-r",children:ie}),e[40]=ie,e[41]=de):de=e[41];const xe=d||E||null;let I;e[42]!==xe?(I=m.jsx("div",{className:"hidden md:block md:w-[300px] p-3",children:m.jsx(to,{model:xe})}),e[42]=xe,e[43]=I):I=e[43];let le;e[44]!==de||e[45]!==I?(le=m.jsxs("div",{className:"flex flex-col md:flex-row h-[350px]",children:[de,I]}),e[44]=de,e[45]=I,e[46]=le):le=e[46];let Te;e[47]!==o||e[48]!==K||e[49]!==le?(Te=m.jsx(hd,{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:K,children:le}),e[47]=o,e[48]=K,e[49]=le,e[50]=Te):Te=e[50];let y;return e[51]!==R||e[52]!==l||e[53]!==M||e[54]!==Te||e[55]!==S?(y=m.jsxs(fd,{open:l,onOpenChange:f,value:S,onValueChange:R,children:[M,Te]}),e[51]=R,e[52]=l,e[53]=M,e[54]=Te,e[55]=S,e[56]=y):y=e[56],y}function W_(t){return m.jsx(gd,{capability:t},t)}function G_(t){return m.jsx(gd,{capability:t},t)}function Q_({messageCount:t,sentinelRef:e}){const n=D.useRef(t),r=D.useRef(0);t>n.current&&r.current!==t&&queueMicrotask(()=>{e.current?.scrollIntoView({behavior:"smooth",block:"start"}),r.current=t}),n.current=t}function no(t,e){const n=D.Children.toArray(t);for(const r of n)if(D.isValidElement(r)&&r.type===e)return r;return null}function X_(t){const e=Z.c(5),{className:n,children:r}=t;let i;e[0]!==n?(i=ue("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 Z_(t){const e=Z.c(11),{children:n}=t;let r;e[0]!==n?(r=no(n,bd),e[0]=n,e[1]=r):r=e[1];const i=r;let a;e[2]!==n?(a=no(n,Ed),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 f;e[6]!==l?(f=m.jsx("div",{className:"flex items-center gap-1",children:l}),e[6]=l,e[7]=f):f=e[7];let d;return e[8]!==o||e[9]!==f?(d=m.jsxs("div",{className:"flex h-12 items-center justify-between border-b border-border px-4 flex-none",children:[o,f]}),e[8]=o,e[9]=f,e[10]=d):d=e[10],d}function bd(t){const e=Z.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 Ed(t){const e=Z.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 K_(t){const e=Z.c(5),{children:n,className:r}=t;let i;e[0]!==r?(i=ue("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 J_(t){const e=Z.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 ey(t){const e=Z.c(12),{messages:n,status:r,minHeightOffset:i}=t,a=i===void 0?240:i,s=D.useRef(null);let u;e[0]!==n.length?(u={messageCount:n.length,sentinelRef:s},e[0]=n.length,e[1]=u):u=e[1],Q_(u);let o;if(e[2]!==n||e[3]!==r){let d;e[5]!==n.length||e[6]!==r?(d=(h,p)=>h.role==="user"?m.jsx(N_,{message:h},h.id):h.role==="assistant"?m.jsx(E_,{message:h,status:p===n.length-1?r:void 0},h.id):null,e[5]=n.length,e[6]=r,e[7]=d):d=e[7],o=n.map(d),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(cd,{children:m.jsx("div",{ref:s,className:"h-0"})}),e[8]=l):l=e[8];let f;return e[9]!==a||e[10]!==o?(f=m.jsxs(y_,{minHeightOffset:a,children:[o,l]}),e[9]=a,e[10]=o,e[11]=f):f=e[11],f}function ty(t){const e=Z.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=ue("flex-none w-full mx-auto p-2","max-w-2xl min-w-0"),e[0]=r):r=e[0];let i;return e[1]!==n?(i=m.jsx("div",{className:r,children:n}),e[1]=n,e[2]=i):i=e[2],i}function fs(t){const e=Z.c(24),{title:n,description:r,icon:i,variant:a,onDismiss:s,children:u}=t,o=a===void 0?"default":a;let l,f,d,h,p;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];h=ue("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full",E.container),p=i&&m.jsx("div",{className:ue("mt-0.5 shrink-0",E.icon),children:i}),l="flex-1 min-w-0",f=n&&m.jsx("div",{className:ue("text-xs mb-1",E.title),children:n}),d=r&&m.jsx("div",{className:ue("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]=f,e[7]=d,e[8]=h,e[9]=p}else l=e[5],f=e[6],d=e[7],h=e[8],p=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 x;e[12]!==l||e[13]!==f||e[14]!==d||e[15]!==g?(x=m.jsxs("div",{className:l,children:[f,d,g]}),e[12]=l,e[13]=f,e[14]=d,e[15]=g,e[16]=x):x=e[16];let _;e[17]!==s?(_=s&&m.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:m.jsx(of,{size:14})}),e[17]=s,e[18]=_):_=e[18];let b;return e[19]!==h||e[20]!==p||e[21]!==x||e[22]!==_?(b=m.jsxs("div",{className:h,children:[p,x,_]}),e[19]=h,e[20]=p,e[21]=x,e[22]=_,e[23]=b):b=e[23],b}function ny(t){const e=Z.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(xo,{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(st,{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(fs,{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 ry(t){const e=Z.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(bo,{size:16}),e[0]=a):a=e[0];let s;e[1]!==r?(s=m.jsx(st,{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(st,{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(fs,{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 iy(t){const e=Z.c(7),{finishReason:n,onContinue:r,onDismiss:i}=t;if(!n||n==="stop")return null;const s=ay(n);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx(uf,{size:16}),e[0]=u):u=e[0];let o;e[1]!==r?(o=m.jsx(st,{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(fs,{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 ay(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 cA=Object.assign(X_,{Header:Object.assign(Z_,{Left:bd,Right:Ed}),Main:K_,Messages:ey,EmptyState:J_,Footer:ty,Input:O0,BranchPreview:ny,ErrorBanner:ry,FinishReasonWarning:iy,Provider:w0});function dA(){const t=Z.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(Or,{align:"right",width:"w-3/4"}),m.jsx(Or,{align:"left",width:"w-full",lines:3}),m.jsx(Or,{align:"right",width:"w-2/3"}),m.jsx(Or,{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 Or(t){const e=Z.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=ue("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 f;e[2]!==l?(f=ue("flex min-w-0 flex-col gap-2",l),e[2]=l,e[3]=f):f=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=m.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=d):d=e[4];const h=n==="right"?"bg-muted":"bg-transparent border border-border/40";let p;e[5]!==h||e[6]!==a?(p=ue("min-w-0 rounded-2xl p-4",h,a),e[5]=h,e[6]=a,e[7]=p):p=e[7];let g;e[8]!==s?(g=Array.from({length:s}),e[8]=s,e[9]=g):g=e[9];let x;e[10]!==s||e[11]!==g?(x=m.jsx("div",{className:"space-y-2",children:g.map((E,w)=>m.jsx("div",{className:ue("h-3 rounded bg-muted-foreground/20 animate-pulse",w===s-1?"w-3/4":"w-full"),style:{animationDelay:`${w*.1}s`}},w))}),e[10]=s,e[11]=g,e[12]=x):x=e[12];let _;e[13]!==x||e[14]!==p?(_=m.jsx("div",{className:p,children:x}),e[13]=x,e[14]=p,e[15]=_):_=e[15];let b;e[16]!==_||e[17]!==f?(b=m.jsxs("div",{className:f,children:[d,_]}),e[16]=_,e[17]=f,e[18]=b):b=e[18];let k;return e[19]!==b||e[20]!==o?(k=m.jsx("div",{className:o,children:b}),e[19]=b,e[20]=o,e[21]=k):k=e[21],k}const Ti=D.createContext(null);Ti.displayName="PanelGroupContext";const Oe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},hs=10,Zt=D.useLayoutEffect,ro=Zd.useId,sy=typeof ro=="function"?ro:()=>null;let uy=0;function ps(t=null){const e=sy(),n=D.useRef(t||e||null);return n.current===null&&(n.current=""+uy++),t??n.current}function Td({children:t,className:e="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:a,id:s,maxSize:u,minSize:o,onCollapse:l,onExpand:f,onResize:d,order:h,style:p,tagName:g="div",...x}){const _=D.useContext(Ti);if(_===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:k,getPanelSize:E,getPanelStyle:w,groupId:R,isPanelCollapsed:S,reevaluatePanelConstraints:O,registerPanel:H,resizePanel:$,unregisterPanel:N}=_,M=ps(s),v=D.useRef({callbacks:{onCollapse:l,onExpand:f,onResize:d},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:u,minSize:o},id:M,idIsFromProps:s!==void 0,order:h});D.useRef({didLogMissingDefaultSizeWarning:!1}),Zt(()=>{const{callbacks:z,constraints:F}=v.current,K={...F};v.current.id=M,v.current.idIsFromProps=s!==void 0,v.current.order=h,z.onCollapse=l,z.onExpand=f,z.onResize=d,F.collapsedSize=n,F.collapsible=r,F.defaultSize=i,F.maxSize=u,F.minSize=o,(K.collapsedSize!==F.collapsedSize||K.collapsible!==F.collapsible||K.maxSize!==F.maxSize||K.minSize!==F.minSize)&&O(v.current,K)}),Zt(()=>{const z=v.current;return H(z),()=>{N(z)}},[h,M,H,N]),D.useImperativeHandle(a,()=>({collapse:()=>{b(v.current)},expand:z=>{k(v.current,z)},getId(){return M},getSize(){return E(v.current)},isCollapsed(){return S(v.current)},isExpanded(){return!S(v.current)},resize:z=>{$(v.current,z)}}),[b,k,E,S,M,$]);const J=w(v.current,i);return D.createElement(g,{...x,children:t,className:e,id:M,style:{...J,...p},[Oe.groupId]:R,[Oe.panel]:"",[Oe.panelCollapsible]:r||void 0,[Oe.panelId]:M,[Oe.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const xd=D.forwardRef((t,e)=>D.createElement(Td,{...t,forwardedRef:e}));Td.displayName="Panel";xd.displayName="forwardRef(Panel)";let Ca=null,zr=-1,vt=null;function oy(t,e){if(e){const n=(e&kd)!==0,r=(e&Sd)!==0,i=(e&Id)!==0,a=(e&Nd)!==0;if(n)return i?"se-resize":a?"ne-resize":"e-resize";if(r)return i?"sw-resize":a?"nw-resize":"w-resize";if(i)return"s-resize";if(a)return"n-resize"}switch(t){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function ly(){vt!==null&&(document.head.removeChild(vt),Ca=null,vt=null,zr=-1)}function Gi(t,e){var n,r;const i=oy(t,e);if(Ca!==i){if(Ca=i,vt===null&&(vt=document.createElement("style"),document.head.appendChild(vt)),zr>=0){var a;(a=vt.sheet)===null||a===void 0||a.removeRule(zr)}zr=(n=(r=vt.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&n!==void 0?n:-1}}function _d(t){return t.type==="keydown"}function yd(t){return t.type.startsWith("pointer")}function Ad(t){return t.type.startsWith("mouse")}function xi(t){if(yd(t)){if(t.isPrimary)return{x:t.clientX,y:t.clientY}}else if(Ad(t))return{x:t.clientX,y:t.clientY};return{x:1/0,y:1/0}}function cy(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function dy(t,e,n){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function fy(t,e){if(t===e)throw new Error("Cannot compare node with itself");const n={a:so(t),b:so(e)};let r;for(;n.a.at(-1)===n.b.at(-1);)t=n.a.pop(),e=n.b.pop(),r=t;ce(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:ao(io(n.a)),b:ao(io(n.b))};if(i.a===i.b){const a=r.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let u=a.length;for(;u--;){const o=a[u];if(o===s.a)return 1;if(o===s.b)return-1}}return Math.sign(i.a-i.b)}const hy=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function py(t){var e;const n=getComputedStyle((e=Cd(t))!==null&&e!==void 0?e:t).display;return n==="flex"||n==="inline-flex"}function my(t){const e=getComputedStyle(t);return!!(e.position==="fixed"||e.zIndex!=="auto"&&(e.position!=="static"||py(t))||+e.opacity<1||"transform"in e&&e.transform!=="none"||"webkitTransform"in e&&e.webkitTransform!=="none"||"mixBlendMode"in e&&e.mixBlendMode!=="normal"||"filter"in e&&e.filter!=="none"||"webkitFilter"in e&&e.webkitFilter!=="none"||"isolation"in e&&e.isolation==="isolate"||hy.test(e.willChange)||e.webkitOverflowScrolling==="touch")}function io(t){let e=t.length;for(;e--;){const n=t[e];if(ce(n,"Missing node"),my(n))return n}return null}function ao(t){return t&&Number(getComputedStyle(t).zIndex)||0}function so(t){const e=[];for(;t;)e.push(t),t=Cd(t);return e}function Cd(t){const{parentNode:e}=t;return e&&e instanceof ShadowRoot?e.host:e}const kd=1,Sd=2,Id=4,Nd=8,gy=cy()==="coarse";let dt=[],xn=!1,Wt=new Map,_i=new Map;const fr=new Set;function by(t,e,n,r,i){var a;const{ownerDocument:s}=e,u={direction:n,element:e,hitAreaMargins:r,setResizeHandlerState:i},o=(a=Wt.get(s))!==null&&a!==void 0?a:0;return Wt.set(s,o+1),fr.add(u),Jr(),function(){var f;_i.delete(t),fr.delete(u);const d=(f=Wt.get(s))!==null&&f!==void 0?f:1;if(Wt.set(s,d-1),Jr(),d===1&&Wt.delete(s),dt.includes(u)){const h=dt.indexOf(u);h>=0&&dt.splice(h,1),gs(),i("up",!0,null)}}}function Ey(t){const{target:e}=t,{x:n,y:r}=xi(t);xn=!0,ms({target:e,x:n,y:r}),Jr(),dt.length>0&&(ei("down",t),t.preventDefault(),wd(e)||t.stopImmediatePropagation())}function Qi(t){const{x:e,y:n}=xi(t);if(xn&&t.buttons===0&&(xn=!1,ei("up",t)),!xn){const{target:r}=t;ms({target:r,x:e,y:n})}ei("move",t),gs(),dt.length>0&&t.preventDefault()}function Xi(t){const{target:e}=t,{x:n,y:r}=xi(t);_i.clear(),xn=!1,dt.length>0&&(t.preventDefault(),wd(e)||t.stopImmediatePropagation()),ei("up",t),ms({target:e,x:n,y:r}),gs(),Jr()}function wd(t){let e=t;for(;e;){if(e.hasAttribute(Oe.resizeHandle))return!0;e=e.parentElement}return!1}function ms({target:t,x:e,y:n}){dt.splice(0);let r=null;(t instanceof HTMLElement||t instanceof SVGElement)&&(r=t),fr.forEach(i=>{const{element:a,hitAreaMargins:s}=i,u=a.getBoundingClientRect(),{bottom:o,left:l,right:f,top:d}=u,h=gy?s.coarse:s.fine;if(e>=l-h&&e<=f+h&&n>=d-h&&n<=o+h){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&fy(r,a)>0){let g=r,x=!1;for(;g&&!g.contains(a);){if(dy(g.getBoundingClientRect(),u)){x=!0;break}g=g.parentElement}if(x)return}dt.push(i)}})}function Zi(t,e){_i.set(t,e)}function gs(){let t=!1,e=!1;dt.forEach(r=>{const{direction:i}=r;i==="horizontal"?t=!0:e=!0});let n=0;_i.forEach(r=>{n|=r}),t&&e?Gi("intersection",n):t?Gi("horizontal",n):e?Gi("vertical",n):ly()}let Ki=new AbortController;function Jr(){Ki.abort(),Ki=new AbortController;const t={capture:!0,signal:Ki.signal};fr.size&&(xn?(dt.length>0&&Wt.forEach((e,n)=>{const{body:r}=n;e>0&&(r.addEventListener("contextmenu",Xi,t),r.addEventListener("pointerleave",Qi,t),r.addEventListener("pointermove",Qi,t))}),window.addEventListener("pointerup",Xi,t),window.addEventListener("pointercancel",Xi,t)):Wt.forEach((e,n)=>{const{body:r}=n;e>0&&(r.addEventListener("pointerdown",Ey,t),r.addEventListener("pointermove",Qi,t))}))}function ei(t,e){fr.forEach(n=>{const{setResizeHandlerState:r}=n,i=dt.includes(n);r(t,i,e)})}function Ty(){const[t,e]=D.useState(0);return D.useCallback(()=>e(n=>n+1),[])}function ce(t,e){if(!t)throw console.error(e),Error(e)}function rn(t,e,n=hs){return t.toFixed(n)===e.toFixed(n)?0:t>e?1:-1}function yt(t,e,n=hs){return rn(t,e,n)===0}function et(t,e,n){return rn(t,e,n)===0}function xy(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){const i=t[r],a=e[r];if(!et(i,a,n))return!1}return!0}function En({panelConstraints:t,panelIndex:e,size:n}){const r=t[e];ce(r!=null,`Panel constraints not found for index ${e}`);let{collapsedSize:i=0,collapsible:a,maxSize:s=100,minSize:u=0}=r;if(rn(n,u)<0)if(a){const o=(i+u)/2;rn(n,o)<0?n=i:n=u}else n=u;return n=Math.min(s,n),n=parseFloat(n.toFixed(hs)),n}function Vn({delta:t,initialLayout:e,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(et(t,0))return e;const s=[...e],[u,o]=r;ce(u!=null,"Invalid first pivot index"),ce(o!=null,"Invalid second pivot index");let l=0;if(a==="keyboard"){{const d=t<0?o:u,h=n[d];ce(h,`Panel constraints not found for index ${d}`);const{collapsedSize:p=0,collapsible:g,minSize:x=0}=h;if(g){const _=e[d];if(ce(_!=null,`Previous layout not found for panel index ${d}`),et(_,p)){const b=x-_;rn(b,Math.abs(t))>0&&(t=t<0?0-b:b)}}}{const d=t<0?u:o,h=n[d];ce(h,`No panel constraints found for index ${d}`);const{collapsedSize:p=0,collapsible:g,minSize:x=0}=h;if(g){const _=e[d];if(ce(_!=null,`Previous layout not found for panel index ${d}`),et(_,x)){const b=_-p;rn(b,Math.abs(t))>0&&(t=t<0?0-b:b)}}}}{const d=t<0?1:-1;let h=t<0?o:u,p=0;for(;;){const x=e[h];ce(x!=null,`Previous layout not found for panel index ${h}`);const b=En({panelConstraints:n,panelIndex:h,size:100})-x;if(p+=b,h+=d,h<0||h>=n.length)break}const g=Math.min(Math.abs(t),Math.abs(p));t=t<0?0-g:g}{let h=t<0?u:o;for(;h>=0&&h<n.length;){const p=Math.abs(t)-Math.abs(l),g=e[h];ce(g!=null,`Previous layout not found for panel index ${h}`);const x=g-p,_=En({panelConstraints:n,panelIndex:h,size:x});if(!et(g,_)&&(l+=g-_,s[h]=_,l.toPrecision(3).localeCompare(Math.abs(t).toPrecision(3),void 0,{numeric:!0})>=0))break;t<0?h--:h++}}if(xy(i,s))return i;{const d=t<0?o:u,h=e[d];ce(h!=null,`Previous layout not found for panel index ${d}`);const p=h+l,g=En({panelConstraints:n,panelIndex:d,size:p});if(s[d]=g,!et(g,p)){let x=p-g,b=t<0?o:u;for(;b>=0&&b<n.length;){const k=s[b];ce(k!=null,`Previous layout not found for panel index ${b}`);const E=k+x,w=En({panelConstraints:n,panelIndex:b,size:E});if(et(k,w)||(x-=w-k,s[b]=w),et(x,0))break;t>0?b--:b++}}}const f=s.reduce((d,h)=>h+d,0);return et(f,100)?s:i}function _y({layout:t,panelsArray:e,pivotIndices:n}){let r=0,i=100,a=0,s=0;const u=n[0];ce(u!=null,"No pivot index found"),e.forEach((d,h)=>{const{constraints:p}=d,{maxSize:g=100,minSize:x=0}=p;h===u?(r=x,i=g):(a+=x,s+=g)});const o=Math.min(i,100-a),l=Math.max(r,100-s),f=t[u];return{valueMax:o,valueMin:l,valueNow:f}}function hr(t,e=document){return Array.from(e.querySelectorAll(`[${Oe.resizeHandleId}][data-panel-group-id="${t}"]`))}function Rd(t,e,n=document){const i=hr(t,n).findIndex(a=>a.getAttribute(Oe.resizeHandleId)===e);return i??null}function Ld(t,e,n){const r=Rd(t,e,n);return r!=null?[r,r+1]:[-1,-1]}function Od(t,e=document){var n;if(e instanceof HTMLElement&&(e==null||(n=e.dataset)===null||n===void 0?void 0:n.panelGroupId)==t)return e;const r=e.querySelector(`[data-panel-group][data-panel-group-id="${t}"]`);return r||null}function yi(t,e=document){const n=e.querySelector(`[${Oe.resizeHandleId}="${t}"]`);return n||null}function yy(t,e,n,r=document){var i,a,s,u;const o=yi(e,r),l=hr(t,r),f=o?l.indexOf(o):-1,d=(i=(a=n[f])===null||a===void 0?void 0:a.id)!==null&&i!==void 0?i:null,h=(s=(u=n[f+1])===null||u===void 0?void 0:u.id)!==null&&s!==void 0?s:null;return[d,h]}function Ay({committedValuesRef:t,eagerValuesRef:e,groupId:n,layout:r,panelDataArray:i,panelGroupElement:a,setLayout:s}){D.useRef({didWarnAboutMissingResizeHandle:!1}),Zt(()=>{if(!a)return;const u=hr(n,a);for(let o=0;o<i.length-1;o++){const{valueMax:l,valueMin:f,valueNow:d}=_y({layout:r,panelsArray:i,pivotIndices:[o,o+1]}),h=u[o];if(h!=null){const p=i[o];ce(p,`No panel data found for index "${o}"`),h.setAttribute("aria-controls",p.id),h.setAttribute("aria-valuemax",""+Math.round(l)),h.setAttribute("aria-valuemin",""+Math.round(f)),h.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{u.forEach((o,l)=>{o.removeAttribute("aria-controls"),o.removeAttribute("aria-valuemax"),o.removeAttribute("aria-valuemin"),o.removeAttribute("aria-valuenow")})}},[n,r,i,a]),D.useEffect(()=>{if(!a)return;const u=e.current;ce(u,"Eager values not found");const{panelDataArray:o}=u,l=Od(n,a);ce(l!=null,`No group found for id "${n}"`);const f=hr(n,a);ce(f,`No resize handles found for group id "${n}"`);const d=f.map(h=>{const p=h.getAttribute(Oe.resizeHandleId);ce(p,"Resize handle element has no handle id attribute");const[g,x]=yy(n,p,o,a);if(g==null||x==null)return()=>{};const _=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const k=o.findIndex(E=>E.id===g);if(k>=0){const E=o[k];ce(E,`No panel data found for index ${k}`);const w=r[k],{collapsedSize:R=0,collapsible:S,minSize:O=0}=E.constraints;if(w!=null&&S){const H=Vn({delta:et(w,R)?O-R:R-w,initialLayout:r,panelConstraints:o.map($=>$.constraints),pivotIndices:Ld(n,p,a),prevLayout:r,trigger:"keyboard"});r!==H&&s(H)}}break}}};return h.addEventListener("keydown",_),()=>{h.removeEventListener("keydown",_)}});return()=>{d.forEach(h=>h())}},[a,t,e,n,r,i,s])}function uo(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function vd(t,e){const n=t==="horizontal",{x:r,y:i}=xi(e);return n?r:i}function Cy(t,e,n,r,i){const a=n==="horizontal",s=yi(e,i);ce(s,`No resize handle element found for id "${e}"`);const u=s.getAttribute(Oe.groupId);ce(u,"Resize handle element has no group id attribute");let{initialCursorPosition:o}=r;const l=vd(n,t),f=Od(u,i);ce(f,`No group element found for id "${u}"`);const d=f.getBoundingClientRect(),h=a?d.width:d.height;return(l-o)/h*100}function ky(t,e,n,r,i,a){if(_d(t)){const s=n==="horizontal";let u=0;t.shiftKey?u=100:i!=null?u=i:u=10;let o=0;switch(t.key){case"ArrowDown":o=s?0:u;break;case"ArrowLeft":o=s?-u:0;break;case"ArrowRight":o=s?u:0;break;case"ArrowUp":o=s?0:-u;break;case"End":o=100;break;case"Home":o=-100;break}return o}else return r==null?0:Cy(t,e,n,r,a)}function Sy({panelDataArray:t}){const e=Array(t.length),n=t.map(a=>a.constraints);let r=0,i=100;for(let a=0;a<t.length;a++){const s=n[a];ce(s,`Panel constraints not found for index ${a}`);const{defaultSize:u}=s;u!=null&&(r++,e[a]=u,i-=u)}for(let a=0;a<t.length;a++){const s=n[a];ce(s,`Panel constraints not found for index ${a}`);const{defaultSize:u}=s;if(u!=null)continue;const o=t.length-r,l=i/o;r++,e[a]=l,i-=l}return e}function fn(t,e,n){e.forEach((r,i)=>{const a=t[i];ce(a,`Panel data not found for index ${i}`);const{callbacks:s,constraints:u,id:o}=a,{collapsedSize:l=0,collapsible:f}=u,d=n[o];if(d==null||r!==d){n[o]=r;const{onCollapse:h,onExpand:p,onResize:g}=s;g&&g(r,d),f&&(h||p)&&(p&&(d==null||yt(d,l))&&!yt(r,l)&&p(),h&&(d==null||!yt(d,l))&&yt(r,l)&&h())}})}function vr(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!=e[n])return!1;return!0}function Iy({defaultSize:t,dragState:e,layout:n,panelData:r,panelIndex:i,precision:a=3}){const s=n[i];let u;return s==null?u=t!=null?t.toPrecision(a):"1":r.length===1?u="1":u=s.toPrecision(a),{flexBasis:0,flexGrow:u,flexShrink:1,overflow:"hidden",pointerEvents:e!==null?"none":void 0}}function Ny(t,e=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{t(...i)},e)}}function oo(t){try{if(typeof localStorage<"u")t.getItem=e=>localStorage.getItem(e),t.setItem=(e,n)=>{localStorage.setItem(e,n)};else throw new Error("localStorage not supported in this environment")}catch(e){console.error(e),t.getItem=()=>null,t.setItem=()=>{}}}function Dd(t){return`react-resizable-panels:${t}`}function Pd(t){return t.map(e=>{const{constraints:n,id:r,idIsFromProps:i,order:a}=e;return i?r:a?`${a}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((e,n)=>e.localeCompare(n)).join(",")}function Md(t,e){try{const n=Dd(t),r=e.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function wy(t,e,n){var r,i;const a=(r=Md(t,n))!==null&&r!==void 0?r:{},s=Pd(e);return(i=a[s])!==null&&i!==void 0?i:null}function Ry(t,e,n,r,i){var a;const s=Dd(t),u=Pd(e),o=(a=Md(t,i))!==null&&a!==void 0?a:{};o[u]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(s,JSON.stringify(o))}catch(l){console.error(l)}}function lo({layout:t,panelConstraints:e}){const n=[...t],r=n.reduce((a,s)=>a+s,0);if(n.length!==e.length)throw Error(`Invalid ${e.length} panel layout: ${n.map(a=>`${a}%`).join(", ")}`);if(!et(r,100)&&n.length>0)for(let a=0;a<e.length;a++){const s=n[a];ce(s!=null,`No layout data found for index ${a}`);const u=100/r*s;n[a]=u}let i=0;for(let a=0;a<e.length;a++){const s=n[a];ce(s!=null,`No layout data found for index ${a}`);const u=En({panelConstraints:e,panelIndex:a,size:s});s!=u&&(i+=s-u,n[a]=u)}if(!et(i,0))for(let a=0;a<e.length;a++){const s=n[a];ce(s!=null,`No layout data found for index ${a}`);const u=s+i,o=En({panelConstraints:e,panelIndex:a,size:u});if(s!==o&&(i-=o-s,n[a]=o,et(i,0)))break}return n}const Ly=100,Wn={getItem:t=>(oo(Wn),Wn.getItem(t)),setItem:(t,e)=>{oo(Wn),Wn.setItem(t,e)}},co={};function Bd({autoSaveId:t=null,children:e,className:n="",direction:r,forwardedRef:i,id:a=null,onLayout:s=null,keyboardResizeBy:u=null,storage:o=Wn,style:l,tagName:f="div",...d}){const h=ps(a),p=D.useRef(null),[g,x]=D.useState(null),[_,b]=D.useState([]),k=Ty(),E=D.useRef({}),w=D.useRef(new Map),R=D.useRef(0),S=D.useRef({autoSaveId:t,direction:r,dragState:g,id:h,keyboardResizeBy:u,onLayout:s,storage:o}),O=D.useRef({layout:_,panelDataArray:[],panelDataArrayChanged:!1});D.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),D.useImperativeHandle(i,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:y}=O.current;return y},setLayout:y=>{const{onLayout:W}=S.current,{layout:Q,panelDataArray:X}=O.current,G=lo({layout:y,panelConstraints:X.map(ee=>ee.constraints)});uo(Q,G)||(b(G),O.current.layout=G,W&&W(G),fn(X,G,E.current))}}),[]),Zt(()=>{S.current.autoSaveId=t,S.current.direction=r,S.current.dragState=g,S.current.id=h,S.current.onLayout=s,S.current.storage=o}),Ay({committedValuesRef:S,eagerValuesRef:O,groupId:h,layout:_,panelDataArray:O.current.panelDataArray,setLayout:b,panelGroupElement:p.current}),D.useEffect(()=>{const{panelDataArray:y}=O.current;if(t){if(_.length===0||_.length!==y.length)return;let W=co[t];W==null&&(W=Ny(Ry,Ly),co[t]=W);const Q=[...y],X=new Map(w.current);W(t,Q,X,_,o)}},[t,_,o]),D.useEffect(()=>{});const H=D.useCallback(y=>{const{onLayout:W}=S.current,{layout:Q,panelDataArray:X}=O.current;if(y.constraints.collapsible){const G=X.map(Re=>Re.constraints),{collapsedSize:ee=0,panelSize:re,pivotIndices:he}=qt(X,y,Q);if(ce(re!=null,`Panel size not found for panel "${y.id}"`),!yt(re,ee)){w.current.set(y.id,re);const Be=gn(X,y)===X.length-1?re-ee:ee-re,me=Vn({delta:Be,initialLayout:Q,panelConstraints:G,pivotIndices:he,prevLayout:Q,trigger:"imperative-api"});vr(Q,me)||(b(me),O.current.layout=me,W&&W(me),fn(X,me,E.current))}}},[]),$=D.useCallback((y,W)=>{const{onLayout:Q}=S.current,{layout:X,panelDataArray:G}=O.current;if(y.constraints.collapsible){const ee=G.map(Ze=>Ze.constraints),{collapsedSize:re=0,panelSize:he=0,minSize:Re=0,pivotIndices:Be}=qt(G,y,X),me=W??Re;if(yt(he,re)){const Ze=w.current.get(y.id),St=Ze!=null&&Ze>=me?Ze:me,on=gn(G,y)===G.length-1?he-St:St-he,Fe=Vn({delta:on,initialLayout:X,panelConstraints:ee,pivotIndices:Be,prevLayout:X,trigger:"imperative-api"});vr(X,Fe)||(b(Fe),O.current.layout=Fe,Q&&Q(Fe),fn(G,Fe,E.current))}}},[]),N=D.useCallback(y=>{const{layout:W,panelDataArray:Q}=O.current,{panelSize:X}=qt(Q,y,W);return ce(X!=null,`Panel size not found for panel "${y.id}"`),X},[]),M=D.useCallback((y,W)=>{const{panelDataArray:Q}=O.current,X=gn(Q,y);return Iy({defaultSize:W,dragState:g,layout:_,panelData:Q,panelIndex:X})},[g,_]),v=D.useCallback(y=>{const{layout:W,panelDataArray:Q}=O.current,{collapsedSize:X=0,collapsible:G,panelSize:ee}=qt(Q,y,W);return ce(ee!=null,`Panel size not found for panel "${y.id}"`),G===!0&&yt(ee,X)},[]),J=D.useCallback(y=>{const{layout:W,panelDataArray:Q}=O.current,{collapsedSize:X=0,collapsible:G,panelSize:ee}=qt(Q,y,W);return ce(ee!=null,`Panel size not found for panel "${y.id}"`),!G||rn(ee,X)>0},[]),z=D.useCallback(y=>{const{panelDataArray:W}=O.current;W.push(y),W.sort((Q,X)=>{const G=Q.order,ee=X.order;return G==null&&ee==null?0:G==null?-1:ee==null?1:G-ee}),O.current.panelDataArrayChanged=!0,k()},[k]);Zt(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:y,onLayout:W,storage:Q}=S.current,{layout:X,panelDataArray:G}=O.current;let ee=null;if(y){const he=wy(y,G,Q);he&&(w.current=new Map(Object.entries(he.expandToSizes)),ee=he.layout)}ee==null&&(ee=Sy({panelDataArray:G}));const re=lo({layout:ee,panelConstraints:G.map(he=>he.constraints)});uo(X,re)||(b(re),O.current.layout=re,W&&W(re),fn(G,re,E.current))}}),Zt(()=>{const y=O.current;return()=>{y.layout=[]}},[]);const F=D.useCallback(y=>{let W=!1;const Q=p.current;return Q&&window.getComputedStyle(Q,null).getPropertyValue("direction")==="rtl"&&(W=!0),function(G){G.preventDefault();const ee=p.current;if(!ee)return()=>null;const{direction:re,dragState:he,id:Re,keyboardResizeBy:Be,onLayout:me}=S.current,{layout:Ze,panelDataArray:St}=O.current,{initialLayout:Ut}=he??{},on=Ld(Re,y,ee);let Fe=ky(G,y,re,he,Be,ee);const Ln=re==="horizontal";Ln&&W&&(Fe=-Fe);const Cr=St.map(Ai=>Ai.constraints),zt=Vn({delta:Fe,initialLayout:Ut??Ze,panelConstraints:Cr,pivotIndices:on,prevLayout:Ze,trigger:_d(G)?"keyboard":"mouse-or-touch"}),kr=!vr(Ze,zt);(yd(G)||Ad(G))&&R.current!=Fe&&(R.current=Fe,!kr&&Fe!==0?Ln?Zi(y,Fe<0?kd:Sd):Zi(y,Fe<0?Id:Nd):Zi(y,0)),kr&&(b(zt),O.current.layout=zt,me&&me(zt),fn(St,zt,E.current))}},[]),K=D.useCallback((y,W)=>{const{onLayout:Q}=S.current,{layout:X,panelDataArray:G}=O.current,ee=G.map(Ze=>Ze.constraints),{panelSize:re,pivotIndices:he}=qt(G,y,X);ce(re!=null,`Panel size not found for panel "${y.id}"`);const Be=gn(G,y)===G.length-1?re-W:W-re,me=Vn({delta:Be,initialLayout:X,panelConstraints:ee,pivotIndices:he,prevLayout:X,trigger:"imperative-api"});vr(X,me)||(b(me),O.current.layout=me,Q&&Q(me),fn(G,me,E.current))},[]),ie=D.useCallback((y,W)=>{const{layout:Q,panelDataArray:X}=O.current,{collapsedSize:G=0,collapsible:ee}=W,{collapsedSize:re=0,collapsible:he,maxSize:Re=100,minSize:Be=0}=y.constraints,{panelSize:me}=qt(X,y,Q);me!=null&&(ee&&he&&yt(me,G)?yt(G,re)||K(y,re):me<Be?K(y,Be):me>Re&&K(y,Re))},[K]),de=D.useCallback((y,W)=>{const{direction:Q}=S.current,{layout:X}=O.current;if(!p.current)return;const G=yi(y,p.current);ce(G,`Drag handle element not found for id "${y}"`);const ee=vd(Q,W);x({dragHandleId:y,dragHandleRect:G.getBoundingClientRect(),initialCursorPosition:ee,initialLayout:X})},[]),xe=D.useCallback(()=>{x(null)},[]),I=D.useCallback(y=>{const{panelDataArray:W}=O.current,Q=gn(W,y);Q>=0&&(W.splice(Q,1),delete E.current[y.id],O.current.panelDataArrayChanged=!0,k())},[k]),le=D.useMemo(()=>({collapsePanel:H,direction:r,dragState:g,expandPanel:$,getPanelSize:N,getPanelStyle:M,groupId:h,isPanelCollapsed:v,isPanelExpanded:J,reevaluatePanelConstraints:ie,registerPanel:z,registerResizeHandle:F,resizePanel:K,startDragging:de,stopDragging:xe,unregisterPanel:I,panelGroupElement:p.current}),[H,g,r,$,N,M,h,v,J,ie,z,F,K,de,xe,I]),Te={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return D.createElement(Ti.Provider,{value:le},D.createElement(f,{...d,children:e,className:n,id:a,ref:p,style:{...Te,...l},[Oe.group]:"",[Oe.groupDirection]:r,[Oe.groupId]:h}))}const Fd=D.forwardRef((t,e)=>D.createElement(Bd,{...t,forwardedRef:e}));Bd.displayName="PanelGroup";Fd.displayName="forwardRef(PanelGroup)";function gn(t,e){return t.findIndex(n=>n===e||n.id===e.id)}function qt(t,e,n){const r=gn(t,e),a=r===t.length-1?[r-1,r]:[r,r+1],s=n[r];return{...e.constraints,panelSize:s,pivotIndices:a}}function Oy({disabled:t,handleId:e,resizeHandler:n,panelGroupElement:r}){D.useEffect(()=>{if(t||n==null||r==null)return;const i=yi(e,r);if(i==null)return;const a=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const u=i.getAttribute(Oe.groupId);ce(u,`No group element found for id "${u}"`);const o=hr(u,r),l=Rd(u,e,r);ce(l!==null,`No resize element found for id "${e}"`);const f=s.shiftKey?l>0?l-1:o.length-1:l+1<o.length?l+1:0;o[f].focus();break}}};return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}},[r,t,e,n])}function Hd({children:t=null,className:e="",disabled:n=!1,hitAreaMargins:r,id:i,onBlur:a,onClick:s,onDragging:u,onFocus:o,onPointerDown:l,onPointerUp:f,style:d={},tabIndex:h=0,tagName:p="div",...g}){var x,_;const b=D.useRef(null),k=D.useRef({onClick:s,onDragging:u,onPointerDown:l,onPointerUp:f});D.useEffect(()=>{k.current.onClick=s,k.current.onDragging=u,k.current.onPointerDown=l,k.current.onPointerUp=f});const E=D.useContext(Ti);if(E===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:w,groupId:R,registerResizeHandle:S,startDragging:O,stopDragging:H,panelGroupElement:$}=E,N=ps(i),[M,v]=D.useState("inactive"),[J,z]=D.useState(!1),[F,K]=D.useState(null),ie=D.useRef({state:M});Zt(()=>{ie.current.state=M}),D.useEffect(()=>{if(n)K(null);else{const le=S(N);K(()=>le)}},[n,N,S]);const de=(x=r?.coarse)!==null&&x!==void 0?x:15,xe=(_=r?.fine)!==null&&_!==void 0?_:5;D.useEffect(()=>{if(n||F==null)return;const le=b.current;ce(le,"Element ref not attached");let Te=!1;return by(N,le,w,{coarse:de,fine:xe},(W,Q,X)=>{if(!Q){v("inactive");return}switch(W){case"down":{v("drag"),Te=!1,ce(X,'Expected event to be defined for "down" action'),O(N,X);const{onDragging:G,onPointerDown:ee}=k.current;G?.(!0),ee?.();break}case"move":{const{state:G}=ie.current;Te=!0,G!=="drag"&&v("hover"),ce(X,'Expected event to be defined for "move" action'),F(X);break}case"up":{v("hover"),H();const{onClick:G,onDragging:ee,onPointerUp:re}=k.current;ee?.(!1),re?.(),Te||G?.();break}}})},[de,w,n,xe,S,N,F,O,H]),Oy({disabled:n,handleId:N,resizeHandler:F,panelGroupElement:$});const I={touchAction:"none",userSelect:"none"};return D.createElement(p,{...g,children:t,className:e,id:i,onBlur:()=>{z(!1),a?.()},onFocus:()=>{z(!0),o?.()},ref:b,role:"separator",style:{...I,...d},tabIndex:h,[Oe.groupDirection]:w,[Oe.groupId]:R,[Oe.resizeHandle]:"",[Oe.resizeHandleActive]:M==="drag"?"pointer":J?"keyboard":void 0,[Oe.resizeHandleEnabled]:!n,[Oe.resizeHandleId]:N,[Oe.resizeHandleState]:M})}Hd.displayName="PanelResizeHandle";function fA(t){const e=Z.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let i;e[3]!==n?(i=ue("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",n),e[3]=n,e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==i?(a=m.jsx(Fd,{"data-slot":"resizable-panel-group",className:i,...r}),e[5]=r,e[6]=i,e[7]=a):a=e[7],a}function hA(t){const e=Z.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=m.jsx(xd,{"data-slot":"resizable-panel",...n}),e[2]=n,e[3]=r):r=e[3],r}function pA(t){const e=Z.c(12);let n,r,i;e[0]!==t?({withHandle:i,className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);let a;e[4]!==n?(a=ue("bg-border focus-visible:ring-ring relative flex w-[0.5px] items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",n),e[4]=n,e[5]=a):a=e[5];let s;e[6]!==i?(s=i&&m.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:m.jsx(yo,{className:"size-2.5"})}),e[6]=i,e[7]=s):s=e[7];let u;return e[8]!==r||e[9]!==a||e[10]!==s?(u=m.jsx(Hd,{"data-slot":"resizable-handle",className:a,...r,children:s}),e[8]=r,e[9]=a,e[10]=s,e[11]=u):u=e[11],u}export{cA as C,R_ as D,oA as G,uA as I,lA as M,hA as R,c_ as U,rA as a,B_ as b,j_ as c,sA as d,iA as e,v_ as f,D_ as g,P_ as h,eo as i,w_ as j,pA as k,dA as l,fA as m,No as n,L0 as u};
|