@cline/cli-windows-arm64 3.0.46-nightly.1785242607 → 3.0.47
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/bin/cline.exe +0 -0
- package/cline-hub/webview/assets/Chat-BA-cxecm.js +201 -0
- package/cline-hub/webview/assets/{extensions-view-DMbfru0m.js → extensions-view-DXvL0IXH.js} +1 -1
- package/cline-hub/webview/assets/{index-CUY7QwHc.js → index-Be-mNsEe.js} +2 -2
- package/cline-hub/webview/assets/index-kv5oct7o.css +1 -0
- package/cline-hub/webview/assets/{label-CqV5yDUu.js → label-BwsGMt3P.js} +1 -1
- package/cline-hub/webview/assets/{settings-view-c-wXbbEP.js → settings-view-B3OOmDmW.js} +1 -1
- package/cline-hub/webview/index.html +2 -2
- package/package.json +1 -1
- package/cline-hub/webview/assets/Chat-Ca65PjKr.js +0 -201
- package/cline-hub/webview/assets/index-CoW3tdiW.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{i as n,r}from"./bundle-mjs-D3mlU5Wg.js";import{t as i}from"./react-dom-Cmec2Q1Q.js";import{$ as a,A as o,B as s,Bt as c,D as l,E as u,F as d,Ht as f,I as p,K as m,L as h,Mt as g,O as ee,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as te,Y as ne,Z as re,_ as D,c as O,ct as ie,d as k,dt as A,et as ae,f as oe,ft as se,g as ce,h as le,k as ue,l as de,lt as fe,m as pe,p as me,st as he,u as ge,v as _e,w as ve,x as ye,xt as be,y as j}from"./vscode-DBs95Ixu.js";import{A as xe,C as Se,D as Ce,E as we,F as Te,I as Ee,M as De,N as Oe,O as ke,P as Ae,S as je,T as Me,_ as Ne,a as Pe,b as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,i as Ve,j as He,k as Ue,l as We,n as Ge,p as Ke,r as qe,s as Je,t as M,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./label-CqV5yDUu.js";import{a as et,i as tt,n as nt,r as rt,t as N}from"./desktop-client-B4hwKFvn.js";import{a as it,i as at,n as ot,r as st,t as ct}from"./switch-D32hLf2L.js";import{$ as lt,B as ut,C as dt,Ct as ft,G as pt,Mt as mt,Nt as ht,O as gt,Pt as _t,Q as vt,S as yt,Tt as bt,W as xt,X as St,Z as Ct,_ as wt,a as Tt,at as Et,b as P,bt as Dt,c as Ot,ct as kt,d as At,dt as jt,et as Mt,f as Nt,ft as Pt,g as Ft,gt as It,h as Lt,ht as F,i as Rt,it as zt,kt as Bt,m as Vt,mt as I,n as Ht,nt as Ut,o as Wt,ot as Gt,pt as Kt,r as qt,rt as Jt,s as L,t as Yt,tt as Xt,u as Zt,v as Qt,vt as $t,w as en,wt as tn,x as nn,xt as rn,y as an,yt as on,z as sn}from"./index-CUY7QwHc.js";var cn=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ln=S(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),un=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),dn=S(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),fn=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),pn=S(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),mn=S(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),hn=S(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),gn=S(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),_n=S(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),vn=S(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),yn=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),bn=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),xn=S(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),R=e(n(),1),Sn=R.createContext({disabled:!1});function Cn(){return R.useContext(Sn)}var wn=R.createContext(void 0);function Tn(e=!0){let t=R.useContext(wn);if(t===void 0&&!e)throw Error(c(3));return t}var z=r();function En(e){let t=e instanceof Error?e.message:String(e);return t.includes(`unsupported desktop command: cline_account`)?Error(`The desktop sidecar is running an older build that does not support account commands. Restart the sidecar or reload the app, then try again.`):e instanceof Error?e:Error(t)}function Dn(e){let t=e.toLowerCase();return t.includes(`no cline account auth token found`)||t.includes(`requires re-authentication`)||t.includes(`auth token`)||t.includes(`unauthorized`)}async function On(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function kn(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function An(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function jn(e){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Mn(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Nn(e,t){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function Pn(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function Fn(){let[e,t]=(0,R.useState)(`overview`),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)([]),[p,m]=(0,R.useState)(!0),[h,g]=(0,R.useState)(null),[ee,_]=(0,R.useState)([]),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1),w=(0,R.useRef)(0),[T,E]=(0,R.useState)([]),[te,ne]=(0,R.useState)(!1),[re,D]=(0,R.useState)(null),[O,ie]=(0,R.useState)(!1),k=d.find(e=>e.active)??null,A=(0,R.useCallback)(()=>{a(null),s(null),l(null),f([]),_([]),C(!1),x(null),E([]),ie(!1),D(null)},[]),ae=(0,R.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([On(),kn(),An()]),r=n.find(e=>e.active)??null,i=r?await jn(r.organizationId):null;a(e),s(t),l(i),f(n)}catch(e){A();let t=En(e).message;g(t)}finally{m(!1)}},[A]);(0,R.useEffect)(()=>{ae()},[ae]);let oe=async()=>{r(`sign-in`),g(null);try{await N.invoke(`run_provider_oauth_login`,{provider:`cline`}),await ae(),t(`overview`)}catch(e){let t=En(e).message;g(t),A()}finally{r(null)}},se=async()=>{r(`sign-out`);try{await N.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),A(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=En(e).message;g(t)}finally{r(null)}},ce=(0,R.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=k?await Nn(k.organizationId,k.memberId):await Mn();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=En(t).message;x(n)}finally{w.current===e&&y(!1)}},[k]);(0,R.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[k?.organizationId]),(0,R.useEffect)(()=>{e===`usage`&&!S&&ce()},[e,S,ce]);let le=(0,R.useCallback)(async()=>{ne(!0),D(null);try{let e=await Pn();E(e),ie(!0)}catch(e){let t=En(e).message;D(t)}finally{ne(!1)}},[]);(0,R.useEffect)(()=>{e===`billing`&&!O&&le()},[e,O,le]);let ue=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),de=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),fe=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),pe=k?c?.balance??o?.balance??null:o?.balance??null,me=[`overview`,`usage`,`billing`],he=(e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,z.jsx)(dn,{className:`h-8 w-8 text-destructive`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 rounded-lg border border-border px-3.5 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,z.jsx)(tt,{className:`h-4 w-4`}),`Retry`]})]}),ge=()=>(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,z.jsx)(xt,{className:`h-6 w-6`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Connect your Cline account to review credits, usage, billing, and organization details from Cline Hub.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,z.jsxs)(j,{disabled:n!==null,onClick:()=>void oe(),type:`button`,children:[n===`sign-in`?(0,z.jsx)(it,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(_n,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,z.jsxs)(`a`,{className:`inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,href:`https://app.cline.bot`,rel:`noopener noreferrer`,target:`_blank`,children:[`Create account`,(0,z.jsx)(et,{className:`h-4 w-4`})]})]})]})}),_e=()=>(0,z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,z.jsx)(it,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,z.jsxs)(Wt,{children:[(0,z.jsx)(L,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,z.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:me.map(n=>{let r=!i&&n!==`overview`;return(0,z.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:u(`relative px-4 py-2.5 text-sm font-medium capitalize transition-colors`,e===n?`text-foreground`:`text-muted-foreground hover:text-foreground`,r&&`cursor-not-allowed opacity-45 hover:text-muted-foreground`),children:[n,e===n&&(0,z.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&_e(),h&&(Dn(h)?ge():he(h,ae)),!p&&!h&&i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,z.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-primary/20 text-2xl font-bold text-primary`,children:i.displayName?.charAt(0)??i.email?.charAt(0)??`?`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,z.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,ue(i.createdAt)]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,z.jsxs)(`a`,{href:`https://app.cline.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[`Open dashboard`,(0,z.jsx)(et,{className:`h-3.5 w-3.5`})]}),(0,z.jsxs)(j,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void se(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,z.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(vn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),pe!==null&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(pn,{className:`h-5 w-5 text-primary`}),(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:k?`${k.name} Balance`:`Credits Balance`})]}),(0,z.jsxs)(`a`,{href:`https://app.cline.bot/dashboard/organization?tab=credits&redirect=true`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,z.jsx)(De,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,z.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,z.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,fe(pe)]})}),k&&o&&(0,z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,fe(o.balance),` `,`credits`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(ln,{className:`h-5 w-5 text-muted-foreground`}),(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,z.jsxs)(`a`,{href:`https://app.cline.bot/onboarding?step=1`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,z.jsx)(De,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-4 py-3 transition-colors hover:bg-accent/20`,children:[(0,z.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary text-sm font-bold text-foreground`,children:e.name.charAt(0)}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,z.jsx)(`span`,{className:`rounded-full bg-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]},e.organizationId))})]})]})]}),e===`usage`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:k?`Recent API usage and token consumption for ${k.name}.`:`Recent API usage and token consumption across all providers.`}),v&&_e(),b&&he(b,ce),!v&&!b&&S&&(ee.length===0?(0,z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Model`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:ee.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,z.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,z.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:fe(e.creditsUsed)}),(0,z.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{children:ue(e.createdAt)}),(0,z.jsx)(`p`,{children:de(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),te&&_e(),re&&he(re,le),!te&&!re&&O&&(T.length===0?(0,z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Date`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(xn,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:ue(e.paidAt)})]}),(0,z.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,z.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,fe(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var In=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Ln({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,R.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(!1),[l,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(null),g=(0,R.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),ee=n.includes(g),_=r.models.length>0,v=r.modelsSourceUrl.trim().length>0,y=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(_||v)&&!ee,b=e=>{if((e.key===`Enter`||e.key===`,`)&&a.trim()){e.preventDefault();let t=a.trim().replace(/,/g,``);t&&!r.models.includes(t)&&i(e=>({...e,models:[...e.models,t],defaultModel:e.defaultModel||t})),o(``)}else e.key===`Backspace`&&!a&&r.models.length>0&&i(e=>({...e,models:e.models.slice(0,-1)}))},x=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},S=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},C=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},w=(e,t,n)=>{let a=Object.entries(r.headers),o={};a.forEach(([e,r],i)=>{o[i===n?t:e]=r}),e!==t&&delete o[e],i(e=>({...e,headers:o}))},T=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},E=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},te=async()=>{if(!(!y||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,z.jsxs)(Wt,{contentClassName:`max-w-4xl`,children:[(0,z.jsx)(L,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,z.jsxs)(j,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,z.jsx)(cn,{className:`h-4 w-4`}),`Providers`]})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,z.jsx)(`input`,{type:`text`,value:r.providerId,onChange:e=>i(t=>({...t,providerId:e.target.value})),placeholder:`my-provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),ee?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,z.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`My Provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]})]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,z.jsx)(`input`,{type:`url`,value:r.baseUrl,onChange:e=>i(t=>({...t,baseUrl:e.target.value})),placeholder:`https://api.example.com/v1`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,z.jsx)(`input`,{type:`url`,value:r.modelsSourceUrl,onChange:e=>i(t=>({...t,modelsSourceUrl:e.target.value})),placeholder:`https://api.example.com/v1/models`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:"Supported JSON: OpenAI `/models` shape with a `data` array, or a direct model array."})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,z.jsxs)(`div`,{className:`flex min-h-11 flex-wrap content-start gap-1.5 rounded-lg border border-border bg-input px-3 py-2 focus-within:ring-1 focus-within:ring-ring`,children:[r.models.map(e=>(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e}),(0,z.jsx)(j,{onClick:()=>x(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,z.jsx)(He,{className:`h-3 w-3`})})]},e)),(0,z.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:b,placeholder:r.models.length===0?`Type model ID and press Enter`:``,className:`min-w-35 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none`})]}),(0,z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Add at least one model or set a Model Source URL.`})]}),r.models.length>1?(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,z.jsx)(`select`,{value:r.defaultModel,onChange:e=>i(t=>({...t,defaultModel:e.target.value})),className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,children:r.models.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`input`,{type:s?`text`:`password`,value:r.apiKey,onChange:e=>i(t=>({...t,apiKey:e.target.value})),placeholder:`sk-...`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 pr-20 font-mono text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,z.jsx)(j,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,z.jsx)(mn,{className:`h-4 w-4`}):(0,z.jsx)(hn,{className:`h-4 w-4`})}),(0,z.jsx)(j,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,z.jsx)(Ae,{className:`h-4 w-4`})})]})]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:In.map(e=>(0,z.jsx)(j,{onClick:()=>S(e),className:u(`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all`,r.capabilities.includes(e)?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-card text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:e.replace(/-/g,` `)},e))})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,z.jsxs)(j,{onClick:()=>d(!l),className:`flex w-full items-center justify-between px-5 py-4 text-sm font-medium transition-colors text-foreground/40`,variant:`ghost`,children:[`Advanced Settings`,(0,z.jsx)(Ee,{className:u(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,z.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,z.jsx)(`input`,{type:`number`,value:r.timeoutMs,onChange:e=>i(t=>({...t,timeoutMs:e.target.value})),placeholder:`30000`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`text`,value:e,onChange:t=>w(e,t.target.value,n),placeholder:`Header name`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(`input`,{type:`text`,value:t,onChange:t=>T(e,t.target.value),placeholder:`Value`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(j,{onClick:()=>E(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,z.jsx)(ve,{className:`h-4 w-4`})})]},e)),(0,z.jsxs)(j,{onClick:C,className:`flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,z.jsx)(De,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,z.jsx)(j,{onClick:e,className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:`Cancel`}),(0,z.jsx)(j,{onClick:()=>void te(),disabled:!y||f,className:u(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,y&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function Rn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function zn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Bn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Vn(e){let t=e.label.toLowerCase(),n=`flag`in e?e.flag.toLowerCase():e.key.toLowerCase();return t.includes(`token`)||t.includes(`secret`)||t.includes(`key`)||n.includes(`token`)||n.includes(`secret`)||n.includes(`key`)}function Hn(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Un(e,t){let n=e.includeWhen;if(!n)return!0;let r=t[n.flag]??``;return!(n.equals!==void 0&&r!==n.equals||n.notEquals!==void 0&&r===n.notEquals)}function Wn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Gn(e){let t=e[0];return{channelId:t?.id??``,values:Wn(t),securityEnabled:!1,securityValues:{}}}function Kn(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)([]),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,R.useState)(null),[ee,_]=(0,R.useState)(null),v=(0,R.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),y=(0,R.useMemo)(()=>{let e={...Wn(v),...p.values};return(v?.fields??[]).filter(t=>Un(t,e))},[v,p.values]),b=(0,R.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:Gn(e.available))},[]),x=(0,R.useCallback)(async()=>{a(!0),l(null);try{let e=await N.invoke(`list_connector_channels`);b(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[b]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=()=>{m(Gn(e)),g(null),f(!0)},C=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},w=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},T=async()=>{if(!v){g(`Choose a channel`);return}for(let e of v.fields)if(y.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&v.security){for(let e of v.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(v.id),g(null),l(null);try{let e=await N.invoke(`start_connector_channel`,{channel:v.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}});b(e),f(!1)}catch(e){let t=e instanceof Error?e.message:String(e);g(t)}finally{s(null)}},E=async e=>{s(e.type),l(null);try{let t=await N.invoke(`stop_connector_channel`,{channel:e.type});b(t),_(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,z.jsxs)(Wt,{children:[(0,z.jsx)(L,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,z.jsx)(Rt,{children:`cline connect`}),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(j,{disabled:i,onClick:()=>void x(),size:`sm`,type:`button`,variant:`outline`,children:(0,z.jsx)(tt,{className:u(`size-4`,i&&`animate-spin`)})}),(0,z.jsxs)(j,{disabled:e.length===0,onClick:S,size:`sm`,type:`button`,children:[(0,z.jsx)(De,{className:`size-4`}),`Add Channel`]})]})}),c?(0,z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:c}):null,i?(0,z.jsx)(Tt,{children:`Loading channels...`}):n.length===0?(0,z.jsx)(Tt,{children:`No channels connected.`}):(0,z.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,z.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,z.jsxs)(`div`,{className:`grid gap-3 border bg-[color-mix(in_oklch,var(--background)_70%,var(--card))] p-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Te,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,z.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:Rn(t,e)}),(0,z.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:zn(t)})]}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,z.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.hubUrl,children:t.hubUrl}),t.baseUrl?(0,z.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.baseUrl,children:t.baseUrl}):null,(0,z.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Bn(t.startedAt)}),t.connectionMode?(0,z.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,z.jsxs)(j,{disabled:o===t.type,onClick:()=>_(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,z.jsx)(ve,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,z.jsx)(Ie,{open:d,onOpenChange:f,children:(0,z.jsxs)(We,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,z.jsxs)(Re,{children:[(0,z.jsx)(Ke,{children:`Add Channel`}),(0,z.jsx)(Ye,{children:`Start a connector channel for Cline Hub.`})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{children:`Channel`}),(0,z.jsxs)(Be,{onValueChange:t=>{t&&m({channelId:t,values:Wn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,z.jsx)(Xe,{children:(0,z.jsx)($e,{placeholder:`Select channel`})}),(0,z.jsx)(ze,{children:e.map(e=>(0,z.jsx)(Ne,{value:e.id,children:e.name},e.id))})]})]}),y.map(e=>(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(M,{children:[e.label,e.required?(0,z.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,z.jsxs)(Be,{onValueChange:t=>{t&&C(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,z.jsx)(Xe,{children:(0,z.jsx)($e,{placeholder:e.placeholder})}),(0,z.jsx)(ze,{children:e.options.map(e=>(0,z.jsx)(Ne,{value:e.value,children:e.label},e.value))})]}):Hn(e)?(0,z.jsx)(Je,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,z.jsx)(O,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,type:Vn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),v?.security?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(M,{className:`text-sm`,children:`Restrict access`}),(0,z.jsx)(ct,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?v.security.fields.map(e=>(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{children:e.label}),(0,z.jsx)(O,{onChange:t=>w(e.key,t.target.value),placeholder:e.placeholder,type:Vn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,z.jsxs)(Le,{children:[(0,z.jsx)(j,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,z.jsx)(j,{disabled:o!==null||!v,onClick:()=>void T(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,z.jsx)(Ft,{open:ee!==null,onOpenChange:e=>{e||_(null)},children:(0,z.jsxs)(an,{children:[(0,z.jsxs)(yt,{children:[(0,z.jsx)(dt,{children:`Remove Channel`}),(0,z.jsxs)(P,{children:[`Confirm that you want to stop the active`,` `,ee?Rn(ee,e):`channel`,` `,`channel for `,ee?zn(ee):``,`.`]})]}),(0,z.jsxs)(nn,{children:[(0,z.jsx)(Qt,{disabled:o!==null,children:`Cancel`}),(0,z.jsx)(wt,{disabled:o!==null||!ee,onClick:()=>{ee&&E(ee)},variant:`destructive`,children:`Remove`})]})]})})]})}function qn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Jn(e){let t=qn(e);if(t.length===0)return;let n={};for(let e of t){let t=e.indexOf(`=`);if(t<=0)continue;let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();r&&(n[r]=i)}return Object.keys(n).length>0?n:void 0}function Yn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function Xn(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Zn(e){return!e||Object.keys(e).length===0?[{id:crypto.randomUUID(),key:``,value:``}]:Object.entries(e).map(([e,t])=>({id:crypto.randomUUID(),key:e,value:t}))}function Qn(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Zn(e?.env),url:e?.url??``,headersText:Yn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function $n(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)(``),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(!0),[c,l]=(0,R.useState)(!1),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(!1),[ee,_]=(0,R.useState)(`create`),[v,y]=(0,R.useState)(()=>Qn()),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(null),w=(0,R.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),T=(0,R.useCallback)(async()=>{s(!0),f(null);try{let e=await N.invoke(`list_mcp_servers`);w(e)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{s(!1)}},[w]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{T()},0);return()=>window.clearTimeout(e)},[T]);let E=async(e,t)=>{m(e.name),f(null);try{let n=await N.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});w(n)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},te=async e=>{m(e.previousName??e.name),f(null);try{let t=await N.invoke(`upsert_mcp_server`,{input:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw f(t),e}finally{m(null)}},ne=async e=>{m(e),f(null);try{let t=await N.invoke(`delete_mcp_server`,{name:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},re=(0,R.useCallback)(e=>{let t=e.name.trim();if(!t)throw Error(`Server name is required.`);let n=e.envEntries.reduce((e,t)=>{let n=t.key.trim();return n&&(e[n]=t.value),e},{}),r=e.metadataText.trim(),i=r.length>0?JSON.parse(r):void 0;if(e.transportType===`stdio`){let r=e.command.trim();if(!r)throw Error(`Command is required for stdio transport.`);let a=qn(e.argsText);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,command:r,args:a.length>0?a:void 0,cwd:e.cwd.trim()||void 0,env:Object.keys(n).length>0?n:void 0,disabled:e.disabled,metadata:i}}let a=e.url.trim();if(!a)throw Error(`URL is required for sse and streamableHttp transport.`);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,url:a,headers:Jn(e.headersText),disabled:e.disabled,metadata:i}},[]),D=()=>{_(`create`),y(Qn()),x(null),g(!0)},ie=e=>{_(`edit`),y(Qn(e)),x(null),g(!0)},k=async()=>{x(null);try{let e=re(v);await te(e),g(!1)}catch(e){x(e instanceof Error?e.message:String(e))}},A=async()=>{l(!0),f(null);try{let e=await N.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},ae=(0,R.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),oe=(e,t,n)=>{y(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},se=()=>{y(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},ce=e=>{y(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,z.jsxs)(Wt,{children:[(0,z.jsx)(L,{description:i?`Editing this list updates cline_mcp_settings.json.`:`No MCP settings file found yet. Add a server to create it.`,title:`MCP Servers`,meta:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Rt,{children:`cline config mcp`}),(0,z.jsx)(`span`,{className:`rounded-md border border-border bg-background px-2 py-0.5 text-xs text-muted-foreground`,children:`From settings file`})]}),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:o,children:(0,z.jsx)(tt,{className:u(`h-4 w-4`,o&&`animate-spin`)})}),(0,z.jsxs)(j,{size:`sm`,onClick:D,children:[(0,z.jsx)(De,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,z.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`MCP settings path:`}),(0,z.jsx)(j,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void A(),disabled:c,children:n||`Open settings file`})]}),d&&(0,z.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):ae.length===0?(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:ae.map(e=>{let t=p===e.name;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(Te,{className:u(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,z.jsx)(`div`,{className:`flex-1`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ie(e),disabled:t,children:(0,z.jsx)(sn,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>C(e),disabled:t,children:(0,z.jsx)(ve,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(ct,{checked:!e.disabled,onCheckedChange:t=>E(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,z.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,Xn(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Yn(e.headers)]})]})]},e.name)})}),(0,z.jsx)(Ie,{open:h,onOpenChange:e=>{g(e),e||x(null)},children:(0,z.jsxs)(We,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,z.jsxs)(Re,{children:[(0,z.jsx)(Ke,{children:ee===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,z.jsxs)(Ye,{children:[`Update the MCP server stored in`,` `,(0,z.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-name`,children:`Server name`}),(0,z.jsx)(O,{id:`mcp-name`,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{children:`Transport type`}),(0,z.jsxs)(Be,{value:v.transportType,onValueChange:e=>y(t=>({...t,transportType:e})),children:[(0,z.jsx)(Xe,{className:`w-full`,children:(0,z.jsx)($e,{placeholder:`Select transport`})}),(0,z.jsxs)(ze,{children:[(0,z.jsx)(Ne,{value:`stdio`,children:`stdio`}),(0,z.jsx)(Ne,{value:`sse`,children:`sse`}),(0,z.jsx)(Ne,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),v.transportType===`stdio`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-command`,children:`Command`}),(0,z.jsx)(O,{id:`mcp-command`,value:v.command,onChange:e=>y(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-args`,children:`Args`}),(0,z.jsx)(Je,{id:`mcp-args`,value:v.argsText,onChange:e=>y(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,z.jsx)(O,{id:`mcp-cwd`,value:v.cwd,onChange:e=>y(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(M,{children:`Environment variables`}),(0,z.jsx)(j,{type:`button`,variant:`ghost`,size:`sm`,onClick:se,children:(0,z.jsx)(De,{className:`h-3.5 w-3.5`})})]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:v.envEntries.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(j,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>ce(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,z.jsx)(yn,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(O,{value:e.key,onChange:t=>oe(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,z.jsx)(O,{type:`password`,value:e.value,onChange:t=>oe(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-url`,children:`Server URL`}),(0,z.jsx)(O,{id:`mcp-url`,value:v.url,onChange:e=>y(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-headers`,children:`Headers`}),(0,z.jsx)(Je,{id:`mcp-headers`,value:v.headersText,onChange:e=>y(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,z.jsx)(Je,{id:`mcp-metadata`,value:v.metadataText,onChange:e=>y(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,z.jsx)(ct,{checked:!v.disabled,onCheckedChange:e=>y(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),b?(0,z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null]}),(0,z.jsxs)(Le,{children:[(0,z.jsx)(j,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,z.jsx)(j,{onClick:()=>void k(),disabled:p!==null,children:p===null?ee===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,z.jsx)(Ft,{open:S!==null,onOpenChange:e=>{e||C(null)},children:(0,z.jsxs)(an,{children:[(0,z.jsxs)(yt,{children:[(0,z.jsx)(dt,{children:`Delete MCP Server`}),(0,z.jsx)(P,{children:S?`Delete MCP server "${S.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,z.jsxs)(nn,{children:[(0,z.jsx)(Qt,{disabled:p!==null,children:`Cancel`}),(0,z.jsx)(wt,{disabled:p!==null||!S,onClick:()=>{S&&(ne(S.name),C(null))},children:`Delete`})]})]})})]})}function er(e){let t={...e.configValues??{}};e.apiKey!==void 0&&t.apiKey===void 0&&(t.apiKey=e.apiKey),e.baseUrl!==void 0&&t.baseUrl===void 0&&(t.baseUrl=e.baseUrl);for(let n of e.configFields??[])t[n.path]===void 0&&n.defaultValue!==void 0&&(t[n.path]=n.defaultValue);return t}function tr(e){return e==null?``:String(e)}function nr(e,t){if(e.type===`boolean`)return!!t;if(typeof t==`boolean`)return t;if(e.type===`select`){let n=e.options?.find(e=>String(e.value)===t);if(n)return n.value}let n=t.trim();if(n.length===0)return null;if(e.type===`number`){let e=Number(n);return Number.isFinite(e)?e:null}return n}function rr({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),d=e.filter(e=>e.enabled).length,f=c.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e,m=a===`panel`;return(0,z.jsx)(Ot,{className:`h-full`,children:(0,z.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,z.jsxs)(`div`,{className:u(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,z.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,z.jsx)(j,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,z.jsx)(st,{className:`size-4`})}),(0,z.jsxs)(j,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,z.jsx)(fn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,z.jsx)(`div`,{className:u(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,z.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,z.jsx)(st,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(O,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>l(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,z.jsxs)(`div`,{className:u(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,z.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,z.jsxs)(`div`,{className:u(`flex min-h-11 items-center gap-4 border-b px-2 py-2 transition-colors hover:bg-accent/30`,i===e.id&&`bg-accent/45`),children:[(0,z.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:[(0,z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,z.jsx)(`p`,{className:`shrink-0 text-[15px] text-muted-foreground`,children:e.models===null?`Models load on demand`:`${e.models} model${e.models===1?``:`s`}`})]}),(0,z.jsx)(ct,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,z.jsx)(`button`,{"aria-label":`Configure ${e.name}`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:(0,z.jsx)(un,{className:`size-4`})})]},e.id))]})]})})}function ir({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,d]=(0,R.useState)({}),[f,p]=(0,R.useState)(()=>er(e)),[m,h]=(0,R.useState)(null),[g,ee]=(0,R.useState)(null),_=(0,R.useRef)(void 0),v=e.configFields??[],y=tr(f.apiKey),b=e.modelList??[],x=m?.providerId===e.id?m.value:``,S=g?.providerId===e.id?g.modelId:null,C=x.trim().toLowerCase(),w=C?b.filter(e=>e.name.toLowerCase().includes(C)||e.id.toLowerCase().includes(C)):b,T=c===`panel`;(0,R.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=nr(e,t),i={...f,[e.path]:r};p(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=tr(r)),e.path===`baseUrl`&&(a.baseUrl=tr(r)),n(a)},te=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{ee({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>ee(null),1600)})};return(0,z.jsx)(Ot,{className:`h-full`,children:(0,z.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,z.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,z.jsx)(j,{"aria-label":T?`Close provider details`:`Back to providers`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,onClick:t,variant:`ghost`,children:T?(0,z.jsx)(He,{className:`h-4 w-4`}):(0,z.jsx)(cn,{className:`h-4 w-4`})}),(0,z.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,z.jsx)(`section`,{className:u(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,z.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=f[e.path],n=tr(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,z.jsxs)(`div`,{className:`grid min-h-18 grid-cols-[minmax(12rem,0.55fr)_minmax(16rem,0.45fr)] items-center gap-6 border-b py-4 max-[900px]:grid-cols-1 max-[900px]:gap-3`,children:[(0,z.jsxs)(`header`,{children:[(0,z.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,z.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,z.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,z.jsx)(ct,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,z.jsxs)(`select`,{className:`h-9 w-full rounded border border-border bg-background px-3 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,onChange:t=>E(e,t.target.value),value:n,children:[(0,z.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,z.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,z.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,z.jsx)(ut,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,z.jsx)(O,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>E(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(j,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,z.jsx)(mn,{className:`h-4 w-4`}):(0,z.jsx)(hn,{className:`h-4 w-4`})}),(0,z.jsx)(j,{"aria-label":`Copy ${e.label}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>navigator.clipboard.writeText(n),variant:`ghost`,children:(0,z.jsx)(Ae,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,z.jsx)(`div`,{className:`mb-8`,children:(0,z.jsxs)(j,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,z.jsx)(it,{className:`h-4 w-4 animate-spin`}):null,(0,z.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,z.jsx)(`p`,{className:`mb-8 text-xs text-muted-foreground`,children:`OAuth is connected. Manual credentials remain available when this provider supports them.`}):null,(0,z.jsxs)(`section`,{className:u(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,z.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,z.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(st,{className:`size-4 text-muted-foreground`}),(0,z.jsx)(j,{"aria-label":`Refresh models`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,disabled:i,onClick:r,variant:`ghost`,children:(0,z.jsx)(tt,{className:u(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,z.jsx)(st,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(O,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,z.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,z.jsxs)(`div`,{className:`group flex min-h-16 items-center gap-3 border-b px-4 py-3 transition-colors hover:bg-accent/30`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,z.jsx)(`div`,{title:`File Support`,children:(0,z.jsx)(gn,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,z.jsx)(`div`,{title:`Image Support`,children:(0,z.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,z.jsxs)(`button`,{"aria-label":`Copy model ID ${e.id}`,className:`mt-1 flex max-w-full items-center gap-1.5 px-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>te(e.id),title:`Copy model ID`,type:`button`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,z.jsx)(Ae,{className:`size-3 shrink-0`}),S===e.id?(0,z.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,z.jsx)(j,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,z.jsx)(rt,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var ar,or=Object.freeze({status:`aborted`});function B(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var sr=Symbol(`zod_brand`),cr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},lr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ar=globalThis).__zod_globalConfig??(ar.__zod_globalConfig={});var ur=globalThis.__zod_globalConfig;function dr(e){return e&&Object.assign(ur,e),ur}var fr=t({BIGINT_FORMAT_RANGES:()=>Jr,Class:()=>_i,NUMBER_FORMAT_RANGES:()=>qr,aborted:()=>ni,allowsEval:()=>Ir,assert:()=>_r,assertEqual:()=>pr,assertIs:()=>hr,assertNever:()=>gr,assertNotEqual:()=>mr,assignProp:()=>Er,base64ToUint8Array:()=>di,base64urlToUint8Array:()=>pi,cached:()=>br,captureStackTrace:()=>Pr,cleanEnum:()=>ui,cleanRegex:()=>Sr,clone:()=>Wr,cloneDef:()=>Or,createTransparentProxy:()=>Gr,defineLazy:()=>H,esc:()=>Mr,escapeRegex:()=>Ur,explicitlyAborted:()=>ri,extend:()=>Zr,finalizeIssue:()=>oi,floatSafeRemainder:()=>Cr,getElementAtPath:()=>kr,getEnumValues:()=>vr,getLengthableOrigin:()=>ci,getParsedType:()=>Br,getSizableOrigin:()=>si,hexToUint8Array:()=>hi,isObject:()=>Fr,isPlainObject:()=>Lr,issue:()=>li,joinValues:()=>V,jsonStringifyReplacer:()=>yr,merge:()=>$r,mergeDefs:()=>Dr,normalizeParams:()=>U,nullish:()=>xr,numKeys:()=>zr,objectClone:()=>Tr,omit:()=>Xr,optionalKeys:()=>Kr,parsedType:()=>G,partial:()=>ei,pick:()=>Yr,prefixIssues:()=>ii,primitiveTypes:()=>Hr,promiseAllObject:()=>Ar,propertyKeyTypes:()=>Vr,randomString:()=>jr,required:()=>ti,safeExtend:()=>Qr,shallowClone:()=>Rr,slugify:()=>Nr,stringifyPrimitive:()=>W,uint8ArrayToBase64:()=>fi,uint8ArrayToBase64url:()=>mi,uint8ArrayToHex:()=>gi,unwrapMessage:()=>ai});function pr(e){return e}function mr(e){return e}function hr(e){}function gr(e){throw Error(`Unexpected value in exhaustive check`)}function _r(e){}function vr(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function V(e,t=`|`){return e.map(e=>W(e)).join(t)}function yr(e,t){return typeof t==`bigint`?t.toString():t}function br(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function xr(e){return e==null}function Sr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Cr(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var wr=Symbol(`evaluating`);function H(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==wr)return r===void 0&&(r=wr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Tr(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Er(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Dr(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Or(e){return Dr(e._zod.def)}function kr(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function Ar(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function jr(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Mr(e){return JSON.stringify(e)}function Nr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Pr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Fr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ir=br(()=>{if(ur.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Lr(e){if(Fr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Fr(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Rr(e){return Lr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function zr(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Br=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Vr=new Set([`string`,`number`,`symbol`]),Hr=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Ur(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Wr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function U(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Gr(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function W(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Kr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var qr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Jr={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Yr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Wr(e,Dr(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Er(this,`shape`,e),e},checks:[]}))}function Xr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Wr(e,Dr(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Er(this,`shape`,r),r},checks:[]}))}function Zr(e,t){if(!Lr(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Wr(e,Dr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Er(this,`shape`,n),n}}))}function Qr(e,t){if(!Lr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Wr(e,Dr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Er(this,`shape`,n),n}}))}function $r(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Wr(e,Dr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Er(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ei(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Wr(t,Dr(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Er(this,`shape`,i),i},checks:[]}))}function ti(e,t,n){return Wr(t,Dr(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Er(this,`shape`,i),i}}))}function ni(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ri(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ii(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ai(e){return typeof e==`string`?e:e?.message}function oi(e,t,n){let r=e.message?e.message:ai(e.inst?._zod.def?.error?.(e))??ai(t?.error?.(e))??ai(n.customError?.(e))??ai(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function si(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function ci(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function G(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function li(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function ui(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function di(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function fi(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function pi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return di(t+`=`.repeat((4-t.length%4)%4))}function mi(e){return fi(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function hi(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function gi(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var _i=class{constructor(...e){}},vi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,yr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},yi=B(`$ZodError`,vi),bi=B(`$ZodError`,vi,{Parent:Error});function xi(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Si(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function Ci(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if(s.code===`invalid_key`)r({issues:s.issues},[...i,...s.path]);else if(s.code===`invalid_element`)r({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function wi(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ti(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${wi(e.path)}`);return t.join(`
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{i as n,r}from"./bundle-mjs-D3mlU5Wg.js";import{t as i}from"./react-dom-Cmec2Q1Q.js";import{$ as a,A as o,B as s,Bt as c,D as l,E as u,F as d,Ht as f,I as p,K as m,L as h,Mt as g,O as ee,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as te,Y as ne,Z as re,_ as D,c as O,ct as ie,d as k,dt as A,et as ae,f as oe,ft as se,g as ce,h as le,k as ue,l as de,lt as fe,m as pe,p as me,st as he,u as ge,v as _e,w as ve,x as ye,xt as be,y as j}from"./vscode-DBs95Ixu.js";import{A as xe,C as Se,D as Ce,E as we,F as Te,I as Ee,M as De,N as Oe,O as ke,P as Ae,S as je,T as Me,_ as Ne,a as Pe,b as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,i as Ve,j as He,k as Ue,l as We,n as Ge,p as Ke,r as qe,s as Je,t as M,u as Ye,v as Xe,w as Ze,x as Qe,y as $e}from"./label-BwsGMt3P.js";import{a as et,i as tt,n as nt,r as rt,t as N}from"./desktop-client-B4hwKFvn.js";import{a as it,i as at,n as ot,r as st,t as ct}from"./switch-D32hLf2L.js";import{$ as lt,B as ut,C as dt,Ct as ft,G as pt,Mt as mt,Nt as ht,O as gt,Pt as _t,Q as vt,S as yt,Tt as bt,W as xt,X as St,Z as Ct,_ as wt,a as Tt,at as Et,b as P,bt as Dt,c as Ot,ct as kt,d as At,dt as jt,et as Mt,f as Nt,ft as Pt,g as Ft,gt as It,h as Lt,ht as F,i as Rt,it as zt,kt as Bt,m as Vt,mt as I,n as Ht,nt as Ut,o as Wt,ot as Gt,pt as Kt,r as qt,rt as Jt,s as L,t as Yt,tt as Xt,u as Zt,v as Qt,vt as $t,w as en,wt as tn,x as nn,xt as rn,y as an,yt as on,z as sn}from"./index-Be-mNsEe.js";var cn=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ln=S(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),un=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),dn=S(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),fn=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),pn=S(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),mn=S(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),hn=S(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),gn=S(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),_n=S(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),vn=S(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),yn=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),bn=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),xn=S(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),R=e(n(),1),Sn=R.createContext({disabled:!1});function Cn(){return R.useContext(Sn)}var wn=R.createContext(void 0);function Tn(e=!0){let t=R.useContext(wn);if(t===void 0&&!e)throw Error(c(3));return t}var z=r();function En(e){let t=e instanceof Error?e.message:String(e);return t.includes(`unsupported desktop command: cline_account`)?Error(`The desktop sidecar is running an older build that does not support account commands. Restart the sidecar or reload the app, then try again.`):e instanceof Error?e:Error(t)}function Dn(e){let t=e.toLowerCase();return t.includes(`no cline account auth token found`)||t.includes(`requires re-authentication`)||t.includes(`auth token`)||t.includes(`unauthorized`)}async function On(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function kn(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function An(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function jn(e){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Mn(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Nn(e,t){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function Pn(){return await N.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function Fn(){let[e,t]=(0,R.useState)(`overview`),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)([]),[p,m]=(0,R.useState)(!0),[h,g]=(0,R.useState)(null),[ee,_]=(0,R.useState)([]),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1),w=(0,R.useRef)(0),[T,E]=(0,R.useState)([]),[te,ne]=(0,R.useState)(!1),[re,D]=(0,R.useState)(null),[O,ie]=(0,R.useState)(!1),k=d.find(e=>e.active)??null,A=(0,R.useCallback)(()=>{a(null),s(null),l(null),f([]),_([]),C(!1),x(null),E([]),ie(!1),D(null)},[]),ae=(0,R.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([On(),kn(),An()]),r=n.find(e=>e.active)??null,i=r?await jn(r.organizationId):null;a(e),s(t),l(i),f(n)}catch(e){A();let t=En(e).message;g(t)}finally{m(!1)}},[A]);(0,R.useEffect)(()=>{ae()},[ae]);let oe=async()=>{r(`sign-in`),g(null);try{await N.invoke(`run_provider_oauth_login`,{provider:`cline`}),await ae(),t(`overview`)}catch(e){let t=En(e).message;g(t),A()}finally{r(null)}},se=async()=>{r(`sign-out`);try{await N.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),A(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=En(e).message;g(t)}finally{r(null)}},ce=(0,R.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=k?await Nn(k.organizationId,k.memberId):await Mn();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=En(t).message;x(n)}finally{w.current===e&&y(!1)}},[k]);(0,R.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[k?.organizationId]),(0,R.useEffect)(()=>{e===`usage`&&!S&&ce()},[e,S,ce]);let le=(0,R.useCallback)(async()=>{ne(!0),D(null);try{let e=await Pn();E(e),ie(!0)}catch(e){let t=En(e).message;D(t)}finally{ne(!1)}},[]);(0,R.useEffect)(()=>{e===`billing`&&!O&&le()},[e,O,le]);let ue=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),de=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),fe=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),pe=k?c?.balance??o?.balance??null:o?.balance??null,me=[`overview`,`usage`,`billing`],he=(e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,z.jsx)(dn,{className:`h-8 w-8 text-destructive`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 rounded-lg border border-border px-3.5 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,z.jsx)(tt,{className:`h-4 w-4`}),`Retry`]})]}),ge=()=>(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,z.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,z.jsx)(xt,{className:`h-6 w-6`})}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Connect your Cline account to review credits, usage, billing, and organization details from Cline Hub.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,z.jsxs)(j,{disabled:n!==null,onClick:()=>void oe(),type:`button`,children:[n===`sign-in`?(0,z.jsx)(it,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(_n,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,z.jsxs)(`a`,{className:`inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,href:`https://app.cline.bot`,rel:`noopener noreferrer`,target:`_blank`,children:[`Create account`,(0,z.jsx)(et,{className:`h-4 w-4`})]})]})]})}),_e=()=>(0,z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,z.jsx)(it,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,z.jsxs)(Wt,{children:[(0,z.jsx)(L,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,z.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:me.map(n=>{let r=!i&&n!==`overview`;return(0,z.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:u(`relative px-4 py-2.5 text-sm font-medium capitalize transition-colors`,e===n?`text-foreground`:`text-muted-foreground hover:text-foreground`,r&&`cursor-not-allowed opacity-45 hover:text-muted-foreground`),children:[n,e===n&&(0,z.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&_e(),h&&(Dn(h)?ge():he(h,ae)),!p&&!h&&i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,z.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-primary/20 text-2xl font-bold text-primary`,children:i.displayName?.charAt(0)??i.email?.charAt(0)??`?`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,z.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,ue(i.createdAt)]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,z.jsxs)(`a`,{href:`https://app.cline.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[`Open dashboard`,(0,z.jsx)(et,{className:`h-3.5 w-3.5`})]}),(0,z.jsxs)(j,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void se(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,z.jsx)(it,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(vn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),pe!==null&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(pn,{className:`h-5 w-5 text-primary`}),(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:k?`${k.name} Balance`:`Credits Balance`})]}),(0,z.jsxs)(`a`,{href:`https://app.cline.bot/dashboard/organization?tab=credits&redirect=true`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,z.jsx)(De,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,z.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,z.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,fe(pe)]})}),k&&o&&(0,z.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,fe(o.balance),` `,`credits`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(ln,{className:`h-5 w-5 text-muted-foreground`}),(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,z.jsxs)(`a`,{href:`https://app.cline.bot/onboarding?step=1`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,z.jsx)(De,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-4 py-3 transition-colors hover:bg-accent/20`,children:[(0,z.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary text-sm font-bold text-foreground`,children:e.name.charAt(0)}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,z.jsx)(`span`,{className:`rounded-full bg-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]},e.organizationId))})]})]})]}),e===`usage`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:k?`Recent API usage and token consumption for ${k.name}.`:`Recent API usage and token consumption across all providers.`}),v&&_e(),b&&he(b,ce),!v&&!b&&S&&(ee.length===0?(0,z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Model`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:ee.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,z.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,z.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:fe(e.creditsUsed)}),(0,z.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{children:ue(e.createdAt)}),(0,z.jsx)(`p`,{children:de(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),te&&_e(),re&&he(re,le),!te&&!re&&O&&(T.length===0?(0,z.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Date`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,z.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(xn,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:ue(e.paidAt)})]}),(0,z.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,z.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,fe(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var In=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Ln({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,R.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(!1),[l,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(null),g=(0,R.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),ee=n.includes(g),_=r.models.length>0,v=r.modelsSourceUrl.trim().length>0,y=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(_||v)&&!ee,b=e=>{if((e.key===`Enter`||e.key===`,`)&&a.trim()){e.preventDefault();let t=a.trim().replace(/,/g,``);t&&!r.models.includes(t)&&i(e=>({...e,models:[...e.models,t],defaultModel:e.defaultModel||t})),o(``)}else e.key===`Backspace`&&!a&&r.models.length>0&&i(e=>({...e,models:e.models.slice(0,-1)}))},x=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},S=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},C=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},w=(e,t,n)=>{let a=Object.entries(r.headers),o={};a.forEach(([e,r],i)=>{o[i===n?t:e]=r}),e!==t&&delete o[e],i(e=>({...e,headers:o}))},T=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},E=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},te=async()=>{if(!(!y||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,z.jsxs)(Wt,{contentClassName:`max-w-4xl`,children:[(0,z.jsx)(L,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,z.jsxs)(j,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,z.jsx)(cn,{className:`h-4 w-4`}),`Providers`]})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,z.jsx)(`input`,{type:`text`,value:r.providerId,onChange:e=>i(t=>({...t,providerId:e.target.value})),placeholder:`my-provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),ee?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,z.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`My Provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]})]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,z.jsx)(`input`,{type:`url`,value:r.baseUrl,onChange:e=>i(t=>({...t,baseUrl:e.target.value})),placeholder:`https://api.example.com/v1`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,z.jsx)(`input`,{type:`url`,value:r.modelsSourceUrl,onChange:e=>i(t=>({...t,modelsSourceUrl:e.target.value})),placeholder:`https://api.example.com/v1/models`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:"Supported JSON: OpenAI `/models` shape with a `data` array, or a direct model array."})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,z.jsxs)(`div`,{className:`flex min-h-11 flex-wrap content-start gap-1.5 rounded-lg border border-border bg-input px-3 py-2 focus-within:ring-1 focus-within:ring-ring`,children:[r.models.map(e=>(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e}),(0,z.jsx)(j,{onClick:()=>x(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,z.jsx)(He,{className:`h-3 w-3`})})]},e)),(0,z.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:b,placeholder:r.models.length===0?`Type model ID and press Enter`:``,className:`min-w-35 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none`})]}),(0,z.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Add at least one model or set a Model Source URL.`})]}),r.models.length>1?(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,z.jsx)(`select`,{value:r.defaultModel,onChange:e=>i(t=>({...t,defaultModel:e.target.value})),className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,children:r.models.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`input`,{type:s?`text`:`password`,value:r.apiKey,onChange:e=>i(t=>({...t,apiKey:e.target.value})),placeholder:`sk-...`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 pr-20 font-mono text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,z.jsx)(j,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,z.jsx)(mn,{className:`h-4 w-4`}):(0,z.jsx)(hn,{className:`h-4 w-4`})}),(0,z.jsx)(j,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,z.jsx)(Ae,{className:`h-4 w-4`})})]})]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,z.jsx)(M,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:In.map(e=>(0,z.jsx)(j,{onClick:()=>S(e),className:u(`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all`,r.capabilities.includes(e)?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-card text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:e.replace(/-/g,` `)},e))})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,z.jsxs)(j,{onClick:()=>d(!l),className:`flex w-full items-center justify-between px-5 py-4 text-sm font-medium transition-colors text-foreground/40`,variant:`ghost`,children:[`Advanced Settings`,(0,z.jsx)(Ee,{className:u(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,z.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,z.jsx)(`input`,{type:`number`,value:r.timeoutMs,onChange:e=>i(t=>({...t,timeoutMs:e.target.value})),placeholder:`30000`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(M,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`text`,value:e,onChange:t=>w(e,t.target.value,n),placeholder:`Header name`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(`input`,{type:`text`,value:t,onChange:t=>T(e,t.target.value),placeholder:`Value`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,z.jsx)(j,{onClick:()=>E(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,z.jsx)(ve,{className:`h-4 w-4`})})]},e)),(0,z.jsxs)(j,{onClick:C,className:`flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,z.jsx)(De,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,z.jsx)(j,{onClick:e,className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:`Cancel`}),(0,z.jsx)(j,{onClick:()=>void te(),disabled:!y||f,className:u(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,y&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function Rn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function zn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Bn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Vn(e){let t=e.label.toLowerCase(),n=`flag`in e?e.flag.toLowerCase():e.key.toLowerCase();return t.includes(`token`)||t.includes(`secret`)||t.includes(`key`)||n.includes(`token`)||n.includes(`secret`)||n.includes(`key`)}function Hn(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Un(e,t){let n=e.includeWhen;if(!n)return!0;let r=t[n.flag]??``;return!(n.equals!==void 0&&r!==n.equals||n.notEquals!==void 0&&r===n.notEquals)}function Wn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Gn(e){let t=e[0];return{channelId:t?.id??``,values:Wn(t),securityEnabled:!1,securityValues:{}}}function Kn(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)([]),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,R.useState)(null),[ee,_]=(0,R.useState)(null),v=(0,R.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),y=(0,R.useMemo)(()=>{let e={...Wn(v),...p.values};return(v?.fields??[]).filter(t=>Un(t,e))},[v,p.values]),b=(0,R.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:Gn(e.available))},[]),x=(0,R.useCallback)(async()=>{a(!0),l(null);try{let e=await N.invoke(`list_connector_channels`);b(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[b]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=()=>{m(Gn(e)),g(null),f(!0)},C=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},w=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},T=async()=>{if(!v){g(`Choose a channel`);return}for(let e of v.fields)if(y.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&v.security){for(let e of v.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(v.id),g(null),l(null);try{let e=await N.invoke(`start_connector_channel`,{channel:v.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}});b(e),f(!1)}catch(e){let t=e instanceof Error?e.message:String(e);g(t)}finally{s(null)}},E=async e=>{s(e.type),l(null);try{let t=await N.invoke(`stop_connector_channel`,{channel:e.type});b(t),_(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,z.jsxs)(Wt,{children:[(0,z.jsx)(L,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,z.jsx)(Rt,{children:`cline connect`}),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(j,{disabled:i,onClick:()=>void x(),size:`sm`,type:`button`,variant:`outline`,children:(0,z.jsx)(tt,{className:u(`size-4`,i&&`animate-spin`)})}),(0,z.jsxs)(j,{disabled:e.length===0,onClick:S,size:`sm`,type:`button`,children:[(0,z.jsx)(De,{className:`size-4`}),`Add Channel`]})]})}),c?(0,z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:c}):null,i?(0,z.jsx)(Tt,{children:`Loading channels...`}):n.length===0?(0,z.jsx)(Tt,{children:`No channels connected.`}):(0,z.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,z.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,z.jsxs)(`div`,{className:`grid gap-3 border bg-[color-mix(in_oklch,var(--background)_70%,var(--card))] p-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Te,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,z.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:Rn(t,e)}),(0,z.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:zn(t)})]}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,z.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.hubUrl,children:t.hubUrl}),t.baseUrl?(0,z.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.baseUrl,children:t.baseUrl}):null,(0,z.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Bn(t.startedAt)}),t.connectionMode?(0,z.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,z.jsxs)(j,{disabled:o===t.type,onClick:()=>_(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,z.jsx)(ve,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,z.jsx)(Ie,{open:d,onOpenChange:f,children:(0,z.jsxs)(We,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,z.jsxs)(Re,{children:[(0,z.jsx)(Ke,{children:`Add Channel`}),(0,z.jsx)(Ye,{children:`Start a connector channel for Cline Hub.`})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{children:`Channel`}),(0,z.jsxs)(Be,{onValueChange:t=>{t&&m({channelId:t,values:Wn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,z.jsx)(Xe,{children:(0,z.jsx)($e,{placeholder:`Select channel`})}),(0,z.jsx)(ze,{children:e.map(e=>(0,z.jsx)(Ne,{value:e.id,children:e.name},e.id))})]})]}),y.map(e=>(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(M,{children:[e.label,e.required?(0,z.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,z.jsxs)(Be,{onValueChange:t=>{t&&C(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,z.jsx)(Xe,{children:(0,z.jsx)($e,{placeholder:e.placeholder})}),(0,z.jsx)(ze,{children:e.options.map(e=>(0,z.jsx)(Ne,{value:e.value,children:e.label},e.value))})]}):Hn(e)?(0,z.jsx)(Je,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,z.jsx)(O,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,type:Vn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),v?.security?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(M,{className:`text-sm`,children:`Restrict access`}),(0,z.jsx)(ct,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?v.security.fields.map(e=>(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{children:e.label}),(0,z.jsx)(O,{onChange:t=>w(e.key,t.target.value),placeholder:e.placeholder,type:Vn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,z.jsxs)(Le,{children:[(0,z.jsx)(j,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,z.jsx)(j,{disabled:o!==null||!v,onClick:()=>void T(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,z.jsx)(Ft,{open:ee!==null,onOpenChange:e=>{e||_(null)},children:(0,z.jsxs)(an,{children:[(0,z.jsxs)(yt,{children:[(0,z.jsx)(dt,{children:`Remove Channel`}),(0,z.jsxs)(P,{children:[`Confirm that you want to stop the active`,` `,ee?Rn(ee,e):`channel`,` `,`channel for `,ee?zn(ee):``,`.`]})]}),(0,z.jsxs)(nn,{children:[(0,z.jsx)(Qt,{disabled:o!==null,children:`Cancel`}),(0,z.jsx)(wt,{disabled:o!==null||!ee,onClick:()=>{ee&&E(ee)},variant:`destructive`,children:`Remove`})]})]})})]})}function qn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Jn(e){let t=qn(e);if(t.length===0)return;let n={};for(let e of t){let t=e.indexOf(`=`);if(t<=0)continue;let r=e.slice(0,t).trim(),i=e.slice(t+1).trim();r&&(n[r]=i)}return Object.keys(n).length>0?n:void 0}function Yn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function Xn(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Zn(e){return!e||Object.keys(e).length===0?[{id:crypto.randomUUID(),key:``,value:``}]:Object.entries(e).map(([e,t])=>({id:crypto.randomUUID(),key:e,value:t}))}function Qn(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Zn(e?.env),url:e?.url??``,headersText:Yn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function $n(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)(``),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(!0),[c,l]=(0,R.useState)(!1),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(!1),[ee,_]=(0,R.useState)(`create`),[v,y]=(0,R.useState)(()=>Qn()),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(null),w=(0,R.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),T=(0,R.useCallback)(async()=>{s(!0),f(null);try{let e=await N.invoke(`list_mcp_servers`);w(e)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{s(!1)}},[w]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{T()},0);return()=>window.clearTimeout(e)},[T]);let E=async(e,t)=>{m(e.name),f(null);try{let n=await N.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});w(n)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},te=async e=>{m(e.previousName??e.name),f(null);try{let t=await N.invoke(`upsert_mcp_server`,{input:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw f(t),e}finally{m(null)}},ne=async e=>{m(e),f(null);try{let t=await N.invoke(`delete_mcp_server`,{name:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},re=(0,R.useCallback)(e=>{let t=e.name.trim();if(!t)throw Error(`Server name is required.`);let n=e.envEntries.reduce((e,t)=>{let n=t.key.trim();return n&&(e[n]=t.value),e},{}),r=e.metadataText.trim(),i=r.length>0?JSON.parse(r):void 0;if(e.transportType===`stdio`){let r=e.command.trim();if(!r)throw Error(`Command is required for stdio transport.`);let a=qn(e.argsText);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,command:r,args:a.length>0?a:void 0,cwd:e.cwd.trim()||void 0,env:Object.keys(n).length>0?n:void 0,disabled:e.disabled,metadata:i}}let a=e.url.trim();if(!a)throw Error(`URL is required for sse and streamableHttp transport.`);return{name:t,previousName:e.previousName.trim()||void 0,transportType:e.transportType,url:a,headers:Jn(e.headersText),disabled:e.disabled,metadata:i}},[]),D=()=>{_(`create`),y(Qn()),x(null),g(!0)},ie=e=>{_(`edit`),y(Qn(e)),x(null),g(!0)},k=async()=>{x(null);try{let e=re(v);await te(e),g(!1)}catch(e){x(e instanceof Error?e.message:String(e))}},A=async()=>{l(!0),f(null);try{let e=await N.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},ae=(0,R.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),oe=(e,t,n)=>{y(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},se=()=>{y(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},ce=e=>{y(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,z.jsxs)(Wt,{children:[(0,z.jsx)(L,{description:i?`Editing this list updates cline_mcp_settings.json.`:`No MCP settings file found yet. Add a server to create it.`,title:`MCP Servers`,meta:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Rt,{children:`cline config mcp`}),(0,z.jsx)(`span`,{className:`rounded-md border border-border bg-background px-2 py-0.5 text-xs text-muted-foreground`,children:`From settings file`})]}),actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:o,children:(0,z.jsx)(tt,{className:u(`h-4 w-4`,o&&`animate-spin`)})}),(0,z.jsxs)(j,{size:`sm`,onClick:D,children:[(0,z.jsx)(De,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,z.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`MCP settings path:`}),(0,z.jsx)(j,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void A(),disabled:c,children:n||`Open settings file`})]}),d&&(0,z.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):ae.length===0?(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:ae.map(e=>{let t=p===e.name;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(Te,{className:u(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,z.jsx)(`div`,{className:`flex-1`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ie(e),disabled:t,children:(0,z.jsx)(sn,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>C(e),disabled:t,children:(0,z.jsx)(ve,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(ct,{checked:!e.disabled,onCheckedChange:t=>E(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,z.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,Xn(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,z.jsxs)(`p`,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Yn(e.headers)]})]})]},e.name)})}),(0,z.jsx)(Ie,{open:h,onOpenChange:e=>{g(e),e||x(null)},children:(0,z.jsxs)(We,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,z.jsxs)(Re,{children:[(0,z.jsx)(Ke,{children:ee===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,z.jsxs)(Ye,{children:[`Update the MCP server stored in`,` `,(0,z.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-name`,children:`Server name`}),(0,z.jsx)(O,{id:`mcp-name`,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{children:`Transport type`}),(0,z.jsxs)(Be,{value:v.transportType,onValueChange:e=>y(t=>({...t,transportType:e})),children:[(0,z.jsx)(Xe,{className:`w-full`,children:(0,z.jsx)($e,{placeholder:`Select transport`})}),(0,z.jsxs)(ze,{children:[(0,z.jsx)(Ne,{value:`stdio`,children:`stdio`}),(0,z.jsx)(Ne,{value:`sse`,children:`sse`}),(0,z.jsx)(Ne,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),v.transportType===`stdio`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-command`,children:`Command`}),(0,z.jsx)(O,{id:`mcp-command`,value:v.command,onChange:e=>y(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-args`,children:`Args`}),(0,z.jsx)(Je,{id:`mcp-args`,value:v.argsText,onChange:e=>y(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,z.jsx)(O,{id:`mcp-cwd`,value:v.cwd,onChange:e=>y(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(M,{children:`Environment variables`}),(0,z.jsx)(j,{type:`button`,variant:`ghost`,size:`sm`,onClick:se,children:(0,z.jsx)(De,{className:`h-3.5 w-3.5`})})]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:v.envEntries.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(j,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>ce(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,z.jsx)(yn,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(O,{value:e.key,onChange:t=>oe(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,z.jsx)(O,{type:`password`,value:e.value,onChange:t=>oe(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-url`,children:`Server URL`}),(0,z.jsx)(O,{id:`mcp-url`,value:v.url,onChange:e=>y(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-headers`,children:`Headers`}),(0,z.jsx)(Je,{id:`mcp-headers`,value:v.headersText,onChange:e=>y(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(M,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,z.jsx)(Je,{id:`mcp-metadata`,value:v.metadataText,onChange:e=>y(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,z.jsx)(ct,{checked:!v.disabled,onCheckedChange:e=>y(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),b?(0,z.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null]}),(0,z.jsxs)(Le,{children:[(0,z.jsx)(j,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,z.jsx)(j,{onClick:()=>void k(),disabled:p!==null,children:p===null?ee===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,z.jsx)(Ft,{open:S!==null,onOpenChange:e=>{e||C(null)},children:(0,z.jsxs)(an,{children:[(0,z.jsxs)(yt,{children:[(0,z.jsx)(dt,{children:`Delete MCP Server`}),(0,z.jsx)(P,{children:S?`Delete MCP server "${S.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,z.jsxs)(nn,{children:[(0,z.jsx)(Qt,{disabled:p!==null,children:`Cancel`}),(0,z.jsx)(wt,{disabled:p!==null||!S,onClick:()=>{S&&(ne(S.name),C(null))},children:`Delete`})]})]})})]})}function er(e){let t={...e.configValues??{}};e.apiKey!==void 0&&t.apiKey===void 0&&(t.apiKey=e.apiKey),e.baseUrl!==void 0&&t.baseUrl===void 0&&(t.baseUrl=e.baseUrl);for(let n of e.configFields??[])t[n.path]===void 0&&n.defaultValue!==void 0&&(t[n.path]=n.defaultValue);return t}function tr(e){return e==null?``:String(e)}function nr(e,t){if(e.type===`boolean`)return!!t;if(typeof t==`boolean`)return t;if(e.type===`select`){let n=e.options?.find(e=>String(e.value)===t);if(n)return n.value}let n=t.trim();if(n.length===0)return null;if(e.type===`number`){let e=Number(n);return Number.isFinite(e)?e:null}return n}function rr({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),d=e.filter(e=>e.enabled).length,f=c.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e,m=a===`panel`;return(0,z.jsx)(Ot,{className:`h-full`,children:(0,z.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,z.jsxs)(`div`,{className:u(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,z.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,z.jsx)(j,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,z.jsx)(st,{className:`size-4`})}),(0,z.jsxs)(j,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,z.jsx)(fn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,z.jsx)(`div`,{className:u(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,z.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,z.jsx)(st,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(O,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>l(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,z.jsxs)(`div`,{className:u(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,z.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,z.jsxs)(`div`,{className:u(`flex min-h-11 items-center gap-4 border-b px-2 py-2 transition-colors hover:bg-accent/30`,i===e.id&&`bg-accent/45`),children:[(0,z.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:[(0,z.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,z.jsx)(`p`,{className:`shrink-0 text-[15px] text-muted-foreground`,children:e.models===null?`Models load on demand`:`${e.models} model${e.models===1?``:`s`}`})]}),(0,z.jsx)(ct,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,z.jsx)(`button`,{"aria-label":`Configure ${e.name}`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:(0,z.jsx)(un,{className:`size-4`})})]},e.id))]})]})})}function ir({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,d]=(0,R.useState)({}),[f,p]=(0,R.useState)(()=>er(e)),[m,h]=(0,R.useState)(null),[g,ee]=(0,R.useState)(null),_=(0,R.useRef)(void 0),v=e.configFields??[],y=tr(f.apiKey),b=e.modelList??[],x=m?.providerId===e.id?m.value:``,S=g?.providerId===e.id?g.modelId:null,C=x.trim().toLowerCase(),w=C?b.filter(e=>e.name.toLowerCase().includes(C)||e.id.toLowerCase().includes(C)):b,T=c===`panel`;(0,R.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=nr(e,t),i={...f,[e.path]:r};p(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=tr(r)),e.path===`baseUrl`&&(a.baseUrl=tr(r)),n(a)},te=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{ee({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>ee(null),1600)})};return(0,z.jsx)(Ot,{className:`h-full`,children:(0,z.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,z.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,z.jsx)(j,{"aria-label":T?`Close provider details`:`Back to providers`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,onClick:t,variant:`ghost`,children:T?(0,z.jsx)(He,{className:`h-4 w-4`}):(0,z.jsx)(cn,{className:`h-4 w-4`})}),(0,z.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,z.jsx)(`section`,{className:u(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,z.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=f[e.path],n=tr(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,z.jsxs)(`div`,{className:`grid min-h-18 grid-cols-[minmax(12rem,0.55fr)_minmax(16rem,0.45fr)] items-center gap-6 border-b py-4 max-[900px]:grid-cols-1 max-[900px]:gap-3`,children:[(0,z.jsxs)(`header`,{children:[(0,z.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,z.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,z.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,z.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,z.jsx)(ct,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,z.jsxs)(`select`,{className:`h-9 w-full rounded border border-border bg-background px-3 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,onChange:t=>E(e,t.target.value),value:n,children:[(0,z.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,z.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,z.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,z.jsx)(ut,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,z.jsx)(O,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>E(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(j,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,z.jsx)(mn,{className:`h-4 w-4`}):(0,z.jsx)(hn,{className:`h-4 w-4`})}),(0,z.jsx)(j,{"aria-label":`Copy ${e.label}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>navigator.clipboard.writeText(n),variant:`ghost`,children:(0,z.jsx)(Ae,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,z.jsx)(`div`,{className:`mb-8`,children:(0,z.jsxs)(j,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,z.jsx)(it,{className:`h-4 w-4 animate-spin`}):null,(0,z.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,z.jsx)(`p`,{className:`mb-8 text-xs text-muted-foreground`,children:`OAuth is connected. Manual credentials remain available when this provider supports them.`}):null,(0,z.jsxs)(`section`,{className:u(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,z.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,z.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(st,{className:`size-4 text-muted-foreground`}),(0,z.jsx)(j,{"aria-label":`Refresh models`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,disabled:i,onClick:r,variant:`ghost`,children:(0,z.jsx)(tt,{className:u(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,z.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,z.jsx)(st,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(O,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,z.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,z.jsxs)(`div`,{className:`group flex min-h-16 items-center gap-3 border-b px-4 py-3 transition-colors hover:bg-accent/30`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,z.jsx)(`div`,{title:`File Support`,children:(0,z.jsx)(gn,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,z.jsx)(`div`,{title:`Image Support`,children:(0,z.jsx)(Oe,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,z.jsxs)(`button`,{"aria-label":`Copy model ID ${e.id}`,className:`mt-1 flex max-w-full items-center gap-1.5 px-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>te(e.id),title:`Copy model ID`,type:`button`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,z.jsx)(Ae,{className:`size-3 shrink-0`}),S===e.id?(0,z.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,z.jsx)(j,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,z.jsx)(rt,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,z.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var ar,or=Object.freeze({status:`aborted`});function B(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var sr=Symbol(`zod_brand`),cr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},lr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ar=globalThis).__zod_globalConfig??(ar.__zod_globalConfig={});var ur=globalThis.__zod_globalConfig;function dr(e){return e&&Object.assign(ur,e),ur}var fr=t({BIGINT_FORMAT_RANGES:()=>Jr,Class:()=>_i,NUMBER_FORMAT_RANGES:()=>qr,aborted:()=>ni,allowsEval:()=>Ir,assert:()=>_r,assertEqual:()=>pr,assertIs:()=>hr,assertNever:()=>gr,assertNotEqual:()=>mr,assignProp:()=>Er,base64ToUint8Array:()=>di,base64urlToUint8Array:()=>pi,cached:()=>br,captureStackTrace:()=>Pr,cleanEnum:()=>ui,cleanRegex:()=>Sr,clone:()=>Wr,cloneDef:()=>Or,createTransparentProxy:()=>Gr,defineLazy:()=>H,esc:()=>Mr,escapeRegex:()=>Ur,explicitlyAborted:()=>ri,extend:()=>Zr,finalizeIssue:()=>oi,floatSafeRemainder:()=>Cr,getElementAtPath:()=>kr,getEnumValues:()=>vr,getLengthableOrigin:()=>ci,getParsedType:()=>Br,getSizableOrigin:()=>si,hexToUint8Array:()=>hi,isObject:()=>Fr,isPlainObject:()=>Lr,issue:()=>li,joinValues:()=>V,jsonStringifyReplacer:()=>yr,merge:()=>$r,mergeDefs:()=>Dr,normalizeParams:()=>U,nullish:()=>xr,numKeys:()=>zr,objectClone:()=>Tr,omit:()=>Xr,optionalKeys:()=>Kr,parsedType:()=>G,partial:()=>ei,pick:()=>Yr,prefixIssues:()=>ii,primitiveTypes:()=>Hr,promiseAllObject:()=>Ar,propertyKeyTypes:()=>Vr,randomString:()=>jr,required:()=>ti,safeExtend:()=>Qr,shallowClone:()=>Rr,slugify:()=>Nr,stringifyPrimitive:()=>W,uint8ArrayToBase64:()=>fi,uint8ArrayToBase64url:()=>mi,uint8ArrayToHex:()=>gi,unwrapMessage:()=>ai});function pr(e){return e}function mr(e){return e}function hr(e){}function gr(e){throw Error(`Unexpected value in exhaustive check`)}function _r(e){}function vr(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function V(e,t=`|`){return e.map(e=>W(e)).join(t)}function yr(e,t){return typeof t==`bigint`?t.toString():t}function br(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function xr(e){return e==null}function Sr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Cr(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var wr=Symbol(`evaluating`);function H(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==wr)return r===void 0&&(r=wr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Tr(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Er(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Dr(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Or(e){return Dr(e._zod.def)}function kr(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function Ar(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function jr(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Mr(e){return JSON.stringify(e)}function Nr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Pr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Fr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ir=br(()=>{if(ur.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Lr(e){if(Fr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Fr(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Rr(e){return Lr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function zr(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Br=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Vr=new Set([`string`,`number`,`symbol`]),Hr=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Ur(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Wr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function U(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Gr(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function W(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Kr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var qr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Jr={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Yr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Wr(e,Dr(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Er(this,`shape`,e),e},checks:[]}))}function Xr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Wr(e,Dr(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Er(this,`shape`,r),r},checks:[]}))}function Zr(e,t){if(!Lr(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Wr(e,Dr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Er(this,`shape`,n),n}}))}function Qr(e,t){if(!Lr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Wr(e,Dr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Er(this,`shape`,n),n}}))}function $r(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Wr(e,Dr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Er(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ei(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Wr(t,Dr(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Er(this,`shape`,i),i},checks:[]}))}function ti(e,t,n){return Wr(t,Dr(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Er(this,`shape`,i),i}}))}function ni(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ri(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ii(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ai(e){return typeof e==`string`?e:e?.message}function oi(e,t,n){let r=e.message?e.message:ai(e.inst?._zod.def?.error?.(e))??ai(t?.error?.(e))??ai(n.customError?.(e))??ai(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function si(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function ci(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function G(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function li(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function ui(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function di(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function fi(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function pi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return di(t+`=`.repeat((4-t.length%4)%4))}function mi(e){return fi(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function hi(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function gi(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var _i=class{constructor(...e){}},vi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,yr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},yi=B(`$ZodError`,vi),bi=B(`$ZodError`,vi,{Parent:Error});function xi(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Si(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function Ci(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if(s.code===`invalid_key`)r({issues:s.issues},[...i,...s.path]);else if(s.code===`invalid_element`)r({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function wi(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ti(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${wi(e.path)}`);return t.join(`
|
|
2
2
|
`)}var Ei=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new cr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>oi(e,a,dr())));throw Pr(t,i?.callee),t}return o.value},Di=Ei(bi),Oi=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>oi(e,a,dr())));throw Pr(t,i?.callee),t}return o.value},ki=Oi(bi),Ai=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new cr;return a.issues.length?{success:!1,error:new(e??yi)(a.issues.map(e=>oi(e,i,dr())))}:{success:!0,data:a.value}},ji=Ai(bi),Mi=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>oi(e,i,dr())))}:{success:!0,data:a.value}},Ni=Mi(bi),Pi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ei(e)(t,n,i)},Fi=Pi(bi),Ii=e=>(t,n,r)=>Ei(e)(t,n,r),Li=Ii(bi),Ri=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Oi(e)(t,n,i)},zi=Ri(bi),Bi=e=>async(t,n,r)=>Oi(e)(t,n,r),Vi=Bi(bi),Hi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ai(e)(t,n,i)},Ui=Hi(bi),Wi=e=>(t,n,r)=>Ai(e)(t,n,r),Gi=Wi(bi),Ki=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Mi(e)(t,n,i)},qi=Ki(bi),Ji=e=>async(t,n,r)=>Mi(e)(t,n,r),Yi=Ji(bi),Xi=t({base64:()=>Ca,base64url:()=>wa,bigint:()=>Fa,boolean:()=>Ra,browserEmail:()=>ha,cidrv4:()=>xa,cidrv6:()=>Sa,cuid:()=>Zi,cuid2:()=>Qi,date:()=>Aa,datetime:()=>Na,domain:()=>Ea,duration:()=>ra,e164:()=>Oa,email:()=>ua,emoji:()=>_a,extendedDuration:()=>ia,guid:()=>aa,hex:()=>Ua,hostname:()=>Ta,html5Email:()=>da,httpProtocol:()=>Da,idnEmail:()=>ma,integer:()=>Ia,ipv4:()=>va,ipv6:()=>ya,ksuid:()=>ta,lowercase:()=>Va,mac:()=>ba,md5_base64:()=>qa,md5_base64url:()=>Ja,md5_hex:()=>Ka,nanoid:()=>na,null:()=>za,number:()=>La,rfc5322Email:()=>fa,sha1_base64:()=>Xa,sha1_base64url:()=>Za,sha1_hex:()=>Ya,sha256_base64:()=>$a,sha256_base64url:()=>eo,sha256_hex:()=>Qa,sha384_base64:()=>no,sha384_base64url:()=>ro,sha384_hex:()=>to,sha512_base64:()=>ao,sha512_base64url:()=>oo,sha512_hex:()=>io,string:()=>Pa,time:()=>Ma,ulid:()=>$i,undefined:()=>Ba,unicodeEmail:()=>pa,uppercase:()=>Ha,uuid:()=>oa,uuid4:()=>sa,uuid6:()=>ca,uuid7:()=>la,xid:()=>ea}),Zi=/^[cC][0-9a-z]{6,}$/,Qi=/^[0-9a-z]+$/,$i=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ea=/^[0-9a-vA-V]{20}$/,ta=/^[A-Za-z0-9]{27}$/,na=/^[a-zA-Z0-9_-]{21}$/,ra=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ia=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,aa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,oa=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,sa=oa(4),ca=oa(6),la=oa(7),ua=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,da=/^[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])?)*$/,fa=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,pa=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,ma=pa,ha=/^[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])?)*$/,ga=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function _a(){return new RegExp(ga,`u`)}var va=/^(?:(?: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])$/,ya=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,ba=e=>{let t=Ur(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},xa=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Sa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ca=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wa=/^[A-Za-z0-9_-]*$/,Ta=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Ea=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Da=/^https?$/,Oa=/^\+[1-9]\d{6,14}$/,ka=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Aa=RegExp(`^${ka}$`);function ja(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ma(e){return RegExp(`^${ja(e)}$`)}function Na(e){let t=ja({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ka}T(?:${r})$`)}var Pa=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Fa=/^-?\d+n?$/,Ia=/^-?\d+$/,La=/^-?\d+(?:\.\d+)?$/,Ra=/^(?:true|false)$/i,za=/^null$/i,Ba=/^undefined$/i,Va=/^[^A-Z]*$/,Ha=/^[^a-z]*$/,Ua=/^[0-9a-fA-F]*$/;function Wa(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Ga(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Ka=/^[0-9a-fA-F]{32}$/,qa=Wa(22,`==`),Ja=Ga(22),Ya=/^[0-9a-fA-F]{40}$/,Xa=Wa(27,`=`),Za=Ga(27),Qa=/^[0-9a-fA-F]{64}$/,$a=Wa(43,`=`),eo=Ga(43),to=/^[0-9a-fA-F]{96}$/,no=Wa(64,``),ro=Ga(64),io=/^[0-9a-fA-F]{128}$/,ao=Wa(86,`==`),oo=Ga(86),so=B(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),co={number:`number`,bigint:`bigint`,object:`date`},lo=B(`$ZodCheckLessThan`,(e,t)=>{so.init(e,t);let n=co[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uo=B(`$ZodCheckGreaterThan`,(e,t)=>{so.init(e,t);let n=co[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fo=B(`$ZodCheckMultipleOf`,(e,t)=>{so.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Cr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),po=B(`$ZodCheckNumberFormat`,(e,t)=>{so.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=qr[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Ia)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),mo=B(`$ZodCheckBigIntFormat`,(e,t)=>{so.init(e,t);let[n,r]=Jr[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=i=>{let a=i.value;a<n&&i.issues.push({origin:`bigint`,input:a,code:`too_small`,minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:`bigint`,input:a,code:`too_big`,maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),ho=B(`$ZodCheckMaxSize`,(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:si(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),go=B(`$ZodCheckMinSize`,(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:si(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_o=B(`$ZodCheckSizeEquals`,(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:si(r),...a?{code:`too_big`,maximum:t.size}:{code:`too_small`,minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),vo=B(`$ZodCheckMaxLength`,(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=ci(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yo=B(`$ZodCheckMinLength`,(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=ci(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bo=B(`$ZodCheckLengthEquals`,(e,t)=>{var n;so.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!xr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=ci(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),xo=B(`$ZodCheckStringFormat`,(e,t)=>{var n,r;so.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),So=B(`$ZodCheckRegex`,(e,t)=>{xo.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Co=B(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Va,xo.init(e,t)}),wo=B(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ha,xo.init(e,t)}),To=B(`$ZodCheckIncludes`,(e,t)=>{so.init(e,t);let n=Ur(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Eo=B(`$ZodCheckStartsWith`,(e,t)=>{so.init(e,t);let n=RegExp(`^${Ur(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Do=B(`$ZodCheckEndsWith`,(e,t)=>{so.init(e,t);let n=RegExp(`.*${Ur(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Oo(e,t,n){e.issues.length&&t.issues.push(...ii(n,e.issues))}var ko=B(`$ZodCheckProperty`,(e,t)=>{so.init(e,t),e._zod.check=e=>{let n=t.schema._zod.run({value:e.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(n=>Oo(n,e,t.property));Oo(n,e,t.property)}}),Ao=B(`$ZodCheckMimeType`,(e,t)=>{so.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:`invalid_value`,values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),jo=B(`$ZodCheckOverwrite`,(e,t)=>{so.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Mo=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
4
4
|
`))}},No={major:4,minor:4,patch:3},K=B(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=No;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=ni(e),i;for(let a of t){if(a._zod.def.when){if(ri(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new cr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=ni(e,t))});else{if(e.issues.length===t)continue;r||=ni(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(ni(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new cr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new cr;return o.then(e=>t(e,r,a))}return t(o,r,a)}}H(e,`~standard`,()=>({validate:t=>{try{let n=ji(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ni(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Po=B(`$ZodString`,(e,t)=>{K.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Pa(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Fo=B(`$ZodStringFormat`,(e,t)=>{xo.init(e,t),Po.init(e,t)}),Io=B(`$ZodGUID`,(e,t)=>{t.pattern??=aa,Fo.init(e,t)}),Lo=B(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=oa(e)}else t.pattern??=oa();Fo.init(e,t)}),Ro=B(`$ZodEmail`,(e,t)=>{t.pattern??=ua,Fo.init(e,t)}),zo=B(`$ZodURL`,(e,t)=>{Fo.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Da.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Bo=B(`$ZodEmoji`,(e,t)=>{t.pattern??=_a(),Fo.init(e,t)}),Vo=B(`$ZodNanoID`,(e,t)=>{t.pattern??=na,Fo.init(e,t)}),Ho=B(`$ZodCUID`,(e,t)=>{t.pattern??=Zi,Fo.init(e,t)}),Uo=B(`$ZodCUID2`,(e,t)=>{t.pattern??=Qi,Fo.init(e,t)}),Wo=B(`$ZodULID`,(e,t)=>{t.pattern??=$i,Fo.init(e,t)}),Go=B(`$ZodXID`,(e,t)=>{t.pattern??=ea,Fo.init(e,t)}),Ko=B(`$ZodKSUID`,(e,t)=>{t.pattern??=ta,Fo.init(e,t)}),qo=B(`$ZodISODateTime`,(e,t)=>{t.pattern??=Na(t),Fo.init(e,t)}),Jo=B(`$ZodISODate`,(e,t)=>{t.pattern??=Aa,Fo.init(e,t)}),Yo=B(`$ZodISOTime`,(e,t)=>{t.pattern??=Ma(t),Fo.init(e,t)}),Xo=B(`$ZodISODuration`,(e,t)=>{t.pattern??=ra,Fo.init(e,t)}),Zo=B(`$ZodIPv4`,(e,t)=>{t.pattern??=va,Fo.init(e,t),e._zod.bag.format=`ipv4`}),Qo=B(`$ZodIPv6`,(e,t)=>{t.pattern??=ya,Fo.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),$o=B(`$ZodMAC`,(e,t)=>{t.pattern??=ba(t.delimiter),Fo.init(e,t),e._zod.bag.format=`mac`}),es=B(`$ZodCIDRv4`,(e,t)=>{t.pattern??=xa,Fo.init(e,t)}),ts=B(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Sa,Fo.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ns(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var rs=B(`$ZodBase64`,(e,t)=>{t.pattern??=Ca,Fo.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{ns(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function is(e){if(!wa.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ns(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var as=B(`$ZodBase64URL`,(e,t)=>{t.pattern??=wa,Fo.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{is(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),os=B(`$ZodE164`,(e,t)=>{t.pattern??=Oa,Fo.init(e,t)});function ss(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var cs=B(`$ZodJWT`,(e,t)=>{Fo.init(e,t),e._zod.check=n=>{ss(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ls=B(`$ZodCustomStringFormat`,(e,t)=>{Fo.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:`invalid_format`,format:t.format,input:n.value,inst:e,continue:!t.abort})}}),us=B(`$ZodNumber`,(e,t)=>{K.init(e,t),e._zod.pattern=e._zod.bag.pattern??La,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ds=B(`$ZodNumberFormat`,(e,t)=>{po.init(e,t),us.init(e,t)}),fs=B(`$ZodBoolean`,(e,t)=>{K.init(e,t),e._zod.pattern=Ra,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ps=B(`$ZodBigInt`,(e,t)=>{K.init(e,t),e._zod.pattern=Fa,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),ms=B(`$ZodBigIntFormat`,(e,t)=>{mo.init(e,t),ps.init(e,t)}),hs=B(`$ZodSymbol`,(e,t)=>{K.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),gs=B(`$ZodUndefined`,(e,t)=>{K.init(e,t),e._zod.pattern=Ba,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),_s=B(`$ZodNull`,(e,t)=>{K.init(e,t),e._zod.pattern=za,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),vs=B(`$ZodAny`,(e,t)=>{K.init(e,t),e._zod.parse=e=>e}),ys=B(`$ZodUnknown`,(e,t)=>{K.init(e,t),e._zod.parse=e=>e}),bs=B(`$ZodNever`,(e,t)=>{K.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),xs=B(`$ZodVoid`,(e,t)=>{K.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),Ss=B(`$ZodDate`,(e,t)=>{K.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}});function Cs(e,t,n){e.issues.length&&t.issues.push(...ii(n,e.issues)),t.value[n]=e.value}var ws=B(`$ZodArray`,(e,t)=>{K.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Cs(t,n,e))):Cs(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Ts(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ii(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Es(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Kr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ds(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ts(e,n,i,t,u,d))):Ts(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Os=B(`$ZodObject`,(e,t)=>{if(K.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=br(()=>Es(t));H(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Fr,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Ts(n,t,e,s,r,i))):Ts(a,t,e,s,r,i)}return i?Ds(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ks=B(`$ZodObjectJIT`,(e,t)=>{Os.init(e,t);let n=e._zod.parse,r=br(()=>Es(t)),i=e=>{let t=new Mo([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Mr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Mr(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="./cline-logo-filled.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Cline Hub</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-Be-mNsEe.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-CNC7AqOf.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/bundle-mjs-D3mlU5Wg.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/react-dom-Cmec2Q1Q.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/vscode-DBs95Ixu.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="./assets/mermaid-parser-HclGiUj8.js">
|
|
14
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
14
|
+
<link rel="stylesheet" crossorigin href="./assets/index-kv5oct7o.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|