@cline/cli-windows-arm64 3.0.51 → 3.0.52
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-Byz21shc.js +201 -0
- package/cline-hub/webview/assets/badge-tZD_60cv.js +1 -0
- package/cline-hub/webview/assets/bundle-mjs-CO994-RQ.js +1 -0
- package/cline-hub/webview/assets/{chunk-BO2N2NFS-CdVUj51Q.js → chunk-BO2N2NFS-DJS94hax.js} +6 -6
- package/cline-hub/webview/assets/{desktop-client-B4hwKFvn.js → desktop-client-bYADwT3y.js} +1 -1
- package/cline-hub/webview/assets/extensions-view-B6Z6Tf6l.js +1 -0
- package/cline-hub/webview/assets/{highlighted-body-OFNGDK62-C3mWNVLk.js → highlighted-body-OFNGDK62-BOW3kov6.js} +1 -1
- package/cline-hub/webview/assets/index-BzdZ8J4d.css +1 -0
- package/cline-hub/webview/assets/index-Cw6Kg0MD.js +10 -0
- package/cline-hub/webview/assets/label-B4VTGFzI.js +1 -0
- package/cline-hub/webview/assets/mermaid-GHXKKRXX-CoORZYz7.js +1 -0
- package/cline-hub/webview/assets/{settings-view-0brQa7wc.js → settings-view-DvSMyQzo.js} +2 -2
- package/cline-hub/webview/assets/switch-DeaHMo5o.js +1 -0
- package/cline-hub/webview/index.html +3 -5
- package/package.json +1 -1
- package/cline-hub/webview/assets/Chat-CcvWZhaa.js +0 -201
- package/cline-hub/webview/assets/badge-BYJWm79X.js +0 -1
- package/cline-hub/webview/assets/bundle-mjs-D3mlU5Wg.js +0 -1
- package/cline-hub/webview/assets/extensions-view-CV6zk8Hh.js +0 -1
- package/cline-hub/webview/assets/index-LZX9pD_t.js +0 -10
- package/cline-hub/webview/assets/index-kv5oct7o.css +0 -1
- package/cline-hub/webview/assets/label-DdPtXNJI.js +0 -1
- package/cline-hub/webview/assets/mermaid-GHXKKRXX-DEqX-Lt6.js +0 -1
- package/cline-hub/webview/assets/react-dom-Cmec2Q1Q.js +0 -1
- package/cline-hub/webview/assets/switch-D32hLf2L.js +0 -1
- package/cline-hub/webview/assets/vscode-DBs95Ixu.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{i as n,r}from"./bundle-mjs-D3mlU5Wg.js";import{t as i}from"./react-dom-Cmec2Q1Q.js";import{$ as a,A as o,B as s,Bt as c,D as l,E as u,F as d,Ht as f,I as p,K as m,L as h,Mt as g,O as ee,P as _,Q as v,R as y,Rt as b,S as x,T as S,U as C,V as w,Vt as T,W as E,X as te,Y as ne,Z as re,_ as D,c as O,ct as ie,d as ae,dt as k,et as oe,f as se,ft as ce,g as le,h as ue,k as de,l as fe,lt as pe,m as me,p as he,st as ge,u as _e,v as ve,w as ye,x as be,xt as xe,y as A}from"./vscode-DBs95Ixu.js";import{A as Se,C as Ce,D as we,E as Te,F as Ee,I as De,M as Oe,N as ke,O as Ae,P as je,S as Me,T as Ne,_ as Pe,a as Fe,b as Ie,c as Le,d as Re,f as ze,g as Be,h as Ve,i as He,j as Ue,k as We,l as Ge,n as Ke,p as qe,r as Je,s as Ye,t as j,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./label-DdPtXNJI.js";import{a as tt,i as nt,n as rt,r as it,t as M}from"./desktop-client-B4hwKFvn.js";import{a as at,i as ot,n as st,r as ct,t as lt}from"./switch-D32hLf2L.js";import{$ as ut,B as dt,C as ft,Ct as pt,G as mt,Mt as ht,Nt as gt,O as _t,Pt as vt,Q as yt,S as bt,Tt as xt,W as St,X as Ct,Z as wt,_ as Tt,a as Et,at as Dt,b as N,bt as Ot,c as kt,ct as At,d as jt,dt as Mt,et as Nt,f as Pt,ft as Ft,g as It,gt as Lt,h as Rt,ht as P,i as zt,it as Bt,kt as Vt,m as Ht,mt as F,n as Ut,nt as Wt,o as Gt,ot as Kt,pt as qt,r as Jt,rt as Yt,s as I,t as Xt,tt as Zt,u as Qt,v as $t,vt as en,w as tn,wt as nn,x as rn,xt as an,y as on,yt as sn,z as cn}from"./index-LZX9pD_t.js";var ln=S(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),un=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`}]]),dn=S(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),fn=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`}]]),pn=S(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),mn=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`}]]),hn=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`}]]),gn=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`}]]),_n=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`}]]),vn=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`}]]),yn=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`}]]),bn=S(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),xn=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`}]]),L=e(n(),1),Cn=L.createContext({disabled:!1});function wn(){return L.useContext(Cn)}var Tn=L.createContext(void 0);function En(e=!0){let t=L.useContext(Tn);if(t===void 0&&!e)throw Error(c(3));return t}var R=r();function Dn(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 On(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 kn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function An(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function jn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function Mn(e){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Nn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Pn(e,t){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function Fn(){return await M.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function In(){let[e,t]=(0,L.useState)(`overview`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)([]),[p,m]=(0,L.useState)(!0),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)([]),[v,y]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(0),[T,E]=(0,L.useState)([]),[te,ne]=(0,L.useState)(!1),[re,D]=(0,L.useState)(null),[O,ie]=(0,L.useState)(!1),ae=d.find(e=>e.active)??null,k=(0,L.useCallback)(()=>{a(null),s(null),l(null),f([]),_([]),C(!1),x(null),E([]),ie(!1),D(null)},[]),oe=(0,L.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([kn(),An(),jn()]),r=n.find(e=>e.active)??null,i=r?await Mn(r.organizationId):null;a(e),s(t),l(i),f(n)}catch(e){k();let t=Dn(e).message;g(t)}finally{m(!1)}},[k]);(0,L.useEffect)(()=>{oe()},[oe]);let se=async()=>{r(`sign-in`),g(null);try{await M.invoke(`run_provider_oauth_login`,{provider:`cline`}),await oe(),t(`overview`)}catch(e){let t=Dn(e).message;g(t),k()}finally{r(null)}},ce=async()=>{r(`sign-out`);try{await M.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),k(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=Dn(e).message;g(t)}finally{r(null)}},le=(0,L.useCallback)(async()=>{let e=w.current;y(!0),x(null);try{let t=ae?await Pn(ae.organizationId,ae.memberId):await Nn();if(w.current!==e)return;_(t),C(!0)}catch(t){if(w.current!==e)return;let n=Dn(t).message;x(n)}finally{w.current===e&&y(!1)}},[ae]);(0,L.useEffect)(()=>{w.current+=1,_([]),C(!1),x(null)},[ae?.organizationId]),(0,L.useEffect)(()=>{e===`usage`&&!S&&le()},[e,S,le]);let ue=(0,L.useCallback)(async()=>{ne(!0),D(null);try{let e=await Fn();E(e),ie(!0)}catch(e){let t=Dn(e).message;D(t)}finally{ne(!1)}},[]);(0,L.useEffect)(()=>{e===`billing`&&!O&&ue()},[e,O,ue]);let de=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),fe=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),pe=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),me=ae?c?.balance??o?.balance??null:o?.balance??null,he=[`overview`,`usage`,`billing`],ge=(e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,R.jsx)(fn,{className:`h-8 w-8 text-destructive`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 rounded-lg border border-border px-3.5 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(nt,{className:`h-4 w-4`}),`Retry`]})]}),_e=()=>(0,R.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,R.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(St,{className:`h-6 w-6`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Connect your Cline account to review credits, usage, billing, and organization details from Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsxs)(A,{disabled:n!==null,onClick:()=>void se(),type:`button`,children:[n===`sign-in`?(0,R.jsx)(at,{className:`h-4 w-4 animate-spin`}):(0,R.jsx)(vn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,R.jsxs)(`a`,{className:`inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,href:`https://app.cline.bot`,rel:`noopener noreferrer`,target:`_blank`,children:[`Create account`,(0,R.jsx)(tt,{className:`h-4 w-4`})]})]})]})}),ve=()=>(0,R.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,R.jsx)(at,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,R.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:he.map(n=>{let r=!i&&n!==`overview`;return(0,R.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:u(`relative px-4 py-2.5 text-sm font-medium capitalize transition-colors`,e===n?`text-foreground`:`text-muted-foreground hover:text-foreground`,r&&`cursor-not-allowed opacity-45 hover:text-muted-foreground`),children:[n,e===n&&(0,R.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&ve(),h&&(On(h)?_e():ge(h,oe)),!p&&!h&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-primary/20 text-2xl font-bold text-primary`,children:i.displayName?.charAt(0)??i.email?.charAt(0)??`?`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,R.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,de(i.createdAt)]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[`Open dashboard`,(0,R.jsx)(tt,{className:`h-3.5 w-3.5`})]}),(0,R.jsxs)(A,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void ce(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,R.jsx)(at,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(yn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),me!==null&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(mn,{className:`h-5 w-5 text-primary`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:ae?`${ae.name} Balance`:`Credits Balance`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard/organization?tab=credits&redirect=true`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,R.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,R.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,pe(me)]})}),ae&&o&&(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,pe(o.balance),` `,`credits`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(un,{className:`h-5 w-5 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/onboarding?step=1`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-4 py-3 transition-colors hover:bg-accent/20`,children:[(0,R.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary text-sm font-bold text-foreground`,children:e.name.charAt(0)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,R.jsx)(`span`,{className:`rounded-full bg-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]},e.organizationId))})]})]})]}),e===`usage`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:ae?`Recent API usage and token consumption for ${ae.name}.`:`Recent API usage and token consumption across all providers.`}),v&&ve(),b&&ge(b,le),!v&&!b&&S&&(ee.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:ee.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,R.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,R.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:pe(e.creditsUsed)}),(0,R.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:de(e.createdAt)}),(0,R.jsx)(`p`,{children:fe(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),te&&ve(),re&&ge(re,ue),!te&&!re&&O&&(T.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Date`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:T.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Sn,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-foreground`,children:de(e.paidAt)})]}),(0,R.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,R.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,pe(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Ln=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Rn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,L.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(null),g=(0,L.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),ee=n.includes(g),_=r.models.length>0,v=r.modelsSourceUrl.trim().length>0,y=g.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(_||v)&&!ee,b=e=>{if((e.key===`Enter`||e.key===`,`)&&a.trim()){e.preventDefault();let t=a.trim().replace(/,/g,``);t&&!r.models.includes(t)&&i(e=>({...e,models:[...e.models,t],defaultModel:e.defaultModel||t})),o(``)}else e.key===`Backspace`&&!a&&r.models.length>0&&i(e=>({...e,models:e.models.slice(0,-1)}))},x=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},S=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},C=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},w=(e,t,n)=>{let a=Object.entries(r.headers),o={};a.forEach(([e,r],i)=>{o[i===n?t:e]=r}),e!==t&&delete o[e],i(e=>({...e,headers:o}))},T=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},E=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},te=async()=>{if(!(!y||f)){p(!0),h(null);try{await t({providerId:g,name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey.trim()||void 0,headers:Object.fromEntries(Object.entries(r.headers).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0)),timeoutMs:r.timeoutMs.trim().length>0?Number.parseInt(r.timeoutMs.trim(),10):void 0,models:r.models,defaultModelId:r.defaultModel||r.models[0],modelsSourceUrl:r.modelsSourceUrl.trim()||void 0,capabilities:r.capabilities.length>0?r.capabilities:void 0})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}};return(0,R.jsxs)(Gt,{contentClassName:`max-w-4xl`,children:[(0,R.jsx)(I,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,R.jsxs)(A,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,R.jsx)(ln,{className:`h-4 w-4`}),`Providers`]})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,R.jsx)(`input`,{type:`text`,value:r.providerId,onChange:e=>i(t=>({...t,providerId:e.target.value})),placeholder:`my-provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),ee?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,R.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`My Provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,R.jsx)(`input`,{type:`url`,value:r.baseUrl,onChange:e=>i(t=>({...t,baseUrl:e.target.value})),placeholder:`https://api.example.com/v1`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,R.jsx)(`input`,{type:`url`,value:r.modelsSourceUrl,onChange:e=>i(t=>({...t,modelsSourceUrl:e.target.value})),placeholder:`https://api.example.com/v1/models`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:"Supported JSON: OpenAI `/models` shape with a `data` array, or a direct model array."})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex min-h-11 flex-wrap content-start gap-1.5 rounded-lg border border-border bg-input px-3 py-2 focus-within:ring-1 focus-within:ring-ring`,children:[r.models.map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:e}),(0,R.jsx)(A,{onClick:()=>x(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,R.jsx)(Ue,{className:`h-3 w-3`})})]},e)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:b,placeholder:r.models.length===0?`Type model ID and press Enter`:``,className:`min-w-35 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none`})]}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Add at least one model or set a Model Source URL.`})]}),r.models.length>1?(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,R.jsx)(`select`,{value:r.defaultModel,onChange:e=>i(t=>({...t,defaultModel:e.target.value})),className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,children:r.models.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`input`,{type:s?`text`:`password`,value:r.apiKey,onChange:e=>i(t=>({...t,apiKey:e.target.value})),placeholder:`sk-...`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 pr-20 font-mono text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,R.jsx)(A,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(A,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,R.jsx)(je,{className:`h-4 w-4`})})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(j,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ln.map(e=>(0,R.jsx)(A,{onClick:()=>S(e),className:u(`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all`,r.capabilities.includes(e)?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-card text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:e.replace(/-/g,` `)},e))})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(A,{onClick:()=>d(!l),className:`flex w-full items-center justify-between px-5 py-4 text-sm font-medium transition-colors text-foreground/40`,variant:`ghost`,children:[`Advanced Settings`,(0,R.jsx)(De,{className:u(`h-4 w-4 text-muted-foreground transition-transform`,l&&`rotate-180`)})]}),l?(0,R.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,R.jsx)(`input`,{type:`number`,value:r.timeoutMs,onChange:e=>i(t=>({...t,timeoutMs:e.target.value})),placeholder:`30000`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,value:e,onChange:t=>w(e,t.target.value,n),placeholder:`Header name`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`input`,{type:`text`,value:t,onChange:t=>T(e,t.target.value),placeholder:`Value`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(A,{onClick:()=>E(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,R.jsx)(ye,{className:`h-4 w-4`})})]},e)),(0,R.jsxs)(A,{onClick:C,className:`flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,R.jsx)(Oe,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),m?(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:m}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,R.jsx)(A,{onClick:e,className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void te(),disabled:!y||f,className:u(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,y&&!f?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:f?`Saving...`:`Add Provider`})]})]})]})}function zn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Bn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Vn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Hn(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 Un(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Wn(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 Gn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Kn(e){let t=e[0];return{channelId:t?.id??``,values:Gn(t),securityEnabled:!1,securityValues:{}}}function qn(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)(null),v=(0,L.useMemo)(()=>e.find(e=>e.id===p.channelId),[e,p.channelId]),y=(0,L.useMemo)(()=>{let e={...Gn(v),...p.values};return(v?.fields??[]).filter(t=>Wn(t,e))},[v,p.values]),b=(0,L.useCallback)(e=>{t(e.available),r(e.active),m(t=>t.channelId?t:Kn(e.available))},[]),x=(0,L.useCallback)(async()=>{a(!0),l(null);try{let e=await M.invoke(`list_connector_channels`);b(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[b]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0);return()=>window.clearTimeout(e)},[x]);let S=()=>{m(Kn(e)),g(null),f(!0)},C=(e,t)=>{m(n=>({...n,values:{...n.values,[e]:t}}))},w=(e,t)=>{m(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},T=async()=>{if(!v){g(`Choose a channel`);return}for(let e of v.fields)if(y.includes(e)&&e.required&&!p.values[e.flag]?.trim()){g(`${e.label} is required`);return}if(p.securityEnabled&&v.security){for(let e of v.security.fields)if(!p.securityValues[e.key]?.trim()){g(e.requiredMessage);return}}s(v.id),g(null),l(null);try{let e=await M.invoke(`start_connector_channel`,{channel:v.id,values:p.values,security:{enabled:p.securityEnabled,values:p.securityValues}});b(e),f(!1)}catch(e){let t=e instanceof Error?e.message:String(e);g(t)}finally{s(null)}},E=async e=>{s(e.type),l(null);try{let t=await M.invoke(`stop_connector_channel`,{channel:e.type});b(t),_(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,R.jsx)(zt,{children:`cline connect`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{disabled:i,onClick:()=>void x(),size:`sm`,type:`button`,variant:`outline`,children:(0,R.jsx)(nt,{className:u(`size-4`,i&&`animate-spin`)})}),(0,R.jsxs)(A,{disabled:e.length===0,onClick:S,size:`sm`,type:`button`,children:[(0,R.jsx)(Oe,{className:`size-4`}),`Add Channel`]})]})}),c?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:c}):null,i?(0,R.jsx)(Et,{children:`Loading channels...`}):n.length===0?(0,R.jsx)(Et,{children:`No channels connected.`}):(0,R.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,R.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,R.jsxs)(`div`,{className:`grid gap-3 border bg-[color-mix(in_oklch,var(--background)_70%,var(--card))] p-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Ee,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,R.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:zn(t,e)}),(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Bn(t)})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.hubUrl,children:t.hubUrl}),t.baseUrl?(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.baseUrl,children:t.baseUrl}):null,(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Vn(t.startedAt)}),t.connectionMode?(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,R.jsxs)(A,{disabled:o===t.type,onClick:()=>_(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,R.jsx)(ye,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,R.jsx)(Le,{open:d,onOpenChange:f,children:(0,R.jsxs)(Ge,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:`Add Channel`}),(0,R.jsx)(Xe,{children:`Start a connector channel for Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:`Channel`}),(0,R.jsxs)(Ve,{onValueChange:t=>{t&&m({channelId:t,values:Gn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:p.channelId,children:[(0,R.jsx)(Ze,{children:(0,R.jsx)(et,{placeholder:`Select channel`})}),(0,R.jsx)(Be,{children:e.map(e=>(0,R.jsx)(Pe,{value:e.id,children:e.name},e.id))})]})]}),y.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(j,{children:[e.label,e.required?(0,R.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,R.jsxs)(Ve,{onValueChange:t=>{t&&C(e.flag,t)},value:p.values[e.flag]??e.initialValue??``,children:[(0,R.jsx)(Ze,{children:(0,R.jsx)(et,{placeholder:e.placeholder})}),(0,R.jsx)(Be,{children:e.options.map(e=>(0,R.jsx)(Pe,{value:e.value,children:e.label},e.value))})]}):Un(e)?(0,R.jsx)(Ye,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:p.values[e.flag]??``}):(0,R.jsx)(O,{onChange:t=>C(e.flag,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:p.values[e.flag]??``})]},e.flag)),v?.security?(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(j,{className:`text-sm`,children:`Restrict access`}),(0,R.jsx)(lt,{checked:p.securityEnabled,onCheckedChange:e=>m(t=>({...t,securityEnabled:e}))})]}),p.securityEnabled?v.security.fields.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:e.label}),(0,R.jsx)(O,{onChange:t=>w(e.key,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:p.securityValues[e.key]??``})]},e.key)):null]}):null,h?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:h}):null]}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,R.jsx)(A,{disabled:o!==null||!v,onClick:()=>void T(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,R.jsx)(It,{open:ee!==null,onOpenChange:e=>{e||_(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Remove Channel`}),(0,R.jsxs)(N,{children:[`Confirm that you want to stop the active`,` `,ee?zn(ee,e):`channel`,` `,`channel for `,ee?Bn(ee):``,`.`]})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:o!==null,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:o!==null||!ee,onClick:()=>{ee&&E(ee)},variant:`destructive`,children:`Remove`})]})]})})]})}function Jn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Yn(e){let t=Jn(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 Xn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function Zn(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Qn(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 $n(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Qn(e?.env),url:e?.url??``,headersText:Xn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function er(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(!1),[ee,_]=(0,L.useState)(`create`),[v,y]=(0,L.useState)(()=>$n()),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),w=(0,L.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),T=(0,L.useCallback)(async()=>{s(!0),f(null);try{let e=await M.invoke(`list_mcp_servers`);w(e)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{s(!1)}},[w]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{T()},0);return()=>window.clearTimeout(e)},[T]);let E=async(e,t)=>{m(e.name),f(null);try{let n=await M.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});w(n)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},te=async e=>{m(e.previousName??e.name),f(null);try{let t=await M.invoke(`upsert_mcp_server`,{input:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw f(t),e}finally{m(null)}},ne=async e=>{m(e),f(null);try{let t=await M.invoke(`delete_mcp_server`,{name:e});w(t)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},re=(0,L.useCallback)(e=>{let t=e.name.trim();if(!t)throw Error(`Server name is required.`);let n=e.envEntries.reduce((e,t)=>{let n=t.key.trim();return n&&(e[n]=t.value),e},{}),r=e.metadataText.trim(),i=r.length>0?JSON.parse(r):void 0;if(e.transportType===`stdio`){let r=e.command.trim();if(!r)throw Error(`Command is required for stdio transport.`);let a=Jn(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:Yn(e.headersText),disabled:e.disabled,metadata:i}},[]),D=()=>{_(`create`),y($n()),x(null),g(!0)},ie=e=>{_(`edit`),y($n(e)),x(null),g(!0)},ae=async()=>{x(null);try{let e=re(v);await te(e),g(!1)}catch(e){x(e instanceof Error?e.message:String(e))}},k=async()=>{l(!0),f(null);try{let e=await M.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},oe=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),se=(e,t,n)=>{y(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},ce=()=>{y(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},le=e=>{y(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:i?`Editing this list updates cline_mcp_settings.json.`:`No MCP settings file found yet. Add a server to create it.`,title:`MCP Servers`,meta:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(zt,{children:`cline config mcp`}),(0,R.jsx)(`span`,{className:`rounded-md border border-border bg-background px-2 py-0.5 text-xs text-muted-foreground`,children:`From settings file`})]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>void T(),disabled:o,children:(0,R.jsx)(nt,{className:u(`h-4 w-4`,o&&`animate-spin`)})}),(0,R.jsxs)(A,{size:`sm`,onClick:D,children:[(0,R.jsx)(Oe,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,R.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`MCP settings path:`}),(0,R.jsx)(A,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void k(),disabled:c,children:n||`Open settings file`})]}),d&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):oe.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:oe.map(e=>{let t=p===e.name;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Ee,{className:u(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ie(e),disabled:t,children:(0,R.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>C(e),disabled:t,children:(0,R.jsx)(ye,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(lt,{checked:!e.disabled,onCheckedChange:t=>E(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,Zn(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Xn(e.headers)]})]})]},e.name)})}),(0,R.jsx)(Le,{open:h,onOpenChange:e=>{g(e),e||x(null)},children:(0,R.jsxs)(Ge,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:ee===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,R.jsxs)(Xe,{children:[`Update the MCP server stored in`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-name`,children:`Server name`}),(0,R.jsx)(O,{id:`mcp-name`,value:v.name,onChange:e=>y(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{children:`Transport type`}),(0,R.jsxs)(Ve,{value:v.transportType,onValueChange:e=>y(t=>({...t,transportType:e})),children:[(0,R.jsx)(Ze,{className:`w-full`,children:(0,R.jsx)(et,{placeholder:`Select transport`})}),(0,R.jsxs)(Be,{children:[(0,R.jsx)(Pe,{value:`stdio`,children:`stdio`}),(0,R.jsx)(Pe,{value:`sse`,children:`sse`}),(0,R.jsx)(Pe,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),v.transportType===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(O,{id:`mcp-command`,value:v.command,onChange:e=>y(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-args`,children:`Args`}),(0,R.jsx)(Ye,{id:`mcp-args`,value:v.argsText,onChange:e=>y(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,R.jsx)(O,{id:`mcp-cwd`,value:v.cwd,onChange:e=>y(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(j,{children:`Environment variables`}),(0,R.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:ce,children:(0,R.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:v.envEntries.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>le(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,R.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(O,{value:e.key,onChange:t=>se(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,R.jsx)(O,{type:`password`,value:e.value,onChange:t=>se(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-url`,children:`Server URL`}),(0,R.jsx)(O,{id:`mcp-url`,value:v.url,onChange:e=>y(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-headers`,children:`Headers`}),(0,R.jsx)(Ye,{id:`mcp-headers`,value:v.headersText,onChange:e=>y(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(j,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,R.jsx)(Ye,{id:`mcp-metadata`,value:v.metadataText,onChange:e=>y(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,R.jsx)(lt,{checked:!v.disabled,onCheckedChange:e=>y(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),b?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null]}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{variant:`outline`,onClick:()=>g(!1),disabled:p!==null,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void ae(),disabled:p!==null,children:p===null?ee===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,R.jsx)(It,{open:S!==null,onOpenChange:e=>{e||C(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Delete MCP Server`}),(0,R.jsx)(N,{children:S?`Delete MCP server "${S.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:p!==null,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:p!==null||!S,onClick:()=>{S&&(ne(S.name),C(null))},children:`Delete`})]})]})})]})}function tr(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 nr(e){return e==null?``:String(e)}function rr(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 ir({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),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,R.jsx)(kt,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,m?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:u(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,m?`max-w-none`:`max-w-[42rem]`),children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,m?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,R.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,d,` `,`enabled`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,R.jsx)(A,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,R.jsx)(ct,{className:`size-4`})}),(0,R.jsxs)(A,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,R.jsx)(pn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,R.jsx)(`div`,{className:u(`mb-4`,m?`max-w-none`:`max-w-[42rem]`),children:(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,R.jsx)(ct,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(O,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>l(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,R.jsxs)(`div`,{className:u(`overflow-hidden`,m?`max-w-none`:`max-w-[42rem]`),children:[p.length===0?(0,R.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,p.map(e=>(0,R.jsxs)(`div`,{className:u(`flex min-h-11 items-center gap-4 border-b px-2 py-2 transition-colors hover:bg-accent/30`,i===e.id&&`bg-accent/45`),children:[(0,R.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`shrink-0 text-[15px] text-muted-foreground`,children:e.models===null?`Models load on demand`:`${e.models} model${e.models===1?``:`s`}`})]}),(0,R.jsx)(lt,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,R.jsx)(`button`,{"aria-label":`Configure ${e.name}`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:(0,R.jsx)(dn,{className:`size-4`})})]},e.id))]})]})})}function ar({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,d]=(0,L.useState)({}),[f,p]=(0,L.useState)(()=>tr(e)),[m,h]=(0,L.useState)(null),[g,ee]=(0,L.useState)(null),_=(0,L.useRef)(void 0),v=e.configFields??[],y=nr(f.apiKey),b=e.modelList??[],x=m?.providerId===e.id?m.value:``,S=g?.providerId===e.id?g.modelId:null,C=x.trim().toLowerCase(),w=C?b.filter(e=>e.name.toLowerCase().includes(C)||e.id.toLowerCase().includes(C)):b,T=c===`panel`;(0,L.useEffect)(()=>()=>{_.current!==void 0&&window.clearTimeout(_.current)},[]);let E=(e,t)=>{let r=rr(e,t),i={...f,[e.path]:r};p(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=nr(r)),e.path===`baseUrl`&&(a.baseUrl=nr(r)),n(a)},te=t=>{typeof navigator>`u`||!navigator.clipboard?.writeText||navigator.clipboard.writeText(t).then(()=>{ee({modelId:t,providerId:e.id}),_.current!==void 0&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>ee(null),1600)})};return(0,R.jsx)(kt,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:u(`py-10 max-[720px]:px-4 max-[720px]:py-5`,T?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,R.jsx)(A,{"aria-label":T?`Close provider details`:`Back to providers`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,onClick:t,variant:`ghost`,children:T?(0,R.jsx)(Ue,{className:`h-4 w-4`}):(0,R.jsx)(ln,{className:`h-4 w-4`})}),(0,R.jsx)(`h1`,{className:u(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,T?`text-[24px]`:`text-[32px]`),children:e.name})]}),v.length>0?(0,R.jsx)(`section`,{className:u(`mb-8`,T?`max-w-none`:`max-w-[86rem]`),children:(0,R.jsx)(`div`,{className:`flex flex-col`,children:v.map(e=>{let t=f[e.path],n=nr(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,R.jsxs)(`div`,{className:`grid min-h-18 grid-cols-[minmax(12rem,0.55fr)_minmax(16rem,0.45fr)] items-center gap-6 border-b py-4 max-[900px]:grid-cols-1 max-[900px]:gap-3`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,R.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,R.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,R.jsx)(lt,{checked:!!t,onCheckedChange:t=>E(e,t)})]}):e.type===`select`?(0,R.jsxs)(`select`,{className:`h-9 w-full rounded border border-border bg-background px-3 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,onChange:t=>E(e,t.target.value),value:n,children:[(0,R.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,R.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,R.jsx)(dt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,R.jsx)(O,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>E(e,n),onChange:t=>p(n=>({...n,[e.path]:t.target.value})),placeholder:e.placeholder,spellCheck:!1,type:r&&!i?`password`:e.type===`number`?`number`:e.type===`url`?`url`:`text`,value:n}),r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{"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,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(A,{"aria-label":`Copy ${e.label}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>navigator.clipboard.writeText(n),variant:`ghost`,children:(0,R.jsx)(je,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!y&&!e.oauthAccessTokenPresent&&o?(0,R.jsx)(`div`,{className:`mb-8`,children:(0,R.jsxs)(A,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,R.jsx)(at,{className:`h-4 w-4 animate-spin`}):null,(0,R.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,R.jsx)(`p`,{className:`mb-8 text-xs text-muted-foreground`,children:`OAuth is connected. Manual credentials remain available when this provider supports them.`}):null,(0,R.jsxs)(`section`,{className:u(`overflow-hidden rounded-lg border`,T?`max-w-none`:`max-w-[46rem]`),children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,R.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(ct,{className:`size-4 text-muted-foreground`}),(0,R.jsx)(A,{"aria-label":`Refresh models`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,disabled:i,onClick:r,variant:`ghost`,children:(0,R.jsx)(nt,{className:u(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,R.jsx)(ct,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(O,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,R.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,R.jsxs)(`div`,{className:`group flex min-h-16 items-center gap-3 border-b px-4 py-3 transition-colors hover:bg-accent/30`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,R.jsx)(`div`,{title:`File Support`,children:(0,R.jsx)(_n,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,R.jsx)(`div`,{title:`Image Support`,children:(0,R.jsx)(ke,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,R.jsxs)(`button`,{"aria-label":`Copy model ID ${e.id}`,className:`mt-1 flex max-w-full items-center gap-1.5 px-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>te(e.id),title:`Copy model ID`,type:`button`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,R.jsx)(je,{className:`size-3 shrink-0`}),S===e.id?(0,R.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,R.jsx)(A,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,R.jsx)(it,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var or,sr=Object.freeze({status:`aborted`});function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var cr=Symbol(`zod_brand`),lr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ur=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(or=globalThis).__zod_globalConfig??(or.__zod_globalConfig={});var dr=globalThis.__zod_globalConfig;function fr(e){return e&&Object.assign(dr,e),dr}var pr=t({BIGINT_FORMAT_RANGES:()=>Yr,Class:()=>vi,NUMBER_FORMAT_RANGES:()=>Jr,aborted:()=>ri,allowsEval:()=>Lr,assert:()=>vr,assertEqual:()=>mr,assertIs:()=>gr,assertNever:()=>_r,assertNotEqual:()=>hr,assignProp:()=>Dr,base64ToUint8Array:()=>fi,base64urlToUint8Array:()=>mi,cached:()=>xr,captureStackTrace:()=>Fr,cleanEnum:()=>di,cleanRegex:()=>Cr,clone:()=>Gr,cloneDef:()=>kr,createTransparentProxy:()=>Kr,defineLazy:()=>V,esc:()=>Nr,escapeRegex:()=>Wr,explicitlyAborted:()=>ii,extend:()=>Qr,finalizeIssue:()=>si,floatSafeRemainder:()=>wr,getElementAtPath:()=>Ar,getEnumValues:()=>yr,getLengthableOrigin:()=>li,getParsedType:()=>Vr,getSizableOrigin:()=>ci,hexToUint8Array:()=>gi,isObject:()=>Ir,isPlainObject:()=>Rr,issue:()=>ui,joinValues:()=>B,jsonStringifyReplacer:()=>br,merge:()=>ei,mergeDefs:()=>Or,normalizeParams:()=>H,nullish:()=>Sr,numKeys:()=>Br,objectClone:()=>Er,omit:()=>Zr,optionalKeys:()=>qr,parsedType:()=>W,partial:()=>ti,pick:()=>Xr,prefixIssues:()=>ai,primitiveTypes:()=>Ur,promiseAllObject:()=>jr,propertyKeyTypes:()=>Hr,randomString:()=>Mr,required:()=>ni,safeExtend:()=>$r,shallowClone:()=>zr,slugify:()=>Pr,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>pi,uint8ArrayToBase64url:()=>hi,uint8ArrayToHex:()=>_i,unwrapMessage:()=>oi});function mr(e){return e}function hr(e){return e}function gr(e){}function _r(e){throw Error(`Unexpected value in exhaustive check`)}function vr(e){}function yr(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function B(e,t=`|`){return e.map(e=>U(e)).join(t)}function br(e,t){return typeof t==`bigint`?t.toString():t}function xr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Sr(e){return e==null}function Cr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wr(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Tr=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Tr)return r===void 0&&(r=Tr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Er(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Dr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Or(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function kr(e){return Or(e._zod.def)}function Ar(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function jr(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function Mr(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Nr(e){return JSON.stringify(e)}function Pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Fr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ir(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Lr=xr(()=>{if(dr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Rr(e){if(Ir(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Ir(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function zr(e){return Rr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Br(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Vr=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Hr=new Set([`string`,`number`,`symbol`]),Ur=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Kr(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function U(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function qr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Jr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Yr={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Xr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Dr(this,`shape`,e),e},checks:[]}))}function Zr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Dr(this,`shape`,r),r},checks:[]}))}function Qr(e,t){if(!Rr(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function $r(e,t){if(!Rr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function ei(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Dr(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ti(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Dr(this,`shape`,i),i},checks:[]}))}function ni(e,t,n){return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Dr(this,`shape`,i),i}}))}function ri(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ii(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ai(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function oi(e){return typeof e==`string`?e:e?.message}function si(e,t,n){let r=e.message?e.message:oi(e.inst?._zod.def?.error?.(e))??oi(t?.error?.(e))??oi(n.customError?.(e))??oi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ci(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function li(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function W(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function ui(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function di(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function fi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function pi(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function mi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return fi(t+`=`.repeat((4-t.length%4)%4))}function hi(e){return pi(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function gi(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function _i(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var vi=class{constructor(...e){}},yi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,br,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bi=z(`$ZodError`,yi),xi=z(`$ZodError`,yi,{Parent:Error});function Si(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ci(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function wi(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if(s.code===`invalid_key`)r({issues:s.issues},[...i,...s.path]);else if(s.code===`invalid_element`)r({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function Ti(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ei(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Ti(e.path)}`);return t.join(`
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{a as n,i as r,r as i}from"./bundle-mjs-CO994-RQ.js";import{A as a,C as o,D as s,E as c,F as l,M as u,N as d,O as f,P as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as ee,f as b,g as x,h as te,i as S,j as C,k as w,l as ne,n as T,p as re,r as ie,s as ae,t as E,u as D,v as O,w as oe,x as se,y as ce}from"./label-B4VTGFzI.js";import{a as k,i as le,n as ue,o as de,r as fe,t as pe}from"./switch-DeaHMo5o.js";import{a as me,i as he,n as ge,r as _e,t as A}from"./desktop-client-bYADwT3y.js";import{$ as ve,At as j,B as ye,Bn as be,C as xe,Cn as Se,Dn as Ce,Dt as we,En as Te,Et as Ee,F as De,Ft as Oe,G as ke,Gn as Ae,Gt as M,H as je,Ht as Me,I as Ne,In as Pe,It as Fe,J as Ie,Jn as Le,K as N,Kn as Re,Kt as P,L as ze,Ln as Be,Lt as Ve,M as He,Mn as Ue,Mt as We,N as Ge,Nn as Ke,Nt as qe,On as Je,Ot as Ye,Pn as Xe,Pt as Ze,Qt as Qe,R as $e,Rn as et,S as tt,T as nt,Tn as rt,Tt as it,U as at,Un as ot,Ut as st,V as ct,Vn as lt,W as ut,Wn as dt,Wt as ft,X as pt,Xt as mt,Yt as ht,Zt as gt,_ as _t,_n as vt,_t as yt,a as bt,an as xt,b as St,bn as Ct,bt as F,c as wt,cn as Tt,en as Et,fn as Dt,ft as Ot,g as kt,gn as At,i as jt,in as Mt,it as Nt,j as Pt,jt as Ft,kt as It,l as Lt,ln as Rt,mn as zt,nn as Bt,o as Vt,pn as Ht,pt as Ut,qn as Wt,qt as Gt,r as Kt,s as qt,sn as Jt,tn as Yt,u as I,ut as Xt,v as Zt,vt as Qt,w as $t,wn as en,wt as tn,x as nn,xn as rn,y as an,yn as on,z as sn,zt as cn}from"./index-Cw6Kg0MD.js";var ln=F(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),un=F(`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`}]]),dn=F(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),fn=F(`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`}]]),pn=F(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),mn=F(`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`}]]),hn=F(`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`}]]),gn=F(`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`}]]),_n=F(`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`}]]),vn=F(`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`}]]),yn=F(`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`}]]),bn=F(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),xn=F(`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=F(`receipt`,[[`path`,{d:`M12 17V7`,key:`pyj7ub`}],[`path`,{d:`M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8`,key:`1elt7d`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]),L=e(n(),1),Cn=L.createContext({disabled:!1});function wn(){return L.useContext(Cn)}var Tn=L.createContext(void 0);function En(e=!0){let t=L.useContext(Tn);if(t===void 0&&!e)throw Error(Re(3));return t}var R=i();function Dn(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 On(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 kn(){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchMe`})}async function An(){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchBalance`})}async function jn(){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUserOrganizations`})}async function Mn(e){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationBalance`,organizationId:e})}async function Nn(){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchUsageTransactions`})}async function Pn(e,t){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchOrganizationUsageTransactions`,organizationId:e,...t?.trim()?{memberId:t.trim()}:{}})}async function Fn(){return await A.invoke(`cline_account`,{action:`clineAccount`,operation:`fetchPaymentTransactions`})}function In(){let[e,t]=(0,L.useState)(`overview`),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)([]),[p,m]=(0,L.useState)(!0),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)([]),[y,ee]=(0,L.useState)(!1),[b,x]=(0,L.useState)(null),[te,S]=(0,L.useState)(!1),C=(0,L.useRef)(0),[w,ne]=(0,L.useState)([]),[T,re]=(0,L.useState)(!1),[ie,ae]=(0,L.useState)(null),[E,D]=(0,L.useState)(!1),O=d.find(e=>e.active)??null,oe=(0,L.useCallback)(()=>{a(null),s(null),l(null),f([]),v([]),S(!1),x(null),ne([]),D(!1),ae(null)},[]),se=(0,L.useCallback)(async()=>{m(!0),g(null);try{let[e,t,n]=await Promise.all([kn(),An(),jn()]),r=n.find(e=>e.active)??null,i=r?await Mn(r.organizationId):null;a(e),s(t),l(i),f(n)}catch(e){oe();let t=Dn(e).message;g(t)}finally{m(!1)}},[oe]);(0,L.useEffect)(()=>{se()},[se]);let ce=async()=>{r(`sign-in`),g(null);try{await A.invoke(`run_provider_oauth_login`,{provider:`cline`}),await se(),t(`overview`)}catch(e){let t=Dn(e).message;g(t),oe()}finally{r(null)}},le=async()=>{r(`sign-out`);try{await A.invoke(`save_provider_settings`,{provider:`cline`,api_key:``,settings:{auth:{accessToken:``,refreshToken:``,accountId:``}}}),oe(),t(`overview`),g(`No Cline account auth token found`)}catch(e){let t=Dn(e).message;g(t)}finally{r(null)}},ue=(0,L.useCallback)(async()=>{let e=C.current;ee(!0),x(null);try{let t=O?await Pn(O.organizationId,O.memberId):await Nn();if(C.current!==e)return;v(t),S(!0)}catch(t){if(C.current!==e)return;let n=Dn(t).message;x(n)}finally{C.current===e&&ee(!1)}},[O]);(0,L.useEffect)(()=>{C.current+=1,v([]),S(!1),x(null)},[O?.organizationId]),(0,L.useEffect)(()=>{e===`usage`&&!te&&ue()},[e,te,ue]);let de=(0,L.useCallback)(async()=>{re(!0),ae(null);try{let e=await Fn();ne(e),D(!0)}catch(e){let t=Dn(e).message;ae(t)}finally{re(!1)}},[]);(0,L.useEffect)(()=>{e===`billing`&&!E&&de()},[e,E,de]);let fe=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),pe=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`}),ge=(e,t=2)=>new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e/1e6),_e=O?c?.balance??o?.balance??null:o?.balance??null,ve=[`overview`,`usage`,`billing`],j=(e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-12 text-center`,children:[(0,R.jsx)(fn,{className:`h-8 w-8 text-destructive`}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:e}),(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 rounded-lg border border-border px-3.5 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(he,{className:`h-4 w-4`}),`Retry`]})]}),ye=()=>(0,R.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-6`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-xl flex-col items-center gap-4 py-8 text-center`,children:[(0,R.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,R.jsx)(yt,{className:`h-6 w-6`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:`Sign in to Cline`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Connect your Cline account to review credits, usage, billing, and organization details from Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,R.jsxs)(N,{disabled:n!==null,onClick:()=>void ce(),type:`button`,children:[n===`sign-in`?(0,R.jsx)(k,{className:`h-4 w-4 animate-spin`}):(0,R.jsx)(vn,{className:`h-4 w-4`}),n===`sign-in`?`Signing in`:`Sign in`]}),(0,R.jsxs)(`a`,{className:`inline-flex h-9 items-center gap-2 rounded-lg border border-border px-3.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,href:`https://app.cline.bot`,rel:`noopener noreferrer`,target:`_blank`,children:[`Create account`,(0,R.jsx)(me,{className:`h-4 w-4`})]})]})]})}),be=()=>(0,R.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,R.jsx)(k,{className:`h-6 w-6 animate-spin text-muted-foreground`})});return(0,R.jsxs)(wt,{children:[(0,R.jsx)(Lt,{description:`Review account, usage, billing, and organization details.`,title:`Account`}),(0,R.jsx)(`div`,{className:`mb-6 flex items-center gap-0 border-b border-border`,children:ve.map(n=>{let r=!i&&n!==`overview`;return(0,R.jsxs)(`button`,{disabled:r,type:`button`,onClick:()=>t(n),className:tn(`relative px-4 py-2.5 text-sm font-medium capitalize transition-colors`,e===n?`text-foreground`:`text-muted-foreground hover:text-foreground`,r&&`cursor-not-allowed opacity-45 hover:text-muted-foreground`),children:[n,e===n&&(0,R.jsx)(`span`,{className:`absolute inset-x-0 -bottom-px h-0.5 bg-foreground`})]},n)})}),e===`overview`&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p&&be(),h&&(On(h)?ye():j(h,se)),!p&&!h&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`rounded-lg border border-border p-5`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`div`,{className:`flex h-16 w-16 shrink-0 items-center justify-center rounded-full bg-primary/20 text-2xl font-bold text-primary`,children:i.displayName?.charAt(0)??i.email?.charAt(0)??`?`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:i.displayName||i.email}),(0,R.jsx)(`p`,{className:`mt-0.5 text-sm text-muted-foreground`,children:i.email}),(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Member since `,fe(i.createdAt)]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[`Open dashboard`,(0,R.jsx)(me,{className:`h-3.5 w-3.5`})]}),(0,R.jsxs)(N,{className:`h-8 rounded-md px-2.5 text-xs`,disabled:n!==null,onClick:()=>void le(),type:`button`,variant:`outline`,children:[n===`sign-out`?(0,R.jsx)(k,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(yn,{className:`h-3.5 w-3.5`}),n===`sign-out`?`Signing out`:`Sign out`]})]})]})}),_e!==null&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(mn,{className:`h-5 w-5 text-primary`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:O?`${O.name} Balance`:`Credits Balance`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/dashboard/organization?tab=credits&redirect=true`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(u,{className:`h-3.5 w-3.5`}),`Credit`]})]}),(0,R.jsx)(`div`,{className:`flex items-baseline gap-2`,children:(0,R.jsxs)(`span`,{className:`text-3xl font-bold text-foreground`,children:[`$`,ge(_e)]})}),O&&o&&(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Personal account: `,ge(o.balance),` `,`credits`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(un,{className:`h-5 w-5 text-muted-foreground`}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Organizations`})]}),(0,R.jsxs)(`a`,{href:`https://app.cline.bot/onboarding?step=1`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:[(0,R.jsx)(u,{className:`h-3.5 w-3.5`}),`Create`]})]}),d.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No organizations yet.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border px-4 py-3 transition-colors hover:bg-accent/20`,children:[(0,R.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-secondary text-sm font-bold text-foreground`,children:e.name.charAt(0)}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground capitalize`,children:e.roles.join(`, `)})]}),e.active&&(0,R.jsx)(`span`,{className:`rounded-full bg-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]},e.organizationId))})]})]})]}),e===`usage`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:O?`Recent API usage and token consumption for ${O.name}.`:`Recent API usage and token consumption across all providers.`}),y&&be(),b&&j(b,ue),!y&&!b&&te&&(_.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No usage transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Model`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Time`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:_.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`font-medium text-foreground truncate`,children:e.aiModelName}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.aiInferenceProviderName})]}),(0,R.jsx)(`div`,{className:`text-right text-muted-foreground`,children:e.totalTokens.toLocaleString()}),(0,R.jsx)(`div`,{className:`text-right text-foreground font-medium`,children:ge(e.creditsUsed)}),(0,R.jsxs)(`div`,{className:`text-right text-xs text-muted-foreground`,children:[(0,R.jsx)(`p`,{children:fe(e.createdAt)}),(0,R.jsx)(`p`,{children:pe(e.createdAt)})]})]},e.id))})]}))]}),e===`billing`&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-6 text-sm text-muted-foreground`,children:`Payment history and credit purchases.`}),T&&be(),ie&&j(ie,de),!T&&!ie&&E&&(w.length===0?(0,R.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No payment transactions yet.`}):(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-secondary/50 px-4 py-2.5 text-xs font-medium text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`Date`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Amount`}),(0,R.jsx)(`span`,{className:`text-right`,children:`Credits`})]}),(0,R.jsx)(`div`,{className:`divide-y divide-border`,children:w.map(e=>(0,R.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] gap-4 px-4 py-3 text-sm transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Sn,{className:`h-4 w-4 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`text-foreground`,children:fe(e.paidAt)})]}),(0,R.jsxs)(`div`,{className:`text-right text-foreground font-medium`,children:[`$`,(e.amountCents/100).toFixed(2)]}),(0,R.jsxs)(`div`,{className:`text-right text-primary font-medium`,children:[`+`,ge(e.credits)]})]},`${e.paidAt}-${e.amountCents}-${e.credits}`))})]}))]})]})}var Ln=[`streaming`,`tools`,`reasoning`,`vision`,`prompt-cache`];function Rn({onBack:e,onSave:t,existingProviderIds:n}){let[r,i]=(0,L.useState)({providerId:``,name:``,models:[],defaultModel:``,apiKey:``,baseUrl:``,modelsSourceUrl:``,headers:{},timeoutMs:``,capabilities:[`streaming`,`tools`]}),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(null),_=(0,L.useMemo)(()=>r.providerId.trim().toLowerCase().replace(/\s+/g,`-`),[r.providerId]),v=n.includes(_),y=r.models.length>0,ee=r.modelsSourceUrl.trim().length>0,b=_.length>0&&r.name.trim().length>0&&r.baseUrl.trim().length>0&&(y||ee)&&!v,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)}))},te=e=>{i(t=>{let n=t.models.filter(t=>t!==e);return{...t,models:n,defaultModel:t.defaultModel===e?n[0]??``:t.defaultModel}})},S=e=>{i(t=>({...t,capabilities:t.capabilities.includes(e)?t.capabilities.filter(t=>t!==e):[...t.capabilities,e]}))},w=()=>{i(e=>({...e,headers:{...e.headers,"":``}}))},ne=(e,t,n)=>{let a=Object.entries(r.headers),o={};a.forEach(([e,r],i)=>{o[i===n?t:e]=r}),e!==t&&delete o[e],i(e=>({...e,headers:o}))},T=(e,t)=>{i(n=>({...n,headers:{...n.headers,[e]:t}}))},re=e=>{let t={...r.headers};delete t[e],i(e=>({...e,headers:t}))},ie=async()=>{if(!(!b||p)){m(!0),g(null);try{await t({providerId:_,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){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}};return(0,R.jsxs)(wt,{contentClassName:`max-w-4xl`,children:[(0,R.jsx)(Lt,{description:`Add an OpenAI-compatible provider and choose its available models.`,title:`Add Provider`,actions:(0,R.jsxs)(N,{onClick:e,variant:`secondary`,className:`rounded-md p-1.5 transition-colors`,"aria-label":`Back to providers`,children:[(0,R.jsx)(ln,{className:`h-4 w-4`}),`Providers`]})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-foreground`,children:`OpenAI-Compatible Provider`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider ID`}),(0,R.jsx)(`input`,{type:`text`,value:r.providerId,onChange:e=>i(t=>({...t,providerId:e.target.value})),placeholder:`my-provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Lowercase ID used in provider registry.`}),v?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:`This provider ID already exists.`}):null]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Provider Name`}),(0,R.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`My Provider`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Base URL`}),(0,R.jsx)(`input`,{type:`url`,value:r.baseUrl,onChange:e=>i(t=>({...t,baseUrl:e.target.value})),placeholder:`https://api.example.com/v1`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Model Source URL (Optional)`}),(0,R.jsx)(`input`,{type:`url`,value:r.modelsSourceUrl,onChange:e=>i(t=>({...t,modelsSourceUrl:e.target.value})),placeholder:`https://api.example.com/v1/models`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:"Supported JSON: OpenAI `/models` shape with a `data` array, or a direct model array."})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex min-h-11 flex-wrap content-start gap-1.5 rounded-lg border border-border bg-input px-3 py-2 focus-within:ring-1 focus-within:ring-ring`,children:[r.models.map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-1 text-xs font-medium text-primary`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:e}),(0,R.jsx)(N,{onClick:()=>te(e),className:`text-primary/60 hover:text-primary transition-colors`,"aria-label":`Remove ${e}`,children:(0,R.jsx)(C,{className:`h-3 w-3`})})]},e)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:x,placeholder:r.models.length===0?`Type model ID and press Enter`:``,className:`min-w-35 flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none`})]}),(0,R.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Add at least one model or set a Model Source URL.`})]}),r.models.length>1?(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Default Model`}),(0,R.jsx)(`select`,{value:r.defaultModel,onChange:e=>i(t=>({...t,defaultModel:e.target.value})),className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,children:r.models.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`API Key (Optional)`}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`input`,{type:s?`text`:`password`,value:r.apiKey,onChange:e=>i(t=>({...t,apiKey:e.target.value})),placeholder:`sk-...`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 pr-20 font-mono text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1`,children:[(0,R.jsx)(N,{onClick:()=>c(!s),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":s?`Hide API key`:`Show API key`,children:s?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(N,{onClick:()=>navigator.clipboard.writeText(r.apiKey),variant:`ghost`,className:`rounded-md p-1 transition-colors`,"aria-label":`Copy API key`,children:(0,R.jsx)(de,{className:`h-4 w-4`})})]})]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border p-5`,children:[(0,R.jsx)(E,{className:`mb-3 block text-xs font-medium text-muted-foreground`,children:`Capabilities`}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Ln.map(e=>(0,R.jsx)(N,{onClick:()=>S(e),className:tn(`rounded-lg border px-3 py-1.5 text-xs font-medium transition-all`,r.capabilities.includes(e)?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-card text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:e.replace(/-/g,` `)},e))})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border border-border overflow-hidden`,children:[(0,R.jsxs)(N,{onClick:()=>f(!d),className:`flex w-full items-center justify-between px-5 py-4 text-sm font-medium transition-colors text-foreground/40`,variant:`ghost`,children:[`Advanced Settings`,(0,R.jsx)(l,{className:tn(`h-4 w-4 text-muted-foreground transition-transform`,d&&`rotate-180`)})]}),d?(0,R.jsxs)(`div`,{className:`border-t border-border px-5 py-5 flex flex-col gap-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Timeout (ms)`}),(0,R.jsx)(`input`,{type:`number`,value:r.timeoutMs,onChange:e=>i(t=>({...t,timeoutMs:e.target.value})),placeholder:`30000`,className:`w-full rounded-lg border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{className:`mb-2 block text-xs font-medium text-muted-foreground`,children:`Custom Headers`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Object.entries(r.headers).map(([e,t],n)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,value:e,onChange:t=>ne(e,t.target.value,n),placeholder:`Header name`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(`input`,{type:`text`,value:t,onChange:t=>T(e,t.target.value),placeholder:`Value`,className:`flex-1 rounded-lg border border-border bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring`}),(0,R.jsx)(N,{onClick:()=>re(e),className:`rounded-md p-2 text-muted-foreground hover:text-destructive transition-colors`,"aria-label":`Remove header`,children:(0,R.jsx)(Xt,{className:`h-4 w-4`})})]},e)),(0,R.jsxs)(N,{onClick:w,className:`flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,R.jsx)(u,{className:`h-3 w-3`}),`Add Header`]})]})]})]}):null]}),h?(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:h}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3 pt-2`,children:[(0,R.jsx)(N,{onClick:e,className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,children:`Cancel`}),(0,R.jsx)(N,{onClick:()=>void ie(),disabled:!b||p,className:tn(`rounded-lg px-4 py-2 text-sm font-medium transition-colors`,b&&!p?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-muted text-muted-foreground cursor-not-allowed`),children:p?`Saving...`:`Add Provider`})]})]})]})}function zn(e,t){return t.find(t=>t.id===e.type)?.name??e.type}function Bn(e){return e.botUsername?`@${e.botUsername}`:e.userName?e.userName:e.applicationId?e.applicationId:`pid ${e.pid}`}function Vn(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Hn(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 Un(e){return e.label.toLowerCase().includes(`json`)||e.flag.includes(`credentials`)}function Wn(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 Gn(e){let t={};for(let n of e?.fields??[])n.initialValue&&(t[n.flag]=n.initialValue);return t}function Kn(e){let t=e[0];return{channelId:t?.id??``,values:Gn(t),securityEnabled:!1,securityValues:{}}}function qn(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)([]),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[d,f]=(0,L.useState)(!1),[m,h]=(0,L.useState)({channelId:``,values:{},securityEnabled:!1,securityValues:{}}),[_,v]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),w=(0,L.useMemo)(()=>e.find(e=>e.id===m.channelId),[e,m.channelId]),T=(0,L.useMemo)(()=>{let e={...Gn(w),...m.values};return(w?.fields??[]).filter(t=>Wn(t,e))},[w,m.values]),ie=(0,L.useCallback)(e=>{t(e.available),r(e.active),h(t=>t.channelId?t:Kn(e.available))},[]),oe=(0,L.useCallback)(async()=>{a(!0),l(null);try{let e=await A.invoke(`list_connector_channels`);ie(e)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{a(!1)}},[ie]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{oe()},0);return()=>window.clearTimeout(e)},[oe]);let se=()=>{h(Kn(e)),v(null),f(!0)},k=(e,t)=>{h(n=>({...n,values:{...n.values,[e]:t}}))},le=(e,t)=>{h(n=>({...n,securityValues:{...n.securityValues,[e]:t}}))},ue=async()=>{if(!w){v(`Choose a channel`);return}for(let e of w.fields)if(T.includes(e)&&e.required&&!m.values[e.flag]?.trim()){v(`${e.label} is required`);return}if(m.securityEnabled&&w.security){for(let e of w.security.fields)if(!m.securityValues[e.key]?.trim()){v(e.requiredMessage);return}}s(w.id),v(null),l(null);try{let e=await A.invoke(`start_connector_channel`,{channel:w.id,values:m.values,security:{enabled:m.securityEnabled,values:m.securityValues}});ie(e),f(!1)}catch(e){let t=e instanceof Error?e.message:String(e);v(t)}finally{s(null)}},de=async e=>{s(e.type),l(null);try{let t=await A.invoke(`stop_connector_channel`,{channel:e.type});ie(t),C(null)}catch(e){let t=e instanceof Error?e.message:String(e);l(t)}finally{s(null)}};return(0,R.jsxs)(wt,{children:[(0,R.jsx)(Lt,{description:`${n.length} connected. Start and manage connector channels for Cline Hub.`,title:`Channels`,meta:(0,R.jsx)(Vt,{children:`cline connect`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{disabled:i,onClick:()=>void oe(),size:`sm`,type:`button`,variant:`outline`,children:(0,R.jsx)(he,{className:tn(`size-4`,i&&`animate-spin`)})}),(0,R.jsxs)(N,{disabled:e.length===0,onClick:se,size:`sm`,type:`button`,children:[(0,R.jsx)(u,{className:`size-4`}),`Add Channel`]})]})}),c?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:c}):null,i?(0,R.jsx)(qt,{children:`Loading channels...`}):n.length===0?(0,R.jsx)(qt,{children:`No channels connected.`}):(0,R.jsx)(`section`,{className:`overflow-hidden rounded-lg border bg-card`,children:(0,R.jsx)(`div`,{className:`grid gap-2 p-2.5`,children:n.map(t=>(0,R.jsxs)(`div`,{className:`grid gap-3 border bg-[color-mix(in_oklch,var(--background)_70%,var(--card))] p-3 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(p,{className:`size-2 fill-emerald-300 text-emerald-300`}),(0,R.jsx)(`p`,{className:`truncate text-[13px] font-semibold leading-tight`,children:zn(t,e)}),(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:Bn(t)})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:[`pid=`,t.pid]}),(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.hubUrl,children:t.hubUrl}),t.baseUrl?(0,R.jsx)(`span`,{className:`max-w-full break-all rounded-md border bg-background px-1.5 py-0.5`,title:t.baseUrl,children:t.baseUrl}):null,(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:Vn(t.startedAt)}),t.connectionMode?(0,R.jsx)(`span`,{className:`rounded-md border bg-background px-1.5 py-0.5`,children:t.connectionMode}):null]})]}),(0,R.jsxs)(N,{disabled:o===t.type,onClick:()=>C(t),size:`sm`,type:`button`,variant:`outline`,children:[(0,R.jsx)(Xt,{className:`size-4`}),`Remove...`]})]},t.id))})}),(0,R.jsx)(y,{open:d,onOpenChange:f,children:(0,R.jsxs)(ne,{className:`max-h-[86vh] overflow-y-auto sm:max-w-xl`,children:[(0,R.jsxs)(b,{children:[(0,R.jsx)(re,{children:`Add Channel`}),(0,R.jsx)(D,{children:`Start a connector channel for Cline Hub.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 py-2`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{children:`Channel`}),(0,R.jsxs)(te,{onValueChange:t=>{t&&h({channelId:t,values:Gn(e.find(e=>e.id===t)),securityEnabled:!1,securityValues:{}})},value:m.channelId,children:[(0,R.jsx)(O,{children:(0,R.jsx)(ce,{placeholder:`Select channel`})}),(0,R.jsx)(x,{children:e.map(e=>(0,R.jsx)(g,{value:e.id,children:e.name},e.id))})]})]}),T.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(E,{children:[e.label,e.required?(0,R.jsx)(`span`,{className:`text-destructive`,children:` *`}):null]}),e.options?(0,R.jsxs)(te,{onValueChange:t=>{t&&k(e.flag,t)},value:m.values[e.flag]??e.initialValue??``,children:[(0,R.jsx)(O,{children:(0,R.jsx)(ce,{placeholder:e.placeholder})}),(0,R.jsx)(x,{children:e.options.map(e=>(0,R.jsx)(g,{value:e.value,children:e.label},e.value))})]}):Un(e)?(0,R.jsx)(ae,{onChange:t=>k(e.flag,t.target.value),placeholder:e.placeholder,rows:5,value:m.values[e.flag]??``}):(0,R.jsx)(kt,{onChange:t=>k(e.flag,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:m.values[e.flag]??``})]},e.flag)),w?.security?(0,R.jsxs)(`div`,{className:`grid gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(E,{className:`text-sm`,children:`Restrict access`}),(0,R.jsx)(pe,{checked:m.securityEnabled,onCheckedChange:e=>h(t=>({...t,securityEnabled:e}))})]}),m.securityEnabled?w.security.fields.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{children:e.label}),(0,R.jsx)(kt,{onChange:t=>le(e.key,t.target.value),placeholder:e.placeholder,type:Hn(e)?`password`:`text`,value:m.securityValues[e.key]??``})]},e.key)):null]}):null,_?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:_}):null]}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(N,{disabled:o!==null,onClick:()=>f(!1),type:`button`,variant:`outline`,children:`Cancel`}),(0,R.jsx)(N,{disabled:o!==null||!w,onClick:()=>void ue(),type:`button`,children:o?`Starting...`:`Add Channel`})]})]})}),(0,R.jsx)($e,{open:S!==null,onOpenChange:e=>{e||C(null)},children:(0,R.jsxs)(ct,{children:[(0,R.jsxs)(ut,{children:[(0,R.jsx)(ke,{children:`Remove Channel`}),(0,R.jsxs)(je,{children:[`Confirm that you want to stop the active`,` `,S?zn(S,e):`channel`,` `,`channel for `,S?Bn(S):``,`.`]})]}),(0,R.jsxs)(at,{children:[(0,R.jsx)(ye,{disabled:o!==null,children:`Cancel`}),(0,R.jsx)(sn,{disabled:o!==null||!S,onClick:()=>{S&&de(S)},variant:`destructive`,children:`Remove`})]})]})})]})}function Jn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function Yn(e){let t=Jn(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 Xn(e){return e?Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`, `):``}function Zn(e){return e?Object.keys(e).map(e=>`${e}=[REDACTED]`).join(`, `):``}function Qn(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 $n(e){return{name:e?.name??``,previousName:e?.name??``,transportType:e?.transportType??`stdio`,command:e?.command??``,argsText:e?.args?.join(`, `)??``,cwd:e?.cwd??``,envEntries:Qn(e?.env),url:e?.url??``,headersText:Xn(e?.headers),disabled:e?.disabled??!1,metadataText:e?.metadata===void 0?``:JSON.stringify(e.metadata,null,2)}}function er(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[m,h]=(0,L.useState)(null),[_,v]=(0,L.useState)(!1),[S,C]=(0,L.useState)(`create`),[w,T]=(0,L.useState)(()=>$n()),[ie,oe]=(0,L.useState)(null),[se,k]=(0,L.useState)(null),le=(0,L.useCallback)(e=>{t(e.servers),r(e.settingsPath),a(e.hasSettingsFile)},[]),ue=(0,L.useCallback)(async()=>{s(!0),f(null);try{let e=await A.invoke(`list_mcp_servers`);le(e)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{s(!1)}},[le]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{ue()},0);return()=>window.clearTimeout(e)},[ue]);let de=async(e,t)=>{h(e.name),f(null);try{let n=await A.invoke(`set_mcp_server_disabled`,{name:e.name,disabled:t});le(n)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{h(null)}},fe=async e=>{h(e.previousName??e.name),f(null);try{let t=await A.invoke(`upsert_mcp_server`,{input:e});le(t)}catch(e){let t=e instanceof Error?e.message:String(e);throw f(t),e}finally{h(null)}},me=async e=>{h(e),f(null);try{let t=await A.invoke(`delete_mcp_server`,{name:e});le(t)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{h(null)}},ge=(0,L.useCallback)(e=>{let t=e.name.trim();if(!t)throw Error(`Server name is required.`);let n=e.envEntries.reduce((e,t)=>{let n=t.key.trim();return n&&(e[n]=t.value),e},{}),r=e.metadataText.trim(),i=r.length>0?JSON.parse(r):void 0;if(e.transportType===`stdio`){let r=e.command.trim();if(!r)throw Error(`Command is required for stdio transport.`);let a=Jn(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:Yn(e.headersText),disabled:e.disabled,metadata:i}},[]),_e=()=>{C(`create`),T($n()),oe(null),v(!0)},ve=e=>{C(`edit`),T($n(e)),oe(null),v(!0)},j=async()=>{oe(null);try{let e=ge(w);await fe(e),v(!1)}catch(e){oe(e instanceof Error?e.message:String(e))}},be=async()=>{l(!0),f(null);try{let e=await A.invoke(`open_mcp_settings_file`);e.trim().length>0&&(r(e),a(!0))}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},xe=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]),Se=(e,t,n)=>{T(r=>({...r,envEntries:r.envEntries.map(r=>r.id===e?{...r,[t]:n}:r)}))},Ce=()=>{T(e=>({...e,envEntries:[...e.envEntries,{id:crypto.randomUUID(),key:``,value:``}]}))},we=e=>{T(t=>({...t,envEntries:t.envEntries.length===1?[{id:crypto.randomUUID(),key:``,value:``}]:t.envEntries.filter(t=>t.id!==e)}))};return(0,R.jsxs)(wt,{children:[(0,R.jsx)(Lt,{description:i?`Editing this list updates cline_mcp_settings.json.`:`No MCP settings file found yet. Add a server to create it.`,title:`MCP Servers`,meta:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Vt,{children:`cline config mcp`}),(0,R.jsx)(`span`,{className:`rounded-md border border-border bg-background px-2 py-0.5 text-xs text-muted-foreground`,children:`From settings file`})]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void ue(),disabled:o,children:(0,R.jsx)(he,{className:tn(`h-4 w-4`,o&&`animate-spin`)})}),(0,R.jsxs)(N,{size:`sm`,onClick:_e,children:[(0,R.jsx)(u,{className:`h-4 w-4`}),`Add MCP Server`]})]})}),(0,R.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:`MCP settings path:`}),(0,R.jsx)(N,{variant:`link`,className:`h-auto p-0 font-mono text-xs`,onClick:()=>void be(),disabled:c,children:n||`Open settings file`})]}),d&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),o?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`Loading MCP servers...`}):xe.length===0?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-5 py-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:xe.map(e=>{let t=m===e.name;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(p,{className:tn(`h-2.5 w-2.5 shrink-0`,e.disabled?`fill-muted-foreground/40 text-muted-foreground/40`:`fill-primary text-primary`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.transportType}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>ve(e),disabled:t,children:(0,R.jsx)(Ot,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>k(e),disabled:t,children:(0,R.jsx)(Xt,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(pe,{checked:!e.disabled,onCheckedChange:t=>de(e,!t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[e.command&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Command:`}),` `,e.command]}),e.args&&e.args.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Args:`}),` `,e.args.join(`, `)]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),e.url&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`URL:`}),` `,e.url]}),e.env&&Object.keys(e.env).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Env:`}),` `,Zn(e.env)]}),e.headers&&Object.keys(e.headers).length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Headers:`}),` `,Xn(e.headers)]})]})]},e.name)})}),(0,R.jsx)(y,{open:_,onOpenChange:e=>{v(e),e||oe(null)},children:(0,R.jsxs)(ne,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(b,{children:[(0,R.jsx)(re,{children:S===`edit`?`Edit MCP Server`:`Add MCP Server`}),(0,R.jsxs)(D,{children:[`Update the MCP server stored in`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:n||`cline_mcp_settings.json`}),`.`]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4`,children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-name`,children:`Server name`}),(0,R.jsx)(kt,{id:`mcp-name`,value:w.name,onChange:e=>T(t=>({...t,name:e.target.value})),placeholder:`github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{children:`Transport type`}),(0,R.jsxs)(te,{value:w.transportType,onValueChange:e=>T(t=>({...t,transportType:e})),children:[(0,R.jsx)(O,{className:`w-full`,children:(0,R.jsx)(ce,{placeholder:`Select transport`})}),(0,R.jsxs)(x,{children:[(0,R.jsx)(g,{value:`stdio`,children:`stdio`}),(0,R.jsx)(g,{value:`sse`,children:`sse`}),(0,R.jsx)(g,{value:`streamableHttp`,children:`streamableHttp`})]})]})]}),w.transportType===`stdio`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(kt,{id:`mcp-command`,value:w.command,onChange:e=>T(t=>({...t,command:e.target.value})),placeholder:`npx`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-args`,children:`Args`}),(0,R.jsx)(ae,{id:`mcp-args`,value:w.argsText,onChange:e=>T(t=>({...t,argsText:e.target.value})),placeholder:`-y, @modelcontextprotocol/server-github`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-cwd`,children:`Working directory`}),(0,R.jsx)(kt,{id:`mcp-cwd`,value:w.cwd,onChange:e=>T(t=>({...t,cwd:e.target.value})),placeholder:`/path/to/project`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(E,{children:`Environment variables`}),(0,R.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:Ce,children:(0,R.jsx)(u,{className:`h-3.5 w-3.5`})})]}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:w.envEntries.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(N,{type:`button`,variant:`ghost`,size:`icon-sm`,onClick:()=>we(e.id),"aria-label":`Remove env var ${e.key||`row`}`,children:(0,R.jsx)(bn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(kt,{value:e.key,onChange:t=>Se(e.id,`key`,t.target.value),placeholder:`KEY`}),(0,R.jsx)(kt,{type:`password`,value:e.value,onChange:t=>Se(e.id,`value`,t.target.value),placeholder:`VALUE`})]},e.id))})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-url`,children:`Server URL`}),(0,R.jsx)(kt,{id:`mcp-url`,value:w.url,onChange:e=>T(t=>({...t,url:e.target.value})),placeholder:`https://example.com/mcp`})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-headers`,children:`Headers`}),(0,R.jsx)(ae,{id:`mcp-headers`,value:w.headersText,onChange:e=>T(t=>({...t,headersText:e.target.value})),placeholder:`Authorization=Bearer token`})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsx)(E,{htmlFor:`mcp-metadata`,children:`Metadata JSON`}),(0,R.jsx)(ae,{id:`mcp-metadata`,value:w.metadataText,onChange:e=>T(t=>({...t,metadataText:e.target.value})),placeholder:`{"key":"value"}`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Enabled`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Disable the server without removing it from settings.`})]}),(0,R.jsx)(pe,{checked:!w.disabled,onCheckedChange:e=>T(t=>({...t,disabled:!e})),"aria-label":`Enable MCP server`})]}),ie?(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:ie}):null]}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(N,{variant:`outline`,onClick:()=>v(!1),disabled:m!==null,children:`Cancel`}),(0,R.jsx)(N,{onClick:()=>void j(),disabled:m!==null,children:m===null?S===`edit`?`Save changes`:`Add server`:`Saving...`})]})]})}),(0,R.jsx)($e,{open:se!==null,onOpenChange:e=>{e||k(null)},children:(0,R.jsxs)(ct,{children:[(0,R.jsxs)(ut,{children:[(0,R.jsx)(ke,{children:`Delete MCP Server`}),(0,R.jsx)(je,{children:se?`Delete MCP server "${se.name}" from settings?`:`Delete this MCP server from settings?`})]}),(0,R.jsxs)(at,{children:[(0,R.jsx)(ye,{disabled:m!==null,children:`Cancel`}),(0,R.jsx)(sn,{disabled:m!==null||!se,onClick:()=>{se&&(me(se.name),k(null))},children:`Delete`})]})]})})]})}function tr(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 nr(e){return e==null?``:String(e)}function rr(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 ir({providers:e,onToggle:t,onConfigure:n,onAddProvider:r,selectedProviderId:i,variant:a=`page`}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),u=e.filter(e=>e.enabled).length,d=c.trim().toLowerCase(),f=d?e.filter(e=>e.name.toLowerCase().includes(d)):e,p=a===`panel`;return(0,R.jsx)(I,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:tn(`py-10 max-[720px]:px-4 max-[720px]:py-5`,p?`px-8`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:tn(`mb-8 flex items-start justify-between gap-6 max-[860px]:flex-col max-[860px]:items-stretch`,p?`max-w-none`:`max-w-[42rem]`),children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h1`,{className:tn(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,p?`text-[24px]`:`text-[32px]`),children:`Model Providers`}),(0,R.jsxs)(`p`,{className:`mt-3 text-[15px] leading-6 text-muted-foreground`,children:[`Configure model providers and choose which ones are available.`,` `,e.length,` available · `,u,` `,`enabled`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 max-[860px]:justify-start`,children:[(0,R.jsx)(N,{"aria-label":`Search providers`,className:`size-8 rounded-md`,onClick:()=>s(e=>!e),size:`icon-sm`,type:`button`,variant:o?`default`:`secondary`,children:(0,R.jsx)(fe,{className:`size-4`})}),(0,R.jsxs)(N,{className:`h-8 rounded-md bg-foreground px-3 text-sm text-background hover:bg-foreground/90`,onClick:r,type:`button`,children:[(0,R.jsx)(pn,{className:`size-4`}),`Add provider`]})]})]}),o?(0,R.jsx)(`div`,{className:tn(`mb-4`,p?`max-w-none`:`max-w-[42rem]`),children:(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border bg-background px-3`,children:[(0,R.jsx)(fe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(kt,{"aria-label":`Search model providers`,autoFocus:!0,className:`h-7 border-0 bg-transparent px-0 text-sm`,onChange:e=>l(e.target.value),placeholder:`Search providers`,value:c})]})}):null,(0,R.jsxs)(`div`,{className:tn(`overflow-hidden`,p?`max-w-none`:`max-w-[42rem]`),children:[f.length===0?(0,R.jsxs)(`div`,{className:`border-b px-2 py-6 text-[15px] text-muted-foreground`,children:[`No providers match "`,c.trim(),`".`]}):null,f.map(e=>(0,R.jsxs)(`div`,{className:tn(`flex min-h-11 items-center gap-4 border-b px-2 py-2 transition-colors hover:bg-accent/30`,i===e.id&&`bg-accent/45`),children:[(0,R.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[17px] font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`p`,{className:`shrink-0 text-[15px] text-muted-foreground`,children:e.models===null?`Models load on demand`:`${e.models} model${e.models===1?``:`s`}`})]}),(0,R.jsx)(pe,{"aria-label":`Toggle ${e.name}`,checked:e.enabled,onCheckedChange:()=>t(e.id)}),(0,R.jsx)(`button`,{"aria-label":`Configure ${e.name}`,className:`grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>n(e.id),type:`button`,children:(0,R.jsx)(dn,{className:`size-4`})})]},e.id))]})]})})}function ar({provider:e,onBack:t,onUpdate:n,onLoadModels:r,modelsLoading:i=!1,modelsError:a,onOAuthLogin:o,oauthLoginPending:s=!1,variant:c=`page`}){let[l,u]=(0,L.useState)({}),[f,p]=(0,L.useState)(()=>tr(e)),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(null),v=(0,L.useRef)(void 0),y=e.configFields??[],ee=nr(f.apiKey),b=e.modelList??[],x=m?.providerId===e.id?m.value:``,te=g?.providerId===e.id?g.modelId:null,S=x.trim().toLowerCase(),w=S?b.filter(e=>e.name.toLowerCase().includes(S)||e.id.toLowerCase().includes(S)):b,ne=c===`panel`;(0,L.useEffect)(()=>()=>{v.current!==void 0&&window.clearTimeout(v.current)},[]);let T=(e,t)=>{let r=rr(e,t),i={...f,[e.path]:r};p(i);let a={configValues:{[e.path]:r}};e.path===`apiKey`&&(a.apiKey=nr(r)),e.path===`baseUrl`&&(a.baseUrl=nr(r)),n(a)},re=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,R.jsx)(I,{className:`h-full`,children:(0,R.jsxs)(`div`,{className:tn(`py-10 max-[720px]:px-4 max-[720px]:py-5`,ne?`px-6`:`px-18 max-[1200px]:px-8`),children:[(0,R.jsxs)(`div`,{className:`mb-8 flex items-center gap-3`,children:[(0,R.jsx)(N,{"aria-label":ne?`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:ne?(0,R.jsx)(C,{className:`h-4 w-4`}):(0,R.jsx)(ln,{className:`h-4 w-4`})}),(0,R.jsx)(`h1`,{className:tn(`truncate font-semibold leading-[1.15] tracking-normal text-foreground`,ne?`text-[24px]`:`text-[32px]`),children:e.name})]}),y.length>0?(0,R.jsx)(`section`,{className:tn(`mb-8`,ne?`max-w-none`:`max-w-[86rem]`),children:(0,R.jsx)(`div`,{className:`flex flex-col`,children:y.map(e=>{let t=f[e.path],n=nr(t),r=e.type===`password`||e.secret,i=l[e.path]??!1;return(0,R.jsxs)(`div`,{className:`grid min-h-18 grid-cols-[minmax(12rem,0.55fr)_minmax(16rem,0.45fr)] items-center gap-6 border-b py-4 max-[900px]:grid-cols-1 max-[900px]:gap-3`,children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`h3`,{className:`text-[17px] font-semibold text-foreground`,children:e.label}),e.description?(0,R.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed text-muted-foreground`,children:e.description}):null]}),e.type===`boolean`?(0,R.jsxs)(`div`,{className:`flex items-center justify-end`,children:[(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label}),(0,R.jsx)(pe,{checked:!!t,onCheckedChange:t=>T(e,t)})]}):e.type===`select`?(0,R.jsxs)(`select`,{className:`h-9 w-full rounded border border-border bg-background px-3 text-sm text-foreground outline-none focus:ring-1 focus:ring-ring`,onChange:t=>T(e,t.target.value),value:n,children:[(0,R.jsx)(`option`,{value:``,children:`Not set`}),e.options?.map(e=>(0,R.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))]}):(0,R.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded border border-border bg-background px-3`,children:[e.type===`url`?(0,R.jsx)(Ut,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):null,(0,R.jsx)(kt,{className:`h-7 flex-1 border-0 bg-transparent px-0 text-sm text-foreground outline-none placeholder:text-muted-foreground`,onBlur:()=>T(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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{"aria-label":i?`Hide secret`:`Show secret`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>u(t=>({...t,[e.path]:!i})),variant:`ghost`,children:i?(0,R.jsx)(hn,{className:`h-4 w-4`}):(0,R.jsx)(gn,{className:`h-4 w-4`})}),(0,R.jsx)(N,{"aria-label":`Copy ${e.label}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>navigator.clipboard.writeText(n),variant:`ghost`,children:(0,R.jsx)(de,{className:`h-4 w-4`})})]}):null]})]},e.path)})})}):null,!ee&&!e.oauthAccessTokenPresent&&o?(0,R.jsx)(`div`,{className:`mb-8`,children:(0,R.jsxs)(N,{className:`inline-flex items-center gap-2 w-full`,disabled:s,onClick:o,variant:`default`,children:[s?(0,R.jsx)(k,{className:`h-4 w-4 animate-spin`}):null,(0,R.jsx)(`span`,{children:`Login via Browser`})]})}):null,e.oauthAccessTokenPresent?(0,R.jsx)(`p`,{className:`mb-8 text-xs text-muted-foreground`,children:`OAuth is connected. Manual credentials remain available when this provider supports them.`}):null,(0,R.jsxs)(`section`,{className:tn(`overflow-hidden rounded-lg border`,ne?`max-w-none`:`max-w-[46rem]`),children:[(0,R.jsxs)(`div`,{className:`flex h-12 items-center justify-between bg-muted/40 px-4`,children:[(0,R.jsx)(`h2`,{className:`text-[17px] font-medium text-muted-foreground`,children:`Models`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(fe,{className:`size-4 text-muted-foreground`}),(0,R.jsx)(N,{"aria-label":`Refresh models`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors`,disabled:i,onClick:r,variant:`ghost`,children:(0,R.jsx)(he,{className:tn(`size-3`,i&&`animate-spin`)})})]})]}),a?(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-destructive`,children:a})}):b.length>0?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`mx-4 mt-4 flex items-center gap-2 rounded border border-border bg-background px-3 py-2`,children:[(0,R.jsx)(fe,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsx)(kt,{"aria-label":`Search models`,className:`h-7 flex-1 border-0 text-sm text-foreground placeholder:text-muted-foreground`,onChange:t=>h({providerId:e.id,value:t.target.value}),placeholder:`Search models by name or ID`,spellCheck:!1,value:x})]}),w.length>0?(0,R.jsx)(`div`,{className:`max-h-125 overflow-y-scroll border-t`,children:w.map(e=>(0,R.jsxs)(`div`,{className:`group flex min-h-16 items-center gap-3 border-b px-4 py-3 transition-colors hover:bg-accent/30`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 font-mono`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 px-1 text-sm text-foreground`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.supportsAttachments&&(0,R.jsx)(`div`,{title:`File Support`,children:(0,R.jsx)(_n,{className:`h-3.5 w-3.5 text-muted-foreground`})}),e.supportsVision&&(0,R.jsx)(`div`,{title:`Image Support`,children:(0,R.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`})})]}),(0,R.jsxs)(`button`,{"aria-label":`Copy model ID ${e.id}`,className:`mt-1 flex max-w-full items-center gap-1.5 px-1 text-left text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>re(e.id),title:`Copy model ID`,type:`button`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.id}),(0,R.jsx)(de,{className:`size-3 shrink-0`}),te===e.id?(0,R.jsx)(`span`,{className:`shrink-0 text-foreground`,children:`Copied`}):null]})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,R.jsx)(N,{"aria-label":`Favorite ${e.name}`,className:`rounded-md p-1 text-muted-foreground hover:text-foreground transition-colors`,variant:`ghost`,children:(0,R.jsx)(_e,{className:`h-3.5 w-3.5`})})})]},e.id))}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No models match "`,x.trim(),`".`]})})]}):(0,R.jsx)(`div`,{className:`rounded-lg border border-border px-4 py-8 text-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`Loading models...`:`No models available. Click refresh to load models.`})})]})]})})}var or,sr=Object.freeze({status:`aborted`});function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var cr=Symbol(`zod_brand`),lr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ur=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(or=globalThis).__zod_globalConfig??(or.__zod_globalConfig={});var dr=globalThis.__zod_globalConfig;function fr(e){return e&&Object.assign(dr,e),dr}var pr=t({BIGINT_FORMAT_RANGES:()=>Yr,Class:()=>vi,NUMBER_FORMAT_RANGES:()=>Jr,aborted:()=>ri,allowsEval:()=>Lr,assert:()=>vr,assertEqual:()=>mr,assertIs:()=>gr,assertNever:()=>_r,assertNotEqual:()=>hr,assignProp:()=>Dr,base64ToUint8Array:()=>fi,base64urlToUint8Array:()=>mi,cached:()=>xr,captureStackTrace:()=>Fr,cleanEnum:()=>di,cleanRegex:()=>Cr,clone:()=>Gr,cloneDef:()=>kr,createTransparentProxy:()=>Kr,defineLazy:()=>V,esc:()=>Nr,escapeRegex:()=>Wr,explicitlyAborted:()=>ii,extend:()=>Qr,finalizeIssue:()=>si,floatSafeRemainder:()=>wr,getElementAtPath:()=>Ar,getEnumValues:()=>yr,getLengthableOrigin:()=>li,getParsedType:()=>Vr,getSizableOrigin:()=>ci,hexToUint8Array:()=>gi,isObject:()=>Ir,isPlainObject:()=>Rr,issue:()=>ui,joinValues:()=>B,jsonStringifyReplacer:()=>br,merge:()=>ei,mergeDefs:()=>Or,normalizeParams:()=>H,nullish:()=>Sr,numKeys:()=>Br,objectClone:()=>Er,omit:()=>Zr,optionalKeys:()=>qr,parsedType:()=>W,partial:()=>ti,pick:()=>Xr,prefixIssues:()=>ai,primitiveTypes:()=>Ur,promiseAllObject:()=>jr,propertyKeyTypes:()=>Hr,randomString:()=>Mr,required:()=>ni,safeExtend:()=>$r,shallowClone:()=>zr,slugify:()=>Pr,stringifyPrimitive:()=>U,uint8ArrayToBase64:()=>pi,uint8ArrayToBase64url:()=>hi,uint8ArrayToHex:()=>_i,unwrapMessage:()=>oi});function mr(e){return e}function hr(e){return e}function gr(e){}function _r(e){throw Error(`Unexpected value in exhaustive check`)}function vr(e){}function yr(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function B(e,t=`|`){return e.map(e=>U(e)).join(t)}function br(e,t){return typeof t==`bigint`?t.toString():t}function xr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Sr(e){return e==null}function Cr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function wr(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Tr=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Tr)return r===void 0&&(r=Tr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Er(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Dr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Or(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function kr(e){return Or(e._zod.def)}function Ar(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function jr(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function Mr(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function Nr(e){return JSON.stringify(e)}function Pr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Fr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ir(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Lr=xr(()=>{if(dr.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Rr(e){if(Ir(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Ir(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function zr(e){return Rr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Br(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Vr=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Hr=new Set([`string`,`number`,`symbol`]),Ur=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function Wr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Gr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Kr(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function U(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function qr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Jr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Yr={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Xr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Dr(this,`shape`,e),e},checks:[]}))}function Zr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Gr(e,Or(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Dr(this,`shape`,r),r},checks:[]}))}function Qr(e,t){if(!Rr(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function $r(e,t){if(!Rr(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dr(this,`shape`,n),n}}))}function ei(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Gr(e,Or(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Dr(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ti(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Dr(this,`shape`,i),i},checks:[]}))}function ni(e,t,n){return Gr(t,Or(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Dr(this,`shape`,i),i}}))}function ri(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ii(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ai(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function oi(e){return typeof e==`string`?e:e?.message}function si(e,t,n){let r=e.message?e.message:oi(e.inst?._zod.def?.error?.(e))??oi(t?.error?.(e))??oi(n.customError?.(e))??oi(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ci(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function li(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function W(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function ui(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function di(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function fi(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function pi(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function mi(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return fi(t+`=`.repeat((4-t.length%4)%4))}function hi(e){return pi(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function gi(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function _i(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var vi=class{constructor(...e){}},yi=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,br,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bi=z(`$ZodError`,yi),xi=z(`$ZodError`,yi,{Parent:Error});function Si(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ci(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function wi(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},[...i,...s.path]));else if(s.code===`invalid_key`)r({issues:s.issues},[...i,...s.path]);else if(s.code===`invalid_element`)r({issues:s.issues},[...i,...s.path]);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function Ti(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ei(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Ti(e.path)}`);return t.join(`
|
|
2
2
|
`)}var Di=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new lr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>si(e,a,fr())));throw Fr(t,i?.callee),t}return o.value},Oi=Di(xi),ki=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>si(e,a,fr())));throw Fr(t,i?.callee),t}return o.value},Ai=ki(xi),ji=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new lr;return a.issues.length?{success:!1,error:new(e??bi)(a.issues.map(e=>si(e,i,fr())))}:{success:!0,data:a.value}},Mi=ji(xi),Ni=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>si(e,i,fr())))}:{success:!0,data:a.value}},Pi=Ni(xi),Fi=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Di(e)(t,n,i)},Ii=Fi(xi),Li=e=>(t,n,r)=>Di(e)(t,n,r),Ri=Li(xi),zi=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ki(e)(t,n,i)},Bi=zi(xi),Vi=e=>async(t,n,r)=>ki(e)(t,n,r),Hi=Vi(xi),Ui=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ji(e)(t,n,i)},Wi=Ui(xi),Gi=e=>(t,n,r)=>ji(e)(t,n,r),Ki=Gi(xi),qi=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ni(e)(t,n,i)},Ji=qi(xi),Yi=e=>async(t,n,r)=>Ni(e)(t,n,r),Xi=Yi(xi),Zi=t({base64:()=>wa,base64url:()=>Ta,bigint:()=>Ia,boolean:()=>za,browserEmail:()=>ga,cidrv4:()=>Sa,cidrv6:()=>Ca,cuid:()=>Qi,cuid2:()=>$i,date:()=>ja,datetime:()=>Pa,domain:()=>Da,duration:()=>ia,e164:()=>ka,email:()=>da,emoji:()=>va,extendedDuration:()=>aa,guid:()=>oa,hex:()=>Wa,hostname:()=>Ea,html5Email:()=>fa,httpProtocol:()=>Oa,idnEmail:()=>ha,integer:()=>La,ipv4:()=>ya,ipv6:()=>ba,ksuid:()=>na,lowercase:()=>Ha,mac:()=>xa,md5_base64:()=>Ja,md5_base64url:()=>Ya,md5_hex:()=>qa,nanoid:()=>ra,null:()=>Ba,number:()=>Ra,rfc5322Email:()=>pa,sha1_base64:()=>Za,sha1_base64url:()=>Qa,sha1_hex:()=>Xa,sha256_base64:()=>eo,sha256_base64url:()=>to,sha256_hex:()=>$a,sha384_base64:()=>ro,sha384_base64url:()=>io,sha384_hex:()=>no,sha512_base64:()=>oo,sha512_base64url:()=>so,sha512_hex:()=>ao,string:()=>Fa,time:()=>Na,ulid:()=>ea,undefined:()=>Va,unicodeEmail:()=>ma,uppercase:()=>Ua,uuid:()=>sa,uuid4:()=>ca,uuid6:()=>la,uuid7:()=>ua,xid:()=>ta}),Qi=/^[cC][0-9a-z]{6,}$/,$i=/^[0-9a-z]+$/,ea=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ta=/^[0-9a-vA-V]{20}$/,na=/^[A-Za-z0-9]{27}$/,ra=/^[a-zA-Z0-9_-]{21}$/,ia=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,aa=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,oa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,sa=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ca=sa(4),la=sa(6),ua=sa(7),da=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fa=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,pa=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,ma=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,ha=ma,ga=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,_a=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function va(){return new RegExp(_a,`u`)}var ya=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ba=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xa=e=>{let t=Wr(e??`:`);return RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Sa=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ca=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ta=/^[A-Za-z0-9_-]*$/,Ea=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Da=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Oa=/^https?$/,ka=/^\+[1-9]\d{6,14}$/,Aa=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ja=RegExp(`^${Aa}$`);function Ma(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Na(e){return RegExp(`^${Ma(e)}$`)}function Pa(e){let t=Ma({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Aa}T(?:${r})$`)}var Fa=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ia=/^-?\d+n?$/,La=/^-?\d+$/,Ra=/^-?\d+(?:\.\d+)?$/,za=/^(?:true|false)$/i,Ba=/^null$/i,Va=/^undefined$/i,Ha=/^[^A-Z]*$/,Ua=/^[^a-z]*$/,Wa=/^[0-9a-fA-F]*$/;function Ga(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Ka(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var qa=/^[0-9a-fA-F]{32}$/,Ja=Ga(22,`==`),Ya=Ka(22),Xa=/^[0-9a-fA-F]{40}$/,Za=Ga(27,`=`),Qa=Ka(27),$a=/^[0-9a-fA-F]{64}$/,eo=Ga(43,`=`),to=Ka(43),no=/^[0-9a-fA-F]{96}$/,ro=Ga(64,``),io=Ka(64),ao=/^[0-9a-fA-F]{128}$/,oo=Ga(86,`==`),so=Ka(86),co=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lo={number:`number`,bigint:`bigint`,object:`date`},uo=z(`$ZodCheckLessThan`,(e,t)=>{co.init(e,t);let n=lo[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fo=z(`$ZodCheckGreaterThan`,(e,t)=>{co.init(e,t);let n=lo[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),po=z(`$ZodCheckMultipleOf`,(e,t)=>{co.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):wr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),mo=z(`$ZodCheckNumberFormat`,(e,t)=>{co.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Jr[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=La)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ho=z(`$ZodCheckBigIntFormat`,(e,t)=>{co.init(e,t);let[n,r]=Yr[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=i=>{let a=i.value;a<n&&i.issues.push({origin:`bigint`,input:a,code:`too_small`,minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:`bigint`,input:a,code:`too_big`,maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),go=z(`$ZodCheckMaxSize`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:ci(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_o=z(`$ZodCheckMinSize`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:ci(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vo=z(`$ZodCheckSizeEquals`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:ci(r),...a?{code:`too_big`,maximum:t.size}:{code:`too_small`,minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yo=z(`$ZodCheckMaxLength`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=li(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bo=z(`$ZodCheckMinLength`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=li(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xo=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;co.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Sr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=li(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),So=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;co.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Co=z(`$ZodCheckRegex`,(e,t)=>{So.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wo=z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ha,So.init(e,t)}),To=z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ua,So.init(e,t)}),Eo=z(`$ZodCheckIncludes`,(e,t)=>{co.init(e,t);let n=Wr(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Do=z(`$ZodCheckStartsWith`,(e,t)=>{co.init(e,t);let n=RegExp(`^${Wr(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Oo=z(`$ZodCheckEndsWith`,(e,t)=>{co.init(e,t);let n=RegExp(`.*${Wr(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function ko(e,t,n){e.issues.length&&t.issues.push(...ai(n,e.issues))}var Ao=z(`$ZodCheckProperty`,(e,t)=>{co.init(e,t),e._zod.check=e=>{let n=t.schema._zod.run({value:e.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(n=>ko(n,e,t.property));ko(n,e,t.property)}}),jo=z(`$ZodCheckMimeType`,(e,t)=>{co.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:`invalid_value`,values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),Mo=z(`$ZodCheckOverwrite`,(e,t)=>{co.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),No=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
4
4
|
`))}},Po={major:4,minor:4,patch:3},G=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Po;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=ri(e),i;for(let a of t){if(a._zod.def.when){if(ii(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new lr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=ri(e,t))});else{if(e.issues.length===t)continue;r||=ri(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(ri(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new lr;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new lr;return o.then(e=>t(e,r,a))}return t(o,r,a)}}V(e,`~standard`,()=>({validate:t=>{try{let n=Mi(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Pi(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Fo=z(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Fa(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Io=z(`$ZodStringFormat`,(e,t)=>{So.init(e,t),Fo.init(e,t)}),Lo=z(`$ZodGUID`,(e,t)=>{t.pattern??=oa,Io.init(e,t)}),Ro=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=sa(e)}else t.pattern??=sa();Io.init(e,t)}),zo=z(`$ZodEmail`,(e,t)=>{t.pattern??=da,Io.init(e,t)}),Bo=z(`$ZodURL`,(e,t)=>{Io.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Oa.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Vo=z(`$ZodEmoji`,(e,t)=>{t.pattern??=va(),Io.init(e,t)}),Ho=z(`$ZodNanoID`,(e,t)=>{t.pattern??=ra,Io.init(e,t)}),Uo=z(`$ZodCUID`,(e,t)=>{t.pattern??=Qi,Io.init(e,t)}),Wo=z(`$ZodCUID2`,(e,t)=>{t.pattern??=$i,Io.init(e,t)}),Go=z(`$ZodULID`,(e,t)=>{t.pattern??=ea,Io.init(e,t)}),Ko=z(`$ZodXID`,(e,t)=>{t.pattern??=ta,Io.init(e,t)}),qo=z(`$ZodKSUID`,(e,t)=>{t.pattern??=na,Io.init(e,t)}),Jo=z(`$ZodISODateTime`,(e,t)=>{t.pattern??=Pa(t),Io.init(e,t)}),Yo=z(`$ZodISODate`,(e,t)=>{t.pattern??=ja,Io.init(e,t)}),Xo=z(`$ZodISOTime`,(e,t)=>{t.pattern??=Na(t),Io.init(e,t)}),Zo=z(`$ZodISODuration`,(e,t)=>{t.pattern??=ia,Io.init(e,t)}),Qo=z(`$ZodIPv4`,(e,t)=>{t.pattern??=ya,Io.init(e,t),e._zod.bag.format=`ipv4`}),$o=z(`$ZodIPv6`,(e,t)=>{t.pattern??=ba,Io.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),es=z(`$ZodMAC`,(e,t)=>{t.pattern??=xa(t.delimiter),Io.init(e,t),e._zod.bag.format=`mac`}),ts=z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Sa,Io.init(e,t)}),ns=z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ca,Io.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function rs(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var is=z(`$ZodBase64`,(e,t)=>{t.pattern??=wa,Io.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{rs(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function as(e){if(!Ta.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rs(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var os=z(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ta,Io.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{as(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ss=z(`$ZodE164`,(e,t)=>{t.pattern??=ka,Io.init(e,t)});function cs(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var ls=z(`$ZodJWT`,(e,t)=>{Io.init(e,t),e._zod.check=n=>{cs(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),us=z(`$ZodCustomStringFormat`,(e,t)=>{Io.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:`invalid_format`,format:t.format,input:n.value,inst:e,continue:!t.abort})}}),ds=z(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ra,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fs=z(`$ZodNumberFormat`,(e,t)=>{mo.init(e,t),ds.init(e,t)}),ps=z(`$ZodBoolean`,(e,t)=>{G.init(e,t),e._zod.pattern=za,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ms=z(`$ZodBigInt`,(e,t)=>{G.init(e,t),e._zod.pattern=Ia,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),hs=z(`$ZodBigIntFormat`,(e,t)=>{ho.init(e,t),ms.init(e,t)}),gs=z(`$ZodSymbol`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),_s=z(`$ZodUndefined`,(e,t)=>{G.init(e,t),e._zod.pattern=Va,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),vs=z(`$ZodNull`,(e,t)=>{G.init(e,t),e._zod.pattern=Ba,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),ys=z(`$ZodAny`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),bs=z(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),xs=z(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),Ss=z(`$ZodVoid`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),Cs=z(`$ZodDate`,(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}});function ws(e,t,n){e.issues.length&&t.issues.push(...ai(n,e.issues)),t.value[n]=e.value}var Ts=z(`$ZodArray`,(e,t)=>{G.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ws(t,n,e))):ws(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Es(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ai(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Ds(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=qr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Os(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Es(e,n,i,t,u,d))):Es(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var ks=z(`$ZodObject`,(e,t)=>{if(G.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=xr(()=>Ds(t));V(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ir,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Es(n,t,e,s,r,i))):Es(a,t,e,s,r,i)}return i?Os(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),As=z(`$ZodObjectJIT`,(e,t)=>{ks.init(e,t);let n=e._zod.parse,r=xr(()=>Ds(t)),i=e=>{let t=new No([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Nr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Nr(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
@@ -73,4 +73,4 @@ You are in Plan mode. Your role is to explore, analyze, and plan -- not to execu
|
|
|
73
73
|
- Do NOT edit files, write code, run destructive commands, or make any changes
|
|
74
74
|
- Do NOT implement anything -- focus on understanding and alignment first
|
|
75
75
|
|
|
76
|
-
The run_commands tool remains available in plan mode strictly for read-only inspection -- listing files, searching (grep), reading configs, inspecting git history and diffs, checking tool versions, and the like. Never use it to change anything: no creating, modifying, or deleting files, no writing scripts that make changes, and no state-changing commands (installs, migrations, database or schema changes, container commands that mutate state, etc.). File-editing commands (rm/mv/cp, in-place edits like sed -i, output redirection to files outside /tmp, git commands that change the working tree, package installs) are hard-blocked in plan mode: they are not executed and return a tool error instead, so do not attempt them. If the task requires a mutation, put it in the plan; it happens only after the user switches to act mode.`;`${$_}`,`${$_}`;var ev=`anthropic/claude-sonnet-5`,tv=Z({models:X(Z({id:q(),temperature:J().optional(),maxTokens:J().optional(),contextWindow:J().optional(),inputPrice:J().optional(),outputPrice:J().optional(),supportsImages:Y().optional()})).optional(),openAiBaseUrl:q().optional(),openAiHeaders:eg(q(),q()).optional(),azureApiVersion:q().optional(),azureIdentity:Y().optional()}),nv=Z({id:q(),thinkingBudgetTokens:J().optional()}),rv=Z({name:q(),baseModelId:q(),thinkingBudgetTokens:J().optional()}),iv=Z({models:X(nv).optional(),customModels:X(rv).optional(),awsRegion:q().optional(),awsUseCrossRegionInference:Y().optional(),awsUseGlobalInference:Y().optional(),awsBedrockUsePromptCache:Y().optional(),awsBedrockEndpoint:q().optional()}),av=Z({models:X(Z({id:q()})).optional()}),ov=Z({models:X(Z({id:q(),thinkingBudgetTokens:J().optional()})).optional(),vertexProjectId:q().optional(),vertexRegion:q().optional()}),sv=Z({models:X(Z({id:q(),thinkingBudgetTokens:J().optional(),promptCachingEnabled:Y().optional()})).optional(),baseUrl:q().optional()}),cv=Z({models:X(Z({id:q(),thinkingBudgetTokens:J().optional()})).optional(),baseUrl:q().optional()}),lv=Z({OpenAiCompatible:tv.optional(),AwsBedrock:iv.optional(),Cline:av.optional(),Vertex:ov.optional(),LiteLLM:sv.optional(),Anthropic:cv.optional()}),uv=Z({id:q()}),dv=Z({name:q(),url:q(),alwaysEnabled:Y().optional(),headers:eg(q(),q()).optional()}),fv=Z({alwaysEnabled:Y(),name:q(),contents:q()}),pv=Z({bucket:q(),accessKeyId:q(),secretAccessKey:q(),region:q().optional(),endpoint:q().optional(),accountId:q().optional()}),mv=Z({promptUploading:Z({enabled:Y().optional(),type:Wh([dg(`s3_access_keys`),dg(`r2_access_keys`),dg(`azure_access_keys`)]).optional(),s3AccessSettings:pv.optional(),r2AccessSettings:pv.optional(),azureAccessSettings:pv.optional()}).optional()});Z({version:q(),providerSettings:lv.optional(),telemetryEnabled:Y().optional(),kanbanEnabled:Y().optional(),mcpMarketplaceEnabled:Y().optional(),allowedMCPServers:X(uv).optional(),remoteMCPServers:X(dv).optional(),blockPersonalRemoteMCPServers:Y().optional(),yoloModeAllowed:Y().optional(),openTelemetryEnabled:Y().optional(),openTelemetryMetricsExporter:q().optional(),openTelemetryLogsExporter:q().optional(),openTelemetryOtlpProtocol:q().optional(),openTelemetryOtlpEndpoint:q().optional(),openTelemetryOtlpHeaders:eg(q(),q()).optional(),openTelemetryOtlpMetricsProtocol:q().optional(),openTelemetryOtlpMetricsEndpoint:q().optional(),openTelemetryOtlpMetricsHeaders:eg(q(),q()).optional(),openTelemetryOtlpLogsProtocol:q().optional(),openTelemetryOtlpLogsEndpoint:q().optional(),openTelemetryOtlpLogsHeaders:eg(q(),q()).optional(),openTelemetryMetricExportInterval:J().optional(),openTelemetryOtlpInsecure:Y().optional(),openTelemetryLogBatchSize:J().optional(),openTelemetryLogBatchTimeout:J().optional(),openTelemetryLogMaxQueueSize:J().optional(),enterpriseTelemetry:mv.optional(),globalRules:X(fv).optional(),globalWorkflows:X(fv).optional()}),eg(q(),q()),T_.enum([`reasoning`,`prompt-cache`,`tools`,`provider-tools`,`oauth`,`temperature`,`files`,`streaming`,`vision`,`computer-use`,`local-auth`,`popular`]),T_.enum([`anthropic`,`gemini`,`openai-chat`,`openai-responses`,`openai-r1`,`ai-sdk`]),T_.enum([`anthropic`,`ai-sdk`,`ai-sdk-community`,`openai`,`openai-compatible`,`openai-r1`,`gemini`,`bedrock`,`custom`,`fetch`,`vertex`]);var hv=Z({rootPath:q().min(1),hint:q().min(1).optional(),associatedRemoteUrls:X(q().min(1)).optional(),latestGitCommitHash:q().min(1).optional(),latestGitBranchName:q().min(1).optional()});Z({currentWorkspacePath:q().min(1).optional(),workspaces:eg(q().min(1),hv)});var gv=[`current_state`,`boundary_analysis`,`interface_proposal`],_v=s_(e=>e instanceof Date?e.toISOString():e,q().datetime()),vv=cg([`pending`,`in_progress`,`blocked`,`completed`]),yv=cg([`queued`,`running`,`completed`,`failed`,`cancelled`,`interrupted`]),bv=cg([`draft`,`in_review`,`finalized`]),xv=Z({agentId:q(),role:cg([`lead`,`teammate`]),description:q().optional(),status:cg([`idle`,`running`,`stopped`])});Z({agentId:q(),rolePrompt:q(),modelId:q().optional(),maxIterations:J().optional()});function Sv(e){return s_(e=>e===null?void 0:e,e.optional())}Z({agentId:q().min(1).describe(`Teammate identifier`),rolePrompt:q().min(1).describe(`System prompt describing teammate role`)}).strict(),Z({agentId:q().min(1).describe(`Teammate identifier`),reason:Sv(q().min(1)).describe(`Optional shutdown reason`)}),Z({});var Cv={create:[`title`,`description`],list:[],claim:[`taskId`],complete:[`taskId`,`summary`],block:[`taskId`,`reason`]};Z({action:cg([`create`,`list`,`claim`,`complete`,`block`]),title:Sv(q().min(1)).describe(`Task title`),description:Sv(q().min(1)).describe(`Task details`),dependsOn:Sv(X(q().describe(`Dependency task ID`))).describe(`Array of dependency task IDs`),assignee:Sv(q().min(1)).describe(`Optional assignee`),status:Sv(cg([`pending`,`in_progress`,`blocked`,`completed`])).describe(`Optional task status filter`),taskId:Sv(q()).describe(`Task ID`),summary:Sv(q().min(1)).describe(`Completion summary`),reason:Sv(q().min(1)).describe(`Blocking reason`)}).superRefine((e,t)=>{for(let n of Cv[e.action])e[n]===void 0&&t.addIssue({code:`custom`,path:[n],message:`Field "${n}" is required when action=${e.action}`})}),Z({agentId:q().describe(`Teammate agent ID`),task:q().min(1).describe(`Task instructions for the teammate`),taskId:Sv(q()).describe(`Optional shared task list ID`),runMode:Sv(cg([`sync`,`async`])).describe(`Execution mode: 'sync' blocks until the teammate finishes and returns the result (default if omitted); 'async' queues the run and returns a runId immediately — use team_await_runs to collect results later.`),continueConversation:Sv(Y()).describe(`If true, continue the teammate conversation; otherwise start fresh`)}),Z({status:Sv(cg([`queued`,`running`,`completed`,`failed`,`cancelled`,`interrupted`])).describe(`Optional run status filter. Omit to include all statuses.`),agentId:Sv(q().min(1)).describe(`Optional teammate ID filter. Omit to include all teammates.`),includeCompleted:Sv(Y()).describe(`Include completed/failed runs (default true)`)}),Z({runId:q().min(1).describe(`Run ID`),reason:Sv(q().min(1)).describe(`Optional cancellation reason`)}),Z({runId:Sv(q().min(1)).describe(`Optional async run ID to await. Omit to wait for all active async runs.`)}).strict(),Z({toAgentId:q().min(1).describe(`Recipient agent ID`),subject:q().min(1).describe(`Message subject`),body:q().min(1).describe(`Message body`),taskId:Sv(q().min(1)).describe(`Optional task ID context`)}),Z({subject:q().min(1).describe(`Message subject`),body:q().min(1).describe(`Message body`),taskId:Sv(q().min(1)).describe(`Optional task ID context`)}),Z({unreadOnly:Sv(Y()).describe(`Only unread messages for read action (default true)`)}),Z({kind:cg([`progress`,`handoff`,`blocked`,`decision`,`done`,`error`]),summary:q().min(1).describe(`Update summary`),taskId:Sv(q().min(1)).describe(`Optional task ID context`),evidence:Sv(X(q().min(1))).describe(`Optional evidence links/snippets`),nextAction:Sv(q().min(1)).describe(`Planned next step`)}),Z({}),Z({title:q().describe(`Outcome title`),requiredSections:X(q()).default(gv).describe(`Required sections for finalization gate (defaults to current_state,boundary_analysis,interface_proposal)`)}),Z({outcomeId:q().describe(`Outcome ID`),section:q().describe(`Section name`),sourceRunId:Sv(q()).describe(`Optional source run ID`),content:q().describe(`Section fragment content`)}),Z({fragmentId:q().describe(`Fragment ID`),approved:Y().describe(`Review decision`)}),Z({outcomeId:q().describe(`Outcome ID`)}),Z({}),Z({teamId:q(),teamName:q(),members:X(xv),taskCounts:eg(vv,J()),unreadMessages:J(),missionLogEntries:J(),activeRuns:J(),queuedRuns:J(),outcomeCounts:eg(bv,J())});var wv=Z({id:q(),title:q(),description:q(),status:vv,createdAt:_v,updatedAt:_v,createdBy:q(),assignee:q().optional(),dependsOn:X(q()),summary:q().optional(),isReady:Y(),blockedBy:X(q())});Jh(`action`,[Z({action:dg(`create`),taskId:q(),status:vv,ignoredFields:X(q()).optional(),note:q().optional()}),Z({action:dg(`list`),tasks:X(wv)}),Z({action:dg(`claim`),taskId:q(),status:vv,nextStep:q()}),Z({action:dg(`complete`),taskId:q(),status:vv}),Z({action:dg(`block`),taskId:q(),status:vv})]),Z({agentId:q(),mode:cg([`sync`,`async`]),status:cg([`dispatched`,`running`,`queued`,`joined`]),dispatched:Y(),message:q(),deduped:Y().optional(),runId:q().optional(),text:q().optional(),iterations:J().optional()});var Tv=Z({textPreview:q(),iterations:J(),finishReason:q(),durationMs:J(),usage:Z({inputTokens:J(),outputTokens:J(),cacheReadTokens:J().optional(),cacheWriteTokens:J().optional(),totalCost:J().optional()})});Z({id:q(),agentId:q(),taskId:q().optional(),status:yv,messagePreview:q(),priority:J(),retryCount:J(),maxRetries:J(),nextAttemptAt:_v.optional(),continueConversation:Y().optional(),startedAt:_v,endedAt:_v.optional(),leaseOwner:q().optional(),heartbeatAt:_v.optional(),lastProgressAt:_v.optional(),lastProgressMessage:q().optional(),currentActivity:q().optional(),error:q().optional(),resultSummary:Tv.optional()}),Z({id:q(),teamId:q(),fromAgentId:q(),toAgentId:q(),subject:q(),body:q(),taskId:q().optional(),sentAt:_v,readAt:_v.optional()}),Z({id:q(),teamId:q(),title:q(),status:bv,requiredSections:X(q()),createdBy:q(),createdAt:_v,finalizedAt:_v.optional()}),Z({outcomeId:q(),status:bv,requiredSections:X(q())}),Z({agentId:q(),status:q()}),Z({runId:q(),status:yv}),Z({id:q(),toAgentId:q()}),Z({delivered:J()}),Z({id:q()}),Z({status:q()}),Z({fragmentId:q(),status:q()}),Z({outcomeId:q(),status:bv});var Ev;(e=>{e.TaskStart=`task_start`,e.TaskEnd=`task_end`,e.AgentEvent=`agent_event`,e.TeammateSpawned=`teammate_spawned`,e.TeammateShutdown=`teammate_shutdown`,e.TeamTaskUpdated=`team_task_updated`,e.TeamMessage=`team_message`,e.TeamMissionLog=`team_mission_log`,e.TeamTaskCompleted=`team_task_completed`,e.RunStarted=`run_started`,e.RunQueued=`run_queued`,e.RunProgress=`run_progress`,e.RunCompleted=`run_completed`,e.RunFailed=`run_failed`,e.RunCancelled=`run_cancelled`,e.RunInterrupted=`run_interrupted`,e.OutcomeCreated=`outcome_created`,e.OutcomeFragmentAttached=`outcome_fragment_attached`,e.OutcomeFragmentReviewed=`outcome_fragment_reviewed`,e.OutcomeFinalized=`outcome_finalized`})(Ev||={});function Dv(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 Ov=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 kv(e){return L.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[Ov.checked]:``}:{[Ov.unchecked]:``}},...D}),[e.indeterminate])}var Av=L.createContext(void 0);function jv(){let e=L.useContext(Av);if(e===void 0)throw Error(c(14));return e}var Mv=`data-parent`,Nv=L.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:c=!1,form:l,id:u,indeterminate:p=!1,inputRef:m,name:h,onCheckedChange:g,parent:v=!1,readOnly:b=!1,render:S,required:C=!1,uncheckedValue:w,value:E,nativeButton:te=!1,style:ne,...re}=e,{clearErrors:D}=se(),{disabled:O,name:k,setDirty:ce,setFilled:le,setFocused:me,setTouched:he,state:ge,validationMode:_e,validityData:ye,validation:A}=ue(),Se=wn(),{labelId:Ce,controlId:we,registerControlId:Te,getDescriptionProps:Ee}=ae(),De=En(),Oe=De?.parent,ke=Oe&&De.allValues,Ae=O||Se.disabled||De?.disabled||c,je=k??h,Me=E??je,Ne=ee(),Pe=ee(),Fe=we;ke?Fe=v?Pe:`${Oe.id}-${Me}`:u&&(Fe=u);let Ie={};ke&&(v?Ie=De.parent.getParentProps():Me&&(Ie=De.parent.getChildProps(Me)));let{checked:Le=n,indeterminate:Re=p,onCheckedChange:ze,...Be}=Ie,Ve=De?.value,He=De?.setValue,Ue=De?.defaultValue,We=L.useRef(null),Ge=f(()=>Symbol(`checkbox-control`)),Ke=L.useRef(!1),{getButtonProps:qe,buttonRef:Je}=x({disabled:Ae,native:te}),Ye=De?.validation??A,[j,Xe]=ve({controlled:Me&&Ve&&!v?Ve.includes(Me):Le,default:Me&&Ue&&!v?Ue.includes(Me):i,name:`Checkbox`,state:`checked`}),Ze=ke?!!Le:j,Qe=ke&&Re||p;T(()=>{Te!==pe&&(Ke.current=!0,Te(Ge.current,Fe))},[Fe,Te,Ge]),L.useEffect(()=>{let e=Ge.current;return()=>{!Ke.current||Te===pe||(Ke.current=!1,Te(e,void 0))}},[Te,Ge]),fe(We,Ne,j,void 0,!De&&!Ae,h);let $e=L.useRef(null),et=y(m,$e,Ye.inputRef,Ye.registerInput),tt=st(a,Ce,$e,!te,Fe??void 0);T(()=>{$e.current&&($e.current.indeterminate=Qe,j&&le(!0))},[j,Qe,le]),be(j,()=>{De||(D(je),le(j),ce(j!==ye.initialValue),Ye.change(j))});let nt=o({checked:j,disabled:Ae,form:l,name:v?void 0:je,id:te?void 0:Fe??void 0,required:C,ref:et,style:je?d:_,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(b){e.preventDefault();return}let t=e.currentTarget.checked,n=s(oe,e.nativeEvent);if(g?.(t,n),!n.isCanceled&&(ze?.(t,n),!n.isCanceled&&(Xe(t),Me&&Ve&&He&&!v&&!ke))){let e=t?[...Ve,Me]:Ve.filter(e=>e!==Me);He(e,n)}},onFocus(){We.current?.focus()}},E===void 0?ie:{value:(De?j&&E:E)||``},Ee,e=>Ye.getValidationProps(Ae,e));L.useEffect(()=>{if(!Oe||!Me)return;let e=Oe.disabledStatesRef.current;return e.set(Me,Ae),()=>{e.delete(Me)}},[Oe,Ae,Me]);let rt=L.useMemo(()=>({...ge,checked:Ze,disabled:Ae,readOnly:b,required:C,indeterminate:Qe}),[ge,Ze,Ae,b,C,Qe]),it=kv(rt),M=de(`span`,e,{state:rt,ref:[Je,We,t,De?.registerControlRef],props:[{id:te?Fe??void 0:Ne,role:`checkbox`,"aria-checked":Qe?`mixed`:Ze,"aria-readonly":b||void 0,"aria-required":C||void 0,"aria-labelledby":tt,[Mv]:v?``:void 0,onFocus(){Ae||me(!0)},onBlur(){let e=$e.current;e&&(he(!0),me(!1),_e===`onBlur`&&Ye.commit(De?Ve:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=$e.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),xe(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||Dv(t)?.click()})},onClick(e){if(b||Ae)return;e.preventDefault();let t=$e.current;t&&t.dispatchEvent(new(xe(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},re,Be,qe,Ee,e=>Ye.getValidationProps(Ae,e)],stateAttributesMapping:it});return(0,R.jsxs)(Av.Provider,{value:rt,children:[M,!j&&!De&&je&&!v&&w!==void 0&&(0,R.jsx)(`input`,{type:`hidden`,form:l,name:je,value:w,disabled:Ae}),(0,R.jsx)(`input`,{...nt,suppressHydrationWarning:!0})]})}),Pv=L.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=jv(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Ft(c),f=L.useRef(null),p={...s,transitionStatus:u};At({open:c,ref:f,onComplete(){c||d(!1)}});let m={...kv(s),...Mt,...D},h=a||l,g=de(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Fv({className:e,...t}){return(0,R.jsx)(Nv,{"data-slot":`checkbox`,className:u(`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,R.jsx)(Pv,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,R.jsx)(mt,{})})})}function Iv(e,t,n,r,i,a,o,s,c,l=2){let u=nn(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 xt(n.current,u)?void 0:u}var Lv=L.createContext(void 0),Rv=L.createContext(void 0),zv=L.createContext(void 0),Bv=L.createContext(!1),Vv=L.createContext(``);function Hv(){let e=L.useContext(Lv);if(!e)throw Error(c(22));return e}function Uv(){let e=L.useContext(Rv);if(!e)throw Error(c(23));return e}function Wv(){let e=L.useContext(zv);if(!e)throw Error(c(24));return e}function Gv(){return L.useContext(Vv)}function Kv(){return L.useContext(Bv)}var $={id:P(e=>e.id),labelId:P(e=>e.labelId),items:P(e=>e.items),selectedValue:P(e=>e.selectedValue),hasSelectionChips:P(e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:P(e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:P((e,t)=>t?Me(e.items):!1),open:P(e=>e.open),mounted:P(e=>e.mounted),forceMounted:P(e=>e.forceMounted),inline:P(e=>e.inline),activeIndex:P(e=>e.activeIndex),selectedIndex:P(e=>e.selectedIndex),isActive:P((e,t)=>e.activeIndex===t),isSelected:P((e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Te(t,e,n)):Te(t,r,n)}),transitionStatus:P(e=>e.transitionStatus),popupProps:P(e=>e.popupProps),inputProps:P(e=>e.inputProps),triggerProps:P(e=>e.triggerProps),itemProps:P(e=>e.itemProps),positionerElement:P(e=>e.positionerElement),listElement:P(e=>e.listElement),popupId:P(e=>e.popupId),triggerElement:P(e=>e.triggerElement),inputElement:P(e=>e.inputElement),inputGroupElement:P(e=>e.inputGroupElement),popupSide:P(e=>e.popupSide),openMethod:P(e=>e.openMethod),inputInsidePopup:P(e=>e.inputInsidePopup),inputOwnsFormValue:P(e=>e.inputOwnsFormValue),selectionMode:P(e=>e.selectionMode),name:P(e=>e.name),form:P(e=>e.form),disabled:P(e=>e.disabled),readOnly:P(e=>e.readOnly),required:P(e=>e.required),grid:P(e=>e.grid),virtualized:P(e=>e.virtualized),itemToStringLabel:P(e=>e.itemToStringLabel),isItemEqualToValue:P(e=>e.isItemEqualToValue),modal:P(e=>e.modal),autoHighlight:P(e=>e.autoHighlight),submitOnItemClick:P(e=>e.submitOnItemClick)};function qv(e){return e==null?void 0:`${e}-popup`}function Jv(e,t){return(n,r)=>{if(n==null)return!1;let i=Qe(n,t);return e.contains(i,r)}}function Yv(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;let a=Qe(r,t),o=n==null?``:Qe(n,t);return o&&e.contains(o,i)&&o.length===i.length?!0:e.contains(a,i)}}function Xv(e){return Array.isArray(e)?e.map(e=>Xv(e)).join(`,`):e==null?``:String(e)}var Zv=new Map;function Qv(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Xv(e.locale)}|${JSON.stringify(t)}`,r=Zv.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=Qe(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=Qe(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Qe(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Zv.set(n,a),a}var $v=Qv,ey=Symbol(`none`),ty={value:ey,index:-1};function ny(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:c,inputValue:u,open:p,defaultOpen:m=!1,selectionMode:g=`none`,onItemHighlighted:ee,name:b,form:x,disabled:S=!1,readOnly:C=!1,required:E=!1,inputRef:ne,grid:D=!1,items:O,filteredItems:ae,filter:le,openOnInputClick:de=!0,autoHighlight:me=!1,keepHighlight:he=!1,highlightItemOnHover:ye=!0,loopFocus:xe=!0,itemToStringLabel:A,itemToStringValue:Ee,isItemEqualToValue:De=we,virtualized:Oe=!1,inline:ke=!1,fillInputOnItemPress:je=!0,modal:Me=!1,limit:Pe=-1,autoComplete:Fe=`list`,formAutoComplete:Ie,locale:Le,submitOnItemClick:Re=!1}=e,{clearErrors:ze}=se(),{setDirty:Be,validityData:Ve,setFilled:He,name:Ue,disabled:Ge,setTouched:Ke,setFocused:qe,validationMode:Je,validation:Ye}=ue(),j=l(),Xe=_e({id:t}),Ze=$v({locale:Le}),[et,tt]=L.useState(!1),[nt,rt]=L.useState(null),it=L.useRef([]),M=L.useRef([]),at=L.useRef(null),ot=L.useRef(null),st=L.useRef(null),ct=L.useRef(null),lt=L.useRef(null),ut=L.useRef(!0),dt=L.useRef(!1),ft=L.useRef(null),pt=L.useRef(null),mt=L.useRef(null),ht=L.useRef(ty),gt=L.useRef(null),_t=L.useRef([]),vt=L.useRef([]),yt=Ge||S,bt=Ue??b,xt=g===`multiple`,St=g===`single`,Ct=u!==void 0||c!==void 0,wt=O!==void 0,Tt=ae!==void 0,Et;Et=me===`always`?`always`:me?`input-change`:!1;let[N,Ot]=ve({controlled:i,default:xt?r??ge:r,name:`Combobox`,state:`selectedValue`}),kt=L.useMemo(()=>le===null?()=>!0:le===void 0?St&&!et?Yv(Ze,A,N):Jv(Ze,A):le,[le,St,N,et,Ze,A]),jt=f(()=>Ct?c??``:St?Qe(N,A):``).current,[Mt,Nt]=ve({controlled:u,default:jt,name:`Combobox`,state:`inputValue`}),[Pt,It]=ve({controlled:p,default:m,name:`Combobox`,state:`open`}),Rt=Ce(O),P=nt??(Mt===``?``:String(Mt).trim()),zt=St?Qe(N,A):``,Ht=St&&!et&&P!==``&&zt!==``&&zt.length===P.length&&Ze.contains(zt,P),Ut=Ht?``:P,Wt=wt&&Tt&&Ht,Gt=L.useMemo(()=>O?Rt?O.flatMap(e=>e.items):O:ge,[O,Rt]),Jt=L.useMemo(()=>{if(ae&&!Wt)return ae;if(!O)return ge;if(Rt){let e=O,t=[],n=0;for(let r of e){if(Pe>-1&&n>=Pe)break;let e=Ut===``?r.items:r.items.filter(e=>kt(e,Ut,A));if(e.length===0)continue;let i=Pe>-1?Pe-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(Ut===``)return Pe>-1?Gt.slice(0,Pe):Gt;let e=[];for(let t of Gt){if(Pe>-1&&e.length>=Pe)break;kt(t,Ut,A)&&e.push(t)}return e},[ae,Wt,O,Rt,Ut,Pe,kt,A,Gt]),Yt=L.useMemo(()=>Rt?Jt.flatMap(e=>e.items):Jt,[Jt,Rt]),I=f(()=>new qt({id:Xe,labelId:void 0,selectedValue:N,open:Pt,filter:kt,query:P,items:O,selectionMode:g,listRef:it,labelsRef:M,popupRef:at,emptyRef:lt,inputRef:ot,startDismissRef:st,endDismissRef:ct,keyboardActiveRef:ut,chipsContainerRef:ft,clearRef:pt,valuesRef:_t,allValuesRef:vt,selectionEventRef:mt,name:bt,form:x,disabled:yt,readOnly:C,required:E,grid:D,isGrouped:Rt,virtualized:Oe,openOnInputClick:de,itemToStringLabel:A,isItemEqualToValue:De,modal:Me,autoHighlight:Et,submitOnItemClick:Re,hasInputValue:Ct,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:ke,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:ie,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:g===`none`,onOpenChangeComplete:n||pe,setOpen:pe,setInputValue:pe,setSelectedValue:pe,setIndices:pe,onItemHighlighted:pe,handleSelection:pe,forceMount:pe,requestSubmit:pe})).current,Xt=g===`none`?Mt:N,Zt=L.useMemo(()=>g===`none`?Xt:Array.isArray(N)?N.map(e=>Ne(e,Ee)):Ne(N,Ee),[Xt,Ee,g,N]),Qt=h(ee),$t=h(n),nn=F(I,$.activeIndex),rn=F(I,$.selectedIndex),an=F(I,$.positionerElement),on=F(I,$.listElement),cn=F(I,$.triggerElement),ln=F(I,$.inputElement),un=F(I,$.inputGroupElement),dn=F(I,$.inline),fn=F(I,$.inputInsidePopup),pn=F(I,$.inputOwnsFormValue),mn=Vt(cn),{mounted:hn,setMounted:gn,transitionStatus:_n}=Ft(Pt),{openMethod:vn,triggerProps:yn}=tn(Pt),bn=h(()=>Zt);fe(fn?mn:ot,Xe,Xt,bn,!yt,b);let xn=h(()=>{O?M.current=Yt.map(e=>Qe(e,A)):I.set(`forceMounted`,!0)}),Sn=L.useRef(N);T(()=>{N!==Sn.current&&xn()},[xn,N]);let Cn=h(e=>{I.update(e);let t=e.type||`none`;if(e.activeIndex!==void 0)if(e.activeIndex===null)ht.current!==ty&&(ht.current=ty,Qt(void 0,w(t,void 0,{index:-1})));else{let n=_t.current[e.activeIndex];ht.current={value:n,index:e.activeIndex},Qt(n,w(t,void 0,{index:e.activeIndex}))}}),wn=h((t,n)=>{if(dt.current=n.reason===te,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&&tt(!0),gt.current={hasQuery:e},e&&Et&&I.state.activeIndex==null&&I.set(`activeIndex`,0)}}Nt(t)}}),Tn=h((t,n)=>{if(Pt!==t&&(n.reason===`escape-key`&&wt&&Yt.length===0&&!I.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&xt&&fn&&!dn&&nt!==null&&(tt(!1),rt(null),Mt!==``&&wn(``,s(te,n.event))),!t&&et&&(St?(dn||rt(P),P===``&&tt(!1)):xt&&(dn||rt(P),fn&&Cn({activeIndex:null}),(!fn||dn)&&wn(``,s(te,n.event)))),It(t),!t&&fn&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(Ke(!0),qe(!1),Je===`onBlur`)))){let e=g===`none`?Mt:N;Ye.commit(e)}}),En=h((e,t)=>{a?.(e,t),!t.isCanceled&&(Ot(e),(g===`none`&&at.current&&je||St&&!I.state.inputInsidePopup)&&wn(Qe(e,A),s(t.reason,t.event)),St&&e!=null&&t.reason!==`input-change`&&et&&!dn&&rt(P))}),Dn=h((e,t)=>{let n=t;if(n===void 0){if(nn===null)return;n=_t.current[nn]}let r=ce(e),i=mt.current??e;mt.current=null;let a=s(v,i),o=r?.closest(`a`)?.getAttribute(`href`);if(o){o.startsWith(`#`)&&Tn(!1,a);return}if(xt){let e=Array.isArray(N)?N:[],t=Se(e,n,I.state.isItemEqualToValue)?We(e,n,I.state.isItemEqualToValue):[...e,n];if(En(t,a),a.isCanceled||!(ot.current&&ot.current.value.trim()!==``))return;I.state.inputInsidePopup?wn(``,s(te,a.event)):Tn(!1,a)}else{if(En(n,a),a.isCanceled)return;Tn(!1,a)}}),On=h(()=>{if(!I.state.submitOnItemClick)return;let e=Ye.inputRef.current?.form??I.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),kn=h(()=>{if(gn(!1),$t?.(!1),tt(!1),rt(null),Cn(g===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),xt&&ot.current&&ot.current.value!==``&&!dt.current&&wn(``,s(te)),St)if(I.state.inputInsidePopup)ot.current&&ot.current.value!==``&&wn(``,s(te));else{let e=Qe(N,A);ot.current&&ot.current.value!==e&&wn(e,s(e===``?te:oe))}}),An=L.useMemo(()=>dn&&an?{current:an.closest(`[role="dialog"]`)}:at,[dn,an]);At({enabled:!e.actionsRef,open:Pt,ref:An,onComplete(){Pt||kn()}}),L.useImperativeHandle(e.actionsRef,()=>({unmount:kn}),[kn]),T(function(){if(Pt||g===`none`)return;let e=O?Gt:vt.current;if(xt){let t=Array.isArray(N)?N:[],n=t[t.length-1],r=Ae(e,n,De);Cn({selectedIndex:r===-1?null:r})}else{let t=Ae(e,N,De);Cn({selectedIndex:t===-1?null:t})}},[Pt,N,O,g,Gt,xt,De,Cn]),T(()=>{O&&(_t.current=Yt,it.current.length=Yt.length)},[O,Yt]),T(()=>{let e=gt.current;if(e&&(e.hasQuery?Et&&I.set(`activeIndex`,0):Et===`always`&&I.set(`activeIndex`,0),gt.current=null),!Pt&&!dn)return;let t=wt||Tt?Yt:_t.current,n=I.state.activeIndex;if(n==null){if(Et===`always`&&t.length>0){I.set(`activeIndex`,0);return}ht.current!==ty&&(ht.current=ty,I.state.onItemHighlighted(void 0,w(oe,void 0,{index:-1})));return}if(n>=t.length){ht.current!==ty&&(ht.current=ty,I.state.onItemHighlighted(void 0,w(oe,void 0,{index:-1}))),I.set(`activeIndex`,null);return}let r=t[n],i=ht.current.value,a=i!==ey&&Te(r,i,I.state.isItemEqualToValue);(ht.current.index!==n||!a)&&(ht.current={value:r,index:n},I.state.onItemHighlighted(r,w(oe,void 0,{index:n})))},[nn,Et,Tt,wt,Yt,dn,Pt,I]),T(()=>{if(g===`none`){He(String(Mt)!==``);return}He(xt?Array.isArray(N)&&N.length>0:N!=null)},[He,g,Mt,N,xt]),L.useEffect(()=>{wt&&Et&&Yt.length===0&&Cn({activeIndex:null})},[wt,Et,Yt.length,Cn]);function jn(e){let t=Ve.initialValue;return Array.isArray(e)&&Array.isArray(t)?!$e(e,t,(e,t)=>Te(e,t,De)):e!==t}be(P,()=>{!Pt||P===``||P===String(jt)||tt(!0)}),be(N,()=>{if(g!==`none`&&(ze(bt),Be(jn(N)),Ye.change(N),St&&!Ct&&!fn)){let e=Qe(N,A);Mt!==e&&wn(e,s(oe))}}),be(Mt,()=>{g===`none`&&(ze(bt),Be(Mt!==Ve.initialValue),Ye.change(Mt))}),be(O,()=>{if(!St||Ct||fn||et)return;let e=Qe(N,A);Mt!==e&&wn(e,s(oe))});let Mn=Dt({open:dn?!0:Pt,onOpenChange:Tn,elements:{reference:fn?cn:ln,floating:an}}),Nn,Pn;dn||(Nn=D?`grid`:`listbox`,Pn=Pt?`true`:`false`);let Fn=L.useMemo(()=>{let e=ln?.tagName===`INPUT`,t=ln==null||e,n=t||Pt,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Pn,r[`aria-haspopup`]=Nn,r[`aria-controls`]=Pt?on?.id:void 0,r[`aria-autocomplete`]=Fe),{reference:r,floating:{role:`presentation`}}},[ln,Pt,Pn,Nn,on?.id,Fe]),In=sn(Mn,{enabled:!C&&!yt&&de,event:`mousedown-only`,toggle:!1,touchOpenDelay:fn?0:100,reason:re}),Ln=en(Mn,{enabled:!C&&!yt&&!dn,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:dn?!0:void 0,outsidePress(e){let t=ce(e);return!k(cn,t)&&!k(pt.current,t)&&!k(ft.current,t)&&!k(un,t)}}),Rn=Bt(Mn,{enabled:!C&&!yt,id:Xe,listRef:it,activeIndex:nn,selectedIndex:rn,virtual:!0,loopFocus:xe,allowEscape:xe&&!Et,focusItemOnOpen:et||g===`none`&&!Et?!1:`auto`,focusItemOnHover:ye,resetOnPointerLeave:!he,orientation:D?`horizontal`:void 0,rtl:j===`rtl`,disabledIndices:ge,grid:D?Iv:void 0,onNavigate(e,t){!t&&!Pt||_n===`ending`||Cn(t?{activeIndex:e,type:ut.current?`keyboard`:`pointer`}:{activeIndex:e})}}),zn=L.useMemo(()=>o(Rn.reference,{onKeyDown(e){D&&I.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Ln.reference,In.reference,Fn.reference),[Rn.reference,Ln.reference,In.reference,Fn.reference,D,I]),Bn=L.useMemo(()=>o(Kt,Rn.floating,Ln.floating,Fn.floating),[Rn.floating,Ln.floating,Fn.floating]),Vn=L.useMemo(()=>{let e=Rn.item;return e?{...e,onFocus:void 0}:ie},[Rn.item]);Lt(()=>{I.update({inline:ke,popupProps:Bn,inputProps:zn,triggerProps:yn,itemProps:Vn,setOpen:Tn,setInputValue:wn,setSelectedValue:En,setIndices:Cn,onItemHighlighted:Qt,handleSelection:Dn,forceMount:xn,requestSubmit:On})}),T(()=>{I.update({id:Xe,selectedValue:N,open:Pt,mounted:hn,transitionStatus:_n,items:O,inline:ke,popupProps:Bn,inputProps:zn,triggerProps:yn,openMethod:vn,itemProps:Vn,selectionMode:g,name:bt,form:x,disabled:yt,readOnly:C,required:E,grid:D,isGrouped:Rt,virtualized:Oe,onOpenChangeComplete:$t,openOnInputClick:de,itemToStringLabel:A,modal:Me,autoHighlight:Et,isItemEqualToValue:De,submitOnItemClick:Re,hasInputValue:Ct,requestSubmit:On,inputOwnsFormValue:g===`none`&&(ke||!I.state.inputInsidePopup)})},[I,Xe,N,Pt,hn,_n,O,Bn,zn,Vn,vn,yn,g,bt,yt,C,E,Ye,D,Rt,Oe,$t,de,A,Me,De,Re,Ct,ke,On,Et,x]);let Hn=y(ne,Ye.inputRef),Un=L.useMemo(()=>({query:P,hasItems:wt,filteredItems:Jt,flatFilteredItems:Yt}),[P,wt,Jt,Yt]),Wn=L.useMemo(()=>Array.isArray(Xt)?``:Ne(Xt,Ee),[Xt,Ee]),Gn=xt&&Array.isArray(N)&&N.length>0,Kn=xt||g===`none`&&pn?void 0:bt,qn=L.useMemo(()=>!xt||!Array.isArray(N)||!bt?null:N.map(e=>{let t=Ne(e,Ee);return(0,R.jsx)(`input`,{type:`hidden`,form:x,name:bt,value:t,disabled:yt},t)}),[xt,N,x,bt,Ee,yt]),Jn=(0,R.jsxs)(L.Fragment,{children:[e.children,(0,R.jsx)(`input`,{...Ye.getValidationProps(yt,{onFocus(){if(fn){cn?.focus();return}(ot.current||cn)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||yt||C)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=s(oe,e.nativeEvent),i=()=>_t.current.findIndex(e=>Ne(e,Ee).toLowerCase()===n||Qe(e,A).toLowerCase()===n);function a(){if(xt)return;if(g===`none`){wn(t,r);return}let e=i();e===-1&&(e=_t.current.findIndex((e,t)=>{let r=M.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:_t.current[e];a!=null&&En?.(a,r)}St&&(xn(),O&&i()===-1&&I.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Xe&&Kn==null?`${Xe}-hidden-input`:void 0,form:x,name:Kn,autoComplete:Ie,disabled:yt,required:E&&!Gn,readOnly:C,value:Wn,ref:Hn,style:Kn?d:_,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),qn]});return(0,R.jsx)(Lv.Provider,{value:I,children:(0,R.jsx)(Rv.Provider,{value:Mn,children:(0,R.jsx)(Bv.Provider,{value:wt,children:(0,R.jsx)(zv.Provider,{value:Un,children:(0,R.jsx)(Vv.Provider,{value:Mt,children:Jn})})})})})}var ry={...Zt,...D,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null},iy=2,ay=L.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:o=!1,id:c,style:l,...u}=e,{state:d,disabled:f,setTouched:m,setFocused:g,validationMode:ee,validation:_}=ue(),{labelId:v}=ae(),y=Hv(),{filteredItems:S}=Wv(),C=F(y,$.selectionMode),w=F(y,$.disabled),T=F(y,$.readOnly),E=F(y,$.required),te=F(y,$.mounted),ne=F(y,$.popupSide),re=F(y,$.positionerElement),D=F(y,$.listElement),O=F(y,$.popupId),ie=F(y,$.triggerProps),oe=F(y,$.triggerElement),se=F(y,$.inputInsidePopup),le=F(y,$.id),fe=F(y,$.labelId),pe=F(y,$.open),me=F(y,$.selectedValue),he=F(y,$.activeIndex),ge=F(y,$.selectedIndex),ve=F(y,$.hasSelectedValue),ye=Uv(),be=Gv(),xe=b(),A=f||w||o,Se=S.length===0,Ce=te&&re?ne:null;_e({id:se?c:void 0});let we=se?c??le:c,Te=Ie(v,fe),Ee;pe&&se?Ee=O??qv(le):pe&&(Ee=D?.id);let De=L.useRef(``);function Oe(e){De.current=e.pointerType}let ke=ye.useState(`domReferenceElement`);L.useEffect(()=>{se&&oe&&oe!==ke&&ye.set(`domReferenceElement`,oe)},[oe,ke,ye,se]);let{reference:Ae}=Yt(ye,{enabled:!pe&&!T&&!w&&C===`single`,listRef:y.state.labelsRef,activeIndex:he,selectedIndex:ge,onMatch(e){let t=y.state.valuesRef.current[e];t!==void 0&&y.state.setSelectedValue(t,s(`none`))}}),{reference:je}=sn(ye,{enabled:!T&&!w,event:`mousedown`}),{buttonRef:Me,getButtonProps:Ne}=x({native:i,disabled:A}),Pe={...d,open:pe,disabled:A,popupSide:Ce,listEmpty:Se,placeholder:C!==`none`&&!ve};return de(`button`,e,{ref:[t,Me,h(e=>{y.set(`triggerElement`,e)})],state:Pe,props:[ie,je,Ae,{id:we,tabIndex:se?0:-1,role:se?`combobox`:void 0,"aria-expanded":pe?`true`:`false`,"aria-haspopup":se?`dialog`:`listbox`,"aria-controls":Ee,"aria-required":se&&E||void 0,"aria-labelledby":Te,onPointerDown:Oe,onPointerEnter:Oe,onFocus(){g(!0),!(A||T)&&xe.start(0,y.state.forceMount)},onBlur(e){if(!k(re,e.relatedTarget)&&(m(!0),g(!1),ee===`onBlur`)){let e=C===`none`?be:me;_.commit(e)}},onMouseDown(e){if(A||T||(se||ye.set(`domReferenceElement`,e.currentTarget),y.state.forceMount(),De.current!==`touch`&&(y.state.inputRef.current?.focus(),se||e.preventDefault()),pe))return;let t=p(e.currentTarget);function n(e){if(!oe)return;let t=ce(e),n=y.state.positionerElement,r=y.state.listElement;if(k(oe,t)||k(n,t)||k(r,t)||t===oe)return;let i=Qt(oe),a=e.clientX>=i.left-iy&&e.clientX<=i.right+iy,o=e.clientY>=i.top-iy&&e.clientY<=i.bottom+iy;a&&o||y.state.setOpen(!1,s(`cancel-open`,e))}se&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){A||T||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(ht(e),y.state.setOpen(!0,s(a,e.nativeEvent)),y.state.inputRef.current?.focus())}},_?_.getValidationProps(A,u):u,Ne],stateAttributesMapping:ry})}),oy=L.createContext(void 0);function sy(){return L.useContext(oy)}var cy=L.createContext(void 0);function ly(e){let t=L.useContext(cy);if(t===void 0&&!e)throw Error(c(21));return t}var uy=L.forwardRef(function(e,t){let n=Hv(),{buttonRef:r,getButtonProps:i}=x({native:!1}),a=y(t,r);function o(e){n.state.setOpen(!1,s(E,e.nativeEvent,e.currentTarget))}return(0,R.jsx)(`span`,{ref:a,...i({onClick:o}),"aria-label":`Dismiss`,tabIndex:void 0,style:d})}),dy=L.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...c}=e,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:_,validation:v}=ue(),{labelId:y}=ae(),b=sy(),x=!!ly(!0),S=Hv(),{filteredItems:C}=Wv(),w=Gv(),T=l(),E=F(S,$.required),re=F(S,$.disabled),D=F(S,$.readOnly),O=F(S,$.name),ie=F(S,$.form),k=F(S,$.selectionMode),se=F(S,$.autoHighlight),ce=F(S,$.inputProps),fe=F(S,$.triggerProps),pe=F(S,$.open),ge=F(S,$.mounted),_e=F(S,$.selectedValue),ve=F(S,$.popupSide),ye=F(S,$.positionerElement),be=F(S,$.id),xe=F(S,$.inline),A=F(S,$.modal),Se=!!se,Ce=ge&&ye?ve:null,we=d||re||i,Te=C.length===0,Ee=x||xe,De=!Ee||A,Oe=ee(a??(Ee?void 0:be)),ke=Ie(y,void 0),Ae=x?le:u,[je,Me]=L.useState(null),Ne=L.useRef(!1),Pe=L.useRef(null),Fe=L.useRef(!1),Le=k===`none`&&!x,Re=h(e=>{let t=x||S.state.inline;t&&!S.state.hasInputValue&&S.state.setInputValue(``,s(oe)),S.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:Le})}),ze=x||!v?c:v.getValidationProps(we,c),Be={...Ae,open:pe,disabled:we,readOnly:D,popupSide:Ce,listEmpty:Te};function Ve(e){if(!b)return;let t,{highlightedChipIndex:n}=b,r=b.chipsRef.current.length,i=T===`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>=_e.length-1?_e.length-2:n;t=r>=0?r:void 0,S.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`})}return t}return e.key===a&&(e.currentTarget.selectionStart??0)===0&&_e.length>0?(e.preventDefault(),t=r>0?r-1:void 0):e.key===`Backspace`&&e.currentTarget.value===``&&_e.length>0&&(S.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`}),e.preventDefault()),t}let He=de(`input`,e,{state:Be,ref:[t,S.state.inputRef,Re],props:[ce,fe,{type:`text`,value:e.value??je??w,"aria-readonly":D||void 0,"aria-required":E||void 0,"aria-labelledby":ke,disabled:we,readOnly:D,required:k===`none`?E:void 0,form:ie,...Le&&O&&{name:O},id:Oe,onFocus(){if(p(!0),!xe||!Fe.current)return;Fe.current=!1;let e=Pe.current;e==null||!Object.hasOwn(S.state.valuesRef.current,e)||S.state.setIndices({activeIndex:e})},onBlur(){f(!0),p(!1);let e=S.state.activeIndex;if(xe&&e!==null&&se!==`always`&&(Pe.current=e,Fe.current=!0,S.state.setIndices({activeIndex:null})),_===`onBlur`){let e=k===`none`?w:_e;v.commit(e)}},onCompositionStart(e){gt||(Ne.current=!0,Me(e.currentTarget.value))},onCompositionEnd(e){Ne.current=!1;let t=e.currentTarget.value;Me(null),S.state.setInputValue(t,s(ne,e.nativeEvent))},onChange(e){let t=e.nativeEvent.inputType,n=!t||t===`insertReplacementText`,r=Ne.current||!n;if(Ne.current){let t=e.currentTarget.value;Me(t),t===``&&!S.state.openOnInputClick&&!S.state.inputInsidePopup&&S.state.setOpen(!1,s(te,e.nativeEvent));let n=t.trim(),i=Se&&n!==``;!D&&!we&&n&&r&&(S.state.setOpen(!0,s(ne,e.nativeEvent)),Se||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?`keyboard`:`pointer`})),pe&&S.state.activeIndex!==null&&!i&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?`keyboard`:`pointer`});return}let i=s(ne,e.nativeEvent);if(S.state.setInputValue(e.currentTarget.value,i),i.isCanceled)return;let a=e.currentTarget.value===``,o=s(te,e.nativeEvent);a&&!S.state.inputInsidePopup&&(k===`single`&&S.state.setSelectedValue(null,o),S.state.openOnInputClick||S.state.setOpen(!1,o));let c=e.currentTarget.value.trim();!D&&!we&&c&&r&&(S.state.setOpen(!0,s(ne,e.nativeEvent)),Se||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?`keyboard`:`pointer`})),pe&&S.state.activeIndex!==null&&!Se&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?`keyboard`:`pointer`})},onKeyDown(e){if(we||D||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;S.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=T===`rtl`;if(e.key===`Home`){ht(e);let n=g&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){ht(e);let i=g&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!ge&&e.key===`Escape`){let t=k===`multiple`&&Array.isArray(_e)?_e.length===0:_e===null,n=s(m,e.nativeEvent),r=k===`multiple`?[]:null;S.state.setInputValue(``,n),S.state.setSelectedValue(r,n),!t&&!S.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(b&&e.key===`Backspace`&&t.value===``&&b.highlightedChipIndex===void 0&&Array.isArray(_e)&&_e.length>0){let t=b.chipsRef.current.length,n=t>0?t-1:_e.length-1,r=_e.filter((e,t)=>t!==n);S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?`keyboard`:`pointer`}),S.state.setSelectedValue(r,s(oe,e.nativeEvent));return}let i=b?.highlightedChipIndex!==void 0,a=Ve(e);if(b?.setHighlightedChipIndex(a),a===void 0?i&&S.state.inputRef.current?.focus():b?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&pe){let t=S.state.activeIndex,n=e.nativeEvent;if(t===null){if(xe)return;S.state.setOpen(!1,s(oe,n));return}ht(e);let r=S.state.listRef.current[t];r&&(S.state.selectionEventRef.current=n,r.click(),S.state.selectionEventRef.current=null)}},onPointerMove(){S.state.keyboardActiveRef.current=!1},onPointerDown(){S.state.keyboardActiveRef.current=!1}},ze],stateAttributesMapping:ry}),Ue=x?(0,R.jsx)(me.Provider,{value:he,children:He}):He;return(0,R.jsxs)(L.Fragment,{children:[pe&&De&&(0,R.jsx)(uy,{ref:S.state.startDismissRef}),Ue]})}),fy={...Mt,...Wt},py=L.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:c,...l}=e,{disabled:u}=ue(),d=Hv(),f=F(d,$.selectionMode),p=F(d,$.disabled),m=F(d,$.readOnly),h=F(d,$.open),g=F(d,$.selectedValue),ee=F(d,$.hasSelectionChips),_=Gv(),v=!1;v=f===`none`?_!==``:f===`single`?g!=null:ee;let y=u||p||i,{buttonRef:b,getButtonProps:S}=x({native:a,disabled:y}),{mounted:w,transitionStatus:T,setMounted:E}=Ft(v),te={disabled:y,visible:v,open:h,transitionStatus:T};At({open:v,ref:d.state.clearRef,onComplete(){v||E(!1)}});let ne=de(`button`,e,{state:te,ref:[t,b,d.state.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(y||m)return;let t=d.state.keyboardActiveRef;d.state.setInputValue(``,s(C,e.nativeEvent)),f===`none`?d.state.setIndices({activeIndex:null,type:t.current?`keyboard`:`pointer`}):(d.state.setSelectedValue(Array.isArray(g)?[]:null,s(C,e.nativeEvent)),d.state.setIndices({activeIndex:null,selectedIndex:null,type:t.current?`keyboard`:`pointer`})),d.state.inputRef.current?.focus()}},l,S],stateAttributesMapping:fy});return o||w?ne:null}),my=L.createContext(null);function hy(){return L.useContext(my)}function gy(e){let{children:t}=e,{filteredItems:n}=Wv(),r=hy(),i=r?r.items:n;return i?(0,R.jsx)(L.Fragment,{children:i.map(t)}):null}var _y=L.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=Hv(),l=Uv(),u=!!ly(!0),{filteredItems:d,hasItems:f}=Wv(),p=F(c,$.selectionMode),m=F(c,$.grid),g=F(c,$.popupProps),ee=F(c,$.virtualized),_=F(c,$.forceMounted),v=p===`multiple`,y=d.length===0,b=h(e=>{c.set(`positionerElement`,e)}),x=h(e=>{c.set(`listElement`,e)}),S=L.useMemo(()=>typeof o==`function`?n||=(0,R.jsx)(gy,{children:o}):o,[o]),C={empty:y},w=l.useState(`floatingId`),T=de(`div`,e,{state:C,ref:[t,x,u?null:b],props:[g,{children:S,tabIndex:-1,id:w,role:m?`grid`:`listbox`,"aria-multiselectable":v?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;ht(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(ee)return T;let E=f&&!_?void 0:c.state.labelsRef;return(0,R.jsx)(Pt,{elementsRef:c.state.listRef,labelsRef:E,children:T})}),vy=``;function yy(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 by(){let e=b(),t=L.useRef(null);return L.useEffect(()=>{if(vt)return;let n=t.current;if(n==null)return;let r=yy(n);if(r==null)return;let i=r.nodeValue??``,a=`${i}${vy}`;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 xy=L.createContext(void 0);function Sy(){let e=L.useContext(xy);if(e===void 0)throw Error(c(20));return e}var Cy=L.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Hv(),a=F(i,$.mounted),o=F(i,$.forceMounted);return a||n||o?(0,R.jsx)(xy.Provider,{value:n,children:(0,R.jsx)(an,{ref:t,...r})}):null}),wy=L.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:m=!1,collisionAvoidance:g=pt,style:ee,..._}=e,v=Hv(),{filteredItems:y}=Wv(),b=Uv(),x=Sy(),S=F(v,$.modal),C=F(v,$.open),w=F(v,$.mounted),E=F(v,$.openMethod),te=F(v,$.positionerElement),ne=F(v,$.triggerElement),re=F(v,$.inputElement),D=F(v,$.inputGroupElement),O=F(v,$.inputInsidePopup),ie=F(v,$.transitionStatus),ae=y.length===0,k=ut({anchor:i??(O?ne:D??re),floatingRootContext:b,positionMethod:a,mounted:w,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:x,collisionAvoidance:g,lazyFlip:!0});jt(C&&S,E===`touch`,te,ne);let oe={open:C,side:k.side,align:k.align,anchorHidden:k.anchorHidden,empty:ae};T(()=>{v.set(`popupSide`,k.side)},[v,k.side]);let se=h(e=>{v.set(`positionerElement`,e)}),ce=wt(e,oe,{styles:k.positionerStyles,transitionStatus:ie,props:_,refs:[t,se],hidden:!w,inert:!C});return(0,R.jsxs)(cy.Provider,{value:k,children:[w&&S&&(0,R.jsx)(_t,{inert:Ct(!C),cutout:D??re??ne}),ce]})}),Ty={...Nt,...Mt},Ey=L.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Hv(),l=ly(),u=Uv(),{filteredItems:d}=Wv(),f=F(c,$.mounted),p=F(c,$.open),m=F(c,$.openMethod),h=F(c,$.transitionStatus),g=F(c,$.inputInsidePopup),ee=F(c,$.inputElement),_=F(c,$.modal),v=F(c,$.id),y=d.length===0,b=s.id??(g?qv(v):void 0);T(()=>(c.set(`popupId`,c.state.popupRef.current?.id||b),()=>{c.set(`popupId`,void 0)}),[c,b]),At({open:p,ref:c.state.popupRef,onComplete(){p&&c.state.onOpenChangeComplete(!0)}});let x=de(`div`,e,{state:{open:p,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:y},ref:[t,c.state.popupRef],props:[{id:b,role:g?`dialog`:`presentation`,tabIndex:-1,onFocus(e){let t=ce(e.nativeEvent);m!==`touch`&&(k(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},yt(h),s],stateAttributesMapping:Ty}),S=a===void 0?g?e=>e===`touch`?c.state.popupRef.current:ee:!1:a,C;C=o??(g?void 0:!1);let w=!g||_;return(0,R.jsx)(Ot,{context:u,disabled:!f,modal:w,openInteractionType:m,initialFocus:S,returnFocus:C,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,R.jsxs)(L.Fragment,{children:[x,w&&(0,R.jsx)(uy,{ref:c.state.endDismissRef})]})})}),Dy=L.createContext(void 0);function Oy(){let e=L.useContext(Dy);if(!e)throw Error(c(19));return e}var ky=L.createContext(!1);function Ay(){return L.useContext(ky)}var jy=e(i(),1);function My(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=L.useRef(!1),m=L.useRef(null),h=Rt({index:l,textRef:m,indexGuessBehavior:Ht.GuessFromOrder}),g=Hv(),ee=Ay(),_=Kv(),v=F(g,$.open),y=F(g,$.selectionMode),b=F(g,$.readOnly),S=F(g,$.isItemEqualToValue),C=y!==`none`,w=l??(r?i??-1:h.index),E=h.index!==-1,te=F(g,$.id),ne=F(g,$.isActive,w),re=F(g,$.isSelected,c),D=F(g,$.itemProps),O=L.useRef(null),ie=te!=null&&E?`${te}-${w}`:void 0,ae=re&&C;T(()=>{if(!(E&&(r||l!=null)))return;let e=g.state.listRef.current;return e[w]=O.current,()=>{delete e[w]}},[E,r,w,l,g]),T(()=>{if(!E||_)return;let e=g.state.valuesRef.current;return e[w]=c,y!==`none`&&g.state.allValuesRef.current.push(c),()=>{delete e[w]}},[E,_,w,c,g,y]),T(()=>{if(!v){p.current=!1;return}if(!E||_)return;let e=g.state.selectedValue,t=Array.isArray(e)?e[e.length-1]:e;Te(c,t,S)&&g.set(`selectedIndex`,w)},[E,_,v,g,w,c,S]);let{getButtonProps:k,buttonRef:oe}=x({disabled:u,focusableWhenDisabled:!0,native:d,composite:!0}),se={disabled:u,selected:ae,highlighted:ne};function ce(e){function t(){g.state.handleSelection(e,c)}g.state.submitOnItemClick?(jy.flushSync(t),g.state.requestSubmit()):t()}let le={id:ie,role:ee?`gridcell`:`option`,"aria-selected":C?ae:void 0,tabIndex:void 0,onPointerDownCapture(e){p.current=!0,e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){u||b||ce(e.nativeEvent)},onMouseUp(e){let t=p.current;p.current=!1,!(u||b||e.button!==0||t||!ne)&&ce(e.nativeEvent)}},ue=de(`div`,t,{ref:[oe,n,h.ref,O],state:se,props:[D,le,f,k]}),fe=L.useMemo(()=>({selected:ae,textRef:m}),[ae,m]);return(0,R.jsx)(Dy.Provider,{value:fe,children:ue})}function Ny(e){let{componentProps:t,forwardedRef:n}=e,r=F(Hv(),$.isItemEqualToValue),{flatFilteredItems:i}=Wv();return(0,R.jsx)(My,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:Ae(i,t.value??null,r)})}var Py=L.memo(L.forwardRef(function(e,t){let n=F(Hv(),$.virtualized);return n&&e.index==null?(0,R.jsx)(Ny,{componentProps:e,forwardedRef:t}):(0,R.jsx)(My,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),Fy=L.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=Wv(),c=Hv(),l=by(),u=s.length===0?a:null;return de(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function Iy(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,R.jsx)(ny,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var Ly=L.forwardRef(function(e,t){let n=e.keepMounted??!1,{selected:r}=Oy();return n||r?(0,R.jsx)(Ry,{...e,ref:t}):null}),Ry=L.memo(L.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Oy(),c=L.useRef(null),{transitionStatus:l,setMounted:u}=Ft(s),d=de(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:Mt});return At({open:s,ref:c,onComplete(){s||u(!1)}}),d})),zy=Iy;function By({className:e,children:t,...n}){return(0,R.jsxs)(ay,{"data-slot":`combobox-trigger`,className:u(`cursor-pointer data-disabled:cursor-not-allowed [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,R.jsx)(De,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function Vy({className:e,...t}){return(0,R.jsx)(py,{"data-slot":`combobox-clear`,render:(0,R.jsx)(He,{variant:`ghost`,size:`icon-xs`}),className:u(e),...t,children:(0,R.jsx)(Ue,{className:`pointer-events-none`})})}function Hy({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...a}){return(0,R.jsxs)(Ke,{className:u(`w-auto`,e),children:[(0,R.jsx)(dy,{render:(0,R.jsx)(Fe,{disabled:n}),...a}),(0,R.jsxs)(Je,{align:`inline-end`,children:[r&&(0,R.jsx)(He,{size:`icon-xs`,variant:`ghost`,render:(0,R.jsx)(By,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n}),i&&(0,R.jsx)(Vy,{disabled:n})]}),t]})}function Uy({className:e,side:t=`bottom`,sideOffset:n=6,align:r=`start`,alignOffset:i=0,anchor:a,...o}){return(0,R.jsx)(Cy,{children:(0,R.jsx)(wy,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:a,className:`isolate z-50`,children:(0,R.jsx)(Ey,{"data-slot":`combobox-content`,"data-chips":!!a,className:u(`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 Wy({className:e,...t}){return(0,R.jsx)(_y,{"data-slot":`combobox-list`,className:u(`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 Gy({className:e,children:t,...n}){return(0,R.jsxs)(Py,{"data-slot":`combobox-item`,className:u(`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,R.jsx)(Ly,{render:(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,R.jsx)(mt,{className:`pointer-events-none`})})]})}function Ky({className:e,...t}){return(0,R.jsx)(Fy,{"data-slot":`combobox-empty`,className:u(`hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex`,e),...t})}var qy=`cline.code.model-selection.v1`;function Jy(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 Yy(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:Jy(r.lastModelByProvider)}:{lastProvider:``,lastModelByProvider:Jy(n)}}catch{return t}}function Xy(){return typeof window>`u`?{lastProvider:``,lastModelByProvider:{}}:Yy(window.localStorage.getItem(qy))}var Zy={openai:`openai-native`,google:`gemini`};function Qy(e){let t=e.trim();return t?Zy[t]??t:``}function $y(e){return(e??[]).map(e=>e.id)}function eb(e){return(e??[]).filter(e=>e.supportsReasoning).map(e=>e.id)}function tb(e){return{providers:e,enabledProviderIds:e.filter(e=>e.enabled).map(e=>e.id),providerModels:Object.fromEntries(e.map(e=>[e.id,$y(e.modelList)])),providerReasoningModels:Object.fromEntries(e.map(e=>[e.id,eb(e.modelList)]))}}async function nb(){return tb((await M.invoke(`list_provider_catalog`)).providers??[])}async function rb(e){return(await M.invoke(`list_provider_models`,{provider:e})).models??[]}var ib=3e4,ab=null;async function ob(){let e=await M.invoke(`list_routine_schedules`);return{schedules:e.schedules??[],activeExecutions:e.activeExecutions??[],upcomingRuns:e.upcomingRuns??[],lastExecutions:e.lastExecutions??[]}}var sb={cline:[ev],anthropic:[`claude-sonnet-4-6`],"openai-native":[`gpt-5.3-codex`],openrouter:[`anthropic/claude-sonnet-4.6`],gemini:[`gemini-2.5-pro`]},cb=[{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 lb(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 ub(e){let t=e.metadata?.[Q_];return typeof t==`number`&&Number.isFinite(t)?t:void 0}function db(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 fb(e){return{provider:e.modelSelection?.providerId?.trim()||e.provider?.trim()||`cline`,model:e.modelSelection?.modelId?.trim()||e.model?.trim()||`anthropic/claude-sonnet-5`}}function pb(e){if(!e)return`-`;let t=e.status?.trim()||`unknown`,n=lb(e.endedAt??e.startedAt??e.triggeredAt);return n===`-`?t:`${t} at ${n}`}function mb(e){return typeof e==`string`?e.trim():``}function hb(e){let t=mb(e);if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<=0))return n}function gb(e){if(typeof e!=`string`)return;let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:void 0}function _b(e){let t=new Set(e);return cb.map(e=>e.value).filter(e=>t.has(e))}function vb(e,t,n){let r=_b(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===cb.length?`${s} ${o} * * *`:`${s} ${o} * * ${r.join(`,`)}`}function yb(e){let t=e?.trim().toUpperCase();if(!t||t===`*`)return cb.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=cb.findIndex(e=>e.value===r[1]),t=cb.findIndex(e=>e.value===r[2]);if(e>=0&&t>=e)for(let r=e;r<=t;r+=1)n.add(cb[r].value);continue}cb.some(e=>e.value===t)&&n.add(t)}return _b([...n])}function bb(e){let t=e.trim().split(/\s+/),n=Number.parseInt(t[0]??``,10),r=Number.parseInt(t[1]??``,10),i=yb(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 xb(){let[e,t]=(0,L.useState)(()=>ab?.schedules??[]),[n,r]=(0,L.useState)(()=>ab?.activeExecutions??[]),[i,a]=(0,L.useState)(()=>ab?.upcomingRuns??[]),[o,s]=(0,L.useState)(()=>ab?.lastExecutions??[]),[c,l]=(0,L.useState)(()=>!ab),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),[ee,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(!1),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(sb),[E,te]=(0,L.useState)(()=>Object.keys(sb)),[ne]=(0,L.useState)(()=>Xy()),re=Qy(ne.lastProvider),[D,ie]=(0,L.useState)({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:`cline`,model:ev,workspaceRoot:``,systemPrompt:``,timeoutSeconds:``,tags:``,enabled:!0}),ae=(0,L.useMemo)(()=>{if(E.length===0)return w;let e={};for(let t of E)e[t]=w[t]??[];return e},[E,w]),k=(0,L.useMemo)(()=>Object.keys(ae),[ae]),oe=(0,L.useMemo)(()=>ae[D.provider]??[],[D.provider,ae]),se=(0,L.useMemo)(()=>vb(D.scheduleDays,D.scheduleHour,D.scheduleMinute),[D.scheduleDays,D.scheduleHour,D.scheduleMinute]);(0,L.useEffect)(()=>{let e=!1;async function t(){try{let t=await nb();if(e)return;T(t.providerModels),te(e=>{let n=new Set(t.enabledProviderIds),r=Qy(D.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}},[D.provider]),(0,L.useEffect)(()=>{let e=Qy(D.provider);if(!e||(w[e]??[]).length>0)return;let t=!1;async function n(){try{let n=await rb(e);if(t||n.length===0)return;T(t=>({...t,[e]:n.map(e=>e.id)})),te(t=>t.includes(e)?t:[...t,e])}catch{}}return n(),()=>{t=!0}},[D.provider,w]),(0,L.useEffect)(()=>{if(k.length===0)return;let e=null,t=Qy(D.provider);if(k.includes(t)){let n=ae[t]??[];if(n.length===0||n.includes(D.model))return;let r=ne.lastModelByProvider[t]??ne.lastModelByProvider[ne.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]}}else{let t=re&&k.includes(re)?re:k[0],n=ae[t]??[],r=ne.lastModelByProvider[t]??ne.lastModelByProvider[ne.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]??``}}let n=window.setTimeout(()=>{ie(t=>({...t,...e}))},0);return()=>window.clearTimeout(n)},[k,D.model,D.provider,ne.lastModelByProvider,ne.lastProvider,re,ae]);let ce=(0,L.useCallback)(async e=>{let n=Date.now();if(!e?.force&&ab&&n-ab.fetchedAt<ib){t(ab.schedules),r(ab.activeExecutions),a(ab.upcomingRuns),s(ab.lastExecutions),f(null),l(!1);return}e?.showLoading!==!1&&l(!0),f(null);try{let e=await ob(),i=e.schedules,o=e.activeExecutions,c=e.upcomingRuns,l=e.lastExecutions;t(i),r(o),a(c),s(l),ab={schedules:i,activeExecutions:o,upcomingRuns:c,lastExecutions:l,fetchedAt:n}}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},[]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{ce()},0);return()=>window.clearTimeout(e)},[ce]);let le=async(e,t)=>{m(e.scheduleId),f(null);try{t?await M.invoke(`resume_routine_schedule`,{schedule_id:e.scheduleId}):await M.invoke(`pause_routine_schedule`,{schedule_id:e.scheduleId}),await ce({force:!0,showLoading:!1})}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},ue=async e=>{m(e),f(null);try{await M.invoke(`trigger_routine_schedule`,{schedule_id:e}),await ce({force:!0,showLoading:!1}),window.setTimeout(()=>{ce({force:!0,showLoading:!1})},1e3)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},de=async e=>{m(e),f(null);try{await M.invoke(`delete_routine_schedule`,{schedule_id:e}),g(null),await ce({force:!0,showLoading:!1})}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{m(null)}},fe=async()=>{y(null),f(null),C(null);let e={workspaceRoot:``,cwd:``};try{e=await M.invoke(`get_process_context`)}catch{}let t=re&&k.includes(re)?re:k[0]??`cline`,n=ae[t]??[],r=ne.lastModelByProvider[t]??ne.lastModelByProvider[ne.lastProvider],i=r&&n.includes(r)?r:n[0]??D.model;ie({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:t,model:i,workspaceRoot:e.workspaceRoot||e.cwd,systemPrompt:``,timeoutSeconds:``,tags:``,enabled:!0}),_(!0)},pe=e=>{if(e.cronPattern===`0`)return;let{provider:t,model:n}=fb(e),r=bb(e.cronPattern);y(e),f(null),C(null),te(e=>e.includes(t)?e:[...e,t]),T(e=>e[t]?.includes(n)?e:{...e,[t]:[...e[t]??[],n]}),ie({name:e.name,...r,prompt:e.prompt,provider:t,model:n,workspaceRoot:e.workspaceRoot??``,systemPrompt:e.systemPrompt??``,timeoutSeconds:typeof e.timeoutSeconds==`number`?String(e.timeoutSeconds):``,tags:e.tags?.join(`,`)??``,enabled:e.enabled}),_(!0)},me=async()=>{let e=mb(D.name);if(!e){C(`Routine name is required.`);return}let t=vb(D.scheduleDays,D.scheduleHour,D.scheduleMinute);if(!t){C(`Select at least one day and a valid time.`);return}let n=mb(D.prompt);if(!n){C(`Prompt is required.`);return}let r=mb(D.workspaceRoot);if(!r){C(`Workspace root is required.`);return}C(null),x(!0);try{let i=Qy(mb(D.provider))||k[0]||`cline`,a=mb(D.model)||(ae[i]??[])[0]||`anthropic/claude-sonnet-5`,o=mb(D.systemPrompt),s=hb(D.timeoutSeconds),c=gb(D.tags),l=v?`update_routine_schedule`:`create_routine_schedule`;await M.invoke(l,{...v?{schedule_id:v.scheduleId}:void 0,name:e,cron_pattern:t,prompt:n,provider:i,model:a,mode:v?.mode??`yolo`,workspace_root:r,cwd:v?v.cwd??null:r,system_prompt:v?o||null:o||void 0,timeout_seconds:v?s??null:s,max_parallel:1,enabled:D.enabled,tags:c??[]}),await ce({force:!0,showLoading:!1}),_(!1),y(null)}catch(e){let t=e instanceof Error?e.message:String(e);C(t)}finally{x(!1)}},he=(0,L.useMemo)(()=>{let e=new Map;for(let t of n)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[n]),ge=(0,L.useMemo)(()=>{let e=new Map;for(let t of o)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[o]),_e=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]);return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`Scheduled jobs are run through the hub.`,title:`Schedules`,meta:(0,R.jsx)(zt,{children:`cline schedule`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>void ce(),disabled:c,children:(0,R.jsx)(nt,{className:u(`h-4 w-4`,c&&`animate-spin`)})}),(0,R.jsxs)(A,{size:`sm`,onClick:()=>void fe(),children:[(0,R.jsx)(Oe,{className:`h-4 w-4`}),`New Schedule`]})]})}),d&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),c?(0,R.jsx)(Et,{children:`Loading schedules...`}):_e.length===0?(0,R.jsx)(Et,{children:`No schedules found. Create a schedule to run routines on a recurring basis.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:_e.map(e=>{let t=p===e.scheduleId,n=he.get(e.scheduleId),r=ge.get(e.scheduleId),a=i.find(t=>t.scheduleId===e.scheduleId);return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(Ee,{className:u(`h-2.5 w-2.5 shrink-0`,e.enabled?`fill-primary text-primary`:`fill-muted-foreground/40 text-muted-foreground/40`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.mode}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.cronPattern===`0`?`Once · ${lb(ub(e))}`:e.cronPattern}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`View ${e.name}`,onClick:()=>{window.alert(JSON.stringify(e,null,2))},children:(0,R.jsx)(gn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>pe(e),disabled:t||e.cronPattern===`0`,children:(0,R.jsx)(cn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run ${e.name} now`,onClick:()=>void ue(e.scheduleId),disabled:t,children:(0,R.jsx)(rt,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":e.enabled?`Pause ${e.name}`:`Resume ${e.name}`,onClick:()=>void le(e,!e.enabled),disabled:t,children:e.enabled?(0,R.jsx)(xn,{className:`h-3.5 w-3.5`}):(0,R.jsx)(ot,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(A,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>g(e),disabled:t,children:(0,R.jsx)(ye,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(lt,{checked:e.enabled,onCheckedChange:t=>void le(e,t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`ID:`}),` `,e.scheduleId]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Prompt:`}),` `,e.prompt]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Model:`}),` `,db(e)]}),e.workspaceRoot&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Workspace:`}),` `,e.workspaceRoot]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last run:`}),` `,lb(e.lastRunAt)]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last result:`}),` `,pb(r)]}),r?.sessionId&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last session:`}),` `,r.sessionId]}),r?.errorMessage&&(0,R.jsxs)(`p`,{className:`text-destructive`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last error:`}),` `,r.errorMessage]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Next run:`}),` `,lb(e.nextRunAt||a?.nextRunAt)]}),n&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Active:`}),` `,n.executionId,` since`,` `,lb(n.startedAt)]}),e.tags&&e.tags.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Tags:`}),` `,e.tags.join(`, `)]})]})]},e.scheduleId)})}),(0,R.jsx)(It,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,R.jsxs)(on,{children:[(0,R.jsxs)(bt,{children:[(0,R.jsx)(ft,{children:`Delete Routine`}),(0,R.jsxs)(N,{children:[`This will delete "`,h?.name??`this routine`,`" and remove future scheduled runs.`]})]}),(0,R.jsxs)(rn,{children:[(0,R.jsx)($t,{disabled:h?p===h.scheduleId:!1,children:`Cancel`}),(0,R.jsx)(Tt,{disabled:!h||p===h.scheduleId,onClick:()=>{h&&de(h.scheduleId)},variant:`destructive`,children:`Delete`})]})]})}),(0,R.jsx)(Le,{open:ee,onOpenChange:e=>{_(e),e||(C(null),y(null))},children:(0,R.jsxs)(Ge,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(ze,{children:[(0,R.jsx)(qe,{children:v?`Edit Routine`:`Create Routine`}),(0,R.jsx)(Xe,{children:v?`Update this scheduler routine.`:`Create a scheduler routine.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(j,{htmlFor:`routine-name`,children:`Name`}),(0,R.jsx)(O,{id:`routine-name`,value:D.name,onChange:e=>ie(t=>({...t,name:e.target.value})),placeholder:`Daily code review`})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2 space-y-3`,children:[(0,R.jsx)(j,{children:`Schedule`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 rounded-md border border-border p-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{htmlFor:`routine-hour`,children:`Hour`}),(0,R.jsxs)(Ve,{value:D.scheduleHour,onValueChange:e=>ie(t=>({...t,scheduleHour:e??t.scheduleHour})),children:[(0,R.jsx)(Ze,{className:`w-full`,id:`routine-hour`,children:(0,R.jsx)(et,{placeholder:`Hour`})}),(0,R.jsx)(Be,{children:Array.from({length:24},(e,t)=>t).map(e=>(0,R.jsx)(Pe,{value:`${e}`,children:e.toString().padStart(2,`0`)},`hour-${e}`))})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{htmlFor:`routine-minute`,children:`Minute`}),(0,R.jsxs)(Ve,{value:D.scheduleMinute,onValueChange:e=>ie(t=>({...t,scheduleMinute:e??t.scheduleMinute})),children:[(0,R.jsx)(Ze,{className:`w-full`,id:`routine-minute`,children:(0,R.jsx)(et,{placeholder:`Minute`})}),(0,R.jsx)(Be,{children:Array.from({length:60},(e,t)=>t).map(e=>(0,R.jsx)(Pe,{value:`${e}`,children:e.toString().padStart(2,`0`)},`minute-${e}`))})]})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(j,{children:`Days of week`}),(0,R.jsx)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-4`,children:cb.map(e=>{let t=`routine-day-${e.value.toLowerCase()}`;return(0,R.jsxs)(j,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-sm`,htmlFor:t,children:[(0,R.jsx)(Fv,{checked:D.scheduleDays.includes(e.value),id:t,onCheckedChange:t=>ie(n=>{let r=new Set(n.scheduleDays);return t===!0?r.add(e.value):r.delete(e.value),{...n,scheduleDays:_b([...r])}})}),e.label]},e.value)})})]}),(0,R.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,R.jsx)(`span`,{className:`font-mono text-foreground`,children:se||`Select one or more days`})]})]})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(j,{htmlFor:`routine-prompt`,children:`Prompt`}),(0,R.jsx)(Ye,{id:`routine-prompt`,value:D.prompt,onChange:e=>ie(t=>({...t,prompt:e.target.value})),rows:4})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{children:`Provider`}),(0,R.jsxs)(zy,{items:k,onValueChange:e=>{if(!e)return;let t=ae[e]??[],n=ne.lastModelByProvider[e],r=n&&t.includes(n)?n:t[0]??``;ie(t=>({...t,provider:e,model:r}))},value:D.provider,children:[(0,R.jsx)(Hy,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,R.jsxs)(Uy,{children:[(0,R.jsx)(Ky,{children:`No providers found.`}),(0,R.jsx)(Wy,{children:e=>(0,R.jsx)(Gy,{value:e,children:e},e)})]})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{children:`Model`}),(0,R.jsxs)(zy,{items:oe,onValueChange:e=>{e&&ie(t=>({...t,model:e}))},value:D.model,children:[(0,R.jsx)(Hy,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,R.jsxs)(Uy,{children:[(0,R.jsx)(Ky,{children:`No models found.`}),(0,R.jsx)(Wy,{children:e=>(0,R.jsx)(Gy,{value:e,children:e},e)})]})]})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(j,{htmlFor:`routine-workspace`,children:`Workspace root`}),(0,R.jsx)(O,{id:`routine-workspace`,value:D.workspaceRoot,onChange:e=>ie(t=>({...t,workspaceRoot:e.target.value}))})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(j,{htmlFor:`routine-system-prompt`,children:`System prompt (optional)`}),(0,R.jsx)(Ye,{id:`routine-system-prompt`,value:D.systemPrompt,onChange:e=>ie(t=>({...t,systemPrompt:e.target.value})),rows:3})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{htmlFor:`routine-timeout`,children:`Timeout seconds (optional)`}),(0,R.jsx)(O,{id:`routine-timeout`,value:D.timeoutSeconds,onChange:e=>ie(t=>({...t,timeoutSeconds:e.target.value})),placeholder:`3600`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(j,{htmlFor:`routine-tags`,children:`Tags (comma-separated, optional)`}),(0,R.jsx)(O,{id:`routine-tags`,value:D.tags,onChange:e=>ie(t=>({...t,tags:e.target.value})),placeholder:`automation,review`})]})]}),S&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:S}),(0,R.jsxs)(Re,{children:[(0,R.jsx)(A,{variant:`outline`,onClick:()=>_(!1),disabled:b,children:`Cancel`}),(0,R.jsx)(A,{onClick:()=>void me(),disabled:b,children:b?v?`Saving...`:`Creating...`:v?`Save Changes`:`Create Schedule`})]})]})})]})}function Sb(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 Cb(e){let t={};for(let[n,r]of Object.entries(e))Sb(t,n,r);return t}var wb=[`General`,`Providers`,`MCP`,`Channels`,`Schedules`,`Account`],Tb=6e4,Eb=null;function Db({chrome:e=`full`,initialSection:t=`General`,onClose:n,onNavigateSection:r}){let[i,a]=(0,L.useState)(t),[o,s]=(0,L.useState)(!0),[c,l]=(0,L.useState)(()=>Eb?.providers??[]),[d,f]=(0,L.useState)(()=>!Eb),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)({}),[ee,_]=(0,L.useState)({}),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),w=(0,L.useCallback)(e=>{l(t=>{let n=typeof e==`function`?e(t):e;return Eb={providers:n,fetchedAt:Date.now()},n})},[]),T=(0,L.useCallback)(async()=>{if(Eb&&Date.now()-Eb.fetchedAt<Tb){l(Eb.providers),f(!1),m(null);return}f(!0),m(null);try{let e=await M.invoke(`list_provider_catalog`);w(e.providers)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),l([])}finally{f(!1)}},[w]);(0,L.useEffect)(()=>{if(i!==`Providers`)return;let e=window.setTimeout(()=>{T()},0);return()=>window.clearTimeout(e)},[i,T]);let E=(0,L.useCallback)(async(e,t)=>{try{await M.invoke(`save_provider_settings`,{provider:e,enabled:t.enabled,api_key:t.apiKey,base_url:t.baseUrl,settings:t.configValues?Cb(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}`)}},[]),te=(0,L.useCallback)(e=>{w(t=>t.map(t=>{if(t.id!==e)return t;let n=!t.enabled;return E(e,{enabled:n}),{...t,enabled:n}}))},[E,w]),ne=(0,L.useCallback)((e,t)=>{w(n=>n.map(n=>n.id===e?{...n,...t,configValues:t.configValues?{...n.configValues??{},...t.configValues}:n.configValues}:n)),E(e,{apiKey:t.apiKey,baseUrl:t.baseUrl,configValues:t.configValues})},[E,w]),re=(0,L.useCallback)(async e=>{g(t=>({...t,[e]:!0})),_(t=>({...t,[e]:null}));try{let t=await M.invoke(`list_provider_models`,{provider:e});w(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);_(t=>({...t,[e]:n}))}finally{g(t=>({...t,[e]:!1}))}},[w]),D=c.filter(e=>e.enabled),O=b?c.find(e=>e.id===b)??null:null,ie=e=>e.capabilities?.includes(`oauth`)??!1,ae=async e=>{y(e);try{let t=await M.invoke(`run_provider_oauth_login`,{provider:e});w(n=>n.map(n=>n.id===e?{...n,enabled:!0,oauthAccessTokenPresent:t.accessToken.trim().length>0}:n)),x(e)}catch(t){let n=t instanceof Error?t.message:String(t);window.alert(`Failed to sign in to ${e}: ${n}`)}finally{y(null)}},k=e=>{a(`Providers`),r?.(`Providers`),x(e)};(0,L.useEffect)(()=>{if(!b)return;let e=c.find(e=>e.id===b);if(!e||(e.modelList?.length??0)>0)return;let t=window.setTimeout(()=>{re(b)},0);return()=>window.clearTimeout(t)},[re,c,b]);let oe=()=>{r?.(`Providers`),x(null),C(!1)},se=(0,L.useCallback)(async e=>{await M.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 T(),C(!1),x(e.providerId)},[T]),ce=()=>{r?.(`Providers`),x(null),C(!0)},le=e=>{a(e),r?.(e),x(null),C(!1)},ue=S?(0,R.jsx)(Rn,{existingProviderIds:c.map(e=>e.id),onBack:oe,onSave:se}):d?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading providers...`})}):p?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsxs)(`p`,{className:`max-w-xl px-4 text-center text-sm text-destructive`,children:[`Failed to load providers: `,p]})}):O?(0,R.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,R.jsx)(ir,{onAddProvider:ce,onConfigure:k,onToggle:te,providers:c,selectedProviderId:O.id,variant:`panel`}),(0,R.jsx)(`aside`,{className:`min-h-0 overflow-hidden border-l bg-background max-[1100px]:border-l-0 max-[1100px]:border-t`,children:(0,R.jsx)(ar,{modelsError:ee[O.id]??null,modelsLoading:h[O.id]??!1,oauthLoginPending:v===O.id,onBack:oe,onLoadModels:()=>void re(O.id),onOAuthLogin:ie(O)?()=>void ae(O.id):void 0,onUpdate:e=>ne(O.id,e),provider:O,variant:`panel`})})]}):(0,R.jsx)(ir,{onAddProvider:ce,onConfigure:k,onToggle:te,providers:c}),de=i===`Providers`?ue:i===`MCP`?(0,R.jsx)(er,{}):i===`Channels`?(0,R.jsx)(qn,{}):i===`Schedules`?(0,R.jsx)(xb,{}):i===`Account`?(0,R.jsx)(In,{}):i===`General`?(0,R.jsx)(Ob,{}):(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i,` settings coming soon.`]})});return e===`content`?(0,R.jsx)(`div`,{className:`h-full overflow-hidden bg-background`,children:de}):(0,R.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border px-6 py-3`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Settings`}),(0,R.jsx)(A,{"aria-label":`Close settings`,className:`justify-start`,onClick:n,variant:`ghost`,children:(0,R.jsx)(Ue,{className:`size-3`})})]}),(0,R.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,R.jsx)(`nav`,{className:`w-56 shrink-0 border-r border-border`,children:(0,R.jsx)(kt,{className:`h-full`,children:(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5 p-3`,children:wb.map(e=>e===`Providers`?(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(A,{className:u(`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:()=>{le(`Providers`),s(e=>!e)},variant:`ghost`,children:[(0,R.jsx)(`span`,{children:`Providers`}),o?(0,R.jsx)(De,{className:`size-3`}):(0,R.jsx)(dn,{className:`size-3`})]}),o&&(0,R.jsx)(`div`,{className:`ml-3 mt-0.5 flex flex-col gap-0.5 border-l border-border pl-2`,children:D.map(e=>(0,R.jsx)(A,{className:u(`justify-start`,b===e.id?`bg-accent/80 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/30`),disabled:v===e.id,onClick:()=>k(e.id),variant:`ghost`,children:(0,R.jsx)(`span`,{className:`truncate`,children:e.name})},e.id))})]},e):(0,R.jsx)(A,{className:u(`justify-start`,i===e&&!b?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>{le(e)},variant:`ghost`,children:e},e))})})}),(0,R.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:de})]})]})}function Ob(){let[e,t]=(0,L.useState)(()=>typeof window>`u`?`light`:Xt()??Ut()),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(!0),[f,p]=(0,L.useState)(!0),[m,h]=(0,L.useState)(!1),[g,ee]=(0,L.useState)(null),_=(0,L.useCallback)(async()=>{a(!0),l(null),p(!0),ee(null);try{let e=await M.invoke(`get_global_settings`);r(e.telemetryOptOut),d(e.autoUpdateEnabled)}catch(e){let t=e instanceof Error?e.message:String(e);l(t),ee(t)}finally{a(!1),p(!1)}},[]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{_()},0);return()=>window.clearTimeout(e)},[_]);let v=async e=>{let t=n;r(e),s(!0),l(null);try{let t=await M.invoke(`set_telemetry_opt_out`,{telemetry_opt_out:e});r(t.telemetryOptOut)}catch(e){let n=e instanceof Error?e.message:String(e);r(t),l(n)}finally{s(!1)}},y=async e=>{let t=u;d(e),h(!0),ee(null);try{let t=await M.invoke(`set_auto_update_enabled`,{auto_update_enabled:e});d(t.autoUpdateEnabled)}catch(e){let n=e instanceof Error?e.message:String(e);d(t),ee(n)}finally{h(!1)}};return(0,R.jsxs)(Gt,{children:[(0,R.jsx)(I,{description:`Manage Hub preferences for this browser and CLI environment.`,title:`Settings`}),(0,R.jsxs)(`section`,{className:`max-w-[86rem]`,children:[(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Dark mode`}),(0,R.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Keep the Hub interface in dark mode on this browser.`})]}),(0,R.jsx)(lt,{"aria-label":`Dark mode`,checked:e===`dark`,onCheckedChange:e=>{t(Jt(e?`dark`:`light`)),window.dispatchEvent(new Event(`cline-hub-theme-change`))}})]}),(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Auto update`}),(0,R.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Automatically install CLI updates on startup.`}),g?(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update auto update setting: `,g]}):null]}),(0,R.jsx)(lt,{"aria-label":`Auto update`,checked:u,disabled:f||m,onCheckedChange:e=>void y(e)})]}),(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Telemetry`}),(0,R.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Enable error and usage report to help us improve Cline.`}),c?(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update telemetry setting: `,c]}):null]}),(0,R.jsx)(lt,{"aria-label":`Telemetry`,checked:!n,disabled:i||o,onCheckedChange:e=>void v(!e)})]})]})]})}export{Db as SettingsView};
|
|
76
|
+
The run_commands tool remains available in plan mode strictly for read-only inspection -- listing files, searching (grep), reading configs, inspecting git history and diffs, checking tool versions, and the like. Never use it to change anything: no creating, modifying, or deleting files, no writing scripts that make changes, and no state-changing commands (installs, migrations, database or schema changes, container commands that mutate state, etc.). File-editing commands (rm/mv/cp, in-place edits like sed -i, output redirection to files outside /tmp, git commands that change the working tree, package installs) are hard-blocked in plan mode: they are not executed and return a tool error instead, so do not attempt them. If the task requires a mutation, put it in the plan; it happens only after the user switches to act mode.`;`${$_}`,`${$_}`;var ev=`anthropic/claude-sonnet-5`,tv=Z({models:X(Z({id:q(),temperature:J().optional(),maxTokens:J().optional(),contextWindow:J().optional(),inputPrice:J().optional(),outputPrice:J().optional(),supportsImages:Y().optional()})).optional(),openAiBaseUrl:q().optional(),openAiHeaders:eg(q(),q()).optional(),azureApiVersion:q().optional(),azureIdentity:Y().optional()}),nv=Z({id:q(),thinkingBudgetTokens:J().optional()}),rv=Z({name:q(),baseModelId:q(),thinkingBudgetTokens:J().optional()}),iv=Z({models:X(nv).optional(),customModels:X(rv).optional(),awsRegion:q().optional(),awsUseCrossRegionInference:Y().optional(),awsUseGlobalInference:Y().optional(),awsBedrockUsePromptCache:Y().optional(),awsBedrockEndpoint:q().optional()}),av=Z({models:X(Z({id:q()})).optional()}),ov=Z({models:X(Z({id:q(),thinkingBudgetTokens:J().optional()})).optional(),vertexProjectId:q().optional(),vertexRegion:q().optional()}),sv=Z({models:X(Z({id:q(),thinkingBudgetTokens:J().optional(),promptCachingEnabled:Y().optional()})).optional(),baseUrl:q().optional()}),cv=Z({models:X(Z({id:q(),thinkingBudgetTokens:J().optional()})).optional(),baseUrl:q().optional()}),lv=Z({OpenAiCompatible:tv.optional(),AwsBedrock:iv.optional(),Cline:av.optional(),Vertex:ov.optional(),LiteLLM:sv.optional(),Anthropic:cv.optional()}),uv=Z({id:q()}),dv=Z({name:q(),url:q(),alwaysEnabled:Y().optional(),headers:eg(q(),q()).optional()}),fv=Z({alwaysEnabled:Y(),name:q(),contents:q()}),pv=Z({bucket:q(),accessKeyId:q(),secretAccessKey:q(),region:q().optional(),endpoint:q().optional(),accountId:q().optional()}),mv=Z({promptUploading:Z({enabled:Y().optional(),type:Wh([dg(`s3_access_keys`),dg(`r2_access_keys`),dg(`azure_access_keys`)]).optional(),s3AccessSettings:pv.optional(),r2AccessSettings:pv.optional(),azureAccessSettings:pv.optional()}).optional()});Z({version:q(),providerSettings:lv.optional(),telemetryEnabled:Y().optional(),kanbanEnabled:Y().optional(),mcpMarketplaceEnabled:Y().optional(),allowedMCPServers:X(uv).optional(),remoteMCPServers:X(dv).optional(),blockPersonalRemoteMCPServers:Y().optional(),yoloModeAllowed:Y().optional(),openTelemetryEnabled:Y().optional(),openTelemetryMetricsExporter:q().optional(),openTelemetryLogsExporter:q().optional(),openTelemetryOtlpProtocol:q().optional(),openTelemetryOtlpEndpoint:q().optional(),openTelemetryOtlpHeaders:eg(q(),q()).optional(),openTelemetryOtlpMetricsProtocol:q().optional(),openTelemetryOtlpMetricsEndpoint:q().optional(),openTelemetryOtlpMetricsHeaders:eg(q(),q()).optional(),openTelemetryOtlpLogsProtocol:q().optional(),openTelemetryOtlpLogsEndpoint:q().optional(),openTelemetryOtlpLogsHeaders:eg(q(),q()).optional(),openTelemetryMetricExportInterval:J().optional(),openTelemetryOtlpInsecure:Y().optional(),openTelemetryLogBatchSize:J().optional(),openTelemetryLogBatchTimeout:J().optional(),openTelemetryLogMaxQueueSize:J().optional(),enterpriseTelemetry:mv.optional(),globalRules:X(fv).optional(),globalWorkflows:X(fv).optional()}),eg(q(),q()),T_.enum([`reasoning`,`prompt-cache`,`tools`,`provider-tools`,`oauth`,`temperature`,`files`,`streaming`,`vision`,`computer-use`,`local-auth`,`popular`]),T_.enum([`anthropic`,`gemini`,`openai-chat`,`openai-responses`,`openai-r1`,`ai-sdk`]),T_.enum([`anthropic`,`ai-sdk`,`ai-sdk-community`,`openai`,`openai-compatible`,`openai-r1`,`gemini`,`bedrock`,`custom`,`fetch`,`vertex`]);var hv=Z({rootPath:q().min(1),hint:q().min(1).optional(),associatedRemoteUrls:X(q().min(1)).optional(),latestGitCommitHash:q().min(1).optional(),latestGitBranchName:q().min(1).optional()});Z({currentWorkspacePath:q().min(1).optional(),workspaces:eg(q().min(1),hv)});var gv=[`current_state`,`boundary_analysis`,`interface_proposal`],_v=s_(e=>e instanceof Date?e.toISOString():e,q().datetime()),vv=cg([`pending`,`in_progress`,`blocked`,`completed`]),yv=cg([`queued`,`running`,`completed`,`failed`,`cancelled`,`interrupted`]),bv=cg([`draft`,`in_review`,`finalized`]),xv=Z({agentId:q(),role:cg([`lead`,`teammate`]),description:q().optional(),status:cg([`idle`,`running`,`stopped`])});Z({agentId:q(),rolePrompt:q(),modelId:q().optional(),maxIterations:J().optional()});function Sv(e){return s_(e=>e===null?void 0:e,e.optional())}Z({agentId:q().min(1).describe(`Teammate identifier`),rolePrompt:q().min(1).describe(`System prompt describing teammate role`)}).strict(),Z({agentId:q().min(1).describe(`Teammate identifier`),reason:Sv(q().min(1)).describe(`Optional shutdown reason`)}),Z({});var Cv={create:[`title`,`description`],list:[],claim:[`taskId`],complete:[`taskId`,`summary`],block:[`taskId`,`reason`]};Z({action:cg([`create`,`list`,`claim`,`complete`,`block`]),title:Sv(q().min(1)).describe(`Task title`),description:Sv(q().min(1)).describe(`Task details`),dependsOn:Sv(X(q().describe(`Dependency task ID`))).describe(`Array of dependency task IDs`),assignee:Sv(q().min(1)).describe(`Optional assignee`),status:Sv(cg([`pending`,`in_progress`,`blocked`,`completed`])).describe(`Optional task status filter`),taskId:Sv(q()).describe(`Task ID`),summary:Sv(q().min(1)).describe(`Completion summary`),reason:Sv(q().min(1)).describe(`Blocking reason`)}).superRefine((e,t)=>{for(let n of Cv[e.action])e[n]===void 0&&t.addIssue({code:`custom`,path:[n],message:`Field "${n}" is required when action=${e.action}`})}),Z({agentId:q().describe(`Teammate agent ID`),task:q().min(1).describe(`Task instructions for the teammate`),taskId:Sv(q()).describe(`Optional shared task list ID`),runMode:Sv(cg([`sync`,`async`])).describe(`Execution mode: 'sync' blocks until the teammate finishes and returns the result (default if omitted); 'async' queues the run and returns a runId immediately — use team_await_runs to collect results later.`),continueConversation:Sv(Y()).describe(`If true, continue the teammate conversation; otherwise start fresh`)}),Z({status:Sv(cg([`queued`,`running`,`completed`,`failed`,`cancelled`,`interrupted`])).describe(`Optional run status filter. Omit to include all statuses.`),agentId:Sv(q().min(1)).describe(`Optional teammate ID filter. Omit to include all teammates.`),includeCompleted:Sv(Y()).describe(`Include completed/failed runs (default true)`)}),Z({runId:q().min(1).describe(`Run ID`),reason:Sv(q().min(1)).describe(`Optional cancellation reason`)}),Z({runId:Sv(q().min(1)).describe(`Optional async run ID to await. Omit to wait for all active async runs.`)}).strict(),Z({toAgentId:q().min(1).describe(`Recipient agent ID`),subject:q().min(1).describe(`Message subject`),body:q().min(1).describe(`Message body`),taskId:Sv(q().min(1)).describe(`Optional task ID context`)}),Z({subject:q().min(1).describe(`Message subject`),body:q().min(1).describe(`Message body`),taskId:Sv(q().min(1)).describe(`Optional task ID context`)}),Z({unreadOnly:Sv(Y()).describe(`Only unread messages for read action (default true)`)}),Z({kind:cg([`progress`,`handoff`,`blocked`,`decision`,`done`,`error`]),summary:q().min(1).describe(`Update summary`),taskId:Sv(q().min(1)).describe(`Optional task ID context`),evidence:Sv(X(q().min(1))).describe(`Optional evidence links/snippets`),nextAction:Sv(q().min(1)).describe(`Planned next step`)}),Z({}),Z({title:q().describe(`Outcome title`),requiredSections:X(q()).default(gv).describe(`Required sections for finalization gate (defaults to current_state,boundary_analysis,interface_proposal)`)}),Z({outcomeId:q().describe(`Outcome ID`),section:q().describe(`Section name`),sourceRunId:Sv(q()).describe(`Optional source run ID`),content:q().describe(`Section fragment content`)}),Z({fragmentId:q().describe(`Fragment ID`),approved:Y().describe(`Review decision`)}),Z({outcomeId:q().describe(`Outcome ID`)}),Z({}),Z({teamId:q(),teamName:q(),members:X(xv),taskCounts:eg(vv,J()),unreadMessages:J(),missionLogEntries:J(),activeRuns:J(),queuedRuns:J(),outcomeCounts:eg(bv,J())});var wv=Z({id:q(),title:q(),description:q(),status:vv,createdAt:_v,updatedAt:_v,createdBy:q(),assignee:q().optional(),dependsOn:X(q()),summary:q().optional(),isReady:Y(),blockedBy:X(q())});Jh(`action`,[Z({action:dg(`create`),taskId:q(),status:vv,ignoredFields:X(q()).optional(),note:q().optional()}),Z({action:dg(`list`),tasks:X(wv)}),Z({action:dg(`claim`),taskId:q(),status:vv,nextStep:q()}),Z({action:dg(`complete`),taskId:q(),status:vv}),Z({action:dg(`block`),taskId:q(),status:vv})]),Z({agentId:q(),mode:cg([`sync`,`async`]),status:cg([`dispatched`,`running`,`queued`,`joined`]),dispatched:Y(),message:q(),deduped:Y().optional(),runId:q().optional(),text:q().optional(),iterations:J().optional()});var Tv=Z({textPreview:q(),iterations:J(),finishReason:q(),durationMs:J(),usage:Z({inputTokens:J(),outputTokens:J(),cacheReadTokens:J().optional(),cacheWriteTokens:J().optional(),totalCost:J().optional()})});Z({id:q(),agentId:q(),taskId:q().optional(),status:yv,messagePreview:q(),priority:J(),retryCount:J(),maxRetries:J(),nextAttemptAt:_v.optional(),continueConversation:Y().optional(),startedAt:_v,endedAt:_v.optional(),leaseOwner:q().optional(),heartbeatAt:_v.optional(),lastProgressAt:_v.optional(),lastProgressMessage:q().optional(),currentActivity:q().optional(),error:q().optional(),resultSummary:Tv.optional()}),Z({id:q(),teamId:q(),fromAgentId:q(),toAgentId:q(),subject:q(),body:q(),taskId:q().optional(),sentAt:_v,readAt:_v.optional()}),Z({id:q(),teamId:q(),title:q(),status:bv,requiredSections:X(q()),createdBy:q(),createdAt:_v,finalizedAt:_v.optional()}),Z({outcomeId:q(),status:bv,requiredSections:X(q())}),Z({agentId:q(),status:q()}),Z({runId:q(),status:yv}),Z({id:q(),toAgentId:q()}),Z({delivered:J()}),Z({id:q()}),Z({status:q()}),Z({fragmentId:q(),status:q()}),Z({outcomeId:q(),status:bv});var Ev;(e=>{e.TaskStart=`task_start`,e.TaskEnd=`task_end`,e.AgentEvent=`agent_event`,e.TeammateSpawned=`teammate_spawned`,e.TeammateShutdown=`teammate_shutdown`,e.TeamTaskUpdated=`team_task_updated`,e.TeamMessage=`team_message`,e.TeamMissionLog=`team_mission_log`,e.TeamTaskCompleted=`team_task_completed`,e.RunStarted=`run_started`,e.RunQueued=`run_queued`,e.RunProgress=`run_progress`,e.RunCompleted=`run_completed`,e.RunFailed=`run_failed`,e.RunCancelled=`run_cancelled`,e.RunInterrupted=`run_interrupted`,e.OutcomeCreated=`outcome_created`,e.OutcomeFragmentAttached=`outcome_fragment_attached`,e.OutcomeFragmentReviewed=`outcome_fragment_reviewed`,e.OutcomeFinalized=`outcome_finalized`})(Ev||={});function Dv(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 Ov=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 kv(e){return L.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[Ov.checked]:``}:{[Ov.unchecked]:``}},...nt}),[e.indeterminate])}var Av=L.createContext(void 0);function jv(){let e=L.useContext(Av);if(e===void 0)throw Error(Re(14));return e}var Mv=`data-parent`,Nv=L.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:m=!1,render:h,required:g=!1,uncheckedValue:_,value:v,nativeButton:y=!1,style:ee,...b}=e,{clearErrors:x}=St(),{disabled:te,name:S,setDirty:C,setFilled:w,setFocused:ne,setTouched:T,state:re,validationMode:ie,validityData:ae,validation:E}=xe(),D=wn(),{labelId:O,controlId:oe,registerControlId:se,getDescriptionProps:ce}=an(),k=En(),le=k?.parent,de=le&&k.allValues,fe=te||D.disabled||k?.disabled||o,pe=S??d,me=v??pe,he=j(),ge=j(),_e=oe;de?_e=p?ge:`${le.id}-${me}`:c&&(_e=c);let A={};de&&(p?A=k.parent.getParentProps():me&&(A=k.parent.getChildProps(me)));let{checked:ve=n,indeterminate:ye=l,onCheckedChange:be,...Se}=A,Ce=k?.value,we=k?.setValue,Te=k?.defaultValue,Ee=L.useRef(null),De=Le(()=>Symbol(`checkbox-control`)),Oe=L.useRef(!1),{getButtonProps:ke,buttonRef:Ae}=Nt({disabled:fe,native:y}),M=k?.validation??E,[je,Me]=ze({controlled:me&&Ce&&!p?Ce.includes(me):ve,default:me&&Te&&!p?Te.includes(me):i,name:`Checkbox`,state:`checked`}),Ne=de?!!ve:je,Pe=de&&ye||l;Wt(()=>{se!==Xe&&(Oe.current=!0,se(De.current,_e))},[_e,se,De]),L.useEffect(()=>{let e=De.current;return()=>{!Oe.current||se===Xe||(Oe.current=!1,se(e,void 0))}},[se,De]),_t(Ee,he,je,void 0,!k&&!fe,d);let Fe=L.useRef(null),Ie=zt(u,Fe,M.inputRef,M.registerInput),N=ue(a,O,Fe,!y,_e??void 0);Wt(()=>{Fe.current&&(Fe.current.indeterminate=Pe,je&&w(!0))},[je,Pe,w]),pt(je,()=>{k||(x(pe),w(je),C(je!==ae.initialValue),M.change(je))});let Re=Bt({checked:je,disabled:fe,form:s,name:p?void 0:pe,id:y?void 0:_e??void 0,required:g,ref:Ie,style:pe?Tt:Jt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(m){e.preventDefault();return}let t=e.currentTarget.checked,n=At(Je,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(be?.(t,n),!n.isCanceled&&(Me(t),me&&Ce&&we&&!p&&!de))){let e=t?[...Ce,me]:Ce.filter(e=>e!==me);we(e,n)}},onFocus(){Ee.current?.focus()}},v===void 0?Ke:{value:(k?je&&v:v)||``},ce,e=>M.getValidationProps(fe,e));L.useEffect(()=>{if(!le||!me)return;let e=le.disabledStatesRef.current;return e.set(me,fe),()=>{e.delete(me)}},[le,fe,me]);let P=L.useMemo(()=>({...re,checked:Ne,disabled:fe,readOnly:m,required:g,indeterminate:Pe}),[re,Ne,fe,m,g,Pe]),Be=kv(P),Ve=Yt(`span`,e,{state:P,ref:[Ae,Ee,t,k?.registerControlRef],props:[{id:y?_e??void 0:he,role:`checkbox`,"aria-checked":Pe?`mixed`:Ne,"aria-readonly":m||void 0,"aria-required":g||void 0,"aria-labelledby":N,[Mv]:p?``:void 0,onFocus(){fe||ne(!0)},onBlur(){let e=Fe.current;e&&(T(!0),ne(!1),ie===`onBlur`&&M.commit(k?Ce:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Fe.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),et(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||Dv(t)?.click()})},onClick(e){if(m||fe)return;e.preventDefault();let t=Fe.current;t&&t.dispatchEvent(new(et(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},b,Se,ke,ce,e=>M.getValidationProps(fe,e)],stateAttributesMapping:Be});return(0,R.jsxs)(Av.Provider,{value:P,children:[Ve,!je&&!k&&pe&&!p&&_!==void 0&&(0,R.jsx)(`input`,{type:`hidden`,form:s,name:pe,value:_,disabled:fe}),(0,R.jsx)(`input`,{...Re,suppressHydrationWarning:!0})]})}),Pv=L.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=jv(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=st(c),f=L.useRef(null),p={...s,transitionStatus:u};cn({open:c,ref:f,onComplete(){c||d(!1)}});let m={...kv(s),...Me,...nt},h=a||l,g=Yt(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null});function Fv({className:e,...t}){return(0,R.jsx)(Nv,{"data-slot":`checkbox`,className:tn(`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,R.jsx)(Pv,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,R.jsx)(Qt,{})})})}function Iv(e,t,n,r,i,a,o,s,c,l=2){let u=Mt(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 xt(n.current,u)?void 0:u}var Lv=L.createContext(void 0),Rv=L.createContext(void 0),zv=L.createContext(void 0),Bv=L.createContext(!1),Vv=L.createContext(``);function Hv(){let e=L.useContext(Lv);if(!e)throw Error(Re(22));return e}function Uv(){let e=L.useContext(Rv);if(!e)throw Error(Re(23));return e}function Wv(){let e=L.useContext(zv);if(!e)throw Error(Re(24));return e}function Gv(){return L.useContext(Vv)}function Kv(){return L.useContext(Bv)}var $={id:P(e=>e.id),labelId:P(e=>e.labelId),items:P(e=>e.items),selectedValue:P(e=>e.selectedValue),hasSelectionChips:P(e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:P(e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:P((e,t)=>t?m(e.items):!1),open:P(e=>e.open),mounted:P(e=>e.mounted),forceMounted:P(e=>e.forceMounted),inline:P(e=>e.inline),activeIndex:P(e=>e.activeIndex),selectedIndex:P(e=>e.selectedIndex),isActive:P((e,t)=>e.activeIndex===t),isSelected:P((e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>c(t,e,n)):c(t,r,n)}),transitionStatus:P(e=>e.transitionStatus),popupProps:P(e=>e.popupProps),inputProps:P(e=>e.inputProps),triggerProps:P(e=>e.triggerProps),itemProps:P(e=>e.itemProps),positionerElement:P(e=>e.positionerElement),listElement:P(e=>e.listElement),popupId:P(e=>e.popupId),triggerElement:P(e=>e.triggerElement),inputElement:P(e=>e.inputElement),inputGroupElement:P(e=>e.inputGroupElement),popupSide:P(e=>e.popupSide),openMethod:P(e=>e.openMethod),inputInsidePopup:P(e=>e.inputInsidePopup),inputOwnsFormValue:P(e=>e.inputOwnsFormValue),selectionMode:P(e=>e.selectionMode),name:P(e=>e.name),form:P(e=>e.form),disabled:P(e=>e.disabled),readOnly:P(e=>e.readOnly),required:P(e=>e.required),grid:P(e=>e.grid),virtualized:P(e=>e.virtualized),itemToStringLabel:P(e=>e.itemToStringLabel),isItemEqualToValue:P(e=>e.isItemEqualToValue),modal:P(e=>e.modal),autoHighlight:P(e=>e.autoHighlight),submitOnItemClick:P(e=>e.submitOnItemClick)};function qv(e){return e==null?void 0:`${e}-popup`}function Jv(e,t){return(n,r)=>{if(n==null)return!1;let i=oe(n,t);return e.contains(i,r)}}function Yv(e,t,n){return(r,i)=>{if(r==null)return!1;if(!i)return!0;let a=oe(r,t),o=n==null?``:oe(n,t);return o&&e.contains(o,i)&&o.length===i.length?!0:e.contains(a,i)}}function Xv(e){return Array.isArray(e)?e.map(e=>Xv(e)).join(`,`):e==null?``:String(e)}var Zv=new Map;function Qv(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Xv(e.locale)}|${JSON.stringify(t)}`,r=Zv.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=oe(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=oe(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=oe(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Zv.set(n,a),a}var $v=Qv,ey=Symbol(`none`),ty={value:ey,index:-1};function ny(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:l,defaultInputValue:u,inputValue:d,open:p,defaultOpen:m=!1,selectionMode:g=`none`,onItemHighlighted:_,name:v,form:y,disabled:ee=!1,readOnly:b=!1,required:x=!1,inputRef:te,grid:S=!1,items:C,filteredItems:ne,filter:T,openOnInputClick:re=!0,autoHighlight:ie=!1,keepHighlight:ae=!1,highlightItemOnHover:E=!0,loopFocus:D=!0,itemToStringLabel:O,itemToStringValue:ce,isItemEqualToValue:k=s,virtualized:le=!1,inline:ue=!1,fillInputOnItemPress:de=!0,modal:fe=!1,limit:pe=-1,autoComplete:me=`list`,formAutoComplete:he,locale:ge,submitOnItemClick:_e=!1}=e,{clearErrors:A}=St(),{setDirty:ve,validityData:j,setFilled:ye,name:be,disabled:Se,setTouched:Ce,setFocused:we,validationMode:Ee,validation:De}=xe(),ke=It(),Ae=Zt({id:t}),je=$v({locale:ge}),[Me,Ne]=L.useState(!1),[N,Re]=L.useState(null),P=L.useRef([]),He=L.useRef([]),We=L.useRef(null),Ge=L.useRef(null),qe=L.useRef(null),Ye=L.useRef(null),Ze=L.useRef(null),Qe=L.useRef(!0),$e=L.useRef(!1),et=L.useRef(null),tt=L.useRef(null),nt=L.useRef(null),it=L.useRef(ty),at=L.useRef(null),ot=L.useRef([]),ct=L.useRef([]),lt=Se||ee,ut=be??v,dt=g===`multiple`,gt=g===`single`,yt=d!==void 0||u!==void 0,bt=C!==void 0,xt=ne!==void 0,Ct;Ct=ie===`always`?`always`:ie?`input-change`:!1;let[F,wt]=ze({controlled:i,default:dt?r??Ue:r,name:`Combobox`,state:`selectedValue`}),Et=L.useMemo(()=>T===null?()=>!0:T===void 0?gt&&!Me?Yv(je,O,F):Jv(je,O):T,[T,gt,F,Me,je,O]),Ot=Le(()=>yt?u??``:gt?oe(F,O):``).current,[kt,jt]=ze({controlled:d,default:Ot,name:`Combobox`,state:`inputValue`}),[Mt,Nt]=ze({controlled:p,default:m,name:`Combobox`,state:`open`}),Pt=o(C),Ft=N??(kt===``?``:String(kt).trim()),Lt=gt?oe(F,O):``,Rt=gt&&!Me&&Ft!==``&&Lt!==``&&Lt.length===Ft.length&&je.contains(Lt,Ft),Vt=Rt?``:Ft,Ut=bt&&xt&&Rt,Kt=L.useMemo(()=>C?Pt?C.flatMap(e=>e.items):C:Ue,[C,Pt]),qt=L.useMemo(()=>{if(ne&&!Ut)return ne;if(!C)return Ue;if(Pt){let e=C,t=[],n=0;for(let r of e){if(pe>-1&&n>=pe)break;let e=Vt===``?r.items:r.items.filter(e=>Et(e,Vt,O));if(e.length===0)continue;let i=pe>-1?pe-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(Vt===``)return pe>-1?Kt.slice(0,pe):Kt;let e=[];for(let t of Kt){if(pe>-1&&e.length>=pe)break;Et(t,Vt,O)&&e.push(t)}return e},[ne,Ut,C,Pt,Vt,pe,Et,O,Kt]),Yt=L.useMemo(()=>Pt?qt.flatMap(e=>e.items):qt,[qt,Pt]),I=Le(()=>new ft({id:Ae,labelId:void 0,selectedValue:F,open:Mt,filter:Et,query:Ft,items:C,selectionMode:g,listRef:P,labelsRef:He,popupRef:We,emptyRef:Ze,inputRef:Ge,startDismissRef:qe,endDismissRef:Ye,keyboardActiveRef:Qe,chipsContainerRef:et,clearRef:tt,valuesRef:ot,allValuesRef:ct,selectionEventRef:nt,name:ut,form:y,disabled:lt,readOnly:b,required:x,grid:S,isGrouped:Pt,virtualized:le,openOnInputClick:re,itemToStringLabel:O,isItemEqualToValue:k,modal:fe,autoHighlight:Ct,submitOnItemClick:_e,hasInputValue:yt,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:ue,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:Ke,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:g===`none`,onOpenChangeComplete:n||Xe,setOpen:Xe,setInputValue:Xe,setSelectedValue:Xe,setIndices:Xe,onItemHighlighted:Xe,handleSelection:Xe,forceMount:Xe,requestSubmit:Xe})).current,Xt=g===`none`?kt:F,Qt=L.useMemo(()=>g===`none`?Xt:Array.isArray(F)?F.map(e=>h(e,ce)):h(F,ce),[Xt,ce,g,F]),$t=Dt(_),tn=Dt(n),nn=M(I,$.activeIndex),rn=M(I,$.selectedIndex),an=M(I,$.positionerElement),on=M(I,$.listElement),sn=M(I,$.triggerElement),ln=M(I,$.inputElement),un=M(I,$.inputGroupElement),dn=M(I,$.inline),fn=M(I,$.inputInsidePopup),pn=M(I,$.inputOwnsFormValue),mn=Ht(sn),{mounted:hn,setMounted:gn,transitionStatus:_n}=st(Mt),{openMethod:vn,triggerProps:yn}=Ie(Mt),bn=Dt(()=>Qt);_t(fn?mn:Ge,Ae,Xt,bn,!lt,v);let xn=Dt(()=>{C?He.current=Yt.map(e=>oe(e,O)):I.set(`forceMounted`,!0)}),Sn=L.useRef(F);Wt(()=>{F!==Sn.current&&xn()},[xn,F]);let Cn=Dt(e=>{I.update(e);let t=e.type||`none`;if(e.activeIndex!==void 0)if(e.activeIndex===null)it.current!==ty&&(it.current=ty,$t(void 0,vt(t,void 0,{index:-1})));else{let n=ot.current[e.activeIndex];it.current={value:n,index:e.activeIndex},$t(n,vt(t,void 0,{index:e.activeIndex}))}}),wn=Dt((t,n)=>{if($e.current=n.reason===en,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&&Ne(!0),at.current={hasQuery:e},e&&Ct&&I.state.activeIndex==null&&I.set(`activeIndex`,0)}}jt(t)}}),Tn=Dt((t,n)=>{if(Mt!==t&&(n.reason===`escape-key`&&bt&&Yt.length===0&&!I.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&dt&&fn&&!dn&&N!==null&&(Ne(!1),Re(null),kt!==``&&wn(``,At(en,n.event))),!t&&Me&&(gt?(dn||Re(Ft),Ft===``&&Ne(!1)):dt&&(dn||Re(Ft),fn&&Cn({activeIndex:null}),(!fn||dn)&&wn(``,At(en,n.event)))),Nt(t),!t&&fn&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(Ce(!0),we(!1),Ee===`onBlur`)))){let e=g===`none`?kt:F;De.commit(e)}}),En=Dt((e,t)=>{l?.(e,t),!t.isCanceled&&(wt(e),(g===`none`&&We.current&&de||gt&&!I.state.inputInsidePopup)&&wn(oe(e,O),At(t.reason,t.event)),gt&&e!=null&&t.reason!==`input-change`&&Me&&!dn&&Re(Ft))}),Dn=Dt((e,t)=>{let n=t;if(n===void 0){if(nn===null)return;n=ot.current[nn]}let r=Be(e),i=nt.current??e;nt.current=null;let o=At(Te,i),s=r?.closest(`a`)?.getAttribute(`href`);if(s){s.startsWith(`#`)&&Tn(!1,o);return}if(dt){let e=Array.isArray(F)?F:[],t=a(e,n,I.state.isItemEqualToValue)?w(e,n,I.state.isItemEqualToValue):[...e,n];if(En(t,o),o.isCanceled||!(Ge.current&&Ge.current.value.trim()!==``))return;I.state.inputInsidePopup?wn(``,At(en,o.event)):Tn(!1,o)}else{if(En(n,o),o.isCanceled)return;Tn(!1,o)}}),On=Dt(()=>{if(!I.state.submitOnItemClick)return;let e=De.inputRef.current?.form??I.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),kn=Dt(()=>{if(gn(!1),tn?.(!1),Ne(!1),Re(null),Cn(g===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),dt&&Ge.current&&Ge.current.value!==``&&!$e.current&&wn(``,At(en)),gt)if(I.state.inputInsidePopup)Ge.current&&Ge.current.value!==``&&wn(``,At(en));else{let e=oe(F,O);Ge.current&&Ge.current.value!==e&&wn(e,At(e===``?en:Je))}}),An=L.useMemo(()=>dn&&an?{current:an.closest(`[role="dialog"]`)}:We,[dn,an]);cn({enabled:!e.actionsRef,open:Mt,ref:An,onComplete(){Mt||kn()}}),L.useImperativeHandle(e.actionsRef,()=>({unmount:kn}),[kn]),Wt(function(){if(Mt||g===`none`)return;let e=C?Kt:ct.current;if(dt){let t=Array.isArray(F)?F:[],n=t[t.length-1],r=f(e,n,k);Cn({selectedIndex:r===-1?null:r})}else{let t=f(e,F,k);Cn({selectedIndex:t===-1?null:t})}},[Mt,F,C,g,Kt,dt,k,Cn]),Wt(()=>{C&&(ot.current=Yt,P.current.length=Yt.length)},[C,Yt]),Wt(()=>{let e=at.current;if(e&&(e.hasQuery?Ct&&I.set(`activeIndex`,0):Ct===`always`&&I.set(`activeIndex`,0),at.current=null),!Mt&&!dn)return;let t=bt||xt?Yt:ot.current,n=I.state.activeIndex;if(n==null){if(Ct===`always`&&t.length>0){I.set(`activeIndex`,0);return}it.current!==ty&&(it.current=ty,I.state.onItemHighlighted(void 0,vt(Je,void 0,{index:-1})));return}if(n>=t.length){it.current!==ty&&(it.current=ty,I.state.onItemHighlighted(void 0,vt(Je,void 0,{index:-1}))),I.set(`activeIndex`,null);return}let r=t[n],i=it.current.value,a=i!==ey&&c(r,i,I.state.isItemEqualToValue);(it.current.index!==n||!a)&&(it.current={value:r,index:n},I.state.onItemHighlighted(r,vt(Je,void 0,{index:n})))},[nn,Ct,xt,bt,Yt,dn,Mt,I]),Wt(()=>{if(g===`none`){ye(String(kt)!==``);return}ye(dt?Array.isArray(F)&&F.length>0:F!=null)},[ye,g,kt,F,dt]),L.useEffect(()=>{bt&&Ct&&Yt.length===0&&Cn({activeIndex:null})},[bt,Ct,Yt.length,Cn]);function jn(e){let t=j.initialValue;return Array.isArray(e)&&Array.isArray(t)?!se(e,t,(e,t)=>c(e,t,k)):e!==t}pt(Ft,()=>{!Mt||Ft===``||Ft===String(Ot)||Ne(!0)}),pt(F,()=>{if(g!==`none`&&(A(ut),ve(jn(F)),De.change(F),gt&&!yt&&!fn)){let e=oe(F,O);kt!==e&&wn(e,At(Je))}}),pt(kt,()=>{g===`none`&&(A(ut),ve(kt!==j.initialValue),De.change(kt))}),pt(C,()=>{if(!gt||yt||fn||Me)return;let e=oe(F,O);kt!==e&&wn(e,At(Je))});let Mn=Fe({open:dn?!0:Mt,onOpenChange:Tn,elements:{reference:fn?sn:ln,floating:an}}),Nn,Pn;dn||(Nn=S?`grid`:`listbox`,Pn=Mt?`true`:`false`);let Fn=L.useMemo(()=>{let e=ln?.tagName===`INPUT`,t=ln==null||e,n=t||Mt,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Pn,r[`aria-haspopup`]=Nn,r[`aria-controls`]=Mt?on?.id:void 0,r[`aria-autocomplete`]=me),{reference:r,floating:{role:`presentation`}}},[ln,Mt,Pn,Nn,on?.id,me]),In=mt(Mn,{enabled:!b&&!lt&&re,event:`mousedown-only`,toggle:!1,touchOpenDelay:fn?0:100,reason:rt}),Ln=ht(Mn,{enabled:!b&&!lt&&!dn,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:dn?!0:void 0,outsidePress(e){let t=Be(e);return!Pe(sn,t)&&!Pe(tt.current,t)&&!Pe(et.current,t)&&!Pe(un,t)}}),Rn=Oe(Mn,{enabled:!b&&!lt,id:Ae,listRef:P,activeIndex:nn,selectedIndex:rn,virtual:!0,loopFocus:D,allowEscape:D&&!Ct,focusItemOnOpen:Me||g===`none`&&!Ct?!1:`auto`,focusItemOnHover:E,resetOnPointerLeave:!ae,orientation:S?`horizontal`:void 0,rtl:ke===`rtl`,disabledIndices:Ue,grid:S?Iv:void 0,onNavigate(e,t){!t&&!Mt||_n===`ending`||Cn(t?{activeIndex:e,type:Qe.current?`keyboard`:`pointer`}:{activeIndex:e})}}),zn=L.useMemo(()=>Bt(Rn.reference,{onKeyDown(e){S&&I.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Ln.reference,In.reference,Fn.reference),[Rn.reference,Ln.reference,In.reference,Fn.reference,S,I]),Bn=L.useMemo(()=>Bt(Ve,Rn.floating,Ln.floating,Fn.floating),[Rn.floating,Ln.floating,Fn.floating]),Vn=L.useMemo(()=>{let e=Rn.item;return e?{...e,onFocus:void 0}:Ke},[Rn.item]);Gt(()=>{I.update({inline:ue,popupProps:Bn,inputProps:zn,triggerProps:yn,itemProps:Vn,setOpen:Tn,setInputValue:wn,setSelectedValue:En,setIndices:Cn,onItemHighlighted:$t,handleSelection:Dn,forceMount:xn,requestSubmit:On})}),Wt(()=>{I.update({id:Ae,selectedValue:F,open:Mt,mounted:hn,transitionStatus:_n,items:C,inline:ue,popupProps:Bn,inputProps:zn,triggerProps:yn,openMethod:vn,itemProps:Vn,selectionMode:g,name:ut,form:y,disabled:lt,readOnly:b,required:x,grid:S,isGrouped:Pt,virtualized:le,onOpenChangeComplete:tn,openOnInputClick:re,itemToStringLabel:O,modal:fe,autoHighlight:Ct,isItemEqualToValue:k,submitOnItemClick:_e,hasInputValue:yt,requestSubmit:On,inputOwnsFormValue:g===`none`&&(ue||!I.state.inputInsidePopup)})},[I,Ae,F,Mt,hn,_n,C,Bn,zn,Vn,vn,yn,g,ut,lt,b,x,De,S,Pt,le,tn,re,O,fe,k,_e,yt,ue,On,Ct,y]);let Hn=zt(te,De.inputRef),Un=L.useMemo(()=>({query:Ft,hasItems:bt,filteredItems:qt,flatFilteredItems:Yt}),[Ft,bt,qt,Yt]),Wn=L.useMemo(()=>Array.isArray(Xt)?``:h(Xt,ce),[Xt,ce]),Gn=dt&&Array.isArray(F)&&F.length>0,Kn=dt||g===`none`&&pn?void 0:ut,qn=L.useMemo(()=>!dt||!Array.isArray(F)||!ut?null:F.map(e=>{let t=h(e,ce);return(0,R.jsx)(`input`,{type:`hidden`,form:y,name:ut,value:t,disabled:lt},t)}),[dt,F,y,ut,ce,lt]),Jn=(0,R.jsxs)(L.Fragment,{children:[e.children,(0,R.jsx)(`input`,{...De.getValidationProps(lt,{onFocus(){if(fn){sn?.focus();return}(Ge.current||sn)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||lt||b)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=At(Je,e.nativeEvent),i=()=>ot.current.findIndex(e=>h(e,ce).toLowerCase()===n||oe(e,O).toLowerCase()===n);function a(){if(dt)return;if(g===`none`){wn(t,r);return}let e=i();e===-1&&(e=ot.current.findIndex((e,t)=>{let r=He.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:ot.current[e];a!=null&&En?.(a,r)}gt&&(xn(),C&&i()===-1&&I.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:Ae&&Kn==null?`${Ae}-hidden-input`:void 0,form:y,name:Kn,autoComplete:he,disabled:lt,required:x&&!Gn,readOnly:b,value:Wn,ref:Hn,style:Kn?Tt:Jt,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),qn]});return(0,R.jsx)(Lv.Provider,{value:I,children:(0,R.jsx)(Rv.Provider,{value:Mn,children:(0,R.jsx)(Bv.Provider,{value:bt,children:(0,R.jsx)(zv.Provider,{value:Un,children:(0,R.jsx)(Vv.Provider,{value:kt,children:Jn})})})})})}var ry={...We,...nt,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null},iy=2,ay=L.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=xe(),{labelId:h}=an(),g=Hv(),{filteredItems:_}=Wv(),y=M(g,$.selectionMode),ee=M(g,$.disabled),b=M(g,$.readOnly),x=M(g,$.required),te=M(g,$.mounted),S=M(g,$.popupSide),C=M(g,$.positionerElement),w=M(g,$.listElement),ne=M(g,$.popupId),T=M(g,$.triggerProps),re=M(g,$.triggerElement),ie=M(g,$.inputInsidePopup),ae=M(g,$.id),E=M(g,$.labelId),D=M(g,$.open),O=M(g,$.selectedValue),oe=M(g,$.activeIndex),se=M(g,$.selectedIndex),ce=M(g,$.hasSelectedValue),k=Uv(),le=Gv(),ue=Ae(),de=u||ee||a,fe=_.length===0,pe=te&&C?S:null;Zt({id:ie?o:void 0});let me=ie?o??ae:o,he=v(h,E),ge;D&&ie?ge=ne??qv(ae):D&&(ge=w?.id);let _e=L.useRef(``);function A(e){_e.current=e.pointerType}let ve=k.useState(`domReferenceElement`);L.useEffect(()=>{ie&&re&&re!==ve&&k.set(`domReferenceElement`,re)},[re,ve,k,ie]);let{reference:j}=Ze(k,{enabled:!D&&!b&&!ee&&y===`single`,listRef:g.state.labelsRef,activeIndex:oe,selectedIndex:se,onMatch(e){let t=g.state.valuesRef.current[e];t!==void 0&&g.state.setSelectedValue(t,At(`none`))}}),{reference:ye}=mt(k,{enabled:!b&&!ee,event:`mousedown`}),{buttonRef:Se,getButtonProps:we}=Nt({native:i,disabled:de}),Te={...l,open:D,disabled:de,popupSide:pe,listEmpty:fe,placeholder:y!==`none`&&!ce};return Yt(`button`,e,{ref:[t,Se,Dt(e=>{g.set(`triggerElement`,e)})],state:Te,props:[T,ye,j,{id:me,tabIndex:ie?0:-1,role:ie?`combobox`:void 0,"aria-expanded":D?`true`:`false`,"aria-haspopup":ie?`dialog`:`listbox`,"aria-controls":ge,"aria-required":ie&&x||void 0,"aria-labelledby":he,onPointerDown:A,onPointerEnter:A,onFocus(){f(!0),!(de||b)&&ue.start(0,g.state.forceMount)},onBlur(e){if(!Pe(C,e.relatedTarget)&&(d(!0),f(!1),p===`onBlur`)){let e=y===`none`?le:O;m.commit(e)}},onMouseDown(e){if(de||b||(ie||k.set(`domReferenceElement`,e.currentTarget),g.state.forceMount(),_e.current!==`touch`&&(g.state.inputRef.current?.focus(),ie||e.preventDefault()),D))return;let t=Rt(e.currentTarget);function n(e){if(!re)return;let t=Be(e),n=g.state.positionerElement,r=g.state.listElement;if(Pe(re,t)||Pe(n,t)||Pe(r,t)||t===re)return;let i=Pt(re),a=e.clientX>=i.left-iy&&e.clientX<=i.right+iy,o=e.clientY>=i.top-iy&&e.clientY<=i.bottom+iy;a&&o||g.state.setOpen(!1,At(`cancel-open`,e))}ie&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){de||b||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(be(e),g.state.setOpen(!0,At(Ce,e.nativeEvent)),g.state.inputRef.current?.focus())}},m?m.getValidationProps(de,c):c,we],stateAttributesMapping:ry})}),oy=L.createContext(void 0);function sy(){return L.useContext(oy)}var cy=L.createContext(void 0);function ly(e){let t=L.useContext(cy);if(t===void 0&&!e)throw Error(Re(21));return t}var uy=L.forwardRef(function(e,t){let n=Hv(),{buttonRef:r,getButtonProps:i}=Nt({native:!1}),a=zt(t,r);function o(e){n.state.setOpen(!1,At(Ct,e.nativeEvent,e.currentTarget))}return(0,R.jsx)(`span`,{ref:a,...i({onClick:o}),"aria-label":`Dismiss`,tabIndex:void 0,style:Tt})}),dy=L.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,setFocused:d,validationMode:f,validation:p}=xe(),{labelId:m}=an(),h=sy(),g=!!ly(!0),_=Hv(),{filteredItems:y}=Wv(),ee=Gv(),b=It(),x=M(_,$.required),te=M(_,$.disabled),S=M(_,$.readOnly),C=M(_,$.name),w=M(_,$.form),ne=M(_,$.selectionMode),T=M(_,$.autoHighlight),re=M(_,$.inputProps),ie=M(_,$.triggerProps),ae=M(_,$.open),E=M(_,$.mounted),D=M(_,$.selectedValue),O=M(_,$.popupSide),oe=M(_,$.positionerElement),se=M(_,$.id),ce=M(_,$.inline),k=M(_,$.modal),le=!!T,ue=E&&oe?O:null,de=l||te||i,fe=y.length===0,pe=g||ce,me=!pe||k,he=j(a??(pe?void 0:se)),ge=v(m,void 0),_e=g?$t:c,[A,ve]=L.useState(null),ye=L.useRef(!1),Ce=L.useRef(null),we=L.useRef(!1),Te=ne===`none`&&!g,Ee=Dt(e=>{let t=g||_.state.inline;t&&!_.state.hasInputValue&&_.state.setInputValue(``,At(Je)),_.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:Te})}),De=g||!p?s:p.getValidationProps(de,s),Oe={..._e,open:ae,disabled:de,readOnly:S,popupSide:ue,listEmpty:fe};function ke(e){if(!h)return;let t,{highlightedChipIndex:n}=h,r=h.chipsRef.current.length,i=b===`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>=D.length-1?D.length-2:n;t=r>=0?r:void 0,_.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`})}return t}return e.key===a&&(e.currentTarget.selectionStart??0)===0&&D.length>0?(e.preventDefault(),t=r>0?r-1:void 0):e.key===`Backspace`&&e.currentTarget.value===``&&D.length>0&&(_.state.setIndices({activeIndex:null,selectedIndex:null,type:`keyboard`}),e.preventDefault()),t}let Ae=Yt(`input`,e,{state:Oe,ref:[t,_.state.inputRef,Ee],props:[re,ie,{type:`text`,value:e.value??A??ee,"aria-readonly":S||void 0,"aria-required":x||void 0,"aria-labelledby":ge,disabled:de,readOnly:S,required:ne===`none`?x:void 0,form:w,...Te&&C&&{name:C},id:he,onFocus(){if(d(!0),!ce||!we.current)return;we.current=!1;let e=Ce.current;e==null||!Object.hasOwn(_.state.valuesRef.current,e)||_.state.setIndices({activeIndex:e})},onBlur(){u(!0),d(!1);let e=_.state.activeIndex;if(ce&&e!==null&&T!==`always`&&(Ce.current=e,we.current=!0,_.state.setIndices({activeIndex:null})),f===`onBlur`){let e=ne===`none`?ee:D;p.commit(e)}},onCompositionStart(e){ot||(ye.current=!0,ve(e.currentTarget.value))},onCompositionEnd(e){ye.current=!1;let t=e.currentTarget.value;ve(null),_.state.setInputValue(t,At(Se,e.nativeEvent))},onChange(e){let t=e.nativeEvent.inputType,n=!t||t===`insertReplacementText`,r=ye.current||!n;if(ye.current){let t=e.currentTarget.value;ve(t),t===``&&!_.state.openOnInputClick&&!_.state.inputInsidePopup&&_.state.setOpen(!1,At(en,e.nativeEvent));let n=t.trim(),i=le&&n!==``;!S&&!de&&n&&r&&(_.state.setOpen(!0,At(Se,e.nativeEvent)),le||_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`})),ae&&_.state.activeIndex!==null&&!i&&_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`});return}let i=At(Se,e.nativeEvent);if(_.state.setInputValue(e.currentTarget.value,i),i.isCanceled)return;let a=e.currentTarget.value===``,o=At(en,e.nativeEvent);a&&!_.state.inputInsidePopup&&(ne===`single`&&_.state.setSelectedValue(null,o),_.state.openOnInputClick||_.state.setOpen(!1,o));let s=e.currentTarget.value.trim();!S&&!de&&s&&r&&(_.state.setOpen(!0,At(Se,e.nativeEvent)),le||_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`})),ae&&_.state.activeIndex!==null&&!le&&_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`})},onKeyDown(e){if(de||S||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;_.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){be(e);let n=lt&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){be(e);let i=lt&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!E&&e.key===`Escape`){let t=ne===`multiple`&&Array.isArray(D)?D.length===0:D===null,n=At(rn,e.nativeEvent),r=ne===`multiple`?[]:null;_.state.setInputValue(``,n),_.state.setSelectedValue(r,n),!t&&!_.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&h.highlightedChipIndex===void 0&&Array.isArray(D)&&D.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:D.length-1,r=D.filter((e,t)=>t!==n);_.state.setIndices({activeIndex:null,selectedIndex:null,type:_.state.keyboardActiveRef.current?`keyboard`:`pointer`}),_.state.setSelectedValue(r,At(Je,e.nativeEvent));return}let i=h?.highlightedChipIndex!==void 0,a=ke(e);if(h?.setHighlightedChipIndex(a),a===void 0?i&&_.state.inputRef.current?.focus():h?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&ae){let t=_.state.activeIndex,n=e.nativeEvent;if(t===null){if(ce)return;_.state.setOpen(!1,At(Je,n));return}be(e);let r=_.state.listRef.current[t];r&&(_.state.selectionEventRef.current=n,r.click(),_.state.selectionEventRef.current=null)}},onPointerMove(){_.state.keyboardActiveRef.current=!1},onPointerDown(){_.state.keyboardActiveRef.current=!1}},De],stateAttributesMapping:ry}),je=g?(0,R.jsx)(tt.Provider,{value:nn,children:Ae}):Ae;return(0,R.jsxs)(L.Fragment,{children:[ae&&me&&(0,R.jsx)(uy,{ref:_.state.startDismissRef}),je]})}),fy={...Me,...qe},py=L.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:s,...c}=e,{disabled:l}=xe(),u=Hv(),d=M(u,$.selectionMode),f=M(u,$.disabled),p=M(u,$.readOnly),m=M(u,$.open),h=M(u,$.selectedValue),g=M(u,$.hasSelectionChips),_=Gv(),v=!1;v=d===`none`?_!==``:d===`single`?h!=null:g;let y=l||f||i,{buttonRef:ee,getButtonProps:b}=Nt({native:a,disabled:y}),{mounted:x,transitionStatus:te,setMounted:S}=st(v),C={disabled:y,visible:v,open:m,transitionStatus:te};cn({open:v,ref:u.state.clearRef,onComplete(){v||S(!1)}});let w=Yt(`button`,e,{state:C,ref:[t,ee,u.state.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(y||p)return;let t=u.state.keyboardActiveRef;u.state.setInputValue(``,At(on,e.nativeEvent)),d===`none`?u.state.setIndices({activeIndex:null,type:t.current?`keyboard`:`pointer`}):(u.state.setSelectedValue(Array.isArray(h)?[]:null,At(on,e.nativeEvent)),u.state.setIndices({activeIndex:null,selectedIndex:null,type:t.current?`keyboard`:`pointer`})),u.state.inputRef.current?.focus()}},c,b],stateAttributesMapping:fy});return o||x?w:null}),my=L.createContext(null);function hy(){return L.useContext(my)}function gy(e){let{children:t}=e,{filteredItems:n}=Wv(),r=hy(),i=r?r.items:n;return i?(0,R.jsx)(L.Fragment,{children:i.map(t)}):null}var _y=L.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=Hv(),l=Uv(),u=!!ly(!0),{filteredItems:d,hasItems:f}=Wv(),p=M(c,$.selectionMode),m=M(c,$.grid),h=M(c,$.popupProps),g=M(c,$.virtualized),_=M(c,$.forceMounted),v=p===`multiple`,y=d.length===0,ee=Dt(e=>{c.set(`positionerElement`,e)}),b=Dt(e=>{c.set(`listElement`,e)}),x=L.useMemo(()=>typeof o==`function`?n||=(0,R.jsx)(gy,{children:o}):o,[o]),te={empty:y},S=l.useState(`floatingId`),C=Yt(`div`,e,{state:te,ref:[t,b,u?null:ee],props:[h,{children:x,tabIndex:-1,id:S,role:m?`grid`:`listbox`,"aria-multiselectable":v?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;be(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(g)return C;let w=f&&!_?void 0:c.state.labelsRef;return(0,R.jsx)(Ge,{elementsRef:c.state.listRef,labelsRef:w,children:C})}),vy=``;function yy(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 by(){let e=Ae(),t=L.useRef(null);return L.useEffect(()=>{if(dt)return;let n=t.current;if(n==null)return;let r=yy(n);if(r==null)return;let i=r.nodeValue??``,a=`${i}${vy}`;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 xy=L.createContext(void 0);function Sy(){let e=L.useContext(xy);if(e===void 0)throw Error(Re(20));return e}var Cy=L.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Hv(),a=M(i,$.mounted),o=M(i,$.forceMounted);return a||n||o?(0,R.jsx)(xy.Provider,{value:n,children:(0,R.jsx)(Qe,{ref:t,...r})}):null}),wy=L.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:m=!1,collisionAvoidance:h=Et,style:g,..._}=e,v=Hv(),{filteredItems:y}=Wv(),ee=Uv(),b=Sy(),x=M(v,$.modal),te=M(v,$.open),S=M(v,$.mounted),C=M(v,$.openMethod),w=M(v,$.positionerElement),ne=M(v,$.triggerElement),T=M(v,$.inputElement),re=M(v,$.inputGroupElement),ie=M(v,$.inputInsidePopup),ae=M(v,$.transitionStatus),E=y.length===0,D=Ye({anchor:i??(ie?ne:re??T),floatingRootContext:ee,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});He(te&&x,C===`touch`,w,ne);let O={open:te,side:D.side,align:D.align,anchorHidden:D.anchorHidden,empty:E};Wt(()=>{v.set(`popupSide`,D.side)},[v,D.side]);let oe=Dt(e=>{v.set(`positionerElement`,e)}),se=Ee(e,O,{styles:D.positionerStyles,transitionStatus:ae,props:_,refs:[t,oe],hidden:!S,inert:!te});return(0,R.jsxs)(cy.Provider,{value:D,children:[S&&x&&(0,R.jsx)(ve,{inert:it(!te),cutout:re??T??ne}),se]})}),Ty={...Ft,...Me},Ey=L.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Hv(),l=ly(),u=Uv(),{filteredItems:d}=Wv(),f=M(c,$.mounted),p=M(c,$.open),m=M(c,$.openMethod),h=M(c,$.transitionStatus),g=M(c,$.inputInsidePopup),_=M(c,$.inputElement),v=M(c,$.modal),y=M(c,$.id),ee=d.length===0,b=s.id??(g?qv(y):void 0);Wt(()=>(c.set(`popupId`,c.state.popupRef.current?.id||b),()=>{c.set(`popupId`,void 0)}),[c,b]),cn({open:p,ref:c.state.popupRef,onComplete(){p&&c.state.onOpenChangeComplete(!0)}});let x=Yt(`div`,e,{state:{open:p,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:ee},ref:[t,c.state.popupRef],props:[{id:b,role:g?`dialog`:`presentation`,tabIndex:-1,onFocus(e){let t=Be(e.nativeEvent);m!==`touch`&&(Pe(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},we(h),s],stateAttributesMapping:Ty}),te=a===void 0?g?e=>e===`touch`?c.state.popupRef.current:_:!1:a,S;S=o??(g?void 0:!1);let C=!g||v;return(0,R.jsx)(gt,{context:u,disabled:!f,modal:C,openInteractionType:m,initialFocus:te,returnFocus:S,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,R.jsxs)(L.Fragment,{children:[x,C&&(0,R.jsx)(uy,{ref:c.state.endDismissRef})]})})}),Dy=L.createContext(void 0);function Oy(){let e=L.useContext(Dy);if(!e)throw Error(Re(19));return e}var ky=L.createContext(!1);function Ay(){return L.useContext(ky)}var jy=e(r(),1);function My(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:l=null,index:u,disabled:d=!1,nativeButton:f=!1,...p}=t,m=L.useRef(!1),h=L.useRef(null),g=Ne({index:u,textRef:h,indexGuessBehavior:De.GuessFromOrder}),_=Hv(),v=Ay(),y=Kv(),ee=M(_,$.open),b=M(_,$.selectionMode),x=M(_,$.readOnly),te=M(_,$.isItemEqualToValue),S=b!==`none`,C=u??(r?i??-1:g.index),w=g.index!==-1,ne=M(_,$.id),T=M(_,$.isActive,C),re=M(_,$.isSelected,l),ie=M(_,$.itemProps),ae=L.useRef(null),E=ne!=null&&w?`${ne}-${C}`:void 0,D=re&&S;Wt(()=>{if(!(w&&(r||u!=null)))return;let e=_.state.listRef.current;return e[C]=ae.current,()=>{delete e[C]}},[w,r,C,u,_]),Wt(()=>{if(!w||y)return;let e=_.state.valuesRef.current;return e[C]=l,b!==`none`&&_.state.allValuesRef.current.push(l),()=>{delete e[C]}},[w,y,C,l,_,b]),Wt(()=>{if(!ee){m.current=!1;return}if(!w||y)return;let e=_.state.selectedValue,t=Array.isArray(e)?e[e.length-1]:e;c(l,t,te)&&_.set(`selectedIndex`,C)},[w,y,ee,_,C,l,te]);let{getButtonProps:O,buttonRef:oe}=Nt({disabled:d,focusableWhenDisabled:!0,native:f,composite:!0}),se={disabled:d,selected:D,highlighted:T};function ce(e){function t(){_.state.handleSelection(e,l)}_.state.submitOnItemClick?(jy.flushSync(t),_.state.requestSubmit()):t()}let k={id:E,role:v?`gridcell`:`option`,"aria-selected":S?D:void 0,tabIndex:void 0,onPointerDownCapture(e){m.current=!0,e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){d||x||ce(e.nativeEvent)},onMouseUp(e){let t=m.current;m.current=!1,!(d||x||e.button!==0||t||!T)&&ce(e.nativeEvent)}},le=Yt(`div`,t,{ref:[oe,n,g.ref,ae],state:se,props:[ie,k,p,O]}),ue=L.useMemo(()=>({selected:D,textRef:h}),[D,h]);return(0,R.jsx)(Dy.Provider,{value:ue,children:le})}function Ny(e){let{componentProps:t,forwardedRef:n}=e,r=M(Hv(),$.isItemEqualToValue),{flatFilteredItems:i}=Wv();return(0,R.jsx)(My,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:f(i,t.value??null,r)})}var Py=L.memo(L.forwardRef(function(e,t){let n=M(Hv(),$.virtualized);return n&&e.index==null?(0,R.jsx)(Ny,{componentProps:e,forwardedRef:t}):(0,R.jsx)(My,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),Fy=L.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=Wv(),c=Hv(),l=by(),u=s.length===0?a:null;return Yt(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function Iy(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,R.jsx)(ny,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var Ly=L.forwardRef(function(e,t){let n=e.keepMounted??!1,{selected:r}=Oy();return n||r?(0,R.jsx)(Ry,{...e,ref:t}):null}),Ry=L.memo(L.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Oy(),c=L.useRef(null),{transitionStatus:l,setMounted:u}=st(s),d=Yt(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:Me});return cn({open:s,ref:c,onComplete(){s||u(!1)}}),d})),zy=Iy;function By({className:e,children:t,...n}){return(0,R.jsxs)(ay,{"data-slot":`combobox-trigger`,className:tn(`cursor-pointer data-disabled:cursor-not-allowed [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,R.jsx)(l,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function Vy({className:e,...t}){return(0,R.jsx)(py,{"data-slot":`combobox-clear`,render:(0,R.jsx)(S,{variant:`ghost`,size:`icon-xs`}),className:tn(e),...t,children:(0,R.jsx)(C,{className:`pointer-events-none`})})}function Hy({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...a}){return(0,R.jsxs)(T,{className:tn(`w-auto`,e),children:[(0,R.jsx)(dy,{render:(0,R.jsx)(_,{disabled:n}),...a}),(0,R.jsxs)(ie,{align:`inline-end`,children:[r&&(0,R.jsx)(S,{size:`icon-xs`,variant:`ghost`,render:(0,R.jsx)(By,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n}),i&&(0,R.jsx)(Vy,{disabled:n})]}),t]})}function Uy({className:e,side:t=`bottom`,sideOffset:n=6,align:r=`start`,alignOffset:i=0,anchor:a,...o}){return(0,R.jsx)(Cy,{children:(0,R.jsx)(wy,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:a,className:`isolate z-50`,children:(0,R.jsx)(Ey,{"data-slot":`combobox-content`,"data-chips":!!a,className:tn(`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 Wy({className:e,...t}){return(0,R.jsx)(_y,{"data-slot":`combobox-list`,className:tn(`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 Gy({className:e,children:t,...n}){return(0,R.jsxs)(Py,{"data-slot":`combobox-item`,className:tn(`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,R.jsx)(Ly,{render:(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,R.jsx)(Qt,{className:`pointer-events-none`})})]})}function Ky({className:e,...t}){return(0,R.jsx)(Fy,{"data-slot":`combobox-empty`,className:tn(`hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex`,e),...t})}var qy=`cline.code.model-selection.v1`;function Jy(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 Yy(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:Jy(r.lastModelByProvider)}:{lastProvider:``,lastModelByProvider:Jy(n)}}catch{return t}}function Xy(){return typeof window>`u`?{lastProvider:``,lastModelByProvider:{}}:Yy(window.localStorage.getItem(qy))}var Zy={openai:`openai-native`,google:`gemini`};function Qy(e){let t=e.trim();return t?Zy[t]??t:``}function $y(e){return(e??[]).map(e=>e.id)}function eb(e){return(e??[]).filter(e=>e.supportsReasoning).map(e=>e.id)}function tb(e){return{providers:e,enabledProviderIds:e.filter(e=>e.enabled).map(e=>e.id),providerModels:Object.fromEntries(e.map(e=>[e.id,$y(e.modelList)])),providerReasoningModels:Object.fromEntries(e.map(e=>[e.id,eb(e.modelList)]))}}async function nb(){return tb((await A.invoke(`list_provider_catalog`)).providers??[])}async function rb(e){return(await A.invoke(`list_provider_models`,{provider:e})).models??[]}var ib=3e4,ab=null;async function ob(){let e=await A.invoke(`list_routine_schedules`);return{schedules:e.schedules??[],activeExecutions:e.activeExecutions??[],upcomingRuns:e.upcomingRuns??[],lastExecutions:e.lastExecutions??[]}}var sb={cline:[ev],anthropic:[`claude-sonnet-4-6`],"openai-native":[`gpt-5.3-codex`],openrouter:[`anthropic/claude-sonnet-4.6`],gemini:[`gemini-2.5-pro`]},cb=[{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 lb(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 ub(e){let t=e.metadata?.[Q_];return typeof t==`number`&&Number.isFinite(t)?t:void 0}function db(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 fb(e){return{provider:e.modelSelection?.providerId?.trim()||e.provider?.trim()||`cline`,model:e.modelSelection?.modelId?.trim()||e.model?.trim()||`anthropic/claude-sonnet-5`}}function pb(e){if(!e)return`-`;let t=e.status?.trim()||`unknown`,n=lb(e.endedAt??e.startedAt??e.triggeredAt);return n===`-`?t:`${t} at ${n}`}function mb(e){return typeof e==`string`?e.trim():``}function hb(e){let t=mb(e);if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<=0))return n}function gb(e){if(typeof e!=`string`)return;let t=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t:void 0}function _b(e){let t=new Set(e);return cb.map(e=>e.value).filter(e=>t.has(e))}function vb(e,t,n){let r=_b(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===cb.length?`${s} ${o} * * *`:`${s} ${o} * * ${r.join(`,`)}`}function yb(e){let t=e?.trim().toUpperCase();if(!t||t===`*`)return cb.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=cb.findIndex(e=>e.value===r[1]),t=cb.findIndex(e=>e.value===r[2]);if(e>=0&&t>=e)for(let r=e;r<=t;r+=1)n.add(cb[r].value);continue}cb.some(e=>e.value===t)&&n.add(t)}return _b([...n])}function bb(e){let t=e.trim().split(/\s+/),n=Number.parseInt(t[0]??``,10),r=Number.parseInt(t[1]??``,10),i=yb(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 xb(){let[e,t]=(0,L.useState)(()=>ab?.schedules??[]),[n,r]=(0,L.useState)(()=>ab?.activeExecutions??[]),[i,a]=(0,L.useState)(()=>ab?.upcomingRuns??[]),[o,s]=(0,L.useState)(()=>ab?.lastExecutions??[]),[c,l]=(0,L.useState)(()=>!ab),[d,f]=(0,L.useState)(null),[m,h]=(0,L.useState)(null),[_,v]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(null),[ie,oe]=(0,L.useState)(!1),[se,k]=(0,L.useState)(null),[ue,de]=(0,L.useState)(sb),[fe,me]=(0,L.useState)(()=>Object.keys(sb)),[_e]=(0,L.useState)(()=>Xy()),ve=Qy(_e.lastProvider),[j,be]=(0,L.useState)({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:`cline`,model:ev,workspaceRoot:``,systemPrompt:``,timeoutSeconds:``,tags:``,enabled:!0}),xe=(0,L.useMemo)(()=>{if(fe.length===0)return ue;let e={};for(let t of fe)e[t]=ue[t]??[];return e},[fe,ue]),Se=(0,L.useMemo)(()=>Object.keys(xe),[xe]),Ce=(0,L.useMemo)(()=>xe[j.provider]??[],[j.provider,xe]),we=(0,L.useMemo)(()=>vb(j.scheduleDays,j.scheduleHour,j.scheduleMinute),[j.scheduleDays,j.scheduleHour,j.scheduleMinute]);(0,L.useEffect)(()=>{let e=!1;async function t(){try{let t=await nb();if(e)return;de(t.providerModels),me(e=>{let n=new Set(t.enabledProviderIds),r=Qy(j.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}},[j.provider]),(0,L.useEffect)(()=>{let e=Qy(j.provider);if(!e||(ue[e]??[]).length>0)return;let t=!1;async function n(){try{let n=await rb(e);if(t||n.length===0)return;de(t=>({...t,[e]:n.map(e=>e.id)})),me(t=>t.includes(e)?t:[...t,e])}catch{}}return n(),()=>{t=!0}},[j.provider,ue]),(0,L.useEffect)(()=>{if(Se.length===0)return;let e=null,t=Qy(j.provider);if(Se.includes(t)){let n=xe[t]??[];if(n.length===0||n.includes(j.model))return;let r=_e.lastModelByProvider[t]??_e.lastModelByProvider[_e.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]}}else{let t=ve&&Se.includes(ve)?ve:Se[0],n=xe[t]??[],r=_e.lastModelByProvider[t]??_e.lastModelByProvider[_e.lastProvider];e={provider:t,model:r&&n.includes(r)?r:n[0]??``}}let n=window.setTimeout(()=>{be(t=>({...t,...e}))},0);return()=>window.clearTimeout(n)},[Se,j.model,j.provider,_e.lastModelByProvider,_e.lastProvider,ve,xe]);let Te=(0,L.useCallback)(async e=>{let n=Date.now();if(!e?.force&&ab&&n-ab.fetchedAt<ib){t(ab.schedules),r(ab.activeExecutions),a(ab.upcomingRuns),s(ab.lastExecutions),f(null),l(!1);return}e?.showLoading!==!1&&l(!0),f(null);try{let e=await ob(),i=e.schedules,o=e.activeExecutions,c=e.upcomingRuns,l=e.lastExecutions;t(i),r(o),a(c),s(l),ab={schedules:i,activeExecutions:o,upcomingRuns:c,lastExecutions:l,fetchedAt:n}}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{l(!1)}},[]);(0,L.useEffect)(()=>{let e=window.setTimeout(()=>{Te()},0);return()=>window.clearTimeout(e)},[Te]);let Ee=async(e,t)=>{h(e.scheduleId),f(null);try{t?await A.invoke(`resume_routine_schedule`,{schedule_id:e.scheduleId}):await A.invoke(`pause_routine_schedule`,{schedule_id:e.scheduleId}),await Te({force:!0,showLoading:!1})}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{h(null)}},De=async e=>{h(e),f(null);try{await A.invoke(`trigger_routine_schedule`,{schedule_id:e}),await Te({force:!0,showLoading:!1}),window.setTimeout(()=>{Te({force:!0,showLoading:!1})},1e3)}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{h(null)}},Oe=async e=>{h(e),f(null);try{await A.invoke(`delete_routine_schedule`,{schedule_id:e}),v(null),await Te({force:!0,showLoading:!1})}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{h(null)}},Ae=async()=>{T(null),f(null),k(null);let e={workspaceRoot:``,cwd:``};try{e=await A.invoke(`get_process_context`)}catch{}let t=ve&&Se.includes(ve)?ve:Se[0]??`cline`,n=xe[t]??[],r=_e.lastModelByProvider[t]??_e.lastModelByProvider[_e.lastProvider],i=r&&n.includes(r)?r:n[0]??j.model;be({name:``,scheduleHour:`9`,scheduleMinute:`0`,scheduleDays:[`MON`,`TUE`,`WED`,`THU`,`FRI`],prompt:`Review PRs opened yesterday and summarize issues.`,provider:t,model:i,workspaceRoot:e.workspaceRoot||e.cwd,systemPrompt:``,timeoutSeconds:``,tags:``,enabled:!0}),C(!0)},M=e=>{if(e.cronPattern===`0`)return;let{provider:t,model:n}=fb(e),r=bb(e.cronPattern);T(e),f(null),k(null),me(e=>e.includes(t)?e:[...e,t]),de(e=>e[t]?.includes(n)?e:{...e,[t]:[...e[t]??[],n]}),be({name:e.name,...r,prompt:e.prompt,provider:t,model:n,workspaceRoot:e.workspaceRoot??``,systemPrompt:e.systemPrompt??``,timeoutSeconds:typeof e.timeoutSeconds==`number`?String(e.timeoutSeconds):``,tags:e.tags?.join(`,`)??``,enabled:e.enabled}),C(!0)},Me=async()=>{let e=mb(j.name);if(!e){k(`Routine name is required.`);return}let t=vb(j.scheduleDays,j.scheduleHour,j.scheduleMinute);if(!t){k(`Select at least one day and a valid time.`);return}let n=mb(j.prompt);if(!n){k(`Prompt is required.`);return}let r=mb(j.workspaceRoot);if(!r){k(`Workspace root is required.`);return}k(null),oe(!0);try{let i=Qy(mb(j.provider))||Se[0]||`cline`,a=mb(j.model)||(xe[i]??[])[0]||`anthropic/claude-sonnet-5`,o=mb(j.systemPrompt),s=hb(j.timeoutSeconds),c=gb(j.tags),l=w?`update_routine_schedule`:`create_routine_schedule`;await A.invoke(l,{...w?{schedule_id:w.scheduleId}:void 0,name:e,cron_pattern:t,prompt:n,provider:i,model:a,mode:w?.mode??`yolo`,workspace_root:r,cwd:w?w.cwd??null:r,system_prompt:w?o||null:o||void 0,timeout_seconds:w?s??null:s,max_parallel:1,enabled:j.enabled,tags:c??[]}),await Te({force:!0,showLoading:!1}),C(!1),T(null)}catch(e){let t=e instanceof Error?e.message:String(e);k(t)}finally{oe(!1)}},Ne=(0,L.useMemo)(()=>{let e=new Map;for(let t of n)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[n]),Pe=(0,L.useMemo)(()=>{let e=new Map;for(let t of o)t.scheduleId&&(e.has(t.scheduleId)||e.set(t.scheduleId,t));return e},[o]),Fe=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.name.toLowerCase().localeCompare(t.name.toLowerCase())),[e]);return(0,R.jsxs)(wt,{children:[(0,R.jsx)(Lt,{description:`Scheduled jobs are run through the hub.`,title:`Schedules`,meta:(0,R.jsx)(Vt,{children:`cline schedule`}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void Te(),disabled:c,children:(0,R.jsx)(he,{className:tn(`h-4 w-4`,c&&`animate-spin`)})}),(0,R.jsxs)(N,{size:`sm`,onClick:()=>void Ae(),children:[(0,R.jsx)(u,{className:`h-4 w-4`}),`New Schedule`]})]})}),d&&(0,R.jsx)(`div`,{className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}),c?(0,R.jsx)(qt,{children:`Loading schedules...`}):Fe.length===0?(0,R.jsx)(qt,{children:`No schedules found. Create a schedule to run routines on a recurring basis.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:Fe.map(e=>{let t=m===e.scheduleId,n=Ne.get(e.scheduleId),r=Pe.get(e.scheduleId),a=i.find(t=>t.scheduleId===e.scheduleId);return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border px-5 py-4 transition-colors hover:bg-accent/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(p,{className:tn(`h-2.5 w-2.5 shrink-0`,e.enabled?`fill-primary text-primary`:`fill-muted-foreground/40 text-muted-foreground/40`)}),(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.mode}),(0,R.jsx)(`span`,{className:`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,children:e.cronPattern===`0`?`Once · ${lb(ub(e))}`:e.cronPattern}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`View ${e.name}`,onClick:()=>{window.alert(JSON.stringify(e,null,2))},children:(0,R.jsx)(gn,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:()=>M(e),disabled:t||e.cronPattern===`0`,children:(0,R.jsx)(Ot,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run ${e.name} now`,onClick:()=>void De(e.scheduleId),disabled:t,children:(0,R.jsx)(ge,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":e.enabled?`Pause ${e.name}`:`Resume ${e.name}`,onClick:()=>void Ee(e,!e.enabled),disabled:t,children:e.enabled?(0,R.jsx)(xn,{className:`h-3.5 w-3.5`}):(0,R.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,onClick:()=>v(e),disabled:t,children:(0,R.jsx)(Xt,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(pe,{checked:e.enabled,onCheckedChange:t=>void Ee(e,t),disabled:t,"aria-label":`Enable ${e.name}`})]})]}),(0,R.jsxs)(`div`,{className:`mt-2.5 ml-5.5 flex flex-col gap-1 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`ID:`}),` `,e.scheduleId]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Prompt:`}),` `,e.prompt]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Model:`}),` `,db(e)]}),e.workspaceRoot&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Workspace:`}),` `,e.workspaceRoot]}),e.cwd&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`CWD:`}),` `,e.cwd]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last run:`}),` `,lb(e.lastRunAt)]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last result:`}),` `,pb(r)]}),r?.sessionId&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last session:`}),` `,r.sessionId]}),r?.errorMessage&&(0,R.jsxs)(`p`,{className:`text-destructive`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Last error:`}),` `,r.errorMessage]}),(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Next run:`}),` `,lb(e.nextRunAt||a?.nextRunAt)]}),n&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Active:`}),` `,n.executionId,` since`,` `,lb(n.startedAt)]}),e.tags&&e.tags.length>0&&(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/70`,children:`Tags:`}),` `,e.tags.join(`, `)]})]})]},e.scheduleId)})}),(0,R.jsx)($e,{open:!!_,onOpenChange:e=>{e||v(null)},children:(0,R.jsxs)(ct,{children:[(0,R.jsxs)(ut,{children:[(0,R.jsx)(ke,{children:`Delete Routine`}),(0,R.jsxs)(je,{children:[`This will delete "`,_?.name??`this routine`,`" and remove future scheduled runs.`]})]}),(0,R.jsxs)(at,{children:[(0,R.jsx)(ye,{disabled:_?m===_.scheduleId:!1,children:`Cancel`}),(0,R.jsx)(sn,{disabled:!_||m===_.scheduleId,onClick:()=>{_&&Oe(_.scheduleId)},variant:`destructive`,children:`Delete`})]})]})}),(0,R.jsx)(y,{open:S,onOpenChange:e=>{C(e),e||(k(null),T(null))},children:(0,R.jsxs)(ne,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:[(0,R.jsxs)(b,{children:[(0,R.jsx)(re,{children:w?`Edit Routine`:`Create Routine`}),(0,R.jsx)(D,{children:w?`Update this scheduler routine.`:`Create a scheduler routine.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(E,{htmlFor:`routine-name`,children:`Name`}),(0,R.jsx)(kt,{id:`routine-name`,value:j.name,onChange:e=>be(t=>({...t,name:e.target.value})),placeholder:`Daily code review`})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2 space-y-3`,children:[(0,R.jsx)(E,{children:`Schedule`}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 rounded-md border border-border p-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{htmlFor:`routine-hour`,children:`Hour`}),(0,R.jsxs)(te,{value:j.scheduleHour,onValueChange:e=>be(t=>({...t,scheduleHour:e??t.scheduleHour})),children:[(0,R.jsx)(O,{className:`w-full`,id:`routine-hour`,children:(0,R.jsx)(ce,{placeholder:`Hour`})}),(0,R.jsx)(x,{children:Array.from({length:24},(e,t)=>t).map(e=>(0,R.jsx)(g,{value:`${e}`,children:e.toString().padStart(2,`0`)},`hour-${e}`))})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{htmlFor:`routine-minute`,children:`Minute`}),(0,R.jsxs)(te,{value:j.scheduleMinute,onValueChange:e=>be(t=>({...t,scheduleMinute:e??t.scheduleMinute})),children:[(0,R.jsx)(O,{className:`w-full`,id:`routine-minute`,children:(0,R.jsx)(ce,{placeholder:`Minute`})}),(0,R.jsx)(x,{children:Array.from({length:60},(e,t)=>t).map(e=>(0,R.jsx)(g,{value:`${e}`,children:e.toString().padStart(2,`0`)},`minute-${e}`))})]})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(E,{children:`Days of week`}),(0,R.jsx)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-4`,children:cb.map(e=>{let t=`routine-day-${e.value.toLowerCase()}`;return(0,R.jsxs)(E,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-sm`,htmlFor:t,children:[(0,R.jsx)(Fv,{checked:j.scheduleDays.includes(e.value),id:t,onCheckedChange:t=>be(n=>{let r=new Set(n.scheduleDays);return t===!0?r.add(e.value):r.delete(e.value),{...n,scheduleDays:_b([...r])}})}),e.label]},e.value)})})]}),(0,R.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,R.jsx)(`span`,{className:`font-mono text-foreground`,children:we||`Select one or more days`})]})]})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(E,{htmlFor:`routine-prompt`,children:`Prompt`}),(0,R.jsx)(ae,{id:`routine-prompt`,value:j.prompt,onChange:e=>be(t=>({...t,prompt:e.target.value})),rows:4})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{children:`Provider`}),(0,R.jsxs)(zy,{items:Se,onValueChange:e=>{if(!e)return;let t=xe[e]??[],n=_e.lastModelByProvider[e],r=n&&t.includes(n)?n:t[0]??``;be(t=>({...t,provider:e,model:r}))},value:j.provider,children:[(0,R.jsx)(Hy,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,R.jsxs)(Uy,{children:[(0,R.jsx)(Ky,{children:`No providers found.`}),(0,R.jsx)(Wy,{children:e=>(0,R.jsx)(Gy,{value:e,children:e},e)})]})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{children:`Model`}),(0,R.jsxs)(zy,{items:Ce,onValueChange:e=>{e&&be(t=>({...t,model:e}))},value:j.model,children:[(0,R.jsx)(Hy,{className:`h-9 w-full`,readOnly:!0,showClear:!1,showTrigger:!0}),(0,R.jsxs)(Uy,{children:[(0,R.jsx)(Ky,{children:`No models found.`}),(0,R.jsx)(Wy,{children:e=>(0,R.jsx)(Gy,{value:e,children:e},e)})]})]})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(E,{htmlFor:`routine-workspace`,children:`Workspace root`}),(0,R.jsx)(kt,{id:`routine-workspace`,value:j.workspaceRoot,onChange:e=>be(t=>({...t,workspaceRoot:e.target.value}))})]}),(0,R.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,R.jsx)(E,{htmlFor:`routine-system-prompt`,children:`System prompt (optional)`}),(0,R.jsx)(ae,{id:`routine-system-prompt`,value:j.systemPrompt,onChange:e=>be(t=>({...t,systemPrompt:e.target.value})),rows:3})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{htmlFor:`routine-timeout`,children:`Timeout seconds (optional)`}),(0,R.jsx)(kt,{id:`routine-timeout`,value:j.timeoutSeconds,onChange:e=>be(t=>({...t,timeoutSeconds:e.target.value})),placeholder:`3600`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(E,{htmlFor:`routine-tags`,children:`Tags (comma-separated, optional)`}),(0,R.jsx)(kt,{id:`routine-tags`,value:j.tags,onChange:e=>be(t=>({...t,tags:e.target.value})),placeholder:`automation,review`})]})]}),se&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:se}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(N,{variant:`outline`,onClick:()=>C(!1),disabled:ie,children:`Cancel`}),(0,R.jsx)(N,{onClick:()=>void Me(),disabled:ie,children:ie?w?`Saving...`:`Creating...`:w?`Save Changes`:`Create Schedule`})]})]})})]})}function Sb(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 Cb(e){let t={};for(let[n,r]of Object.entries(e))Sb(t,n,r);return t}var wb=[`General`,`Providers`,`MCP`,`Channels`,`Schedules`,`Account`],Tb=6e4,Eb=null;function Db({chrome:e=`full`,initialSection:t=`General`,onClose:n,onNavigateSection:r}){let[i,a]=(0,L.useState)(t),[o,s]=(0,L.useState)(!0),[c,u]=(0,L.useState)(()=>Eb?.providers??[]),[d,f]=(0,L.useState)(()=>!Eb),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)({}),[_,v]=(0,L.useState)({}),[y,ee]=(0,L.useState)(null),[b,x]=(0,L.useState)(null),[te,S]=(0,L.useState)(!1),w=(0,L.useCallback)(e=>{u(t=>{let n=typeof e==`function`?e(t):e;return Eb={providers:n,fetchedAt:Date.now()},n})},[]),ne=(0,L.useCallback)(async()=>{if(Eb&&Date.now()-Eb.fetchedAt<Tb){u(Eb.providers),f(!1),m(null);return}f(!0),m(null);try{let e=await A.invoke(`list_provider_catalog`);w(e.providers)}catch(e){let t=e instanceof Error?e.message:String(e);m(t),u([])}finally{f(!1)}},[w]);(0,L.useEffect)(()=>{if(i!==`Providers`)return;let e=window.setTimeout(()=>{ne()},0);return()=>window.clearTimeout(e)},[i,ne]);let T=(0,L.useCallback)(async(e,t)=>{try{await A.invoke(`save_provider_settings`,{provider:e,enabled:t.enabled,api_key:t.apiKey,base_url:t.baseUrl,settings:t.configValues?Cb(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}`)}},[]),re=(0,L.useCallback)(e=>{w(t=>t.map(t=>{if(t.id!==e)return t;let n=!t.enabled;return T(e,{enabled:n}),{...t,enabled:n}}))},[T,w]),ie=(0,L.useCallback)((e,t)=>{w(n=>n.map(n=>n.id===e?{...n,...t,configValues:t.configValues?{...n.configValues??{},...t.configValues}:n.configValues}:n)),T(e,{apiKey:t.apiKey,baseUrl:t.baseUrl,configValues:t.configValues})},[T,w]),ae=(0,L.useCallback)(async e=>{g(t=>({...t,[e]:!0})),v(t=>({...t,[e]:null}));try{let t=await A.invoke(`list_provider_models`,{provider:e});w(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}))}},[w]),E=c.filter(e=>e.enabled),D=b?c.find(e=>e.id===b)??null:null,O=e=>e.capabilities?.includes(`oauth`)??!1,oe=async e=>{ee(e);try{let t=await A.invoke(`run_provider_oauth_login`,{provider:e});w(n=>n.map(n=>n.id===e?{...n,enabled:!0,oauthAccessTokenPresent:t.accessToken.trim().length>0}:n)),x(e)}catch(t){let n=t instanceof Error?t.message:String(t);window.alert(`Failed to sign in to ${e}: ${n}`)}finally{ee(null)}},se=e=>{a(`Providers`),r?.(`Providers`),x(e)};(0,L.useEffect)(()=>{if(!b)return;let e=c.find(e=>e.id===b);if(!e||(e.modelList?.length??0)>0)return;let t=window.setTimeout(()=>{ae(b)},0);return()=>window.clearTimeout(t)},[ae,c,b]);let ce=()=>{r?.(`Providers`),x(null),S(!1)},k=(0,L.useCallback)(async e=>{await A.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 ne(),S(!1),x(e.providerId)},[ne]),le=()=>{r?.(`Providers`),x(null),S(!0)},ue=e=>{a(e),r?.(e),x(null),S(!1)},de=te?(0,R.jsx)(Rn,{existingProviderIds:c.map(e=>e.id),onBack:ce,onSave:k}):d?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading providers...`})}):p?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsxs)(`p`,{className:`max-w-xl px-4 text-center text-sm text-destructive`,children:[`Failed to load providers: `,p]})}):D?(0,R.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,R.jsx)(ir,{onAddProvider:le,onConfigure:se,onToggle:re,providers:c,selectedProviderId:D.id,variant:`panel`}),(0,R.jsx)(`aside`,{className:`min-h-0 overflow-hidden border-l bg-background max-[1100px]:border-l-0 max-[1100px]:border-t`,children:(0,R.jsx)(ar,{modelsError:_[D.id]??null,modelsLoading:h[D.id]??!1,oauthLoginPending:y===D.id,onBack:ce,onLoadModels:()=>void ae(D.id),onOAuthLogin:O(D)?()=>void oe(D.id):void 0,onUpdate:e=>ie(D.id,e),provider:D,variant:`panel`})})]}):(0,R.jsx)(ir,{onAddProvider:le,onConfigure:se,onToggle:re,providers:c}),fe=i===`Providers`?de:i===`MCP`?(0,R.jsx)(er,{}):i===`Channels`?(0,R.jsx)(qn,{}):i===`Schedules`?(0,R.jsx)(xb,{}):i===`Account`?(0,R.jsx)(In,{}):i===`General`?(0,R.jsx)(Ob,{}):(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i,` settings coming soon.`]})});return e===`content`?(0,R.jsx)(`div`,{className:`h-full overflow-hidden bg-background`,children:fe}):(0,R.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border px-6 py-3`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Settings`}),(0,R.jsx)(N,{"aria-label":`Close settings`,className:`justify-start`,onClick:n,variant:`ghost`,children:(0,R.jsx)(C,{className:`size-3`})})]}),(0,R.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,R.jsx)(`nav`,{className:`w-56 shrink-0 border-r border-border`,children:(0,R.jsx)(I,{className:`h-full`,children:(0,R.jsx)(`div`,{className:`flex flex-col gap-0.5 p-3`,children:wb.map(e=>e===`Providers`?(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(N,{className:tn(`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:()=>{ue(`Providers`),s(e=>!e)},variant:`ghost`,children:[(0,R.jsx)(`span`,{children:`Providers`}),o?(0,R.jsx)(l,{className:`size-3`}):(0,R.jsx)(dn,{className:`size-3`})]}),o&&(0,R.jsx)(`div`,{className:`ml-3 mt-0.5 flex flex-col gap-0.5 border-l border-border pl-2`,children:E.map(e=>(0,R.jsx)(N,{className:tn(`justify-start`,b===e.id?`bg-accent/80 text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/30`),disabled:y===e.id,onClick:()=>se(e.id),variant:`ghost`,children:(0,R.jsx)(`span`,{className:`truncate`,children:e.name})},e.id))})]},e):(0,R.jsx)(N,{className:tn(`justify-start`,i===e&&!b?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>{ue(e)},variant:`ghost`,children:e},e))})})}),(0,R.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:fe})]})]})}function Ob(){let[e,t]=(0,L.useState)(()=>typeof window>`u`?`light`:Kt()??jt()),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!0),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(!0),[f,p]=(0,L.useState)(!0),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(null),v=(0,L.useCallback)(async()=>{a(!0),l(null),p(!0),_(null);try{let e=await A.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,L.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{let t=await A.invoke(`set_telemetry_opt_out`,{telemetry_opt_out:e});r(t.telemetryOptOut)}catch(e){let n=e instanceof Error?e.message:String(e);r(t),l(n)}finally{s(!1)}},ee=async e=>{let t=u;d(e),h(!0),_(null);try{let t=await A.invoke(`set_auto_update_enabled`,{auto_update_enabled:e});d(t.autoUpdateEnabled)}catch(e){let n=e instanceof Error?e.message:String(e);d(t),_(n)}finally{h(!1)}};return(0,R.jsxs)(wt,{children:[(0,R.jsx)(Lt,{description:`Manage Hub preferences for this browser and CLI environment.`,title:`Settings`}),(0,R.jsxs)(`section`,{className:`max-w-[86rem]`,children:[(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Dark mode`}),(0,R.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Keep the Hub interface in dark mode on this browser.`})]}),(0,R.jsx)(pe,{"aria-label":`Dark mode`,checked:e===`dark`,onCheckedChange:e=>{t(bt(e?`dark`:`light`)),window.dispatchEvent(new Event(`cline-hub-theme-change`))}})]}),(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Auto update`}),(0,R.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Automatically install CLI updates on startup.`}),g?(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update auto update setting: `,g]}):null]}),(0,R.jsx)(pe,{"aria-label":`Auto update`,checked:u,disabled:f||m,onCheckedChange:e=>void ee(e)})]}),(0,R.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,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[17px] font-semibold text-foreground`,children:`Telemetry`}),(0,R.jsx)(`p`,{className:`mt-1 text-[15px] text-muted-foreground`,children:`Enable error and usage report to help us improve Cline.`}),c?(0,R.jsxs)(`p`,{className:`mt-2 text-xs text-destructive`,children:[`Failed to update telemetry setting: `,c]}):null]}),(0,R.jsx)(pe,{"aria-label":`Telemetry`,checked:!n,disabled:i||o,onCheckedChange:e=>void y(!e)})]})]})]})}export{Db as SettingsView};
|