@cline/cli-windows-x64 3.0.30 → 3.0.31
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-B1-IjjcY.js +197 -0
- package/cline-hub/webview/assets/{extensions-view-Czr1F6UU.js → extensions-view-BxKh4fke.js} +1 -1
- package/cline-hub/webview/assets/{index-COgdQxvL.js → index-BGdYnZ-k.js} +2 -2
- package/cline-hub/webview/assets/{label-CWJcfOco.js → label-Mo02KX88.js} +1 -1
- package/cline-hub/webview/assets/{mermaid.core-bKbkko4L.js → mermaid.core-CiYLsDpO.js} +6 -6
- package/cline-hub/webview/assets/{settings-view-D3YT4VdK.js → settings-view-Dap2DoPb.js} +1 -1
- package/cline-hub/webview/index.html +1 -1
- package/package.json +1 -1
- package/cline-hub/webview/assets/Chat-L1CH__f4.js +0 -201
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-CPvDmBTC.js";import{t as r}from"./react-dom-hobdzdVk.js";import{$ as i,A as a,B as o,Bt as s,D as c,E as l,F as u,Ht as d,I as f,K as p,L as m,Mt as h,O as g,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as D,Y as O,Z as k,_ as A,c as j,ct as M,d as N,dt as P,et as F,f as I,ft as ee,g as L,h as te,k as ne,l as re,lt as ie,m as ae,p as oe,st as se,u as ce,v as R,w as le,x as ue,xt as de,y as z}from"./vscode-DK7ayvks.js";import{A as fe,C as pe,D as me,E as he,F as B,I as ge,M as V,N as _e,O as ve,P as H,S as ye,T as U,_ as be,a as xe,b as Se,c as Ce,d as we,f as Te,g as Ee,h as De,i as Oe,j as ke,k as Ae,l as je,n as Me,p as Ne,r as Pe,s as Fe,t as W,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./label-CWJcfOco.js";import{a as Ve,i as He,n as Ue,r as We,t as G}from"./desktop-client-Cbu3aJ5_.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./switch-O5JzNA9x.js";import{$ as Xe,B as Ze,C as Qe,Ct as $e,G as et,Mt as tt,Nt as nt,O as rt,Pt as it,Q as at,S as ot,Tt as st,W as ct,X as lt,Z as ut,_ as dt,a as ft,at as pt,b as mt,bt as K,c as ht,ct as gt,d as _t,dt as vt,et as yt,f as bt,ft as xt,g as q,gt as St,h as Ct,ht as J,i as wt,it as Tt,kt as Et,m as Dt,mt as Y,n as Ot,nt as kt,o as At,ot as jt,pt as Mt,r as Nt,rt as Pt,s as Ft,t as X,tt as It,u as Lt,v as Rt,vt as zt,w as Bt,wt as Vt,x as Ht,xt as Ut,y as Wt,yt as Gt,z as Kt}from"./index-COgdQxvL.js";var qt=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Jt=S(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),Yt=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Xt=S(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Zt=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),Qt=S(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),$t=S(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),en=S(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),tn=S(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),nn=S(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),rn=S(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),an=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),on=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),sn=S(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),Z=e(t(),1),cn=Z.createContext({disabled:!1});function ln(){return Z.useContext(cn)}var un=Z.createContext(void 0);function dn(e=!0){let t=Z.useContext(un);if(t===void 0&&!e)throw Error(s(3));return t}var Q=n();function fn(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 pn(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 mn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function hn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function gn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function _n(e){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function vn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function yn(e,t){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function bn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function xn(){let[e,t]=(0,Z.useState)(`overview`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(!0),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(0),[E,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),P=d.find(e=>e.active)??null,F=(0,Z.useCallback)(()=>{a(null),s(null),u(null),f([]),v([]),w(!1),S(null),D([]),N(!1),j(null)},[]),I=(0,Z.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([mn(),hn(),gn()]),r=n.find(e=>e.active)??null,i=r?await _n(r.organizationId):null;a(e),s(t),u(i),f(n)}catch(e){F();let t=fn(e).message;g(t)}finally{m(!1)}},[F]);(0,Z.useEffect)(()=>{I()},[I]);let ee=async()=>{r(`sign-in`),g(null);try{await G.invoke(`run_provider_oauth_login`,{provider:`cline`}),await I(),t(`overview`)}catch(e){let t=fn(e).message;g(t),F()}finally{r(null)}},L=async()=>{r(`sign-out`);try{await G.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),F(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=fn(e).message;g(t)}finally{r(null)}},te=(0,Z.useCallback)(async()=>{let e=T.current;b(!0),S(null);try{let t=P?await yn(P.organizationId,P.memberId):await vn();if(T.current!==e)return;v(t),w(!0)}catch(t){if(T.current!==e)return;let n=fn(t).message;S(n)}finally{T.current===e&&b(!1)}},[P]);(0,Z.useEffect)(()=>{T.current+=1,v([]),w(!1),S(null)},[P?.organizationId]),(0,Z.useEffect)(()=>{e===`usage`&&!C&&te()},[e,C,te]);let ne=(0,Z.useCallback)(async()=>{k(!0),j(null);try{D(await bn()),N(!0)}catch(e){let t=fn(e).message;j(t)}finally{k(!1)}},[]);(0,Z.useEffect)(()=>{e===`billing`&&!M&&ne()},[e,M,ne]);let re=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ie=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),ae=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),oe=P?c?.balance??o?.balance??null:o?.balance??null,se=[`overview`,`usage`,`billing`],ce=(e,t)=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(Xt,{className:`h-8 w-8 text-destructive`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,Q.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,Q.jsx)(He,{className:`h-4 w-4`}),`Retry`]})]}),R=()=>(0,Q.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,Q.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,Q.jsx)(ct,{className:`h-6 w-6`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Q.jsxs)(z,{disabled:n!==null,onClick:()=>void ee(),type:`button`,children:[n===`sign-in`?(0,Q.jsx)(Ge,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(nn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,Q.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,Q.jsx)(Ve,{className:`h-4 w-4`})]})]})]})}),le=()=>(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(Ge,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,Q.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:se.map(n=>{let r=!i&&n!==`overview`;return(0,Q.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:l(`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,Q.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&le(),h&&(pn(h)?R():ce(h,I)),!p&&!h&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,re(i.createdAt)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.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,Q.jsx)(Ve,{className:`h-3.5 w-3.5`})]}),(0,Q.jsxs)(z,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void L(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(rn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),oe!==null&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Qt,{className:`h-5 w-5 text-primary`}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:P?`${P.name} Balance`:`Credits Balance`})]}),(0,Q.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,Q.jsx)(V,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,Q.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,ae(oe)]})}),P&&o&&(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,ae(o.balance),` `,`credits`]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Jt,{className:`h-5 w-5 text-muted-foreground`}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,Q.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,Q.jsx)(V,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:P?`Recent API usage and token consumption for ${P.name}.`:`Recent API usage and token consumption across all providers.`}),y&&le(),x&&ce(x,te),!y&&!x&&C&&(_.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,Q.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,Q.jsx)(`span`,{children:`Model`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border`,children:_.map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,Q.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,Q.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:ae(e.creditsUsed)}),(0,Q.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:re(e.createdAt)}),(0,Q.jsx)(`p`,{children:ie(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),O&&le(),A&&ce(A,ne),!O&&!A&&M&&(E.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,Q.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,Q.jsx)(`span`,{children:`Date`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border`,children:E.map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(sn,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:re(e.paidAt)})]}),(0,Q.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,Q.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,ae(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Sn=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Cn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,Z.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=(0,Z.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),_=n.includes(g),v=r.models.length>0,y=r.modelsSourceUrl.trim().length>0,b=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(v||y)&&!_,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}))},O=async()=>{if(!(!b||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,Q.jsxs)(At,{contentClassName:`max-w-4xl`,children:[(0,Q.jsx)(Ft,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,Q.jsxs)(z,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,Q.jsx)(qt,{className:`h-4 w-4`}),`Providers`]})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,Q.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,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),_?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,Q.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,Q.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,Q.jsx)(`span`,{className:`font-mono`,children:e}),(0,Q.jsx)(z,{onClick:()=>S(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,Q.jsx)(ke,{className:`h-3 w-3`})})]},e)),(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,Q.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,Q.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,Q.jsx)(z,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,Q.jsx)($t,{className:`h-4 w-4`}):(0,Q.jsx)(en,{className:`h-4 w-4`})}),(0,Q.jsx)(z,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,Q.jsx)(H,{className:`h-4 w-4`})})]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Sn.map(e=>(0,Q.jsx)(z,{onClick:()=>C(e),className:l(`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,Q.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,Q.jsxs)(z,{onClick:()=>d(!u),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,Q.jsx)(ge,{className:l(`h-4 w-4 text-muted-foreground transition-transform`,u&&`rotate-180`)})]}),u?(0,Q.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.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,Q.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,Q.jsx)(z,{onClick:()=>D(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,Q.jsx)(le,{className:`h-4 w-4`})})]},e)),(0,Q.jsxs)(z,{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,Q.jsx)(V,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,Q.jsx)(z,{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,Q.jsx)(z,{onClick:()=>void O(),disabled:!b||f,className:l(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,b&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function wn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Tn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function En(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Dn(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 On(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function kn(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 An(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function jn(e){let t=e[0];return{channelId:t?.id??``,values:An(t),securityEnabled:!1,securityValues:{}}}function Mn(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),b=(0,Z.useMemo)(()=>{let e={...An(y),...p.values};return(y?.fields??[]).filter(t=>kn(t,e))},[y,p.values]),x=(0,Z.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:jn(e.available))},[]),S=(0,Z.useCallback)(async()=>{a(!0),u(null);try{x(await G.invoke(`list_connector_channels`))}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}},[x]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{S()},0);return()=>window.clearTimeout(e)},[S]);let C=()=>{m(jn(e)),g(null),f(!0)},w=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},T=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},E=async()=>{if(!y){g(`Choose a channel`);return}for(let e of y.fields)if(b.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&y.security){for(let e of y.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(y.id),g(null),u(null);try{x(await G.invoke(`start_connector_channel`,{channel:y.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}})),f(!1)}catch(e){g(e instanceof Error?e.message:String(e))}finally{s(null)}},D=async e=>{s(e.type),u(null);try{x(await G.invoke(`stop_connector_channel`,{channel:e.type})),v(null)}catch(e){u(e instanceof Error?e.message:String(e))}finally{s(null)}};return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,Q.jsx)(wt,{children:`cline connect`}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{disabled:i,onClick:()=>void S(),size:`sm`,type:`button`,variant:`outline`,children:(0,Q.jsx)(He,{className:l(`size-4`,i&&`animate-spin`)})}),(0,Q.jsxs)(z,{disabled:e.length===0,onClick:C,size:`sm`,type:`button`,children:[(0,Q.jsx)(V,{className:`size-4`}),`Add Channel`]})]})}),c?(0,Q.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,Q.jsx)(ft,{children:`Loading channels...`}):n.length===0?(0,Q.jsx)(ft,{children:`No channels connected.`}):(0,Q.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,Q.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(B,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,Q.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:wn(t,e)}),(0,Q.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Tn(t)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,Q.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,Q.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,Q.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:En(t.startedAt)}),t.connectionMode?(0,Q.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,Q.jsxs)(z,{disabled:o===t.type,onClick:()=>v(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,Q.jsx)(le,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,Q.jsx)(Ce,{open:d,onOpenChange:f,children:(0,Q.jsxs)(je,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ne,{children:`Add Channel`}),(0,Q.jsx)(Ie,{children:`Start a connector channel for Cline Hub.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{children:`Channel`}),(0,Q.jsxs)(De,{onValueChange:t=>{t&&m({channelId:t,values:An(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,Q.jsx)(Le,{children:(0,Q.jsx)(Be,{placeholder:`Select channel`})}),(0,Q.jsx)(Ee,{children:e.map(e=>(0,Q.jsx)(be,{value:e.id,children:e.name},e.id))})]})]}),b.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(W,{children:[e.label,e.required?(0,Q.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,Q.jsxs)(De,{onValueChange:t=>{t&&w(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,Q.jsx)(Le,{children:(0,Q.jsx)(Be,{placeholder:e.placeholder})}),(0,Q.jsx)(Ee,{children:e.options.map(e=>(0,Q.jsx)(be,{value:e.value,children:e.label},e.value))})]}):On(e)?(0,Q.jsx)(Fe,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,Q.jsx)(j,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,type:Dn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),y?.security?(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(W,{className:`text-sm`,children:`Restrict access`}),(0,Q.jsx)(Ye,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?y.security.fields.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{children:e.label}),(0,Q.jsx)(j,{onChange:t=>T(e.key,t.target.value),placeholder:e.placeholder,type:Dn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(z,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,Q.jsx)(z,{disabled:o!==null||!y,onClick:()=>void E(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,Q.jsx)(q,{open:_!==null,onOpenChange:e=>{e||v(null)},children:(0,Q.jsxs)(Wt,{children:[(0,Q.jsxs)(ot,{children:[(0,Q.jsx)(Qe,{children:`Remove Channel`}),(0,Q.jsxs)(mt,{children:[`Confirm that you want to stop the active`,` `,_?wn(_,e):`channel`,` `,`channel for `,_?Tn(_):``,`.`]})]}),(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Rt,{disabled:o!==null,children:`Cancel`}),(0,Q.jsx)(dt,{disabled:o!==null||!_,onClick:()=>{_&&D(_)},variant:`destructive`,children:`Remove`})]})]})})]})}function Nn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Pn(e){let t=Nn(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 Fn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function In(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Ln(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 Rn(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Ln(e?.env),url:e?.url??``,headersText:Fn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function zn(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!0),[c,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`create`),[y,b]=(0,Z.useState)(()=>Rn()),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),T=(0,Z.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),E=(0,Z.useCallback)(async()=>{s(!0),f(null);try{T(await G.invoke(`list_mcp_servers`))}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}},[T]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{E()},0);return()=>window.clearTimeout(e)},[E]);let D=async(e,t)=>{m(e.name),f(null);try{T(await G.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t}))}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},O=async e=>{m(e.previousName??e.name),f(null);try{T(await G.invoke(`upsert_mcp_server`,{input:e}))}catch(e){throw f(e instanceof Error?e.message:String(e)),e}finally{m(null)}},k=async e=>{m(e),f(null);try{T(await G.invoke(`delete_mcp_server`,{name:e}))}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},A=(0,Z.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=Nn(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:Pn(e.headersText),disabled:e.disabled,metadata:i}},[]),M=()=>{v(`create`),b(Rn()),S(null),g(!0)},N=e=>{v(`edit`),b(Rn(e)),S(null),g(!0)},P=async()=>{S(null);try{await O(A(y)),g(!1)}catch(e){S(e instanceof Error?e.message:String(e))}},F=async()=>{u(!0),f(null);try{let e=await G.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},I=(0,Z.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),ee=(e,t,n)=>{b(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},L=()=>{b(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},te=e=>{b(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wt,{children:`cline config mcp`}),(0,Q.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>void E(),disabled:o,children:(0,Q.jsx)(He,{className:l(`h-4 w-4`,o&&`animate-spin`)})}),(0,Q.jsxs)(z,{size:`sm`,onClick:M,children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,Q.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`MCP settings path:`}),(0,Q.jsx)(z,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void F(),disabled:c,children:n||`Open settings file`})]}),d&&(0,Q.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):I.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:I.map(e=>{let t=p===e.name;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(B,{className:l(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>N(e),disabled:t,children:(0,Q.jsx)(Kt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>w(e),disabled:t,children:(0,Q.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Ye,{checked:!e.disabled,onCheckedChange:t=>D(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,Q.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,In(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Fn(e.headers)]})]})]},e.name)})}),(0,Q.jsx)(Ce,{open:h,onOpenChange:e=>{g(e),e||S(null)},children:(0,Q.jsxs)(je,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ne,{children:_===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,Q.jsxs)(Ie,{children:[`Update the MCP server stored in`,` `,(0,Q.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-name`,children:`Server name`}),(0,Q.jsx)(j,{id:`mcp-name`,value:y.name,onChange:e=>b(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{children:`Transport type`}),(0,Q.jsxs)(De,{value:y.transportType,onValueChange:e=>b(t=>({...t,transportType:e})),children:[(0,Q.jsx)(Le,{className:`w-full`,children:(0,Q.jsx)(Be,{placeholder:`Select transport`})}),(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(be,{value:`stdio`,children:`stdio`}),(0,Q.jsx)(be,{value:`sse`,children:`sse`}),(0,Q.jsx)(be,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),y.transportType===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-command`,children:`Command`}),(0,Q.jsx)(j,{id:`mcp-command`,value:y.command,onChange:e=>b(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-args`,children:`Args`}),(0,Q.jsx)(Fe,{id:`mcp-args`,value:y.argsText,onChange:e=>b(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,Q.jsx)(j,{id:`mcp-cwd`,value:y.cwd,onChange:e=>b(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(W,{children:`Environment variables`}),(0,Q.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:L,children:(0,Q.jsx)(V,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:y.envEntries.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>te(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,Q.jsx)(an,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(j,{value:e.key,onChange:t=>ee(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,Q.jsx)(j,{type:`password`,value:e.value,onChange:t=>ee(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-url`,children:`Server URL`}),(0,Q.jsx)(j,{id:`mcp-url`,value:y.url,onChange:e=>b(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-headers`,children:`Headers`}),(0,Q.jsx)(Fe,{id:`mcp-headers`,value:y.headersText,onChange:e=>b(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,Q.jsx)(Fe,{id:`mcp-metadata`,value:y.metadataText,onChange:e=>b(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,Q.jsx)(Ye,{checked:!y.disabled,onCheckedChange:e=>b(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),x?(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:x}):null]}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(z,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,Q.jsx)(z,{onClick:()=>void P(),disabled:p!==null,children:p===null?_===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,Q.jsx)(q,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,Q.jsxs)(Wt,{children:[(0,Q.jsxs)(ot,{children:[(0,Q.jsx)(Qe,{children:`Delete MCP Server`}),(0,Q.jsx)(mt,{children:C?`Delete MCP server "${C.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Rt,{disabled:p!==null,children:`Cancel`}),(0,Q.jsx)(dt,{disabled:p!==null||!C,onClick:()=>{C&&(k(C.name),w(null))},children:`Delete`})]})]})})]})}function Bn(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 Vn(e){return e==null?``:String(e)}function Hn(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 Un({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,Z.useState)(!1),[c,u]=(0,Z.useState)(``),d=e.filter(e=>e.enabled).length,f=c.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e,m=a===`panel`;return(0,Q.jsx)(ht,{className:`h-full`,children:(0,Q.jsxs)(`div`,{className:l(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,Q.jsxs)(`div`,{className:l(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:l(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Models`}),(0,Q.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,Q.jsx)(z,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,Q.jsx)(Je,{className:`size-4`})}),(0,Q.jsxs)(z,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,Q.jsx)(Zt,{className:`size-4`}),`Add provider`]})]})]}),o?(0,Q.jsx)(`div`,{className:l(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,Q.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,Q.jsx)(Je,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(j,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>u(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,Q.jsxs)(`div`,{className:l(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,Q.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,Q.jsxs)(`div`,{className:l(`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,Q.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,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,Q.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,Q.jsx)(Ye,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,Q.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,Q.jsx)(Yt,{className:`size-4`})})]},e.id))]})]})})}function Wn({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(()=>Bn(e)),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),v=(0,Z.useRef)(void 0),y=e.configFields??[],b=Vn(f.apiKey),x=e.modelList??[],S=m?.providerId===e.id?m.value:``,C=g?.providerId===e.id?g.modelId:null,w=S.trim().toLowerCase(),T=w?x.filter(e=>e.name.toLowerCase().includes(w)||e.id.toLowerCase().includes(w)):x,E=c===`panel`;(0,Z.useEffect)(()=>()=>{v.current!==void 0&&window.clearTimeout(v.current)},[]);let D=(e,t)=>{let r=Hn(e,t);p({...f,[e.path]:r});let i={configValues:{[e.path]:r}};e.path===`apiKey`&&(i.apiKey=Vn(r)),e.path===`baseUrl`&&(i.baseUrl=Vn(r)),n(i)},O=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{_({modelId:t,providerId:e.id}),v.current!==void 0&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>_(null),1600)})};return(0,Q.jsx)(ht,{className:`h-full`,children:(0,Q.jsxs)(`div`,{className:l(`py-10 max-[720px]:px-4 max-[720px]:py-5`,E?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,Q.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,Q.jsx)(z,{"aria-label":E?`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:E?(0,Q.jsx)(ke,{className:`h-4 w-4`}):(0,Q.jsx)(qt,{className:`h-4 w-4`})}),(0,Q.jsx)(`h1`,{className:l(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,E?`text-[24px]`:`text-[32px]`),children:e.name})]}),y.length>0?(0,Q.jsx)(`section`,{className:l(`mb-8`,E?`max-w-none`:`max-w-[86rem]`),children:(0,Q.jsx)(`div`,{className:`flex flex-col`,children:y.map(e=>{let t=f[e.path],n=Vn(t),r=e.type===`password`||e.secret,i=u[e.path]??!1;return(0,Q.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,Q.jsxs)(`header`,{children:[(0,Q.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,Q.jsx)(Ye,{checked:!!t,onCheckedChange:t=>D(e,t)})]}):e.type===`select`?(0,Q.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=>D(e,t.target.value),value:n,children:[(0,Q.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,Q.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,Q.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,Q.jsx)(Ze,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,Q.jsx)(j,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>D(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,Q.jsx)($t,{className:`h-4 w-4`}):(0,Q.jsx)(en,{className:`h-4 w-4`})}),(0,Q.jsx)(z,{"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,Q.jsx)(H,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!b&&!e.oauthAccessTokenPresent&&o?(0,Q.jsx)(`div`,{className:`mb-8`,children:(0,Q.jsxs)(z,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,Q.jsx)(Ge,{className:`h-4 w-4 animate-spin`}):null,(0,Q.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,Q.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,Q.jsxs)(`section`,{className:l(`overflow-hidden rounded-lg border`,E?`max-w-none`:`max-w-[46rem]`),children:[(0,Q.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,Q.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Je,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(z,{"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,Q.jsx)(He,{className:l(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):x.length>0?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,Q.jsx)(Je,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(j,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:S})]}),T.length>0?(0,Q.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:T.map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,Q.jsx)(`div`,{title:`File Support`,children:(0,Q.jsx)(tn,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,Q.jsx)(`div`,{title:`Image Support`,children:(0,Q.jsx)(_e,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,Q.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:()=>O(e.id),title:`Copy model ID`,type:`button`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,Q.jsx)(H,{className:`size-3 shrink-0`}),C===e.id?(0,Q.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Q.jsx)(z,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,Q.jsx)(We,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,S.trim(),`".`]})})]}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}function Gn(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var Kn=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.indeterminate=`data-indeterminate`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({});function qn(e){return Z.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[Kn.checked]:``}:{[Kn.unchecked]:``}},...A}),[e.indeterminate])}var Jn=Z.createContext(void 0);function Yn(){let e=Z.useContext(Jn);if(e===void 0)throw Error(s(14));return e}var Xn=`data-parent`,Zn=Z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":s,disabled:c=!1,form:l,id:f,indeterminate:p=!1,inputRef:m,name:h,onCheckedChange:v,parent:b=!1,readOnly:S=!1,render:C,required:w=!1,uncheckedValue:E,value:D,nativeButton:O=!1,style:k,...A}=e,{clearErrors:j}=I(),{disabled:P,name:ee,setDirty:L,setFilled:ae,setFocused:oe,setTouched:se,state:ce,validationMode:le,validityData:z,validation:fe}=te(),pe=ln(),{labelId:me,controlId:he,registerControlId:B,getDescriptionProps:ge}=N(),V=dn(),_e=V?.parent,ve=_e&&V.allValues,H=P||pe.disabled||V?.disabled||c,ye=ee??h,U=D??ye,be=g(),xe=g(),Se=he;ve?Se=b?xe:`${_e.id}-${U}`:f&&(Se=f);let Ce={};ve&&(b?Ce=V.parent.getParentProps():U&&(Ce=V.parent.getChildProps(U)));let{checked:we=n,indeterminate:Te=p,onCheckedChange:Ee,...De}=Ce,Oe=V?.value,ke=V?.setValue,Ae=V?.defaultValue,je=Z.useRef(null),Me=d(()=>Symbol(`checkbox-control`)),Ne=Z.useRef(!1),{getButtonProps:Pe,buttonRef:Fe}=x({disabled:H,native:O}),W=V?.validation??fe,[Ie,Le]=R({controlled:U&&Oe&&!b?Oe.includes(U):we,default:U&&Ae&&!b?Ae.includes(U):i,name:`Checkbox`,state:`checked`}),Re=ve?!!we:Ie,ze=ve&&Te||p;T(()=>{B!==ie&&(Ne.current=!0,B(Me.current,Se))},[Se,B,Me]),Z.useEffect(()=>{let e=Me.current;return()=>{!Ne.current||B===ie||(Ne.current=!1,B(e,void 0))}},[B,Me]),re(je,be,Ie,void 0,!V&&!H,h);let Be=Z.useRef(null),Ve=y(m,Be,W.inputRef,W.registerInput),He=qe(s,me,Be,!O,Se??void 0);T(()=>{Be.current&&(Be.current.indeterminate=ze,Ie&&ae(!0))},[Ie,ze,ae]),ue(Ie,()=>{V||(j(ye),ae(Ie),L(Ie!==z.initialValue),W.change(Ie))});let Ue=a({checked:Ie,disabled:H,form:l,name:b?void 0:ye,id:O?void 0:Se??void 0,required:w,ref:Ve,style:ye?u:_,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(S){e.preventDefault();return}let t=e.currentTarget.checked,n=o(F,e.nativeEvent);v?.(t,n),!n.isCanceled&&(Ee?.(t,n),!n.isCanceled&&(Le(t),U&&Oe&&ke&&!b&&!ve&&ke(t?[...Oe,U]:Oe.filter(e=>e!==U),n)))},onFocus(){je.current?.focus()}},D===void 0?M:{value:(V?Ie&&D:D)||``},ge,e=>W.getValidationProps(H,e));Z.useEffect(()=>{if(!_e||!U)return;let e=_e.disabledStatesRef.current;return e.set(U,H),()=>{e.delete(U)}},[_e,H,U]);let We=Z.useMemo(()=>({...ce,checked:Re,disabled:H,readOnly:S,required:w,indeterminate:ze}),[ce,Re,H,S,w,ze]),G=qn(We),Ge=ne(`span`,e,{state:We,ref:[Fe,je,t,V?.registerControlRef],props:[{id:O?Se??void 0:be,role:`checkbox`,"aria-checked":ze?`mixed`:Re,"aria-readonly":S||void 0,"aria-required":w||void 0,"aria-labelledby":He,[Xn]:b?``:void 0,onFocus(){H||oe(!0)},onBlur(){let e=Be.current;e&&(se(!0),oe(!1),le===`onBlur`&&W.commit(V?Oe:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Be.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),de(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||Gn(t)?.click()})},onClick(e){if(S||H)return;e.preventDefault();let t=Be.current;t&&t.dispatchEvent(new(de(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},A,De,Pe,ge,e=>W.getValidationProps(H,e)],stateAttributesMapping:G});return(0,Q.jsxs)(Jn.Provider,{value:We,children:[Ge,!Ie&&!V&&ye&&!b&&E!==void 0&&(0,Q.jsx)(`input`,{type:`hidden`,form:l,name:ye,value:E,disabled:H}),(0,Q.jsx)(`input`,{...Ue,suppressHydrationWarning:!0})]})}),Qn=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Yn(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=xt(c),f=Z.useRef(null),p={...s,transitionStatus:u};gt({open:c,ref:f,onComplete(){c||d(!1)}});let m={...qn(s),...vt,...A},h=a||l,g=ne(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function $n({className:e,...t}){return(0,Q.jsx)(Zn,{"data-slot":`checkbox`,className:l(`peer relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...t,children:(0,Q.jsx)(Qn,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(et,{})})})}function er(e,t,n,r,i,a,o,s,c,l=2){let u=Vt(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return st(n.current,u)?void 0:u}var tr=Z.createContext(void 0),nr=Z.createContext(void 0),rr=Z.createContext(void 0),ir=Z.createContext(!1),ar=Z.createContext(``);function or(){let e=Z.useContext(tr);if(!e)throw Error(s(22));return e}function sr(){let e=Z.useContext(nr);if(!e)throw Error(s(23));return e}function cr(){let e=Z.useContext(rr);if(!e)throw Error(s(24));return e}function lr(){return Z.useContext(ar)}function ur(){return Z.useContext(ir)}var $={id:J(e=>e.id),labelId:J(e=>e.labelId),items:J(e=>e.items),selectedValue:J(e=>e.selectedValue),hasSelectionChips:J(e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:J(e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:J((e,t)=>t?ye(e.items):!1),open:J(e=>e.open),mounted:J(e=>e.mounted),forceMounted:J(e=>e.forceMounted),inline:J(e=>e.inline),activeIndex:J(e=>e.activeIndex),selectedIndex:J(e=>e.selectedIndex),isActive:J((e,t)=>e.activeIndex===t),isSelected:J((e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>he(t,e,n)):he(t,r,n)}),transitionStatus:J(e=>e.transitionStatus),popupProps:J(e=>e.popupProps),inputProps:J(e=>e.inputProps),triggerProps:J(e=>e.triggerProps),itemProps:J(e=>e.itemProps),positionerElement:J(e=>e.positionerElement),listElement:J(e=>e.listElement),popupId:J(e=>e.popupId),triggerElement:J(e=>e.triggerElement),inputElement:J(e=>e.inputElement),inputGroupElement:J(e=>e.inputGroupElement),popupSide:J(e=>e.popupSide),openMethod:J(e=>e.openMethod),inputInsidePopup:J(e=>e.inputInsidePopup),inputOwnsFormValue:J(e=>e.inputOwnsFormValue),selectionMode:J(e=>e.selectionMode),name:J(e=>e.name),form:J(e=>e.form),disabled:J(e=>e.disabled),readOnly:J(e=>e.readOnly),required:J(e=>e.required),grid:J(e=>e.grid),virtualized:J(e=>e.virtualized),itemToStringLabel:J(e=>e.itemToStringLabel),isItemEqualToValue:J(e=>e.isItemEqualToValue),modal:J(e=>e.modal),autoHighlight:J(e=>e.autoHighlight),submitOnItemClick:J(e=>e.submitOnItemClick)};function dr(e){return e==null?void 0:`${e}-popup`}function fr(e,t){return(n,r)=>{if(n==null)return!1;let i=Re(n,t);return e.contains(i,r)}}function pr(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;let a=Re(r,t),o=n==null?``:Re(n,t);return o&&e.contains(o,i)&&o.length===i.length?!0:e.contains(a,i)}}function mr(e){return Array.isArray(e)?e.map(e=>mr(e)).join(`,`):e==null?``:String(e)}var hr=new Map;function gr(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${mr(e.locale)}|${JSON.stringify(t)}`,r=hr.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Re(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Re(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Re(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return hr.set(n,a),a}var _r=gr,vr=Symbol(`none`),yr={value:vr,index:-1};function br(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:s,defaultInputValue:l,inputValue:f,open:p,defaultOpen:h=!1,selectionMode:g=`none`,onItemHighlighted:b,name:x,form:S,disabled:C=!1,readOnly:E=!1,required:O=!1,inputRef:A,grid:j=!1,items:N,filteredItems:L,filter:ne,openOnInputClick:ae=!0,autoHighlight:oe=!1,keepHighlight:le=!1,highlightItemOnHover:de=!0,loopFocus:z=!0,itemToStringLabel:B,itemToStringValue:ge,isItemEqualToValue:V=me,virtualized:_e=!1,inline:H=!1,fillInputOnItemPress:ye=!0,modal:be=!1,limit:xe=-1,autoComplete:Se=`list`,formAutoComplete:Ce,locale:we,submitOnItemClick:Te=!1}=e,{clearErrors:Ee}=I(),{setDirty:De,validityData:Oe,setFilled:ke,name:je,disabled:Me,setTouched:Ne,setFocused:Pe,validationMode:Fe,validation:W}=te(),Ie=c(),Le=ce({id:t}),Be=_r({locale:we}),[Ve,He]=Z.useState(!1),[Ue,We]=Z.useState(null),G=Z.useRef([]),Ge=Z.useRef([]),Ke=Z.useRef(null),qe=Z.useRef(null),Je=Z.useRef(null),Ye=Z.useRef(null),Xe=Z.useRef(null),Ze=Z.useRef(!0),Qe=Z.useRef(!1),$e=Z.useRef(null),et=Z.useRef(null),tt=Z.useRef(null),nt=Z.useRef(yr),rt=Z.useRef(null),it=Z.useRef([]),at=Z.useRef([]),ot=Me||C,st=je??x,ct=g===`multiple`,lt=g===`single`,ut=f!==void 0||l!==void 0,dt=N!==void 0,ft=L!==void 0,mt;mt=oe===`always`?`always`:oe?`input-change`:!1;let[K,ht]=R({controlled:i,default:ct?r??se:r,name:`Combobox`,state:`selectedValue`}),_t=Z.useMemo(()=>ne===null?()=>!0:ne===void 0?lt&&!Ve?pr(Be,B,K):fr(Be,B):ne,[ne,lt,K,Ve,Be,B]),vt=d(()=>ut?l??``:lt?Re(K,B):``).current,[yt,bt]=R({controlled:f,default:vt,name:`Combobox`,state:`inputValue`}),[q,Ct]=R({controlled:p,default:h,name:`Combobox`,state:`open`}),J=pe(N),wt=Ue??(yt===``?``:String(yt).trim()),Dt=lt?Re(K,B):``,Ot=lt&&!Ve&&wt!==``&&Dt!==``&&Dt.length===wt.length&&Be.contains(Dt,wt),kt=Ot?``:wt,At=dt&&ft&&Ot,Nt=Z.useMemo(()=>N?J?N.flatMap(e=>e.items):N:se,[N,J]),Pt=Z.useMemo(()=>{if(L&&!At)return L;if(!N)return se;if(J){let e=N,t=[],n=0;for(let r of e){if(xe>-1&&n>=xe)break;let e=kt===``?r.items:r.items.filter(e=>_t(e,kt,B));if(e.length===0)continue;let i=xe>-1?xe-n:1/0,a=e.slice(0,i);if(a.length>0){let e={...r,items:a};t.push(e),n+=a.length}}return t}if(kt===``)return xe>-1?Nt.slice(0,xe):Nt;let e=[];for(let t of Nt){if(xe>-1&&e.length>=xe)break;_t(t,kt,B)&&e.push(t)}return e},[L,At,N,J,kt,xe,_t,B,Nt]),Ft=Z.useMemo(()=>J?Pt.flatMap(e=>e.items):Pt,[Pt,J]),X=d(()=>new Mt({id:Le,labelId:void 0,selectedValue:K,open:q,filter:_t,query:wt,items:N,selectionMode:g,listRef:G,labelsRef:Ge,popupRef:Ke,emptyRef:Xe,inputRef:qe,startDismissRef:Je,endDismissRef:Ye,keyboardActiveRef:Ze,chipsContainerRef:$e,clearRef:et,valuesRef:it,allValuesRef:at,selectionEventRef:tt,name:st,form:S,disabled:ot,readOnly:E,required:O,grid:j,isGrouped:J,virtualized:_e,openOnInputClick:ae,itemToStringLabel:B,isItemEqualToValue:V,modal:be,autoHighlight:mt,submitOnItemClick:Te,hasInputValue:ut,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:H,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:M,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:g===`none`,onOpenChangeComplete:n||ie,setOpen:ie,setInputValue:ie,setSelectedValue:ie,setIndices:ie,onItemHighlighted:ie,handleSelection:ie,forceMount:ie,requestSubmit:ie})).current,It=g===`none`?yt:K,Lt=Z.useMemo(()=>g===`none`?It:Array.isArray(K)?K.map(e=>U(e,ge)):U(K,ge),[It,ge,g,K]),Rt=m(b),Vt=m(n),Ht=Y(X,$.activeIndex),Ut=Y(X,$.selectedIndex),Wt=Y(X,$.positionerElement),Kt=Y(X,$.listElement),qt=Y(X,$.triggerElement),Jt=Y(X,$.inputElement),Yt=Y(X,$.inputGroupElement),Xt=Y(X,$.inline),Zt=Y(X,$.inputInsidePopup),Qt=Y(X,$.inputOwnsFormValue),$t=Et(qt),{mounted:en,setMounted:tn,transitionStatus:nn}=xt(q),{openMethod:rn,triggerProps:an}=Bt(q),on=m(()=>Lt);re(Zt?$t:qe,Le,It,on,!ot,x);let sn=m(()=>{N?Ge.current=Ft.map(e=>Re(e,B)):X.set(`forceMounted`,!0)}),cn=Z.useRef(K);T(()=>{K!==cn.current&&sn()},[sn,K]);let ln=m(e=>{X.update(e);let t=e.type||`none`;if(e.activeIndex!==void 0)if(e.activeIndex===null)nt.current!==yr&&(nt.current=yr,Rt(void 0,w(t,void 0,{index:-1})));else{let n=it.current[e.activeIndex];nt.current={value:n,index:e.activeIndex},Rt(n,w(t,void 0,{index:e.activeIndex}))}}),un=m((t,n)=>{if(Qe.current=n.reason===D,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===`input-change`){let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&He(!0),rt.current={hasQuery:e},e&&mt&&X.state.activeIndex==null&&X.set(`activeIndex`,0)}}bt(t)}}),dn=m((t,n)=>{if(q!==t&&(n.reason===`escape-key`&&dt&&Ft.length===0&&!X.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&ct&&Zt&&!Xt&&Ue!==null&&(He(!1),We(null),yt!==``&&un(``,o(D,n.event))),!t&&Ve&&(lt?(Xt||We(wt),wt===``&&He(!1)):ct&&(Xt||We(wt),Zt&&ln({activeIndex:null}),(!Zt||Xt)&&un(``,o(D,n.event)))),Ct(t),!t&&Zt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(Ne(!0),Pe(!1),Fe===`onBlur`)))){let e=g===`none`?yt:K;W.commit(e)}}),fn=m((e,t)=>{s?.(e,t),!t.isCanceled&&(ht(e),(g===`none`&&Ke.current&&ye||lt&&!X.state.inputInsidePopup)&&un(Re(e,B),o(t.reason,t.event)),lt&&e!=null&&t.reason!==`input-change`&&Ve&&!Xt&&We(wt))}),pn=m((e,t)=>{let n=t;if(n===void 0){if(Ht===null)return;n=it.current[Ht]}let r=ee(e),i=tt.current??e;tt.current=null;let a=o(v,i),s=r?.closest(`a`)?.getAttribute(`href`);if(s){s.startsWith(`#`)&&dn(!1,a);return}if(ct){let e=Array.isArray(K)?K:[];if(fn(fe(e,n,X.state.isItemEqualToValue)?Ae(e,n,X.state.isItemEqualToValue):[...e,n],a),a.isCanceled||!(qe.current&&qe.current.value.trim()!==``))return;X.state.inputInsidePopup?un(``,o(D,a.event)):dn(!1,a)}else{if(fn(n,a),a.isCanceled)return;dn(!1,a)}}),mn=m(()=>{if(!X.state.submitOnItemClick)return;let e=W.inputRef.current?.form??X.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),hn=m(()=>{if(tn(!1),Vt?.(!1),He(!1),We(null),ln(g===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),ct&&qe.current&&qe.current.value!==``&&!Qe.current&&un(``,o(D)),lt)if(X.state.inputInsidePopup)qe.current&&qe.current.value!==``&&un(``,o(D));else{let e=Re(K,B);qe.current&&qe.current.value!==e&&un(e,o(e===``?D:F))}}),gn=Z.useMemo(()=>Xt&&Wt?{current:Wt.closest(`[role="dialog"]`)}:Ke,[Xt,Wt]);gt({enabled:!e.actionsRef,open:q,ref:gn,onComplete(){q||hn()}}),Z.useImperativeHandle(e.actionsRef,()=>({unmount:hn}),[hn]),T(function(){if(q||g===`none`)return;let e=N?Nt:at.current;if(ct){let t=Array.isArray(K)?K:[],n=t[t.length-1],r=ve(e,n,V);ln({selectedIndex:r===-1?null:r})}else{let t=ve(e,K,V);ln({selectedIndex:t===-1?null:t})}},[q,K,N,g,Nt,ct,V,ln]),T(()=>{N&&(it.current=Ft,G.current.length=Ft.length)},[N,Ft]),T(()=>{let e=rt.current;if(e&&(e.hasQuery?mt&&X.set(`activeIndex`,0):mt===`always`&&X.set(`activeIndex`,0),rt.current=null),!q&&!Xt)return;let t=dt||ft?Ft:it.current,n=X.state.activeIndex;if(n==null){if(mt===`always`&&t.length>0){X.set(`activeIndex`,0);return}nt.current!==yr&&(nt.current=yr,X.state.onItemHighlighted(void 0,w(F,void 0,{index:-1})));return}if(n>=t.length){nt.current!==yr&&(nt.current=yr,X.state.onItemHighlighted(void 0,w(F,void 0,{index:-1}))),X.set(`activeIndex`,null);return}let r=t[n],i=nt.current.value,a=i!==vr&&he(r,i,X.state.isItemEqualToValue);(nt.current.index!==n||!a)&&(nt.current={value:r,index:n},X.state.onItemHighlighted(r,w(F,void 0,{index:n})))},[Ht,mt,ft,dt,Ft,Xt,q,X]),T(()=>{if(g===`none`){ke(String(yt)!==``);return}ke(ct?Array.isArray(K)&&K.length>0:K!=null)},[ke,g,yt,K,ct]),Z.useEffect(()=>{dt&&mt&&Ft.length===0&&ln({activeIndex:null})},[dt,mt,Ft.length,ln]);function _n(e){let t=Oe.initialValue;return Array.isArray(e)&&Array.isArray(t)?!ze(e,t,(e,t)=>he(e,t,V)):e!==t}ue(wt,()=>{!q||wt===``||wt===String(vt)||He(!0)}),ue(K,()=>{if(g!==`none`&&(Ee(st),De(_n(K)),W.change(K),lt&&!ut&&!Zt)){let e=Re(K,B);yt!==e&&un(e,o(F))}}),ue(yt,()=>{g===`none`&&(Ee(st),De(yt!==Oe.initialValue),W.change(yt))}),ue(N,()=>{if(!lt||ut||Zt||Ve)return;let e=Re(K,B);yt!==e&&un(e,o(F))});let vn=pt({open:Xt?!0:q,onOpenChange:dn,elements:{reference:Zt?qt:Jt,floating:Wt}}),yn,bn;Xt||(yn=j?`grid`:`listbox`,bn=q?`true`:`false`);let xn=Z.useMemo(()=>{let e=Jt?.tagName===`INPUT`,t=Jt==null||e,n=t||q,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=bn,r[`aria-haspopup`]=yn,r[`aria-controls`]=q?Kt?.id:void 0,r[`aria-autocomplete`]=Se),{reference:r,floating:{role:`presentation`}}},[Jt,q,bn,yn,Kt?.id,Se]),Sn=Gt(vn,{enabled:!E&&!ot&&ae,event:`mousedown-only`,toggle:!1,touchOpenDelay:Zt?0:100,reason:k}),Cn=zt(vn,{enabled:!E&&!ot&&!Xt,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Xt?!0:void 0,outsidePress(e){let t=ee(e);return!P(qt,t)&&!P(et.current,t)&&!P($e.current,t)&&!P(Yt,t)}}),wn=Tt(vn,{enabled:!E&&!ot,id:Le,listRef:G,activeIndex:Ht,selectedIndex:Ut,virtual:!0,loopFocus:z,allowEscape:z&&!mt,focusItemOnOpen:Ve||g===`none`&&!mt?!1:`auto`,focusItemOnHover:de,resetOnPointerLeave:!le,orientation:j?`horizontal`:void 0,rtl:Ie===`rtl`,disabledIndices:se,grid:j?er:void 0,onNavigate(e,t){!t&&!q||nn===`ending`||ln(t?{activeIndex:e,type:Ze.current?`keyboard`:`pointer`}:{activeIndex:e})}}),Tn=Z.useMemo(()=>a(wn.reference,{onKeyDown(e){j&&X.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Cn.reference,Sn.reference,xn.reference),[wn.reference,Cn.reference,Sn.reference,xn.reference,j,X]),En=Z.useMemo(()=>a(jt,wn.floating,Cn.floating,xn.floating),[wn.floating,Cn.floating,xn.floating]),Dn=Z.useMemo(()=>{let e=wn.item;return e?{...e,onFocus:void 0}:M},[wn.item]);St(()=>{X.update({inline:H,popupProps:En,inputProps:Tn,triggerProps:an,itemProps:Dn,setOpen:dn,setInputValue:un,setSelectedValue:fn,setIndices:ln,onItemHighlighted:Rt,handleSelection:pn,forceMount:sn,requestSubmit:mn})}),T(()=>{X.update({id:Le,selectedValue:K,open:q,mounted:en,transitionStatus:nn,items:N,inline:H,popupProps:En,inputProps:Tn,triggerProps:an,openMethod:rn,itemProps:Dn,selectionMode:g,name:st,form:S,disabled:ot,readOnly:E,required:O,grid:j,isGrouped:J,virtualized:_e,onOpenChangeComplete:Vt,openOnInputClick:ae,itemToStringLabel:B,modal:be,autoHighlight:mt,isItemEqualToValue:V,submitOnItemClick:Te,hasInputValue:ut,requestSubmit:mn,inputOwnsFormValue:g===`none`&&(H||!X.state.inputInsidePopup)})},[X,Le,K,q,en,nn,N,En,Tn,Dn,rn,an,g,st,ot,E,O,W,j,J,_e,Vt,ae,B,be,V,Te,ut,H,mn,mt,S]);let On=y(A,W.inputRef),kn=Z.useMemo(()=>({query:wt,hasItems:dt,filteredItems:Pt,flatFilteredItems:Ft}),[wt,dt,Pt,Ft]),An=Z.useMemo(()=>Array.isArray(It)?``:U(It,ge),[It,ge]),jn=ct&&Array.isArray(K)&&K.length>0,Mn=ct||g===`none`&&Qt?void 0:st,Nn=Z.useMemo(()=>!ct||!Array.isArray(K)||!st?null:K.map(e=>{let t=U(e,ge);return(0,Q.jsx)(`input`,{type:`hidden`,form:S,name:st,value:t,disabled:ot},t)}),[ct,K,S,st,ge,ot]),Pn=(0,Q.jsxs)(Z.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...W.getValidationProps(ot,{onFocus(){if(Zt){qt?.focus();return}(qe.current||qt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||ot||E)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=o(F,e.nativeEvent),i=()=>it.current.findIndex(e=>U(e,ge).toLowerCase()===n||Re(e,B).toLowerCase()===n);function a(){if(ct)return;if(g===`none`){un(t,r);return}let e=i();e===-1&&(e=it.current.findIndex((e,t)=>{let r=Ge.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:it.current[e];a!=null&&fn?.(a,r)}lt&&(sn(),N&&i()===-1&&X.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Le&&Mn==null?`${Le}-hidden-input`:void 0,form:S,name:Mn,autoComplete:Ce,disabled:ot,required:O&&!jn,readOnly:E,value:An,ref:On,style:Mn?u:_,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Nn]});return(0,Q.jsx)(tr.Provider,{value:X,children:(0,Q.jsx)(nr.Provider,{value:vn,children:(0,Q.jsx)(ir.Provider,{value:dt,children:(0,Q.jsx)(rr.Provider,{value:kn,children:(0,Q.jsx)(ar.Provider,{value:yt,children:Pn})})})})})}var xr={...It,...A,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null},Sr=2,Cr=Z.forwardRef(function(e,t){let{render:n,className:r,nativeButton:a=!0,disabled:s=!1,id:c,style:l,...u}=e,{state:d,disabled:p,setTouched:h,setFocused:g,validationMode:_,validation:v}=te(),{labelId:y}=N(),S=or(),{filteredItems:C}=cr(),w=Y(S,$.selectionMode),T=Y(S,$.disabled),E=Y(S,$.readOnly),D=Y(S,$.required),O=Y(S,$.mounted),k=Y(S,$.popupSide),A=Y(S,$.positionerElement),j=Y(S,$.listElement),M=Y(S,$.popupId),F=Y(S,$.triggerProps),I=Y(S,$.triggerElement),L=Y(S,$.inputInsidePopup),re=Y(S,$.id),ie=Y(S,$.labelId),ae=Y(S,$.open),oe=Y(S,$.selectedValue),se=Y(S,$.activeIndex),R=Y(S,$.selectedIndex),le=Y(S,$.hasSelectedValue),ue=sr(),de=lr(),z=b(),fe=p||T||s,pe=C.length===0,me=O&&A?k:null;ce({id:L?c:void 0});let he=L?c??re:c,B=Se(y,ie),ge;ae&&L?ge=M??dr(re):ae&&(ge=j?.id);let V=Z.useRef(``);function _e(e){V.current=e.pointerType}let ve=ue.useState(`domReferenceElement`);Z.useEffect(()=>{L&&I&&I!==ve&&ue.set(`domReferenceElement`,I)},[I,ve,ue,L]);let{reference:H}=Pt(ue,{enabled:!ae&&!E&&!T&&w===`single`,listRef:S.state.labelsRef,activeIndex:se,selectedIndex:R,onMatch(e){let t=S.state.valuesRef.current[e];t!==void 0&&S.state.setSelectedValue(t,o(`none`))}}),{reference:ye}=Gt(ue,{enabled:!E&&!T,event:`mousedown`}),{buttonRef:U,getButtonProps:be}=x({native:a,disabled:fe}),xe={...d,open:ae,disabled:fe,popupSide:me,listEmpty:pe,placeholder:w===`none`?!1:!le};return ne(`button`,e,{ref:[t,U,m(e=>{S.set(`triggerElement`,e)})],state:xe,props:[F,ye,H,{id:he,tabIndex:L?0:-1,role:L?`combobox`:void 0,"aria-expanded":ae?`true`:`false`,"aria-haspopup":L?`dialog`:`listbox`,"aria-controls":ge,"aria-required":L&&D||void 0,"aria-labelledby":B,onPointerDown:_e,onPointerEnter:_e,onFocus(){g(!0),!(fe||E)&&z.start(0,S.state.forceMount)},onBlur(e){if(!P(A,e.relatedTarget)&&(h(!0),g(!1),_===`onBlur`)){let e=w===`none`?de:oe;v.commit(e)}},onMouseDown(e){if(fe||E||(L||ue.set(`domReferenceElement`,e.currentTarget),S.state.forceMount(),V.current!==`touch`&&(S.state.inputRef.current?.focus(),L||e.preventDefault()),ae))return;let t=f(e.currentTarget);function n(e){if(!I)return;let t=ee(e),n=S.state.positionerElement,r=S.state.listElement;if(P(I,t)||P(n,t)||P(r,t)||t===I)return;let i=Lt(I),a=e.clientX>=i.left-Sr&&e.clientX<=i.right+Sr,s=e.clientY>=i.top-Sr&&e.clientY<=i.bottom+Sr;a&&s||S.state.setOpen(!1,o(`cancel-open`,e))}L&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){fe||E||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(tt(e),S.state.setOpen(!0,o(i,e.nativeEvent)),S.state.inputRef.current?.focus())}},v?v.getValidationProps(fe,u):u,be],stateAttributesMapping:xr})}),wr=Z.createContext(void 0);function Tr(){return Z.useContext(wr)}var Er=Z.createContext(void 0);function Dr(e){let t=Z.useContext(Er);if(t===void 0&&!e)throw Error(s(21));return t}var Or=Z.forwardRef(function(e,t){let n=or(),{buttonRef:r,getButtonProps:i}=x({native:!1}),a=y(t,r);function s(e){n.state.setOpen(!1,o(E,e.nativeEvent,e.currentTarget))}return(0,Q.jsx)(`span`,{ref:a,...i({onClick:s}),"aria-label":`Dismiss`,tabIndex:void 0,style:u})}),kr=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:s,...l}=e,{state:u,disabled:d,setTouched:f,setFocused:_,validationMode:v,validation:y}=te(),{labelId:b}=N(),x=Tr(),S=!!Dr(!0),C=or(),{filteredItems:w}=cr(),T=lr(),E=c(),k=Y(C,$.required),A=Y(C,$.disabled),j=Y(C,$.readOnly),M=Y(C,$.name),P=Y(C,$.form),I=Y(C,$.selectionMode),ee=Y(C,$.autoHighlight),re=Y(C,$.inputProps),ie=Y(C,$.triggerProps),se=Y(C,$.open),ce=Y(C,$.mounted),R=Y(C,$.selectedValue),le=Y(C,$.popupSide),ue=Y(C,$.positionerElement),de=Y(C,$.id),z=Y(C,$.inline),fe=Y(C,$.modal),pe=!!ee,me=ce&&ue?le:null,he=d||A||i,B=w.length===0,ge=S||z,V=!ge||fe,_e=g(a??(ge?void 0:de)),ve=Se(b,void 0),H=S?L:u,[ye,U]=Z.useState(null),be=Z.useRef(!1),xe=Z.useRef(null),Ce=Z.useRef(!1),we=I===`none`&&!S,Te=m(e=>{let t=S||C.state.inline;t&&!C.state.hasInputValue&&C.state.setInputValue(``,o(F)),C.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:we})}),Ee=S||!y?l:y.getValidationProps(he,l),De={...H,open:se,disabled:he,readOnly:j,popupSide:me,listEmpty:B};function Oe(e){if(!x)return;let t,{highlightedChipIndex:n}=x,r=x.chipsRef.current.length,i=E===`rtl`,a=i?`ArrowRight`:`ArrowLeft`,o=i?`ArrowLeft`:`ArrowRight`;if(n!==void 0){if(e.key===a)e.preventDefault(),t=n>0?n-1:void 0;else if(e.key===o)e.preventDefault(),t=n<r-1?n+1:void 0;else if(e.key===`Backspace`||e.key===`Delete`){e.preventDefault();let r=n>=R.length-1?R.length-2:n;t=r>=0?r:void 0,C.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`})}return t}return e.key===a&&(e.currentTarget.selectionStart??0)===0&&R.length>0?(e.preventDefault(),t=r>0?r-1:void 0):e.key===`Backspace`&&e.currentTarget.value===``&&R.length>0&&(C.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`}),e.preventDefault()),t}let ke=ne(`input`,e,{state:De,ref:[t,C.state.inputRef,Te],props:[re,ie,{type:`text`,value:e.value??ye??T,"aria-readonly":j||void 0,"aria-required":k||void 0,"aria-labelledby":ve,disabled:he,readOnly:j,required:I===`none`?k:void 0,form:P,...we&&M&&{name:M},id:_e,onFocus(){if(_(!0),!z||!Ce.current)return;Ce.current=!1;let e=xe.current;e==null||!Object.hasOwn(C.state.valuesRef.current,e)||C.state.setIndices({activeIndex:e})},onBlur(){f(!0),_(!1);let e=C.state.activeIndex;if(z&&e!==null&&ee!==`always`&&(xe.current=e,Ce.current=!0,C.state.setIndices({activeIndex:null})),v===`onBlur`){let e=I===`none`?T:R;y.commit(e)}},onCompositionStart(e){nt||(be.current=!0,U(e.currentTarget.value))},onCompositionEnd(e){be.current=!1;let t=e.currentTarget.value;U(null),C.state.setInputValue(t,o(O,e.nativeEvent))},onChange(e){let t=e.nativeEvent.inputType,n=!t||t===`insertReplacementText`,r=be.current||!n;if(be.current){let t=e.currentTarget.value;U(t),t===``&&!C.state.openOnInputClick&&!C.state.inputInsidePopup&&C.state.setOpen(!1,o(D,e.nativeEvent));let n=t.trim(),i=pe&&n!==``;!j&&!he&&n&&r&&(C.state.setOpen(!0,o(O,e.nativeEvent)),pe||C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`})),se&&C.state.activeIndex!==null&&!i&&C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`});return}let i=o(O,e.nativeEvent);if(C.state.setInputValue(e.currentTarget.value,i),i.isCanceled)return;let a=e.currentTarget.value===``,s=o(D,e.nativeEvent);a&&!C.state.inputInsidePopup&&(I===`single`&&C.state.setSelectedValue(null,s),C.state.openOnInputClick||C.state.setOpen(!1,s));let c=e.currentTarget.value.trim();!j&&!he&&c&&r&&(C.state.setOpen(!0,o(O,e.nativeEvent)),pe||C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`})),se&&C.state.activeIndex!==null&&!pe&&C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`})},onKeyDown(e){if(he||j||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;C.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=E===`rtl`;if(e.key===`Home`){tt(e);let n=h&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){tt(e);let i=h&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!ce&&e.key===`Escape`){let t=I===`multiple`&&Array.isArray(R)?R.length===0:R===null,n=o(p,e.nativeEvent),r=I===`multiple`?[]:null;C.state.setInputValue(``,n),C.state.setSelectedValue(r,n),!t&&!C.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(x&&e.key===`Backspace`&&t.value===``&&x.highlightedChipIndex===void 0&&Array.isArray(R)&&R.length>0){let t=x.chipsRef.current.length,n=t>0?t-1:R.length-1,r=R.filter((e,t)=>t!==n);C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`}),C.state.setSelectedValue(r,o(F,e.nativeEvent));return}let i=x?.highlightedChipIndex!==void 0,a=Oe(e);if(x?.setHighlightedChipIndex(a),a===void 0?i&&C.state.inputRef.current?.focus():x?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&se){let t=C.state.activeIndex,n=e.nativeEvent;if(t===null){if(z)return;C.state.setOpen(!1,o(F,n));return}tt(e);let r=C.state.listRef.current[t];r&&(C.state.selectionEventRef.current=n,r.click(),C.state.selectionEventRef.current=null)}},onPointerMove(){C.state.keyboardActiveRef.current=!1},onPointerDown(){C.state.keyboardActiveRef.current=!1}},Ee],stateAttributesMapping:xr}),Ae=S?(0,Q.jsx)(ae.Provider,{value:oe,children:ke}):ke;return(0,Q.jsxs)(Z.Fragment,{children:[se&&V&&(0,Q.jsx)(Or,{ref:C.state.startDismissRef}),Ae]})}),Ar={...vt,...kt},jr=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:s=!1,style:c,...l}=e,{disabled:u}=te(),d=or(),f=Y(d,$.selectionMode),p=Y(d,$.disabled),m=Y(d,$.readOnly),h=Y(d,$.open),g=Y(d,$.selectedValue),_=Y(d,$.hasSelectionChips),v=lr(),y=!1;y=f===`none`?v!==``:f===`single`?g!=null:_;let b=u||p||i,{buttonRef:S,getButtonProps:w}=x({native:a,disabled:b}),{mounted:T,transitionStatus:E,setMounted:D}=xt(y),O={disabled:b,visible:y,open:h,transitionStatus:E};gt({open:y,ref:d.state.clearRef,onComplete(){y||D(!1)}});let k=ne(`button`,e,{state:O,ref:[t,S,d.state.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(b||m)return;let t=d.state.keyboardActiveRef;d.state.setInputValue(``,o(C,e.nativeEvent)),f===`none`?d.state.setIndices({activeIndex:null,type:t.current?`keyboard`:`pointer`}):(d.state.setSelectedValue(Array.isArray(g)?[]:null,o(C,e.nativeEvent)),d.state.setIndices({activeIndex:null,selectedIndex:null,type:t.current?`keyboard`:`pointer`})),d.state.inputRef.current?.focus()}},l,w],stateAttributesMapping:Ar});return s||T?k:null}),Mr=Z.createContext(null);function Nr(){return Z.useContext(Mr)}function Pr(e){let{children:t}=e,{filteredItems:n}=cr(),r=Nr(),i=r?r.items:n;return i?(0,Q.jsx)(Z.Fragment,{children:i.map(t)}):null}var Fr=Z.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=or(),l=sr(),u=!!Dr(!0),{filteredItems:d,hasItems:f}=cr(),p=Y(c,$.selectionMode),h=Y(c,$.grid),g=Y(c,$.popupProps),_=Y(c,$.virtualized),v=Y(c,$.forceMounted),y=p===`multiple`,b=d.length===0,x=m(e=>{c.set(`positionerElement`,e)}),S=m(e=>{c.set(`listElement`,e)}),C=Z.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(Pr,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=ne(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:h?`grid`:`listbox`,"aria-multiselectable":y?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;tt(e);let n=e.nativeEvent,r=c.state.listRef.current[t];r&&(c.state.selectionEventRef.current=n,r.click(),c.state.selectionEventRef.current=null)}},onKeyDownCapture(){c.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.state.keyboardActiveRef.current=!1}},s]});if(_)return E;let D=f&&!v?void 0:c.state.labelsRef;return(0,Q.jsx)(bt,{elementsRef:c.state.listRef,labelsRef:D,children:E})}),Ir=``;function Lr(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Rr(){let e=b(),t=Z.useRef(null);return Z.useEffect(()=>{if(it)return;let n=t.current;if(n==null)return;let r=Lr(n);if(r==null)return;let i=r.nodeValue??``,a=`${i}${Ir}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var zr=Z.createContext(void 0);function Br(){let e=Z.useContext(zr);if(e===void 0)throw Error(s(20));return e}var Vr=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=or(),a=Y(i,$.mounted),o=Y(i,$.forceMounted);return a||n||o?(0,Q.jsx)(zr.Provider,{value:n,children:(0,Q.jsx)(Ut,{ref:t,...r})}):null}),Hr=Z.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=$e,style:_,...v}=e,y=or(),{filteredItems:b}=cr(),x=sr(),S=Br(),C=Y(y,$.modal),w=Y(y,$.open),E=Y(y,$.mounted),D=Y(y,$.openMethod),O=Y(y,$.positionerElement),k=Y(y,$.triggerElement),A=Y(y,$.inputElement),j=Y(y,$.inputGroupElement),M=Y(y,$.inputInsidePopup),N=Y(y,$.transitionStatus),P=b.length===0,F=Xe({anchor:i??(M?k:j??A),floatingRootContext:x,positionMethod:a,mounted:E,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:h,keepMounted:S,collisionAvoidance:g,lazyFlip:!0});_t(w&&C,D===`touch`,O,k);let I={open:w,side:F.side,align:F.align,anchorHidden:F.anchorHidden,empty:P};T(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=m(e=>{y.set(`positionerElement`,e)}),L=ut(e,I,{styles:F.positionerStyles,transitionStatus:N,props:v,refs:[t,ee],hidden:!E,inert:!w});return(0,Q.jsxs)(Er.Provider,{value:F,children:[E&&C&&(0,Q.jsx)(rt,{inert:lt(!w),cutout:j??A??k}),L]})}),Ur={...yt,...vt},Wr=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=or(),l=Dr(),u=sr(),{filteredItems:d}=cr(),f=Y(c,$.mounted),p=Y(c,$.open),m=Y(c,$.openMethod),h=Y(c,$.transitionStatus),g=Y(c,$.inputInsidePopup),_=Y(c,$.inputElement),v=Y(c,$.modal),y=Y(c,$.id),b=d.length===0,x=s.id??(g?dr(y):void 0);T(()=>(c.set(`popupId`,c.state.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),gt({open:p,ref:c.state.popupRef,onComplete(){p&&c.state.onOpenChangeComplete(!0)}});let S=ne(`div`,e,{state:{open:p,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.state.popupRef],props:[{id:x,role:g?`dialog`:`presentation`,tabIndex:-1,onFocus(e){let t=ee(e.nativeEvent);m!==`touch`&&(P(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},at(h),s],stateAttributesMapping:Ur}),C=a===void 0?g?e=>e===`touch`?c.state.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let E=!g||v;return(0,Q.jsx)(K,{context:u,disabled:!f,modal:E,openInteractionType:m,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,Q.jsxs)(Z.Fragment,{children:[S,E&&(0,Q.jsx)(Or,{ref:c.state.endDismissRef})]})})}),Gr=Z.createContext(void 0);function Kr(){let e=Z.useContext(Gr);if(!e)throw Error(s(19));return e}var qr=Z.createContext(!1);function Jr(){return Z.useContext(qr)}var Yr=e(r(),1);function Xr(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=Z.useRef(!1),m=Z.useRef(null),h=Ct({index:l,textRef:m,indexGuessBehavior:Dt.GuessFromOrder}),g=or(),_=Jr(),v=ur(),y=Y(g,$.open),b=Y(g,$.selectionMode),S=Y(g,$.readOnly),C=Y(g,$.isItemEqualToValue),w=b!==`none`,E=l??(r?i??-1:h.index),D=h.index!==-1,O=Y(g,$.id),k=Y(g,$.isActive,E),A=Y(g,$.isSelected,c),j=Y(g,$.itemProps),M=Z.useRef(null),N=O!=null&&D?`${O}-${E}`:void 0,P=A&&w;T(()=>{if(!(D&&(r||l!=null)))return;let e=g.state.listRef.current;return e[E]=M.current,()=>{delete e[E]}},[D,r,E,l,g]),T(()=>{if(!D||v)return;let e=g.state.valuesRef.current;return e[E]=c,b!==`none`&&g.state.allValuesRef.current.push(c),()=>{delete e[E]}},[D,v,E,c,g,b]),T(()=>{if(!y){p.current=!1;return}if(!D||v)return;let e=g.state.selectedValue;he(c,Array.isArray(e)?e[e.length-1]:e,C)&&g.set(`selectedIndex`,E)},[D,v,y,g,E,c,C]);let{getButtonProps:F,buttonRef:I}=x({disabled:u,focusableWhenDisabled:!0,native:d,composite:!0}),ee={disabled:u,selected:P,highlighted:k};function L(e){function t(){g.state.handleSelection(e,c)}g.state.submitOnItemClick?(Yr.flushSync(t),g.state.requestSubmit()):t()}let te={id:N,role:_?`gridcell`:`option`,"aria-selected":w?P:void 0,tabIndex:void 0,onPointerDownCapture(e){p.current=!0,e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){u||S||L(e.nativeEvent)},onMouseUp(e){let t=p.current;p.current=!1,!(u||S||e.button!==0||t||!k)&&L(e.nativeEvent)}},re=ne(`div`,t,{ref:[I,n,h.ref,M],state:ee,props:[j,te,f,F]}),ie=Z.useMemo(()=>({selected:P,textRef:m}),[P,m]);return(0,Q.jsx)(Gr.Provider,{value:ie,children:re})}function Zr(e){let{componentProps:t,forwardedRef:n}=e,r=Y(or(),$.isItemEqualToValue),{flatFilteredItems:i}=cr();return(0,Q.jsx)(Xr,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:ve(i,t.value??null,r)})}var Qr=Z.memo(Z.forwardRef(function(e,t){let n=Y(or(),$.virtualized);return n&&e.index==null?(0,Q.jsx)(Zr,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(Xr,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),$r=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=cr(),c=or(),l=Rr(),u=s.length===0?a:null;return ne(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function ei(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,Q.jsx)(br,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var ti=Z.forwardRef(function(e,t){let n=e.keepMounted??!1,{selected:r}=Kr();return n||r?(0,Q.jsx)(ni,{...e,ref:t}):null}),ni=Z.memo(Z.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Kr(),c=Z.useRef(null),{transitionStatus:l,setMounted:u}=xt(s),d=ne(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:vt});return gt({open:s,ref:c,onComplete(){s||u(!1)}}),d})),ri=ei;function ii({className:e,children:t,...n}){return(0,Q.jsxs)(Cr,{"data-slot":`combobox-trigger`,className:l(`cursor-pointer data-disabled:cursor-not-allowed [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,Q.jsx)(ge,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function ai({className:e,...t}){return(0,Q.jsx)(jr,{"data-slot":`combobox-clear`,render:(0,Q.jsx)(Oe,{variant:`ghost`,size:`icon-xs`}),className:l(e),...t,children:(0,Q.jsx)(ke,{className:`pointer-events-none`})})}function oi({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...a}){return(0,Q.jsxs)(Me,{className:l(`w-auto`,e),children:[(0,Q.jsx)(kr,{render:(0,Q.jsx)(xe,{disabled:n}),...a}),(0,Q.jsxs)(Pe,{align:`inline-end`,children:[r&&(0,Q.jsx)(Oe,{size:`icon-xs`,variant:`ghost`,render:(0,Q.jsx)(ii,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n}),i&&(0,Q.jsx)(ai,{disabled:n})]}),t]})}function si({className:e,side:t=`bottom`,sideOffset:n=6,align:r=`start`,alignOffset:i=0,anchor:a,...o}){return(0,Q.jsx)(Vr,{children:(0,Q.jsx)(Hr,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:a,className:`isolate z-50`,children:(0,Q.jsx)(Wr,{"data-slot":`combobox-content`,"data-chips":!!a,className:l(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o})})})}function ci({className:e,...t}){return(0,Q.jsx)(Fr,{"data-slot":`combobox-list`,className:l(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,e),...t})}function li({className:e,children:t,...n}){return(0,Q.jsxs)(Qr,{"data-slot":`combobox-item`,className:l(`relative flex w-full cursor-pointer items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,Q.jsx)(ti,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,Q.jsx)(et,{className:`pointer-events-none`})})]})}function ui({className:e,...t}){return(0,Q.jsx)($r,{"data-slot":`combobox-empty`,className:l(`hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex`,e),...t})}var di=`cline.code.model-selection.v1`;function fi(e){return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([e,t])=>typeof e==`string`&&typeof t==`string`&&t.trim().length>0))}function pi(e){let t={lastProvider:``,lastModelByProvider:{}};if(!e)return t;try{let n=JSON.parse(e);if(!n||typeof n!=`object`||Array.isArray(n))return t;let r=n;return`lastProvider`in r||`lastModelByProvider`in r?{lastProvider:typeof r.lastProvider==`string`?r.lastProvider.trim():``,lastModelByProvider:fi(r.lastModelByProvider)}:{lastProvider:``,lastModelByProvider:fi(n)}}catch{return t}}function mi(){return typeof window>`u`?{lastProvider:``,lastModelByProvider:{}}:pi(window.localStorage.getItem(di))}var hi={openai:`openai-native`,google:`gemini`};function gi(e){let t=e.trim();return t?hi[t]??t:``}function _i(e){return(e??[]).map(e=>e.id)}function vi(e){return(e??[]).filter(e=>e.supportsReasoning).map(e=>e.id)}function yi(e){return{providers:e,enabledProviderIds:e.filter(e=>e.enabled).map(e=>e.id),providerModels:Object.fromEntries(e.map(e=>[e.id,_i(e.modelList)])),providerReasoningModels:Object.fromEntries(e.map(e=>[e.id,vi(e.modelList)]))}}async function bi(){return yi((await G.invoke(`list_provider_catalog`)).providers??[])}async function xi(e){return(await G.invoke(`list_provider_models`,{provider:e})).models??[]}var Si=3e4,Ci=null;async function wi(){let e=await G.invoke(`list_routine_schedules`);return{schedules:e.schedules??[],activeExecutions:e.activeExecutions??[],upcomingRuns:e.upcomingRuns??[],lastExecutions:e.lastExecutions??[]}}var Ti={cline:[`anthropic/claude-sonnet-4.6`],anthropic:[`claude-sonnet-4-6`],"openai-native":[`gpt-5.3-codex`],openrouter:[`anthropic/claude-sonnet-4.6`],gemini:[`gemini-2.5-pro`]},Ei=[{label:`Mon`,value:`MON`},{label:`Tue`,value:`TUE`},{label:`Wed`,value:`WED`},{label:`Thu`,value:`THU`},{label:`Fri`,value:`FRI`},{label:`Sat`,value:`SAT`},{label:`Sun`,value:`SUN`}];function Di(e){if(e==null)return`-`;if(typeof e==`number`){if(!Number.isFinite(e))return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.toLocaleString()}let t=e.trim();if(t.length===0)return`-`;let n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Oi(e){let t=e.modelSelection?.providerId?.trim()||e.provider?.trim(),n=e.modelSelection?.modelId?.trim()||e.model?.trim();return t&&n?`${t}/${n}`:n||t||`-`}function ki(e){return{provider:e.modelSelection?.providerId?.trim()||e.provider?.trim()||`cline`,model:e.modelSelection?.modelId?.trim()||e.model?.trim()||`openai/gpt-5.3-codex`}}function Ai(e){if(!e)return`-`;let t=e.status?.trim()||`unknown`,n=Di(e.endedAt??e.startedAt??e.triggeredAt);return n===`-`?t:`${t} at ${n}`}function ji(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<=0))return n}function Mi(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:void 0}function Ni(e){let t=new Set(e);return Ei.map(e=>e.value).filter(e=>t.has(e))}function Pi(e,t,n){let r=Ni(e);if(r.length===0)return``;let i=Number.parseInt(t,10),a=Number.parseInt(n,10),o=Number.isFinite(i)?Math.min(Math.max(i,0),23):9,s=Number.isFinite(a)?Math.min(Math.max(a,0),59):0;return r.length===Ei.length?`${s} ${o} * * *`:`${s} ${o} * * ${r.join(`,`)}`}function Fi(e){let t=e?.trim().toUpperCase();if(!t||t===`*`)return Ei.map(e=>e.value);let n=new Set;for(let e of t.split(`,`)){let t=e.trim();if(!t)continue;let r=/^([A-Z]{3})-([A-Z]{3})$/.exec(t);if(r){let e=Ei.findIndex(e=>e.value===r[1]),t=Ei.findIndex(e=>e.value===r[2]);if(e>=0&&t>=e)for(let r=e;r<=t;r+=1)n.add(Ei[r].value);continue}Ei.some(e=>e.value===t)&&n.add(t)}return Ni([...n])}function Ii(e){let t=e.trim().split(/\s+/),n=Number.parseInt(t[0]??``,10),r=Number.parseInt(t[1]??``,10),i=Fi(t[4]);return{scheduleHour:Number.isInteger(r)&&r>=0&&r<=23?String(r):`9`,scheduleMinute:Number.isInteger(n)&&n>=0&&n<=59?String(n):`0`,scheduleDays:i.length>0?i:[`MON`,`TUE`,`WED`,`THU`,`FRI`]}}function Li(){let[e,t]=(0,Z.useState)(()=>Ci?.schedules??[]),[n,r]=(0,Z.useState)(()=>Ci?.activeExecutions??[]),[i,a]=(0,Z.useState)(()=>Ci?.upcomingRuns??[]),[o,s]=(0,Z.useState)(()=>Ci?.lastExecutions??[]),[c,u]=(0,Z.useState)(()=>!Ci),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(Ti),[D,O]=(0,Z.useState)(()=>Object.keys(Ti)),[k]=(0,Z.useState)(()=>mi()),A=gi(k.lastProvider),[M,N]=(0,Z.useState)({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:`cline`,model:`openai/gpt-5.3-codex`,mode:`act`,workspaceRoot:``,cwd:``,systemPrompt:``,maxIterations:``,timeoutSeconds:``,maxParallel:`1`,tags:``,enabled:!0}),P=(0,Z.useMemo)(()=>{if(D.length===0)return T;let e={};for(let t of D)e[t]=T[t]??[];return e},[D,T]),F=(0,Z.useMemo)(()=>Object.keys(P),[P]),I=(0,Z.useMemo)(()=>P[M.provider]??[],[M.provider,P]),ee=(0,Z.useMemo)(()=>Pi(M.scheduleDays,M.scheduleHour,M.scheduleMinute),[M.scheduleDays,M.scheduleHour,M.scheduleMinute]);(0,Z.useEffect)(()=>{let e=!1;async function t(){try{let t=await bi();if(e)return;E(t.providerModels),O(e=>{let n=new Set(t.enabledProviderIds),r=gi(M.provider);r&&n.add(r);for(let r of e)r in t.providerModels&&n.add(r);return Array.from(n)})}catch{}}return t(),()=>{e=!0}},[M.provider]),(0,Z.useEffect)(()=>{let e=gi(M.provider);if(!e||(T[e]??[]).length>0)return;let t=!1;async function n(){try{let n=await xi(e);if(t||n.length===0)return;E(t=>({...t,[e]:n.map(e=>e.id)})),O(t=>t.includes(e)?t:[...t,e])}catch{}}return n(),()=>{t=!0}},[M.provider,T]),(0,Z.useEffect)(()=>{if(F.length===0)return;let e=null,t=gi(M.provider);if(F.includes(t)){let n=P[t]??[];if(n.length===0||n.includes(M.model))return;let r=k.lastModelByProvider[t]??k.lastModelByProvider[k.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]}}else{let t=A&&F.includes(A)?A:F[0],n=P[t]??[],r=k.lastModelByProvider[t]??k.lastModelByProvider[k.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]??``}}let n=window.setTimeout(()=>{N(t=>({...t,...e}))},0);return()=>window.clearTimeout(n)},[F,M.model,M.provider,k.lastModelByProvider,k.lastProvider,A,P]);let L=(0,Z.useCallback)(async e=>{let n=Date.now();if(!e?.force&&Ci&&n-Ci.fetchedAt<Si){t(Ci.schedules),r(Ci.activeExecutions),a(Ci.upcomingRuns),s(Ci.lastExecutions),f(null),u(!1);return}e?.showLoading!==!1&&u(!0),f(null);try{let e=await wi(),i=e.schedules,o=e.activeExecutions,c=e.upcomingRuns,l=e.lastExecutions;t(i),r(o),a(c),s(l),Ci={schedules:i,activeExecutions:o,upcomingRuns:c,lastExecutions:l,fetchedAt:n}}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{L()},0);return()=>window.clearTimeout(e)},[L]);let te=async(e,t)=>{m(e.scheduleId),f(null);try{t?await G.invoke(`resume_routine_schedule`,{schedule_id:e.scheduleId}):await G.invoke(`pause_routine_schedule`,{schedule_id:e.scheduleId}),await L({force:!0,showLoading:!1})}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},ne=async e=>{m(e),f(null);try{await G.invoke(`trigger_routine_schedule`,{schedule_id:e}),await L({force:!0,showLoading:!1}),window.setTimeout(()=>{L({force:!0,showLoading:!1})},1e3)}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},re=async e=>{m(e),f(null);try{await G.invoke(`delete_routine_schedule`,{schedule_id:e}),g(null),await L({force:!0,showLoading:!1})}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},ie=async()=>{b(null),f(null),w(null);let e={workspaceRoot:``,cwd:``};try{e=await G.invoke(`get_process_context`)}catch{}let t=A&&F.includes(A)?A:F[0]??`cline`,n=P[t]??[],r=k.lastModelByProvider[t]??k.lastModelByProvider[k.lastProvider];N({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:t,model:r&&n.includes(r)?r:n[0]??M.model,mode:`act`,workspaceRoot:e.workspaceRoot||e.cwd,cwd:e.cwd||``,systemPrompt:``,maxIterations:``,timeoutSeconds:``,maxParallel:`1`,tags:``,enabled:!0}),v(!0)},ae=e=>{let{provider:t,model:n}=ki(e),r=Ii(e.cronPattern);b(e),f(null),w(null),O(e=>e.includes(t)?e:[...e,t]),E(e=>e[t]?.includes(n)?e:{...e,[t]:[...e[t]??[],n]}),N({name:e.name,...r,prompt:e.prompt,provider:t,model:n,mode:e.mode===`plan`?`plan`:`act`,workspaceRoot:e.workspaceRoot??``,cwd:e.cwd??``,systemPrompt:e.systemPrompt??``,maxIterations:typeof e.maxIterations==`number`?String(e.maxIterations):``,timeoutSeconds:typeof e.timeoutSeconds==`number`?String(e.timeoutSeconds):``,maxParallel:typeof e.maxParallel==`number`?String(e.maxParallel):`1`,tags:e.tags?.join(`,`)??``,enabled:e.enabled}),v(!0)},oe=async()=>{let e=M.name.trim();if(!e){w(`Routine name is required.`);return}let t=Pi(M.scheduleDays,M.scheduleHour,M.scheduleMinute);if(!t){w(`Select at least one day and a valid time.`);return}let n=M.prompt.trim();if(!n){w(`Prompt is required.`);return}let r=M.workspaceRoot.trim();if(!r){w(`Workspace root is required.`);return}w(null),S(!0);try{let i=gi(M.provider)||F[0]||`cline`,a=M.model.trim()||(P[i]??[])[0]||`openai/gpt-5.3-codex`,o=ji(M.maxIterations),s=ji(M.timeoutSeconds),c=ji(M.maxParallel)??1,l=Mi(M.tags),u=y?`update_routine_schedule`:`create_routine_schedule`;await G.invoke(u,{...y?{schedule_id:y.scheduleId}:void 0,name:e,cron_pattern:t,prompt:n,provider:i,model:a,mode:M.mode,workspace_root:r,cwd:M.cwd.trim()||void 0,system_prompt:y?M.systemPrompt.trim()||null:M.systemPrompt.trim()||void 0,max_iterations:y?o??null:o,timeout_seconds:y?s??null:s,max_parallel:c,enabled:M.enabled,tags:l??[]}),await L({force:!0,showLoading:!1}),v(!1),b(null)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},se=(0,Z.useMemo)(()=>{let e=new Map;for(let t of n)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[n]),ce=(0,Z.useMemo)(()=>{let e=new Map;for(let t of o)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[o]),R=(0,Z.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]);return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`Scheduled jobs are run through the hub.`,title:`Schedules`,meta:(0,Q.jsx)(wt,{children:`cline schedule`}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:c,children:(0,Q.jsx)(He,{className:l(`h-4 w-4`,c&&`animate-spin`)})}),(0,Q.jsxs)(z,{size:`sm`,onClick:()=>void ie(),children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),`New Schedule`]})]})}),d&&(0,Q.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),c?(0,Q.jsx)(ft,{children:`Loading schedules...`}):R.length===0?(0,Q.jsx)(ft,{children:`No schedules found. Create a schedule to run routines on a recurring basis.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:R.map(e=>{let t=p===e.scheduleId,n=se.get(e.scheduleId),r=ce.get(e.scheduleId),a=i.find(t=>t.scheduleId===e.scheduleId);return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(B,{className:l(`h-2.5 w-2.5 shrink-0`,e.enabled?`fill-primary text-primary`:`fill-muted-foreground/40 text-muted-foreground/40`)}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.mode}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.cronPattern}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`View ${e.name}`,onClick:()=>{window.alert(JSON.stringify(e,null,2))},children:(0,Q.jsx)(en,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ae(e),disabled:t,children:(0,Q.jsx)(Kt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run ${e.name} now`,onClick:()=>void ne(e.scheduleId),disabled:t,children:(0,Q.jsx)(Ue,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":e.enabled?`Pause ${e.name}`:`Resume ${e.name}`,onClick:()=>void te(e,!e.enabled),disabled:t,children:e.enabled?(0,Q.jsx)(on,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>g(e),disabled:t,children:(0,Q.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Ye,{checked:e.enabled,onCheckedChange:t=>void te(e,t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,Q.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`ID:`}),` `,e.scheduleId]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Prompt:`}),` `,e.prompt]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Model:`}),` `,Oi(e)]}),e.workspaceRoot&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Workspace:`}),` `,e.workspaceRoot]}),e.cwd&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last run:`}),` `,Di(e.lastRunAt)]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last result:`}),` `,Ai(r)]}),r?.sessionId&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last session:`}),` `,r.sessionId]}),r?.errorMessage&&(0,Q.jsxs)(`p`,{className:`text-destructive`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last error:`}),` `,r.errorMessage]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Next run:`}),` `,Di(e.nextRunAt||a?.nextRunAt)]}),n&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Active:`}),` `,n.executionId,` since`,` `,Di(n.startedAt)]}),e.tags&&e.tags.length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Tags:`}),` `,e.tags.join(`, `)]})]})]},e.scheduleId)})}),(0,Q.jsx)(q,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,Q.jsxs)(Wt,{children:[(0,Q.jsxs)(ot,{children:[(0,Q.jsx)(Qe,{children:`Delete Routine`}),(0,Q.jsxs)(mt,{children:[`This will delete "`,h?.name??`this routine`,`" and remove future scheduled runs.`]})]}),(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Rt,{disabled:h?p===h.scheduleId:!1,children:`Cancel`}),(0,Q.jsx)(dt,{disabled:!h||p===h.scheduleId,onClick:()=>{h&&re(h.scheduleId)},variant:`destructive`,children:`Delete`})]})]})}),(0,Q.jsx)(Ce,{open:_,onOpenChange:e=>{v(e),e||(w(null),b(null))},children:(0,Q.jsxs)(je,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ne,{children:y?`Edit Routine`:`Create Routine`}),(0,Q.jsx)(Ie,{children:y?`Update this scheduler routine.`:`Create a scheduler routine.`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-name`,children:`Name`}),(0,Q.jsx)(j,{id:`routine-name`,value:M.name,onChange:e=>N(t=>({...t,name:e.target.value})),placeholder:`Daily code review`})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2 space-y-3`,children:[(0,Q.jsx)(W,{children:`Schedule`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 rounded-md border border-border p-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-hour`,children:`Hour`}),(0,Q.jsxs)(De,{value:M.scheduleHour,onValueChange:e=>N(t=>({...t,scheduleHour:e??t.scheduleHour})),children:[(0,Q.jsx)(Le,{className:`w-full`,id:`routine-hour`,children:(0,Q.jsx)(Be,{placeholder:`Hour`})}),(0,Q.jsx)(Ee,{children:Array.from({length:24},(e,t)=>t).map(e=>(0,Q.jsx)(be,{value:`${e}`,children:e.toString().padStart(2,`0`)},`hour-${e}`))})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-minute`,children:`Minute`}),(0,Q.jsxs)(De,{value:M.scheduleMinute,onValueChange:e=>N(t=>({...t,scheduleMinute:e??t.scheduleMinute})),children:[(0,Q.jsx)(Le,{className:`w-full`,id:`routine-minute`,children:(0,Q.jsx)(Be,{placeholder:`Minute`})}),(0,Q.jsx)(Ee,{children:Array.from({length:60},(e,t)=>t).map(e=>(0,Q.jsx)(be,{value:`${e}`,children:e.toString().padStart(2,`0`)},`minute-${e}`))})]})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{children:`Days of week`}),(0,Q.jsx)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-4`,children:Ei.map(e=>{let t=`routine-day-${e.value.toLowerCase()}`;return(0,Q.jsxs)(W,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-sm`,htmlFor:t,children:[(0,Q.jsx)($n,{checked:M.scheduleDays.includes(e.value),id:t,onCheckedChange:t=>N(n=>{let r=new Set(n.scheduleDays);return t===!0?r.add(e.value):r.delete(e.value),{...n,scheduleDays:Ni([...r])}})}),e.label]},e.value)})})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2 rounded-md border border-border bg-muted/30 px-2 py-1.5 text-xs text-muted-foreground`,children:[`Cron:`,` `,(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:ee||`Select one or more days`})]})]})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-prompt`,children:`Prompt`}),(0,Q.jsx)(Fe,{id:`routine-prompt`,value:M.prompt,onChange:e=>N(t=>({...t,prompt:e.target.value})),rows:4})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{children:`Provider`}),(0,Q.jsxs)(ri,{items:F,onValueChange:e=>{if(!e)return;let t=P[e]??[],n=k.lastModelByProvider[e],r=n&&t.includes(n)?n:t[0]??``;N(t=>({...t,provider:e,model:r}))},value:M.provider,children:[(0,Q.jsx)(oi,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,Q.jsxs)(si,{children:[(0,Q.jsx)(ui,{children:`No providers found.`}),(0,Q.jsx)(ci,{children:e=>(0,Q.jsx)(li,{value:e,children:e},e)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{children:`Model`}),(0,Q.jsxs)(ri,{items:I,onValueChange:e=>{e&&N(t=>({...t,model:e}))},value:M.model,children:[(0,Q.jsx)(oi,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,Q.jsxs)(si,{children:[(0,Q.jsx)(ui,{children:`No models found.`}),(0,Q.jsx)(ci,{children:e=>(0,Q.jsx)(li,{value:e,children:e},e)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{children:`Mode`}),(0,Q.jsxs)(De,{value:M.mode,onValueChange:e=>N(t=>({...t,mode:e===`plan`?`plan`:`act`})),children:[(0,Q.jsx)(Le,{className:`w-full`,children:(0,Q.jsx)(Be,{placeholder:`Select mode`})}),(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(be,{value:`act`,children:`act`}),(0,Q.jsx)(be,{value:`plan`,children:`plan`})]})]})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-workspace`,children:`Workspace root`}),(0,Q.jsx)(j,{id:`routine-workspace`,value:M.workspaceRoot,onChange:e=>N(t=>({...t,workspaceRoot:e.target.value}))})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-cwd`,children:`CWD (optional)`}),(0,Q.jsx)(j,{id:`routine-cwd`,value:M.cwd,onChange:e=>N(t=>({...t,cwd:e.target.value}))})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-system-prompt`,children:`System prompt (optional)`}),(0,Q.jsx)(Fe,{id:`routine-system-prompt`,value:M.systemPrompt,onChange:e=>N(t=>({...t,systemPrompt:e.target.value})),rows:3})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-max-iterations`,children:`Max iterations (optional)`}),(0,Q.jsx)(j,{id:`routine-max-iterations`,value:M.maxIterations,onChange:e=>N(t=>({...t,maxIterations:e.target.value})),placeholder:`50`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-timeout`,children:`Timeout seconds (optional)`}),(0,Q.jsx)(j,{id:`routine-timeout`,value:M.timeoutSeconds,onChange:e=>N(t=>({...t,timeoutSeconds:e.target.value})),placeholder:`3600`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-max-parallel`,children:`Max parallel`}),(0,Q.jsx)(j,{id:`routine-max-parallel`,value:M.maxParallel,onChange:e=>N(t=>({...t,maxParallel:e.target.value})),placeholder:`1`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-tags`,children:`Tags (comma-separated, optional)`}),(0,Q.jsx)(j,{id:`routine-tags`,value:M.tags,onChange:e=>N(t=>({...t,tags:e.target.value})),placeholder:`automation,review`})]})]}),C&&(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:C}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(z,{variant:`outline`,onClick:()=>v(!1),disabled:x,children:`Cancel`}),(0,Q.jsx)(z,{onClick:()=>void oe(),disabled:x,children:x?y?`Saving...`:`Creating...`:y?`Save Changes`:`Create Schedule`})]})]})})]})}function Ri(e,t,n){let r=t.split(`.`).filter(Boolean);if(r.length===0)return;let i=e;for(let e of r.slice(0,-1)){let t=i[e];(!t||typeof t!=`object`||Array.isArray(t))&&(i[e]={}),i=i[e]}let a=r.at(-1);a&&(i[a]=n)}function zi(e){let t={};for(let[n,r]of Object.entries(e))Ri(t,n,r);return t}var Bi=[`General`,`Providers`,`MCP`,`Channels`,`Schedules`,`Account`],Vi=6e4,Hi=null;function Ui({chrome:e=`full`,initialSection:t=`General`,onClose:n,onNavigateSection:r}){let[i,a]=(0,Z.useState)(t),[o,s]=(0,Z.useState)(!0),[c,u]=(0,Z.useState)(()=>Hi?.providers??[]),[d,f]=(0,Z.useState)(()=>!Hi),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useCallback)(e=>{u(t=>{let n=typeof e==`function`?e(t):e;return Hi={providers:n,fetchedAt:Date.now()},n})},[]),E=(0,Z.useCallback)(async()=>{if(Hi&&Date.now()-Hi.fetchedAt<Vi){u(Hi.providers),f(!1),m(null);return}f(!0),m(null);try{T((await G.invoke(`list_provider_catalog`)).providers)}catch(e){m(e instanceof Error?e.message:String(e)),u([])}finally{f(!1)}},[T]);(0,Z.useEffect)(()=>{if(i!==`Providers`)return;let e=window.setTimeout(()=>{E()},0);return()=>window.clearTimeout(e)},[i,E]);let D=(0,Z.useCallback)(async(e,t)=>{try{await G.invoke(`save_provider_settings`,{provider:e,enabled:t.enabled,api_key:t.apiKey,base_url:t.baseUrl,settings:t.configValues?zi(t.configValues):void 0})}catch(t){let n=t instanceof Error?t.message:String(t);window.alert(`Failed to save provider settings for ${e}: ${n}`)}},[]),O=(0,Z.useCallback)(e=>{T(t=>t.map(t=>{if(t.id!==e)return t;let n=!t.enabled;return D(e,{enabled:n}),{...t,enabled:n}}))},[D,T]),k=(0,Z.useCallback)((e,t)=>{T(n=>n.map(n=>n.id===e?{...n,...t,configValues:t.configValues?{...n.configValues??{},...t.configValues}:n.configValues}:n)),D(e,{apiKey:t.apiKey,baseUrl:t.baseUrl,configValues:t.configValues})},[D,T]),A=(0,Z.useCallback)(async e=>{g(t=>({...t,[e]:!0})),v(t=>({...t,[e]:null}));try{let t=await G.invoke(`list_provider_models`,{provider:e});T(n=>n.map(n=>n.id===e?{...n,modelList:t.models,models:t.models.length}:n))}catch(t){let n=t instanceof Error?t.message:String(t);v(t=>({...t,[e]:n}))}finally{g(t=>({...t,[e]:!1}))}},[T]),j=c.filter(e=>e.enabled),M=x?c.find(e=>e.id===x)??null:null,N=e=>e===`cline`||e===`oca`||e===`openai-codex`,P=async e=>{b(e);try{let t=await G.invoke(`run_provider_oauth_login`,{provider:e});T(n=>n.map(n=>n.id===e?{...n,enabled:!0,oauthAccessTokenPresent:t.accessToken.trim().length>0}:n)),S(e)}catch(t){let n=t instanceof Error?t.message:String(t);window.alert(`Failed to sign in to ${e}: ${n}`)}finally{b(null)}},F=e=>{a(`Providers`),r?.(`Providers`),S(e)};(0,Z.useEffect)(()=>{if(!x)return;let e=c.find(e=>e.id===x);if(!e||(e.modelList?.length??0)>0)return;let t=window.setTimeout(()=>{A(x)},0);return()=>window.clearTimeout(t)},[A,c,x]);let I=()=>{r?.(`Providers`),S(null),w(!1)},ee=(0,Z.useCallback)(async e=>{await G.invoke(`add_provider`,{provider_id:e.providerId,name:e.name,base_url:e.baseUrl,api_key:e.apiKey,headers:e.headers,timeout_ms:e.timeoutMs,models:e.models,default_model_id:e.defaultModelId,models_source_url:e.modelsSourceUrl,capabilities:e.capabilities}),await E(),w(!1),S(e.providerId)},[E]),L=()=>{r?.(`Providers`),S(null),w(!0)},te=e=>{a(e),r?.(e),S(null),w(!1)},ne=C?(0,Q.jsx)(Cn,{existingProviderIds:c.map(e=>e.id),onBack:I,onSave:ee}):d?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading providers...`})}):p?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsxs)(`p`,{className:`max-w-xl px-4 text-center text-sm text-destructive`,children:[`Failed to load providers: `,p]})}):M?(0,Q.jsxs)(`div`,{className:`grid h-full grid-cols-[minmax(24rem,0.95fr)_minmax(28rem,1.05fr)] overflow-hidden max-[1100px]:grid-cols-1 max-[1100px]:grid-rows-[minmax(24rem,0.9fr)_minmax(26rem,1fr)]`,children:[(0,Q.jsx)(Un,{onAddProvider:L,onConfigure:F,onToggle:O,providers:c,selectedProviderId:M.id,variant:`panel`}),(0,Q.jsx)(`aside`,{className:`min-h-0 overflow-hidden border-l bg-background max-[1100px]:border-l-0 max-[1100px]:border-t`,children:(0,Q.jsx)(Wn,{modelsError:_[M.id]??null,modelsLoading:h[M.id]??!1,oauthLoginPending:y===M.id,onBack:I,onLoadModels:()=>void A(M.id),onOAuthLogin:N(M.id)?()=>void P(M.id):void 0,onUpdate:e=>k(M.id,e),provider:M,variant:`panel`})})]}):(0,Q.jsx)(Un,{onAddProvider:L,onConfigure:F,onToggle:O,providers:c}),re=i===`Providers`?ne:i===`MCP`?(0,Q.jsx)(zn,{}):i===`Channels`?(0,Q.jsx)(Mn,{}):i===`Schedules`?(0,Q.jsx)(Li,{}):i===`Account`?(0,Q.jsx)(xn,{}):i===`General`?(0,Q.jsx)(Wi,{}):(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i,` settings coming soon.`]})});return e===`content`?(0,Q.jsx)(`div`,{className:`h-full overflow-hidden bg-background`,children:re}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border px-6 py-3`,children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Settings`}),(0,Q.jsx)(z,{"aria-label":`Close settings`,className:`justify-start`,onClick:n,variant:`ghost`,children:(0,Q.jsx)(ke,{className:`size-3`})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,Q.jsx)(`nav`,{className:`w-56 shrink-0 border-r border-border`,children:(0,Q.jsx)(ht,{className:`h-full`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 p-3`,children:Bi.map(e=>e===`Providers`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(z,{className:l(`flex w-full items-center justify-between rounded-md px-3 py-2 text-sm transition-colors`,i===`Providers`?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>{te(`Providers`),s(e=>!e)},variant:`ghost`,children:[(0,Q.jsx)(`span`,{children:`Providers`}),o?(0,Q.jsx)(ge,{className:`size-3`}):(0,Q.jsx)(Yt,{className:`size-3`})]}),o&&(0,Q.jsx)(`div`,{className:`ml-3 mt-0.5 flex flex-col gap-0.5 border-l border-border pl-2`,children:j.map(e=>(0,Q.jsx)(z,{className:l(`justify-start`,x===e.id?`bg-accent/80 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/30`),disabled:y===e.id,onClick:()=>F(e.id),variant:`ghost`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})},e.id))})]},e):(0,Q.jsx)(z,{className:l(`justify-start`,i===e&&!x?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>{te(e)},variant:`ghost`,children:e},e))})})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:re})]})]})}function Wi(){let[e,t]=(0,Z.useState)(()=>typeof window>`u`?`light`:X()??Ot()),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v=(0,Z.useCallback)(async()=>{a(!0),l(null),p(!0),_(null);try{let e=await G.invoke(`get_global_settings`);r(e.telemetryOptOut),d(e.autoUpdateEnabled)}catch(e){let t=e instanceof Error?e.message:String(e);l(t),_(t)}finally{a(!1),p(!1)}},[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{v()},0);return()=>window.clearTimeout(e)},[v]);let y=async e=>{let t=n;r(e),s(!0),l(null);try{r((await G.invoke(`set_telemetry_opt_out`,{telemetry_opt_out:e})).telemetryOptOut)}catch(e){let n=e instanceof Error?e.message:String(e);r(t),l(n)}finally{s(!1)}},b=async e=>{let t=u;d(e),h(!0),_(null);try{d((await G.invoke(`set_auto_update_enabled`,{auto_update_enabled:e})).autoUpdateEnabled)}catch(e){let n=e instanceof Error?e.message:String(e);d(t),_(n)}finally{h(!1)}};return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`Manage Hub preferences for this browser and CLI environment.`,title:`Settings`}),(0,Q.jsxs)(`section`,{className:`max-w-[86rem]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center justify-between gap-5 border-b max-[720px]:flex-col max-[720px]:items-stretch max-[720px]:py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Dark mode`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Keep the Hub interface in dark mode on this browser.`})]}),(0,Q.jsx)(Ye,{"aria-label":`Dark mode`,checked:e===`dark`,onCheckedChange:e=>{t(Nt(e?`dark`:`light`)),window.dispatchEvent(new Event(`cline-hub-theme-change`))}})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center justify-between gap-5 border-b max-[720px]:flex-col max-[720px]:items-stretch max-[720px]:py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Auto update`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Automatically install CLI updates on startup.`}),g?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update auto update setting: `,g]}):null]}),(0,Q.jsx)(Ye,{"aria-label":`Auto update`,checked:u,disabled:f||m,onCheckedChange:e=>void b(e)})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center justify-between gap-5 border-b max-[720px]:flex-col max-[720px]:items-stretch max-[720px]:py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Telemetry`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Enable error and usage report to help us improve Cline.`}),c?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update telemetry setting: `,c]}):null]}),(0,Q.jsx)(Ye,{"aria-label":`Telemetry`,checked:!n,disabled:i||o,onCheckedChange:e=>void y(!e)})]})]})]})}export{Ui as SettingsView};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-CPvDmBTC.js";import{t as r}from"./react-dom-hobdzdVk.js";import{$ as i,A as a,B as o,Bt as s,D as c,E as l,F as u,Ht as d,I as f,K as p,L as m,Mt as h,O as g,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as D,Y as O,Z as k,_ as A,c as j,ct as M,d as N,dt as P,et as F,f as I,ft as ee,g as L,h as te,k as ne,l as re,lt as ie,m as ae,p as oe,st as se,u as ce,v as R,w as le,x as ue,xt as de,y as z}from"./vscode-DK7ayvks.js";import{A as fe,C as pe,D as me,E as he,F as B,I as ge,M as V,N as _e,O as ve,P as H,S as ye,T as U,_ as be,a as xe,b as Se,c as Ce,d as we,f as Te,g as Ee,h as De,i as Oe,j as ke,k as Ae,l as je,n as Me,p as Ne,r as Pe,s as Fe,t as W,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./label-Mo02KX88.js";import{a as Ve,i as He,n as Ue,r as We,t as G}from"./desktop-client-Cbu3aJ5_.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./switch-O5JzNA9x.js";import{$ as Xe,B as Ze,C as Qe,Ct as $e,G as et,Mt as tt,Nt as nt,O as rt,Pt as it,Q as at,S as ot,Tt as st,W as ct,X as lt,Z as ut,_ as dt,a as ft,at as pt,b as mt,bt as K,c as ht,ct as gt,d as _t,dt as vt,et as yt,f as bt,ft as xt,g as q,gt as St,h as Ct,ht as J,i as wt,it as Tt,kt as Et,m as Dt,mt as Y,n as Ot,nt as kt,o as At,ot as jt,pt as Mt,r as Nt,rt as Pt,s as Ft,t as X,tt as It,u as Lt,v as Rt,vt as zt,w as Bt,wt as Vt,x as Ht,xt as Ut,y as Wt,yt as Gt,z as Kt}from"./index-BGdYnZ-k.js";var qt=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Jt=S(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),Yt=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Xt=S(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Zt=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),Qt=S(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),$t=S(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),en=S(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),tn=S(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),nn=S(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),rn=S(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),an=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),on=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),sn=S(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),Z=e(t(),1),cn=Z.createContext({disabled:!1});function ln(){return Z.useContext(cn)}var un=Z.createContext(void 0);function dn(e=!0){let t=Z.useContext(un);if(t===void 0&&!e)throw Error(s(3));return t}var Q=n();function fn(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 pn(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 mn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function hn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function gn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function _n(e){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function vn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function yn(e,t){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function bn(){return await G.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function xn(){let[e,t]=(0,Z.useState)(`overview`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(!0),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(0),[E,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),P=d.find(e=>e.active)??null,F=(0,Z.useCallback)(()=>{a(null),s(null),u(null),f([]),v([]),w(!1),S(null),D([]),N(!1),j(null)},[]),I=(0,Z.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([mn(),hn(),gn()]),r=n.find(e=>e.active)??null,i=r?await _n(r.organizationId):null;a(e),s(t),u(i),f(n)}catch(e){F();let t=fn(e).message;g(t)}finally{m(!1)}},[F]);(0,Z.useEffect)(()=>{I()},[I]);let ee=async()=>{r(`sign-in`),g(null);try{await G.invoke(`run_provider_oauth_login`,{provider:`cline`}),await I(),t(`overview`)}catch(e){let t=fn(e).message;g(t),F()}finally{r(null)}},L=async()=>{r(`sign-out`);try{await G.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),F(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=fn(e).message;g(t)}finally{r(null)}},te=(0,Z.useCallback)(async()=>{let e=T.current;b(!0),S(null);try{let t=P?await yn(P.organizationId,P.memberId):await vn();if(T.current!==e)return;v(t),w(!0)}catch(t){if(T.current!==e)return;let n=fn(t).message;S(n)}finally{T.current===e&&b(!1)}},[P]);(0,Z.useEffect)(()=>{T.current+=1,v([]),w(!1),S(null)},[P?.organizationId]),(0,Z.useEffect)(()=>{e===`usage`&&!C&&te()},[e,C,te]);let ne=(0,Z.useCallback)(async()=>{k(!0),j(null);try{D(await bn()),N(!0)}catch(e){let t=fn(e).message;j(t)}finally{k(!1)}},[]);(0,Z.useEffect)(()=>{e===`billing`&&!M&&ne()},[e,M,ne]);let re=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ie=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),ae=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),oe=P?c?.balance??o?.balance??null:o?.balance??null,se=[`overview`,`usage`,`billing`],ce=(e,t)=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,Q.jsx)(Xt,{className:`h-8 w-8 text-destructive`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,Q.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,Q.jsx)(He,{className:`h-4 w-4`}),`Retry`]})]}),R=()=>(0,Q.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,Q.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,Q.jsx)(ct,{className:`h-6 w-6`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Q.jsxs)(z,{disabled:n!==null,onClick:()=>void ee(),type:`button`,children:[n===`sign-in`?(0,Q.jsx)(Ge,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(nn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,Q.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,Q.jsx)(Ve,{className:`h-4 w-4`})]})]})]})}),le=()=>(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsx)(Ge,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,Q.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:se.map(n=>{let r=!i&&n!==`overview`;return(0,Q.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:l(`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,Q.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&le(),h&&(pn(h)?R():ce(h,I)),!p&&!h&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,re(i.createdAt)]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.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,Q.jsx)(Ve,{className:`h-3.5 w-3.5`})]}),(0,Q.jsxs)(z,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void L(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(rn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),oe!==null&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Qt,{className:`h-5 w-5 text-primary`}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:P?`${P.name} Balance`:`Credits Balance`})]}),(0,Q.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,Q.jsx)(V,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,Q.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,ae(oe)]})}),P&&o&&(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,ae(o.balance),` `,`credits`]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(Jt,{className:`h-5 w-5 text-muted-foreground`}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,Q.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,Q.jsx)(V,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:P?`Recent API usage and token consumption for ${P.name}.`:`Recent API usage and token consumption across all providers.`}),y&&le(),x&&ce(x,te),!y&&!x&&C&&(_.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,Q.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,Q.jsx)(`span`,{children:`Model`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border`,children:_.map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,Q.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,Q.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:ae(e.creditsUsed)}),(0,Q.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:re(e.createdAt)}),(0,Q.jsx)(`p`,{children:ie(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),O&&le(),A&&ce(A,ne),!O&&!A&&M&&(E.length===0?(0,Q.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,Q.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,Q.jsx)(`span`,{children:`Date`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,Q.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-border`,children:E.map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(sn,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:re(e.paidAt)})]}),(0,Q.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,Q.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,ae(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Sn=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Cn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,Z.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=(0,Z.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),_=n.includes(g),v=r.models.length>0,y=r.modelsSourceUrl.trim().length>0,b=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(v||y)&&!_,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}))},O=async()=>{if(!(!b||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,Q.jsxs)(At,{contentClassName:`max-w-4xl`,children:[(0,Q.jsx)(Ft,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,Q.jsxs)(z,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,Q.jsx)(qt,{className:`h-4 w-4`}),`Providers`]})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,Q.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,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),_?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,Q.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,Q.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,Q.jsx)(`span`,{className:`font-mono`,children:e}),(0,Q.jsx)(z,{onClick:()=>S(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,Q.jsx)(ke,{className:`h-3 w-3`})})]},e)),(0,Q.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,Q.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,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,Q.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,Q.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.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,Q.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,Q.jsx)(z,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,Q.jsx)($t,{className:`h-4 w-4`}):(0,Q.jsx)(en,{className:`h-4 w-4`})}),(0,Q.jsx)(z,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,Q.jsx)(H,{className:`h-4 w-4`})})]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,Q.jsx)(W,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Sn.map(e=>(0,Q.jsx)(z,{onClick:()=>C(e),className:l(`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,Q.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,Q.jsxs)(z,{onClick:()=>d(!u),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,Q.jsx)(ge,{className:l(`h-4 w-4 text-muted-foreground transition-transform`,u&&`rotate-180`)})]}),u?(0,Q.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.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,Q.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,Q.jsx)(z,{onClick:()=>D(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,Q.jsx)(le,{className:`h-4 w-4`})})]},e)),(0,Q.jsxs)(z,{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,Q.jsx)(V,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,Q.jsx)(z,{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,Q.jsx)(z,{onClick:()=>void O(),disabled:!b||f,className:l(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,b&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function wn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Tn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function En(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Dn(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 On(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function kn(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 An(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function jn(e){let t=e[0];return{channelId:t?.id??``,values:An(t),securityEnabled:!1,securityValues:{}}}function Mn(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(null),[c,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=(0,Z.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),b=(0,Z.useMemo)(()=>{let e={...An(y),...p.values};return(y?.fields??[]).filter(t=>kn(t,e))},[y,p.values]),x=(0,Z.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:jn(e.available))},[]),S=(0,Z.useCallback)(async()=>{a(!0),u(null);try{x(await G.invoke(`list_connector_channels`))}catch(e){u(e instanceof Error?e.message:String(e))}finally{a(!1)}},[x]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{S()},0);return()=>window.clearTimeout(e)},[S]);let C=()=>{m(jn(e)),g(null),f(!0)},w=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},T=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},E=async()=>{if(!y){g(`Choose a channel`);return}for(let e of y.fields)if(b.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&y.security){for(let e of y.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(y.id),g(null),u(null);try{x(await G.invoke(`start_connector_channel`,{channel:y.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}})),f(!1)}catch(e){g(e instanceof Error?e.message:String(e))}finally{s(null)}},D=async e=>{s(e.type),u(null);try{x(await G.invoke(`stop_connector_channel`,{channel:e.type})),v(null)}catch(e){u(e instanceof Error?e.message:String(e))}finally{s(null)}};return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,Q.jsx)(wt,{children:`cline connect`}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{disabled:i,onClick:()=>void S(),size:`sm`,type:`button`,variant:`outline`,children:(0,Q.jsx)(He,{className:l(`size-4`,i&&`animate-spin`)})}),(0,Q.jsxs)(z,{disabled:e.length===0,onClick:C,size:`sm`,type:`button`,children:[(0,Q.jsx)(V,{className:`size-4`}),`Add Channel`]})]})}),c?(0,Q.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,Q.jsx)(ft,{children:`Loading channels...`}):n.length===0?(0,Q.jsx)(ft,{children:`No channels connected.`}):(0,Q.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,Q.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(B,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,Q.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:wn(t,e)}),(0,Q.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Tn(t)})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,Q.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,Q.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,Q.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:En(t.startedAt)}),t.connectionMode?(0,Q.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,Q.jsxs)(z,{disabled:o===t.type,onClick:()=>v(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,Q.jsx)(le,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,Q.jsx)(Ce,{open:d,onOpenChange:f,children:(0,Q.jsxs)(je,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ne,{children:`Add Channel`}),(0,Q.jsx)(Ie,{children:`Start a connector channel for Cline Hub.`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{children:`Channel`}),(0,Q.jsxs)(De,{onValueChange:t=>{t&&m({channelId:t,values:An(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,Q.jsx)(Le,{children:(0,Q.jsx)(Be,{placeholder:`Select channel`})}),(0,Q.jsx)(Ee,{children:e.map(e=>(0,Q.jsx)(be,{value:e.id,children:e.name},e.id))})]})]}),b.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(W,{children:[e.label,e.required?(0,Q.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,Q.jsxs)(De,{onValueChange:t=>{t&&w(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,Q.jsx)(Le,{children:(0,Q.jsx)(Be,{placeholder:e.placeholder})}),(0,Q.jsx)(Ee,{children:e.options.map(e=>(0,Q.jsx)(be,{value:e.value,children:e.label},e.value))})]}):On(e)?(0,Q.jsx)(Fe,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,Q.jsx)(j,{onChange:t=>w(e.flag,t.target.value),placeholder:e.placeholder,type:Dn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),y?.security?(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(W,{className:`text-sm`,children:`Restrict access`}),(0,Q.jsx)(Ye,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?y.security.fields.map(e=>(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{children:e.label}),(0,Q.jsx)(j,{onChange:t=>T(e.key,t.target.value),placeholder:e.placeholder,type:Dn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(z,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,Q.jsx)(z,{disabled:o!==null||!y,onClick:()=>void E(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,Q.jsx)(q,{open:_!==null,onOpenChange:e=>{e||v(null)},children:(0,Q.jsxs)(Wt,{children:[(0,Q.jsxs)(ot,{children:[(0,Q.jsx)(Qe,{children:`Remove Channel`}),(0,Q.jsxs)(mt,{children:[`Confirm that you want to stop the active`,` `,_?wn(_,e):`channel`,` `,`channel for `,_?Tn(_):``,`.`]})]}),(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Rt,{disabled:o!==null,children:`Cancel`}),(0,Q.jsx)(dt,{disabled:o!==null||!_,onClick:()=>{_&&D(_)},variant:`destructive`,children:`Remove`})]})]})})]})}function Nn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Pn(e){let t=Nn(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 Fn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function In(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Ln(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 Rn(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Ln(e?.env),url:e?.url??``,headersText:Fn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function zn(){let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!0),[c,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`create`),[y,b]=(0,Z.useState)(()=>Rn()),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),T=(0,Z.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),E=(0,Z.useCallback)(async()=>{s(!0),f(null);try{T(await G.invoke(`list_mcp_servers`))}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}},[T]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{E()},0);return()=>window.clearTimeout(e)},[E]);let D=async(e,t)=>{m(e.name),f(null);try{T(await G.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t}))}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},O=async e=>{m(e.previousName??e.name),f(null);try{T(await G.invoke(`upsert_mcp_server`,{input:e}))}catch(e){throw f(e instanceof Error?e.message:String(e)),e}finally{m(null)}},k=async e=>{m(e),f(null);try{T(await G.invoke(`delete_mcp_server`,{name:e}))}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},A=(0,Z.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=Nn(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:Pn(e.headersText),disabled:e.disabled,metadata:i}},[]),M=()=>{v(`create`),b(Rn()),S(null),g(!0)},N=e=>{v(`edit`),b(Rn(e)),S(null),g(!0)},P=async()=>{S(null);try{await O(A(y)),g(!1)}catch(e){S(e instanceof Error?e.message:String(e))}},F=async()=>{u(!0),f(null);try{let e=await G.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},I=(0,Z.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),ee=(e,t,n)=>{b(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},L=()=>{b(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},te=e=>{b(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wt,{children:`cline config mcp`}),(0,Q.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>void E(),disabled:o,children:(0,Q.jsx)(He,{className:l(`h-4 w-4`,o&&`animate-spin`)})}),(0,Q.jsxs)(z,{size:`sm`,onClick:M,children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,Q.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`MCP settings path:`}),(0,Q.jsx)(z,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void F(),disabled:c,children:n||`Open settings file`})]}),d&&(0,Q.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):I.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:I.map(e=>{let t=p===e.name;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(B,{className:l(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>N(e),disabled:t,children:(0,Q.jsx)(Kt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>w(e),disabled:t,children:(0,Q.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Ye,{checked:!e.disabled,onCheckedChange:t=>D(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,Q.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,In(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Fn(e.headers)]})]})]},e.name)})}),(0,Q.jsx)(Ce,{open:h,onOpenChange:e=>{g(e),e||S(null)},children:(0,Q.jsxs)(je,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ne,{children:_===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,Q.jsxs)(Ie,{children:[`Update the MCP server stored in`,` `,(0,Q.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-name`,children:`Server name`}),(0,Q.jsx)(j,{id:`mcp-name`,value:y.name,onChange:e=>b(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{children:`Transport type`}),(0,Q.jsxs)(De,{value:y.transportType,onValueChange:e=>b(t=>({...t,transportType:e})),children:[(0,Q.jsx)(Le,{className:`w-full`,children:(0,Q.jsx)(Be,{placeholder:`Select transport`})}),(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(be,{value:`stdio`,children:`stdio`}),(0,Q.jsx)(be,{value:`sse`,children:`sse`}),(0,Q.jsx)(be,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),y.transportType===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-command`,children:`Command`}),(0,Q.jsx)(j,{id:`mcp-command`,value:y.command,onChange:e=>b(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-args`,children:`Args`}),(0,Q.jsx)(Fe,{id:`mcp-args`,value:y.argsText,onChange:e=>b(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,Q.jsx)(j,{id:`mcp-cwd`,value:y.cwd,onChange:e=>b(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(W,{children:`Environment variables`}),(0,Q.jsx)(z,{type:`button`,variant:`ghost`,size:`sm`,onClick:L,children:(0,Q.jsx)(V,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:y.envEntries.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(z,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>te(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,Q.jsx)(an,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(j,{value:e.key,onChange:t=>ee(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,Q.jsx)(j,{type:`password`,value:e.value,onChange:t=>ee(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-url`,children:`Server URL`}),(0,Q.jsx)(j,{id:`mcp-url`,value:y.url,onChange:e=>b(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-headers`,children:`Headers`}),(0,Q.jsx)(Fe,{id:`mcp-headers`,value:y.headersText,onChange:e=>b(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(W,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,Q.jsx)(Fe,{id:`mcp-metadata`,value:y.metadataText,onChange:e=>b(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,Q.jsx)(Ye,{checked:!y.disabled,onCheckedChange:e=>b(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),x?(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:x}):null]}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(z,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,Q.jsx)(z,{onClick:()=>void P(),disabled:p!==null,children:p===null?_===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,Q.jsx)(q,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,Q.jsxs)(Wt,{children:[(0,Q.jsxs)(ot,{children:[(0,Q.jsx)(Qe,{children:`Delete MCP Server`}),(0,Q.jsx)(mt,{children:C?`Delete MCP server "${C.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Rt,{disabled:p!==null,children:`Cancel`}),(0,Q.jsx)(dt,{disabled:p!==null||!C,onClick:()=>{C&&(k(C.name),w(null))},children:`Delete`})]})]})})]})}function Bn(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 Vn(e){return e==null?``:String(e)}function Hn(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 Un({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,Z.useState)(!1),[c,u]=(0,Z.useState)(``),d=e.filter(e=>e.enabled).length,f=c.trim().toLowerCase(),p=f?e.filter(e=>e.name.toLowerCase().includes(f)):e,m=a===`panel`;return(0,Q.jsx)(ht,{className:`h-full`,children:(0,Q.jsxs)(`div`,{className:l(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,Q.jsxs)(`div`,{className:l(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:l(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Models`}),(0,Q.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,Q.jsx)(z,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,Q.jsx)(Je,{className:`size-4`})}),(0,Q.jsxs)(z,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,Q.jsx)(Zt,{className:`size-4`}),`Add provider`]})]})]}),o?(0,Q.jsx)(`div`,{className:l(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,Q.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,Q.jsx)(Je,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(j,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>u(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,Q.jsxs)(`div`,{className:l(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,Q.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,Q.jsxs)(`div`,{className:l(`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,Q.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,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,Q.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,Q.jsx)(Ye,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,Q.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,Q.jsx)(Yt,{className:`size-4`})})]},e.id))]})]})})}function Wn({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(()=>Bn(e)),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),v=(0,Z.useRef)(void 0),y=e.configFields??[],b=Vn(f.apiKey),x=e.modelList??[],S=m?.providerId===e.id?m.value:``,C=g?.providerId===e.id?g.modelId:null,w=S.trim().toLowerCase(),T=w?x.filter(e=>e.name.toLowerCase().includes(w)||e.id.toLowerCase().includes(w)):x,E=c===`panel`;(0,Z.useEffect)(()=>()=>{v.current!==void 0&&window.clearTimeout(v.current)},[]);let D=(e,t)=>{let r=Hn(e,t);p({...f,[e.path]:r});let i={configValues:{[e.path]:r}};e.path===`apiKey`&&(i.apiKey=Vn(r)),e.path===`baseUrl`&&(i.baseUrl=Vn(r)),n(i)},O=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{_({modelId:t,providerId:e.id}),v.current!==void 0&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>_(null),1600)})};return(0,Q.jsx)(ht,{className:`h-full`,children:(0,Q.jsxs)(`div`,{className:l(`py-10 max-[720px]:px-4 max-[720px]:py-5`,E?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,Q.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,Q.jsx)(z,{"aria-label":E?`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:E?(0,Q.jsx)(ke,{className:`h-4 w-4`}):(0,Q.jsx)(qt,{className:`h-4 w-4`})}),(0,Q.jsx)(`h1`,{className:l(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,E?`text-[24px]`:`text-[32px]`),children:e.name})]}),y.length>0?(0,Q.jsx)(`section`,{className:l(`mb-8`,E?`max-w-none`:`max-w-[86rem]`),children:(0,Q.jsx)(`div`,{className:`flex flex-col`,children:y.map(e=>{let t=f[e.path],n=Vn(t),r=e.type===`password`||e.secret,i=u[e.path]??!1;return(0,Q.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,Q.jsxs)(`header`,{children:[(0,Q.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,Q.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,Q.jsx)(Ye,{checked:!!t,onCheckedChange:t=>D(e,t)})]}):e.type===`select`?(0,Q.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=>D(e,t.target.value),value:n,children:[(0,Q.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,Q.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,Q.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,Q.jsx)(Ze,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,Q.jsx)(j,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>D(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,Q.jsx)($t,{className:`h-4 w-4`}):(0,Q.jsx)(en,{className:`h-4 w-4`})}),(0,Q.jsx)(z,{"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,Q.jsx)(H,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!b&&!e.oauthAccessTokenPresent&&o?(0,Q.jsx)(`div`,{className:`mb-8`,children:(0,Q.jsxs)(z,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,Q.jsx)(Ge,{className:`h-4 w-4 animate-spin`}):null,(0,Q.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,Q.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,Q.jsxs)(`section`,{className:l(`overflow-hidden rounded-lg border`,E?`max-w-none`:`max-w-[46rem]`),children:[(0,Q.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,Q.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Je,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(z,{"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,Q.jsx)(He,{className:l(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):x.length>0?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,Q.jsx)(Je,{className:`size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(j,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:S})]}),T.length>0?(0,Q.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:T.map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,Q.jsx)(`div`,{title:`File Support`,children:(0,Q.jsx)(tn,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,Q.jsx)(`div`,{title:`Image Support`,children:(0,Q.jsx)(_e,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,Q.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:()=>O(e.id),title:`Copy model ID`,type:`button`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,Q.jsx)(H,{className:`size-3 shrink-0`}),C===e.id?(0,Q.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Q.jsx)(z,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,Q.jsx)(We,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,S.trim(),`".`]})})]}):(0,Q.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}function Gn(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var Kn=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.indeterminate=`data-indeterminate`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({});function qn(e){return Z.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[Kn.checked]:``}:{[Kn.unchecked]:``}},...A}),[e.indeterminate])}var Jn=Z.createContext(void 0);function Yn(){let e=Z.useContext(Jn);if(e===void 0)throw Error(s(14));return e}var Xn=`data-parent`,Zn=Z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":s,disabled:c=!1,form:l,id:f,indeterminate:p=!1,inputRef:m,name:h,onCheckedChange:v,parent:b=!1,readOnly:S=!1,render:C,required:w=!1,uncheckedValue:E,value:D,nativeButton:O=!1,style:k,...A}=e,{clearErrors:j}=I(),{disabled:P,name:ee,setDirty:L,setFilled:ae,setFocused:oe,setTouched:se,state:ce,validationMode:le,validityData:z,validation:fe}=te(),pe=ln(),{labelId:me,controlId:he,registerControlId:B,getDescriptionProps:ge}=N(),V=dn(),_e=V?.parent,ve=_e&&V.allValues,H=P||pe.disabled||V?.disabled||c,ye=ee??h,U=D??ye,be=g(),xe=g(),Se=he;ve?Se=b?xe:`${_e.id}-${U}`:f&&(Se=f);let Ce={};ve&&(b?Ce=V.parent.getParentProps():U&&(Ce=V.parent.getChildProps(U)));let{checked:we=n,indeterminate:Te=p,onCheckedChange:Ee,...De}=Ce,Oe=V?.value,ke=V?.setValue,Ae=V?.defaultValue,je=Z.useRef(null),Me=d(()=>Symbol(`checkbox-control`)),Ne=Z.useRef(!1),{getButtonProps:Pe,buttonRef:Fe}=x({disabled:H,native:O}),W=V?.validation??fe,[Ie,Le]=R({controlled:U&&Oe&&!b?Oe.includes(U):we,default:U&&Ae&&!b?Ae.includes(U):i,name:`Checkbox`,state:`checked`}),Re=ve?!!we:Ie,ze=ve&&Te||p;T(()=>{B!==ie&&(Ne.current=!0,B(Me.current,Se))},[Se,B,Me]),Z.useEffect(()=>{let e=Me.current;return()=>{!Ne.current||B===ie||(Ne.current=!1,B(e,void 0))}},[B,Me]),re(je,be,Ie,void 0,!V&&!H,h);let Be=Z.useRef(null),Ve=y(m,Be,W.inputRef,W.registerInput),He=qe(s,me,Be,!O,Se??void 0);T(()=>{Be.current&&(Be.current.indeterminate=ze,Ie&&ae(!0))},[Ie,ze,ae]),ue(Ie,()=>{V||(j(ye),ae(Ie),L(Ie!==z.initialValue),W.change(Ie))});let Ue=a({checked:Ie,disabled:H,form:l,name:b?void 0:ye,id:O?void 0:Se??void 0,required:w,ref:Ve,style:ye?u:_,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(S){e.preventDefault();return}let t=e.currentTarget.checked,n=o(F,e.nativeEvent);v?.(t,n),!n.isCanceled&&(Ee?.(t,n),!n.isCanceled&&(Le(t),U&&Oe&&ke&&!b&&!ve&&ke(t?[...Oe,U]:Oe.filter(e=>e!==U),n)))},onFocus(){je.current?.focus()}},D===void 0?M:{value:(V?Ie&&D:D)||``},ge,e=>W.getValidationProps(H,e));Z.useEffect(()=>{if(!_e||!U)return;let e=_e.disabledStatesRef.current;return e.set(U,H),()=>{e.delete(U)}},[_e,H,U]);let We=Z.useMemo(()=>({...ce,checked:Re,disabled:H,readOnly:S,required:w,indeterminate:ze}),[ce,Re,H,S,w,ze]),G=qn(We),Ge=ne(`span`,e,{state:We,ref:[Fe,je,t,V?.registerControlRef],props:[{id:O?Se??void 0:be,role:`checkbox`,"aria-checked":ze?`mixed`:Re,"aria-readonly":S||void 0,"aria-required":w||void 0,"aria-labelledby":He,[Xn]:b?``:void 0,onFocus(){H||oe(!0)},onBlur(){let e=Be.current;e&&(se(!0),oe(!1),le===`onBlur`&&W.commit(V?Oe:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Be.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),de(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||Gn(t)?.click()})},onClick(e){if(S||H)return;e.preventDefault();let t=Be.current;t&&t.dispatchEvent(new(de(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},A,De,Pe,ge,e=>W.getValidationProps(H,e)],stateAttributesMapping:G});return(0,Q.jsxs)(Jn.Provider,{value:We,children:[Ge,!Ie&&!V&&ye&&!b&&E!==void 0&&(0,Q.jsx)(`input`,{type:`hidden`,form:l,name:ye,value:E,disabled:H}),(0,Q.jsx)(`input`,{...Ue,suppressHydrationWarning:!0})]})}),Qn=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Yn(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=xt(c),f=Z.useRef(null),p={...s,transitionStatus:u};gt({open:c,ref:f,onComplete(){c||d(!1)}});let m={...qn(s),...vt,...A},h=a||l,g=ne(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function $n({className:e,...t}){return(0,Q.jsx)(Zn,{"data-slot":`checkbox`,className:l(`peer relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...t,children:(0,Q.jsx)(Qn,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(et,{})})})}function er(e,t,n,r,i,a,o,s,c,l=2){let u=Vt(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return st(n.current,u)?void 0:u}var tr=Z.createContext(void 0),nr=Z.createContext(void 0),rr=Z.createContext(void 0),ir=Z.createContext(!1),ar=Z.createContext(``);function or(){let e=Z.useContext(tr);if(!e)throw Error(s(22));return e}function sr(){let e=Z.useContext(nr);if(!e)throw Error(s(23));return e}function cr(){let e=Z.useContext(rr);if(!e)throw Error(s(24));return e}function lr(){return Z.useContext(ar)}function ur(){return Z.useContext(ir)}var $={id:J(e=>e.id),labelId:J(e=>e.labelId),items:J(e=>e.items),selectedValue:J(e=>e.selectedValue),hasSelectionChips:J(e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:J(e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:J((e,t)=>t?ye(e.items):!1),open:J(e=>e.open),mounted:J(e=>e.mounted),forceMounted:J(e=>e.forceMounted),inline:J(e=>e.inline),activeIndex:J(e=>e.activeIndex),selectedIndex:J(e=>e.selectedIndex),isActive:J((e,t)=>e.activeIndex===t),isSelected:J((e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>he(t,e,n)):he(t,r,n)}),transitionStatus:J(e=>e.transitionStatus),popupProps:J(e=>e.popupProps),inputProps:J(e=>e.inputProps),triggerProps:J(e=>e.triggerProps),itemProps:J(e=>e.itemProps),positionerElement:J(e=>e.positionerElement),listElement:J(e=>e.listElement),popupId:J(e=>e.popupId),triggerElement:J(e=>e.triggerElement),inputElement:J(e=>e.inputElement),inputGroupElement:J(e=>e.inputGroupElement),popupSide:J(e=>e.popupSide),openMethod:J(e=>e.openMethod),inputInsidePopup:J(e=>e.inputInsidePopup),inputOwnsFormValue:J(e=>e.inputOwnsFormValue),selectionMode:J(e=>e.selectionMode),name:J(e=>e.name),form:J(e=>e.form),disabled:J(e=>e.disabled),readOnly:J(e=>e.readOnly),required:J(e=>e.required),grid:J(e=>e.grid),virtualized:J(e=>e.virtualized),itemToStringLabel:J(e=>e.itemToStringLabel),isItemEqualToValue:J(e=>e.isItemEqualToValue),modal:J(e=>e.modal),autoHighlight:J(e=>e.autoHighlight),submitOnItemClick:J(e=>e.submitOnItemClick)};function dr(e){return e==null?void 0:`${e}-popup`}function fr(e,t){return(n,r)=>{if(n==null)return!1;let i=Re(n,t);return e.contains(i,r)}}function pr(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;let a=Re(r,t),o=n==null?``:Re(n,t);return o&&e.contains(o,i)&&o.length===i.length?!0:e.contains(a,i)}}function mr(e){return Array.isArray(e)?e.map(e=>mr(e)).join(`,`):e==null?``:String(e)}var hr=new Map;function gr(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${mr(e.locale)}|${JSON.stringify(t)}`,r=hr.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Re(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Re(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Re(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return hr.set(n,a),a}var _r=gr,vr=Symbol(`none`),yr={value:vr,index:-1};function br(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:s,defaultInputValue:l,inputValue:f,open:p,defaultOpen:h=!1,selectionMode:g=`none`,onItemHighlighted:b,name:x,form:S,disabled:C=!1,readOnly:E=!1,required:O=!1,inputRef:A,grid:j=!1,items:N,filteredItems:L,filter:ne,openOnInputClick:ae=!0,autoHighlight:oe=!1,keepHighlight:le=!1,highlightItemOnHover:de=!0,loopFocus:z=!0,itemToStringLabel:B,itemToStringValue:ge,isItemEqualToValue:V=me,virtualized:_e=!1,inline:H=!1,fillInputOnItemPress:ye=!0,modal:be=!1,limit:xe=-1,autoComplete:Se=`list`,formAutoComplete:Ce,locale:we,submitOnItemClick:Te=!1}=e,{clearErrors:Ee}=I(),{setDirty:De,validityData:Oe,setFilled:ke,name:je,disabled:Me,setTouched:Ne,setFocused:Pe,validationMode:Fe,validation:W}=te(),Ie=c(),Le=ce({id:t}),Be=_r({locale:we}),[Ve,He]=Z.useState(!1),[Ue,We]=Z.useState(null),G=Z.useRef([]),Ge=Z.useRef([]),Ke=Z.useRef(null),qe=Z.useRef(null),Je=Z.useRef(null),Ye=Z.useRef(null),Xe=Z.useRef(null),Ze=Z.useRef(!0),Qe=Z.useRef(!1),$e=Z.useRef(null),et=Z.useRef(null),tt=Z.useRef(null),nt=Z.useRef(yr),rt=Z.useRef(null),it=Z.useRef([]),at=Z.useRef([]),ot=Me||C,st=je??x,ct=g===`multiple`,lt=g===`single`,ut=f!==void 0||l!==void 0,dt=N!==void 0,ft=L!==void 0,mt;mt=oe===`always`?`always`:oe?`input-change`:!1;let[K,ht]=R({controlled:i,default:ct?r??se:r,name:`Combobox`,state:`selectedValue`}),_t=Z.useMemo(()=>ne===null?()=>!0:ne===void 0?lt&&!Ve?pr(Be,B,K):fr(Be,B):ne,[ne,lt,K,Ve,Be,B]),vt=d(()=>ut?l??``:lt?Re(K,B):``).current,[yt,bt]=R({controlled:f,default:vt,name:`Combobox`,state:`inputValue`}),[q,Ct]=R({controlled:p,default:h,name:`Combobox`,state:`open`}),J=pe(N),wt=Ue??(yt===``?``:String(yt).trim()),Dt=lt?Re(K,B):``,Ot=lt&&!Ve&&wt!==``&&Dt!==``&&Dt.length===wt.length&&Be.contains(Dt,wt),kt=Ot?``:wt,At=dt&&ft&&Ot,Nt=Z.useMemo(()=>N?J?N.flatMap(e=>e.items):N:se,[N,J]),Pt=Z.useMemo(()=>{if(L&&!At)return L;if(!N)return se;if(J){let e=N,t=[],n=0;for(let r of e){if(xe>-1&&n>=xe)break;let e=kt===``?r.items:r.items.filter(e=>_t(e,kt,B));if(e.length===0)continue;let i=xe>-1?xe-n:1/0,a=e.slice(0,i);if(a.length>0){let e={...r,items:a};t.push(e),n+=a.length}}return t}if(kt===``)return xe>-1?Nt.slice(0,xe):Nt;let e=[];for(let t of Nt){if(xe>-1&&e.length>=xe)break;_t(t,kt,B)&&e.push(t)}return e},[L,At,N,J,kt,xe,_t,B,Nt]),Ft=Z.useMemo(()=>J?Pt.flatMap(e=>e.items):Pt,[Pt,J]),X=d(()=>new Mt({id:Le,labelId:void 0,selectedValue:K,open:q,filter:_t,query:wt,items:N,selectionMode:g,listRef:G,labelsRef:Ge,popupRef:Ke,emptyRef:Xe,inputRef:qe,startDismissRef:Je,endDismissRef:Ye,keyboardActiveRef:Ze,chipsContainerRef:$e,clearRef:et,valuesRef:it,allValuesRef:at,selectionEventRef:tt,name:st,form:S,disabled:ot,readOnly:E,required:O,grid:j,isGrouped:J,virtualized:_e,openOnInputClick:ae,itemToStringLabel:B,isItemEqualToValue:V,modal:be,autoHighlight:mt,submitOnItemClick:Te,hasInputValue:ut,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:H,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:M,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:g===`none`,onOpenChangeComplete:n||ie,setOpen:ie,setInputValue:ie,setSelectedValue:ie,setIndices:ie,onItemHighlighted:ie,handleSelection:ie,forceMount:ie,requestSubmit:ie})).current,It=g===`none`?yt:K,Lt=Z.useMemo(()=>g===`none`?It:Array.isArray(K)?K.map(e=>U(e,ge)):U(K,ge),[It,ge,g,K]),Rt=m(b),Vt=m(n),Ht=Y(X,$.activeIndex),Ut=Y(X,$.selectedIndex),Wt=Y(X,$.positionerElement),Kt=Y(X,$.listElement),qt=Y(X,$.triggerElement),Jt=Y(X,$.inputElement),Yt=Y(X,$.inputGroupElement),Xt=Y(X,$.inline),Zt=Y(X,$.inputInsidePopup),Qt=Y(X,$.inputOwnsFormValue),$t=Et(qt),{mounted:en,setMounted:tn,transitionStatus:nn}=xt(q),{openMethod:rn,triggerProps:an}=Bt(q),on=m(()=>Lt);re(Zt?$t:qe,Le,It,on,!ot,x);let sn=m(()=>{N?Ge.current=Ft.map(e=>Re(e,B)):X.set(`forceMounted`,!0)}),cn=Z.useRef(K);T(()=>{K!==cn.current&&sn()},[sn,K]);let ln=m(e=>{X.update(e);let t=e.type||`none`;if(e.activeIndex!==void 0)if(e.activeIndex===null)nt.current!==yr&&(nt.current=yr,Rt(void 0,w(t,void 0,{index:-1})));else{let n=it.current[e.activeIndex];nt.current={value:n,index:e.activeIndex},Rt(n,w(t,void 0,{index:e.activeIndex}))}}),un=m((t,n)=>{if(Qe.current=n.reason===D,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===`input-change`){let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&He(!0),rt.current={hasQuery:e},e&&mt&&X.state.activeIndex==null&&X.set(`activeIndex`,0)}}bt(t)}}),dn=m((t,n)=>{if(q!==t&&(n.reason===`escape-key`&&dt&&Ft.length===0&&!X.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&ct&&Zt&&!Xt&&Ue!==null&&(He(!1),We(null),yt!==``&&un(``,o(D,n.event))),!t&&Ve&&(lt?(Xt||We(wt),wt===``&&He(!1)):ct&&(Xt||We(wt),Zt&&ln({activeIndex:null}),(!Zt||Xt)&&un(``,o(D,n.event)))),Ct(t),!t&&Zt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(Ne(!0),Pe(!1),Fe===`onBlur`)))){let e=g===`none`?yt:K;W.commit(e)}}),fn=m((e,t)=>{s?.(e,t),!t.isCanceled&&(ht(e),(g===`none`&&Ke.current&&ye||lt&&!X.state.inputInsidePopup)&&un(Re(e,B),o(t.reason,t.event)),lt&&e!=null&&t.reason!==`input-change`&&Ve&&!Xt&&We(wt))}),pn=m((e,t)=>{let n=t;if(n===void 0){if(Ht===null)return;n=it.current[Ht]}let r=ee(e),i=tt.current??e;tt.current=null;let a=o(v,i),s=r?.closest(`a`)?.getAttribute(`href`);if(s){s.startsWith(`#`)&&dn(!1,a);return}if(ct){let e=Array.isArray(K)?K:[];if(fn(fe(e,n,X.state.isItemEqualToValue)?Ae(e,n,X.state.isItemEqualToValue):[...e,n],a),a.isCanceled||!(qe.current&&qe.current.value.trim()!==``))return;X.state.inputInsidePopup?un(``,o(D,a.event)):dn(!1,a)}else{if(fn(n,a),a.isCanceled)return;dn(!1,a)}}),mn=m(()=>{if(!X.state.submitOnItemClick)return;let e=W.inputRef.current?.form??X.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),hn=m(()=>{if(tn(!1),Vt?.(!1),He(!1),We(null),ln(g===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),ct&&qe.current&&qe.current.value!==``&&!Qe.current&&un(``,o(D)),lt)if(X.state.inputInsidePopup)qe.current&&qe.current.value!==``&&un(``,o(D));else{let e=Re(K,B);qe.current&&qe.current.value!==e&&un(e,o(e===``?D:F))}}),gn=Z.useMemo(()=>Xt&&Wt?{current:Wt.closest(`[role="dialog"]`)}:Ke,[Xt,Wt]);gt({enabled:!e.actionsRef,open:q,ref:gn,onComplete(){q||hn()}}),Z.useImperativeHandle(e.actionsRef,()=>({unmount:hn}),[hn]),T(function(){if(q||g===`none`)return;let e=N?Nt:at.current;if(ct){let t=Array.isArray(K)?K:[],n=t[t.length-1],r=ve(e,n,V);ln({selectedIndex:r===-1?null:r})}else{let t=ve(e,K,V);ln({selectedIndex:t===-1?null:t})}},[q,K,N,g,Nt,ct,V,ln]),T(()=>{N&&(it.current=Ft,G.current.length=Ft.length)},[N,Ft]),T(()=>{let e=rt.current;if(e&&(e.hasQuery?mt&&X.set(`activeIndex`,0):mt===`always`&&X.set(`activeIndex`,0),rt.current=null),!q&&!Xt)return;let t=dt||ft?Ft:it.current,n=X.state.activeIndex;if(n==null){if(mt===`always`&&t.length>0){X.set(`activeIndex`,0);return}nt.current!==yr&&(nt.current=yr,X.state.onItemHighlighted(void 0,w(F,void 0,{index:-1})));return}if(n>=t.length){nt.current!==yr&&(nt.current=yr,X.state.onItemHighlighted(void 0,w(F,void 0,{index:-1}))),X.set(`activeIndex`,null);return}let r=t[n],i=nt.current.value,a=i!==vr&&he(r,i,X.state.isItemEqualToValue);(nt.current.index!==n||!a)&&(nt.current={value:r,index:n},X.state.onItemHighlighted(r,w(F,void 0,{index:n})))},[Ht,mt,ft,dt,Ft,Xt,q,X]),T(()=>{if(g===`none`){ke(String(yt)!==``);return}ke(ct?Array.isArray(K)&&K.length>0:K!=null)},[ke,g,yt,K,ct]),Z.useEffect(()=>{dt&&mt&&Ft.length===0&&ln({activeIndex:null})},[dt,mt,Ft.length,ln]);function _n(e){let t=Oe.initialValue;return Array.isArray(e)&&Array.isArray(t)?!ze(e,t,(e,t)=>he(e,t,V)):e!==t}ue(wt,()=>{!q||wt===``||wt===String(vt)||He(!0)}),ue(K,()=>{if(g!==`none`&&(Ee(st),De(_n(K)),W.change(K),lt&&!ut&&!Zt)){let e=Re(K,B);yt!==e&&un(e,o(F))}}),ue(yt,()=>{g===`none`&&(Ee(st),De(yt!==Oe.initialValue),W.change(yt))}),ue(N,()=>{if(!lt||ut||Zt||Ve)return;let e=Re(K,B);yt!==e&&un(e,o(F))});let vn=pt({open:Xt?!0:q,onOpenChange:dn,elements:{reference:Zt?qt:Jt,floating:Wt}}),yn,bn;Xt||(yn=j?`grid`:`listbox`,bn=q?`true`:`false`);let xn=Z.useMemo(()=>{let e=Jt?.tagName===`INPUT`,t=Jt==null||e,n=t||q,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=bn,r[`aria-haspopup`]=yn,r[`aria-controls`]=q?Kt?.id:void 0,r[`aria-autocomplete`]=Se),{reference:r,floating:{role:`presentation`}}},[Jt,q,bn,yn,Kt?.id,Se]),Sn=Gt(vn,{enabled:!E&&!ot&&ae,event:`mousedown-only`,toggle:!1,touchOpenDelay:Zt?0:100,reason:k}),Cn=zt(vn,{enabled:!E&&!ot&&!Xt,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Xt?!0:void 0,outsidePress(e){let t=ee(e);return!P(qt,t)&&!P(et.current,t)&&!P($e.current,t)&&!P(Yt,t)}}),wn=Tt(vn,{enabled:!E&&!ot,id:Le,listRef:G,activeIndex:Ht,selectedIndex:Ut,virtual:!0,loopFocus:z,allowEscape:z&&!mt,focusItemOnOpen:Ve||g===`none`&&!mt?!1:`auto`,focusItemOnHover:de,resetOnPointerLeave:!le,orientation:j?`horizontal`:void 0,rtl:Ie===`rtl`,disabledIndices:se,grid:j?er:void 0,onNavigate(e,t){!t&&!q||nn===`ending`||ln(t?{activeIndex:e,type:Ze.current?`keyboard`:`pointer`}:{activeIndex:e})}}),Tn=Z.useMemo(()=>a(wn.reference,{onKeyDown(e){j&&X.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Cn.reference,Sn.reference,xn.reference),[wn.reference,Cn.reference,Sn.reference,xn.reference,j,X]),En=Z.useMemo(()=>a(jt,wn.floating,Cn.floating,xn.floating),[wn.floating,Cn.floating,xn.floating]),Dn=Z.useMemo(()=>{let e=wn.item;return e?{...e,onFocus:void 0}:M},[wn.item]);St(()=>{X.update({inline:H,popupProps:En,inputProps:Tn,triggerProps:an,itemProps:Dn,setOpen:dn,setInputValue:un,setSelectedValue:fn,setIndices:ln,onItemHighlighted:Rt,handleSelection:pn,forceMount:sn,requestSubmit:mn})}),T(()=>{X.update({id:Le,selectedValue:K,open:q,mounted:en,transitionStatus:nn,items:N,inline:H,popupProps:En,inputProps:Tn,triggerProps:an,openMethod:rn,itemProps:Dn,selectionMode:g,name:st,form:S,disabled:ot,readOnly:E,required:O,grid:j,isGrouped:J,virtualized:_e,onOpenChangeComplete:Vt,openOnInputClick:ae,itemToStringLabel:B,modal:be,autoHighlight:mt,isItemEqualToValue:V,submitOnItemClick:Te,hasInputValue:ut,requestSubmit:mn,inputOwnsFormValue:g===`none`&&(H||!X.state.inputInsidePopup)})},[X,Le,K,q,en,nn,N,En,Tn,Dn,rn,an,g,st,ot,E,O,W,j,J,_e,Vt,ae,B,be,V,Te,ut,H,mn,mt,S]);let On=y(A,W.inputRef),kn=Z.useMemo(()=>({query:wt,hasItems:dt,filteredItems:Pt,flatFilteredItems:Ft}),[wt,dt,Pt,Ft]),An=Z.useMemo(()=>Array.isArray(It)?``:U(It,ge),[It,ge]),jn=ct&&Array.isArray(K)&&K.length>0,Mn=ct||g===`none`&&Qt?void 0:st,Nn=Z.useMemo(()=>!ct||!Array.isArray(K)||!st?null:K.map(e=>{let t=U(e,ge);return(0,Q.jsx)(`input`,{type:`hidden`,form:S,name:st,value:t,disabled:ot},t)}),[ct,K,S,st,ge,ot]),Pn=(0,Q.jsxs)(Z.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...W.getValidationProps(ot,{onFocus(){if(Zt){qt?.focus();return}(qe.current||qt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||ot||E)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=o(F,e.nativeEvent),i=()=>it.current.findIndex(e=>U(e,ge).toLowerCase()===n||Re(e,B).toLowerCase()===n);function a(){if(ct)return;if(g===`none`){un(t,r);return}let e=i();e===-1&&(e=it.current.findIndex((e,t)=>{let r=Ge.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:it.current[e];a!=null&&fn?.(a,r)}lt&&(sn(),N&&i()===-1&&X.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Le&&Mn==null?`${Le}-hidden-input`:void 0,form:S,name:Mn,autoComplete:Ce,disabled:ot,required:O&&!jn,readOnly:E,value:An,ref:On,style:Mn?u:_,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Nn]});return(0,Q.jsx)(tr.Provider,{value:X,children:(0,Q.jsx)(nr.Provider,{value:vn,children:(0,Q.jsx)(ir.Provider,{value:dt,children:(0,Q.jsx)(rr.Provider,{value:kn,children:(0,Q.jsx)(ar.Provider,{value:yt,children:Pn})})})})})}var xr={...It,...A,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null},Sr=2,Cr=Z.forwardRef(function(e,t){let{render:n,className:r,nativeButton:a=!0,disabled:s=!1,id:c,style:l,...u}=e,{state:d,disabled:p,setTouched:h,setFocused:g,validationMode:_,validation:v}=te(),{labelId:y}=N(),S=or(),{filteredItems:C}=cr(),w=Y(S,$.selectionMode),T=Y(S,$.disabled),E=Y(S,$.readOnly),D=Y(S,$.required),O=Y(S,$.mounted),k=Y(S,$.popupSide),A=Y(S,$.positionerElement),j=Y(S,$.listElement),M=Y(S,$.popupId),F=Y(S,$.triggerProps),I=Y(S,$.triggerElement),L=Y(S,$.inputInsidePopup),re=Y(S,$.id),ie=Y(S,$.labelId),ae=Y(S,$.open),oe=Y(S,$.selectedValue),se=Y(S,$.activeIndex),R=Y(S,$.selectedIndex),le=Y(S,$.hasSelectedValue),ue=sr(),de=lr(),z=b(),fe=p||T||s,pe=C.length===0,me=O&&A?k:null;ce({id:L?c:void 0});let he=L?c??re:c,B=Se(y,ie),ge;ae&&L?ge=M??dr(re):ae&&(ge=j?.id);let V=Z.useRef(``);function _e(e){V.current=e.pointerType}let ve=ue.useState(`domReferenceElement`);Z.useEffect(()=>{L&&I&&I!==ve&&ue.set(`domReferenceElement`,I)},[I,ve,ue,L]);let{reference:H}=Pt(ue,{enabled:!ae&&!E&&!T&&w===`single`,listRef:S.state.labelsRef,activeIndex:se,selectedIndex:R,onMatch(e){let t=S.state.valuesRef.current[e];t!==void 0&&S.state.setSelectedValue(t,o(`none`))}}),{reference:ye}=Gt(ue,{enabled:!E&&!T,event:`mousedown`}),{buttonRef:U,getButtonProps:be}=x({native:a,disabled:fe}),xe={...d,open:ae,disabled:fe,popupSide:me,listEmpty:pe,placeholder:w===`none`?!1:!le};return ne(`button`,e,{ref:[t,U,m(e=>{S.set(`triggerElement`,e)})],state:xe,props:[F,ye,H,{id:he,tabIndex:L?0:-1,role:L?`combobox`:void 0,"aria-expanded":ae?`true`:`false`,"aria-haspopup":L?`dialog`:`listbox`,"aria-controls":ge,"aria-required":L&&D||void 0,"aria-labelledby":B,onPointerDown:_e,onPointerEnter:_e,onFocus(){g(!0),!(fe||E)&&z.start(0,S.state.forceMount)},onBlur(e){if(!P(A,e.relatedTarget)&&(h(!0),g(!1),_===`onBlur`)){let e=w===`none`?de:oe;v.commit(e)}},onMouseDown(e){if(fe||E||(L||ue.set(`domReferenceElement`,e.currentTarget),S.state.forceMount(),V.current!==`touch`&&(S.state.inputRef.current?.focus(),L||e.preventDefault()),ae))return;let t=f(e.currentTarget);function n(e){if(!I)return;let t=ee(e),n=S.state.positionerElement,r=S.state.listElement;if(P(I,t)||P(n,t)||P(r,t)||t===I)return;let i=Lt(I),a=e.clientX>=i.left-Sr&&e.clientX<=i.right+Sr,s=e.clientY>=i.top-Sr&&e.clientY<=i.bottom+Sr;a&&s||S.state.setOpen(!1,o(`cancel-open`,e))}L&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){fe||E||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(tt(e),S.state.setOpen(!0,o(i,e.nativeEvent)),S.state.inputRef.current?.focus())}},v?v.getValidationProps(fe,u):u,be],stateAttributesMapping:xr})}),wr=Z.createContext(void 0);function Tr(){return Z.useContext(wr)}var Er=Z.createContext(void 0);function Dr(e){let t=Z.useContext(Er);if(t===void 0&&!e)throw Error(s(21));return t}var Or=Z.forwardRef(function(e,t){let n=or(),{buttonRef:r,getButtonProps:i}=x({native:!1}),a=y(t,r);function s(e){n.state.setOpen(!1,o(E,e.nativeEvent,e.currentTarget))}return(0,Q.jsx)(`span`,{ref:a,...i({onClick:s}),"aria-label":`Dismiss`,tabIndex:void 0,style:u})}),kr=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:s,...l}=e,{state:u,disabled:d,setTouched:f,setFocused:_,validationMode:v,validation:y}=te(),{labelId:b}=N(),x=Tr(),S=!!Dr(!0),C=or(),{filteredItems:w}=cr(),T=lr(),E=c(),k=Y(C,$.required),A=Y(C,$.disabled),j=Y(C,$.readOnly),M=Y(C,$.name),P=Y(C,$.form),I=Y(C,$.selectionMode),ee=Y(C,$.autoHighlight),re=Y(C,$.inputProps),ie=Y(C,$.triggerProps),se=Y(C,$.open),ce=Y(C,$.mounted),R=Y(C,$.selectedValue),le=Y(C,$.popupSide),ue=Y(C,$.positionerElement),de=Y(C,$.id),z=Y(C,$.inline),fe=Y(C,$.modal),pe=!!ee,me=ce&&ue?le:null,he=d||A||i,B=w.length===0,ge=S||z,V=!ge||fe,_e=g(a??(ge?void 0:de)),ve=Se(b,void 0),H=S?L:u,[ye,U]=Z.useState(null),be=Z.useRef(!1),xe=Z.useRef(null),Ce=Z.useRef(!1),we=I===`none`&&!S,Te=m(e=>{let t=S||C.state.inline;t&&!C.state.hasInputValue&&C.state.setInputValue(``,o(F)),C.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:we})}),Ee=S||!y?l:y.getValidationProps(he,l),De={...H,open:se,disabled:he,readOnly:j,popupSide:me,listEmpty:B};function Oe(e){if(!x)return;let t,{highlightedChipIndex:n}=x,r=x.chipsRef.current.length,i=E===`rtl`,a=i?`ArrowRight`:`ArrowLeft`,o=i?`ArrowLeft`:`ArrowRight`;if(n!==void 0){if(e.key===a)e.preventDefault(),t=n>0?n-1:void 0;else if(e.key===o)e.preventDefault(),t=n<r-1?n+1:void 0;else if(e.key===`Backspace`||e.key===`Delete`){e.preventDefault();let r=n>=R.length-1?R.length-2:n;t=r>=0?r:void 0,C.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`})}return t}return e.key===a&&(e.currentTarget.selectionStart??0)===0&&R.length>0?(e.preventDefault(),t=r>0?r-1:void 0):e.key===`Backspace`&&e.currentTarget.value===``&&R.length>0&&(C.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`}),e.preventDefault()),t}let ke=ne(`input`,e,{state:De,ref:[t,C.state.inputRef,Te],props:[re,ie,{type:`text`,value:e.value??ye??T,"aria-readonly":j||void 0,"aria-required":k||void 0,"aria-labelledby":ve,disabled:he,readOnly:j,required:I===`none`?k:void 0,form:P,...we&&M&&{name:M},id:_e,onFocus(){if(_(!0),!z||!Ce.current)return;Ce.current=!1;let e=xe.current;e==null||!Object.hasOwn(C.state.valuesRef.current,e)||C.state.setIndices({activeIndex:e})},onBlur(){f(!0),_(!1);let e=C.state.activeIndex;if(z&&e!==null&&ee!==`always`&&(xe.current=e,Ce.current=!0,C.state.setIndices({activeIndex:null})),v===`onBlur`){let e=I===`none`?T:R;y.commit(e)}},onCompositionStart(e){nt||(be.current=!0,U(e.currentTarget.value))},onCompositionEnd(e){be.current=!1;let t=e.currentTarget.value;U(null),C.state.setInputValue(t,o(O,e.nativeEvent))},onChange(e){let t=e.nativeEvent.inputType,n=!t||t===`insertReplacementText`,r=be.current||!n;if(be.current){let t=e.currentTarget.value;U(t),t===``&&!C.state.openOnInputClick&&!C.state.inputInsidePopup&&C.state.setOpen(!1,o(D,e.nativeEvent));let n=t.trim(),i=pe&&n!==``;!j&&!he&&n&&r&&(C.state.setOpen(!0,o(O,e.nativeEvent)),pe||C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`})),se&&C.state.activeIndex!==null&&!i&&C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`});return}let i=o(O,e.nativeEvent);if(C.state.setInputValue(e.currentTarget.value,i),i.isCanceled)return;let a=e.currentTarget.value===``,s=o(D,e.nativeEvent);a&&!C.state.inputInsidePopup&&(I===`single`&&C.state.setSelectedValue(null,s),C.state.openOnInputClick||C.state.setOpen(!1,s));let c=e.currentTarget.value.trim();!j&&!he&&c&&r&&(C.state.setOpen(!0,o(O,e.nativeEvent)),pe||C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`})),se&&C.state.activeIndex!==null&&!pe&&C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`})},onKeyDown(e){if(he||j||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;C.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=E===`rtl`;if(e.key===`Home`){tt(e);let n=h&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){tt(e);let i=h&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!ce&&e.key===`Escape`){let t=I===`multiple`&&Array.isArray(R)?R.length===0:R===null,n=o(p,e.nativeEvent),r=I===`multiple`?[]:null;C.state.setInputValue(``,n),C.state.setSelectedValue(r,n),!t&&!C.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(x&&e.key===`Backspace`&&t.value===``&&x.highlightedChipIndex===void 0&&Array.isArray(R)&&R.length>0){let t=x.chipsRef.current.length,n=t>0?t-1:R.length-1,r=R.filter((e,t)=>t!==n);C.state.setIndices({activeIndex:null,selectedIndex:null,type:C.state.keyboardActiveRef.current?`keyboard`:`pointer`}),C.state.setSelectedValue(r,o(F,e.nativeEvent));return}let i=x?.highlightedChipIndex!==void 0,a=Oe(e);if(x?.setHighlightedChipIndex(a),a===void 0?i&&C.state.inputRef.current?.focus():x?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&se){let t=C.state.activeIndex,n=e.nativeEvent;if(t===null){if(z)return;C.state.setOpen(!1,o(F,n));return}tt(e);let r=C.state.listRef.current[t];r&&(C.state.selectionEventRef.current=n,r.click(),C.state.selectionEventRef.current=null)}},onPointerMove(){C.state.keyboardActiveRef.current=!1},onPointerDown(){C.state.keyboardActiveRef.current=!1}},Ee],stateAttributesMapping:xr}),Ae=S?(0,Q.jsx)(ae.Provider,{value:oe,children:ke}):ke;return(0,Q.jsxs)(Z.Fragment,{children:[se&&V&&(0,Q.jsx)(Or,{ref:C.state.startDismissRef}),Ae]})}),Ar={...vt,...kt},jr=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:s=!1,style:c,...l}=e,{disabled:u}=te(),d=or(),f=Y(d,$.selectionMode),p=Y(d,$.disabled),m=Y(d,$.readOnly),h=Y(d,$.open),g=Y(d,$.selectedValue),_=Y(d,$.hasSelectionChips),v=lr(),y=!1;y=f===`none`?v!==``:f===`single`?g!=null:_;let b=u||p||i,{buttonRef:S,getButtonProps:w}=x({native:a,disabled:b}),{mounted:T,transitionStatus:E,setMounted:D}=xt(y),O={disabled:b,visible:y,open:h,transitionStatus:E};gt({open:y,ref:d.state.clearRef,onComplete(){y||D(!1)}});let k=ne(`button`,e,{state:O,ref:[t,S,d.state.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(b||m)return;let t=d.state.keyboardActiveRef;d.state.setInputValue(``,o(C,e.nativeEvent)),f===`none`?d.state.setIndices({activeIndex:null,type:t.current?`keyboard`:`pointer`}):(d.state.setSelectedValue(Array.isArray(g)?[]:null,o(C,e.nativeEvent)),d.state.setIndices({activeIndex:null,selectedIndex:null,type:t.current?`keyboard`:`pointer`})),d.state.inputRef.current?.focus()}},l,w],stateAttributesMapping:Ar});return s||T?k:null}),Mr=Z.createContext(null);function Nr(){return Z.useContext(Mr)}function Pr(e){let{children:t}=e,{filteredItems:n}=cr(),r=Nr(),i=r?r.items:n;return i?(0,Q.jsx)(Z.Fragment,{children:i.map(t)}):null}var Fr=Z.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=or(),l=sr(),u=!!Dr(!0),{filteredItems:d,hasItems:f}=cr(),p=Y(c,$.selectionMode),h=Y(c,$.grid),g=Y(c,$.popupProps),_=Y(c,$.virtualized),v=Y(c,$.forceMounted),y=p===`multiple`,b=d.length===0,x=m(e=>{c.set(`positionerElement`,e)}),S=m(e=>{c.set(`listElement`,e)}),C=Z.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(Pr,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=ne(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:h?`grid`:`listbox`,"aria-multiselectable":y?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;tt(e);let n=e.nativeEvent,r=c.state.listRef.current[t];r&&(c.state.selectionEventRef.current=n,r.click(),c.state.selectionEventRef.current=null)}},onKeyDownCapture(){c.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.state.keyboardActiveRef.current=!1}},s]});if(_)return E;let D=f&&!v?void 0:c.state.labelsRef;return(0,Q.jsx)(bt,{elementsRef:c.state.listRef,labelsRef:D,children:E})}),Ir=``;function Lr(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Rr(){let e=b(),t=Z.useRef(null);return Z.useEffect(()=>{if(it)return;let n=t.current;if(n==null)return;let r=Lr(n);if(r==null)return;let i=r.nodeValue??``,a=`${i}${Ir}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var zr=Z.createContext(void 0);function Br(){let e=Z.useContext(zr);if(e===void 0)throw Error(s(20));return e}var Vr=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=or(),a=Y(i,$.mounted),o=Y(i,$.forceMounted);return a||n||o?(0,Q.jsx)(zr.Provider,{value:n,children:(0,Q.jsx)(Ut,{ref:t,...r})}):null}),Hr=Z.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=$e,style:_,...v}=e,y=or(),{filteredItems:b}=cr(),x=sr(),S=Br(),C=Y(y,$.modal),w=Y(y,$.open),E=Y(y,$.mounted),D=Y(y,$.openMethod),O=Y(y,$.positionerElement),k=Y(y,$.triggerElement),A=Y(y,$.inputElement),j=Y(y,$.inputGroupElement),M=Y(y,$.inputInsidePopup),N=Y(y,$.transitionStatus),P=b.length===0,F=Xe({anchor:i??(M?k:j??A),floatingRootContext:x,positionMethod:a,mounted:E,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:h,keepMounted:S,collisionAvoidance:g,lazyFlip:!0});_t(w&&C,D===`touch`,O,k);let I={open:w,side:F.side,align:F.align,anchorHidden:F.anchorHidden,empty:P};T(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=m(e=>{y.set(`positionerElement`,e)}),L=ut(e,I,{styles:F.positionerStyles,transitionStatus:N,props:v,refs:[t,ee],hidden:!E,inert:!w});return(0,Q.jsxs)(Er.Provider,{value:F,children:[E&&C&&(0,Q.jsx)(rt,{inert:lt(!w),cutout:j??A??k}),L]})}),Ur={...yt,...vt},Wr=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=or(),l=Dr(),u=sr(),{filteredItems:d}=cr(),f=Y(c,$.mounted),p=Y(c,$.open),m=Y(c,$.openMethod),h=Y(c,$.transitionStatus),g=Y(c,$.inputInsidePopup),_=Y(c,$.inputElement),v=Y(c,$.modal),y=Y(c,$.id),b=d.length===0,x=s.id??(g?dr(y):void 0);T(()=>(c.set(`popupId`,c.state.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),gt({open:p,ref:c.state.popupRef,onComplete(){p&&c.state.onOpenChangeComplete(!0)}});let S=ne(`div`,e,{state:{open:p,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.state.popupRef],props:[{id:x,role:g?`dialog`:`presentation`,tabIndex:-1,onFocus(e){let t=ee(e.nativeEvent);m!==`touch`&&(P(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},at(h),s],stateAttributesMapping:Ur}),C=a===void 0?g?e=>e===`touch`?c.state.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let E=!g||v;return(0,Q.jsx)(K,{context:u,disabled:!f,modal:E,openInteractionType:m,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,Q.jsxs)(Z.Fragment,{children:[S,E&&(0,Q.jsx)(Or,{ref:c.state.endDismissRef})]})})}),Gr=Z.createContext(void 0);function Kr(){let e=Z.useContext(Gr);if(!e)throw Error(s(19));return e}var qr=Z.createContext(!1);function Jr(){return Z.useContext(qr)}var Yr=e(r(),1);function Xr(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=Z.useRef(!1),m=Z.useRef(null),h=Ct({index:l,textRef:m,indexGuessBehavior:Dt.GuessFromOrder}),g=or(),_=Jr(),v=ur(),y=Y(g,$.open),b=Y(g,$.selectionMode),S=Y(g,$.readOnly),C=Y(g,$.isItemEqualToValue),w=b!==`none`,E=l??(r?i??-1:h.index),D=h.index!==-1,O=Y(g,$.id),k=Y(g,$.isActive,E),A=Y(g,$.isSelected,c),j=Y(g,$.itemProps),M=Z.useRef(null),N=O!=null&&D?`${O}-${E}`:void 0,P=A&&w;T(()=>{if(!(D&&(r||l!=null)))return;let e=g.state.listRef.current;return e[E]=M.current,()=>{delete e[E]}},[D,r,E,l,g]),T(()=>{if(!D||v)return;let e=g.state.valuesRef.current;return e[E]=c,b!==`none`&&g.state.allValuesRef.current.push(c),()=>{delete e[E]}},[D,v,E,c,g,b]),T(()=>{if(!y){p.current=!1;return}if(!D||v)return;let e=g.state.selectedValue;he(c,Array.isArray(e)?e[e.length-1]:e,C)&&g.set(`selectedIndex`,E)},[D,v,y,g,E,c,C]);let{getButtonProps:F,buttonRef:I}=x({disabled:u,focusableWhenDisabled:!0,native:d,composite:!0}),ee={disabled:u,selected:P,highlighted:k};function L(e){function t(){g.state.handleSelection(e,c)}g.state.submitOnItemClick?(Yr.flushSync(t),g.state.requestSubmit()):t()}let te={id:N,role:_?`gridcell`:`option`,"aria-selected":w?P:void 0,tabIndex:void 0,onPointerDownCapture(e){p.current=!0,e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){u||S||L(e.nativeEvent)},onMouseUp(e){let t=p.current;p.current=!1,!(u||S||e.button!==0||t||!k)&&L(e.nativeEvent)}},re=ne(`div`,t,{ref:[I,n,h.ref,M],state:ee,props:[j,te,f,F]}),ie=Z.useMemo(()=>({selected:P,textRef:m}),[P,m]);return(0,Q.jsx)(Gr.Provider,{value:ie,children:re})}function Zr(e){let{componentProps:t,forwardedRef:n}=e,r=Y(or(),$.isItemEqualToValue),{flatFilteredItems:i}=cr();return(0,Q.jsx)(Xr,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:ve(i,t.value??null,r)})}var Qr=Z.memo(Z.forwardRef(function(e,t){let n=Y(or(),$.virtualized);return n&&e.index==null?(0,Q.jsx)(Zr,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(Xr,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),$r=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=cr(),c=or(),l=Rr(),u=s.length===0?a:null;return ne(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function ei(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,Q.jsx)(br,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var ti=Z.forwardRef(function(e,t){let n=e.keepMounted??!1,{selected:r}=Kr();return n||r?(0,Q.jsx)(ni,{...e,ref:t}):null}),ni=Z.memo(Z.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Kr(),c=Z.useRef(null),{transitionStatus:l,setMounted:u}=xt(s),d=ne(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:vt});return gt({open:s,ref:c,onComplete(){s||u(!1)}}),d})),ri=ei;function ii({className:e,children:t,...n}){return(0,Q.jsxs)(Cr,{"data-slot":`combobox-trigger`,className:l(`cursor-pointer data-disabled:cursor-not-allowed [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,Q.jsx)(ge,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function ai({className:e,...t}){return(0,Q.jsx)(jr,{"data-slot":`combobox-clear`,render:(0,Q.jsx)(Oe,{variant:`ghost`,size:`icon-xs`}),className:l(e),...t,children:(0,Q.jsx)(ke,{className:`pointer-events-none`})})}function oi({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...a}){return(0,Q.jsxs)(Me,{className:l(`w-auto`,e),children:[(0,Q.jsx)(kr,{render:(0,Q.jsx)(xe,{disabled:n}),...a}),(0,Q.jsxs)(Pe,{align:`inline-end`,children:[r&&(0,Q.jsx)(Oe,{size:`icon-xs`,variant:`ghost`,render:(0,Q.jsx)(ii,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n}),i&&(0,Q.jsx)(ai,{disabled:n})]}),t]})}function si({className:e,side:t=`bottom`,sideOffset:n=6,align:r=`start`,alignOffset:i=0,anchor:a,...o}){return(0,Q.jsx)(Vr,{children:(0,Q.jsx)(Hr,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:a,className:`isolate z-50`,children:(0,Q.jsx)(Wr,{"data-slot":`combobox-content`,"data-chips":!!a,className:l(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o})})})}function ci({className:e,...t}){return(0,Q.jsx)(Fr,{"data-slot":`combobox-list`,className:l(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,e),...t})}function li({className:e,children:t,...n}){return(0,Q.jsxs)(Qr,{"data-slot":`combobox-item`,className:l(`relative flex w-full cursor-pointer items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,Q.jsx)(ti,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,Q.jsx)(et,{className:`pointer-events-none`})})]})}function ui({className:e,...t}){return(0,Q.jsx)($r,{"data-slot":`combobox-empty`,className:l(`hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex`,e),...t})}var di=`cline.code.model-selection.v1`;function fi(e){return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([e,t])=>typeof e==`string`&&typeof t==`string`&&t.trim().length>0))}function pi(e){let t={lastProvider:``,lastModelByProvider:{}};if(!e)return t;try{let n=JSON.parse(e);if(!n||typeof n!=`object`||Array.isArray(n))return t;let r=n;return`lastProvider`in r||`lastModelByProvider`in r?{lastProvider:typeof r.lastProvider==`string`?r.lastProvider.trim():``,lastModelByProvider:fi(r.lastModelByProvider)}:{lastProvider:``,lastModelByProvider:fi(n)}}catch{return t}}function mi(){return typeof window>`u`?{lastProvider:``,lastModelByProvider:{}}:pi(window.localStorage.getItem(di))}var hi={openai:`openai-native`,google:`gemini`};function gi(e){let t=e.trim();return t?hi[t]??t:``}function _i(e){return(e??[]).map(e=>e.id)}function vi(e){return(e??[]).filter(e=>e.supportsReasoning).map(e=>e.id)}function yi(e){return{providers:e,enabledProviderIds:e.filter(e=>e.enabled).map(e=>e.id),providerModels:Object.fromEntries(e.map(e=>[e.id,_i(e.modelList)])),providerReasoningModels:Object.fromEntries(e.map(e=>[e.id,vi(e.modelList)]))}}async function bi(){return yi((await G.invoke(`list_provider_catalog`)).providers??[])}async function xi(e){return(await G.invoke(`list_provider_models`,{provider:e})).models??[]}var Si=3e4,Ci=null;async function wi(){let e=await G.invoke(`list_routine_schedules`);return{schedules:e.schedules??[],activeExecutions:e.activeExecutions??[],upcomingRuns:e.upcomingRuns??[],lastExecutions:e.lastExecutions??[]}}var Ti={cline:[`anthropic/claude-sonnet-4.6`],anthropic:[`claude-sonnet-4-6`],"openai-native":[`gpt-5.3-codex`],openrouter:[`anthropic/claude-sonnet-4.6`],gemini:[`gemini-2.5-pro`]},Ei=[{label:`Mon`,value:`MON`},{label:`Tue`,value:`TUE`},{label:`Wed`,value:`WED`},{label:`Thu`,value:`THU`},{label:`Fri`,value:`FRI`},{label:`Sat`,value:`SAT`},{label:`Sun`,value:`SUN`}];function Di(e){if(e==null)return`-`;if(typeof e==`number`){if(!Number.isFinite(e))return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?`-`:t.toLocaleString()}let t=e.trim();if(t.length===0)return`-`;let n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Oi(e){let t=e.modelSelection?.providerId?.trim()||e.provider?.trim(),n=e.modelSelection?.modelId?.trim()||e.model?.trim();return t&&n?`${t}/${n}`:n||t||`-`}function ki(e){return{provider:e.modelSelection?.providerId?.trim()||e.provider?.trim()||`cline`,model:e.modelSelection?.modelId?.trim()||e.model?.trim()||`openai/gpt-5.3-codex`}}function Ai(e){if(!e)return`-`;let t=e.status?.trim()||`unknown`,n=Di(e.endedAt??e.startedAt??e.triggeredAt);return n===`-`?t:`${t} at ${n}`}function ji(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<=0))return n}function Mi(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:void 0}function Ni(e){let t=new Set(e);return Ei.map(e=>e.value).filter(e=>t.has(e))}function Pi(e,t,n){let r=Ni(e);if(r.length===0)return``;let i=Number.parseInt(t,10),a=Number.parseInt(n,10),o=Number.isFinite(i)?Math.min(Math.max(i,0),23):9,s=Number.isFinite(a)?Math.min(Math.max(a,0),59):0;return r.length===Ei.length?`${s} ${o} * * *`:`${s} ${o} * * ${r.join(`,`)}`}function Fi(e){let t=e?.trim().toUpperCase();if(!t||t===`*`)return Ei.map(e=>e.value);let n=new Set;for(let e of t.split(`,`)){let t=e.trim();if(!t)continue;let r=/^([A-Z]{3})-([A-Z]{3})$/.exec(t);if(r){let e=Ei.findIndex(e=>e.value===r[1]),t=Ei.findIndex(e=>e.value===r[2]);if(e>=0&&t>=e)for(let r=e;r<=t;r+=1)n.add(Ei[r].value);continue}Ei.some(e=>e.value===t)&&n.add(t)}return Ni([...n])}function Ii(e){let t=e.trim().split(/\s+/),n=Number.parseInt(t[0]??``,10),r=Number.parseInt(t[1]??``,10),i=Fi(t[4]);return{scheduleHour:Number.isInteger(r)&&r>=0&&r<=23?String(r):`9`,scheduleMinute:Number.isInteger(n)&&n>=0&&n<=59?String(n):`0`,scheduleDays:i.length>0?i:[`MON`,`TUE`,`WED`,`THU`,`FRI`]}}function Li(){let[e,t]=(0,Z.useState)(()=>Ci?.schedules??[]),[n,r]=(0,Z.useState)(()=>Ci?.activeExecutions??[]),[i,a]=(0,Z.useState)(()=>Ci?.upcomingRuns??[]),[o,s]=(0,Z.useState)(()=>Ci?.lastExecutions??[]),[c,u]=(0,Z.useState)(()=>!Ci),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(Ti),[D,O]=(0,Z.useState)(()=>Object.keys(Ti)),[k]=(0,Z.useState)(()=>mi()),A=gi(k.lastProvider),[M,N]=(0,Z.useState)({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:`cline`,model:`openai/gpt-5.3-codex`,mode:`act`,workspaceRoot:``,cwd:``,systemPrompt:``,maxIterations:``,timeoutSeconds:``,maxParallel:`1`,tags:``,enabled:!0}),P=(0,Z.useMemo)(()=>{if(D.length===0)return T;let e={};for(let t of D)e[t]=T[t]??[];return e},[D,T]),F=(0,Z.useMemo)(()=>Object.keys(P),[P]),I=(0,Z.useMemo)(()=>P[M.provider]??[],[M.provider,P]),ee=(0,Z.useMemo)(()=>Pi(M.scheduleDays,M.scheduleHour,M.scheduleMinute),[M.scheduleDays,M.scheduleHour,M.scheduleMinute]);(0,Z.useEffect)(()=>{let e=!1;async function t(){try{let t=await bi();if(e)return;E(t.providerModels),O(e=>{let n=new Set(t.enabledProviderIds),r=gi(M.provider);r&&n.add(r);for(let r of e)r in t.providerModels&&n.add(r);return Array.from(n)})}catch{}}return t(),()=>{e=!0}},[M.provider]),(0,Z.useEffect)(()=>{let e=gi(M.provider);if(!e||(T[e]??[]).length>0)return;let t=!1;async function n(){try{let n=await xi(e);if(t||n.length===0)return;E(t=>({...t,[e]:n.map(e=>e.id)})),O(t=>t.includes(e)?t:[...t,e])}catch{}}return n(),()=>{t=!0}},[M.provider,T]),(0,Z.useEffect)(()=>{if(F.length===0)return;let e=null,t=gi(M.provider);if(F.includes(t)){let n=P[t]??[];if(n.length===0||n.includes(M.model))return;let r=k.lastModelByProvider[t]??k.lastModelByProvider[k.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]}}else{let t=A&&F.includes(A)?A:F[0],n=P[t]??[],r=k.lastModelByProvider[t]??k.lastModelByProvider[k.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]??``}}let n=window.setTimeout(()=>{N(t=>({...t,...e}))},0);return()=>window.clearTimeout(n)},[F,M.model,M.provider,k.lastModelByProvider,k.lastProvider,A,P]);let L=(0,Z.useCallback)(async e=>{let n=Date.now();if(!e?.force&&Ci&&n-Ci.fetchedAt<Si){t(Ci.schedules),r(Ci.activeExecutions),a(Ci.upcomingRuns),s(Ci.lastExecutions),f(null),u(!1);return}e?.showLoading!==!1&&u(!0),f(null);try{let e=await wi(),i=e.schedules,o=e.activeExecutions,c=e.upcomingRuns,l=e.lastExecutions;t(i),r(o),a(c),s(l),Ci={schedules:i,activeExecutions:o,upcomingRuns:c,lastExecutions:l,fetchedAt:n}}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{L()},0);return()=>window.clearTimeout(e)},[L]);let te=async(e,t)=>{m(e.scheduleId),f(null);try{t?await G.invoke(`resume_routine_schedule`,{schedule_id:e.scheduleId}):await G.invoke(`pause_routine_schedule`,{schedule_id:e.scheduleId}),await L({force:!0,showLoading:!1})}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},ne=async e=>{m(e),f(null);try{await G.invoke(`trigger_routine_schedule`,{schedule_id:e}),await L({force:!0,showLoading:!1}),window.setTimeout(()=>{L({force:!0,showLoading:!1})},1e3)}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},re=async e=>{m(e),f(null);try{await G.invoke(`delete_routine_schedule`,{schedule_id:e}),g(null),await L({force:!0,showLoading:!1})}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(null)}},ie=async()=>{b(null),f(null),w(null);let e={workspaceRoot:``,cwd:``};try{e=await G.invoke(`get_process_context`)}catch{}let t=A&&F.includes(A)?A:F[0]??`cline`,n=P[t]??[],r=k.lastModelByProvider[t]??k.lastModelByProvider[k.lastProvider];N({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:t,model:r&&n.includes(r)?r:n[0]??M.model,mode:`act`,workspaceRoot:e.workspaceRoot||e.cwd,cwd:e.cwd||``,systemPrompt:``,maxIterations:``,timeoutSeconds:``,maxParallel:`1`,tags:``,enabled:!0}),v(!0)},ae=e=>{let{provider:t,model:n}=ki(e),r=Ii(e.cronPattern);b(e),f(null),w(null),O(e=>e.includes(t)?e:[...e,t]),E(e=>e[t]?.includes(n)?e:{...e,[t]:[...e[t]??[],n]}),N({name:e.name,...r,prompt:e.prompt,provider:t,model:n,mode:e.mode===`plan`?`plan`:`act`,workspaceRoot:e.workspaceRoot??``,cwd:e.cwd??``,systemPrompt:e.systemPrompt??``,maxIterations:typeof e.maxIterations==`number`?String(e.maxIterations):``,timeoutSeconds:typeof e.timeoutSeconds==`number`?String(e.timeoutSeconds):``,maxParallel:typeof e.maxParallel==`number`?String(e.maxParallel):`1`,tags:e.tags?.join(`,`)??``,enabled:e.enabled}),v(!0)},oe=async()=>{let e=M.name.trim();if(!e){w(`Routine name is required.`);return}let t=Pi(M.scheduleDays,M.scheduleHour,M.scheduleMinute);if(!t){w(`Select at least one day and a valid time.`);return}let n=M.prompt.trim();if(!n){w(`Prompt is required.`);return}let r=M.workspaceRoot.trim();if(!r){w(`Workspace root is required.`);return}w(null),S(!0);try{let i=gi(M.provider)||F[0]||`cline`,a=M.model.trim()||(P[i]??[])[0]||`openai/gpt-5.3-codex`,o=ji(M.maxIterations),s=ji(M.timeoutSeconds),c=ji(M.maxParallel)??1,l=Mi(M.tags),u=y?`update_routine_schedule`:`create_routine_schedule`;await G.invoke(u,{...y?{schedule_id:y.scheduleId}:void 0,name:e,cron_pattern:t,prompt:n,provider:i,model:a,mode:M.mode,workspace_root:r,cwd:M.cwd.trim()||void 0,system_prompt:y?M.systemPrompt.trim()||null:M.systemPrompt.trim()||void 0,max_iterations:y?o??null:o,timeout_seconds:y?s??null:s,max_parallel:c,enabled:M.enabled,tags:l??[]}),await L({force:!0,showLoading:!1}),v(!1),b(null)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},se=(0,Z.useMemo)(()=>{let e=new Map;for(let t of n)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[n]),ce=(0,Z.useMemo)(()=>{let e=new Map;for(let t of o)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[o]),R=(0,Z.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]);return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`Scheduled jobs are run through the hub.`,title:`Schedules`,meta:(0,Q.jsx)(wt,{children:`cline schedule`}),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:c,children:(0,Q.jsx)(He,{className:l(`h-4 w-4`,c&&`animate-spin`)})}),(0,Q.jsxs)(z,{size:`sm`,onClick:()=>void ie(),children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),`New Schedule`]})]})}),d&&(0,Q.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),c?(0,Q.jsx)(ft,{children:`Loading schedules...`}):R.length===0?(0,Q.jsx)(ft,{children:`No schedules found. Create a schedule to run routines on a recurring basis.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:R.map(e=>{let t=p===e.scheduleId,n=se.get(e.scheduleId),r=ce.get(e.scheduleId),a=i.find(t=>t.scheduleId===e.scheduleId);return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(B,{className:l(`h-2.5 w-2.5 shrink-0`,e.enabled?`fill-primary text-primary`:`fill-muted-foreground/40 text-muted-foreground/40`)}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.mode}),(0,Q.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.cronPattern}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`View ${e.name}`,onClick:()=>{window.alert(JSON.stringify(e,null,2))},children:(0,Q.jsx)(en,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ae(e),disabled:t,children:(0,Q.jsx)(Kt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run ${e.name} now`,onClick:()=>void ne(e.scheduleId),disabled:t,children:(0,Q.jsx)(Ue,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":e.enabled?`Pause ${e.name}`:`Resume ${e.name}`,onClick:()=>void te(e,!e.enabled),disabled:t,children:e.enabled?(0,Q.jsx)(on,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(z,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>g(e),disabled:t,children:(0,Q.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Ye,{checked:e.enabled,onCheckedChange:t=>void te(e,t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,Q.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`ID:`}),` `,e.scheduleId]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Prompt:`}),` `,e.prompt]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Model:`}),` `,Oi(e)]}),e.workspaceRoot&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Workspace:`}),` `,e.workspaceRoot]}),e.cwd&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last run:`}),` `,Di(e.lastRunAt)]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last result:`}),` `,Ai(r)]}),r?.sessionId&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last session:`}),` `,r.sessionId]}),r?.errorMessage&&(0,Q.jsxs)(`p`,{className:`text-destructive`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last error:`}),` `,r.errorMessage]}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Next run:`}),` `,Di(e.nextRunAt||a?.nextRunAt)]}),n&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Active:`}),` `,n.executionId,` since`,` `,Di(n.startedAt)]}),e.tags&&e.tags.length>0&&(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Tags:`}),` `,e.tags.join(`, `)]})]})]},e.scheduleId)})}),(0,Q.jsx)(q,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,Q.jsxs)(Wt,{children:[(0,Q.jsxs)(ot,{children:[(0,Q.jsx)(Qe,{children:`Delete Routine`}),(0,Q.jsxs)(mt,{children:[`This will delete "`,h?.name??`this routine`,`" and remove future scheduled runs.`]})]}),(0,Q.jsxs)(Ht,{children:[(0,Q.jsx)(Rt,{disabled:h?p===h.scheduleId:!1,children:`Cancel`}),(0,Q.jsx)(dt,{disabled:!h||p===h.scheduleId,onClick:()=>{h&&re(h.scheduleId)},variant:`destructive`,children:`Delete`})]})]})}),(0,Q.jsx)(Ce,{open:_,onOpenChange:e=>{v(e),e||(w(null),b(null))},children:(0,Q.jsxs)(je,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ne,{children:y?`Edit Routine`:`Create Routine`}),(0,Q.jsx)(Ie,{children:y?`Update this scheduler routine.`:`Create a scheduler routine.`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-name`,children:`Name`}),(0,Q.jsx)(j,{id:`routine-name`,value:M.name,onChange:e=>N(t=>({...t,name:e.target.value})),placeholder:`Daily code review`})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2 space-y-3`,children:[(0,Q.jsx)(W,{children:`Schedule`}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 rounded-md border border-border p-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-hour`,children:`Hour`}),(0,Q.jsxs)(De,{value:M.scheduleHour,onValueChange:e=>N(t=>({...t,scheduleHour:e??t.scheduleHour})),children:[(0,Q.jsx)(Le,{className:`w-full`,id:`routine-hour`,children:(0,Q.jsx)(Be,{placeholder:`Hour`})}),(0,Q.jsx)(Ee,{children:Array.from({length:24},(e,t)=>t).map(e=>(0,Q.jsx)(be,{value:`${e}`,children:e.toString().padStart(2,`0`)},`hour-${e}`))})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-minute`,children:`Minute`}),(0,Q.jsxs)(De,{value:M.scheduleMinute,onValueChange:e=>N(t=>({...t,scheduleMinute:e??t.scheduleMinute})),children:[(0,Q.jsx)(Le,{className:`w-full`,id:`routine-minute`,children:(0,Q.jsx)(Be,{placeholder:`Minute`})}),(0,Q.jsx)(Ee,{children:Array.from({length:60},(e,t)=>t).map(e=>(0,Q.jsx)(be,{value:`${e}`,children:e.toString().padStart(2,`0`)},`minute-${e}`))})]})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{children:`Days of week`}),(0,Q.jsx)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-4`,children:Ei.map(e=>{let t=`routine-day-${e.value.toLowerCase()}`;return(0,Q.jsxs)(W,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-sm`,htmlFor:t,children:[(0,Q.jsx)($n,{checked:M.scheduleDays.includes(e.value),id:t,onCheckedChange:t=>N(n=>{let r=new Set(n.scheduleDays);return t===!0?r.add(e.value):r.delete(e.value),{...n,scheduleDays:Ni([...r])}})}),e.label]},e.value)})})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2 rounded-md border border-border bg-muted/30 px-2 py-1.5 text-xs text-muted-foreground`,children:[`Cron:`,` `,(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:ee||`Select one or more days`})]})]})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-prompt`,children:`Prompt`}),(0,Q.jsx)(Fe,{id:`routine-prompt`,value:M.prompt,onChange:e=>N(t=>({...t,prompt:e.target.value})),rows:4})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{children:`Provider`}),(0,Q.jsxs)(ri,{items:F,onValueChange:e=>{if(!e)return;let t=P[e]??[],n=k.lastModelByProvider[e],r=n&&t.includes(n)?n:t[0]??``;N(t=>({...t,provider:e,model:r}))},value:M.provider,children:[(0,Q.jsx)(oi,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,Q.jsxs)(si,{children:[(0,Q.jsx)(ui,{children:`No providers found.`}),(0,Q.jsx)(ci,{children:e=>(0,Q.jsx)(li,{value:e,children:e},e)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{children:`Model`}),(0,Q.jsxs)(ri,{items:I,onValueChange:e=>{e&&N(t=>({...t,model:e}))},value:M.model,children:[(0,Q.jsx)(oi,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,Q.jsxs)(si,{children:[(0,Q.jsx)(ui,{children:`No models found.`}),(0,Q.jsx)(ci,{children:e=>(0,Q.jsx)(li,{value:e,children:e},e)})]})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{children:`Mode`}),(0,Q.jsxs)(De,{value:M.mode,onValueChange:e=>N(t=>({...t,mode:e===`plan`?`plan`:`act`})),children:[(0,Q.jsx)(Le,{className:`w-full`,children:(0,Q.jsx)(Be,{placeholder:`Select mode`})}),(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(be,{value:`act`,children:`act`}),(0,Q.jsx)(be,{value:`plan`,children:`plan`})]})]})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-workspace`,children:`Workspace root`}),(0,Q.jsx)(j,{id:`routine-workspace`,value:M.workspaceRoot,onChange:e=>N(t=>({...t,workspaceRoot:e.target.value}))})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-cwd`,children:`CWD (optional)`}),(0,Q.jsx)(j,{id:`routine-cwd`,value:M.cwd,onChange:e=>N(t=>({...t,cwd:e.target.value}))})]}),(0,Q.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Q.jsx)(W,{htmlFor:`routine-system-prompt`,children:`System prompt (optional)`}),(0,Q.jsx)(Fe,{id:`routine-system-prompt`,value:M.systemPrompt,onChange:e=>N(t=>({...t,systemPrompt:e.target.value})),rows:3})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-max-iterations`,children:`Max iterations (optional)`}),(0,Q.jsx)(j,{id:`routine-max-iterations`,value:M.maxIterations,onChange:e=>N(t=>({...t,maxIterations:e.target.value})),placeholder:`50`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-timeout`,children:`Timeout seconds (optional)`}),(0,Q.jsx)(j,{id:`routine-timeout`,value:M.timeoutSeconds,onChange:e=>N(t=>({...t,timeoutSeconds:e.target.value})),placeholder:`3600`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-max-parallel`,children:`Max parallel`}),(0,Q.jsx)(j,{id:`routine-max-parallel`,value:M.maxParallel,onChange:e=>N(t=>({...t,maxParallel:e.target.value})),placeholder:`1`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{htmlFor:`routine-tags`,children:`Tags (comma-separated, optional)`}),(0,Q.jsx)(j,{id:`routine-tags`,value:M.tags,onChange:e=>N(t=>({...t,tags:e.target.value})),placeholder:`automation,review`})]})]}),C&&(0,Q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:C}),(0,Q.jsxs)(we,{children:[(0,Q.jsx)(z,{variant:`outline`,onClick:()=>v(!1),disabled:x,children:`Cancel`}),(0,Q.jsx)(z,{onClick:()=>void oe(),disabled:x,children:x?y?`Saving...`:`Creating...`:y?`Save Changes`:`Create Schedule`})]})]})})]})}function Ri(e,t,n){let r=t.split(`.`).filter(Boolean);if(r.length===0)return;let i=e;for(let e of r.slice(0,-1)){let t=i[e];(!t||typeof t!=`object`||Array.isArray(t))&&(i[e]={}),i=i[e]}let a=r.at(-1);a&&(i[a]=n)}function zi(e){let t={};for(let[n,r]of Object.entries(e))Ri(t,n,r);return t}var Bi=[`General`,`Providers`,`MCP`,`Channels`,`Schedules`,`Account`],Vi=6e4,Hi=null;function Ui({chrome:e=`full`,initialSection:t=`General`,onClose:n,onNavigateSection:r}){let[i,a]=(0,Z.useState)(t),[o,s]=(0,Z.useState)(!0),[c,u]=(0,Z.useState)(()=>Hi?.providers??[]),[d,f]=(0,Z.useState)(()=>!Hi),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)({}),[_,v]=(0,Z.useState)({}),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useCallback)(e=>{u(t=>{let n=typeof e==`function`?e(t):e;return Hi={providers:n,fetchedAt:Date.now()},n})},[]),E=(0,Z.useCallback)(async()=>{if(Hi&&Date.now()-Hi.fetchedAt<Vi){u(Hi.providers),f(!1),m(null);return}f(!0),m(null);try{T((await G.invoke(`list_provider_catalog`)).providers)}catch(e){m(e instanceof Error?e.message:String(e)),u([])}finally{f(!1)}},[T]);(0,Z.useEffect)(()=>{if(i!==`Providers`)return;let e=window.setTimeout(()=>{E()},0);return()=>window.clearTimeout(e)},[i,E]);let D=(0,Z.useCallback)(async(e,t)=>{try{await G.invoke(`save_provider_settings`,{provider:e,enabled:t.enabled,api_key:t.apiKey,base_url:t.baseUrl,settings:t.configValues?zi(t.configValues):void 0})}catch(t){let n=t instanceof Error?t.message:String(t);window.alert(`Failed to save provider settings for ${e}: ${n}`)}},[]),O=(0,Z.useCallback)(e=>{T(t=>t.map(t=>{if(t.id!==e)return t;let n=!t.enabled;return D(e,{enabled:n}),{...t,enabled:n}}))},[D,T]),k=(0,Z.useCallback)((e,t)=>{T(n=>n.map(n=>n.id===e?{...n,...t,configValues:t.configValues?{...n.configValues??{},...t.configValues}:n.configValues}:n)),D(e,{apiKey:t.apiKey,baseUrl:t.baseUrl,configValues:t.configValues})},[D,T]),A=(0,Z.useCallback)(async e=>{g(t=>({...t,[e]:!0})),v(t=>({...t,[e]:null}));try{let t=await G.invoke(`list_provider_models`,{provider:e});T(n=>n.map(n=>n.id===e?{...n,modelList:t.models,models:t.models.length}:n))}catch(t){let n=t instanceof Error?t.message:String(t);v(t=>({...t,[e]:n}))}finally{g(t=>({...t,[e]:!1}))}},[T]),j=c.filter(e=>e.enabled),M=x?c.find(e=>e.id===x)??null:null,N=e=>e===`cline`||e===`oca`||e===`openai-codex`,P=async e=>{b(e);try{let t=await G.invoke(`run_provider_oauth_login`,{provider:e});T(n=>n.map(n=>n.id===e?{...n,enabled:!0,oauthAccessTokenPresent:t.accessToken.trim().length>0}:n)),S(e)}catch(t){let n=t instanceof Error?t.message:String(t);window.alert(`Failed to sign in to ${e}: ${n}`)}finally{b(null)}},F=e=>{a(`Providers`),r?.(`Providers`),S(e)};(0,Z.useEffect)(()=>{if(!x)return;let e=c.find(e=>e.id===x);if(!e||(e.modelList?.length??0)>0)return;let t=window.setTimeout(()=>{A(x)},0);return()=>window.clearTimeout(t)},[A,c,x]);let I=()=>{r?.(`Providers`),S(null),w(!1)},ee=(0,Z.useCallback)(async e=>{await G.invoke(`add_provider`,{provider_id:e.providerId,name:e.name,base_url:e.baseUrl,api_key:e.apiKey,headers:e.headers,timeout_ms:e.timeoutMs,models:e.models,default_model_id:e.defaultModelId,models_source_url:e.modelsSourceUrl,capabilities:e.capabilities}),await E(),w(!1),S(e.providerId)},[E]),L=()=>{r?.(`Providers`),S(null),w(!0)},te=e=>{a(e),r?.(e),S(null),w(!1)},ne=C?(0,Q.jsx)(Cn,{existingProviderIds:c.map(e=>e.id),onBack:I,onSave:ee}):d?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading providers...`})}):p?(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsxs)(`p`,{className:`max-w-xl px-4 text-center text-sm text-destructive`,children:[`Failed to load providers: `,p]})}):M?(0,Q.jsxs)(`div`,{className:`grid h-full grid-cols-[minmax(24rem,0.95fr)_minmax(28rem,1.05fr)] overflow-hidden max-[1100px]:grid-cols-1 max-[1100px]:grid-rows-[minmax(24rem,0.9fr)_minmax(26rem,1fr)]`,children:[(0,Q.jsx)(Un,{onAddProvider:L,onConfigure:F,onToggle:O,providers:c,selectedProviderId:M.id,variant:`panel`}),(0,Q.jsx)(`aside`,{className:`min-h-0 overflow-hidden border-l bg-background max-[1100px]:border-l-0 max-[1100px]:border-t`,children:(0,Q.jsx)(Wn,{modelsError:_[M.id]??null,modelsLoading:h[M.id]??!1,oauthLoginPending:y===M.id,onBack:I,onLoadModels:()=>void A(M.id),onOAuthLogin:N(M.id)?()=>void P(M.id):void 0,onUpdate:e=>k(M.id,e),provider:M,variant:`panel`})})]}):(0,Q.jsx)(Un,{onAddProvider:L,onConfigure:F,onToggle:O,providers:c}),re=i===`Providers`?ne:i===`MCP`?(0,Q.jsx)(zn,{}):i===`Channels`?(0,Q.jsx)(Mn,{}):i===`Schedules`?(0,Q.jsx)(Li,{}):i===`Account`?(0,Q.jsx)(xn,{}):i===`General`?(0,Q.jsx)(Wi,{}):(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i,` settings coming soon.`]})});return e===`content`?(0,Q.jsx)(`div`,{className:`h-full overflow-hidden bg-background`,children:re}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border px-6 py-3`,children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Settings`}),(0,Q.jsx)(z,{"aria-label":`Close settings`,className:`justify-start`,onClick:n,variant:`ghost`,children:(0,Q.jsx)(ke,{className:`size-3`})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,Q.jsx)(`nav`,{className:`w-56 shrink-0 border-r border-border`,children:(0,Q.jsx)(ht,{className:`h-full`,children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 p-3`,children:Bi.map(e=>e===`Providers`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(z,{className:l(`flex w-full items-center justify-between rounded-md px-3 py-2 text-sm transition-colors`,i===`Providers`?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>{te(`Providers`),s(e=>!e)},variant:`ghost`,children:[(0,Q.jsx)(`span`,{children:`Providers`}),o?(0,Q.jsx)(ge,{className:`size-3`}):(0,Q.jsx)(Yt,{className:`size-3`})]}),o&&(0,Q.jsx)(`div`,{className:`ml-3 mt-0.5 flex flex-col gap-0.5 border-l border-border pl-2`,children:j.map(e=>(0,Q.jsx)(z,{className:l(`justify-start`,x===e.id?`bg-accent/80 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/30`),disabled:y===e.id,onClick:()=>F(e.id),variant:`ghost`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})},e.id))})]},e):(0,Q.jsx)(z,{className:l(`justify-start`,i===e&&!x?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>{te(e)},variant:`ghost`,children:e},e))})})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:re})]})]})}function Wi(){let[e,t]=(0,Z.useState)(()=>typeof window>`u`?`light`:X()??Ot()),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!0),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!0),[f,p]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v=(0,Z.useCallback)(async()=>{a(!0),l(null),p(!0),_(null);try{let e=await G.invoke(`get_global_settings`);r(e.telemetryOptOut),d(e.autoUpdateEnabled)}catch(e){let t=e instanceof Error?e.message:String(e);l(t),_(t)}finally{a(!1),p(!1)}},[]);(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>{v()},0);return()=>window.clearTimeout(e)},[v]);let y=async e=>{let t=n;r(e),s(!0),l(null);try{r((await G.invoke(`set_telemetry_opt_out`,{telemetry_opt_out:e})).telemetryOptOut)}catch(e){let n=e instanceof Error?e.message:String(e);r(t),l(n)}finally{s(!1)}},b=async e=>{let t=u;d(e),h(!0),_(null);try{d((await G.invoke(`set_auto_update_enabled`,{auto_update_enabled:e})).autoUpdateEnabled)}catch(e){let n=e instanceof Error?e.message:String(e);d(t),_(n)}finally{h(!1)}};return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ft,{description:`Manage Hub preferences for this browser and CLI environment.`,title:`Settings`}),(0,Q.jsxs)(`section`,{className:`max-w-[86rem]`,children:[(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center justify-between gap-5 border-b max-[720px]:flex-col max-[720px]:items-stretch max-[720px]:py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Dark mode`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Keep the Hub interface in dark mode on this browser.`})]}),(0,Q.jsx)(Ye,{"aria-label":`Dark mode`,checked:e===`dark`,onCheckedChange:e=>{t(Nt(e?`dark`:`light`)),window.dispatchEvent(new Event(`cline-hub-theme-change`))}})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center justify-between gap-5 border-b max-[720px]:flex-col max-[720px]:items-stretch max-[720px]:py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Auto update`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Automatically install CLI updates on startup.`}),g?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update auto update setting: `,g]}):null]}),(0,Q.jsx)(Ye,{"aria-label":`Auto update`,checked:u,disabled:f||m,onCheckedChange:e=>void b(e)})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-20 items-center justify-between gap-5 border-b max-[720px]:flex-col max-[720px]:items-stretch max-[720px]:py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Telemetry`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Enable error and usage report to help us improve Cline.`}),c?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update telemetry setting: `,c]}):null]}),(0,Q.jsx)(Ye,{"aria-label":`Telemetry`,checked:!n,disabled:i||o,onCheckedChange:e=>void y(!e)})]})]})]})}export{Ui as SettingsView};
|