@cline/cli-windows-arm64 3.0.53 → 3.0.54
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-5-m425Jp.js → Chat-Ddr1_y0K.js} +1 -1
- package/cline-hub/webview/assets/{extensions-view-Cd8F5xpl.js → extensions-view-BPiQgdTf.js} +1 -1
- package/cline-hub/webview/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/cline-hub/webview/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/cline-hub/webview/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/cline-hub/webview/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/cline-hub/webview/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/cline-hub/webview/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/cline-hub/webview/assets/{index-CfNkVILD.js → index-D_uZQMMw.js} +2 -2
- package/cline-hub/webview/assets/index-Dwkfosyp.css +1 -0
- package/cline-hub/webview/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/cline-hub/webview/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/cline-hub/webview/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/cline-hub/webview/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/cline-hub/webview/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/cline-hub/webview/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/cline-hub/webview/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/cline-hub/webview/assets/{settings-view-DS30eWav.js → settings-view-CBVLcC-5.js} +1 -1
- package/cline-hub/webview/index.html +2 -2
- package/package.json +1 -1
- package/cline-hub/webview/assets/index-BzdZ8J4d.css +0 -1
- package/cline-hub/webview/assets/schibsted-grotesk-latin-ext-wght-normal-hsMS0n0O.woff2 +0 -0
- package/cline-hub/webview/assets/schibsted-grotesk-latin-wght-normal-Bb8VGrTG.woff2 +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{a as n,i as r,r as i}from"./bundle-mjs-CSP5ngA5.js";import{$n as a,$t as o,B as s,Bn as c,Bt as l,C as u,Cn as d,Ct as f,Dt as p,E as m,En as h,Et as g,F as _,G as v,Gn as y,H as b,I as x,J as S,L as C,Lt as w,M as T,O as E,Pt as D,Q as ee,Qn as O,R as k,Rn as te,S as A,Sn as ne,St as j,Tt as re,U as ie,Un as ae,V as oe,Vn as se,W as ce,X as le,Xn as ue,Xt as de,Yn as fe,Yt as M,Z as pe,_ as me,an as he,ar as ge,b as _e,bn as ve,c as ye,cr as be,d as xe,dn as Se,dr as Ce,en as we,f as Te,fn as Ee,g as De,gt as Oe,h as ke,hn as Ae,in as je,ir as Me,it as Ne,j as Pe,k as Fe,l as Ie,ln as Le,m as Re,nr as ze,on as Be,or as Ve,p as He,pn as Ue,q as We,sr as Ge,tn as Ke,u as qe,un as Je,v as Ye,vn as Xe,vt as Ze,w as N,wn as Qe,xn as $e,y as et,yn as tt,z as nt,zn as rt,zt as it}from"./vscode-tfEHsPTc.js";import{A as at,C as ot,D as st,E as ct,F as lt,I as ut,L as dt,M as ft,N as pt,O as mt,P as ht,R as gt,S as _t,T as vt,_ as yt,a as bt,b as xt,c as St,d as Ct,f as wt,g as Tt,h as Et,i as Dt,j as Ot,k as kt,l as At,n as jt,p as Mt,r as Nt,s as Pt,t as P,u as Ft,v as It,w as Lt,x as Rt,y as zt}from"./label-CFn0VYsb.js";import{a as Bt,i as Vt,n as Ht,o as Ut,r as Wt,t as Gt}from"./switch-1OAUgxzd.js";import{a as Kt,i as qt,n as Jt,r as Yt,t as F}from"./desktop-client-Cc9yU7GV.js";import{l as Xt}from"./DialogTitle-jgZKJpfs.js";import{O as Zt,_ as Qt,a as $t,b as en,c as tn,g as nn,h as I,i as rn,m as an,n as on,o as sn,r as cn,s as ln,t as un,v as dn,w as fn,x as pn,y as mn}from"./index-CfNkVILD.js";var hn=C(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),gn=C(`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`}]]),_n=C(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),vn=C(`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`}]]),yn=C(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),bn=C(`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`}]]),xn=C(`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`}]]),Sn=C(`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`}]]),Cn=C(`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`}]]),wn=C(`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`}]]),Tn=C(`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`}]]),En=C(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Dn=C(`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`}]]),On=C(`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`}]]),L=e(n(),1),kn=L.createContext({disabled:!1});function An(){return L.useContext(kn)}var R=i();function jn(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 Mn(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 Nn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function Pn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function Fn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function In(e){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Ln(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Rn(e,t){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function zn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function Bn(){let[e,t]=(0,L.useState)(`overview`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)([]),[f,p]=(0,L.useState)(!0),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)([]),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(0),[T,E]=(0,L.useState)([]),[D,ee]=(0,L.useState)(!1),[O,te]=(0,L.useState)(null),[A,ne]=(0,L.useState)(!1),j=u.find(e=>e.active)??null,re=(0,L.useCallback)(()=>{a(null),s(null),l(null),d([]),_([]),C(!1),x(null),E([]),ne(!1),te(null)},[]),ie=(0,L.useCallback)(async()=>{p(!0),h(null);try{let[e,t,n]=await Promise.all([Nn(),Pn(),Fn()]),r=n.find(e=>e.active)??null,i=r?await In(r.organizationId):null;a(e),s(t),l(i),d(n)}catch(e){re();let t=jn(e).message;h(t)}finally{p(!1)}},[re]);(0,L.useEffect)(()=>{ie()},[ie]);let ae=async()=>{r(`sign-in`),h(null);try{await F.invoke(`run_provider_oauth_login`,{provider:`cline`}),await ie(),t(`overview`)}catch(e){let t=jn(e).message;h(t),re()}finally{r(null)}},oe=async()=>{r(`sign-out`);try{await F.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),re(),t(`overview`),h(`No Cline account auth token found`)}catch(e){let t=jn(e).message;h(t)}finally{r(null)}},se=(0,L.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=j?await Rn(j.organizationId,j.memberId):await Ln();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=jn(t).message;x(n)}finally{w.current===e&&y(!1)}},[j]);(0,L.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[j?.organizationId]),(0,L.useEffect)(()=>{e===`usage`&&!S&&se()},[e,S,se]);let ce=(0,L.useCallback)(async()=>{ee(!0),te(null);try{let e=await zn();E(e),ne(!0)}catch(e){let t=jn(e).message;te(t)}finally{ee(!1)}},[]);(0,L.useEffect)(()=>{e===`billing`&&!A&&ce()},[e,A,ce]);let le=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ue=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),de=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),fe=j?c?.balance??o?.balance??null:o?.balance??null,M=[`overview`,`usage`,`billing`],pe=(e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,R.jsx)(vn,{className:`h-8 w-8 text-destructive`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,R.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,R.jsx)(qt,{className:`h-4 w-4`}),`Retry`]})]}),me=()=>(0,R.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,R.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(Zt,{className:`h-6 w-6`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,R.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,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsxs)(N,{disabled:n!==null,onClick:()=>void ae(),type:`button`,children:[n===`sign-in`?(0,R.jsx)(Bt,{className:`h-4 w-4 animate-spin`}):(0,R.jsx)(wn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,R.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,R.jsx)(Kt,{className:`h-4 w-4`})]})]})]})}),he=()=>(0,R.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,R.jsx)(Bt,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,R.jsxs)(sn,{children:[(0,R.jsx)(ln,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,R.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:M.map(n=>{let r=!i&&n!==`overview`;return(0,R.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:k(`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,R.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[f&&he(),m&&(Mn(m)?me():pe(m,ie)),!f&&!m&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,R.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,le(i.createdAt)]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.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,R.jsx)(Kt,{className:`h-3.5 w-3.5`})]}),(0,R.jsxs)(N,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void oe(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,R.jsx)(Bt,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(Tn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),fe!==null&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(bn,{className:`h-5 w-5 text-primary`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:j?`${j.name} Balance`:`Credits Balance`})]}),(0,R.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,R.jsx)(ht,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,R.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,R.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,de(fe)]})}),j&&o&&(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,de(o.balance),` `,`credits`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(gn,{className:`h-5 w-5 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,R.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,R.jsx)(ht,{className:`h-3.5 w-3.5`}),`Create`]})]}),u.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,R.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,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:j?`Recent API usage and token consumption for ${j.name}.`:`Recent API usage and token consumption across all providers.`}),v&&he(),b&&pe(b,se),!v&&!b&&S&&(g.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.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,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:g.map(e=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,R.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,R.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:de(e.creditsUsed)}),(0,R.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:le(e.createdAt)}),(0,R.jsx)(`p`,{children:ue(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),D&&he(),O&&pe(O,ce),!D&&!O&&A&&(T.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.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,R.jsx)(`span`,{children:`Date`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(On,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-foreground`,children:le(e.paidAt)})]}),(0,R.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,R.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,de(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Vn=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Hn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,L.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(null),h=(0,L.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),g=n.includes(h),v=r.models.length>0,y=r.modelsSourceUrl.trim().length>0,b=h.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(v||y)&&!g,x=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)}))},S=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},C=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},w=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},T=(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}))},E=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},D=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},ee=async()=>{if(!(!b||d)){f(!0),m(null);try{await t({providerId:h,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){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}};return(0,R.jsxs)(sn,{contentClassName:`max-w-4xl`,children:[(0,R.jsx)(ln,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,R.jsxs)(N,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,R.jsx)(hn,{className:`h-4 w-4`}),`Providers`]})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,R.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,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),g?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,R.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,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,R.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,R.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,R.jsx)(`span`,{className:`font-mono`,children:e}),(0,R.jsx)(N,{onClick:()=>S(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,R.jsx)(pt,{className:`h-3 w-3`})})]},e)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:x,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,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,R.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,R.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.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,R.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,R.jsx)(N,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,R.jsx)(xn,{className:`h-4 w-4`}):(0,R.jsx)(Sn,{className:`h-4 w-4`})}),(0,R.jsx)(N,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,R.jsx)(Ut,{className:`h-4 w-4`})})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Vn.map(e=>(0,R.jsx)(N,{onClick:()=>C(e),className:k(`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,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(N,{onClick:()=>u(!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,R.jsx)(dt,{className:k(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,R.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,value:e,onChange:t=>T(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,R.jsx)(`input`,{type:`text`,value:t,onChange:t=>E(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,R.jsx)(N,{onClick:()=>D(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,R.jsx)(_,{className:`h-4 w-4`})})]},e)),(0,R.jsxs)(N,{onClick:w,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,R.jsx)(ht,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),p?(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:p}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,R.jsx)(N,{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,R.jsx)(N,{onClick:()=>void ee(),disabled:!b||d,className:k(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,b&&!d?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:d?`Saving...`:`Add Provider`})]})]})]})}function Un(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Wn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Gn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Kn(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 qn(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Jn(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 Yn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Xn(e){let t=e[0];return{channelId:t?.id??``,values:Yn(t),securityEnabled:!1,securityValues:{}}}function Zn(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[m,h]=(0,L.useState)(null),[g,v]=(0,L.useState)(null),y=(0,L.useMemo)(()=>e.find(e=>e.id===f.channelId),[e,f.channelId]),b=(0,L.useMemo)(()=>{let e={...Yn(y),...f.values};return(y?.fields??[]).filter(t=>Jn(t,e))},[y,f.values]),x=(0,L.useCallback)(e=>{t(e.available),r(e.active),p(t=>t.channelId?t:Xn(e.available))},[]),S=(0,L.useCallback)(async()=>{a(!0),l(null);try{let e=await F.invoke(`list_connector_channels`);x(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[x]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{S()},0);return()=>window.clearTimeout(e)},[S]);let C=()=>{p(Xn(e)),h(null),d(!0)},w=(e,t)=>{p(n=>({...n,values:{...n.values,[e]:t}}))},T=(e,t)=>{p(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},E=async()=>{if(!y){h(`Choose a channel`);return}for(let e of y.fields)if(b.includes(e)&&e.required&&!f.values[e.flag]?.trim()){h(`${e.label} is required`);return}if(f.securityEnabled&&y.security){for(let e of y.security.fields)if(!f.securityValues[e.key]?.trim()){h(e.requiredMessage);return}}s(y.id),h(null),l(null);try{let e=await F.invoke(`start_connector_channel`,{channel:y.id,values:f.values,security:{enabled:f.securityEnabled,values:f.securityValues}});x(e),d(!1)}catch(e){let t=e instanceof Error?e.message:String(e);h(t)}finally{s(null)}},D=async e=>{s(e.type),l(null);try{let t=await F.invoke(`stop_connector_channel`,{channel:e.type});x(t),v(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,R.jsxs)(sn,{children:[(0,R.jsx)(ln,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,R.jsx)(rn,{children:`cline connect`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{disabled:i,onClick:()=>void S(),size:`sm`,type:`button`,variant:`outline`,children:(0,R.jsx)(qt,{className:k(`size-4`,i&&`animate-spin`)})}),(0,R.jsxs)(N,{disabled:e.length===0,onClick:C,size:`sm`,type:`button`,children:[(0,R.jsx)(ht,{className:`size-4`}),`Add Channel`]})]})}),c?(0,R.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,R.jsx)($t,{children:`Loading channels...`}):n.length===0?(0,R.jsx)($t,{children:`No channels connected.`}):(0,R.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,R.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(ut,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,R.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:Un(t,e)}),(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Wn(t)})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,R.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,R.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,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Gn(t.startedAt)}),t.connectionMode?(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,R.jsxs)(N,{disabled:o===t.type,onClick:()=>v(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,R.jsx)(_,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,R.jsx)(St,{open:u,onOpenChange:d,children:(0,R.jsxs)(At,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,R.jsxs)(wt,{children:[(0,R.jsx)(Mt,{children:`Add Channel`}),(0,R.jsx)(Ft,{children:`Start a connector channel for Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{children:`Channel`}),(0,R.jsxs)(Et,{onValueChange:t=>{t&&p({channelId:t,values:Yn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:f.channelId,children:[(0,R.jsx)(It,{children:(0,R.jsx)(zt,{placeholder:`Select channel`})}),(0,R.jsx)(Tt,{children:e.map(e=>(0,R.jsx)(yt,{value:e.id,children:e.name},e.id))})]})]}),b.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(P,{children:[e.label,e.required?(0,R.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,R.jsxs)(Et,{onValueChange:t=>{t&&w(e.flag,t)},value:f.values[e.flag]??e.initialValue??``,children:[(0,R.jsx)(It,{children:(0,R.jsx)(zt,{placeholder:e.placeholder})}),(0,R.jsx)(Tt,{children:e.options.map(e=>(0,R.jsx)(yt,{value:e.value,children:e.label},e.value))})]}):qn(e)?(0,R.jsx)(Pt,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:f.values[e.flag]??``}):(0,R.jsx)(ye,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,type:Kn(e)?`password`:`text`,value:f.values[e.flag]??``})]},e.flag)),y?.security?(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(P,{className:`text-sm`,children:`Restrict access`}),(0,R.jsx)(Gt,{checked:f.securityEnabled,onCheckedChange:e=>p(t=>({...t,securityEnabled:e}))})]}),f.securityEnabled?y.security.fields.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{children:e.label}),(0,R.jsx)(ye,{onChange:t=>T(e.key,t.target.value),placeholder:e.placeholder,type:Kn(e)?`password`:`text`,value:f.securityValues[e.key]??``})]},e.key)):null]}):null,m?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:m}):null]}),(0,R.jsxs)(Ct,{children:[(0,R.jsx)(N,{disabled:o!==null,onClick:()=>d(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,R.jsx)(N,{disabled:o!==null||!y,onClick:()=>void E(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,R.jsx)(an,{open:g!==null,onOpenChange:e=>{e||v(null)},children:(0,R.jsxs)(Qt,{children:[(0,R.jsxs)(en,{children:[(0,R.jsx)(pn,{children:`Remove Channel`}),(0,R.jsxs)(dn,{children:[`Confirm that you want to stop the active`,` `,g?Un(g,e):`channel`,` `,`channel for `,g?Wn(g):``,`.`]})]}),(0,R.jsxs)(mn,{children:[(0,R.jsx)(nn,{disabled:o!==null,children:`Cancel`}),(0,R.jsx)(I,{disabled:o!==null||!g,onClick:()=>{g&&D(g)},variant:`destructive`,children:`Remove`})]})]})})]})}function Qn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function $n(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 er(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function tr(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function nr(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 rr(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:nr(e?.env),url:e?.url??``,headersText:er(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function ir(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(!1),[g,v]=(0,L.useState)(`create`),[y,b]=(0,L.useState)(()=>rr()),[x,S]=(0,L.useState)(null),[C,w]=(0,L.useState)(null),T=(0,L.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),E=(0,L.useCallback)(async()=>{s(!0),d(null);try{let e=await F.invoke(`list_mcp_servers`);T(e)}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{s(!1)}},[T]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{E()},0);return()=>window.clearTimeout(e)},[E]);let D=async(e,t)=>{p(e.name),d(null);try{let n=await F.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});T(n)}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{p(null)}},ee=async e=>{p(e.previousName??e.name),d(null);try{let t=await F.invoke(`upsert_mcp_server`,{input:e});T(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw d(t),e}finally{p(null)}},O=async e=>{p(e),d(null);try{let t=await F.invoke(`delete_mcp_server`,{name:e});T(t)}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{p(null)}},te=(0,L.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:$n(e.headersText),disabled:e.disabled,metadata:i}},[]),A=()=>{v(`create`),b(rr()),S(null),h(!0)},ne=e=>{v(`edit`),b(rr(e)),S(null),h(!0)},j=async()=>{S(null);try{let e=te(y);await ee(e),h(!1)}catch(e){S(e instanceof Error?e.message:String(e))}},re=async()=>{l(!0),d(null);try{let e=await F.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{l(!1)}},ie=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),ae=(e,t,n)=>{b(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},oe=()=>{b(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},se=e=>{b(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,R.jsxs)(sn,{children:[(0,R.jsx)(ln,{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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(rn,{children:`cline config mcp`}),(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void E(),disabled:o,children:(0,R.jsx)(qt,{className:k(`h-4 w-4`,o&&`animate-spin`)})}),(0,R.jsxs)(N,{size:`sm`,onClick:A,children:[(0,R.jsx)(ht,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,R.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`MCP settings path:`}),(0,R.jsx)(N,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void re(),disabled:c,children:n||`Open settings file`})]}),u&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:u}),o?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):ie.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:ie.map(e=>{let t=f===e.name;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(ut,{className:k(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ne(e),disabled:t,children:(0,R.jsx)(Xt,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>w(e),disabled:t,children:(0,R.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(Gt,{checked:!e.disabled,onCheckedChange:t=>D(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,tr(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,er(e.headers)]})]})]},e.name)})}),(0,R.jsx)(St,{open:m,onOpenChange:e=>{h(e),e||S(null)},children:(0,R.jsxs)(At,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(wt,{children:[(0,R.jsx)(Mt,{children:g===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,R.jsxs)(Ft,{children:[`Update the MCP server stored in`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-name`,children:`Server name`}),(0,R.jsx)(ye,{id:`mcp-name`,value:y.name,onChange:e=>b(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{children:`Transport type`}),(0,R.jsxs)(Et,{value:y.transportType,onValueChange:e=>b(t=>({...t,transportType:e})),children:[(0,R.jsx)(It,{className:`w-full`,children:(0,R.jsx)(zt,{placeholder:`Select transport`})}),(0,R.jsxs)(Tt,{children:[(0,R.jsx)(yt,{value:`stdio`,children:`stdio`}),(0,R.jsx)(yt,{value:`sse`,children:`sse`}),(0,R.jsx)(yt,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),y.transportType===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(ye,{id:`mcp-command`,value:y.command,onChange:e=>b(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-args`,children:`Args`}),(0,R.jsx)(Pt,{id:`mcp-args`,value:y.argsText,onChange:e=>b(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,R.jsx)(ye,{id:`mcp-cwd`,value:y.cwd,onChange:e=>b(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(P,{children:`Environment variables`}),(0,R.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:oe,children:(0,R.jsx)(ht,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:y.envEntries.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(N,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>se(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,R.jsx)(En,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(ye,{value:e.key,onChange:t=>ae(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,R.jsx)(ye,{type:`password`,value:e.value,onChange:t=>ae(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-url`,children:`Server URL`}),(0,R.jsx)(ye,{id:`mcp-url`,value:y.url,onChange:e=>b(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-headers`,children:`Headers`}),(0,R.jsx)(Pt,{id:`mcp-headers`,value:y.headersText,onChange:e=>b(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,R.jsx)(Pt,{id:`mcp-metadata`,value:y.metadataText,onChange:e=>b(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,R.jsx)(Gt,{checked:!y.disabled,onCheckedChange:e=>b(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),x?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:x}):null]}),(0,R.jsxs)(Ct,{children:[(0,R.jsx)(N,{variant:`outline`,onClick:()=>h(!1),disabled:f!==null,children:`Cancel`}),(0,R.jsx)(N,{onClick:()=>void j(),disabled:f!==null,children:f===null?g===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,R.jsx)(an,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,R.jsxs)(Qt,{children:[(0,R.jsxs)(en,{children:[(0,R.jsx)(pn,{children:`Delete MCP Server`}),(0,R.jsx)(dn,{children:C?`Delete MCP server "${C.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,R.jsxs)(mn,{children:[(0,R.jsx)(nn,{disabled:f!==null,children:`Cancel`}),(0,R.jsx)(I,{disabled:f!==null||!C,onClick:()=>{C&&(O(C.name),w(null))},children:`Delete`})]})]})})]})}function ar(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 or(e){return e==null?``:String(e)}function sr(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 cr({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),u=e.filter(e=>e.enabled).length,d=c.trim().toLowerCase(),f=d?e.filter(e=>e.name.toLowerCase().includes(d)):e,p=a===`panel`;return(0,R.jsx)(tn,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:k(`py-10 max-[720px]:px-4 max-[720px]:py-5`,p?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:k(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,p?`max-w-none`:`max-w-[42rem]`),children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:k(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,p?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,R.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 · `,u,` `,`enabled`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,R.jsx)(N,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,R.jsx)(Wt,{className:`size-4`})}),(0,R.jsxs)(N,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,R.jsx)(yn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,R.jsx)(`div`,{className:k(`mb-4`,p?`max-w-none`:`max-w-[42rem]`),children:(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,R.jsx)(Wt,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(ye,{"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,R.jsxs)(`div`,{className:k(`overflow-hidden`,p?`max-w-none`:`max-w-[42rem]`),children:[f.length===0?(0,R.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,f.map(e=>(0,R.jsxs)(`div`,{className:k(`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,R.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,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,R.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,R.jsx)(Gt,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,R.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,R.jsx)(_n,{className:`size-4`})})]},e.id))]})]})})}function lr({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,u]=(0,L.useState)({}),[d,f]=(0,L.useState)(()=>ar(e)),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=(0,L.useRef)(void 0),v=e.configFields??[],y=or(d.apiKey),b=e.modelList??[],x=p?.providerId===e.id?p.value:``,S=h?.providerId===e.id?h.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,L.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=sr(e,t),i={...d,[e.path]:r};f(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=or(r)),e.path===`baseUrl`&&(a.baseUrl=or(r)),n(a)},D=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{g({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>g(null),1600)})};return(0,R.jsx)(tn,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:k(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,R.jsx)(N,{"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,R.jsx)(pt,{className:`h-4 w-4`}):(0,R.jsx)(hn,{className:`h-4 w-4`})}),(0,R.jsx)(`h1`,{className:k(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,R.jsx)(`section`,{className:k(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,R.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=d[e.path],n=or(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,R.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,R.jsxs)(`header`,{children:[(0,R.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,R.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,R.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,R.jsx)(Gt,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,R.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,R.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,R.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,R.jsx)(fn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,R.jsx)(ye,{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=>f(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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>u(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,R.jsx)(xn,{className:`h-4 w-4`}):(0,R.jsx)(Sn,{className:`h-4 w-4`})}),(0,R.jsx)(N,{"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,R.jsx)(Ut,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,R.jsx)(`div`,{className:`mb-8`,children:(0,R.jsxs)(N,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,R.jsx)(Bt,{className:`h-4 w-4 animate-spin`}):null,(0,R.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,R.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,R.jsxs)(`section`,{className:k(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,R.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(Wt,{className:`size-4 text-muted-foreground`}),(0,R.jsx)(N,{"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,R.jsx)(qt,{className:k(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,R.jsx)(Wt,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(ye,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>m({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,R.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,R.jsx)(`div`,{title:`File Support`,children:(0,R.jsx)(Cn,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,R.jsx)(`div`,{title:`Image Support`,children:(0,R.jsx)(lt,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,R.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:()=>D(e.id),title:`Copy model ID`,type:`button`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,R.jsx)(Ut,{className:`size-3 shrink-0`}),S===e.id?(0,R.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,R.jsx)(N,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,R.jsx)(Yt,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var ur,dr=Object.freeze({status:`aborted`});function z(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 fr=Symbol(`zod_brand`),pr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},mr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ur=globalThis).__zod_globalConfig??(ur.__zod_globalConfig={});var hr=globalThis.__zod_globalConfig;function gr(e){return e&&Object.assign(hr,e),hr}var _r=t({BIGINT_FORMAT_RANGES:()=>$r,Class:()=>Si,NUMBER_FORMAT_RANGES:()=>Qr,aborted:()=>si,allowsEval:()=>Vr,assert:()=>Sr,assertEqual:()=>vr,assertIs:()=>br,assertNever:()=>xr,assertNotEqual:()=>yr,assignProp:()=>jr,base64ToUint8Array:()=>gi,base64urlToUint8Array:()=>vi,cached:()=>Tr,captureStackTrace:()=>zr,cleanEnum:()=>hi,cleanRegex:()=>Dr,clone:()=>Yr,cloneDef:()=>Nr,createTransparentProxy:()=>Xr,defineLazy:()=>V,esc:()=>Lr,escapeRegex:()=>Jr,explicitlyAborted:()=>ci,extend:()=>ni,finalizeIssue:()=>di,floatSafeRemainder:()=>Or,getElementAtPath:()=>Pr,getEnumValues:()=>Cr,getLengthableOrigin:()=>pi,getParsedType:()=>Gr,getSizableOrigin:()=>fi,hexToUint8Array:()=>bi,isObject:()=>Br,isPlainObject:()=>Hr,issue:()=>mi,joinValues:()=>B,jsonStringifyReplacer:()=>wr,merge:()=>ii,mergeDefs:()=>Mr,normalizeParams:()=>H,nullish:()=>Er,numKeys:()=>Wr,objectClone:()=>Ar,omit:()=>ti,optionalKeys:()=>Zr,parsedType:()=>W,partial:()=>ai,pick:()=>ei,prefixIssues:()=>li,primitiveTypes:()=>qr,promiseAllObject:()=>Fr,propertyKeyTypes:()=>Kr,randomString:()=>Ir,required:()=>oi,safeExtend:()=>ri,shallowClone:()=>Ur,slugify:()=>Rr,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>_i,uint8ArrayToBase64url:()=>yi,uint8ArrayToHex:()=>xi,unwrapMessage:()=>ui});function vr(e){return e}function yr(e){return e}function br(e){}function xr(e){throw Error(`Unexpected value in exhaustive check`)}function Sr(e){}function Cr(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 B(e,t=`|`){return e.map(e=>U(e)).join(t)}function wr(e,t){return typeof t==`bigint`?t.toString():t}function Tr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Er(e){return e==null}function Dr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Or(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 kr=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==kr)return r===void 0&&(r=kr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ar(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function jr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Mr(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Nr(e){return Mr(e._zod.def)}function Pr(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function Fr(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 Ir(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Lr(e){return JSON.stringify(e)}function Rr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var zr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Br(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Vr=Tr(()=>{if(hr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Hr(e){if(Br(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Br(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ur(e){return Hr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Wr(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Gr=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}`)}},Kr=new Set([`string`,`number`,`symbol`]),qr=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Jr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Yr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(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 Xr(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 U(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Zr(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]},$r={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ei(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 Yr(e,Mr(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 jr(this,`shape`,e),e},checks:[]}))}function ti(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 Yr(e,Mr(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 jr(this,`shape`,r),r},checks:[]}))}function ni(e,t){if(!Hr(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 Yr(e,Mr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return jr(this,`shape`,n),n}}))}function ri(e,t){if(!Hr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Yr(e,Mr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return jr(this,`shape`,n),n}}))}function ii(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Yr(e,Mr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return jr(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ai(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 Yr(t,Mr(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 jr(this,`shape`,i),i},checks:[]}))}function oi(e,t,n){return Yr(t,Mr(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 jr(this,`shape`,i),i}}))}function si(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 ci(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 li(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ui(e){return typeof e==`string`?e:e?.message}function di(e,t,n){let r=e.message?e.message:ui(e.inst?._zod.def?.error?.(e))??ui(t?.error?.(e))??ui(n.customError?.(e))??ui(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 fi(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function pi(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function W(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 mi(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function hi(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function gi(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 _i(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function vi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return gi(t+`=`.repeat((4-t.length%4)%4))}function yi(e){return _i(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function bi(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 xi(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var Si=class{constructor(...e){}},Ci=(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,wr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wi=z(`$ZodError`,Ci),Ti=z(`$ZodError`,Ci,{Parent:Error});function Ei(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 Di(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 Oi(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??(r.properties={}),(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??(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 ki(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 Ai(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 ${ki(e.path)}`);return t.join(`
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{a as n,i as r,r as i}from"./bundle-mjs-CSP5ngA5.js";import{$n as a,$t as o,B as s,Bn as c,Bt as l,C as u,Cn as d,Ct as f,Dt as p,E as m,En as h,Et as g,F as _,G as v,Gn as y,H as b,I as x,J as S,L as C,Lt as w,M as T,O as E,Pt as D,Q as ee,Qn as O,R as k,Rn as te,S as A,Sn as ne,St as j,Tt as re,U as ie,Un as ae,V as oe,Vn as se,W as ce,X as le,Xn as ue,Xt as de,Yn as fe,Yt as M,Z as pe,_ as me,an as he,ar as ge,b as _e,bn as ve,c as ye,cr as be,d as xe,dn as Se,dr as Ce,en as we,f as Te,fn as Ee,g as De,gt as Oe,h as ke,hn as Ae,in as je,ir as Me,it as Ne,j as Pe,k as Fe,l as Ie,ln as Le,m as Re,nr as ze,on as Be,or as Ve,p as He,pn as Ue,q as We,sr as Ge,tn as Ke,u as qe,un as Je,v as Ye,vn as Xe,vt as Ze,w as N,wn as Qe,xn as $e,y as et,yn as tt,z as nt,zn as rt,zt as it}from"./vscode-tfEHsPTc.js";import{A as at,C as ot,D as st,E as ct,F as lt,I as ut,L as dt,M as ft,N as pt,O as mt,P as ht,R as gt,S as _t,T as vt,_ as yt,a as bt,b as xt,c as St,d as Ct,f as wt,g as Tt,h as Et,i as Dt,j as Ot,k as kt,l as At,n as jt,p as Mt,r as Nt,s as Pt,t as P,u as Ft,v as It,w as Lt,x as Rt,y as zt}from"./label-CFn0VYsb.js";import{a as Bt,i as Vt,n as Ht,o as Ut,r as Wt,t as Gt}from"./switch-1OAUgxzd.js";import{a as Kt,i as qt,n as Jt,r as Yt,t as F}from"./desktop-client-Cc9yU7GV.js";import{l as Xt}from"./DialogTitle-jgZKJpfs.js";import{O as Zt,_ as Qt,a as $t,b as en,c as tn,g as nn,h as I,i as rn,m as an,n as on,o as sn,r as cn,s as ln,t as un,v as dn,w as fn,x as pn,y as mn}from"./index-D_uZQMMw.js";var hn=C(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),gn=C(`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`}]]),_n=C(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),vn=C(`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`}]]),yn=C(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),bn=C(`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`}]]),xn=C(`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`}]]),Sn=C(`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`}]]),Cn=C(`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`}]]),wn=C(`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`}]]),Tn=C(`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`}]]),En=C(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Dn=C(`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`}]]),On=C(`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`}]]),L=e(n(),1),kn=L.createContext({disabled:!1});function An(){return L.useContext(kn)}var R=i();function jn(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 Mn(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 Nn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function Pn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function Fn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function In(e){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Ln(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Rn(e,t){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function zn(){return await F.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function Bn(){let[e,t]=(0,L.useState)(`overview`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)([]),[f,p]=(0,L.useState)(!0),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)([]),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(0),[T,E]=(0,L.useState)([]),[D,ee]=(0,L.useState)(!1),[O,te]=(0,L.useState)(null),[A,ne]=(0,L.useState)(!1),j=u.find(e=>e.active)??null,re=(0,L.useCallback)(()=>{a(null),s(null),l(null),d([]),_([]),C(!1),x(null),E([]),ne(!1),te(null)},[]),ie=(0,L.useCallback)(async()=>{p(!0),h(null);try{let[e,t,n]=await Promise.all([Nn(),Pn(),Fn()]),r=n.find(e=>e.active)??null,i=r?await In(r.organizationId):null;a(e),s(t),l(i),d(n)}catch(e){re();let t=jn(e).message;h(t)}finally{p(!1)}},[re]);(0,L.useEffect)(()=>{ie()},[ie]);let ae=async()=>{r(`sign-in`),h(null);try{await F.invoke(`run_provider_oauth_login`,{provider:`cline`}),await ie(),t(`overview`)}catch(e){let t=jn(e).message;h(t),re()}finally{r(null)}},oe=async()=>{r(`sign-out`);try{await F.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),re(),t(`overview`),h(`No Cline account auth token found`)}catch(e){let t=jn(e).message;h(t)}finally{r(null)}},se=(0,L.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=j?await Rn(j.organizationId,j.memberId):await Ln();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=jn(t).message;x(n)}finally{w.current===e&&y(!1)}},[j]);(0,L.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[j?.organizationId]),(0,L.useEffect)(()=>{e===`usage`&&!S&&se()},[e,S,se]);let ce=(0,L.useCallback)(async()=>{ee(!0),te(null);try{let e=await zn();E(e),ne(!0)}catch(e){let t=jn(e).message;te(t)}finally{ee(!1)}},[]);(0,L.useEffect)(()=>{e===`billing`&&!A&&ce()},[e,A,ce]);let le=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ue=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),de=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),fe=j?c?.balance??o?.balance??null:o?.balance??null,M=[`overview`,`usage`,`billing`],pe=(e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,R.jsx)(vn,{className:`h-8 w-8 text-destructive`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,R.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,R.jsx)(qt,{className:`h-4 w-4`}),`Retry`]})]}),me=()=>(0,R.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,R.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(Zt,{className:`h-6 w-6`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,R.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,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsxs)(N,{disabled:n!==null,onClick:()=>void ae(),type:`button`,children:[n===`sign-in`?(0,R.jsx)(Bt,{className:`h-4 w-4 animate-spin`}):(0,R.jsx)(wn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,R.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,R.jsx)(Kt,{className:`h-4 w-4`})]})]})]})}),he=()=>(0,R.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,R.jsx)(Bt,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,R.jsxs)(sn,{children:[(0,R.jsx)(ln,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,R.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:M.map(n=>{let r=!i&&n!==`overview`;return(0,R.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:k(`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,R.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[f&&he(),m&&(Mn(m)?me():pe(m,ie)),!f&&!m&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,R.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,le(i.createdAt)]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.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,R.jsx)(Kt,{className:`h-3.5 w-3.5`})]}),(0,R.jsxs)(N,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void oe(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,R.jsx)(Bt,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(Tn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),fe!==null&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(bn,{className:`h-5 w-5 text-primary`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:j?`${j.name} Balance`:`Credits Balance`})]}),(0,R.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,R.jsx)(ht,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,R.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,R.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,de(fe)]})}),j&&o&&(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,de(o.balance),` `,`credits`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(gn,{className:`h-5 w-5 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,R.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,R.jsx)(ht,{className:`h-3.5 w-3.5`}),`Create`]})]}),u.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,R.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,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:j?`Recent API usage and token consumption for ${j.name}.`:`Recent API usage and token consumption across all providers.`}),v&&he(),b&&pe(b,se),!v&&!b&&S&&(g.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.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,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:g.map(e=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,R.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,R.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:de(e.creditsUsed)}),(0,R.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:le(e.createdAt)}),(0,R.jsx)(`p`,{children:ue(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),D&&he(),O&&pe(O,ce),!D&&!O&&A&&(T.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.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,R.jsx)(`span`,{children:`Date`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(On,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-foreground`,children:le(e.paidAt)})]}),(0,R.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,R.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,de(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Vn=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Hn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,L.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(null),h=(0,L.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),g=n.includes(h),v=r.models.length>0,y=r.modelsSourceUrl.trim().length>0,b=h.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(v||y)&&!g,x=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)}))},S=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},C=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},w=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},T=(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}))},E=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},D=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},ee=async()=>{if(!(!b||d)){f(!0),m(null);try{await t({providerId:h,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){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}};return(0,R.jsxs)(sn,{contentClassName:`max-w-4xl`,children:[(0,R.jsx)(ln,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,R.jsxs)(N,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,R.jsx)(hn,{className:`h-4 w-4`}),`Providers`]})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,R.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,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),g?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,R.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,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,R.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,R.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,R.jsx)(`span`,{className:`font-mono`,children:e}),(0,R.jsx)(N,{onClick:()=>S(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,R.jsx)(pt,{className:`h-3 w-3`})})]},e)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:x,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,R.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,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,R.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,R.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.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,R.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,R.jsx)(N,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,R.jsx)(xn,{className:`h-4 w-4`}):(0,R.jsx)(Sn,{className:`h-4 w-4`})}),(0,R.jsx)(N,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,R.jsx)(Ut,{className:`h-4 w-4`})})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(P,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Vn.map(e=>(0,R.jsx)(N,{onClick:()=>C(e),className:k(`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,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(N,{onClick:()=>u(!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,R.jsx)(dt,{className:k(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,R.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(P,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,value:e,onChange:t=>T(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,R.jsx)(`input`,{type:`text`,value:t,onChange:t=>E(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,R.jsx)(N,{onClick:()=>D(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,R.jsx)(_,{className:`h-4 w-4`})})]},e)),(0,R.jsxs)(N,{onClick:w,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,R.jsx)(ht,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),p?(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:p}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,R.jsx)(N,{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,R.jsx)(N,{onClick:()=>void ee(),disabled:!b||d,className:k(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,b&&!d?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:d?`Saving...`:`Add Provider`})]})]})]})}function Un(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Wn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Gn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Kn(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 qn(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Jn(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 Yn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Xn(e){let t=e[0];return{channelId:t?.id??``,values:Yn(t),securityEnabled:!1,securityValues:{}}}function Zn(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[m,h]=(0,L.useState)(null),[g,v]=(0,L.useState)(null),y=(0,L.useMemo)(()=>e.find(e=>e.id===f.channelId),[e,f.channelId]),b=(0,L.useMemo)(()=>{let e={...Yn(y),...f.values};return(y?.fields??[]).filter(t=>Jn(t,e))},[y,f.values]),x=(0,L.useCallback)(e=>{t(e.available),r(e.active),p(t=>t.channelId?t:Xn(e.available))},[]),S=(0,L.useCallback)(async()=>{a(!0),l(null);try{let e=await F.invoke(`list_connector_channels`);x(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[x]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{S()},0);return()=>window.clearTimeout(e)},[S]);let C=()=>{p(Xn(e)),h(null),d(!0)},w=(e,t)=>{p(n=>({...n,values:{...n.values,[e]:t}}))},T=(e,t)=>{p(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},E=async()=>{if(!y){h(`Choose a channel`);return}for(let e of y.fields)if(b.includes(e)&&e.required&&!f.values[e.flag]?.trim()){h(`${e.label} is required`);return}if(f.securityEnabled&&y.security){for(let e of y.security.fields)if(!f.securityValues[e.key]?.trim()){h(e.requiredMessage);return}}s(y.id),h(null),l(null);try{let e=await F.invoke(`start_connector_channel`,{channel:y.id,values:f.values,security:{enabled:f.securityEnabled,values:f.securityValues}});x(e),d(!1)}catch(e){let t=e instanceof Error?e.message:String(e);h(t)}finally{s(null)}},D=async e=>{s(e.type),l(null);try{let t=await F.invoke(`stop_connector_channel`,{channel:e.type});x(t),v(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,R.jsxs)(sn,{children:[(0,R.jsx)(ln,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,R.jsx)(rn,{children:`cline connect`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{disabled:i,onClick:()=>void S(),size:`sm`,type:`button`,variant:`outline`,children:(0,R.jsx)(qt,{className:k(`size-4`,i&&`animate-spin`)})}),(0,R.jsxs)(N,{disabled:e.length===0,onClick:C,size:`sm`,type:`button`,children:[(0,R.jsx)(ht,{className:`size-4`}),`Add Channel`]})]})}),c?(0,R.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,R.jsx)($t,{children:`Loading channels...`}):n.length===0?(0,R.jsx)($t,{children:`No channels connected.`}):(0,R.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,R.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(ut,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,R.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:Un(t,e)}),(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Wn(t)})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,R.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,R.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,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Gn(t.startedAt)}),t.connectionMode?(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,R.jsxs)(N,{disabled:o===t.type,onClick:()=>v(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,R.jsx)(_,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,R.jsx)(St,{open:u,onOpenChange:d,children:(0,R.jsxs)(At,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,R.jsxs)(wt,{children:[(0,R.jsx)(Mt,{children:`Add Channel`}),(0,R.jsx)(Ft,{children:`Start a connector channel for Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{children:`Channel`}),(0,R.jsxs)(Et,{onValueChange:t=>{t&&p({channelId:t,values:Yn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:f.channelId,children:[(0,R.jsx)(It,{children:(0,R.jsx)(zt,{placeholder:`Select channel`})}),(0,R.jsx)(Tt,{children:e.map(e=>(0,R.jsx)(yt,{value:e.id,children:e.name},e.id))})]})]}),b.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(P,{children:[e.label,e.required?(0,R.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,R.jsxs)(Et,{onValueChange:t=>{t&&w(e.flag,t)},value:f.values[e.flag]??e.initialValue??``,children:[(0,R.jsx)(It,{children:(0,R.jsx)(zt,{placeholder:e.placeholder})}),(0,R.jsx)(Tt,{children:e.options.map(e=>(0,R.jsx)(yt,{value:e.value,children:e.label},e.value))})]}):qn(e)?(0,R.jsx)(Pt,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:f.values[e.flag]??``}):(0,R.jsx)(ye,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,type:Kn(e)?`password`:`text`,value:f.values[e.flag]??``})]},e.flag)),y?.security?(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(P,{className:`text-sm`,children:`Restrict access`}),(0,R.jsx)(Gt,{checked:f.securityEnabled,onCheckedChange:e=>p(t=>({...t,securityEnabled:e}))})]}),f.securityEnabled?y.security.fields.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{children:e.label}),(0,R.jsx)(ye,{onChange:t=>T(e.key,t.target.value),placeholder:e.placeholder,type:Kn(e)?`password`:`text`,value:f.securityValues[e.key]??``})]},e.key)):null]}):null,m?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:m}):null]}),(0,R.jsxs)(Ct,{children:[(0,R.jsx)(N,{disabled:o!==null,onClick:()=>d(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,R.jsx)(N,{disabled:o!==null||!y,onClick:()=>void E(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,R.jsx)(an,{open:g!==null,onOpenChange:e=>{e||v(null)},children:(0,R.jsxs)(Qt,{children:[(0,R.jsxs)(en,{children:[(0,R.jsx)(pn,{children:`Remove Channel`}),(0,R.jsxs)(dn,{children:[`Confirm that you want to stop the active`,` `,g?Un(g,e):`channel`,` `,`channel for `,g?Wn(g):``,`.`]})]}),(0,R.jsxs)(mn,{children:[(0,R.jsx)(nn,{disabled:o!==null,children:`Cancel`}),(0,R.jsx)(I,{disabled:o!==null||!g,onClick:()=>{g&&D(g)},variant:`destructive`,children:`Remove`})]})]})})]})}function Qn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function $n(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 er(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function tr(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function nr(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 rr(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:nr(e?.env),url:e?.url??``,headersText:er(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function ir(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(!1),[g,v]=(0,L.useState)(`create`),[y,b]=(0,L.useState)(()=>rr()),[x,S]=(0,L.useState)(null),[C,w]=(0,L.useState)(null),T=(0,L.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),E=(0,L.useCallback)(async()=>{s(!0),d(null);try{let e=await F.invoke(`list_mcp_servers`);T(e)}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{s(!1)}},[T]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{E()},0);return()=>window.clearTimeout(e)},[E]);let D=async(e,t)=>{p(e.name),d(null);try{let n=await F.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});T(n)}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{p(null)}},ee=async e=>{p(e.previousName??e.name),d(null);try{let t=await F.invoke(`upsert_mcp_server`,{input:e});T(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw d(t),e}finally{p(null)}},O=async e=>{p(e),d(null);try{let t=await F.invoke(`delete_mcp_server`,{name:e});T(t)}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{p(null)}},te=(0,L.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:$n(e.headersText),disabled:e.disabled,metadata:i}},[]),A=()=>{v(`create`),b(rr()),S(null),h(!0)},ne=e=>{v(`edit`),b(rr(e)),S(null),h(!0)},j=async()=>{S(null);try{let e=te(y);await ee(e),h(!1)}catch(e){S(e instanceof Error?e.message:String(e))}},re=async()=>{l(!0),d(null);try{let e=await F.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);d(t)}finally{l(!1)}},ie=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),ae=(e,t,n)=>{b(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},oe=()=>{b(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},se=e=>{b(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,R.jsxs)(sn,{children:[(0,R.jsx)(ln,{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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(rn,{children:`cline config mcp`}),(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void E(),disabled:o,children:(0,R.jsx)(qt,{className:k(`h-4 w-4`,o&&`animate-spin`)})}),(0,R.jsxs)(N,{size:`sm`,onClick:A,children:[(0,R.jsx)(ht,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,R.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`MCP settings path:`}),(0,R.jsx)(N,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void re(),disabled:c,children:n||`Open settings file`})]}),u&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:u}),o?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):ie.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:ie.map(e=>{let t=f===e.name;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(ut,{className:k(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ne(e),disabled:t,children:(0,R.jsx)(Xt,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>w(e),disabled:t,children:(0,R.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(Gt,{checked:!e.disabled,onCheckedChange:t=>D(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,tr(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,er(e.headers)]})]})]},e.name)})}),(0,R.jsx)(St,{open:m,onOpenChange:e=>{h(e),e||S(null)},children:(0,R.jsxs)(At,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(wt,{children:[(0,R.jsx)(Mt,{children:g===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,R.jsxs)(Ft,{children:[`Update the MCP server stored in`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-name`,children:`Server name`}),(0,R.jsx)(ye,{id:`mcp-name`,value:y.name,onChange:e=>b(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{children:`Transport type`}),(0,R.jsxs)(Et,{value:y.transportType,onValueChange:e=>b(t=>({...t,transportType:e})),children:[(0,R.jsx)(It,{className:`w-full`,children:(0,R.jsx)(zt,{placeholder:`Select transport`})}),(0,R.jsxs)(Tt,{children:[(0,R.jsx)(yt,{value:`stdio`,children:`stdio`}),(0,R.jsx)(yt,{value:`sse`,children:`sse`}),(0,R.jsx)(yt,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),y.transportType===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(ye,{id:`mcp-command`,value:y.command,onChange:e=>b(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-args`,children:`Args`}),(0,R.jsx)(Pt,{id:`mcp-args`,value:y.argsText,onChange:e=>b(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,R.jsx)(ye,{id:`mcp-cwd`,value:y.cwd,onChange:e=>b(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(P,{children:`Environment variables`}),(0,R.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:oe,children:(0,R.jsx)(ht,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:y.envEntries.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(N,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>se(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,R.jsx)(En,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(ye,{value:e.key,onChange:t=>ae(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,R.jsx)(ye,{type:`password`,value:e.value,onChange:t=>ae(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-url`,children:`Server URL`}),(0,R.jsx)(ye,{id:`mcp-url`,value:y.url,onChange:e=>b(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-headers`,children:`Headers`}),(0,R.jsx)(Pt,{id:`mcp-headers`,value:y.headersText,onChange:e=>b(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(P,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,R.jsx)(Pt,{id:`mcp-metadata`,value:y.metadataText,onChange:e=>b(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,R.jsx)(Gt,{checked:!y.disabled,onCheckedChange:e=>b(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),x?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:x}):null]}),(0,R.jsxs)(Ct,{children:[(0,R.jsx)(N,{variant:`outline`,onClick:()=>h(!1),disabled:f!==null,children:`Cancel`}),(0,R.jsx)(N,{onClick:()=>void j(),disabled:f!==null,children:f===null?g===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,R.jsx)(an,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,R.jsxs)(Qt,{children:[(0,R.jsxs)(en,{children:[(0,R.jsx)(pn,{children:`Delete MCP Server`}),(0,R.jsx)(dn,{children:C?`Delete MCP server "${C.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,R.jsxs)(mn,{children:[(0,R.jsx)(nn,{disabled:f!==null,children:`Cancel`}),(0,R.jsx)(I,{disabled:f!==null||!C,onClick:()=>{C&&(O(C.name),w(null))},children:`Delete`})]})]})})]})}function ar(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 or(e){return e==null?``:String(e)}function sr(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 cr({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),u=e.filter(e=>e.enabled).length,d=c.trim().toLowerCase(),f=d?e.filter(e=>e.name.toLowerCase().includes(d)):e,p=a===`panel`;return(0,R.jsx)(tn,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:k(`py-10 max-[720px]:px-4 max-[720px]:py-5`,p?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:k(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,p?`max-w-none`:`max-w-[42rem]`),children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:k(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,p?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,R.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 · `,u,` `,`enabled`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,R.jsx)(N,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,R.jsx)(Wt,{className:`size-4`})}),(0,R.jsxs)(N,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,R.jsx)(yn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,R.jsx)(`div`,{className:k(`mb-4`,p?`max-w-none`:`max-w-[42rem]`),children:(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,R.jsx)(Wt,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(ye,{"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,R.jsxs)(`div`,{className:k(`overflow-hidden`,p?`max-w-none`:`max-w-[42rem]`),children:[f.length===0?(0,R.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,f.map(e=>(0,R.jsxs)(`div`,{className:k(`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,R.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,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,R.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,R.jsx)(Gt,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,R.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,R.jsx)(_n,{className:`size-4`})})]},e.id))]})]})})}function lr({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,u]=(0,L.useState)({}),[d,f]=(0,L.useState)(()=>ar(e)),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=(0,L.useRef)(void 0),v=e.configFields??[],y=or(d.apiKey),b=e.modelList??[],x=p?.providerId===e.id?p.value:``,S=h?.providerId===e.id?h.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,L.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=sr(e,t),i={...d,[e.path]:r};f(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=or(r)),e.path===`baseUrl`&&(a.baseUrl=or(r)),n(a)},D=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{g({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>g(null),1600)})};return(0,R.jsx)(tn,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:k(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,R.jsx)(N,{"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,R.jsx)(pt,{className:`h-4 w-4`}):(0,R.jsx)(hn,{className:`h-4 w-4`})}),(0,R.jsx)(`h1`,{className:k(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,R.jsx)(`section`,{className:k(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,R.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=d[e.path],n=or(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,R.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,R.jsxs)(`header`,{children:[(0,R.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,R.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,R.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,R.jsx)(Gt,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,R.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,R.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,R.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,R.jsx)(fn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,R.jsx)(ye,{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=>f(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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>u(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,R.jsx)(xn,{className:`h-4 w-4`}):(0,R.jsx)(Sn,{className:`h-4 w-4`})}),(0,R.jsx)(N,{"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,R.jsx)(Ut,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,R.jsx)(`div`,{className:`mb-8`,children:(0,R.jsxs)(N,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,R.jsx)(Bt,{className:`h-4 w-4 animate-spin`}):null,(0,R.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,R.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,R.jsxs)(`section`,{className:k(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,R.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(Wt,{className:`size-4 text-muted-foreground`}),(0,R.jsx)(N,{"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,R.jsx)(qt,{className:k(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,R.jsx)(Wt,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(ye,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>m({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,R.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,R.jsx)(`div`,{title:`File Support`,children:(0,R.jsx)(Cn,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,R.jsx)(`div`,{title:`Image Support`,children:(0,R.jsx)(lt,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,R.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:()=>D(e.id),title:`Copy model ID`,type:`button`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,R.jsx)(Ut,{className:`size-3 shrink-0`}),S===e.id?(0,R.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,R.jsx)(N,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,R.jsx)(Yt,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var ur,dr=Object.freeze({status:`aborted`});function z(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 fr=Symbol(`zod_brand`),pr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},mr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ur=globalThis).__zod_globalConfig??(ur.__zod_globalConfig={});var hr=globalThis.__zod_globalConfig;function gr(e){return e&&Object.assign(hr,e),hr}var _r=t({BIGINT_FORMAT_RANGES:()=>$r,Class:()=>Si,NUMBER_FORMAT_RANGES:()=>Qr,aborted:()=>si,allowsEval:()=>Vr,assert:()=>Sr,assertEqual:()=>vr,assertIs:()=>br,assertNever:()=>xr,assertNotEqual:()=>yr,assignProp:()=>jr,base64ToUint8Array:()=>gi,base64urlToUint8Array:()=>vi,cached:()=>Tr,captureStackTrace:()=>zr,cleanEnum:()=>hi,cleanRegex:()=>Dr,clone:()=>Yr,cloneDef:()=>Nr,createTransparentProxy:()=>Xr,defineLazy:()=>V,esc:()=>Lr,escapeRegex:()=>Jr,explicitlyAborted:()=>ci,extend:()=>ni,finalizeIssue:()=>di,floatSafeRemainder:()=>Or,getElementAtPath:()=>Pr,getEnumValues:()=>Cr,getLengthableOrigin:()=>pi,getParsedType:()=>Gr,getSizableOrigin:()=>fi,hexToUint8Array:()=>bi,isObject:()=>Br,isPlainObject:()=>Hr,issue:()=>mi,joinValues:()=>B,jsonStringifyReplacer:()=>wr,merge:()=>ii,mergeDefs:()=>Mr,normalizeParams:()=>H,nullish:()=>Er,numKeys:()=>Wr,objectClone:()=>Ar,omit:()=>ti,optionalKeys:()=>Zr,parsedType:()=>W,partial:()=>ai,pick:()=>ei,prefixIssues:()=>li,primitiveTypes:()=>qr,promiseAllObject:()=>Fr,propertyKeyTypes:()=>Kr,randomString:()=>Ir,required:()=>oi,safeExtend:()=>ri,shallowClone:()=>Ur,slugify:()=>Rr,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>_i,uint8ArrayToBase64url:()=>yi,uint8ArrayToHex:()=>xi,unwrapMessage:()=>ui});function vr(e){return e}function yr(e){return e}function br(e){}function xr(e){throw Error(`Unexpected value in exhaustive check`)}function Sr(e){}function Cr(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 B(e,t=`|`){return e.map(e=>U(e)).join(t)}function wr(e,t){return typeof t==`bigint`?t.toString():t}function Tr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Er(e){return e==null}function Dr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Or(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 kr=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==kr)return r===void 0&&(r=kr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ar(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function jr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Mr(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Nr(e){return Mr(e._zod.def)}function Pr(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function Fr(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 Ir(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Lr(e){return JSON.stringify(e)}function Rr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var zr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Br(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Vr=Tr(()=>{if(hr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Hr(e){if(Br(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Br(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ur(e){return Hr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Wr(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Gr=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}`)}},Kr=new Set([`string`,`number`,`symbol`]),qr=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Jr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Yr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(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 Xr(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 U(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Zr(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]},$r={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ei(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 Yr(e,Mr(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 jr(this,`shape`,e),e},checks:[]}))}function ti(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 Yr(e,Mr(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 jr(this,`shape`,r),r},checks:[]}))}function ni(e,t){if(!Hr(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 Yr(e,Mr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return jr(this,`shape`,n),n}}))}function ri(e,t){if(!Hr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Yr(e,Mr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return jr(this,`shape`,n),n}}))}function ii(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Yr(e,Mr(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return jr(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ai(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 Yr(t,Mr(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 jr(this,`shape`,i),i},checks:[]}))}function oi(e,t,n){return Yr(t,Mr(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 jr(this,`shape`,i),i}}))}function si(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 ci(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 li(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ui(e){return typeof e==`string`?e:e?.message}function di(e,t,n){let r=e.message?e.message:ui(e.inst?._zod.def?.error?.(e))??ui(t?.error?.(e))??ui(n.customError?.(e))??ui(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 fi(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function pi(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function W(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 mi(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function hi(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function gi(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 _i(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function vi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return gi(t+`=`.repeat((4-t.length%4)%4))}function yi(e){return _i(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function bi(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 xi(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var Si=class{constructor(...e){}},Ci=(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,wr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wi=z(`$ZodError`,Ci),Ti=z(`$ZodError`,Ci,{Parent:Error});function Ei(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 Di(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 Oi(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??(r.properties={}),(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??(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 ki(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 Ai(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 ${ki(e.path)}`);return t.join(`
|
|
2
2
|
`)}var ji=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 pr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>di(e,a,gr())));throw zr(t,i?.callee),t}return o.value},Mi=ji(Ti),Ni=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=>di(e,a,gr())));throw zr(t,i?.callee),t}return o.value},Pi=Ni(Ti),Fi=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 pr;return a.issues.length?{success:!1,error:new(e??wi)(a.issues.map(e=>di(e,i,gr())))}:{success:!0,data:a.value}},Ii=Fi(Ti),Li=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=>di(e,i,gr())))}:{success:!0,data:a.value}},Ri=Li(Ti),zi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ji(e)(t,n,i)},Bi=zi(Ti),Vi=e=>(t,n,r)=>ji(e)(t,n,r),Hi=Vi(Ti),Ui=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ni(e)(t,n,i)},Wi=Ui(Ti),Gi=e=>async(t,n,r)=>Ni(e)(t,n,r),Ki=Gi(Ti),qi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Fi(e)(t,n,i)},Ji=qi(Ti),Yi=e=>(t,n,r)=>Fi(e)(t,n,r),Xi=Yi(Ti),Zi=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Li(e)(t,n,i)},Qi=Zi(Ti),$i=e=>async(t,n,r)=>Li(e)(t,n,r),ea=$i(Ti),ta=t({base64:()=>Oa,base64url:()=>ka,bigint:()=>Ba,boolean:()=>Ua,browserEmail:()=>ba,cidrv4:()=>Ea,cidrv6:()=>Da,cuid:()=>na,cuid2:()=>ra,date:()=>Fa,datetime:()=>Ra,domain:()=>ja,duration:()=>ca,e164:()=>Na,email:()=>ha,emoji:()=>Sa,extendedDuration:()=>la,guid:()=>ua,hex:()=>Ja,hostname:()=>Aa,html5Email:()=>ga,httpProtocol:()=>Ma,idnEmail:()=>ya,integer:()=>Va,ipv4:()=>Ca,ipv6:()=>wa,ksuid:()=>oa,lowercase:()=>Ka,mac:()=>Ta,md5_base64:()=>Qa,md5_base64url:()=>$a,md5_hex:()=>Za,nanoid:()=>sa,null:()=>Wa,number:()=>Ha,rfc5322Email:()=>_a,sha1_base64:()=>to,sha1_base64url:()=>no,sha1_hex:()=>eo,sha256_base64:()=>io,sha256_base64url:()=>ao,sha256_hex:()=>ro,sha384_base64:()=>so,sha384_base64url:()=>co,sha384_hex:()=>oo,sha512_base64:()=>uo,sha512_base64url:()=>fo,sha512_hex:()=>lo,string:()=>za,time:()=>La,ulid:()=>ia,undefined:()=>Ga,unicodeEmail:()=>va,uppercase:()=>qa,uuid:()=>da,uuid4:()=>fa,uuid6:()=>pa,uuid7:()=>ma,xid:()=>aa}),na=/^[cC][0-9a-z]{6,}$/,ra=/^[0-9a-z]+$/,ia=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,aa=/^[0-9a-vA-V]{20}$/,oa=/^[A-Za-z0-9]{27}$/,sa=/^[a-zA-Z0-9_-]{21}$/,ca=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,la=/^[-+]?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)?)??$/,ua=/^([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})$/,da=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)$/,fa=da(4),pa=da(6),ma=da(7),ha=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ga=/^[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])?)*$/,_a=/^(([^<>()\[\]\\.,;:\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,}))$/,va=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,ya=va,ba=/^[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])?)*$/,xa=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Sa(){return new RegExp(xa,`u`)}var Ca=/^(?:(?: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])$/,wa=/^(([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}|:))$/,Ta=e=>{let t=Jr(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Ea=/^((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])$/,Da=/^(([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])$/,Oa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ka=/^[A-Za-z0-9_-]*$/,Aa=/^(?=.{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])?)*\.?$/,ja=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Ma=/^https?$/,Na=/^\+[1-9]\d{6,14}$/,Pa=`(?:(?:\\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])))`,Fa=RegExp(`^${Pa}$`);function Ia(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 La(e){return RegExp(`^${Ia(e)}$`)}function Ra(e){let t=Ia({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(`^${Pa}T(?:${r})$`)}var za=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ba=/^-?\d+n?$/,Va=/^-?\d+$/,Ha=/^-?\d+(?:\.\d+)?$/,Ua=/^(?:true|false)$/i,Wa=/^null$/i,Ga=/^undefined$/i,Ka=/^[^A-Z]*$/,qa=/^[^a-z]*$/,Ja=/^[0-9a-fA-F]*$/;function Ya(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Xa(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Za=/^[0-9a-fA-F]{32}$/,Qa=Ya(22,`==`),$a=Xa(22),eo=/^[0-9a-fA-F]{40}$/,to=Ya(27,`=`),no=Xa(27),ro=/^[0-9a-fA-F]{64}$/,io=Ya(43,`=`),ao=Xa(43),oo=/^[0-9a-fA-F]{96}$/,so=Ya(64,``),co=Xa(64),lo=/^[0-9a-fA-F]{128}$/,uo=Ya(86,`==`),fo=Xa(86),po=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mo={number:`number`,bigint:`bigint`,object:`date`},ho=z(`$ZodCheckLessThan`,(e,t)=>{po.init(e,t);let n=mo[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})}}),go=z(`$ZodCheckGreaterThan`,(e,t)=>{po.init(e,t);let n=mo[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})}}),_o=z(`$ZodCheckMultipleOf`,(e,t)=>{po.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):Or(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})}}),vo=z(`$ZodCheckNumberFormat`,(e,t)=>{po.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=Va)}),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})}}),yo=z(`$ZodCheckBigIntFormat`,(e,t)=>{po.init(e,t);let[n,r]=$r[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})}}),bo=z(`$ZodCheckMaxSize`,(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Er(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:fi(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xo=z(`$ZodCheckMinSize`,(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Er(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:fi(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),So=z(`$ZodCheckSizeEquals`,(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Er(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:fi(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})}}),Co=z(`$ZodCheckMaxLength`,(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Er(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=pi(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wo=z(`$ZodCheckMinLength`,(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Er(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=pi(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),To=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Er(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=pi(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})}}),Eo=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;po.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=()=>{})}),Do=z(`$ZodCheckRegex`,(e,t)=>{Eo.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})}}),Oo=z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ka,Eo.init(e,t)}),ko=z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=qa,Eo.init(e,t)}),Ao=z(`$ZodCheckIncludes`,(e,t)=>{po.init(e,t);let n=Jr(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})}}),jo=z(`$ZodCheckStartsWith`,(e,t)=>{po.init(e,t);let n=RegExp(`^${Jr(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})}}),Mo=z(`$ZodCheckEndsWith`,(e,t)=>{po.init(e,t);let n=RegExp(`.*${Jr(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 No(e,t,n){e.issues.length&&t.issues.push(...li(n,e.issues))}var Po=z(`$ZodCheckProperty`,(e,t)=>{po.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=>No(n,e,t.property));No(n,e,t.property)}}),Fo=z(`$ZodCheckMimeType`,(e,t)=>{po.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})}}),Io=z(`$ZodCheckOverwrite`,(e,t)=>{po.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Lo=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
|
`))}},Ro={major:4,minor:4,patch:3},G=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ro;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=si(e),i;for(let a of t){if(a._zod.def.when){if(ci(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 pr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=si(e,t))});else{if(e.issues.length===t)continue;r||=si(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(si(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new pr;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 pr;return o.then(e=>t(e,r,a))}return t(o,r,a)}}V(e,`~standard`,()=>({validate:t=>{try{let n=Ii(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ri(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),zo=z(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??za(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}}),Bo=z(`$ZodStringFormat`,(e,t)=>{Eo.init(e,t),zo.init(e,t)}),Vo=z(`$ZodGUID`,(e,t)=>{t.pattern??=ua,Bo.init(e,t)}),Ho=z(`$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??=da(e)}else t.pattern??=da();Bo.init(e,t)}),Uo=z(`$ZodEmail`,(e,t)=>{t.pattern??=ha,Bo.init(e,t)}),Wo=z(`$ZodURL`,(e,t)=>{Bo.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Ma.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})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Go=z(`$ZodEmoji`,(e,t)=>{t.pattern??=Sa(),Bo.init(e,t)}),Ko=z(`$ZodNanoID`,(e,t)=>{t.pattern??=sa,Bo.init(e,t)}),qo=z(`$ZodCUID`,(e,t)=>{t.pattern??=na,Bo.init(e,t)}),Jo=z(`$ZodCUID2`,(e,t)=>{t.pattern??=ra,Bo.init(e,t)}),Yo=z(`$ZodULID`,(e,t)=>{t.pattern??=ia,Bo.init(e,t)}),Xo=z(`$ZodXID`,(e,t)=>{t.pattern??=aa,Bo.init(e,t)}),Zo=z(`$ZodKSUID`,(e,t)=>{t.pattern??=oa,Bo.init(e,t)}),Qo=z(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ra(t),Bo.init(e,t)}),$o=z(`$ZodISODate`,(e,t)=>{t.pattern??=Fa,Bo.init(e,t)}),es=z(`$ZodISOTime`,(e,t)=>{t.pattern??=La(t),Bo.init(e,t)}),ts=z(`$ZodISODuration`,(e,t)=>{t.pattern??=ca,Bo.init(e,t)}),ns=z(`$ZodIPv4`,(e,t)=>{t.pattern??=Ca,Bo.init(e,t),e._zod.bag.format=`ipv4`}),rs=z(`$ZodIPv6`,(e,t)=>{t.pattern??=wa,Bo.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})}}}),is=z(`$ZodMAC`,(e,t)=>{t.pattern??=Ta(t.delimiter),Bo.init(e,t),e._zod.bag.format=`mac`}),as=z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ea,Bo.init(e,t)}),os=z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Da,Bo.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 ss(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var cs=z(`$ZodBase64`,(e,t)=>{t.pattern??=Oa,Bo.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{ss(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function ls(e){if(!ka.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ss(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var us=z(`$ZodBase64URL`,(e,t)=>{t.pattern??=ka,Bo.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{ls(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ds=z(`$ZodE164`,(e,t)=>{t.pattern??=Na,Bo.init(e,t)});function fs(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 ps=z(`$ZodJWT`,(e,t)=>{Bo.init(e,t),e._zod.check=n=>{fs(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ms=z(`$ZodCustomStringFormat`,(e,t)=>{Bo.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})}}),hs=z(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ha,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}}),gs=z(`$ZodNumberFormat`,(e,t)=>{vo.init(e,t),hs.init(e,t)}),_s=z(`$ZodBoolean`,(e,t)=>{G.init(e,t),e._zod.pattern=Ua,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}}),vs=z(`$ZodBigInt`,(e,t)=>{G.init(e,t),e._zod.pattern=Ba,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}}),ys=z(`$ZodBigIntFormat`,(e,t)=>{yo.init(e,t),vs.init(e,t)}),bs=z(`$ZodSymbol`,(e,t)=>{G.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}}),xs=z(`$ZodUndefined`,(e,t)=>{G.init(e,t),e._zod.pattern=Ga,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}}),Ss=z(`$ZodNull`,(e,t)=>{G.init(e,t),e._zod.pattern=Wa,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}}),Cs=z(`$ZodAny`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),ws=z(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),Ts=z(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),Es=z(`$ZodVoid`,(e,t)=>{G.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}}),Ds=z(`$ZodDate`,(e,t)=>{G.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 Os(e,t,n){e.issues.length&&t.issues.push(...li(n,e.issues)),t.value[n]=e.value}var ks=z(`$ZodArray`,(e,t)=>{G.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=>Os(t,n,e))):Os(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function As(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...li(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 js(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=Zr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ms(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=>As(e,n,i,t,u,d))):As(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 Ns=z(`$ZodObject`,(e,t)=>{if(G.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=Tr(()=>js(t));V(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=Br,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=>As(n,t,e,s,r,i))):As(a,t,e,s,r,i)}return i?Ms(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Ps=z(`$ZodObjectJIT`,(e,t)=>{Ns.init(e,t);let n=e._zod.parse,r=Tr(()=>js(t)),i=e=>{let t=new Lo([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Lr(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=Lr(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-D_uZQMMw.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-B0Z9INg1.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/bundle-mjs-CSP5ngA5.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/vscode-tfEHsPTc.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="./assets/DialogTitle-jgZKJpfs.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-Dwkfosyp.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|