openpond 0.0.48 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{app-layer-4PR4BS7N.js → app-layer-E2JWCA6D.js} +2 -2
- package/dist/chunks/{app-server-runtime-NR6VUXZG.js → app-server-runtime-OWEIHFEU.js} +6 -6
- package/dist/chunks/{apps-V7TF6RTV.js → apps-VQDIVGST.js} +2 -2
- package/dist/chunks/{chunk-CGVG46T5.js → chunk-3BR4ACFF.js} +1 -1
- package/dist/chunks/{chunk-VTCLHCHX.js → chunk-64LWPRGN.js} +2 -2
- package/dist/chunks/{chunk-I4CQJSZK.js → chunk-7G472COA.js} +451 -80
- package/dist/chunks/{chunk-37IPWV2S.js → chunk-7M4HGT5X.js} +1 -1
- package/dist/chunks/{chunk-4GHFK3DG.js → chunk-CNIMJPM5.js} +1305 -891
- package/dist/chunks/{chunk-HGJQUQAP.js → chunk-LRLDBKTI.js} +1 -1
- package/dist/chunks/{chunk-YYJH2WWX.js → chunk-NR2N6JAC.js} +1 -1
- package/dist/chunks/{chunk-IM67TWCC.js → chunk-NRLI3S72.js} +1 -1
- package/dist/chunks/{chunk-YBQTQWOY.js → chunk-QD4FR3O4.js} +32 -32
- package/dist/chunks/{chunk-RUEMWXU6.js → chunk-UJV3UYLP.js} +1 -1
- package/dist/chunks/{cli-7APSIEWR.js → cli-T6TTMVSU.js} +5 -5
- package/dist/chunks/{core-commands-O76V62SB.js → core-commands-UW4XTGXK.js} +3 -3
- package/dist/chunks/{desktop-test-N2UPF5PP.js → desktop-test-JTBPE7CH.js} +2 -2
- package/dist/chunks/{extension-XQBSBEVO.js → extension-VP7LMA32.js} +1 -1
- package/dist/chunks/{help-YSGYNWPJ.js → help-OZNCHHO3.js} +1 -1
- package/dist/chunks/{opchat-F5OFTH56.js → opchat-RY3QU5UJ.js} +2 -2
- package/dist/chunks/{organizations-EEQPOIAZ.js → organizations-GLKSXK3Q.js} +4 -4
- package/dist/chunks/{profile-3OGGNTDS.js → profile-JWUYJF23.js} +2 -2
- package/dist/chunks/{project-agent-LVOSTVE5.js → project-agent-L4EB7QFO.js} +2 -2
- package/dist/chunks/{sandbox-command-S3VMWGMH.js → sandbox-command-26255MSV.js} +2 -2
- package/dist/chunks/{sandbox-template-UDXW7LRZ.js → sandbox-template-6UDA3AEY.js} +3 -3
- package/dist/chunks/{src-EFVACWDG.js → src-7S66FU4P.js} +22 -21
- package/dist/chunks/{src-JMDVVYFD.js → src-GCZ2GMG3.js} +3 -3
- package/dist/chunks/{teams-bot-YRKKQDYL.js → teams-bot-PO3GOLWU.js} +2 -2
- package/dist/chunks/{workspaces-5LKGF3AG.js → workspaces-26IF6TQV.js} +2 -2
- package/dist/cli.js +13 -13
- package/dist/web/assets/{AppDialog-Bqw26W0m.js → AppDialog-BTOxCNC5.js} +1 -1
- package/dist/web/assets/{AppsView-CWhWKF1c.js → AppsView-Cm5x09IS.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-MTkosLlw.js → BrowserSidebar-CIPh5JIn.js} +1 -1
- package/dist/web/assets/{CommandMenu-Bz9bpiwl.js → CommandMenu-DdR82TLd.js} +1 -1
- package/dist/web/assets/{CommunityView-BqFeUGPj.js → CommunityView-Dqu4cos1.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-B6BBqdaL.js → ComposerCreateImproveStrip-CW2QuI7r.js} +1 -1
- package/dist/web/assets/{GetStartedView-BsgErNU9.js → GetStartedView--CbCnzFQ.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-BLnFb7Mt.js → LabModelVersionDetailPage-BPUvR5XP.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-Ba6gRUbM.js → LabSkillSidebar-CnuyFZ1G.js} +1 -1
- package/dist/web/assets/{LabsRoute-BFV7VPOU.js → LabsRoute-CYk2dzQp.js} +3 -3
- package/dist/web/assets/{MainChatThread-B283zmgR.js → MainChatThread-0Tc95p0t.js} +2 -2
- package/dist/web/assets/{MainPane-Lv073mMC.js → MainPane-Bke4JEHC.js} +3 -3
- package/dist/web/assets/{MarkdownText-CinDMr2e.js → MarkdownText-DTBS9xe7.js} +1 -1
- package/dist/web/assets/{Messages-okIKN3y-.js → Messages-Bae_sFx5.js} +1 -1
- package/dist/web/assets/{NativeSkillSidebar-B1QrK2aH.js → NativeSkillSidebar-DSoPD42b.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-CcbDk9Py.js → NewProjectDialog-CmXg2GK7.js} +1 -1
- package/dist/web/assets/{OutputsPage-CmwXC2Xd.js → OutputsPage-XmIreC0M.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-CHOpwL1L.js → RightChatPanelStack-BMOtbjus.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-BzSPcB3d.js → ScheduledWorkPage-Cn5a9VLV.js} +1 -1
- package/dist/web/assets/{SettingsView-CkmRV5NT.js → SettingsView-DXF8z3P2.js} +6 -6
- package/dist/web/assets/{TeamChatView-DevmTvuf.js → TeamChatView-CB_0oRid.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-CteY7dSQ.js → TerminalOverlay-XhABQsCB.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-AMq0npLN.js → TrainingCreationPanel-ChsDr2GP.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-BVxPaBhF.js → TrainingDraftPanel-CDlpnno6.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-BPIzRNKL.js → UsageSettingsSection-NbX7_3Uz.js} +1 -1
- package/dist/web/assets/{WorkspaceDiffPanel-DMu3IIuX.js → WorkspaceDiffPanel-jaJU08NH.js} +3 -3
- package/dist/web/assets/{WorkspaceEnvironmentMenu-ConUKuWd.js → WorkspaceEnvironmentMenu-D0nvQmmj.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-o76400dH.js → WorkspaceGitDialogs-C0PMpVfj.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-HwyVbn8h.js → WorkspaceMonacoEditor-6QNGzQUi.js} +3 -3
- package/dist/web/assets/{arrow-up-right-BKN-maHj.js → arrow-up-right-Cx2xjktp.js} +1 -1
- package/dist/web/assets/{chevron-up-CVs6VVxb.js → chevron-up-UF_r7JHT.js} +1 -1
- package/dist/web/assets/{circle-alert-C01fZFW7.js → circle-alert-BUHAQ7Du.js} +1 -1
- package/dist/web/assets/{cloud-upload-jtADHeTW.js → cloud-upload-Cc_ZQEAm.js} +1 -1
- package/dist/web/assets/{cssMode-xJZoI37_.js → cssMode-CrigFsxI.js} +1 -1
- package/dist/web/assets/{folder-open-DyyC6ByN.js → folder-open-D7a4t258.js} +1 -1
- package/dist/web/assets/{folder-plus-UGSTW1kn.js → folder-plus-CmeHTj5W.js} +1 -1
- package/dist/web/assets/{git-branch-D6gtbKJu.js → git-branch-CaVUghsI.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-C_GYw-SZ.js → git-commit-horizontal-oiDAVV_Y.js} +1 -1
- package/dist/web/assets/{htmlMode-BjKG829K.js → htmlMode-CLzM5GNi.js} +1 -1
- package/dist/web/assets/index-De6p2npi.js +1 -0
- package/dist/web/assets/index-UUM3pwfd.css +1 -0
- package/dist/web/assets/index-Ure41UF0.js +178 -0
- package/dist/web/assets/{info-z2hv9cD1.js → info-dTkimobU.js} +1 -1
- package/dist/web/assets/{jsonMode-DjZzpcCY.js → jsonMode-BBF67cOE.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-B4RETEmT.js → lspLanguageFeatures-DHtN2nxz.js} +1 -1
- package/dist/web/assets/{monaco.contribution-I3nbx1nu.js → monaco.contribution-BClTZJd2.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DJK2Dt3T.js → monaco.contribution-C_GWU01R.js} +2 -2
- package/dist/web/assets/{monaco.contribution-Du7kEHLz.js → monaco.contribution-DtM9AdPi.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DCRifLw0.js → monaco.contribution-riAIDf7J.js} +2 -2
- package/dist/web/assets/{monitor-DCUsiZyp.js → monitor-POfnZCWw.js} +1 -1
- package/dist/web/assets/{play-DCKc0E80.js → play-CjWTsI9z.js} +1 -1
- package/dist/web/assets/{python-DwbW9406.js → python-CvZQM_g2.js} +1 -1
- package/dist/web/assets/{refresh-cw-D6okuGLV.js → refresh-cw-CeHT_tXT.js} +1 -1
- package/dist/web/assets/{reply-KIN_PSFi.js → reply-BkH8nKWG.js} +1 -1
- package/dist/web/assets/{save-D7tbQpM9.js → save-CmJ92Odx.js} +1 -1
- package/dist/web/assets/{square-BUG8bwGr.js → square-B00f_944.js} +1 -1
- package/dist/web/assets/{square-pen-CWS_8PrJ.js → square-pen-LHr8bFfZ.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-CO8n70ql.js → toggleHighContrast-C6N52VOS.js} +1 -1
- package/dist/web/assets/{tsMode-f9Hqewvr.js → tsMode-CDIfvnHn.js} +1 -1
- package/dist/web/assets/{upload-DXI5er5D.js → upload-DK0-5jXz.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-BMvi6vmi.js → useLocalAgentSchedules-BUkZjV9E.js} +1 -1
- package/dist/web/assets/{wifi-off-B3ZtcrOA.js → wifi-off-BQGq-son.js} +1 -1
- package/dist/web/assets/{workers-CNGv6B0J.js → workers-BfcjsZ3C.js} +1 -1
- package/dist/web/assets/{yaml-C-tL3IVE.js → yaml-CNqgAihH.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-B8xSSlBW.js +0 -178
- package/dist/web/assets/index-C-1-yaL8.js +0 -1
- package/dist/web/assets/index-D9jTe16Q.css +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-
|
|
2
|
-
import{c as ge,j as e,r,au as rs,X as ie,av as ct,aw as dt,ax as ut,ay as ht,az as mt,aA as pt,P as me,aB as gt,aC as ft,n as $,aD as xt,aE as Ze,aF as jt,aG as vt,aH as bt,K as Ts,s as ze,aI as yt,t as Nt,L as Ee,aJ as wt,b as Os,aK as Xe,aL as Fe,ae as St,C as Ct,aM as kt,G as es,a0 as Pt,F as Le,aN as ae,aO as Rt,aP as ss,aQ as ts,a3 as Us,A as At,a1 as Dt,a2 as It,B as $t,a as zs,aR as Mt,aS as Et,p as Lt,I as ns,a8 as Ge,aT as je,ai as Tt,aU as Ot,aV as Ut,aW as zt,Z as Bt,aX as _t,_ as Ht}from"./index-B8xSSlBW.js";import{R as te}from"./refresh-cw-D6okuGLV.js";import{D as Pe,T as be,P as Bs,B as Be,W as qe,C as Ft}from"./MarkdownText-CinDMr2e.js";/* empty css */import{S as os}from"./save-D7tbQpM9.js";import{F as _s}from"./folder-open-DyyC6ByN.js";import{C as Gt}from"./chevron-up-CVs6VVxb.js";import{C as Hs}from"./circle-alert-C01fZFW7.js";import{P as Fs}from"./play-DCKc0E80.js";import{B as Gs,W as qt,S as Wt}from"./wifi-off-B3ZtcrOA.js";import{R as Te,u as Vt}from"./useLocalAgentSchedules-BMvi6vmi.js";import{C as pe}from"./cloud-upload-jtADHeTW.js";import{F as De,M as Kt}from"./monitor-DCUsiZyp.js";import{G as Oe}from"./git-commit-horizontal-C_GYw-SZ.js";import{S as Jt}from"./square-pen-CWS_8PrJ.js";import{r as Yt}from"./index-C-1-yaL8.js";import{F as Qt}from"./folder-plus-UGSTW1kn.js";import{WorkspaceDiffPanel as Zt}from"./WorkspaceDiffPanel-DMu3IIuX.js";import"./training-model-data-B7-1Bxil.js";import"./info-z2hv9cD1.js";const Xt=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],en=ge("clipboard-copy",Xt);const sn=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],tn=ge("hard-drive",sn);const nn=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ue=ge("key-round",nn);const an=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ln=ge("power",an);const rn=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],qs=ge("radio-tower",rn);const on=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],cn=ge("rotate-cw",on);const dn=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Ws=ge("sliders-horizontal",dn);const un=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],hn=ge("circle-user",un);function hs({handle:s,image:t}){const a=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:t?e.jsx("img",{src:t,alt:""}):e.jsx("span",{children:a})})}function We({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}const as="https://openpond.ai",ls="https://api.openpond.ai";function mn(s,t){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:t?.handle,currentBaseUrl:t?.baseUrl??null}}function ms(s,t){const a=t.trim().replace(/\/+$/,"");if(!a)throw new Error(`${s} is required.`);try{const n=new URL(a);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return a}function ps({account:s,busy:t,initialApiKey:a="",mode:n="update",onClose:l,onSave:i}){const u=r.useId(),c=n==="connect",[o,y]=r.useState(a),[p,x]=r.useState(!1),[d,m]=r.useState(s?.baseUrl??as),[h,j]=r.useState(s?.apiBaseUrl??ls),[S,k]=r.useState(null),[f,R]=r.useState(null);rs(f),r.useEffect(()=>{y(a),x(!1),m(s?.baseUrl??as),j(s?.apiBaseUrl??ls),k(null),R(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,a]);async function D(N){N.preventDefault(),k(null),R(null);const I=o.trim();if(c&&!I){k("API key is required.");return}let P,O;try{P=ms("Base URL",d),O=ms("API base URL",h)}catch(g){k(g instanceof Error?g.message:String(g));return}try{const g=mn(n,s);await i({...g,baseUrl:P,apiBaseUrl:O,apiKey:c?I:void 0,environment:c?pn(P,O):s?.environment??null})}catch(g){R(g instanceof Error?g.message:String(g))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&!t&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":u,onSubmit:N=>{D(N)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(ie,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:c?e.jsx(ue,{size:18}):e.jsx(Ws,{size:18})}),e.jsx("h2",{id:u,children:c?"Add account":"Account endpoints"}),c?e.jsx("p",{children:"Enter your OpenPond API key to connect another account."}):null,c?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:t,placeholder:"opk_...",type:"password",value:o,onChange:N=>y(N.target.value)})]}):null,c?e.jsxs("label",{className:"git-dialog-toggle account-dialog-advanced-toggle",children:[e.jsx("input",{checked:p,disabled:t,type:"checkbox",onChange:N=>x(N.target.checked)}),e.jsx("span",{}),"Advanced"]}):null,!c||p?e.jsxs("div",{className:"account-dialog-advanced-fields",children:[e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{autoFocus:!c,disabled:t,inputMode:"url",value:d,onChange:N=>m(N.target.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API base URL"}),e.jsx("input",{disabled:t,inputMode:"url",value:h,onChange:N=>j(N.target.value)})]})]}):null,S?e.jsx("div",{className:"profile-dialog-warning",children:S}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:t,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(os,{size:14}),e.jsx("span",{children:t?"Saving":c?"Connect account":"Update account"})]})]})]})})}function pn(s,t){return s===as&&t===ls?"production":"custom"}const gn="Changing the active OpenPond account rechecks cloud projects, hosted agents, default team, and profile sync for that account. Local projects stay on this machine; projects uploaded from another account will need to be synced again for this account.";function fn({payload:s,connection:t,saving:a,refreshingAccounts:n,saveAccount:l,refreshAccounts:i,switchAccount:u,removeAccount:c,onPayload:o,onPreferences:y,onError:p,onToast:x}){const d=s?.account,m=d?.state??"loading",h=m==="signed_in",j=m==="signed_out",S=m==="auth_error",k=d?.email?.trim()||null,f=d?.accounts??[],[R,D]=r.useState([]),[,N]=r.useState(!1),[I,P]=r.useState(null),[O,g]=r.useState(null),[C,w]=r.useState(null),[b,E]=r.useState(null),[L,G]=r.useState(!1),[K,Q]=r.useState(null),{confirmAction:v,confirmDialog:A,resolveConfirmDialog:q}=ct(),J=f.find(M=>M.isActive)??f[0]??null,W=s?.preferences.defaultTeamId?.trim()||null,X=C??W,Y=dt(d),U=s?.accountMeta.asOf??"",ne=we(d?.environment,J?.environment),re=h?we(J?.displayLabel,J?.handle,d?.label,d?.activeProfile?.handle,"Signed in"):S?"Account needs attention":j?"No account connected":"Loading account",ce=h?k??gs(ne):S?"Not connected":j?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",V=f.length>0,le=S?xn(d?.error):null,se=r.useMemo(()=>R.filter(M=>M.status==="active"),[R]),T=(r.useMemo(()=>X?se.find(M=>M.teamId===X)??null:null,[se,X])??ut(se))?.teamId??"",B=r.useMemo(()=>se.map(M=>({value:M.teamId,label:we(M.displayName,M.name,M.slug,"Team"),description:ht(M.role)})),[se]),H=T||B[0]?.value||"",z=B.length>0,_=!t||!!O||!!I||se.length===0,Ne=b?Ve(b):null,us=!!(Ne&&K===Ne),tt=h||S;r.useEffect(()=>{if(!t||!Y){D([]),P(null),N(!1);return}let M=!1;const Z=mt(Y);return Z?(D(Z),N(!1)):(D([]),N(!0)),P(null),pt({accountKey:Y,force:!!U,fetchOrganizations:async()=>(await $.organizations(t)).organizations.map(xt).filter(ee=>!!ee).filter(ee=>ee.status==="active")}).then(F=>{M||D(F)}).catch(F=>{M||(Z||D([]),P(F instanceof Error?F.message:String(F)))}).finally(()=>{M||N(!1)}),()=>{M=!0}},[U,t,Y]),r.useEffect(()=>{C&&W===C&&w(null)},[W,C]);async function nt(M,Z={notify:!0}){const F=se.find(ee=>ee.teamId===M)??null;if(!(!t||!F||O||(C??W)===F.teamId)){w(F.teamId),g(F.teamId),p(null),ft({teamId:F.teamId,accountKey:Y,force:!0,fetchAgents:async ee=>(await $.listSandboxAgents(t,{teamId:ee})).agents}).catch(()=>{});try{y(await $.savePreferences(t,{defaultTeamId:F.teamId})),Z.notify&&x?.("Default team updated","success")}catch(ee){w(null),p(ee instanceof Error?ee.message:String(ee))}finally{g(null)}}}async function _e(M="Continue"){return tt?v({title:"Change active OpenPond account?",body:gn,confirmLabel:M,cancelLabel:"Cancel"}):!0}async function at(M){await _e("Save account")&&(await l({apiKey:M.apiKey??"",handle:M.handle,baseUrl:M.baseUrl,apiBaseUrl:M.apiBaseUrl,environment:M.environment}),G(!1))}async function lt(M){if(!t||!b)throw new Error("OpenPond server connection is not ready.");if(b.isActive&&!await _e("Save endpoints"))return;const Z=Ve(b);Q(Z),p(null);try{const F=await $.updateOpenPondAccountConfig(t,{handle:M.handle??b.handle,currentBaseUrl:M.currentBaseUrl,baseUrl:M.baseUrl,apiBaseUrl:M.apiBaseUrl,chatApiBaseUrl:null,environment:jn(M.environment),setActive:b.isActive});o(F),x?.("Account endpoints updated","success"),E(null)}catch(F){throw p(F instanceof Error?F.message:String(F)),F}finally{Q(null)}}async function it(M){const Z=M.handle?.trim()||"";Z&&await _e("Switch account")&&await u(Z,M.baseUrl)}async function rt(M){const Z=M.handle?.trim()||"";if(!Z||M.isActive)return;const F=we(M.displayLabel,M.email,M.handle,"this account");await v({title:"Remove saved account?",body:`Remove ${F} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await c(Z,M.baseUrl)&&x?.("Account removed","success")}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsxs("div",{className:"account-settings-title-actions",children:[e.jsxs("button",{className:"settings-secondary compact account-add-action",disabled:!t||a,type:"button",onClick:()=>G(!0),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!t||a||n,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{i()},children:e.jsx(te,{size:15,className:n?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(hs,{handle:re,image:h?d?.avatarUrl??J?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:re}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:h&&k?"private-account-email":h?void 0:"account-summary-copy",tabIndex:h&&k?0:void 0,children:ce}),h&&z?e.jsx(Pe,{className:"account-team-dropdown",compact:!0,disabled:_,label:"Default team",options:B,value:H,onChange:M=>{nt(M)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(We,{state:m,label:j?"not signed in":void 0})})]}),V?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"OpenPond accounts"}),e.jsxs("small",{children:[f.length," account",f.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),f.map(M=>{const Z=M.handle?.trim()||"",F=we(M.displayLabel,M.handle,"Unknown account"),ee=M.email?.trim()||null,He=vn(M.environment),ot=Ve(M);return e.jsxs("div",{className:"account-row",children:[e.jsx(hs,{handle:F,image:M.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:F}),ee?e.jsx("span",{className:"private-account-email",tabIndex:0,children:ee}):null,e.jsx("span",{children:gs(M.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(We,{state:M.authHealth}),M.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:`account-env-toggle ${He?"active":""}`,disabled:!t||a||!!K||!Z,type:"button","aria-label":`Configure ${F} environment endpoints`,"aria-pressed":He,title:"Configure environment endpoints",onClick:()=>E(M),children:e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"})}),M.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!Z,type:"button",onClick:()=>{it(M)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!Z,type:"button","aria-label":`Remove ${F}`,title:`Remove ${F}`,onClick:()=>{rt(M)},children:e.jsx(be,{size:13})})]})]})]},ot)})]}):null,d?.products&&d.products.length>0&&e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Products"}),e.jsxs("small",{children:[d.products.length," active"]})]}),d.products.map(M=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:M.name}),e.jsx("span",{children:M.type})]}),e.jsx(We,{state:M.status})]},M.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:t?.serverUrl??"loading"})]}),le?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:le})]}):null,b?e.jsx(ps,{account:b,busy:us,onClose:()=>{us||E(null)},onSave:lt}):null,L?e.jsx(ps,{busy:a,mode:"connect",onClose:()=>{a||G(!1)},onSave:at}):null,e.jsx(gt,{state:A,onResolve:q})]})}function Ve(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function we(...s){for(const t of s){const a=t?.trim();if(a)return a}return""}function xn(s){const t=s?.trim();if(!t)return null;const a=t.toLowerCase();return a.includes("protected deployment")||a.includes("vercel_auth_enabled")?"Staging is protected by Vercel. Restart OpenPond after signing in to Vercel, then try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")||a.includes("vercel.com/sso-api")?"OpenPond received a web login page instead of account data. Restart after signing in to Vercel, then try again.":a.includes("401")||a.includes("unauthorized")||a.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":t.length>220?`${t.slice(0,217)}...`:t}function gs(s){const t=s.trim().toLowerCase();return!t||t==="production"?"Production":"Environment"}function jn(s){const t=s?.trim();return!t||t.toLowerCase()==="production"?"custom":t}function vn(s){const t=s?.trim().toLowerCase();return!!(t&&t!=="production")}function bn({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:a,preferences:n,saving:l,chooseDefaultProjectDirectory:i,saveDefaults:u,setAdvancedWorkspaceControls:c,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:y}){const p=Ze(t)===n.defaultBranchPrefix&&a.trim()===n.defaultNewProjectDirectory&&s===n.advancedWorkspaceControls;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Defaults"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:x=>{u(x)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:x=>c(x.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Show advanced Git controls"}),e.jsx("small",{children:"Show branch, commit, and push controls for local project workflows."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Git branches"}),e.jsx("small",{children:"Used for advanced and non-managed branch creation"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Branch prefix"}),e.jsx("input",{value:t,disabled:l,placeholder:"feat/",onChange:x=>o(x.target.value)})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Projects"}),e.jsx("small",{children:"Used when starting a new local project from scratch"})]}),e.jsxs("div",{className:"settings-path-row",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"New project directory"}),e.jsx("input",{value:a,disabled:l,placeholder:"~/Documents/OpenPond Projects",onChange:x=>y(x.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{i()},children:[e.jsx(_s,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||p,children:e.jsx("span",{children:l?"Saving":"Save defaults"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Ze(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||n.defaultNewProjectDirectory})]})]})}function yn({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:a,diagnosticsStatus:n,logDir:l,logLineLimit:i,logLines:u,logViewBusy:c,logViewSummary:o,logViewportRef:y,tailLogs:p,copyRecentLogs:x,exportDiagnosticsBundle:d,loadOlderLogs:m,openLogsFolder:h,refreshLogView:j,toggleTailLogs:S}){const k=s.filter(R=>R.name==="diagnostic"&&R.status==="failed").slice().reverse().map(Nn),f=typeof window>"u"?void 0:window.openpond;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Diagnostics"}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Recent errors"}),e.jsxs("small",{children:[k.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:k.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):k.map(R=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Hs,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:R.message}),e.jsx("time",{dateTime:R.timestamp,children:R.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:R.surface}),R.status?e.jsx("span",{children:R.status}):null,R.sequence?e.jsxs("span",{children:["#",R.sequence]}):null]}),R.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:R.detail})]}):null]})]},R.id))})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Logs"}),e.jsx("small",{children:t?"Desktop":"Unavailable"})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Logs folder"}),e.jsx("span",{children:"Desktop and server logs"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!f?.openLogsFolder,onClick:()=>{h()},children:[e.jsx(_s,{size:15}),e.jsx("span",{children:a==="logs"?"Opening":"Open"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Diagnostics export"}),e.jsx("span",{children:"Support folder with diagnostics.txt"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!f?.exportDiagnostics,onClick:()=>{d()},children:[e.jsx(jt,{size:15}),e.jsx("span",{children:a==="export"?"Exporting":"Export"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Recent logs"}),e.jsx("span",{children:"Last 1000 lines to clipboard"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!f?.copyRecentLogs,onClick:()=>{x()},children:[e.jsx(en,{size:15}),e.jsx("span",{children:a==="copy"?"Copying":"Copy"})]})]})]}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Log view"}),e.jsxs("div",{className:"settings-heading-actions diagnostics-log-actions",children:[e.jsx("small",{children:o}),e.jsx("button",{type:"button",className:`settings-icon-button ${p?"active":""}`,title:p?"Pause tail":"Tail logs","aria-label":p?"Pause tail":"Tail logs",disabled:!f?.readRecentLogs,onClick:S,children:p?e.jsx(Bs,{size:15}):e.jsx(Fs,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:c!==null||!f?.readRecentLogs,onClick:()=>{j(i,"refresh")},children:e.jsx(te,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:c!==null||!f?.readRecentLogs,onClick:m,children:[e.jsx(Gt,{size:15}),e.jsx("span",{children:c==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:y,className:"diagnostics-log-viewer",role:"log","aria-live":p?"polite":"off",children:u.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:c?"Loading logs":"No log lines"}):u.map((R,D)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:R.file}),e.jsx("code",{children:R.line})]},`${R.file}:${R.timestamp}:${R.index}:${D}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),n&&e.jsxs("div",{className:`settings-footnote ${n.warning?"warning":""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]})]})}function Nn(s){const t=fs(s.data),a=fs(t.context),l=he(t.stack)??he(t.detail)??he(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:Sn(s.timestamp),message:wn(s,t),surface:he(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function wn(s,t){return he(s.error)??he(s.output)??he(t.message)??he(t.error)??"Diagnostic event"}function Sn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function fs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function he(s){return typeof s=="string"&&s.trim()?s.trim():null}const xs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Cn({editorPreferences:s,lspStatus:t,preferences:a,restarting:n,saving:l,statusLoading:i,refreshLspStatus:u,restartLanguageServers:c,saveEditorSettings:o,setEditorPreferences:y,setLanguageCustomCommand:p,setLanguageMode:x}){const d=JSON.stringify(s)!==JSON.stringify(a.editor),m=new Map(t?.languages.map(h=>[h.language,h])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:h=>{o(h)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Language servers"}),e.jsx("small",{children:"Local tools"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Language servers"}),e.jsx(Pe,{value:s.languageServers,disabled:l,label:"Language servers",options:vt,onChange:h=>y(j=>({...j,languageServers:h}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:h=>y(j=>({...j,diagnosticsWhileEditing:h.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Diagnostics while editing"}),e.jsx("small",{children:"Update Monaco markers as the local buffer changes."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.checkOnSave,disabled:l||s.languageServers==="off",onChange:h=>y(j=>({...j,checkOnSave:h.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Check on save"}),e.jsx("small",{children:"Refresh diagnostics after writing a file."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Languages"}),e.jsx("small",{children:"Auto, disabled, or custom executable"})]}),e.jsx("div",{className:"lsp-language-list",children:xs.map(h=>{const j=s.languages[h.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:h.label}),e.jsx("span",{children:js(m.get(h.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Pe,{value:j.mode,disabled:l||s.languageServers==="off",label:`${h.label} language server mode`,options:bt,onChange:S=>x(h.id,S)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:j.customCommand,disabled:l||s.languageServers==="off"||j.mode!=="custom",placeholder:h.placeholder,onChange:S=>p(h.id,S.target.value)})]})]},h.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!d,children:e.jsx("span",{children:l?"Saving":"Save editor settings"})})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"LSP status"}),e.jsxs("div",{className:"settings-heading-actions",children:[e.jsx("small",{children:i?"Checking":t?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:i||n,onClick:()=>{u()},children:e.jsx(te,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||n,onClick:()=>{c()},children:[e.jsx(cn,{className:n?"settings-spin":void 0,size:15}),e.jsx("span",{children:n?"Restarting":"Restart"})]})]})]}),xs.map(h=>{const j=m.get(h.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:h.label}),e.jsx("span",{title:j?.command??j?.message??void 0,children:j?.command??j?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${j?.status??"missing"}`,children:js(j,i)})]},h.id)})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Project config"}),e.jsx("strong",{children:"Uses tsconfig, pyrightconfig, pyproject, and Cargo files when present"})]})]})}function js(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function kn({contextCompactionAutoEnabled:s,preferences:t,saving:a,saveDefaults:n,setContextCompactionAutoEnabled:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:i=>{n(i)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Compaction"}),e.jsx("small",{children:"Controls automatic compaction for long OpenPond and BYOK chats"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:i=>l(i.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Auto compact long chats"}),e.jsx("small",{children:"Summarize older turns at 85% context before the selected model runs out. The transcript stays visible."})]})]}),e.jsx("button",{className:"settings-primary",disabled:a||s===t.contextCompaction.autoEnabled,children:e.jsx("span",{children:a?"Saving":"Save context"})})]})]})}function Pn({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:a,subagentsProvider:n,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:u,subagentsMaxConcurrentRunsPerProvider:c,subagentsMaxConcurrentRunsPerWorkspaceTarget:o,preferences:y,providers:p,saving:x,saveDefaults:d,changeSubagentsProvider:m,setSubagentsEnabled:h,setSubagentDelegationMode:j,setSubagentsUseDefaultModel:S,setSubagentsModel:k,setSubagentsMaxConcurrentRuns:f,setSubagentsMaxConcurrentRunsPerProvider:R,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:D,setSubagentRoleEnabled:N,setSubagentRoleIsolationMode:I,setSubagentRoleMaxConcurrentRuns:P,setSubagentRoleModel:O,setSubagentRolePeerMessages:g,setSubagentRoleToolPolicy:C,changeSubagentRoleProvider:w}){const b=Ts(p,{enabledOnly:!0}),E=a?y.defaultChatProvider:n,L=a?y.defaultChatModel:l,G=Vs(ze(E,p),L),K=a?null:{providerId:n,modelId:l.trim()},Q=$n({enabled:s,delegationMode:t,defaultModelRef:K,roles:i,maxConcurrentRuns:u,maxConcurrentRunsPerProvider:c,maxConcurrentRunsPerWorkspaceTarget:o},y);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:v=>{d(v)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Subagents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${Q?"":" dirty"}`,disabled:x||Q,children:e.jsx("span",{children:x?"Saving":"Save agents"})}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":"Allow subagents",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:x,onChange:v=>h(v.target.checked)}),e.jsx("span",{})]})]})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Default delegation"}),e.jsx("small",{children:"Used unless a task overrides it from the composer."})]})}),e.jsx("div",{className:"subagent-field-grid two",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Subagent use"}),e.jsxs("select",{value:t,disabled:x||!s,onChange:v=>j(v.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"balanced",children:"Balanced"}),e.jsx("option",{value:"proactive",children:"Proactive"})]})]})})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsx("div",{children:e.jsx("span",{children:"Default model"})})}),e.jsxs("div",{className:"subagent-field-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Provider"}),e.jsx("select",{value:E,disabled:x||!s,onChange:v=>{S(!1),m(v.target.value)},children:b.map(v=>e.jsx("option",{value:v.value,children:v.label},v.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:L,disabled:x||!s,onChange:v=>{S(!1),k(v.target.value)},children:G.map(v=>e.jsx("option",{value:v.value,children:v.label},v.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(v=>{const A=yt.find(U=>U.id===v.id),q=v.modelRef?.providerId??E,J=v.modelRef?.modelId||Nt(q,p)||L,W=In(b,p,{providerId:q,modelId:J}),X=Me(q,J),Y=x||!s||!v.enabled;return e.jsxs("section",{className:`subagent-role-row${v.enabled?"":" disabled"}`,children:[e.jsxs("div",{className:"subagent-settings-card-header subagent-role-header",children:[e.jsxs("div",{className:"subagent-role-title",children:[e.jsx("span",{children:A?.label??v.id}),e.jsx("small",{children:A?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${A?.label??v.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:v.enabled,disabled:x||!s,onChange:U=>N(v.id,U.target.checked)}),e.jsx("span",{})]})]}),e.jsxs("div",{className:"subagent-role-controls",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:X,disabled:Y,onChange:U=>{const ne=W.find(re=>re.value===U.target.value);ne&&(w(v.id,ne.providerId),O(v.id,ne.modelId))},children:W.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:v.isolationMode,disabled:Y,onChange:U=>I(v.id,U.target.value),children:Rn.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:v.toolPolicy,disabled:Y,onChange:U=>C(v.id,U.target.value),children:An.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:v.peerMessages,disabled:Y,onChange:U=>g(v.id,U.target.value),children:Dn.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]})]}),e.jsx("div",{className:"subagent-role-budget-grid",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Role concurrency"}),e.jsx("input",{type:"number",min:1,max:16,value:v.maxConcurrentRuns,disabled:Y,onChange:U=>P(v.id,vs(U.target.value,1))})]})})]},v.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:u,disabled:x||!s,onChange:v=>f(vs(v.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:c??"",placeholder:"No cap",disabled:x||!s,onChange:v=>R(is(v.target.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per workspace"}),e.jsx("input",{type:"number",min:1,max:32,value:o??"",placeholder:"No cap",disabled:x||!s,onChange:v=>D(is(v.target.value))})]})]})]})]})})}const Rn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],An=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Dn=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function Vs(s,t){const a=t.trim();return!a||s.some(n=>n.value===a)?s:[{value:a,label:a},...s]}function Me(s,t){return JSON.stringify([s,t])}function In(s,t,a){const n=[];for(const l of s){const i=Vs(ze(l.value,t),l.value===a.providerId?a.modelId:"");for(const u of i)n.push({value:Me(l.value,u.value),label:`${l.label} / ${u.label}`,providerId:l.value,modelId:u.value})}return a.modelId&&!n.some(l=>l.value===Me(a.providerId,a.modelId))&&n.unshift({value:Me(a.providerId,a.modelId),label:`${Ee(a.providerId,t)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),n}function is(s){const t=s.trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function vs(s,t){return is(s)??t}function $n(s,t){const a=t.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Mn(s.defaultModelRef,a.defaultModelRef)&&s.maxConcurrentRuns===a.maxConcurrentRuns&&s.maxConcurrentRunsPerProvider===a.maxConcurrentRunsPerProvider&&s.maxConcurrentRunsPerWorkspaceTarget===a.maxConcurrentRunsPerWorkspaceTarget&&JSON.stringify(s.roles)===JSON.stringify(a.roles)}function Mn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const En=[{mode:"all",label:"All new messages",detail:"Show an in-app alert for every Team Chat message."},{mode:"direct_mentions",label:"Direct messages and mentions",detail:"Show alerts for direct messages and messages that mention you."},{mode:"none",label:"Nothing",detail:"Keep unread counts without showing message alerts."}];function Ln({currentUserId:s,enabled:t,mode:a,threads:n,onModeChange:l,onThreadMuteChange:i}){const[u,c]=r.useState(null),[o,y]=r.useState(null);rs(o);const p=r.useMemo(()=>n.filter(m=>m.archivedAt===null).map(m=>({thread:m,label:Tn(m,s)})).sort((m,h)=>{const j=+!!h.thread.mutedAt-+!!m.thread.mutedAt;return j!==0?j:m.label.localeCompare(h.label)}),[s,n]),x=p.filter(({thread:m})=>!!m.mutedAt).length,d=r.useCallback(async m=>{c(m.id),y(null),await i(m.id,!m.mutedAt)||y("Could not update this conversation. Try again."),c(null)},[i]);return e.jsxs("section",{className:"account-settings notifications-settings",children:[e.jsx("h1",{children:"Notifications"}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Team chat notifications"}),e.jsx("small",{children:"In-app alerts"})]}),e.jsx("div",{className:"notification-mode-list",role:"radiogroup","aria-label":"Notify me about",children:En.map(m=>e.jsxs("label",{className:`notification-mode-option${a===m.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===m.mode,onChange:()=>l(m.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:m.label}),e.jsx("small",{children:m.detail})]})]},m.mode))})]}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Conversation overrides"}),e.jsx("small",{children:x===1?"1 muted":`${x} muted`})]}),t?p.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):p.map(({thread:m,label:h})=>{const j=!!m.mutedAt,S=u===m.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${j?" muted":""}`,children:j?e.jsx(wt,{size:15}):e.jsx(Gs,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:h}),e.jsx("small",{children:j?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:u!==null,onClick:()=>{d(m)},children:S?"Saving":j?"Unmute":"Mute"})]},m.id)}):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Connect a team to manage conversation overrides."})})]}),e.jsx("div",{className:"settings-footnote",children:e.jsx("span",{children:"Muted conversations never show alerts. Unread counts remain available."})})]})}function Tn(s,t){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(a=>a.userId!==t)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(a=>a.userId!==t).map(a=>a.name).join(", ")||"Group conversation"}function On({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:a,saveAsNewOpen:n,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:u,soulDraft:c,templateNameDraft:o,changePersonalizationTemplate:y,changeSoulDraft:p,openSaveAsNew:x,resetPersonalizationDraft:d,savePersonalization:m,setSaveAsNewOpen:h,setTemplateNameDraft:j}){function S(k){k.preventDefault(),m(n)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:S,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:n?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:o,onChange:k=>j(k.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:l,onClick:()=>h(!1),children:e.jsx(ie,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!c.trim()||!o.trim(),onClick:()=>{m(!0)},children:e.jsx(Os,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:u?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:l||!i||!c.trim(),onClick:x,children:e.jsx(me,{size:15})})]})})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Template"}),e.jsx(Pe,{value:t,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:k=>{y(k)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:c,onChange:k=>p(k.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Reset to template","aria-label":"Reset to template",disabled:l||!i,onClick:d,children:e.jsx(Te,{size:15})}),u&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(os,{size:15})})]})]})]})}function Un({connection:s,profile:t,selectedDefaultTeamId:a}){const n=Vt(s),l=_n(n.schedules);return rs(n.error,{prefix:"Local schedules"}),e.jsxs("div",{className:"account-list profile-agent-list","aria-label":"Profile agents",children:[e.jsx("div",{className:"account-list-heading profile-agent-list-heading",children:e.jsx("span",{children:"Agents"})}),e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-agent-table","aria-label":"Profile agents table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-agent-column"}),e.jsx("col",{className:"profile-action-column"}),e.jsx("col",{className:"profile-check-column"}),e.jsx("col",{className:"profile-sync-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Action"}),e.jsx("th",{scope:"col",children:"Check"}),e.jsx("th",{scope:"col",children:"Sync"})]})}),e.jsxs("tbody",{children:[l.active.map(i=>e.jsx(bs,{pending:n.pendingScheduleIds.has(i.id),schedule:i,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(i)},onToggle:()=>{n.toggle(i)}},i.id)),e.jsx(zn,{}),t.agents.map(i=>e.jsx(Bn,{agent:i,defaultAction:t.summary.defaultAction,profile:t,selectedDefaultTeamId:a},i.id)),l.paused.map(i=>e.jsx(bs,{pending:n.pendingScheduleIds.has(i.id),schedule:i,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(i)},onToggle:()=>{n.toggle(i)}},i.id))]})]})})]})}function zn(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset Builder"}),e.jsx("span",{children:"Built in · every Profile"})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:"Design · Materialize · Test"})})}),e.jsx("td",{children:e.jsx(Re,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Re,{status:{state:"ready",label:"Built in"}})})]})}function Bn({agent:s,defaultAction:t,profile:a,selectedDefaultTeamId:n}){const l=Gn(a,s,n);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{title:s.path,children:s.path})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:t??"None"})})}),e.jsx("td",{children:e.jsx(Re,{status:l.check})}),e.jsx("td",{children:e.jsx(Re,{status:l.sync})})]})}function bs({pending:s,refreshing:t,schedule:a,onRefresh:n,onRun:l,onToggle:i}){const u=Hn(a),c=a.enabled?"Pause schedule":"Resume schedule";return e.jsxs("tr",{className:"profile-agent-row profile-schedule-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.localProjectName}),e.jsxs("span",{title:a.scheduleName,children:["schedule: ",a.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:a.targetAction,children:a.targetAction})})}),e.jsx("td",{children:e.jsx(Re,{status:u})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:Fn(a),children:a.enabled?a.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${a.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:t,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:n,children:e.jsx(te,{size:14,className:t?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${a.scheduleName} now`,onClick:l,children:e.jsx(Te,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:c,"aria-label":`${c}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(Bs,{size:14}):e.jsx(Fs,{size:14})})]})]})})]})}function Re({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function _n(s){const t=[],a=[];for(const n of s)n.enabled?t.push(n):a.push(n);return t.sort((n,l)=>ys(n)-ys(l)),{active:t,paused:a}}function ys(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function Hn(s){return s.enabled?s.lastError||s.lastRunStatus==="failed"?{state:"warning",label:"Failed"}:s.lastRunStatus==="running"?{state:"loading",label:"Running"}:s.lastRunStatus==="queued"?{state:"loading",label:"Queued"}:s.lastRunStatus==="skipped"?{state:"warning",label:"Skipped"}:s.lastRunStatus==="succeeded"?{state:"ready",label:"Succeeded"}:{state:"loading",label:"Scheduled"}:{state:"disabled",label:"Paused"}}function Fn(s){const t=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&t.push(`next ${Ns(s.nextRunAt)}`),s.lastRunAt&&t.push(`last ${Ns(s.lastRunAt)}`),t.join(" - ")}function Ns(s){const t=new Date(s);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function Gn(s,t,a){if(!t.enabled)return{check:{state:"disabled",label:"Disabled"},sync:{state:"disabled",label:"Disabled"}};if(s.error)return{check:{state:"warning",label:"Error"},sync:{state:"warning",label:"Blocked"}};if(s.setupGate.blockingCount>0)return{check:{state:"warning",label:"Setup"},sync:{state:"warning",label:"Blocked"}};if(s.git?.dirty||Wn(s,t)>0)return{check:{state:"loading",label:"Pending"},sync:{state:"warning",label:"Changed"}};if(s.catalog.stale)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(!s.lastCheck)return{check:{state:"loading",label:"Unchecked"},sync:{state:"loading",label:"Waiting"}};if(s.lastCheck.status==="failed")return{check:{state:"warning",label:"Failed"},sync:{state:"warning",label:"Blocked"}};if(!s.summary.checkFresh)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(qn(s,a))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const n=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null;return!(s.summary.hostedHead??s.hosted?.sourceCommitSha??null)&&!l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Not synced"}}:n&&l&&n!==l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function qn(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}function Wn(s,t){let a=0;s.diff.changedAgents.includes(t.id)&&(a+=1),s.diff.newAgents.includes(t.id)&&(a+=1),s.diff.deletedAgents.includes(t.id)&&(a+=1);const n=t.path.replace(/^profiles\/[^/]+\//,"");for(const l of s.diff.files){const i=l.path.replace(/^profiles\/[^/]+\//,"");(i===n||i.startsWith(`${n}/`)||i.startsWith(`agents/${t.id}/`))&&(a+=1)}return a}function Vn({actions:s,busy:t,library:a,onSelect:n}){const l=a.profiles.find(u=>Xe(u.ref,a.lastUsed))??a.profiles[0]??null,i=l?Fe(l.ref):"";return e.jsxs("div",{className:"profile-selector-bar",children:[e.jsxs("label",{className:"profile-selector-control",children:[e.jsx("select",{"aria-label":"Active profile",disabled:t||a.profiles.length===0,value:i,onChange:u=>{const c=St(a,u.currentTarget.value),o=a.profiles.find(y=>Xe(y.ref,c));o&&n(o)},children:a.profiles.length?a.profiles.map(u=>e.jsx("option",{value:Fe(u.ref),children:u.name},Fe(u.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Ct,{"aria-hidden":"true",size:14})]}),s]})}function Kn({addDisabled:s,commitDisabled:t,commitLabel:a,refreshDisabled:n,repoDisabled:l,syncDisabled:i,syncLabel:u,syncStatus:c,onAdd:o,onCommit:y,onRefresh:p,onRepo:x,onSync:d}){const[m,h]=r.useState(!1),j=r.useRef(null);r.useEffect(()=>{if(!m)return;function k(R){j.current?.contains(R.target)||h(!1)}function f(R){R.key==="Escape"&&h(!1)}return document.addEventListener("pointerdown",k),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",f)}},[m]);function S(k){h(!1),k()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:j,children:[e.jsx("button",{"aria-expanded":m,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>h(k=>!k),children:e.jsx(kt,{size:15})}),m?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>S(y),children:[e.jsx(Oe,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>S(d),children:[e.jsx(pe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:u}),c?e.jsx("small",{children:c}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>S(x),children:[e.jsx(De,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>S(p),children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>S(o),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const Jn=[{id:"actions",label:"Actions",detail:"Profile-level reusable actions"},{id:"prompts",label:"Prompts",detail:"Shared prompt files"},{id:"goals",label:"Goals",detail:"Goal definitions; never started automatically"},{id:"evals",label:"Evals",detail:"Evaluation definitions and fixtures"},{id:"examples",label:"Examples",detail:"Example inputs and usage"},{id:"tasksets",label:"Tasksets",detail:"Training and evaluation tasksets"},{id:"extensions",label:"Extension declarations",detail:"Third-party extension metadata"}];function Yn({connection:s,entry:t,onClose:a,onPublished:n}){const[l,i]=r.useState("github"),[u,c]=r.useState(""),[o,y]=r.useState(`${t.name}-profile`),[p,x]=r.useState("public"),[d,m]=r.useState(()=>t.state.agents.filter(b=>b.enabled).map(b=>b.id)),[h,j]=r.useState(()=>t.state.skills.filter(b=>b.enabled).map(b=>b.name)),[S,k]=r.useState([]),[f,R]=r.useState(null),[D,N]=r.useState(null),[I,P]=r.useState(null),O=r.useMemo(()=>({ref:t.ref,selection:{agentIds:d,skillNames:h,optionalContent:S},target:{provider:l,owner:u.trim()||null,repository:o.trim(),visibility:l==="github"?"public":p}}),[d,t.ref,S,u,l,o,h,p]);function g(b,E,L){return L?[...new Set([...b,E])]:b.filter(G=>G!==E)}async function C(b){if(b.preventDefault(),!(!o.trim()||D)){N("preview"),P(null);try{R(await $.profilePublicationPreview(s,O))}catch(E){P(E instanceof Error?E.message:String(E))}finally{N(null)}}}async function w(){if(!(!f||f.blockedReasons.length>0||D)){N("publish"),P(null);try{const b=await $.profilePublicationPublish(s,{...O,expectedSourceHash:f.sourceHash,confirmed:!0});n(`Published ${t.name} to ${b.owner}/${b.repository}`),a()}catch(b){P(b instanceof Error?b.message:String(b))}finally{N(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:b=>b.stopPropagation(),onSubmit:C,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!D,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(pe,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",t.name]}),e.jsx("p",{children:"Choose the exact Agents, Skills, and optional files to share. OpenPond will show the complete file list before it pushes anything."}),f?e.jsx(Qn,{preview:f}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:"Destination"}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="github",onChange:()=>{i("github"),x("public")}}),e.jsx(es,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"GitHub"}),e.jsx("small",{children:"Published publicly with your signed-in gh CLI"})]})]}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="openpond_git",onChange:()=>{i("openpond_git"),x("private")}}),e.jsx(Pt,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[l==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:u,placeholder:"Uses gh account",onChange:b=>c(b.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:o,onChange:b=>y(b.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:p,onChange:b=>x(b.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ke,{title:"Agents",empty:"No Agents in this Profile",children:t.state.agents.map(b=>e.jsx(Je,{checked:d.includes(b.id),label:b.name,detail:b.path,onChange:E=>m(L=>g(L,b.id,E))},b.id))}),e.jsx(Ke,{title:"Skills",empty:"No Skills in this Profile",children:t.state.skills.map(b=>e.jsx(Je,{checked:h.includes(b.name),label:b.name,detail:b.description||b.path,onChange:E=>j(L=>g(L,b.name,E))},b.name))}),e.jsx(Ke,{title:"Optional content",empty:"",children:Jn.map(b=>e.jsx(Je,{checked:S.includes(b.id),label:b.label,detail:b.detail,onChange:E=>k(L=>g(L,b.id,E))},b.id))})]}),I?e.jsx("div",{className:"profile-dialog-warning",children:I}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!D,type:"button",onClick:f?()=>R(null):a,children:f?"Back":"Cancel"}),f?e.jsxs("button",{className:"git-dialog-primary",disabled:!!D||f.blockedReasons.length>0,type:"button",onClick:()=>{w()},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:D==="publish"?"Publishing":f.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!D||!o.trim(),type:"submit",children:D==="preview"?"Building preview":"Review exact files"})]})]})})}function Ke({title:s,empty:t,children:a}){const n=Array.isArray(a)?a.length:a?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),n?a:e.jsx("span",{className:"profile-publication-empty",children:t})]})}function Je({checked:s,label:t,detail:a,onChange:n}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:l=>n(l.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t}),e.jsx("small",{children:a})]})]})}function Qn({preview:s}){const t=s.files.reduce((a,n)=>a+n.sizeBytes,0);return e.jsxs("div",{className:"profile-publication-preview",children:[e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[s.files.length," files · ",ws(t)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(a=>e.jsx("div",{className:"profile-dialog-warning",children:a},a)),s.warnings.map(a=>e.jsx("div",{className:"profile-publication-warning",children:a},a)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(a=>e.jsxs("div",{children:[e.jsx("span",{title:a.path,children:a.path}),e.jsxs("small",{children:[a.category," · ",ws(a.sizeBytes)]})]},a.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(a=>e.jsx("code",{children:a},a))]}):null]})}function ws(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Zn({section:s="all",catalogPresentation:t="list",payload:a,connection:n,onPayload:l,onError:i,onToast:u,onSkillCommand:c,overviewContent:o}){const[y,p]=r.useState(""),[x,d]=r.useState(null),[m,h]=r.useState(!1),[j,S]=r.useState(null),[k,f]=r.useState(null),R=a?.profile??null,D=a?.preferences.defaultTeamId?.trim()||"",N=s==="all"||s==="profile"||s==="controls",I=s==="all"||s==="profile",P=s==="all"||s==="agents",O=s==="all"||s==="profile";async function g(A){n&&(l(await $.bootstrap(n)),u?.(A,"success"))}async function C(A,q){if(!(!n||x)){d(A),i(null);try{await q()}catch(J){i(J instanceof Error?J.message:String(J))}finally{d(null)}}}function w(){C("init",async()=>{await $.profileInit(n,{}),await g("Profile initialized")})}function b(){C("commit",async()=>{await $.profileCommit(n,{message:y.trim()||null}),p(""),await g("Profile commit complete")})}function E(){C("push",async()=>{if(!D)throw new Error("Select a default team before syncing a hosted profile.");await $.profileCheck(n,{kind:"all"}),await $.profilePush(n,{teamId:D,ensureHosted:!0,message:null}),await g("Profile synced to hosted profile repo")})}function L(A){C(`select:${A.ref.profileId}`,async()=>{await $.profileSelect(n,A.ref),await g(`Using ${A.name}`)})}function G(A){C("add",async()=>{A.source==="blank"?await $.profileInit(n,{path:A.path,profile:A.profile,template:"blank-profile"}):A.source==="local"?await $.profileLoad(n,A):await $.profileInstall(n,A),h(!1),await g(A.source==="blank"?`${A.profile} created`:"Profile added")})}function K(A){C("update",async()=>{await $.profileUpdate(n,A.ref),await g(`${A.name} updated`)})}function Q(A){C("remove",async()=>{await $.profileRemove(n,A.ref),S(null),await g("Profile removed from this device")})}function v(){C("refresh",async()=>{await g("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[R?.mode==="local"?e.jsxs(e.Fragment,{children:[N?e.jsxs(e.Fragment,{children:[I&&t==="select"?e.jsx(Vn,{actions:e.jsx(Ss,{connection:n,onAdd:()=>h(!0),onRefresh:v,presentation:"menu",profile:R,profileBusy:x,profileCommitMessage:y,selectedDefaultTeamId:D,syncDisabledReason:Cs(R,D),setProfileCommitMessage:p,submitProfileCommit:b,submitProfilePush:E}),busy:!!x,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:L}):e.jsxs(e.Fragment,{children:[I?e.jsx(Xn,{busy:!!x,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>h(!0),onRefresh:v,onRemove:S,onPublish:f,onUpdate:K,onSelect:L}):null,e.jsx(Ss,{connection:n,profile:R,profileBusy:x,profileCommitMessage:y,selectedDefaultTeamId:D,syncDisabledReason:Cs(R,D),setProfileCommitMessage:p,submitProfileCommit:b,submitProfilePush:E})]}),o]}):null,P?e.jsx(Un,{connection:n,profile:R,selectedDefaultTeamId:D}):null,O?e.jsx(la,{onSkillCommand:c,profile:R}):null]}):s==="agents"?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agents"}),e.jsx("small",{children:"Profile required"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Open Profile to create or load a Profile before managing agents."})]})]}):e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Summary"}),e.jsx("small",{children:"Not loaded"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Create an empty Profile, start with an Agent template, or add an existing repository."}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!x,type:"button",onClick:()=>h(!0),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!x,type:"button",onClick:w,children:[e.jsx(me,{size:14}),e.jsx("span",{children:x==="init"?"Creating":"Create starter Profile"})]})]})]}),m?e.jsx(ea,{busy:!!x,onClose:()=>h(!1),onSubmit:G}):null,j?e.jsx(sa,{busy:!!x,entry:j,onClose:()=>S(null),onConfirm:()=>Q(j)}):null,k&&n?e.jsx(Yn,{connection:n,entry:k,onClose:()=>f(null),onPublished:A=>u?.(A,"success")}):null]})}function Xn({busy:s,library:t,onAdd:a,onRefresh:n,onRemove:l,onPublish:i,onSelect:u,onUpdate:c}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[t.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:n,children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),t.profiles.map(o=>{const y=Xe(o.ref,t.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${y?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||u(o)},onKeyDown:p=>{s||p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),u(o))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(De,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{title:o.repoPath,children:o.repoPath})]})]}),e.jsx(Ks,{status:{state:o.state.error?"warning":"ready",label:o.state.error?"error":y?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:o.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:o.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[o.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:p=>{p.stopPropagation(),c(o)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),c(o))},children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:p=>{p.stopPropagation(),i(o)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),i(o))},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${o.name}`,onClick:p=>{p.stopPropagation(),l(o)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),l(o))},children:[e.jsx(be,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${o.ref.source}:${o.ref.repositoryId}:${o.ref.profileId}`)})]})}function ea({busy:s,onClose:t,onSubmit:a}){const[n,l]=r.useState("blank"),[i,u]=r.useState(""),[c,o]=r.useState(""),[y,p]=r.useState("");function x(d){if(d.preventDefault(),s)return;if(n==="blank"){const h=y.trim();if(!h)return;a({source:n,path:i.trim()||null,profile:h});return}if(n==="local"){const h=i.trim();if(!h)return;a({source:n,path:h,profile:y.trim()||null});return}const m=c.trim();m&&a({source:n,repositoryId:m,profile:y.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:t,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:d=>d.stopPropagation(),onSubmit:x,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:t,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(De,{size:18})}),e.jsx("h2",{id:"add-profile-title",children:"Add Profile"}),e.jsx("p",{children:"Create a blank Profile, add a local repository, or install a shareable Profile from Git."}),e.jsxs("div",{className:"profile-add-source-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="blank",onChange:()=>l("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="local",onChange:()=>l("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="github",onChange:()=>l("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="openpond_git",onChange:()=>l("openpond_git")}),"OpenPond Git"]})]}),n==="blank"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path (optional)"}),e.jsx("input",{disabled:s,value:i,placeholder:"Uses the default local Profile repository",onChange:d=>u(d.currentTarget.value)})]}):n==="local"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path"}),e.jsx("input",{autoFocus:!0,disabled:s,value:i,placeholder:"/path/to/profile-repo",onChange:d=>u(d.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[n==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:c,placeholder:"owner/repository",onChange:d=>o(d.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:n==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:n==="blank",disabled:s,value:y,placeholder:n==="blank"?"research":"Uses repository default",onChange:d=>p(d.currentTarget.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:s||!(n==="blank"?y:n==="local"?i:c).trim(),type:"submit",children:n==="blank"?"Create Profile":"Add Profile"})]})]})})}function sa({busy:s,entry:t,onClose:a,onConfirm:n}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"remove-profile-title",onMouseDown:l=>l.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(be,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",t.name,"?"]}),e.jsx("p",{children:"This removes the Profile from OpenPond on this device. It does not delete the repository or any source files."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{children:t.repoPath})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:n,children:"Remove"})]})]})})}function Ss({connection:s,onAdd:t,onRefresh:a,presentation:n="toolbar",profile:l,profileBusy:i,profileCommitMessage:u,selectedDefaultTeamId:c,syncDisabledReason:o,setProfileCommitMessage:y,submitProfileCommit:p,submitProfilePush:x}){const[d,m]=r.useState(!1),[h,j]=r.useState(!1),[S,k]=r.useState(!1),f=!s||!!i;return e.jsxs(e.Fragment,{children:[n==="menu"&&t&&a?e.jsx(Kn,{addDisabled:!!i,commitDisabled:f,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:f,repoDisabled:!!i||!l,syncDisabled:f||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ye(l,c):null,onAdd:t,onCommit:()=>j(!0),onRefresh:a,onRepo:()=>m(!0),onSync:()=>k(!0)}):e.jsx("div",{className:"profile-control-panel",children:e.jsxs("div",{className:"profile-control-toolbar",children:[e.jsxs("div",{className:"profile-control-actions",children:[e.jsxs("button",{className:"settings-secondary",disabled:f,type:"button",onClick:()=>j(!0),children:[e.jsx(Oe,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:f||!l,type:"button",onClick:()=>k(!0),children:[e.jsx(pe,{size:14}),e.jsx("span",{children:i==="push"?"Syncing":"Sync"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!!i||!l,type:"button",onClick:()=>m(!0),children:[e.jsx(De,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ye(l,c)}`,children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ye(l,c)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),d&&l?e.jsx(aa,{profile:l,profileBusy:i,onClose:()=>m(!1)}):null,h?e.jsx(ta,{disabled:f,profileBusy:i,profileCommitMessage:u,setProfileCommitMessage:y,submitProfileCommit:p,onClose:()=>j(!1)}):null,S&&l?e.jsx(na,{disabled:f,profile:l,profileBusy:i,selectedDefaultTeamId:c,syncDisabledReason:o,submitProfilePush:x,onClose:()=>k(!1)}):null]})}function ta({disabled:s,profileBusy:t,profileCommitMessage:a,setProfileCommitMessage:n,submitProfileCommit:l,onClose:i}){function u(c){c.preventDefault(),!s&&(l(),i())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:i,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:c=>c.stopPropagation(),onSubmit:u,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:i,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Oe,{size:18})}),e.jsx("h2",{id:"profile-commit-dialog-title",children:"Commit profile"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Commit message"}),e.jsx("input",{autoFocus:!0,value:a,disabled:!!t,placeholder:"Update OpenPond profile",onChange:c=>n(c.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:i,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(Oe,{size:14}),e.jsx("span",{children:t==="commit"?"Committing":"Commit"})]})]})]})})}function na({disabled:s,profile:t,profileBusy:a,selectedDefaultTeamId:n,syncDisabledReason:l,submitProfilePush:i,onClose:u}){const c=ra(t,n),o=c.reduce((x,d)=>x+d.count,0),y=!s&&!l;function p(x){x.preventDefault(),y&&(i(),u())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:u,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:x=>x.stopPropagation(),onSubmit:p,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(pe,{size:18})}),e.jsx("h2",{id:"profile-sync-dialog-title",children:"Sync profile"}),e.jsx("p",{className:"profile-sync-explainer",children:"Sync publishes this committed Profile source for your team, so its Agents can be shared in team chat and attached to hosted sandboxes."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[o," ",o===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",ye(t.summary.localHead??t.git?.head)," - Last pushed"," ",ye(t.hosted?.lastPushedLocalHead)]})]}),c.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:c.map(x=>e.jsxs("div",{className:`profile-dialog-diff-row ${x.tone??""}`,children:[e.jsx("strong",{children:x.label}),e.jsx("span",{children:x.detail})]},x.label))}):e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:e.jsxs("div",{className:"profile-dialog-diff-row",children:[e.jsx("strong",{children:"Aligned"}),e.jsx("span",{children:"Current local profile source has already been pushed."})]})}),l?e.jsx("div",{className:"profile-dialog-warning",children:l}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:u,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!y,type:"submit",children:[e.jsx(pe,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function aa({profile:s,profileBusy:t,onClose:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:n=>n.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:a,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(De,{size:18})}),e.jsx("h2",{id:"profile-path-dialog-title",children:"Profile repo"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Profile repo path"}),e.jsx("input",{"aria-label":"Profile repo path",readOnly:!0,value:s.repoPath??""})]}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:s.git?.isRepo?"Git-backed":"Git setup required"}),e.jsxs("span",{children:[s.git?.branch??"No branch"," · ",ye(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:a,children:"Close"})})]})})}function la({onSkillCommand:s,profile:t}){const a=t.skills.slice().sort((i,u)=>i.name.localeCompare(u.name)),n=!s;function l(i){s?.(i)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[t.skillCatalog.skillCount," tracked"]})})]}),a.length?e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-skill-table","aria-label":"Profile skills table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-skill-name-column"}),e.jsx("col",{className:"profile-skill-trigger-column"}),e.jsx("col",{className:"profile-skill-status-column"}),e.jsx("col",{className:"profile-skill-source-column"}),e.jsx("col",{className:"profile-skill-actions-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Skill"}),e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:a.map(i=>e.jsx(ia,{commandDisabled:n,onSkillCommand:l,skill:i},i.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function ia({commandDisabled:s,onSkillCommand:t,skill:a}){const n=a.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:a.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Le,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.name}),e.jsx("span",{title:a.path,children:a.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:a.description,children:a.description||"No description"}),e.jsx("td",{children:e.jsx(Ks,{status:n})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:a.sourcePath,children:a.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:s||!a.enabled,type:"button",title:`Use ${a.name}`,onClick:()=>t(`$${a.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${a.name}`,onClick:()=>t(`/skill edit ${a.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function Ks({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ye(s){return s?s.slice(0,10):"None"}function Ye(s,t){return Js(s,t)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${ye(s.hosted.sourceCommitSha)}`:"Not pushed"}function Cs(s,t){return t?s.git?.head?s.git.dirty?"Commit local profile changes before syncing.":null:"Commit the profile before syncing.":"Select a default team before syncing."}function ra(s,t){const a=[],n=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null,i=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(Js(s,t)&&a.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!i&&!l?a.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):n&&l&&n!==l&&a.push({label:"Commit",detail:`Local ${ye(n)} has not been pushed since ${ye(l)}.`,count:1}),s.git?.dirty){const c=s.git.files.length||s.diff.files.length||1;a.push({label:"Uncommitted files",detail:`${c} local ${c===1?"file":"files"} changed.`,count:c,tone:"warning"})}const u=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return u>0&&a.push({label:"Profile changes",detail:oa(s),count:u,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&a.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&a.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),a}function oa(s){const t=[],a=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return a&&t.push(`${a} agent ${a===1?"change":"changes"}`),s.diff.changedActions.length&&t.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&t.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&t.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&t.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&t.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),t.join(", ")||"Profile source has local changes."}function Js(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}const ca=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],da=120,ua=new Set(["openai","xai","zai"]),ha=new Set(["chatgpt-subscription"]),ma="https://api.z.ai/api/coding/paas/v4";function ks(s){return s.split(/[\n,]/).map(t=>t.trim()).filter(Boolean)}function Ys(s){return s?s.available?"Ready":s.credential.connected?"Configured":s.credential.lastError||s.lastError?"Needs attention":s.id==="codex"?"Needs Codex login":s.routing.localByok?"Needs key":s.enabled?"Enabled":"Off":"Unknown"}function Qs(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Ps(s){return s.credential.connected?s.credential.redacted?s.credential.redacted:s.credential.source==="chatgpt_subscription"?"ChatGPT subscription":s.credential.source:s.credential.lastError??"Not connected"}function pa(s){return s?.trim().replace(/\/+$/,"")??""}function Zs(s,t){return s.id==="zai"&&pa(t.providers.zai?.baseUrl)===ma}function ga(s,t){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":Zs(s,t)?"Coding Plan key":"API key"}function fa(s,t){const a=t.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const n=Math.max(a?.models.length??0,s.modelIds.length),l=s.defaultModel?ts(s.defaultModel,t,s.id):"",i=n===1?"1 model":`${n} models`,u=ga(s,t);return[Ys(s),u,a?i:"",l].filter(Boolean).join(" · ")}function xa(s){return s!=="openpond"&&ss(s)}function cs(s){return s?ua.has(s.id)||s.credentialModes.some(t=>ha.has(t)):!1}function ja(s){return cs(s)?["api","subscription"]:["api"]}function Rs(s,t){return!s||!t||!cs(s)?"api":s.credential.source==="chatgpt_subscription"||Zs(s,t)?"subscription":"api"}function As(s,t){const a=Rt.filter(n=>!!s?.statuses[n]);return t?a.filter(n=>cs(s?.statuses[n])):a}function va(s){if(!s)return"Never";const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function ba(s,t,a=da){const n=[],l=new Set,i=new Set(t.map(c=>c.trim()).filter(Boolean)),u=c=>{l.has(c.value)||n.length>=a||(l.add(c.value),n.push(c))};for(const c of s)i.has(c.value)&&u(c);for(const c of s)u(c);return n}function ya({account:s,codex:t,providers:a,providerBusy:n,validationMessage:l,deleteProviderCredential:i,loadProviderModels:u,refreshProviderModels:c,saveProviderConfig:o,saveProviderCredential:y,startOpenAiSubscriptionAuth:p,validateProvider:x}){const[d,m]=r.useState(null),[h,j]=r.useState(!1),S=r.useMemo(()=>As(a,!1),[a]),k=r.useMemo(()=>As(a,h),[a,h]),f=d?a?.statuses[d]??null:null;function R(D,N){m(D),N&&u(D)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),a?e.jsxs("div",{className:"provider-manager-panel",children:[e.jsxs("div",{className:"account-list-heading provider-manager-heading",children:[e.jsxs("div",{className:"provider-manager-title-row",children:[e.jsx("span",{children:"Model providers"}),e.jsxs("label",{className:"settings-check-row compact provider-subscription-filter",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:D=>j(D.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[k.length," of ",S.length," presets"]})]}),k.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:k.map(D=>{const N=a.statuses[D],I=a.modelCaches[D],P=N.modelIds.length>0&&(I?.models.length??0)<N.modelIds.length,O=n?.startsWith(`${D}:`)??!1,g=xa(D),C=D==="openpond"||!!a.providers[D]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${N.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:C,disabled:!g||O,onChange:w=>{R(D,!1),o(D,{enabled:w.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:N.displayName})}),e.jsxs("div",{className:`provider-row-status ${Qs(N)}`,children:[O?e.jsx(ae,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:fa(N,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{R(D,P)},children:"Details"})]},D)})}):e.jsxs("div",{className:"empty-account-list provider-manager-empty",children:[e.jsx("strong",{children:"No subscription providers"}),e.jsx("span",{children:"Turn off the filter to show API-key providers."})]})]}):null,l?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:l})]}):null,d&&f&&a?e.jsx(Na,{account:s,codex:t,providerId:d,providerBusy:n,settings:a,status:f,onClose:()=>m(null),onDeleteCredential:i,onRefreshModels:c,onSaveConfig:o,onSaveCredential:y,onStartOpenAiSubscriptionAuth:p,onValidate:x}):null]})}function Na({account:s,codex:t,providerId:a,providerBusy:n,settings:l,status:i,onClose:u,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:y,onSaveCredential:p,onStartOpenAiSubscriptionAuth:x,onValidate:d}){const m=l.providers[a],h=l.modelCaches[a],j=r.useId(),S=r.useRef(a),k=Math.max(h?.models.length??0,i.modelIds.length),f=i.routing.localByok&&ss(a)&&a!=="codex",R=r.useMemo(()=>f?ja(i):[],[f,i]),D=R.includes("subscription"),[N,I]=r.useState(()=>Rs(i,l)),P=f&&N==="subscription"&&D,O=C=>`${j}-${C}-panel`,g=a==="codex"?"Codex app server":m?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(S.current!==a){S.current=a,I(Rs(i,l));return}f&&!R.includes(N)&&I("api")},[N,R,f,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:u,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:C=>C.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(ie,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.displayName}),e.jsx("span",{children:Ee(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${Qs(i)}`,children:Ys(i)})]}),f?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:R.map(C=>e.jsx("button",{type:"button",role:"tab",id:`${j}-${C}`,className:N===C?"active":void 0,"aria-selected":N===C,"aria-controls":O(C),onClick:()=>I(C),children:C==="api"?"API":"Subscription"},C))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Ps(i),children:Ps(i)})]}),P?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:g,children:g})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:m?.defaultModel??i.defaultModel??void 0,children:m?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:h?.lastError??void 0,children:[k," cached · ",va(h?.fetchedAt)]})]})]}),a==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:t?.account?.email??void 0,children:t?.account?.label??t?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:t?.binaryPath??void 0,children:t?.binaryPath??"Not found"})]})]}):null,i.credential.lastError||h?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??h?.lastError??i.lastError??void 0,children:i.credential.lastError??h?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(wa,{providerBusy:n,status:i,onValidate:d}):f&&m&&h?e.jsx(Sa,{credentialTab:N,credentialTabsId:j,hasSubscriptionTab:D,providerId:a,providerBusy:n,settings:l,status:i,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:y,onSaveCredential:p,onStartOpenAiSubscriptionAuth:x,onValidate:d}):i.routing.localByok&&!ss(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Hs,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function wa({providerBusy:s,status:t,onValidate:a}){const n=s==="codex:validate";return e.jsxs("div",{className:"provider-dialog-body codex-provider-body",children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(ue,{size:15}),e.jsxs("span",{children:["Uses your local ",e.jsx("code",{children:"codex login"})," session through the Codex app server. This route is separate from OpenAI Platform API-key billing."]})]}),e.jsx("div",{className:"settings-button-row codex-provider-actions",children:e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n,onClick:()=>{a("codex",{modelId:t.defaultModel??void 0})},children:[n?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(Us,{size:14}),e.jsx("span",{children:n?"Testing":"Test Codex login"})]})})]})}function Sa({credentialTab:s,credentialTabsId:t,hasSubscriptionTab:a,providerId:n,providerBusy:l,settings:i,status:u,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:y,onSaveCredential:p,onStartOpenAiSubscriptionAuth:x,onValidate:d}){const m=i.providers[n],h=r.useMemo(()=>ze(n,i),[n,i]),j=`provider-models-${n}`,S=r.useRef(n),[k,f]=r.useState(m.baseUrl??""),[R,D]=r.useState(m.defaultModel??""),[N,I]=r.useState(m.modelOverrides.join(`
|
|
3
|
-
`)),[P,O]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[g,C]=r.useState("local_secret"),[w,
|
|
4
|
-
`));return}P.baseUrl||
|
|
5
|
-
`))},[m.baseUrl,m.defaultModel,m.modelOverrides,P.baseUrl,P.defaultModel,P.modelOverrides,n]);const fe=g==="env"?!!E.trim():!!w.trim();async function oe(z){z.preventDefault(),await y(n,{enabled:!0,baseUrl:k.trim()||null,defaultModel:R.trim()||null,modelOverrides:ks(N)}),O({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function T(z){if(z.preventDefault(),!!fe){if(g==="env"){await p(n,{source:"env",envVar:E.trim()});return}await p(n,{source:"local_secret",value:w}),b("")}}function B({panel:z=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:z?Y:void 0,role:z?"tabpanel":void 0,"aria-labelledby":z?`${t}-${s}`:void 0,onSubmit:_=>{T(_)},children:[e.jsxs("div",{className:"provider-card-grid credential-grid",children:[e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Credential source"}),e.jsx(Pe,{value:g,disabled:K,label:"Credential source",options:ca,onChange:_=>C(_)})]}),g==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:E,disabled:K,placeholder:"PROVIDER_API_KEY",onChange:_=>L(_.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:re}),e.jsx("input",{type:"password",value:w,disabled:K,placeholder:ce,autoComplete:"off",onChange:_=>b(_.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:K||!fe,children:[K?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:K?"Saving":V})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:K||!u.credential.connected,onClick:()=>{c(n)},children:e.jsx(be,{size:15})})]})]})}function H(){return q?e.jsxs("div",{className:"provider-subscription-panel",id:Y,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(ue,{size:15}),e.jsx("span",{children:"ChatGPT subscription auth opens OpenAI login and stores a refresh token locally. API keys remain available under the API tab for raw Platform billing."})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{type:"button",className:"settings-secondary",disabled:A,onClick:()=>{x("browser")},children:[A?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:A?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:A,onClick:()=>{x("device")},children:[A?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:A||!u.credential.connected,onClick:()=>{c(n)},children:e.jsx(be,{size:15})})]})]}):J?e.jsx("div",{className:"provider-subscription-panel",id:Y,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(ue,{size:15}),e.jsx("span",{children:"SuperGrok includes Grok app and Grok Build access. xAI API calls here still use an xAI Console API key with API credits or invoiced billing, so there is no separate Connect SuperGrok step yet."})]})}):W?e.jsxs("div",{className:"provider-subscription-panel",id:Y,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(ue,{size:15}),e.jsx("span",{children:"GLM Coding Plan uses a plan API key with the dedicated Coding endpoint. General Z.ai API keys and balances are separate."})]}),B({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[U?null:e.jsxs("form",{className:"provider-card-form",onSubmit:z=>{oe(z)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:k,disabled:G,placeholder:"https://api.example.com/v1",onChange:z=>{O(_=>({..._,baseUrl:!0})),f(z.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:j,value:R,disabled:G,placeholder:"Model id",onChange:z=>{O(_=>({..._,defaultModel:!0})),D(z.currentTarget.value)}}),e.jsx("datalist",{id:j,children:le.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))}),se>0?e.jsxs("small",{children:[se," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:G,children:[G?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(os,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:v,onClick:()=>{o(n)},children:[v?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(te,{size:14}),e.jsx("span",{children:v?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Q||!R.trim(),onClick:()=>{d(n,{baseUrl:k.trim()||void 0,modelId:R.trim()||void 0})},children:[Q?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(Us,{size:14}),e.jsx("span",{children:Q?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:U?H():B()})]})}function Ca({status:s,busy:t,flashTailscaleUp:a,refresh:n,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:u,copyTailscaleUpCommand:c,copyServeCommand:o,copyServeSetupUrl:y,copyOperatorCommand:p,createRemoteLink:x}){const d=s?.tailscale.installed??!1,m=s?.serve.enabled??!1,h=s?.serve.reachable??!1,j=!!(s?.webUiAvailable&&d),S=m?!!s?.remoteWebUrl:j,f=(s?.tailscale.peers??[]).filter(N=>!N.isSelf),R=!!s?.tailscale.error?.includes("set --operator"),D=!!(m&&s?.remoteWebUrl);return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx("div",{className:`remote-access-icon ${h?"online":m?"configured":""}`,children:d?e.jsx(qs,{size:18}):e.jsx(qt,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:h?"Tailscale Serve is reachable":m?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Ra(s):"Checking Tailscale"})]})]}),e.jsxs("div",{className:"account-summary-actions",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh remote access","aria-label":"Refresh remote access",disabled:t!==null,onClick:()=>{n()},children:e.jsx(te,{className:t==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t!==null||!d||!m&&!j,onClick:()=>{m?i():l()},children:[e.jsx(ln,{size:15}),e.jsx("span",{children:m?t==="disable"?"Turning off":"Turn off":t==="enable"?"Turning on":"Turn on"})]})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsx("div",{className:"account-list-heading remote-access-link-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"OpenPond link"}),e.jsx("small",{children:D?"Browser UI":"Tailscale + Serve"})]})}),D&&e.jsx(de,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:t==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||t!==null,onAction:u}),e.jsx(de,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:c}),e.jsx(de,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:o}),s?.serve.setupUrl&&e.jsx(de,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:y}),R&&e.jsx(de,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:p}),e.jsx(de,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(de,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(de,{label:"Disable command",value:s?.disableCommand??null})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading remote-access-link-heading",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Authorized clients"}),e.jsxs("small",{children:[f.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:t!==null||!S,onClick:()=>{x()},children:e.jsx("span",{children:m?"Copy link":"Create link"})})]}),s?f.length===0?e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No clients reported"}),e.jsx("span",{children:s?.tailscale.running?"Tailscale did not return peer devices.":"Tailscale is not running."})]}):f.map(N=>e.jsx(Pa,{peer:N},N.id)):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"Checking clients"}),e.jsx("span",{children:"Loading tailnet devices."})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Remote environment"}),e.jsx("small",{children:s?.tailscale.tailnetName??"Tailnet"})]}),e.jsx(ka,{status:s})]}),s?.serve.configText&&e.jsxs("div",{className:"remote-access-config",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Tailscale config"}),e.jsx("small",{children:s.serve.enabled?"OpenPond target found":"No OpenPond target"})]}),e.jsx("pre",{children:s.serve.configText})]})]})}function de({actionLabel:s,disabled:t,flash:a,label:n,onAction:l,value:i}){return e.jsxs("div",{className:"product-row remote-access-value-row",children:[e.jsxs("div",{children:[e.jsx("strong",{className:a?"flash":void 0,children:n}),e.jsx("code",{children:i??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function ka({status:s}){const t=[{label:"State",value:s?.tailscale.backendState??"Unknown"},{label:"Machine",value:s?.tailscale.machineName??"Unknown"},{label:"Tailnet",value:s?.tailscale.tailnetName??"Unknown"}],a=[{label:"Tailscale IP",value:s?.tailscale.tailscaleIps.join(", ")||"Unknown"},{label:"HTTPS host",value:s?.serve.httpsHost??s?.tailscale.dnsName??"Unknown"}];return e.jsxs("div",{className:"remote-access-environment",children:[e.jsx("div",{className:"remote-access-environment-row three",children:t.map(n=>e.jsx(Ds,{label:n.label,value:n.value},n.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(n=>e.jsx(Ds,{label:n.label,value:n.value},n.label))})]})}function Ds({label:s,value:t}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:t})]})}function Pa({peer:s}){return e.jsxs("div",{className:"account-row remote-access-peer-row",children:[e.jsx("div",{className:`remote-access-peer-dot ${s.online?"online":""}`}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:s.name}),e.jsx("span",{children:s.dnsName??s.tailscaleIps[0]??"No address"})]}),e.jsx("span",{className:`account-state ${s.online?"signed_in":""}`,children:s.online?"Online":"Offline"}),e.jsx("span",{className:"account-state",children:s.os??"Unknown"})]})}function Ra(s){return s.tailscale.installed?s.tailscale.running?s.webUiAvailable?s.serve.reachable?s.remoteUrl??"Tailnet link ready":s.remoteUrl?`${s.remoteUrl} ready to configure`:"Tailnet DNS unavailable":"Browser UI is not served by this process":s.tailscale.authUrl?"Tailscale needs sign-in":"Tailscale is not running":"Tailscale is not installed"}const Aa=[{items:[{section:"account",label:"Account",Icon:hn},{section:"notifications",label:"Notifications",Icon:Gs},{section:"providers",label:"Providers",Icon:Dt},{section:"compute",label:"Compute",Icon:Kt},{section:"dataset-storage",label:"Dataset Storage",Icon:tn},{section:"usage",label:"Activity",Icon:It},{section:"defaults",label:"Defaults",Icon:Ws}]},{label:"Harness",items:[{section:"harness",label:"Harness",Icon:qe},{section:"skills",label:"Skills",Icon:Le},{section:"context",label:"Context",Icon:$t},{section:"training",label:"Training",Icon:qe},{section:"subagents",label:"Subagents",Icon:qe}]},{items:[{section:"profile",label:"Legacy Profiles",Icon:Be},{section:"editor",label:"Editor",Icon:Ft},{section:"remote",label:"Remote",Icon:qs},{section:"personalization",label:"Personalization",Icon:Jt},{section:"diagnostics",label:"Diagnostics",Icon:Wt}]}];function Da({section:s,onBack:t,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back",onClick:t,children:[e.jsx(At,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Aa.map((n,l)=>e.jsxs("div",{className:"settings-nav-group",children:[n.label?e.jsx("div",{className:"settings-nav-heading",children:n.label}):null,n.items.map(({section:i,label:u,Icon:c})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(c,{size:16}),e.jsx("span",{children:u})]},i))]},n.label??`settings-${l}`))})]})}function Ia({catalog:s,connection:t,onCatalog:a,onError:n,onOpenExtension:l,onToast:i}){const[u,c]=r.useState(""),[o,y]=r.useState(""),[p,x]=r.useState(null),[d,m]=r.useState(null),[h,j]=r.useState(null),S=r.useCallback(g=>{const C=g instanceof Error?g.message:String(g);j(C),n(C),i?.(C,"error")},[n,i]),k=r.useCallback(()=>{j(null),n(null)},[n]),f=r.useCallback(async g=>{if(g?.preventDefault(),!(!t||!u.trim()||d)){k(),m("preview");try{const C=await $.extensionPreview(t,{source:u.trim(),...o.trim()?{ref:o.trim()}:{}});x(C)}catch(C){x(null),S(C)}finally{m(null)}}},[d,k,t,S,o,u]),R=r.useCallback(async()=>{if(!(!t||!p||d)){k(),m("install");try{const g=await $.extensionAdd(t,{source:p.repositoryUrl,ref:p.requestedRef});a(g.catalog),c(""),y(""),x(null),i?.(`Installed ${g.extension.owner}/${g.extension.repo}.`,"success")}catch(g){S(g)}finally{m(null)}}},[d,k,t,a,i,p,S]),D=r.useCallback(async g=>{if(!(!t||d)){k(),m(`update:${g.id}`);try{const C=await $.extensionUpdate(t,g);a(C.catalog);const w=C.extension.resolvedCommit===g.resolvedCommit&&C.extension.packageHash===g.packageHash;i?.(w?`${g.owner}/${g.repo} is already current.`:`Updated ${g.owner}/${g.repo}.`,"success")}catch(C){S(C)}finally{m(null)}}},[d,k,t,a,i,S]),N=r.useCallback(async()=>{if(!(!t||d||s.extensions.length===0)){k(),m("update-all");try{const g=await $.extensionUpdateAll(t);a(g.catalog);const C=`Updated ${g.updated.length}; ${g.unchanged.length} already current${g.failed.length?`; ${g.failed.length} failed`:""}.`;i?.(C,g.failed.length?"error":"success"),g.failed.length&&j(g.failed.map(w=>w.error).join(" "))}catch(g){S(g)}finally{m(null)}}},[d,s.extensions.length,k,t,a,i,S]),I=r.useCallback(async g=>{if(!(!t||d)&&window.confirm(`Remove ${g.owner}/${g.repo} and its ${g.skills.length} installed skill${g.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){k(),m(`remove:${g.id}`);try{const C=await $.extensionRemove(t,g);a(C.catalog),i?.(`Removed ${g.owner}/${g.repo}.`,"success")}catch(C){S(C)}finally{m(null)}}},[d,k,t,a,i,S]),P=r.useCallback(g=>{c(g),x(null),j(null)},[]),O=r.useCallback(g=>{y(g),x(null),j(null)},[]);return e.jsxs("div",{className:"account-list native-skills-list github-extensions-list",children:[e.jsxs("div",{className:"account-list-heading github-extensions-heading",children:[e.jsx("span",{children:"Third-party extensions"}),e.jsxs("div",{className:"github-extensions-heading-actions",children:[e.jsxs("small",{children:[s.extensions.length," installed from GitHub"]}),e.jsxs("button",{className:"settings-secondary compact",disabled:!t||d!==null||s.extensions.length===0,type:"button",onClick:()=>{N()},children:[d==="update-all"?e.jsx(ae,{className:"settings-spin",size:13}):e.jsx(te,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:g=>{f(g)},children:[e.jsxs("div",{className:"github-extension-add-copy",children:[e.jsx("strong",{children:"Add a GitHub skill pack"}),e.jsx("span",{children:"Use a skills-CLI-compatible owner/repo or GitHub URL. OpenPond installs it locally without running setup code."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{disabled:!t||d!==null,placeholder:"owner/repo",value:u,onChange:g=>P(g.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!t||d!==null,placeholder:"Default branch",value:o,onChange:g=>O(g.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!u.trim()||d!==null,type:"submit",children:[d==="preview"?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(es,{size:14}),d==="preview"?"Checking":"Preview"]})]}),h||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:h??s.error}):null,p?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[p.owner,"/",p.repo]}),e.jsxs("span",{children:[p.skills.length," skill",p.skills.length===1?"":"s"," at ",p.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:p.skills.map(g=>e.jsx("span",{children:g.name},g.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:d!==null,type:"button",onClick:()=>{R()},children:[d==="install"?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(me,{size:14}),d==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(g=>{const C=d===`update:${g.id}`,w=d===`remove:${g.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${g.owner}/${g.repo} extension source`,className:"github-extension-open",disabled:!t||d!==null,type:"button",onClick:()=>l(g),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(es,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[g.owner,"/",g.repo]}),e.jsx("span",{children:g.skills.map(b=>b.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[g.skills.length," skill",g.skills.length===1?"":"s"]}),e.jsxs("span",{children:[g.requestedRef," · ",g.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${g.validationStatus==="valid"?"":"invalid"}`,children:g.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(zs,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${g.owner}/${g.repo}`,className:"settings-icon-button ghost",disabled:d!==null,title:"Update extension",type:"button",onClick:()=>{D(g)},children:C?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(te,{size:14})}),e.jsx("button",{"aria-label":`Remove ${g.owner}/${g.repo}`,className:"settings-icon-button ghost danger",disabled:d!==null,title:"Remove extension",type:"button",onClick:()=>{I(g)},children:w?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(be,{size:14})})]})]},g.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function $a({onOpenSkill:s,onOpenExtension:t,personalSkills:a,extensionCatalog:n,connection:l,onExtensionCatalog:i,onError:u,onToast:c}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(Ia,{catalog:n,connection:l,onCatalog:i,onError:u,onOpenExtension:t,onToast:c}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),a.length?a.map(o=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Le,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:o.resourceFiles.length?`${o.resourceFiles.length} packaged resource${o.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:o.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${o.validationStatus==="valid"?"":"invalid"}`,children:o.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},o.sourcePath)):e.jsx("div",{className:"skills-settings-empty",children:"No personal Codex skills found."})]}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"App integration skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),Mt.map(o=>{const y=Et(o.provider)?.label??o.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(o),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Le,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:y}),e.jsx("span",{children:o.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(zs,{size:16,"aria-hidden":"true"})]},o.name)})]})]})}const ds="default";function Ma({connection:s,embedded:t=!1,onError:a,onPreferences:n,preferences:l,providers:i}){const u=l.training,[c,o]=r.useState(Qe(u.defaultModelRef)),[y,p]=r.useState(u.creationMode),[x,d]=r.useState(u.autoApproveEvidence),[m,h]=r.useState(!1),j=r.useMemo(()=>Ts(i,{includeUnavailable:!0}),[i]),S=r.useMemo(()=>j.map(N=>({provider:N,models:ze(N.value,i)})).filter(N=>N.models.length>0),[j,i]),k=Ea(c),f=Lt(l.defaultChatProvider,l.defaultChatModel,i)?` · ${La(l.codexReasoningEffort)} reasoning`:"",R=Ta(k,u.defaultModelRef??null)&&y===u.creationMode&&x===u.autoApproveEvidence;r.useEffect(()=>{o(Qe(u.defaultModelRef)),p(u.creationMode),d(u.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,u.autoApproveEvidence,u.creationMode,u.defaultModelRef]);async function D(N){if(N.preventDefault(),!!s){h(!0),a(null);try{n(await $.savePreferences(s,{training:{defaultModelRef:k,creationMode:y,autoApproveEvidence:x}}))}catch(I){a(I instanceof Error?I.message:String(I))}finally{h(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${t?" embedded":""}`,children:[t?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:N=>{D(N)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Taskset authoring"}),e.jsx("small",{children:"The coding model that proposes tasks, graders, fixtures, and policy boundaries"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Authoring model"}),e.jsxs("select",{value:c,disabled:m,onChange:N=>o(N.target.value),children:[e.jsxs("option",{value:ds,children:["Use chat default — ",Ee(l.defaultChatProvider,i)," · ",ts(l.defaultChatModel,i,l.defaultChatProvider),f]}),S.map(N=>e.jsx("optgroup",{label:N.provider.label,children:N.models.map(I=>e.jsx("option",{value:Qe({providerId:N.provider.value,modelId:I.value}),children:I.label},I.value))},N.provider.value))]}),e.jsx("small",{children:"By default, /train follows the same provider, model, and reasoning level selected for chat."})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Default flow"}),e.jsx("small",{children:"Used by /train and Task Creator unless you choose another mode"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Task Creator mode"}),e.jsxs("select",{value:y,disabled:m,onChange:N=>p(N.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:x,disabled:m,onChange:N=>d(N.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:m||R,children:e.jsx("span",{children:m?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:k?`${Ee(k.providerId,i)} / ${ts(k.modelId,i,k.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function Qe(s){return s?JSON.stringify([s.providerId,s.modelId]):ds}function Ea(s){if(s===ds)return null;try{const t=JSON.parse(s);return!Array.isArray(t)||t.length!==2||typeof t[0]!="string"||typeof t[1]!="string"?null:{providerId:t[0],modelId:t[1]}}catch{return null}}function La(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Ta(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function Xs({disabled:s,onChange:t,purpose:a="model",storageRoots:n,value:l}){const i=r.useId(),[u,c]=r.useState(!1),o=Is(l),y=d=>a==="dataset"?d.datasetStorePath:d.modelStorePath,p=a==="dataset"?"Dataset":"Model",x=n.find(d=>Is(y(d))===o)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:i,children:[p," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${p} storage drive`,className:"model-storage-select",disabled:s,id:i,title:l??`No ${a} storage configured`,value:l??"",onChange:d=>t(d.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),l&&!x?e.jsx("option",{value:l,children:"Manual location"}):null,n.map(d=>e.jsxs("option",{disabled:!d.mounted||!d.writable,title:y(d),value:y(d),children:[d.label," · ",Ba(d.kind)," · ",_a(d)]},d.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":`Add manual ${a} storage location`,onClick:()=>c(!0),children:e.jsx(me,{size:15})})]}),u?Oa(e.jsx(Ua,{initialPath:l??"",purpose:a,onClose:()=>c(!1),onUse:d=>{t(d),c(!1)}})):null]})}function Oa(s){return typeof document>"u"?s:Yt.createPortal(s,document.body)}function Ua({initialPath:s,onClose:t,onUse:a,purpose:n="model"}){const l=r.useId(),[i,u]=r.useState(s),c=za(i);r.useEffect(()=>{const y=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[t]);function o(y){y.preventDefault(),y.stopPropagation(),!c&&a(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${n} storage`,onClick:t,children:e.jsx(ie,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Qt,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",n," storage"]}),e.jsx("p",{children:"Enter an absolute path to a folder mounted on this machine."}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Mounted folder path"}),e.jsx("input",{autoFocus:!0,spellCheck:!1,value:i,placeholder:n==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:y=>u(y.target.value)})]}),e.jsx("div",{className:"model-storage-dialog-note",children:"For SMB, connect the share in Files or Finder first, then paste its mounted folder path. OpenPond uses your operating system’s existing connection and credentials."}),i.trim()&&c?e.jsx("div",{className:"profile-dialog-warning",children:c}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!c,type:"submit",children:"Use location"})]})]})})}function za(s){const t=s.trim();return t?/^[a-z][a-z\d+.-]*:\/\//i.test(t)?"Use the mounted folder path, not an smb:// or other network URL.":t==="~"||t.startsWith("~/")||t.startsWith("/")||t.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(t)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function Ba(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function _a(s){return s.mounted?s.writable?`${Ha(s.freeBytes)} free`:"Read only":"Not mounted"}function Is(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Ha(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function Fa({state:s,busy:t,title:a="Compute",onScan:n,onSave:l,onDownloadSmolLm2:i,onCancelDownload:u}){const c=s?.inventory??null,[o,y]=r.useState(s?.settings.modelStorePath??null),[p,x]=r.useState(s?.settings.defaultDeviceIds[0]??"automatic");r.useEffect(()=>{y(s?.settings.modelStorePath??null)},[s?.settings.modelStorePath]),r.useEffect(()=>{x(s?.settings.defaultDeviceIds[0]??"automatic")},[s?.settings.defaultDeviceIds]);const d=o===(s?.settings.modelStorePath??null)&&p===(s?.settings.defaultDeviceIds[0]??"automatic"),m=r.useMemo(()=>c?.devices.filter(f=>f.kind!=="cpu"&&f.available)??[],[c?.devices]),h=c?.models.find(f=>f.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,j=[...c?.downloads??[]].reverse().find(f=>f.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,S=!!(j&&["queued","downloading","verifying","cancelling"].includes(j.status));async function k(f){f.preventDefault(),await l(o,s?.settings.datasetStorePath??null,p==="automatic"?[]:[p])}return e.jsxs("section",{className:"account-settings compute-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsx("h1",{children:a}),e.jsx("button",{className:"settings-icon-button",type:"button",title:"Scan compute","aria-label":"Scan compute",disabled:t!==null,onClick:()=>{n()},children:e.jsx(te,{size:15,className:t==="scan"?"settings-spin":void 0})})]}),e.jsx("div",{className:"account-summary",children:e.jsx("div",{className:"account-summary-main compute-summary-main",children:e.jsxs("div",{children:[e.jsx("strong",{children:c?`${c.host.operatingSystem} · ${c.host.architecture}`:t==="load"?"Loading this machine":"This machine has not been scanned"}),e.jsx("small",{children:c?`${c.devices.length} device${c.devices.length===1?"":"s"} · ${Ce(c.host.totalMemoryBytes)} memory · scanned ${Va(c.scannedAt)}`:"Run a bounded native scan to discover local training capabilities."})]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:f=>{k(f)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Defaults"})}),e.jsx(Xs,{disabled:t!==null,storageRoots:c?.storageRoots??[],value:o,onChange:y}),e.jsx("div",{className:"provider-settings-grid single compute-device-default",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default device"}),e.jsxs("select",{value:p,disabled:t!==null,onChange:f=>x(f.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),m.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})]})}),e.jsx("button",{className:"settings-primary",disabled:t!==null||d,children:t==="save"?"Saving":"Save compute settings"})]}),e.jsx($s,{title:"Devices",empty:"No devices discovered",rows:(c?.devices??[]).map(f=>({id:f.id,title:f.name,detail:Ga(f),meta:f.available?"Available":f.unavailableReason??"Unavailable"}))}),e.jsx($s,{title:"Runtimes",empty:"No runtimes discovered",rows:(c?.runtimes??[]).map(f=>({id:f.id,title:qa(f.kind),detail:f.version??f.detail??"Not installed",meta:f.state==="available"?"Available":"Unavailable"}))}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Models"}),e.jsxs("div",{className:"compute-heading-actions",children:[S&&j?e.jsx("button",{type:"button",className:"settings-secondary",disabled:j.status==="cancelling",onClick:()=>{u(j.id)},children:j.status==="cancelling"?"Cancelling":"Cancel"}):h?null:e.jsx("button",{type:"button",className:"settings-secondary",disabled:!s?.settings.modelStorePath,onClick:()=>{i()},children:"Download SmolLM2"}),e.jsx("small",{children:c?.models.length??0})]})]}),j&&!h?e.jsxs("div",{className:"compute-download-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"SmolLM2 135M Instruct"}),e.jsx("small",{children:j.status==="failed"?j.error:`${Wa(j.status)} · ${Ce(j.downloadedBytes)} of ${Ce(j.expectedBytes)} · Apache-2.0`})]}),e.jsx("progress",{max:j.expectedBytes,value:j.downloadedBytes})]}):null,c?.models.length?c.models.map(f=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:f.name}),e.jsxs("small",{children:[f.source," · ",f.format," · ",Ce(f.sizeBytes)]})]}),e.jsx("span",{children:f.trainingCompatible?"Trainable":f.inferenceCompatible?"Inference only":"Unsupported"})]},f.id)):j?null:e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"No recognized local models"})})]}),c?.warnings.length?e.jsxs("details",{className:"compute-diagnostics",children:[e.jsx("summary",{children:"Diagnostics"}),e.jsx("ul",{children:c.warnings.map(f=>e.jsx("li",{children:f},f))})]}):null]})}function $s({title:s,empty:t,rows:a}){return e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:s}),e.jsx("small",{children:a.length})]}),a.length?a.map(n=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:n.title}),e.jsx("small",{children:n.detail})]}),e.jsx("span",{children:n.meta})]},n.id)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t})})]})}function Ga(s){return[s.vendor,s.kind,s.totalMemoryBytes?Ce(s.totalMemoryBytes):null,s.computeCapability?`compute ${s.computeCapability}`:null].filter(Boolean).join(" · ")}function qa(s){return s==="trl_peft"?"TRL / PEFT":s.toUpperCase()}function Wa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Va(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Ce(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function Ka({state:s,catalog:t,busy:a,catalogLoading:n,onRefresh:l,onSave:i}){const[u,c]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{c(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const o=r.useMemo(()=>s?.inventory?.storageRoots.find(d=>Ms(d.datasetStorePath)===Ms(u))??null,[u,s?.inventory?.storageRoots]),y=u===(s?.settings.datasetStorePath??null),p=t?.datasets??[];async function x(d){d.preventDefault(),await i(u)}return e.jsxs("section",{className:"account-settings compute-settings dataset-storage-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Dataset Storage"}),e.jsx("p",{className:"dataset-storage-intro",children:"Choose where Dataset artifacts are saved and review registered Datasets without loading their rows."})]}),e.jsx("button",{"aria-label":"Refresh Dataset storage",className:"settings-icon-button",disabled:a!==null||n,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(te,{className:n?"settings-spin":void 0,size:15})})]}),e.jsx("div",{className:"account-summary",children:e.jsx("div",{className:"account-summary-main compute-summary-main",children:e.jsxs("div",{children:[e.jsx("strong",{children:o?.label??(u?"Manual location":"Not configured")}),e.jsx("small",{children:u??"Choose a writable local or mounted location before importing a Dataset."}),o?e.jsxs("small",{children:[Za(o.kind)," · ",o.freeBytes==null?"Free space unknown":`${et(o.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{x(d)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(Xs,{disabled:a!==null,onChange:c,purpose:"dataset",storageRoots:s?.inventory?.storageRoots??[],value:u}),e.jsx("button",{className:"settings-primary",disabled:a!==null||y,children:a==="save"?"Saving":"Save Dataset storage"})]}),e.jsxs("div",{className:"account-list dataset-storage-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Registered Datasets"}),e.jsx("small",{children:p.length})]}),p.length?p.map(d=>e.jsx(Ja,{dataset:d},d.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:n?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Ja({dataset:s}){const t=s.storageKind==="parquet"?"Parquet":"Inline Taskset";return e.jsxs("div",{className:"compute-row dataset-storage-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[st(s.rowCount)," rows"," · ",Ya(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":et(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?Qa(s.status):"Unavailable"})]})}function Ya(s){return[["train",s.splitCounts.train],["validation",s.splitCounts.validation],["test",s.splitCounts.test],["frozen eval",s.splitCounts.frozen_eval]].filter(([,a])=>Number(a)>0).map(([a,n])=>`${st(Number(n))} ${a}`).join(" · ")||"No split rows"}function et(s){if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function st(s){return new Intl.NumberFormat().format(s)}function Ms(s){return s?.replace(/[\\/]+$/,"")??""}function Qa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Za(s){return s.replace(/^./,t=>t.toUpperCase())}function ve(s){if(!s)return"Not yet";const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function ke(s){return s?s.slice(0,10):"none"}function Ue(s){return s.replaceAll("_"," ")}function Xa({review:s}){const t=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:t.map(([a,n])=>e.jsxs("div",{className:n?"linked":"pending",children:[e.jsx("span",{children:a}),e.jsx("code",{children:n?ke(n.contentHash):"Not created"})]},a))})}function el({accepting:s,onAcceptTasksetReview:t,review:a}){const n=a.classification==="taskset"&&a.nextAuthority==="human_review"&&a.tasksetProposal===null;return e.jsxs("article",{className:"harness-history-card harness-evaluation-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:`harness-status harness-status-${a.classification}`,children:Ue(a.classification)}),e.jsx("span",{children:Ue(a.nextAuthority)})]}),e.jsx("h2",{children:a.claim?.statement??a.reason})]}),e.jsx("time",{children:ve(a.createdAt)})]}),e.jsx("p",{children:a.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.claim?.independentOccurrences??0})," independent occurrences"]}),e.jsxs("span",{children:[e.jsxs("strong",{children:["$",a.maxEstimatedCostUsd.toFixed(2)]})," maximum cost"]})]}),e.jsx(Xa,{review:a}),n?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>t(a),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null,e.jsxs("footer",{children:[e.jsxs("span",{children:["Watermark ",ve(a.nextWatermark.throughCreatedAt)]}),e.jsx("code",{children:ke(a.nextWatermark.cursor)})]})]})}function sl({receipt:s}){return e.jsxs("article",{className:"harness-route-card harness-qualification-card",children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:Ue(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsx("time",{children:ve(s.createdAt)})]}),e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("small",{children:["Review ",ke(s.review.contentHash)," · Taskset ",ke(s.tasksetRelease?.contentHash)," · Baseline ",ke(s.baselineEvaluation?.contentHash)," · maximum $",s.maximumCostUsd.toFixed(2)]})]})}function tl({acceptingReviewId:s,busy:t,onAcceptTasksetReview:a,reviews:n,qualifications:l,schedule:i,onReview:u,onSaveSchedule:c}){const[o,y]=r.useState(i.cadence),[p,x]=r.useState(i.enabled),[d,m]=r.useState(String(i.maxEstimatedCostUsd));r.useEffect(()=>{y(i.cadence),x(i.enabled),m(String(i.maxEstimatedCostUsd))},[i]);const h=Number(d),j=Number.isFinite(h)&&h>=0,S=n[0]??null,k=r.useMemo(()=>o!==i.cadence||p!==i.enabled||j&&h!==i.maxEstimatedCostUsd,[o,p,h,i,j]);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Model improvement review"}),e.jsx("p",{children:"Review authorized Harness evidence against a persisted watermark. This does not start training."})]}),e.jsx("button",{className:"settings-primary compact",disabled:t||!j,onClick:()=>u(h),type:"button",children:t?"Reviewing…":"Review now"})]}),e.jsxs("section",{className:"account-list harness-review-controls",children:[e.jsxs("div",{className:"harness-review-control-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Cadence"}),e.jsxs("select",{disabled:t,onChange:f=>{const R=f.target.value;y(R),R==="manual"&&x(!1)},value:o,children:[e.jsx("option",{value:"manual",children:"Manual only"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Maximum estimated cost (USD)"}),e.jsx("input",{disabled:t,min:0,onChange:f=>m(f.target.value),step:"0.01",type:"number",value:d})]}),e.jsxs("label",{className:"harness-schedule-toggle",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Scheduled review"}),e.jsx("small",{children:"Uses the same review operation as Review now."})]}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{checked:p&&o!=="manual",disabled:t||o==="manual",onChange:f=>x(f.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-secondary compact",disabled:t||!k||!j,onClick:()=>c({enabled:p,cadence:o,maxEstimatedCostUsd:h}),type:"button",children:"Save schedule"})]}),e.jsxs("div",{className:"harness-review-status-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Last result"}),e.jsx("strong",{children:S?Ue(S.classification):"No review"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Last run"}),e.jsx("strong",{children:ve(i.lastRunAt)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Next run"}),e.jsx("strong",{children:i.enabled?ve(i.nextRunAt):"Manual"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Watermark"}),e.jsx("strong",{children:S?ve(S.nextWatermark.throughCreatedAt):"Not established"})]})]}),i.lastError?e.jsxs("p",{className:"harness-review-error",children:["Last scheduled run: ",i.lastError]}):null]})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Evaluation reviews"}),e.jsx("p",{children:"Immutable review receipts and their downstream lineage."})]}),e.jsx("span",{children:n.length})]}),n.length?n.map(f=>e.jsx(el,{accepting:s===f.id,onAcceptTasksetReview:a,review:f},`${f.id}:${f.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No model improvement reviews have run."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Training qualifications"}),e.jsx("p",{children:"Evidence-bound decisions that permit a specific training method or record why training is not warranted."})]}),e.jsx("span",{children:l.length})]}),l.length?l.map(f=>e.jsx(sl,{receipt:f},`${f.id}:${f.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No review has reached training qualification."})]})]})}const nl={enabled:!1,cadence:"manual",maxEstimatedCostUsd:0,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null};function Ie(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Ae(s){return s?s.slice(0,10):"none"}function Es(s,t,a){return{workspaceId:s,baseRelease:t?{id:t.id,contentHash:t.contentHash}:null,targetRelease:{id:a.id,contentHash:a.contentHash},title:a.current?"Current Harness release":`Harness release ${Ae(a.contentHash)}`}}function al({change:s,onOpenDiff:t,onOpenSourceSession:a}){const n=s.trigger?.runRef??null,l=s.proposal;return e.jsxs("article",{className:"harness-history-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:`harness-status harness-status-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("span",{children:l?.route??(s.receipt.rollbackOf?"rollback":"workspace")})]}),e.jsx("h2",{children:l?.expectedOutcome??s.receipt.reason})]}),e.jsx("time",{children:Ie(s.receipt.createdAt)})]}),e.jsxs("div",{className:"harness-history-release-flow",children:[e.jsx("code",{children:Ae(s.receipt.previousRelease?.contentHash)}),e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("code",{children:Ae(s.receipt.nextRelease?.contentHash)}),e.jsxs("span",{children:["channel ",s.receipt.previousChannelRevision," → ",s.receipt.nextChannelRevision]})]}),e.jsx("p",{children:s.receipt.reason}),t||n&&a?e.jsxs("div",{className:"harness-history-actions",children:[t?e.jsx("button",{className:"settings-secondary compact",onClick:t,type:"button",children:"View release diff"}):null,n&&a?e.jsx("button",{className:"settings-secondary compact",onClick:()=>a(n),type:"button",children:"Open source conversation"}):null]}):null,l?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Review ",l.edits.length," exact edit",l.edits.length===1?"":"s"]}),e.jsx("div",{className:"harness-edit-list",children:l.edits.map(i=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[i.operation," · ",i.target]}),e.jsx("span",{children:i.summary})]}),i.content!==null?e.jsx("pre",{children:i.content}):e.jsx("p",{children:"File deleted."})]},i.id))})]}):null,s.validations.length?e.jsx("div",{className:"harness-validation-list",children:s.validations.map(i=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${i.status}`,children:i.status}),e.jsx("strong",{children:i.kind.replaceAll("_"," ")}),e.jsx("span",{children:i.summary})]},i.id))}):null,s.outcome?e.jsxs("footer",{children:[e.jsxs("span",{children:["Refiner: ",s.outcome.decision.replaceAll("_"," ")]}),e.jsxs("span",{children:["Estimated cost $",s.outcome.estimatedCostUsd.toFixed(4)]})]}):null]})}function ll({route:s}){return e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"recommendation"}),e.jsx("strong",{children:s.decision.route}),e.jsx("time",{children:Ie(s.decision.createdAt)})]}),e.jsx("p",{children:s.decision.reason}),s.trigger?e.jsxs("small",{children:["Triggered by ",s.trigger.reason]}):null]})}function il({review:s,busy:t,onReview:a}){return e.jsxs("article",{className:"harness-history-card harness-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"review required"}),e.jsxs("span",{children:[s.proposal.route," · ",s.proposal.edits[0]?.operation??"change"]})]}),e.jsx("h2",{children:s.proposal.expectedOutcome})]}),e.jsx("time",{children:Ie(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(n=>n.summary).join(" ")}),e.jsxs("details",{className:"harness-history-details",open:!0,children:[e.jsxs("summary",{children:["Review ",s.proposal.edits.length," exact edit",s.proposal.edits.length===1?"":"s"]}),e.jsx("div",{className:"harness-edit-list",children:s.proposal.edits.map(n=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.operation," · ",n.target]}),e.jsx("span",{children:n.summary})]}),n.content!==null?e.jsx("pre",{children:n.content}):e.jsx("p",{children:"File deleted."})]},n.id))})]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(n=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${n.status}`,children:n.status}),e.jsx("strong",{children:n.kind.replaceAll("_"," ")}),e.jsx("span",{children:n.summary})]},n.id))}),e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:t,onClick:()=>a(s,"decline"),type:"button",children:[e.jsx(ie,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:t||s.validations.some(n=>n.status!=="passed"),onClick:()=>a(s,"approve"),type:"button",children:[e.jsx(Os,{size:13})," Approve and release"]})]})]})}function rl({baseRelease:s,release:t,busy:a,onOpenDiff:n,onRollback:l}){const[i,u]=r.useState(!1);return e.jsxs("div",{className:"harness-release-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.current?"Current release":t.id}),e.jsxs("span",{children:[Ae(t.contentHash)," · ",t.files.length," files · ",Ie(t.createdAt)]})]}),i?e.jsxs("div",{className:"harness-inline-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:a,onClick:()=>u(!1),type:"button",children:[e.jsx(ie,{size:13})," Cancel"]}),e.jsxs("button",{className:"settings-primary compact",disabled:a,onClick:()=>{u(!1),l(t)},type:"button",children:[e.jsx(Te,{size:13})," Confirm rollback"]})]}):e.jsxs("div",{className:"harness-inline-actions",children:[t.current?e.jsx("span",{className:"harness-current-pill",children:"current"}):null,e.jsx("button",{className:"settings-secondary compact",onClick:()=>n(s,t),type:"button",children:"View changes"}),t.current?null:e.jsxs("button",{className:"settings-secondary compact",disabled:a,onClick:()=>u(!0),type:"button",children:[e.jsx(Te,{size:13})," Roll back"]})]})]})}function ol({connection:s,enabled:t,onAcceptEvaluationReview:a,onError:n,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:u,onToast:c}){const[o,y]=r.useState(null),[p,x]=r.useState(!1),[d,m]=r.useState(null),[h,j]=r.useState(null),[S,k]=r.useState(!1),[f,R]=r.useState(!1),[D,N]=r.useState(null),[I,P]=r.useState(!1),O=r.useCallback(async()=>{if(s){x(!0);try{const v=await $.harnessHistory(s);y(v);const A=v.releases.findIndex(J=>J.current),q=A>=0?v.releases[A]:null;v.workspace&&q&&l(Es(v.workspace.id,v.releases[A+1]??null,q)),n(null)}catch(v){n(v instanceof Error?v.message:String(v))}finally{x(!1)}}},[s,l,n]);r.useEffect(()=>{t&&O()},[t,O]);const g=r.useMemo(()=>o?.releases.find(v=>v.current)??null,[o]),C=r.useCallback(async v=>{if(!(!s||!o?.workspace)){k(!0);try{const A=await $.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:v});y(A.history),n(null),c?.(v?"Harness background review enabled.":"Harness background review disabled.","info")}catch(A){n(A instanceof Error?A.message:String(A))}finally{k(!1)}}},[s,o?.workspace,n,c]),w=r.useCallback(async v=>{if(!(!s||!o?.workspace)){R(!0);try{const A=await $.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:v});y(A.history),n(null),c?.(`Harness review completed: ${A.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(A){n(A instanceof Error?A.message:String(A))}finally{R(!1)}}},[s,o?.workspace,n,c]),b=r.useCallback(async v=>{if(!(!s||!o?.workspace)){P(!0);try{const A=await $.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,...v});y(A.history),n(null),c?.(v.enabled?"Harness review schedule saved.":"Harness review schedule disabled.","info")}catch(A){n(A instanceof Error?A.message:String(A))}finally{P(!1)}}},[s,o?.workspace,n,c]),E=r.useCallback(async v=>{if(o?.workspace){N(v.id);try{await a(o.workspace.id,{id:v.id,contentHash:v.contentHash})&&(n(null),c?.("Taskset review opened in Models.","success"))}catch(A){n(A instanceof Error?A.message:String(A))}finally{N(null)}}},[o?.workspace,a,n,c]),L=r.useCallback((v,A)=>{o?.workspace&&i(Es(o.workspace.id,v,A))},[o?.workspace,i]),G=r.useCallback(v=>{!o?.workspace||!v.receipt.nextRelease||i({workspaceId:o.workspace.id,baseRelease:v.receipt.previousRelease,targetRelease:v.receipt.nextRelease,title:v.proposal?.expectedOutcome??v.receipt.reason})},[o?.workspace,i]),K=r.useCallback(async v=>{if(!(!s||!o?.workspace)){m(v.contentHash);try{const A=await $.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:v.id,contentHash:v.contentHash}});y(A.history),n(null),c?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(A){n(A instanceof Error?A.message:String(A))}finally{m(null)}}},[s,o?.workspace,n,c]),Q=r.useCallback(async(v,A)=>{if(!(!s||!o?.workspace)){j(v.proposal.id);try{const q=await $.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:v.proposal.id,contentHash:v.proposal.contentHash},decision:A});y(q.history),n(null),c?.(A==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",A==="approve"?"success":"info")}catch(q){n(q instanceof Error?q.message:String(q))}finally{j(null)}}},[s,o?.workspace,n,c]);return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:"Harness"}),e.jsx("p",{children:"Immutable releases, Refiner changes, validation evidence, and rollback history."})]}),e.jsxs("button",{className:"settings-secondary",disabled:p,onClick:()=>{O()},type:"button",children:[e.jsx(te,{className:p?"settings-spin":void 0,size:14})," Refresh"]})]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&p&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-summary-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Workspace"}),e.jsx("strong",{children:o.workspace.name})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Current release"}),e.jsx("strong",{children:Ae(g?.contentHash)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Channel revision"}),e.jsx("strong",{children:o.workspace.currentChannel.revision})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Status"}),e.jsx("strong",{children:o.workspace.dirty?"Unreleased changes":"Clean"})]})]}),e.jsx("section",{className:"account-list",children:e.jsxs("div",{className:"account-list-row",children:[e.jsxs("div",{className:"account-list-copy",children:[e.jsx("strong",{children:"Background review"}),e.jsx("span",{children:"Review completed Local Work turns for reusable Harness improvements. Turning this off stops new reviews; already queued work may finish."})]}),e.jsxs("label",{className:"provider-toggle","aria-label":"Harness background review enabled",children:[e.jsx("input",{checked:o.backgroundReview.enabled,disabled:S,onChange:v=>{C(v.target.checked)},type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]})}),e.jsx(tl,{acceptingReviewId:D,busy:f||I,onAcceptTasksetReview:v=>{E(v)},onReview:v=>{w(v)},onSaveSchedule:v=>{b(v)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??nl}),e.jsxs("section",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Releases"}),e.jsx("small",{children:"New runs use current; active runs stay pinned."})]}),o.releases.map((v,A)=>e.jsx(rl,{baseRelease:o.releases[A+1]??null,busy:d!==null,onOpenDiff:L,onRollback:K,release:v},`${v.id}:${v.contentHash}`))]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Needs review"}),e.jsx("p",{children:"Executable, Agent, destructive, and sensitive changes never advance without your approval."})]}),e.jsx("span",{children:o.pendingReviews.length})]}),o.pendingReviews.length?o.pendingReviews.map(v=>e.jsx(il,{busy:h!==null,onReview:Q,review:v},`${v.proposal.id}:${v.proposal.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No Harness proposals need review."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Applied history"}),e.jsx("p",{children:"Every release transition with its exact change and validation receipts."})]}),e.jsx("span",{children:o.changes.length})]}),o.changes.length?o.changes.map(v=>e.jsx(al,{change:v,onOpenDiff:v.receipt.nextRelease?()=>G(v):void 0,onOpenSourceSession:u},`${v.receipt.id}:${v.receipt.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No Harness changes have been applied."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Routed recommendations"}),e.jsx("p",{children:"Runtime, memory, product, Taskset, and training observations that did not mutate the Harness."})]}),e.jsx("span",{children:o.routes.length})]}),o.routes.length?o.routes.map(v=>e.jsx(ll,{route:v},`${v.decision.id}:${v.decision.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No external recommendations have been routed."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{children:"Bounded external memory available through search; it is not copied into every Agent prompt or sandbox."})]}),e.jsx("span",{children:o.memories.length})]}),o.memories.length?o.memories.map(v=>e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:v.key}),e.jsxs("span",{children:["revision ",v.revision]}),e.jsx("time",{children:Ie(v.updatedAt)})]}),e.jsx("p",{children:v.content}),v.tags.length?e.jsx("small",{children:v.tags.join(" · ")}):null]},`${v.id}:${v.revision}`)):e.jsx("div",{className:"harness-empty",children:"No Harness memory has been saved."})]})]}):null]})}function Ls(s){return s?s.slice(0,10):"initial"}function cl({connection:s,expanded:t,onResizeStart:a,onToggleExpanded:n,selection:l}){const[i,u]=r.useState(null),[c,o]=r.useState(null),[y,p]=r.useState(!0),x=r.useCallback(async()=>{o(null),p(!0);try{u(await $.harnessReleaseDiff(s,l))}catch(h){u(null),o(h instanceof Error?h.message:String(h))}finally{p(!1)}},[s,l]);r.useEffect(()=>{x()},[x]);const d=r.useMemo(()=>i?{appId:`harness:${l.workspaceId}`,repoPath:l.title,initialized:!0,dirty:i.filesChanged>0,filesChanged:i.filesChanged,additions:i.additions,deletions:i.deletions,repoFiles:i.files.map(h=>h.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),m=`${l.title} · ${Ls(l.baseRelease?.contentHash)} → ${Ls(l.targetRelease.contentHash)}`;return e.jsx(Zt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:d,editorPreferences:null,expanded:t,filesWithPreview:!0,loading:y,onOpenBrowserUrl:()=>{},onRefresh:x,onResizeStart:a,onToggleExpanded:n,readOnly:!0,workspaceError:c,workspaceInitialized:!0,workspaceName:m})}function dl({connection:s,onError:t,onPayload:a}){const[n,l]=r.useState(!1),[i,u]=r.useState(!1);async function c(x,d){if(s){l(!0),t(null);try{const m=await $.switchOpenPondAccount(s,{handle:x,baseUrl:d??null}),h=await $.savePreferences(s,{defaultTeamId:null});a({...m,preferences:h.preferences})}catch(m){t(m instanceof Error?m.message:String(m))}finally{l(!1)}}}async function o(x,d){if(!s)return!1;l(!0),t(null);try{return a(await $.removeOpenPondAccount(s,{handle:x,baseUrl:d??null})),!0}catch(m){return t(m instanceof Error?m.message:String(m)),!1}finally{l(!1)}}async function y(x){if(!(!s||!x.apiKey.trim())){l(!0),t(null);try{const d=x.handle?.trim(),m=x.environment?.trim(),h=await $.saveOpenPondAccount(s,{apiKey:x.apiKey.trim(),handle:d||void 0,baseUrl:x.baseUrl,apiBaseUrl:x.apiBaseUrl,environment:m||"custom",setActive:!0}),j=await $.savePreferences(s,{defaultTeamId:null});a({...h,preferences:j.preferences})}catch(d){throw t(d instanceof Error?d.message:String(d)),d}finally{l(!1)}}}async function p(){if(s){u(!0),t(null);try{a(await $.refreshOpenPondAccounts(s))}catch(x){t(x instanceof Error?x.message:String(x))}finally{u(!1)}}}return{refreshingAccounts:i,saving:n,refreshAccounts:p,removeAccount:o,saveAccount:y,switchAccount:c}}function ul({connection:s,onError:t,onPreferences:a,preferences:n,providers:l}){const[i,u]=r.useState(n.defaultBranchPrefix),[c,o]=r.useState(n.defaultNewProjectDirectory),[y,p]=r.useState(n.advancedWorkspaceControls),[x,d]=r.useState(n.contextCompaction.autoEnabled),[m,h]=r.useState(n.subagents.enabled),[j,S]=r.useState(n.subagents.delegationMode),[k,f]=r.useState(!n.subagents.defaultModelRef),[R,D]=r.useState(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),[N,I]=r.useState(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),[P,O]=r.useState(n.subagents.roles),[g,C]=r.useState(n.subagents.maxConcurrentRuns),[w,b]=r.useState(n.subagents.maxConcurrentRunsPerProvider),[E,L]=r.useState(n.subagents.maxConcurrentRunsPerWorkspaceTarget),[G,K]=r.useState(!1),Q=k?null:{providerId:R,modelId:N.trim()},v=m!==n.subagents.enabled||j!==n.subagents.delegationMode||!hl(Q,n.subagents.defaultModelRef)||g!==n.subagents.maxConcurrentRuns||w!==n.subagents.maxConcurrentRunsPerProvider||E!==n.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(P)!==JSON.stringify(n.subagents.roles);r.useEffect(()=>{u(n.defaultBranchPrefix),o(n.defaultNewProjectDirectory),p(n.advancedWorkspaceControls),d(n.contextCompaction.autoEnabled),h(n.subagents.enabled),S(n.subagents.delegationMode),f(!n.subagents.defaultModelRef),D(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),I(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),O(n.subagents.roles),C(n.subagents.maxConcurrentRuns),b(n.subagents.maxConcurrentRunsPerProvider),L(n.subagents.maxConcurrentRunsPerWorkspaceTarget)},[n.defaultChatProvider,n.defaultChatModel,n.defaultBranchPrefix,n.defaultNewProjectDirectory,n.advancedWorkspaceControls,n.contextCompaction.autoEnabled,n.subagents]);function A(T){D(T),I(B=>ns(T,B,l))}function q(){return k?n.defaultChatProvider:R}function J(){return k?n.defaultChatModel:N}function W(T,B){O(H=>H.map(z=>z.id===T?B(z):z))}function X(T,B){W(T,H=>({...H,enabled:B}))}function Y(T,B){W(T,H=>({...H,background:B}))}function U(T,B){W(T,H=>{if(B)return{...H,modelRef:null};const z=H.modelRef?.providerId??q(),_=H.modelRef?.modelId??J();return{...H,modelRef:Ge(z,_,l)??null}})}function ne(T,B){W(T,H=>({...H,modelRef:Ge(B,H.modelRef?.modelId??J(),l)??null}))}function re(T,B){W(T,H=>{const z=H.modelRef?.providerId??q(),_=B.trim();return{...H,modelRef:_?{providerId:z,modelId:_}:null}})}function ce(T,B){W(T,H=>({...H,isolationMode:B}))}function V(T,B){W(T,H=>({...H,toolPolicy:B}))}function le(T,B){W(T,H=>({...H,peerMessages:B}))}function se(T,B){W(T,H=>({...H,maxConcurrentRuns:xe(B,1,16)}))}async function fe(){let T=null;if(window.openpond?.selectFolder){const B=await window.openpond.selectFolder();if(B.canceled)return;T=B.path}else T=window.prompt("Default new project directory",c);T?.trim()&&o(T.trim())}async function oe(T){if(T.preventDefault(),!!s){K(!0),t(null);try{a(await $.savePreferences(s,{defaultBranchPrefix:Ze(i),defaultNewProjectDirectory:c.trim(),advancedWorkspaceControls:y,contextCompaction:{...n.contextCompaction,autoEnabled:x},subagents:{enabled:m,workspaceDefaultsVersion:n.subagents.workspaceDefaultsVersion,toolDefaultsVersion:n.subagents.toolDefaultsVersion,delegationMode:j,defaultModelRef:k?null:Ge(R,N,l)??null,roles:P,maxConcurrentRuns:xe(g,1,32),maxConcurrentRunsPerProvider:w===null?null:xe(w,1,32),maxConcurrentRunsPerWorkspaceTarget:E===null?null:xe(E,1,32)}}))}catch(B){t(B instanceof Error?B.message:String(B))}finally{K(!1)}}}return{advancedWorkspaceControls:y,contextCompactionAutoEnabled:x,defaultBranchPrefix:i,defaultNewProjectDirectory:c,subagentsEnabled:m,subagentDelegationMode:j,subagentsUseDefaultModel:k,subagentsProvider:R,subagentsModel:N,subagentRoles:P,subagentsMaxConcurrentRuns:g,subagentsMaxConcurrentRunsPerProvider:w,subagentsMaxConcurrentRunsPerWorkspaceTarget:E,subagentsDirty:v,saving:G,chooseDefaultProjectDirectory:fe,saveDefaults:oe,changeSubagentsProvider:A,changeSubagentRoleProvider:ne,setAdvancedWorkspaceControls:p,setContextCompactionAutoEnabled:d,setDefaultBranchPrefix:u,setDefaultNewProjectDirectory:o,setSubagentsUseDefaultModel:f,setSubagentsModel:I,setSubagentsEnabled:h,setSubagentDelegationMode:T=>S(T),setSubagentsMaxConcurrentRuns:T=>C(xe(T,1,32)),setSubagentsMaxConcurrentRunsPerProvider:T=>b(T===null?null:xe(T,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:T=>L(T===null?null:xe(T,1,32)),setSubagentRoleBackground:Y,setSubagentRoleEnabled:X,setSubagentRoleIsolationMode:ce,setSubagentRoleMaxConcurrentRuns:se,setSubagentRoleModel:re,setSubagentRolePeerMessages:le,setSubagentRoleToolPolicy:V,setSubagentRoleUseDefaultModel:U}}function xe(s,t,a){return Number.isFinite(s)?Math.min(a,Math.max(t,Math.trunc(s))):t}function hl(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const ml=15e3,pl=100,gl=100,fl=2500;function xl({onError:s,section:t}){const[a,n]=r.useState(null),[l,i]=r.useState(null),[u,c]=r.useState(pl),[o,y]=r.useState([]),[p,x]=r.useState(null),[d,m]=r.useState(!0),h=r.useRef(null),[j,S]=r.useState(null),k=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),R=!!window.openpond?.readRecentLogs?`${o.length} of ${u} line${u===1?"":"s"}${d?" tailing":""}`:"Unavailable";r.useEffect(()=>{t==="diagnostics"&&D(u,"refresh",{quiet:!0})},[t]),r.useEffect(()=>{if(t!=="diagnostics"||!d||!window.openpond?.readRecentLogs)return;let C=!1;const w=window.setInterval(()=>{C||(C=!0,D(u,"refresh",{quiet:!0}).finally(()=>{C=!1}))},fl);return()=>window.clearInterval(w)},[t,d,u]),r.useEffect(()=>{if(t!=="diagnostics"||!d)return;const C=h.current;C&&(C.scrollTop=C.scrollHeight)},[t,d,o]);async function D(C=u,w="refresh",b={}){const E=window.openpond?.readRecentLogs;if(!E){const L="Log view is not available in this runtime.";b.quiet||(S({label:"Logs",value:L,warning:!0}),s(L));return}b.quiet||i(w);try{const L=await $e(E(C),"Read logs");if(!L.ok)throw new Error(L.error);c(L.lineLimit),x(L.logDir),y(L.lines),b.quiet?S(G=>G?.label==="Logs"?null:G):S(null)}catch(L){const G=L instanceof Error?L.message:String(L);S({label:"Logs",value:G,warning:!0}),b.quiet||s(G)}finally{b.quiet||i(null)}}function N(){m(!1),D(u+gl,"older")}function I(){const C=!d;m(C),C&&D(u,"refresh",{quiet:!0})}async function P(){const C=window.openpond?.openLogsFolder;if(!C){const w="Desktop logs are not available in this runtime.";S({label:"Logs",value:w,warning:!0}),s(w);return}n("logs"),s(null);try{const w=await $e(C(),"Open logs");if(!w.ok)throw new Error(w.error??"Could not open the logs folder.");S(null)}catch(w){const b=w instanceof Error?w.message:String(w);S({label:"Logs",value:b,warning:!0}),s(b)}finally{n(null)}}async function O(){const C=window.openpond?.copyRecentLogs;if(!C){const w="Recent log copy is not available in this runtime.";S({label:"Copy",value:w,warning:!0}),s(w);return}n("copy"),s(null);try{const w=await $e(C(1e3),"Copy recent logs");if(!w.ok)throw new Error(w.error??"Could not copy recent logs.");S({label:"Copy",value:w.lines?`Copied ${w.lines} recent log lines.`:"Copied recent logs."})}catch(w){const b=w instanceof Error?w.message:String(w);S({label:"Copy",value:b,warning:!0}),s(b)}finally{n(null)}}async function g(){const C=window.openpond?.exportDiagnostics;if(!C){const w="Diagnostics export is not available in this runtime.";S({label:"Export",value:w,warning:!0}),s(w);return}n("export"),s(null);try{const w=await $e(C(),"Export diagnostics");if(!w.ok)throw new Error(w.error??"Could not export diagnostics.");S({label:"Export",value:w.path?`Saved to ${w.path}`:"Diagnostics exported."})}catch(w){const b=w instanceof Error?w.message:String(w);S({label:"Export",value:b,warning:!0}),s(b)}finally{n(null)}}return{diagnosticsAvailable:k,diagnosticsBusy:a,diagnosticsStatus:j,logDir:p,logLineLimit:u,logLines:o,logViewBusy:l,logViewSummary:R,logViewportRef:h,tailLogs:d,copyRecentLogs:O,exportDiagnosticsBundle:g,loadOlderLogs:N,openLogsFolder:P,refreshLogView:D,toggleTailLogs:I}}async function $e(s,t){let a;try{return await Promise.race([s,new Promise((n,l)=>{a=window.setTimeout(()=>{l(new Error(`${t} did not receive a desktop response.`))},ml)})])}finally{a!==void 0&&window.clearTimeout(a)}}function jl({connection:s,enabled:t,onError:a,onPreferences:n,onToast:l,preferences:i}){const[u,c]=r.useState(i.editor),[o,y]=r.useState(null),[p,x]=r.useState(!1),[d,m]=r.useState(!1),[h,j]=r.useState(!1);r.useEffect(()=>{c(i.editor)},[i.editor]);const S=r.useCallback(async()=>{if(s){m(!0);try{y(await $.workspaceLspSettingsStatus(s))}catch(N){a(N instanceof Error?N.message:String(N))}finally{m(!1)}}},[s,a]);r.useEffect(()=>{!t||!s||S()},[s,t,S]);function k(N,I){c(P=>({...P,languages:{...P.languages,[N]:{...P.languages[N],mode:I}}}))}function f(N,I){c(P=>({...P,languages:{...P.languages,[N]:{...P.languages[N],customCommand:I}}}))}async function R(N){if(N.preventDefault(),!!s){x(!0),a(null);try{const I=await $.savePreferences(s,{editor:u});n(I),y(await $.workspaceLspSettingsStatus(s))}catch(I){a(I instanceof Error?I.message:String(I))}finally{x(!1)}}}async function D(){if(s){j(!0),a(null);try{await $.restartWorkspaceLsp(s),y(await $.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(N){a(N instanceof Error?N.message:String(N))}finally{j(!1)}}}return{editorPreferences:u,lspStatus:o,restarting:h,saving:p,statusLoading:d,refreshLspStatus:S,restartLanguageServers:D,saveEditorSettings:R,setEditorPreferences:c,setLanguageCustomCommand:f,setLanguageMode:k}}function vl({connection:s,onError:t,onPayload:a,personalization:n}){const l=r.useMemo(()=>n.templates.map(g=>({value:g.id,label:g.name,description:g.id===n.activeTemplateId?"Selected":g.source==="built_in"?g.description:void 0})),[n.activeTemplateId,n.templates]),[i,u]=r.useState(n.activeTemplateId),[c,o]=r.useState(n.soul),[y,p]=r.useState(""),[x,d]=r.useState(!1),[m,h]=r.useState(!1),j=n.templates.find(g=>g.id===i)??n.templates[0],S=j?.source==="custom",k=j?c!==j.content:!0,f=i!==n.activeTemplateId||c!==n.soul||k,R=!!(S&&c.trim()&&j&&f);r.useEffect(()=>{u(n.activeTemplateId),o(n.soul);const g=n.templates.find(C=>C.id===n.activeTemplateId);p(g?`${g.name} Copy`:""),d(!1)},[n.activeTemplateId,n.soul,n.templates]);async function D(g=!1){if(!g&&!S)return;const C=g?y:j?.name;if(!(!s||!c.trim()||!C?.trim())){h(!0),t(null);try{a(await $.savePersonalization(s,{activeTemplateId:i,templateName:C,soul:c,saveAsNew:g})),d(!1)}catch(w){t(w instanceof Error?w.message:String(w))}finally{h(!1)}}}async function N(g){const C=n.templates.find(w=>w.id===g);if(C&&(u(C.id),p(`${C.name} Copy`),o(C.content),d(!1),!!s)){h(!0),t(null);try{a(await $.savePersonalization(s,{activeTemplateId:C.id,templateName:C.name,soul:C.content,saveAsNew:!1}))}catch(w){t(w instanceof Error?w.message:String(w))}finally{h(!1)}}}function I(){j&&(p(`${j.name} Copy`),o(j.content),d(!1))}function P(g){o(g),j&&!S&&g!==j.content&&d(!0)}function O(){j&&(p(`${j.name} Copy`),d(!0))}return{canSaveCurrentTemplate:R,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:x,saving:m,selectedPersonalizationTemplate:j,selectedTemplateIsCustom:S,soulDraft:c,templateNameDraft:y,changePersonalizationTemplate:N,changeSoulDraft:P,openSaveAsNew:O,resetPersonalizationDraft:I,savePersonalization:D,setSaveAsNewOpen:d,setTemplateNameDraft:p}}function bl({connection:s,onError:t,onPreferences:a,onProviders:n,preferences:l,providers:i}){const[u,c]=r.useState(l.defaultChatProvider),[o,y]=r.useState(l.defaultChatModel),[p,x]=r.useState(!1),[d,m]=r.useState(null),[h,j]=r.useState(null);r.useEffect(()=>{c(l.defaultChatProvider),y(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function S(w){if(w.preventDefault(),!!s){x(!0),t(null);try{a(await $.savePreferences(s,{defaultChatProvider:u,defaultChatModel:ns(u,o,i)}))}catch(b){t(b instanceof Error?b.message:String(b))}finally{x(!1)}}}function k(w){c(w),y(b=>ns(w,b,i))}async function f(w,b,E){if(!s)return null;m(`${w}:${b}`),j(null),t(null);try{return await E()}catch(L){return t(L instanceof Error?L.message:String(L)),null}finally{m(null)}}async function R(w,b){await f(w,"config",async()=>{const E=await $.saveProviderSettings(s,{providers:{[w]:b}});return n(E),E})}async function D(w,b){await f(w,"credential",async()=>{const E=await $.saveProviderCredential(s,w,b);return n(E),E})}async function N(w){await f(w,"credential",async()=>{const b=await $.deleteProviderCredential(s,w,{});return n(b),b})}async function I(w){return f("openai","credential",async()=>{const b=await $.startOpenAiSubscriptionAuth(s,{method:w});return b.method==="browser"?(window.open(b.url,"_blank","noopener,noreferrer"),j("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(b.url,"_blank","noopener,noreferrer"),j(`OpenAI device login started. Enter code ${b.userCode}.`)),P(b.expiresAt),b})}async function P(w){if(s)for(;Date.now()<w;){await new Promise(b=>setTimeout(b,2500));try{const b=await $.providerSettings(s);n(b);const E=b.statuses.openai?.credential;if(E?.connected&&E.source==="chatgpt_subscription"){j("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function O(w){await f(w,"models",async()=>{const b=await $.refreshProviderModels(s,w,{force:!0});return n(b.providers),b})}async function g(w){await f(w,"models",async()=>{const b=await $.loadProviderModels(s,w,{limit:500});return n(b.providers),b})}async function C(w,b={}){await f(w,"validate",async()=>{const E=await $.validateProviderCredential(s,w,b);return j(E.ok?`${w} validated${E.modelId?` with ${E.modelId}`:""}.`:E.errors.join(`
|
|
6
|
-
`)||`${w} validation failed.`),n(E.providers),E})}return{defaultModel:o,defaultProvider:u,providerBusy:d,saving:p,validationMessage:
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-NbX7_3Uz.js","./index-Ure41UF0.js","./index-UUM3pwfd.css","./arrow-up-right-Cx2xjktp.js","./index-De6p2npi.js","./UsageSettingsSection-O8VK0qBL.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ge,j as e,r,au as rs,X as ie,av as ct,aw as dt,ax as ut,ay as ht,az as mt,aA as pt,P as me,aB as gt,aC as ft,n as $,aD as xt,aE as Ze,aF as jt,aG as vt,aH as bt,K as Ts,s as ze,aI as yt,t as Nt,L as Ee,aJ as wt,b as Os,aK as Xe,aL as Fe,ae as St,C as Ct,aM as kt,G as es,a0 as Pt,F as Le,aN as ae,aO as Rt,aP as ss,aQ as ts,a3 as Us,A as At,a1 as Dt,a2 as It,B as $t,a as zs,aR as Mt,aS as Et,p as Lt,I as ns,a8 as Ge,aT as je,ai as Tt,aU as Ot,aV as Ut,aW as zt,Z as Bt,aX as _t,_ as Ht}from"./index-Ure41UF0.js";import{R as te}from"./refresh-cw-CeHT_tXT.js";import{D as Pe,T as be,P as Bs,B as Be,W as qe,C as Ft}from"./MarkdownText-DTBS9xe7.js";/* empty css */import{S as os}from"./save-CmJ92Odx.js";import{F as _s}from"./folder-open-D7a4t258.js";import{C as Gt}from"./chevron-up-UF_r7JHT.js";import{C as Hs}from"./circle-alert-BUHAQ7Du.js";import{P as Fs}from"./play-CjWTsI9z.js";import{B as Gs,W as qt,S as Wt}from"./wifi-off-BQGq-son.js";import{R as Te,u as Vt}from"./useLocalAgentSchedules-BUkZjV9E.js";import{C as pe}from"./cloud-upload-Cc_ZQEAm.js";import{F as De,M as Kt}from"./monitor-POfnZCWw.js";import{G as Oe}from"./git-commit-horizontal-oiDAVV_Y.js";import{S as Jt}from"./square-pen-LHr8bFfZ.js";import{r as Yt}from"./index-De6p2npi.js";import{F as Qt}from"./folder-plus-CmeHTj5W.js";import{WorkspaceDiffPanel as Zt}from"./WorkspaceDiffPanel-jaJU08NH.js";import"./training-model-data-B7-1Bxil.js";import"./info-dTkimobU.js";const Xt=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],en=ge("clipboard-copy",Xt);const sn=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],tn=ge("hard-drive",sn);const nn=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ue=ge("key-round",nn);const an=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],ln=ge("power",an);const rn=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],qs=ge("radio-tower",rn);const on=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],cn=ge("rotate-cw",on);const dn=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Ws=ge("sliders-horizontal",dn);const un=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],hn=ge("circle-user",un);function hs({handle:s,image:t}){const a=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:t?e.jsx("img",{src:t,alt:""}):e.jsx("span",{children:a})})}function We({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}const as="https://openpond.ai",ls="https://api.openpond.ai";function mn(s,t){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:t?.handle,currentBaseUrl:t?.baseUrl??null}}function ms(s,t){const a=t.trim().replace(/\/+$/,"");if(!a)throw new Error(`${s} is required.`);try{const n=new URL(a);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return a}function ps({account:s,busy:t,initialApiKey:a="",mode:n="update",onClose:l,onSave:i}){const u=r.useId(),c=n==="connect",[o,N]=r.useState(a),[p,f]=r.useState(!1),[d,h]=r.useState(s?.baseUrl??as),[m,j]=r.useState(s?.apiBaseUrl??ls),[k,S]=r.useState(null),[x,R]=r.useState(null);rs(x),r.useEffect(()=>{N(a),f(!1),h(s?.baseUrl??as),j(s?.apiBaseUrl??ls),S(null),R(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,a]);async function I(b){b.preventDefault(),S(null),R(null);const D=o.trim();if(c&&!D){S("API key is required.");return}let P,O;try{P=ms("Base URL",d),O=ms("API base URL",m)}catch(g){S(g instanceof Error?g.message:String(g));return}try{const g=mn(n,s);await i({...g,baseUrl:P,apiBaseUrl:O,apiKey:c?D:void 0,environment:c?pn(P,O):s?.environment??null})}catch(g){R(g instanceof Error?g.message:String(g))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&!t&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":u,onSubmit:b=>{I(b)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(ie,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:c?e.jsx(ue,{size:18}):e.jsx(Ws,{size:18})}),e.jsx("h2",{id:u,children:c?"Add account":"Account endpoints"}),c?e.jsx("p",{children:"Enter your OpenPond API key to connect another account."}):null,c?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:t,placeholder:"opk_...",type:"password",value:o,onChange:b=>N(b.target.value)})]}):null,c?e.jsxs("label",{className:"git-dialog-toggle account-dialog-advanced-toggle",children:[e.jsx("input",{checked:p,disabled:t,type:"checkbox",onChange:b=>f(b.target.checked)}),e.jsx("span",{}),"Advanced"]}):null,!c||p?e.jsxs("div",{className:"account-dialog-advanced-fields",children:[e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{autoFocus:!c,disabled:t,inputMode:"url",value:d,onChange:b=>h(b.target.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API base URL"}),e.jsx("input",{disabled:t,inputMode:"url",value:m,onChange:b=>j(b.target.value)})]})]}):null,k?e.jsx("div",{className:"profile-dialog-warning",children:k}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:t,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(os,{size:14}),e.jsx("span",{children:t?"Saving":c?"Connect account":"Update account"})]})]})]})})}function pn(s,t){return s===as&&t===ls?"production":"custom"}const gn="Changing the active OpenPond account rechecks cloud projects, hosted agents, default team, and profile sync for that account. Local projects stay on this machine; projects uploaded from another account will need to be synced again for this account.";function fn({payload:s,connection:t,saving:a,refreshingAccounts:n,saveAccount:l,refreshAccounts:i,switchAccount:u,removeAccount:c,onPayload:o,onPreferences:N,onError:p,onToast:f}){const d=s?.account,h=d?.state??"loading",m=h==="signed_in",j=h==="signed_out",k=h==="auth_error",S=d?.email?.trim()||null,x=d?.accounts??[],[R,I]=r.useState([]),[,b]=r.useState(!1),[D,P]=r.useState(null),[O,g]=r.useState(null),[C,w]=r.useState(null),[y,E]=r.useState(null),[L,G]=r.useState(!1),[K,Q]=r.useState(null),{confirmAction:v,confirmDialog:A,resolveConfirmDialog:q}=ct(),J=x.find(M=>M.isActive)??x[0]??null,W=s?.preferences.defaultTeamId?.trim()||null,X=C??W,Y=dt(d),U=s?.accountMeta.asOf??"",ne=we(d?.environment,J?.environment),re=m?we(J?.displayLabel,J?.handle,d?.label,d?.activeProfile?.handle,"Signed in"):k?"Account needs attention":j?"No account connected":"Loading account",ce=m?S??gs(ne):k?"Not connected":j?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",V=x.length>0,le=k?xn(d?.error):null,se=r.useMemo(()=>R.filter(M=>M.status==="active"),[R]),T=(r.useMemo(()=>X?se.find(M=>M.teamId===X)??null:null,[se,X])??ut(se))?.teamId??"",B=r.useMemo(()=>se.map(M=>({value:M.teamId,label:we(M.displayName,M.name,M.slug,"Team"),description:ht(M.role)})),[se]),H=T||B[0]?.value||"",z=B.length>0,_=!t||!!O||!!D||se.length===0,Ne=y?Ve(y):null,us=!!(Ne&&K===Ne),tt=m||k;r.useEffect(()=>{if(!t||!Y){I([]),P(null),b(!1);return}let M=!1;const Z=mt(Y);return Z?(I(Z),b(!1)):(I([]),b(!0)),P(null),pt({accountKey:Y,force:!!U,fetchOrganizations:async()=>(await $.organizations(t)).organizations.map(xt).filter(ee=>!!ee).filter(ee=>ee.status==="active")}).then(F=>{M||I(F)}).catch(F=>{M||(Z||I([]),P(F instanceof Error?F.message:String(F)))}).finally(()=>{M||b(!1)}),()=>{M=!0}},[U,t,Y]),r.useEffect(()=>{C&&W===C&&w(null)},[W,C]);async function nt(M,Z={notify:!0}){const F=se.find(ee=>ee.teamId===M)??null;if(!(!t||!F||O||(C??W)===F.teamId)){w(F.teamId),g(F.teamId),p(null),ft({teamId:F.teamId,accountKey:Y,force:!0,fetchAgents:async ee=>(await $.listSandboxAgents(t,{teamId:ee})).agents}).catch(()=>{});try{N(await $.savePreferences(t,{defaultTeamId:F.teamId})),Z.notify&&f?.("Default team updated","success")}catch(ee){w(null),p(ee instanceof Error?ee.message:String(ee))}finally{g(null)}}}async function _e(M="Continue"){return tt?v({title:"Change active OpenPond account?",body:gn,confirmLabel:M,cancelLabel:"Cancel"}):!0}async function at(M){await _e("Save account")&&(await l({apiKey:M.apiKey??"",handle:M.handle,baseUrl:M.baseUrl,apiBaseUrl:M.apiBaseUrl,environment:M.environment}),G(!1))}async function lt(M){if(!t||!y)throw new Error("OpenPond server connection is not ready.");if(y.isActive&&!await _e("Save endpoints"))return;const Z=Ve(y);Q(Z),p(null);try{const F=await $.updateOpenPondAccountConfig(t,{handle:M.handle??y.handle,currentBaseUrl:M.currentBaseUrl,baseUrl:M.baseUrl,apiBaseUrl:M.apiBaseUrl,chatApiBaseUrl:null,environment:jn(M.environment),setActive:y.isActive});o(F),f?.("Account endpoints updated","success"),E(null)}catch(F){throw p(F instanceof Error?F.message:String(F)),F}finally{Q(null)}}async function it(M){const Z=M.handle?.trim()||"";Z&&await _e("Switch account")&&await u(Z,M.baseUrl)}async function rt(M){const Z=M.handle?.trim()||"";if(!Z||M.isActive)return;const F=we(M.displayLabel,M.email,M.handle,"this account");await v({title:"Remove saved account?",body:`Remove ${F} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await c(Z,M.baseUrl)&&f?.("Account removed","success")}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsxs("div",{className:"account-settings-title-actions",children:[e.jsxs("button",{className:"settings-secondary compact account-add-action",disabled:!t||a,type:"button",onClick:()=>G(!0),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!t||a||n,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{i()},children:e.jsx(te,{size:15,className:n?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(hs,{handle:re,image:m?d?.avatarUrl??J?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:re}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:m&&S?"private-account-email":m?void 0:"account-summary-copy",tabIndex:m&&S?0:void 0,children:ce}),m&&z?e.jsx(Pe,{className:"account-team-dropdown",compact:!0,disabled:_,label:"Default team",options:B,value:H,onChange:M=>{nt(M)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(We,{state:h,label:j?"not signed in":void 0})})]}),V?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"OpenPond accounts"}),e.jsxs("small",{children:[x.length," account",x.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),x.map(M=>{const Z=M.handle?.trim()||"",F=we(M.displayLabel,M.handle,"Unknown account"),ee=M.email?.trim()||null,He=vn(M.environment),ot=Ve(M);return e.jsxs("div",{className:"account-row",children:[e.jsx(hs,{handle:F,image:M.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:F}),ee?e.jsx("span",{className:"private-account-email",tabIndex:0,children:ee}):null,e.jsx("span",{children:gs(M.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(We,{state:M.authHealth}),M.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:`account-env-toggle ${He?"active":""}`,disabled:!t||a||!!K||!Z,type:"button","aria-label":`Configure ${F} environment endpoints`,"aria-pressed":He,title:"Configure environment endpoints",onClick:()=>E(M),children:e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"})}),M.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!Z,type:"button",onClick:()=>{it(M)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!Z,type:"button","aria-label":`Remove ${F}`,title:`Remove ${F}`,onClick:()=>{rt(M)},children:e.jsx(be,{size:13})})]})]})]},ot)})]}):null,d?.products&&d.products.length>0&&e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Products"}),e.jsxs("small",{children:[d.products.length," active"]})]}),d.products.map(M=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:M.name}),e.jsx("span",{children:M.type})]}),e.jsx(We,{state:M.status})]},M.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:t?.serverUrl??"loading"})]}),le?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:le})]}):null,y?e.jsx(ps,{account:y,busy:us,onClose:()=>{us||E(null)},onSave:lt}):null,L?e.jsx(ps,{busy:a,mode:"connect",onClose:()=>{a||G(!1)},onSave:at}):null,e.jsx(gt,{state:A,onResolve:q})]})}function Ve(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function we(...s){for(const t of s){const a=t?.trim();if(a)return a}return""}function xn(s){const t=s?.trim();if(!t)return null;const a=t.toLowerCase();return a.includes("protected deployment")||a.includes("vercel_auth_enabled")?"Staging is protected by Vercel. Restart OpenPond after signing in to Vercel, then try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")||a.includes("vercel.com/sso-api")?"OpenPond received a web login page instead of account data. Restart after signing in to Vercel, then try again.":a.includes("401")||a.includes("unauthorized")||a.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":t.length>220?`${t.slice(0,217)}...`:t}function gs(s){const t=s.trim().toLowerCase();return!t||t==="production"?"Production":"Environment"}function jn(s){const t=s?.trim();return!t||t.toLowerCase()==="production"?"custom":t}function vn(s){const t=s?.trim().toLowerCase();return!!(t&&t!=="production")}function bn({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:a,preferences:n,saving:l,chooseDefaultProjectDirectory:i,saveDefaults:u,setAdvancedWorkspaceControls:c,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:N}){const p=Ze(t)===n.defaultBranchPrefix&&a.trim()===n.defaultNewProjectDirectory&&s===n.advancedWorkspaceControls;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Defaults"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:f=>{u(f)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:f=>c(f.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Show advanced Git controls"}),e.jsx("small",{children:"Show branch, commit, and push controls for local project workflows."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Git branches"}),e.jsx("small",{children:"Used for advanced and non-managed branch creation"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Branch prefix"}),e.jsx("input",{value:t,disabled:l,placeholder:"feat/",onChange:f=>o(f.target.value)})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Projects"}),e.jsx("small",{children:"Used when starting a new local project from scratch"})]}),e.jsxs("div",{className:"settings-path-row",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"New project directory"}),e.jsx("input",{value:a,disabled:l,placeholder:"~/Documents/OpenPond Projects",onChange:f=>N(f.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{i()},children:[e.jsx(_s,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||p,children:e.jsx("span",{children:l?"Saving":"Save defaults"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Ze(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||n.defaultNewProjectDirectory})]})]})}function yn({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:a,diagnosticsStatus:n,logDir:l,logLineLimit:i,logLines:u,logViewBusy:c,logViewSummary:o,logViewportRef:N,tailLogs:p,copyRecentLogs:f,exportDiagnosticsBundle:d,loadOlderLogs:h,openLogsFolder:m,refreshLogView:j,toggleTailLogs:k}){const S=s.filter(R=>R.name==="diagnostic"&&R.status==="failed").slice().reverse().map(Nn),x=typeof window>"u"?void 0:window.openpond;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Diagnostics"}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Recent errors"}),e.jsxs("small",{children:[S.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:S.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):S.map(R=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Hs,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:R.message}),e.jsx("time",{dateTime:R.timestamp,children:R.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:R.surface}),R.status?e.jsx("span",{children:R.status}):null,R.sequence?e.jsxs("span",{children:["#",R.sequence]}):null]}),R.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:R.detail})]}):null]})]},R.id))})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Logs"}),e.jsx("small",{children:t?"Desktop":"Unavailable"})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Logs folder"}),e.jsx("span",{children:"Desktop and server logs"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!x?.openLogsFolder,onClick:()=>{m()},children:[e.jsx(_s,{size:15}),e.jsx("span",{children:a==="logs"?"Opening":"Open"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Diagnostics export"}),e.jsx("span",{children:"Support folder with diagnostics.txt"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!x?.exportDiagnostics,onClick:()=>{d()},children:[e.jsx(jt,{size:15}),e.jsx("span",{children:a==="export"?"Exporting":"Export"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Recent logs"}),e.jsx("span",{children:"Last 1000 lines to clipboard"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!x?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(en,{size:15}),e.jsx("span",{children:a==="copy"?"Copying":"Copy"})]})]})]}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Log view"}),e.jsxs("div",{className:"settings-heading-actions diagnostics-log-actions",children:[e.jsx("small",{children:o}),e.jsx("button",{type:"button",className:`settings-icon-button ${p?"active":""}`,title:p?"Pause tail":"Tail logs","aria-label":p?"Pause tail":"Tail logs",disabled:!x?.readRecentLogs,onClick:k,children:p?e.jsx(Bs,{size:15}):e.jsx(Fs,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:c!==null||!x?.readRecentLogs,onClick:()=>{j(i,"refresh")},children:e.jsx(te,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:c!==null||!x?.readRecentLogs,onClick:h,children:[e.jsx(Gt,{size:15}),e.jsx("span",{children:c==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:N,className:"diagnostics-log-viewer",role:"log","aria-live":p?"polite":"off",children:u.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:c?"Loading logs":"No log lines"}):u.map((R,I)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:R.file}),e.jsx("code",{children:R.line})]},`${R.file}:${R.timestamp}:${R.index}:${I}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),n&&e.jsxs("div",{className:`settings-footnote ${n.warning?"warning":""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]})]})}function Nn(s){const t=fs(s.data),a=fs(t.context),l=he(t.stack)??he(t.detail)??he(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:Sn(s.timestamp),message:wn(s,t),surface:he(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function wn(s,t){return he(s.error)??he(s.output)??he(t.message)??he(t.error)??"Diagnostic event"}function Sn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function fs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function he(s){return typeof s=="string"&&s.trim()?s.trim():null}const xs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Cn({editorPreferences:s,lspStatus:t,preferences:a,restarting:n,saving:l,statusLoading:i,refreshLspStatus:u,restartLanguageServers:c,saveEditorSettings:o,setEditorPreferences:N,setLanguageCustomCommand:p,setLanguageMode:f}){const d=JSON.stringify(s)!==JSON.stringify(a.editor),h=new Map(t?.languages.map(m=>[m.language,m])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:m=>{o(m)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Language servers"}),e.jsx("small",{children:"Local tools"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Language servers"}),e.jsx(Pe,{value:s.languageServers,disabled:l,label:"Language servers",options:vt,onChange:m=>N(j=>({...j,languageServers:m}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:m=>N(j=>({...j,diagnosticsWhileEditing:m.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Diagnostics while editing"}),e.jsx("small",{children:"Update Monaco markers as the local buffer changes."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.checkOnSave,disabled:l||s.languageServers==="off",onChange:m=>N(j=>({...j,checkOnSave:m.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Check on save"}),e.jsx("small",{children:"Refresh diagnostics after writing a file."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Languages"}),e.jsx("small",{children:"Auto, disabled, or custom executable"})]}),e.jsx("div",{className:"lsp-language-list",children:xs.map(m=>{const j=s.languages[m.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:m.label}),e.jsx("span",{children:js(h.get(m.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Pe,{value:j.mode,disabled:l||s.languageServers==="off",label:`${m.label} language server mode`,options:bt,onChange:k=>f(m.id,k)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:j.customCommand,disabled:l||s.languageServers==="off"||j.mode!=="custom",placeholder:m.placeholder,onChange:k=>p(m.id,k.target.value)})]})]},m.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!d,children:e.jsx("span",{children:l?"Saving":"Save editor settings"})})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"LSP status"}),e.jsxs("div",{className:"settings-heading-actions",children:[e.jsx("small",{children:i?"Checking":t?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:i||n,onClick:()=>{u()},children:e.jsx(te,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||n,onClick:()=>{c()},children:[e.jsx(cn,{className:n?"settings-spin":void 0,size:15}),e.jsx("span",{children:n?"Restarting":"Restart"})]})]})]}),xs.map(m=>{const j=h.get(m.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:m.label}),e.jsx("span",{title:j?.command??j?.message??void 0,children:j?.command??j?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${j?.status??"missing"}`,children:js(j,i)})]},m.id)})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Project config"}),e.jsx("strong",{children:"Uses tsconfig, pyrightconfig, pyproject, and Cargo files when present"})]})]})}function js(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function kn({contextCompactionAutoEnabled:s,preferences:t,saving:a,saveDefaults:n,setContextCompactionAutoEnabled:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:i=>{n(i)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Compaction"}),e.jsx("small",{children:"Controls automatic compaction for long OpenPond and BYOK chats"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:i=>l(i.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Auto compact long chats"}),e.jsx("small",{children:"Summarize older turns at 85% context before the selected model runs out. The transcript stays visible."})]})]}),e.jsx("button",{className:"settings-primary",disabled:a||s===t.contextCompaction.autoEnabled,children:e.jsx("span",{children:a?"Saving":"Save context"})})]})]})}function Pn({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:a,subagentsProvider:n,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:u,subagentsMaxConcurrentRunsPerProvider:c,subagentsMaxConcurrentRunsPerWorkspaceTarget:o,preferences:N,providers:p,saving:f,saveDefaults:d,changeSubagentsProvider:h,setSubagentsEnabled:m,setSubagentDelegationMode:j,setSubagentsUseDefaultModel:k,setSubagentsModel:S,setSubagentsMaxConcurrentRuns:x,setSubagentsMaxConcurrentRunsPerProvider:R,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:I,setSubagentRoleEnabled:b,setSubagentRoleIsolationMode:D,setSubagentRoleMaxConcurrentRuns:P,setSubagentRoleModel:O,setSubagentRolePeerMessages:g,setSubagentRoleToolPolicy:C,changeSubagentRoleProvider:w}){const y=Ts(p,{enabledOnly:!0}),E=a?N.defaultChatProvider:n,L=a?N.defaultChatModel:l,G=Vs(ze(E,p),L),K=a?null:{providerId:n,modelId:l.trim()},Q=$n({enabled:s,delegationMode:t,defaultModelRef:K,roles:i,maxConcurrentRuns:u,maxConcurrentRunsPerProvider:c,maxConcurrentRunsPerWorkspaceTarget:o},N);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:v=>{d(v)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Subagents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${Q?"":" dirty"}`,disabled:f||Q,children:e.jsx("span",{children:f?"Saving":"Save agents"})}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":"Allow subagents",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:f,onChange:v=>m(v.target.checked)}),e.jsx("span",{})]})]})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Default delegation"}),e.jsx("small",{children:"Used unless a task overrides it from the composer."})]})}),e.jsx("div",{className:"subagent-field-grid two",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Subagent use"}),e.jsxs("select",{value:t,disabled:f||!s,onChange:v=>j(v.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"balanced",children:"Balanced"}),e.jsx("option",{value:"proactive",children:"Proactive"})]})]})})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsx("div",{children:e.jsx("span",{children:"Default model"})})}),e.jsxs("div",{className:"subagent-field-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Provider"}),e.jsx("select",{value:E,disabled:f||!s,onChange:v=>{k(!1),h(v.target.value)},children:y.map(v=>e.jsx("option",{value:v.value,children:v.label},v.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:L,disabled:f||!s,onChange:v=>{k(!1),S(v.target.value)},children:G.map(v=>e.jsx("option",{value:v.value,children:v.label},v.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(v=>{const A=yt.find(U=>U.id===v.id),q=v.modelRef?.providerId??E,J=v.modelRef?.modelId||Nt(q,p)||L,W=In(y,p,{providerId:q,modelId:J}),X=Me(q,J),Y=f||!s||!v.enabled;return e.jsxs("section",{className:`subagent-role-row${v.enabled?"":" disabled"}`,children:[e.jsxs("div",{className:"subagent-settings-card-header subagent-role-header",children:[e.jsxs("div",{className:"subagent-role-title",children:[e.jsx("span",{children:A?.label??v.id}),e.jsx("small",{children:A?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${A?.label??v.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:v.enabled,disabled:f||!s,onChange:U=>b(v.id,U.target.checked)}),e.jsx("span",{})]})]}),e.jsxs("div",{className:"subagent-role-controls",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:X,disabled:Y,onChange:U=>{const ne=W.find(re=>re.value===U.target.value);ne&&(w(v.id,ne.providerId),O(v.id,ne.modelId))},children:W.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:v.isolationMode,disabled:Y,onChange:U=>D(v.id,U.target.value),children:Rn.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:v.toolPolicy,disabled:Y,onChange:U=>C(v.id,U.target.value),children:An.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:v.peerMessages,disabled:Y,onChange:U=>g(v.id,U.target.value),children:Dn.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]})]}),e.jsx("div",{className:"subagent-role-budget-grid",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Role concurrency"}),e.jsx("input",{type:"number",min:1,max:16,value:v.maxConcurrentRuns,disabled:Y,onChange:U=>P(v.id,vs(U.target.value,1))})]})})]},v.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:u,disabled:f||!s,onChange:v=>x(vs(v.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:c??"",placeholder:"No cap",disabled:f||!s,onChange:v=>R(is(v.target.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per workspace"}),e.jsx("input",{type:"number",min:1,max:32,value:o??"",placeholder:"No cap",disabled:f||!s,onChange:v=>I(is(v.target.value))})]})]})]})]})})}const Rn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],An=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Dn=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function Vs(s,t){const a=t.trim();return!a||s.some(n=>n.value===a)?s:[{value:a,label:a},...s]}function Me(s,t){return JSON.stringify([s,t])}function In(s,t,a){const n=[];for(const l of s){const i=Vs(ze(l.value,t),l.value===a.providerId?a.modelId:"");for(const u of i)n.push({value:Me(l.value,u.value),label:`${l.label} / ${u.label}`,providerId:l.value,modelId:u.value})}return a.modelId&&!n.some(l=>l.value===Me(a.providerId,a.modelId))&&n.unshift({value:Me(a.providerId,a.modelId),label:`${Ee(a.providerId,t)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),n}function is(s){const t=s.trim();if(!t)return null;const a=Number(t);return Number.isFinite(a)?a:null}function vs(s,t){return is(s)??t}function $n(s,t){const a=t.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Mn(s.defaultModelRef,a.defaultModelRef)&&s.maxConcurrentRuns===a.maxConcurrentRuns&&s.maxConcurrentRunsPerProvider===a.maxConcurrentRunsPerProvider&&s.maxConcurrentRunsPerWorkspaceTarget===a.maxConcurrentRunsPerWorkspaceTarget&&JSON.stringify(s.roles)===JSON.stringify(a.roles)}function Mn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const En=[{mode:"all",label:"All new messages",detail:"Show an in-app alert for every Team Chat message."},{mode:"direct_mentions",label:"Direct messages and mentions",detail:"Show alerts for direct messages and messages that mention you."},{mode:"none",label:"Nothing",detail:"Keep unread counts without showing message alerts."}];function Ln({currentUserId:s,enabled:t,mode:a,threads:n,onModeChange:l,onThreadMuteChange:i}){const[u,c]=r.useState(null),[o,N]=r.useState(null);rs(o);const p=r.useMemo(()=>n.filter(h=>h.archivedAt===null).map(h=>({thread:h,label:Tn(h,s)})).sort((h,m)=>{const j=+!!m.thread.mutedAt-+!!h.thread.mutedAt;return j!==0?j:h.label.localeCompare(m.label)}),[s,n]),f=p.filter(({thread:h})=>!!h.mutedAt).length,d=r.useCallback(async h=>{c(h.id),N(null),await i(h.id,!h.mutedAt)||N("Could not update this conversation. Try again."),c(null)},[i]);return e.jsxs("section",{className:"account-settings notifications-settings",children:[e.jsx("h1",{children:"Notifications"}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Team chat notifications"}),e.jsx("small",{children:"In-app alerts"})]}),e.jsx("div",{className:"notification-mode-list",role:"radiogroup","aria-label":"Notify me about",children:En.map(h=>e.jsxs("label",{className:`notification-mode-option${a===h.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===h.mode,onChange:()=>l(h.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:h.label}),e.jsx("small",{children:h.detail})]})]},h.mode))})]}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Conversation overrides"}),e.jsx("small",{children:f===1?"1 muted":`${f} muted`})]}),t?p.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):p.map(({thread:h,label:m})=>{const j=!!h.mutedAt,k=u===h.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${j?" muted":""}`,children:j?e.jsx(wt,{size:15}):e.jsx(Gs,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:m}),e.jsx("small",{children:j?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:u!==null,onClick:()=>{d(h)},children:k?"Saving":j?"Unmute":"Mute"})]},h.id)}):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Connect a team to manage conversation overrides."})})]}),e.jsx("div",{className:"settings-footnote",children:e.jsx("span",{children:"Muted conversations never show alerts. Unread counts remain available."})})]})}function Tn(s,t){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(a=>a.userId!==t)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(a=>a.userId!==t).map(a=>a.name).join(", ")||"Group conversation"}function On({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:a,saveAsNewOpen:n,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:u,soulDraft:c,templateNameDraft:o,changePersonalizationTemplate:N,changeSoulDraft:p,openSaveAsNew:f,resetPersonalizationDraft:d,savePersonalization:h,setSaveAsNewOpen:m,setTemplateNameDraft:j}){function k(S){S.preventDefault(),h(n)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:k,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:n?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:o,onChange:S=>j(S.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:l,onClick:()=>m(!1),children:e.jsx(ie,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!c.trim()||!o.trim(),onClick:()=>{h(!0)},children:e.jsx(Os,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:u?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:l||!i||!c.trim(),onClick:f,children:e.jsx(me,{size:15})})]})})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Template"}),e.jsx(Pe,{value:t,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:S=>{N(S)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:c,onChange:S=>p(S.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Reset to template","aria-label":"Reset to template",disabled:l||!i,onClick:d,children:e.jsx(Te,{size:15})}),u&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(os,{size:15})})]})]})]})}function Un({connection:s,profile:t,selectedDefaultTeamId:a}){const n=Vt(s),l=_n(n.schedules);return rs(n.error,{prefix:"Local schedules"}),e.jsxs("div",{className:"account-list profile-agent-list","aria-label":"Profile agents",children:[e.jsx("div",{className:"account-list-heading profile-agent-list-heading",children:e.jsx("span",{children:"Agents"})}),e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-agent-table","aria-label":"Profile agents table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-agent-column"}),e.jsx("col",{className:"profile-action-column"}),e.jsx("col",{className:"profile-check-column"}),e.jsx("col",{className:"profile-sync-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Action"}),e.jsx("th",{scope:"col",children:"Check"}),e.jsx("th",{scope:"col",children:"Sync"})]})}),e.jsxs("tbody",{children:[l.active.map(i=>e.jsx(bs,{pending:n.pendingScheduleIds.has(i.id),schedule:i,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(i)},onToggle:()=>{n.toggle(i)}},i.id)),e.jsx(zn,{}),t.agents.map(i=>e.jsx(Bn,{agent:i,defaultAction:t.summary.defaultAction,profile:t,selectedDefaultTeamId:a},i.id)),l.paused.map(i=>e.jsx(bs,{pending:n.pendingScheduleIds.has(i.id),schedule:i,refreshing:n.loading,onRefresh:()=>{n.refresh()},onRun:()=>{n.run(i)},onToggle:()=>{n.toggle(i)}},i.id))]})]})})]})}function zn(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset Builder"}),e.jsx("span",{children:"Built in · every Profile"})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:"Design · Materialize · Test"})})}),e.jsx("td",{children:e.jsx(Re,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Re,{status:{state:"ready",label:"Built in"}})})]})}function Bn({agent:s,defaultAction:t,profile:a,selectedDefaultTeamId:n}){const l=Gn(a,s,n);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{title:s.path,children:s.path})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:t??"None"})})}),e.jsx("td",{children:e.jsx(Re,{status:l.check})}),e.jsx("td",{children:e.jsx(Re,{status:l.sync})})]})}function bs({pending:s,refreshing:t,schedule:a,onRefresh:n,onRun:l,onToggle:i}){const u=Hn(a),c=a.enabled?"Pause schedule":"Resume schedule";return e.jsxs("tr",{className:"profile-agent-row profile-schedule-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.localProjectName}),e.jsxs("span",{title:a.scheduleName,children:["schedule: ",a.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:a.targetAction,children:a.targetAction})})}),e.jsx("td",{children:e.jsx(Re,{status:u})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:Fn(a),children:a.enabled?a.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${a.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:t,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:n,children:e.jsx(te,{size:14,className:t?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${a.scheduleName} now`,onClick:l,children:e.jsx(Te,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:c,"aria-label":`${c}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(Bs,{size:14}):e.jsx(Fs,{size:14})})]})]})})]})}function Re({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function _n(s){const t=[],a=[];for(const n of s)n.enabled?t.push(n):a.push(n);return t.sort((n,l)=>ys(n)-ys(l)),{active:t,paused:a}}function ys(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function Hn(s){return s.enabled?s.lastError||s.lastRunStatus==="failed"?{state:"warning",label:"Failed"}:s.lastRunStatus==="running"?{state:"loading",label:"Running"}:s.lastRunStatus==="queued"?{state:"loading",label:"Queued"}:s.lastRunStatus==="skipped"?{state:"warning",label:"Skipped"}:s.lastRunStatus==="succeeded"?{state:"ready",label:"Succeeded"}:{state:"loading",label:"Scheduled"}:{state:"disabled",label:"Paused"}}function Fn(s){const t=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&t.push(`next ${Ns(s.nextRunAt)}`),s.lastRunAt&&t.push(`last ${Ns(s.lastRunAt)}`),t.join(" - ")}function Ns(s){const t=new Date(s);return Number.isFinite(t.getTime())?t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function Gn(s,t,a){if(!t.enabled)return{check:{state:"disabled",label:"Disabled"},sync:{state:"disabled",label:"Disabled"}};if(s.error)return{check:{state:"warning",label:"Error"},sync:{state:"warning",label:"Blocked"}};if(s.setupGate.blockingCount>0)return{check:{state:"warning",label:"Setup"},sync:{state:"warning",label:"Blocked"}};if(s.git?.dirty||Wn(s,t)>0)return{check:{state:"loading",label:"Pending"},sync:{state:"warning",label:"Changed"}};if(s.catalog.stale)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(!s.lastCheck)return{check:{state:"loading",label:"Unchecked"},sync:{state:"loading",label:"Waiting"}};if(s.lastCheck.status==="failed")return{check:{state:"warning",label:"Failed"},sync:{state:"warning",label:"Blocked"}};if(!s.summary.checkFresh)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(qn(s,a))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const n=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null;return!(s.summary.hostedHead??s.hosted?.sourceCommitSha??null)&&!l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Not synced"}}:n&&l&&n!==l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function qn(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}function Wn(s,t){let a=0;s.diff.changedAgents.includes(t.id)&&(a+=1),s.diff.newAgents.includes(t.id)&&(a+=1),s.diff.deletedAgents.includes(t.id)&&(a+=1);const n=t.path.replace(/^profiles\/[^/]+\//,"");for(const l of s.diff.files){const i=l.path.replace(/^profiles\/[^/]+\//,"");(i===n||i.startsWith(`${n}/`)||i.startsWith(`agents/${t.id}/`))&&(a+=1)}return a}function Vn({actions:s,busy:t,library:a,onSelect:n}){const l=a.profiles.find(u=>Xe(u.ref,a.lastUsed))??a.profiles[0]??null,i=l?Fe(l.ref):"";return e.jsxs("div",{className:"profile-selector-bar",children:[e.jsxs("label",{className:"profile-selector-control",children:[e.jsx("select",{"aria-label":"Active profile",disabled:t||a.profiles.length===0,value:i,onChange:u=>{const c=St(a,u.currentTarget.value),o=a.profiles.find(N=>Xe(N.ref,c));o&&n(o)},children:a.profiles.length?a.profiles.map(u=>e.jsx("option",{value:Fe(u.ref),children:u.name},Fe(u.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Ct,{"aria-hidden":"true",size:14})]}),s]})}function Kn({addDisabled:s,commitDisabled:t,commitLabel:a,refreshDisabled:n,repoDisabled:l,syncDisabled:i,syncLabel:u,syncStatus:c,onAdd:o,onCommit:N,onRefresh:p,onRepo:f,onSync:d}){const[h,m]=r.useState(!1),j=r.useRef(null);r.useEffect(()=>{if(!h)return;function S(R){j.current?.contains(R.target)||m(!1)}function x(R){R.key==="Escape"&&m(!1)}return document.addEventListener("pointerdown",S),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",x)}},[h]);function k(S){m(!1),S()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:j,children:[e.jsx("button",{"aria-expanded":h,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>m(S=>!S),children:e.jsx(kt,{size:15})}),h?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>k(N),children:[e.jsx(Oe,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>k(d),children:[e.jsx(pe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:u}),c?e.jsx("small",{children:c}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>k(f),children:[e.jsx(De,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>k(p),children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>k(o),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const Jn=[{id:"actions",label:"Actions",detail:"Profile-level reusable actions"},{id:"prompts",label:"Prompts",detail:"Shared prompt files"},{id:"goals",label:"Goals",detail:"Goal definitions; never started automatically"},{id:"evals",label:"Evals",detail:"Evaluation definitions and fixtures"},{id:"examples",label:"Examples",detail:"Example inputs and usage"},{id:"tasksets",label:"Tasksets",detail:"Training and evaluation tasksets"},{id:"extensions",label:"Extension declarations",detail:"Third-party extension metadata"}];function Yn({connection:s,entry:t,onClose:a,onPublished:n}){const[l,i]=r.useState("github"),[u,c]=r.useState(""),[o,N]=r.useState(`${t.name}-profile`),[p,f]=r.useState("public"),[d,h]=r.useState(()=>t.state.agents.filter(y=>y.enabled).map(y=>y.id)),[m,j]=r.useState(()=>t.state.skills.filter(y=>y.enabled).map(y=>y.name)),[k,S]=r.useState([]),[x,R]=r.useState(null),[I,b]=r.useState(null),[D,P]=r.useState(null),O=r.useMemo(()=>({ref:t.ref,selection:{agentIds:d,skillNames:m,optionalContent:k},target:{provider:l,owner:u.trim()||null,repository:o.trim(),visibility:l==="github"?"public":p}}),[d,t.ref,k,u,l,o,m,p]);function g(y,E,L){return L?[...new Set([...y,E])]:y.filter(G=>G!==E)}async function C(y){if(y.preventDefault(),!(!o.trim()||I)){b("preview"),P(null);try{R(await $.profilePublicationPreview(s,O))}catch(E){P(E instanceof Error?E.message:String(E))}finally{b(null)}}}async function w(){if(!(!x||x.blockedReasons.length>0||I)){b("publish"),P(null);try{const y=await $.profilePublicationPublish(s,{...O,expectedSourceHash:x.sourceHash,confirmed:!0});n(`Published ${t.name} to ${y.owner}/${y.repository}`),a()}catch(y){P(y instanceof Error?y.message:String(y))}finally{b(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:y=>y.stopPropagation(),onSubmit:C,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!I,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(pe,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",t.name]}),e.jsx("p",{children:"Choose the exact Agents, Skills, and optional files to share. OpenPond will show the complete file list before it pushes anything."}),x?e.jsx(Qn,{preview:x}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:"Destination"}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="github",onChange:()=>{i("github"),f("public")}}),e.jsx(es,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"GitHub"}),e.jsx("small",{children:"Published publicly with your signed-in gh CLI"})]})]}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="openpond_git",onChange:()=>{i("openpond_git"),f("private")}}),e.jsx(Pt,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[l==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:u,placeholder:"Uses gh account",onChange:y=>c(y.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:o,onChange:y=>N(y.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:p,onChange:y=>f(y.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ke,{title:"Agents",empty:"No Agents in this Profile",children:t.state.agents.map(y=>e.jsx(Je,{checked:d.includes(y.id),label:y.name,detail:y.path,onChange:E=>h(L=>g(L,y.id,E))},y.id))}),e.jsx(Ke,{title:"Skills",empty:"No Skills in this Profile",children:t.state.skills.map(y=>e.jsx(Je,{checked:m.includes(y.name),label:y.name,detail:y.description||y.path,onChange:E=>j(L=>g(L,y.name,E))},y.name))}),e.jsx(Ke,{title:"Optional content",empty:"",children:Jn.map(y=>e.jsx(Je,{checked:k.includes(y.id),label:y.label,detail:y.detail,onChange:E=>S(L=>g(L,y.id,E))},y.id))})]}),D?e.jsx("div",{className:"profile-dialog-warning",children:D}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!I,type:"button",onClick:x?()=>R(null):a,children:x?"Back":"Cancel"}),x?e.jsxs("button",{className:"git-dialog-primary",disabled:!!I||x.blockedReasons.length>0,type:"button",onClick:()=>{w()},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:I==="publish"?"Publishing":x.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!I||!o.trim(),type:"submit",children:I==="preview"?"Building preview":"Review exact files"})]})]})})}function Ke({title:s,empty:t,children:a}){const n=Array.isArray(a)?a.length:a?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),n?a:e.jsx("span",{className:"profile-publication-empty",children:t})]})}function Je({checked:s,label:t,detail:a,onChange:n}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:l=>n(l.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t}),e.jsx("small",{children:a})]})]})}function Qn({preview:s}){const t=s.files.reduce((a,n)=>a+n.sizeBytes,0);return e.jsxs("div",{className:"profile-publication-preview",children:[e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[s.files.length," files · ",ws(t)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(a=>e.jsx("div",{className:"profile-dialog-warning",children:a},a)),s.warnings.map(a=>e.jsx("div",{className:"profile-publication-warning",children:a},a)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(a=>e.jsxs("div",{children:[e.jsx("span",{title:a.path,children:a.path}),e.jsxs("small",{children:[a.category," · ",ws(a.sizeBytes)]})]},a.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(a=>e.jsx("code",{children:a},a))]}):null]})}function ws(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Zn({section:s="all",catalogPresentation:t="list",payload:a,connection:n,onPayload:l,onError:i,onToast:u,onSkillCommand:c,overviewContent:o}){const[N,p]=r.useState(""),[f,d]=r.useState(null),[h,m]=r.useState(!1),[j,k]=r.useState(null),[S,x]=r.useState(null),R=a?.profile??null,I=a?.preferences.defaultTeamId?.trim()||"",b=s==="all"||s==="profile"||s==="controls",D=s==="all"||s==="profile",P=s==="all"||s==="agents",O=s==="all"||s==="profile";async function g(A){n&&(l(await $.bootstrap(n)),u?.(A,"success"))}async function C(A,q){if(!(!n||f)){d(A),i(null);try{await q()}catch(J){i(J instanceof Error?J.message:String(J))}finally{d(null)}}}function w(){C("init",async()=>{await $.profileInit(n,{}),await g("Profile initialized")})}function y(){C("commit",async()=>{await $.profileCommit(n,{message:N.trim()||null}),p(""),await g("Profile commit complete")})}function E(){C("push",async()=>{if(!I)throw new Error("Select a default team before syncing a hosted profile.");await $.profileCheck(n,{kind:"all"}),await $.profilePush(n,{teamId:I,ensureHosted:!0,message:null}),await g("Profile synced to hosted profile repo")})}function L(A){C(`select:${A.ref.profileId}`,async()=>{await $.profileSelect(n,A.ref),await g(`Using ${A.name}`)})}function G(A){C("add",async()=>{A.source==="blank"?await $.profileInit(n,{path:A.path,profile:A.profile,template:"blank-profile"}):A.source==="local"?await $.profileLoad(n,A):await $.profileInstall(n,A),m(!1),await g(A.source==="blank"?`${A.profile} created`:"Profile added")})}function K(A){C("update",async()=>{await $.profileUpdate(n,A.ref),await g(`${A.name} updated`)})}function Q(A){C("remove",async()=>{await $.profileRemove(n,A.ref),k(null),await g("Profile removed from this device")})}function v(){C("refresh",async()=>{await g("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[R?.mode==="local"?e.jsxs(e.Fragment,{children:[b?e.jsxs(e.Fragment,{children:[D&&t==="select"?e.jsx(Vn,{actions:e.jsx(Ss,{connection:n,onAdd:()=>m(!0),onRefresh:v,presentation:"menu",profile:R,profileBusy:f,profileCommitMessage:N,selectedDefaultTeamId:I,syncDisabledReason:Cs(R,I),setProfileCommitMessage:p,submitProfileCommit:y,submitProfilePush:E}),busy:!!f,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:L}):e.jsxs(e.Fragment,{children:[D?e.jsx(Xn,{busy:!!f,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>m(!0),onRefresh:v,onRemove:k,onPublish:x,onUpdate:K,onSelect:L}):null,e.jsx(Ss,{connection:n,profile:R,profileBusy:f,profileCommitMessage:N,selectedDefaultTeamId:I,syncDisabledReason:Cs(R,I),setProfileCommitMessage:p,submitProfileCommit:y,submitProfilePush:E})]}),o]}):null,P?e.jsx(Un,{connection:n,profile:R,selectedDefaultTeamId:I}):null,O?e.jsx(la,{onSkillCommand:c,profile:R}):null]}):s==="agents"?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agents"}),e.jsx("small",{children:"Profile required"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Open Profile to create or load a Profile before managing agents."})]})]}):e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Summary"}),e.jsx("small",{children:"Not loaded"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Create an empty Profile, start with an Agent template, or add an existing repository."}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!f,type:"button",onClick:()=>m(!0),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!!f,type:"button",onClick:w,children:[e.jsx(me,{size:14}),e.jsx("span",{children:f==="init"?"Creating":"Create starter Profile"})]})]})]}),h?e.jsx(ea,{busy:!!f,onClose:()=>m(!1),onSubmit:G}):null,j?e.jsx(sa,{busy:!!f,entry:j,onClose:()=>k(null),onConfirm:()=>Q(j)}):null,S&&n?e.jsx(Yn,{connection:n,entry:S,onClose:()=>x(null),onPublished:A=>u?.(A,"success")}):null]})}function Xn({busy:s,library:t,onAdd:a,onRefresh:n,onRemove:l,onPublish:i,onSelect:u,onUpdate:c}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[t.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:n,children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),t.profiles.map(o=>{const N=Xe(o.ref,t.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${N?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||u(o)},onKeyDown:p=>{s||p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),u(o))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(De,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{title:o.repoPath,children:o.repoPath})]})]}),e.jsx(Ks,{status:{state:o.state.error?"warning":"ready",label:o.state.error?"error":N?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:o.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:o.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[o.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:p=>{p.stopPropagation(),c(o)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),c(o))},children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:p=>{p.stopPropagation(),i(o)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),i(o))},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${o.name}`,onClick:p=>{p.stopPropagation(),l(o)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),l(o))},children:[e.jsx(be,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${o.ref.source}:${o.ref.repositoryId}:${o.ref.profileId}`)})]})}function ea({busy:s,onClose:t,onSubmit:a}){const[n,l]=r.useState("blank"),[i,u]=r.useState(""),[c,o]=r.useState(""),[N,p]=r.useState("");function f(d){if(d.preventDefault(),s)return;if(n==="blank"){const m=N.trim();if(!m)return;a({source:n,path:i.trim()||null,profile:m});return}if(n==="local"){const m=i.trim();if(!m)return;a({source:n,path:m,profile:N.trim()||null});return}const h=c.trim();h&&a({source:n,repositoryId:h,profile:N.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:t,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:d=>d.stopPropagation(),onSubmit:f,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:t,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(De,{size:18})}),e.jsx("h2",{id:"add-profile-title",children:"Add Profile"}),e.jsx("p",{children:"Create a blank Profile, add a local repository, or install a shareable Profile from Git."}),e.jsxs("div",{className:"profile-add-source-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="blank",onChange:()=>l("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="local",onChange:()=>l("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="github",onChange:()=>l("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:n==="openpond_git",onChange:()=>l("openpond_git")}),"OpenPond Git"]})]}),n==="blank"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path (optional)"}),e.jsx("input",{disabled:s,value:i,placeholder:"Uses the default local Profile repository",onChange:d=>u(d.currentTarget.value)})]}):n==="local"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path"}),e.jsx("input",{autoFocus:!0,disabled:s,value:i,placeholder:"/path/to/profile-repo",onChange:d=>u(d.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[n==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:c,placeholder:"owner/repository",onChange:d=>o(d.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:n==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:n==="blank",disabled:s,value:N,placeholder:n==="blank"?"research":"Uses repository default",onChange:d=>p(d.currentTarget.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:s||!(n==="blank"?N:n==="local"?i:c).trim(),type:"submit",children:n==="blank"?"Create Profile":"Add Profile"})]})]})})}function sa({busy:s,entry:t,onClose:a,onConfirm:n}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"remove-profile-title",onMouseDown:l=>l.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(be,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",t.name,"?"]}),e.jsx("p",{children:"This removes the Profile from OpenPond on this device. It does not delete the repository or any source files."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:t.name}),e.jsx("span",{children:t.repoPath})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:n,children:"Remove"})]})]})})}function Ss({connection:s,onAdd:t,onRefresh:a,presentation:n="toolbar",profile:l,profileBusy:i,profileCommitMessage:u,selectedDefaultTeamId:c,syncDisabledReason:o,setProfileCommitMessage:N,submitProfileCommit:p,submitProfilePush:f}){const[d,h]=r.useState(!1),[m,j]=r.useState(!1),[k,S]=r.useState(!1),x=!s||!!i;return e.jsxs(e.Fragment,{children:[n==="menu"&&t&&a?e.jsx(Kn,{addDisabled:!!i,commitDisabled:x,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:x,repoDisabled:!!i||!l,syncDisabled:x||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ye(l,c):null,onAdd:t,onCommit:()=>j(!0),onRefresh:a,onRepo:()=>h(!0),onSync:()=>S(!0)}):e.jsx("div",{className:"profile-control-panel",children:e.jsxs("div",{className:"profile-control-toolbar",children:[e.jsxs("div",{className:"profile-control-actions",children:[e.jsxs("button",{className:"settings-secondary",disabled:x,type:"button",onClick:()=>j(!0),children:[e.jsx(Oe,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:x||!l,type:"button",onClick:()=>S(!0),children:[e.jsx(pe,{size:14}),e.jsx("span",{children:i==="push"?"Syncing":"Sync"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!!i||!l,type:"button",onClick:()=>h(!0),children:[e.jsx(De,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ye(l,c)}`,children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ye(l,c)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),d&&l?e.jsx(aa,{profile:l,profileBusy:i,onClose:()=>h(!1)}):null,m?e.jsx(ta,{disabled:x,profileBusy:i,profileCommitMessage:u,setProfileCommitMessage:N,submitProfileCommit:p,onClose:()=>j(!1)}):null,k&&l?e.jsx(na,{disabled:x,profile:l,profileBusy:i,selectedDefaultTeamId:c,syncDisabledReason:o,submitProfilePush:f,onClose:()=>S(!1)}):null]})}function ta({disabled:s,profileBusy:t,profileCommitMessage:a,setProfileCommitMessage:n,submitProfileCommit:l,onClose:i}){function u(c){c.preventDefault(),!s&&(l(),i())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:i,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:c=>c.stopPropagation(),onSubmit:u,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:i,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Oe,{size:18})}),e.jsx("h2",{id:"profile-commit-dialog-title",children:"Commit profile"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Commit message"}),e.jsx("input",{autoFocus:!0,value:a,disabled:!!t,placeholder:"Update OpenPond profile",onChange:c=>n(c.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:i,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(Oe,{size:14}),e.jsx("span",{children:t==="commit"?"Committing":"Commit"})]})]})]})})}function na({disabled:s,profile:t,profileBusy:a,selectedDefaultTeamId:n,syncDisabledReason:l,submitProfilePush:i,onClose:u}){const c=ra(t,n),o=c.reduce((f,d)=>f+d.count,0),N=!s&&!l;function p(f){f.preventDefault(),N&&(i(),u())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:u,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:f=>f.stopPropagation(),onSubmit:p,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(pe,{size:18})}),e.jsx("h2",{id:"profile-sync-dialog-title",children:"Sync profile"}),e.jsx("p",{className:"profile-sync-explainer",children:"Sync publishes this committed Profile source for your team, so its Agents can be shared in team chat and attached to hosted sandboxes."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[o," ",o===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",ye(t.summary.localHead??t.git?.head)," - Last pushed"," ",ye(t.hosted?.lastPushedLocalHead)]})]}),c.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:c.map(f=>e.jsxs("div",{className:`profile-dialog-diff-row ${f.tone??""}`,children:[e.jsx("strong",{children:f.label}),e.jsx("span",{children:f.detail})]},f.label))}):e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:e.jsxs("div",{className:"profile-dialog-diff-row",children:[e.jsx("strong",{children:"Aligned"}),e.jsx("span",{children:"Current local profile source has already been pushed."})]})}),l?e.jsx("div",{className:"profile-dialog-warning",children:l}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:u,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!N,type:"submit",children:[e.jsx(pe,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function aa({profile:s,profileBusy:t,onClose:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:n=>n.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:a,children:e.jsx(ie,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(De,{size:18})}),e.jsx("h2",{id:"profile-path-dialog-title",children:"Profile repo"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Profile repo path"}),e.jsx("input",{"aria-label":"Profile repo path",readOnly:!0,value:s.repoPath??""})]}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:s.git?.isRepo?"Git-backed":"Git setup required"}),e.jsxs("span",{children:[s.git?.branch??"No branch"," · ",ye(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:a,children:"Close"})})]})})}function la({onSkillCommand:s,profile:t}){const a=t.skills.slice().sort((i,u)=>i.name.localeCompare(u.name)),n=!s;function l(i){s?.(i)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[t.skillCatalog.skillCount," tracked"]})})]}),a.length?e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-skill-table","aria-label":"Profile skills table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-skill-name-column"}),e.jsx("col",{className:"profile-skill-trigger-column"}),e.jsx("col",{className:"profile-skill-status-column"}),e.jsx("col",{className:"profile-skill-source-column"}),e.jsx("col",{className:"profile-skill-actions-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Skill"}),e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:a.map(i=>e.jsx(ia,{commandDisabled:n,onSkillCommand:l,skill:i},i.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function ia({commandDisabled:s,onSkillCommand:t,skill:a}){const n=a.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:a.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Le,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.name}),e.jsx("span",{title:a.path,children:a.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:a.description,children:a.description||"No description"}),e.jsx("td",{children:e.jsx(Ks,{status:n})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:a.sourcePath,children:a.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:s||!a.enabled,type:"button",title:`Use ${a.name}`,onClick:()=>t(`$${a.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${a.name}`,onClick:()=>t(`/skill edit ${a.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function Ks({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ye(s){return s?s.slice(0,10):"None"}function Ye(s,t){return Js(s,t)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${ye(s.hosted.sourceCommitSha)}`:"Not pushed"}function Cs(s,t){return t?s.git?.head?s.git.dirty?"Commit local profile changes before syncing.":null:"Commit the profile before syncing.":"Select a default team before syncing."}function ra(s,t){const a=[],n=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null,i=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(Js(s,t)&&a.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!i&&!l?a.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):n&&l&&n!==l&&a.push({label:"Commit",detail:`Local ${ye(n)} has not been pushed since ${ye(l)}.`,count:1}),s.git?.dirty){const c=s.git.files.length||s.diff.files.length||1;a.push({label:"Uncommitted files",detail:`${c} local ${c===1?"file":"files"} changed.`,count:c,tone:"warning"})}const u=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return u>0&&a.push({label:"Profile changes",detail:oa(s),count:u,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&a.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&a.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),a}function oa(s){const t=[],a=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return a&&t.push(`${a} agent ${a===1?"change":"changes"}`),s.diff.changedActions.length&&t.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&t.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&t.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&t.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&t.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),t.join(", ")||"Profile source has local changes."}function Js(s,t){const a=s.hosted?.teamId?.trim()??"";return!!(a&&t&&a!==t)}const ca=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],da=120,ua=new Set(["openai","xai","zai"]),ha=new Set(["chatgpt-subscription"]),ma="https://api.z.ai/api/coding/paas/v4";function ks(s){return s.split(/[\n,]/).map(t=>t.trim()).filter(Boolean)}function Ys(s){return s?s.available?"Ready":s.credential.connected?"Configured":s.credential.lastError||s.lastError?"Needs attention":s.id==="codex"?"Needs Codex login":s.routing.localByok?"Needs key":s.enabled?"Enabled":"Off":"Unknown"}function Qs(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Ps(s){return s.credential.connected?s.credential.redacted?s.credential.redacted:s.credential.source==="chatgpt_subscription"?"ChatGPT subscription":s.credential.source:s.credential.lastError??"Not connected"}function pa(s){return s?.trim().replace(/\/+$/,"")??""}function Zs(s,t){return s.id==="zai"&&pa(t.providers.zai?.baseUrl)===ma}function ga(s,t){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":Zs(s,t)?"Coding Plan key":"API key"}function fa(s,t){const a=t.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const n=Math.max(a?.models.length??0,s.modelIds.length),l=s.defaultModel?ts(s.defaultModel,t,s.id):"",i=n===1?"1 model":`${n} models`,u=ga(s,t);return[Ys(s),u,a?i:"",l].filter(Boolean).join(" · ")}function xa(s){return s!=="openpond"&&ss(s)}function cs(s){return s?ua.has(s.id)||s.credentialModes.some(t=>ha.has(t)):!1}function ja(s){return cs(s)?["api","subscription"]:["api"]}function Rs(s,t){return!s||!t||!cs(s)?"api":s.credential.source==="chatgpt_subscription"||Zs(s,t)?"subscription":"api"}function As(s,t){const a=Rt.filter(n=>!!s?.statuses[n]);return t?a.filter(n=>cs(s?.statuses[n])):a}function va(s){if(!s)return"Never";const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function ba(s,t,a=da){const n=[],l=new Set,i=new Set(t.map(c=>c.trim()).filter(Boolean)),u=c=>{l.has(c.value)||n.length>=a||(l.add(c.value),n.push(c))};for(const c of s)i.has(c.value)&&u(c);for(const c of s)u(c);return n}function ya({account:s,codex:t,providers:a,providerBusy:n,validationMessage:l,deleteProviderCredential:i,loadProviderModels:u,refreshProviderModels:c,saveProviderConfig:o,saveProviderCredential:N,startOpenAiSubscriptionAuth:p,validateProvider:f}){const[d,h]=r.useState(null),[m,j]=r.useState(!1),k=r.useMemo(()=>As(a,!1),[a]),S=r.useMemo(()=>As(a,m),[a,m]),x=d?a?.statuses[d]??null:null;function R(I,b){h(I),b&&u(I)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),a?e.jsxs("div",{className:"provider-manager-panel",children:[e.jsxs("div",{className:"account-list-heading provider-manager-heading",children:[e.jsxs("div",{className:"provider-manager-title-row",children:[e.jsx("span",{children:"Model providers"}),e.jsxs("label",{className:"settings-check-row compact provider-subscription-filter",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:I=>j(I.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[S.length," of ",k.length," presets"]})]}),S.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:S.map(I=>{const b=a.statuses[I],D=a.modelCaches[I],P=b.modelIds.length>0&&(D?.models.length??0)<b.modelIds.length,O=n?.startsWith(`${I}:`)??!1,g=xa(I),C=I==="openpond"||!!a.providers[I]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${b.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:C,disabled:!g||O,onChange:w=>{R(I,!1),o(I,{enabled:w.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:b.displayName})}),e.jsxs("div",{className:`provider-row-status ${Qs(b)}`,children:[O?e.jsx(ae,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:fa(b,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{R(I,P)},children:"Details"})]},I)})}):e.jsxs("div",{className:"empty-account-list provider-manager-empty",children:[e.jsx("strong",{children:"No subscription providers"}),e.jsx("span",{children:"Turn off the filter to show API-key providers."})]})]}):null,l?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:l})]}):null,d&&x&&a?e.jsx(Na,{account:s,codex:t,providerId:d,providerBusy:n,settings:a,status:x,onClose:()=>h(null),onDeleteCredential:i,onRefreshModels:c,onSaveConfig:o,onSaveCredential:N,onStartOpenAiSubscriptionAuth:p,onValidate:f}):null]})}function Na({account:s,codex:t,providerId:a,providerBusy:n,settings:l,status:i,onClose:u,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:N,onSaveCredential:p,onStartOpenAiSubscriptionAuth:f,onValidate:d}){const h=l.providers[a],m=l.modelCaches[a],j=r.useId(),k=r.useRef(a),S=Math.max(m?.models.length??0,i.modelIds.length),x=i.routing.localByok&&ss(a)&&a!=="codex",R=r.useMemo(()=>x?ja(i):[],[x,i]),I=R.includes("subscription"),[b,D]=r.useState(()=>Rs(i,l)),P=x&&b==="subscription"&&I,O=C=>`${j}-${C}-panel`,g=a==="codex"?"Codex app server":h?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(k.current!==a){k.current=a,D(Rs(i,l));return}x&&!R.includes(b)&&D("api")},[b,R,x,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:u,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:C=>C.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(ie,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.displayName}),e.jsx("span",{children:Ee(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${Qs(i)}`,children:Ys(i)})]}),x?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:R.map(C=>e.jsx("button",{type:"button",role:"tab",id:`${j}-${C}`,className:b===C?"active":void 0,"aria-selected":b===C,"aria-controls":O(C),onClick:()=>D(C),children:C==="api"?"API":"Subscription"},C))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Ps(i),children:Ps(i)})]}),P?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:g,children:g})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:h?.defaultModel??i.defaultModel??void 0,children:h?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:m?.lastError??void 0,children:[S," cached · ",va(m?.fetchedAt)]})]})]}),a==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:t?.account?.email??void 0,children:t?.account?.label??t?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:t?.binaryPath??void 0,children:t?.binaryPath??"Not found"})]})]}):null,i.credential.lastError||m?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??m?.lastError??i.lastError??void 0,children:i.credential.lastError??m?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(wa,{providerBusy:n,status:i,onValidate:d}):x&&h&&m?e.jsx(Sa,{credentialTab:b,credentialTabsId:j,hasSubscriptionTab:I,providerId:a,providerBusy:n,settings:l,status:i,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:N,onSaveCredential:p,onStartOpenAiSubscriptionAuth:f,onValidate:d}):i.routing.localByok&&!ss(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Hs,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function wa({providerBusy:s,status:t,onValidate:a}){const n=s==="codex:validate";return e.jsxs("div",{className:"provider-dialog-body codex-provider-body",children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(ue,{size:15}),e.jsxs("span",{children:["Uses your local ",e.jsx("code",{children:"codex login"})," session through the Codex app server. This route is separate from OpenAI Platform API-key billing."]})]}),e.jsx("div",{className:"settings-button-row codex-provider-actions",children:e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n,onClick:()=>{a("codex",{modelId:t.defaultModel??void 0})},children:[n?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(Us,{size:14}),e.jsx("span",{children:n?"Testing":"Test Codex login"})]})})]})}function Sa({credentialTab:s,credentialTabsId:t,hasSubscriptionTab:a,providerId:n,providerBusy:l,settings:i,status:u,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:N,onSaveCredential:p,onStartOpenAiSubscriptionAuth:f,onValidate:d}){const h=i.providers[n],m=r.useMemo(()=>ze(n,i),[n,i]),j=`provider-models-${n}`,k=r.useRef(n),[S,x]=r.useState(h.baseUrl??""),[R,I]=r.useState(h.defaultModel??""),[b,D]=r.useState(h.modelOverrides.join(`
|
|
3
|
+
`)),[P,O]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[g,C]=r.useState("local_secret"),[w,y]=r.useState(""),[E,L]=r.useState(""),G=l===`${n}:config`,K=l===`${n}:credential`,Q=l===`${n}:validate`,v=l===`${n}:models`,A=l==="openai:credential",q=n==="openai",J=n==="xai",W=n==="zai",Y=(z=>`${t}-${z}-panel`)(s),U=s==="subscription"&&a,ne=s==="subscription"&&W?"coding-plan":"api",re=ne==="coding-plan"?"Coding Plan key":"API key",ce=u.credential.connected?ne==="coding-plan"?"Replace saved plan key":"Replace saved key":re,V=ne==="coding-plan"?"Save plan key":"Save key",le=r.useMemo(()=>ba(m,[R,...ks(b)]),[R,m,b]),se=Math.max(0,m.length-le.length);r.useEffect(()=>{if(k.current!==n){k.current=n,O({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),x(h.baseUrl??""),I(h.defaultModel??""),D(h.modelOverrides.join(`
|
|
4
|
+
`));return}P.baseUrl||x(h.baseUrl??""),P.defaultModel||I(h.defaultModel??""),P.modelOverrides||D(h.modelOverrides.join(`
|
|
5
|
+
`))},[h.baseUrl,h.defaultModel,h.modelOverrides,P.baseUrl,P.defaultModel,P.modelOverrides,n]);const fe=g==="env"?!!E.trim():!!w.trim();async function oe(z){z.preventDefault(),await N(n,{enabled:!0,baseUrl:S.trim()||null,defaultModel:R.trim()||null,modelOverrides:ks(b)}),O({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function T(z){if(z.preventDefault(),!!fe){if(g==="env"){await p(n,{source:"env",envVar:E.trim()});return}await p(n,{source:"local_secret",value:w}),y("")}}function B({panel:z=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:z?Y:void 0,role:z?"tabpanel":void 0,"aria-labelledby":z?`${t}-${s}`:void 0,onSubmit:_=>{T(_)},children:[e.jsxs("div",{className:"provider-card-grid credential-grid",children:[e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Credential source"}),e.jsx(Pe,{value:g,disabled:K,label:"Credential source",options:ca,onChange:_=>C(_)})]}),g==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:E,disabled:K,placeholder:"PROVIDER_API_KEY",onChange:_=>L(_.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:re}),e.jsx("input",{type:"password",value:w,disabled:K,placeholder:ce,autoComplete:"off",onChange:_=>y(_.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:K||!fe,children:[K?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:K?"Saving":V})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:K||!u.credential.connected,onClick:()=>{c(n)},children:e.jsx(be,{size:15})})]})]})}function H(){return q?e.jsxs("div",{className:"provider-subscription-panel",id:Y,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(ue,{size:15}),e.jsx("span",{children:"ChatGPT subscription auth opens OpenAI login and stores a refresh token locally. API keys remain available under the API tab for raw Platform billing."})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{type:"button",className:"settings-secondary",disabled:A,onClick:()=>{f("browser")},children:[A?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:A?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:A,onClick:()=>{f("device")},children:[A?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:A||!u.credential.connected,onClick:()=>{c(n)},children:e.jsx(be,{size:15})})]})]}):J?e.jsx("div",{className:"provider-subscription-panel",id:Y,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(ue,{size:15}),e.jsx("span",{children:"SuperGrok includes Grok app and Grok Build access. xAI API calls here still use an xAI Console API key with API credits or invoiced billing, so there is no separate Connect SuperGrok step yet."})]})}):W?e.jsxs("div",{className:"provider-subscription-panel",id:Y,role:"tabpanel","aria-labelledby":`${t}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(ue,{size:15}),e.jsx("span",{children:"GLM Coding Plan uses a plan API key with the dedicated Coding endpoint. General Z.ai API keys and balances are separate."})]}),B({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[U?null:e.jsxs("form",{className:"provider-card-form",onSubmit:z=>{oe(z)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:S,disabled:G,placeholder:"https://api.example.com/v1",onChange:z=>{O(_=>({..._,baseUrl:!0})),x(z.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:j,value:R,disabled:G,placeholder:"Model id",onChange:z=>{O(_=>({..._,defaultModel:!0})),I(z.currentTarget.value)}}),e.jsx("datalist",{id:j,children:le.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))}),se>0?e.jsxs("small",{children:[se," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:G,children:[G?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(os,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:v,onClick:()=>{o(n)},children:[v?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(te,{size:14}),e.jsx("span",{children:v?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Q||!R.trim(),onClick:()=>{d(n,{baseUrl:S.trim()||void 0,modelId:R.trim()||void 0})},children:[Q?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(Us,{size:14}),e.jsx("span",{children:Q?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:U?H():B()})]})}function Ca({status:s,busy:t,flashTailscaleUp:a,refresh:n,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:u,copyTailscaleUpCommand:c,copyServeCommand:o,copyServeSetupUrl:N,copyOperatorCommand:p,createRemoteLink:f}){const d=s?.tailscale.installed??!1,h=s?.serve.enabled??!1,m=s?.serve.reachable??!1,j=!!(s?.webUiAvailable&&d),k=h?!!s?.remoteWebUrl:j,x=(s?.tailscale.peers??[]).filter(b=>!b.isSelf),R=!!s?.tailscale.error?.includes("set --operator"),I=!!(h&&s?.remoteWebUrl);return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx("div",{className:`remote-access-icon ${m?"online":h?"configured":""}`,children:d?e.jsx(qs,{size:18}):e.jsx(qt,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:m?"Tailscale Serve is reachable":h?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Ra(s):"Checking Tailscale"})]})]}),e.jsxs("div",{className:"account-summary-actions",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh remote access","aria-label":"Refresh remote access",disabled:t!==null,onClick:()=>{n()},children:e.jsx(te,{className:t==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t!==null||!d||!h&&!j,onClick:()=>{h?i():l()},children:[e.jsx(ln,{size:15}),e.jsx("span",{children:h?t==="disable"?"Turning off":"Turn off":t==="enable"?"Turning on":"Turn on"})]})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsx("div",{className:"account-list-heading remote-access-link-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"OpenPond link"}),e.jsx("small",{children:I?"Browser UI":"Tailscale + Serve"})]})}),I&&e.jsx(de,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:t==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||t!==null,onAction:u}),e.jsx(de,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:c}),e.jsx(de,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:o}),s?.serve.setupUrl&&e.jsx(de,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:N}),R&&e.jsx(de,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:p}),e.jsx(de,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(de,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(de,{label:"Disable command",value:s?.disableCommand??null})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading remote-access-link-heading",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Authorized clients"}),e.jsxs("small",{children:[x.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:t!==null||!k,onClick:()=>{f()},children:e.jsx("span",{children:h?"Copy link":"Create link"})})]}),s?x.length===0?e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No clients reported"}),e.jsx("span",{children:s?.tailscale.running?"Tailscale did not return peer devices.":"Tailscale is not running."})]}):x.map(b=>e.jsx(Pa,{peer:b},b.id)):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"Checking clients"}),e.jsx("span",{children:"Loading tailnet devices."})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Remote environment"}),e.jsx("small",{children:s?.tailscale.tailnetName??"Tailnet"})]}),e.jsx(ka,{status:s})]}),s?.serve.configText&&e.jsxs("div",{className:"remote-access-config",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Tailscale config"}),e.jsx("small",{children:s.serve.enabled?"OpenPond target found":"No OpenPond target"})]}),e.jsx("pre",{children:s.serve.configText})]})]})}function de({actionLabel:s,disabled:t,flash:a,label:n,onAction:l,value:i}){return e.jsxs("div",{className:"product-row remote-access-value-row",children:[e.jsxs("div",{children:[e.jsx("strong",{className:a?"flash":void 0,children:n}),e.jsx("code",{children:i??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function ka({status:s}){const t=[{label:"State",value:s?.tailscale.backendState??"Unknown"},{label:"Machine",value:s?.tailscale.machineName??"Unknown"},{label:"Tailnet",value:s?.tailscale.tailnetName??"Unknown"}],a=[{label:"Tailscale IP",value:s?.tailscale.tailscaleIps.join(", ")||"Unknown"},{label:"HTTPS host",value:s?.serve.httpsHost??s?.tailscale.dnsName??"Unknown"}];return e.jsxs("div",{className:"remote-access-environment",children:[e.jsx("div",{className:"remote-access-environment-row three",children:t.map(n=>e.jsx(Ds,{label:n.label,value:n.value},n.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(n=>e.jsx(Ds,{label:n.label,value:n.value},n.label))})]})}function Ds({label:s,value:t}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:t})]})}function Pa({peer:s}){return e.jsxs("div",{className:"account-row remote-access-peer-row",children:[e.jsx("div",{className:`remote-access-peer-dot ${s.online?"online":""}`}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:s.name}),e.jsx("span",{children:s.dnsName??s.tailscaleIps[0]??"No address"})]}),e.jsx("span",{className:`account-state ${s.online?"signed_in":""}`,children:s.online?"Online":"Offline"}),e.jsx("span",{className:"account-state",children:s.os??"Unknown"})]})}function Ra(s){return s.tailscale.installed?s.tailscale.running?s.webUiAvailable?s.serve.reachable?s.remoteUrl??"Tailnet link ready":s.remoteUrl?`${s.remoteUrl} ready to configure`:"Tailnet DNS unavailable":"Browser UI is not served by this process":s.tailscale.authUrl?"Tailscale needs sign-in":"Tailscale is not running":"Tailscale is not installed"}const Aa=[{items:[{section:"account",label:"Account",Icon:hn},{section:"notifications",label:"Notifications",Icon:Gs},{section:"providers",label:"Providers",Icon:Dt},{section:"compute",label:"Compute",Icon:Kt},{section:"dataset-storage",label:"Dataset Storage",Icon:tn},{section:"usage",label:"Activity",Icon:It},{section:"defaults",label:"Defaults",Icon:Ws}]},{label:"Harness",items:[{section:"harness",label:"Harness",Icon:qe},{section:"skills",label:"Skills",Icon:Le},{section:"context",label:"Context",Icon:$t},{section:"training",label:"Training",Icon:qe},{section:"subagents",label:"Subagents",Icon:qe}]},{items:[{section:"profile",label:"Legacy Profiles",Icon:Be},{section:"editor",label:"Editor",Icon:Ft},{section:"remote",label:"Remote",Icon:qs},{section:"personalization",label:"Personalization",Icon:Jt},{section:"diagnostics",label:"Diagnostics",Icon:Wt}]}];function Da({section:s,onBack:t,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back",onClick:t,children:[e.jsx(At,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Aa.map((n,l)=>e.jsxs("div",{className:"settings-nav-group",children:[n.label?e.jsx("div",{className:"settings-nav-heading",children:n.label}):null,n.items.map(({section:i,label:u,Icon:c})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(c,{size:16}),e.jsx("span",{children:u})]},i))]},n.label??`settings-${l}`))})]})}function Ia({catalog:s,connection:t,onCatalog:a,onError:n,onOpenExtension:l,onToast:i}){const[u,c]=r.useState(""),[o,N]=r.useState(""),[p,f]=r.useState(null),[d,h]=r.useState(null),[m,j]=r.useState(null),k=r.useCallback(g=>{const C=g instanceof Error?g.message:String(g);j(C),n(C),i?.(C,"error")},[n,i]),S=r.useCallback(()=>{j(null),n(null)},[n]),x=r.useCallback(async g=>{if(g?.preventDefault(),!(!t||!u.trim()||d)){S(),h("preview");try{const C=await $.extensionPreview(t,{source:u.trim(),...o.trim()?{ref:o.trim()}:{}});f(C)}catch(C){f(null),k(C)}finally{h(null)}}},[d,S,t,k,o,u]),R=r.useCallback(async()=>{if(!(!t||!p||d)){S(),h("install");try{const g=await $.extensionAdd(t,{source:p.repositoryUrl,ref:p.requestedRef});a(g.catalog),c(""),N(""),f(null),i?.(`Installed ${g.extension.owner}/${g.extension.repo}.`,"success")}catch(g){k(g)}finally{h(null)}}},[d,S,t,a,i,p,k]),I=r.useCallback(async g=>{if(!(!t||d)){S(),h(`update:${g.id}`);try{const C=await $.extensionUpdate(t,g);a(C.catalog);const w=C.extension.resolvedCommit===g.resolvedCommit&&C.extension.packageHash===g.packageHash;i?.(w?`${g.owner}/${g.repo} is already current.`:`Updated ${g.owner}/${g.repo}.`,"success")}catch(C){k(C)}finally{h(null)}}},[d,S,t,a,i,k]),b=r.useCallback(async()=>{if(!(!t||d||s.extensions.length===0)){S(),h("update-all");try{const g=await $.extensionUpdateAll(t);a(g.catalog);const C=`Updated ${g.updated.length}; ${g.unchanged.length} already current${g.failed.length?`; ${g.failed.length} failed`:""}.`;i?.(C,g.failed.length?"error":"success"),g.failed.length&&j(g.failed.map(w=>w.error).join(" "))}catch(g){k(g)}finally{h(null)}}},[d,s.extensions.length,S,t,a,i,k]),D=r.useCallback(async g=>{if(!(!t||d)&&window.confirm(`Remove ${g.owner}/${g.repo} and its ${g.skills.length} installed skill${g.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){S(),h(`remove:${g.id}`);try{const C=await $.extensionRemove(t,g);a(C.catalog),i?.(`Removed ${g.owner}/${g.repo}.`,"success")}catch(C){k(C)}finally{h(null)}}},[d,S,t,a,i,k]),P=r.useCallback(g=>{c(g),f(null),j(null)},[]),O=r.useCallback(g=>{N(g),f(null),j(null)},[]);return e.jsxs("div",{className:"account-list native-skills-list github-extensions-list",children:[e.jsxs("div",{className:"account-list-heading github-extensions-heading",children:[e.jsx("span",{children:"Third-party extensions"}),e.jsxs("div",{className:"github-extensions-heading-actions",children:[e.jsxs("small",{children:[s.extensions.length," installed from GitHub"]}),e.jsxs("button",{className:"settings-secondary compact",disabled:!t||d!==null||s.extensions.length===0,type:"button",onClick:()=>{b()},children:[d==="update-all"?e.jsx(ae,{className:"settings-spin",size:13}):e.jsx(te,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:g=>{x(g)},children:[e.jsxs("div",{className:"github-extension-add-copy",children:[e.jsx("strong",{children:"Add a GitHub skill pack"}),e.jsx("span",{children:"Use a skills-CLI-compatible owner/repo or GitHub URL. OpenPond installs it locally without running setup code."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{disabled:!t||d!==null,placeholder:"owner/repo",value:u,onChange:g=>P(g.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!t||d!==null,placeholder:"Default branch",value:o,onChange:g=>O(g.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!u.trim()||d!==null,type:"submit",children:[d==="preview"?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(es,{size:14}),d==="preview"?"Checking":"Preview"]})]}),m||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:m??s.error}):null,p?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[p.owner,"/",p.repo]}),e.jsxs("span",{children:[p.skills.length," skill",p.skills.length===1?"":"s"," at ",p.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:p.skills.map(g=>e.jsx("span",{children:g.name},g.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:d!==null,type:"button",onClick:()=>{R()},children:[d==="install"?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(me,{size:14}),d==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(g=>{const C=d===`update:${g.id}`,w=d===`remove:${g.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${g.owner}/${g.repo} extension source`,className:"github-extension-open",disabled:!t||d!==null,type:"button",onClick:()=>l(g),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(es,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[g.owner,"/",g.repo]}),e.jsx("span",{children:g.skills.map(y=>y.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[g.skills.length," skill",g.skills.length===1?"":"s"]}),e.jsxs("span",{children:[g.requestedRef," · ",g.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${g.validationStatus==="valid"?"":"invalid"}`,children:g.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(zs,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${g.owner}/${g.repo}`,className:"settings-icon-button ghost",disabled:d!==null,title:"Update extension",type:"button",onClick:()=>{I(g)},children:C?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(te,{size:14})}),e.jsx("button",{"aria-label":`Remove ${g.owner}/${g.repo}`,className:"settings-icon-button ghost danger",disabled:d!==null,title:"Remove extension",type:"button",onClick:()=>{D(g)},children:w?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(be,{size:14})})]})]},g.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function $a({onOpenSkill:s,onOpenExtension:t,personalSkills:a,extensionCatalog:n,connection:l,onExtensionCatalog:i,onError:u,onToast:c}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(Ia,{catalog:n,connection:l,onCatalog:i,onError:u,onOpenExtension:t,onToast:c}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),a.length?a.map(o=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Le,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:o.resourceFiles.length?`${o.resourceFiles.length} packaged resource${o.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:o.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${o.validationStatus==="valid"?"":"invalid"}`,children:o.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},o.sourcePath)):e.jsx("div",{className:"skills-settings-empty",children:"No personal Codex skills found."})]}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"App integration skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),Mt.map(o=>{const N=Et(o.provider)?.label??o.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(o),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Le,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:N}),e.jsx("span",{children:o.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(zs,{size:16,"aria-hidden":"true"})]},o.name)})]})]})}const ds="default";function Ma({connection:s,embedded:t=!1,onError:a,onPreferences:n,preferences:l,providers:i}){const u=l.training,[c,o]=r.useState(Qe(u.defaultModelRef)),[N,p]=r.useState(u.creationMode),[f,d]=r.useState(u.autoApproveEvidence),[h,m]=r.useState(!1),j=r.useMemo(()=>Ts(i,{includeUnavailable:!0}),[i]),k=r.useMemo(()=>j.map(b=>({provider:b,models:ze(b.value,i)})).filter(b=>b.models.length>0),[j,i]),S=Ea(c),x=Lt(l.defaultChatProvider,l.defaultChatModel,i)?` · ${La(l.codexReasoningEffort)} reasoning`:"",R=Ta(S,u.defaultModelRef??null)&&N===u.creationMode&&f===u.autoApproveEvidence;r.useEffect(()=>{o(Qe(u.defaultModelRef)),p(u.creationMode),d(u.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,u.autoApproveEvidence,u.creationMode,u.defaultModelRef]);async function I(b){if(b.preventDefault(),!!s){m(!0),a(null);try{n(await $.savePreferences(s,{training:{defaultModelRef:S,creationMode:N,autoApproveEvidence:f}}))}catch(D){a(D instanceof Error?D.message:String(D))}finally{m(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${t?" embedded":""}`,children:[t?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:b=>{I(b)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Taskset authoring"}),e.jsx("small",{children:"The coding model that proposes tasks, graders, fixtures, and policy boundaries"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Authoring model"}),e.jsxs("select",{value:c,disabled:h,onChange:b=>o(b.target.value),children:[e.jsxs("option",{value:ds,children:["Use chat default — ",Ee(l.defaultChatProvider,i)," · ",ts(l.defaultChatModel,i,l.defaultChatProvider),x]}),k.map(b=>e.jsx("optgroup",{label:b.provider.label,children:b.models.map(D=>e.jsx("option",{value:Qe({providerId:b.provider.value,modelId:D.value}),children:D.label},D.value))},b.provider.value))]}),e.jsx("small",{children:"By default, /train follows the same provider, model, and reasoning level selected for chat."})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Default flow"}),e.jsx("small",{children:"Used by /train and Task Creator unless you choose another mode"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Task Creator mode"}),e.jsxs("select",{value:N,disabled:h,onChange:b=>p(b.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:f,disabled:h,onChange:b=>d(b.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:h||R,children:e.jsx("span",{children:h?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:S?`${Ee(S.providerId,i)} / ${ts(S.modelId,i,S.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function Qe(s){return s?JSON.stringify([s.providerId,s.modelId]):ds}function Ea(s){if(s===ds)return null;try{const t=JSON.parse(s);return!Array.isArray(t)||t.length!==2||typeof t[0]!="string"||typeof t[1]!="string"?null:{providerId:t[0],modelId:t[1]}}catch{return null}}function La(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function Ta(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function Xs({disabled:s,onChange:t,purpose:a="model",storageRoots:n,value:l}){const i=r.useId(),[u,c]=r.useState(!1),o=Is(l),N=d=>a==="dataset"?d.datasetStorePath:d.modelStorePath,p=a==="dataset"?"Dataset":"Model",f=n.find(d=>Is(N(d))===o)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:i,children:[p," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${p} storage drive`,className:"model-storage-select",disabled:s,id:i,title:l??`No ${a} storage configured`,value:l??"",onChange:d=>t(d.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),l&&!f?e.jsx("option",{value:l,children:"Manual location"}):null,n.map(d=>e.jsxs("option",{disabled:!d.mounted||!d.writable,title:N(d),value:N(d),children:[d.label," · ",Ba(d.kind)," · ",_a(d)]},d.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":`Add manual ${a} storage location`,onClick:()=>c(!0),children:e.jsx(me,{size:15})})]}),u?Oa(e.jsx(Ua,{initialPath:l??"",purpose:a,onClose:()=>c(!1),onUse:d=>{t(d),c(!1)}})):null]})}function Oa(s){return typeof document>"u"?s:Yt.createPortal(s,document.body)}function Ua({initialPath:s,onClose:t,onUse:a,purpose:n="model"}){const l=r.useId(),[i,u]=r.useState(s),c=za(i);r.useEffect(()=>{const N=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);function o(N){N.preventDefault(),N.stopPropagation(),!c&&a(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${n} storage`,onClick:t,children:e.jsx(ie,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Qt,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",n," storage"]}),e.jsx("p",{children:"Enter an absolute path to a folder mounted on this machine."}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Mounted folder path"}),e.jsx("input",{autoFocus:!0,spellCheck:!1,value:i,placeholder:n==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:N=>u(N.target.value)})]}),e.jsx("div",{className:"model-storage-dialog-note",children:"For SMB, connect the share in Files or Finder first, then paste its mounted folder path. OpenPond uses your operating system’s existing connection and credentials."}),i.trim()&&c?e.jsx("div",{className:"profile-dialog-warning",children:c}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:t,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!c,type:"submit",children:"Use location"})]})]})})}function za(s){const t=s.trim();return t?/^[a-z][a-z\d+.-]*:\/\//i.test(t)?"Use the mounted folder path, not an smb:// or other network URL.":t==="~"||t.startsWith("~/")||t.startsWith("/")||t.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(t)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function Ba(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function _a(s){return s.mounted?s.writable?`${Ha(s.freeBytes)} free`:"Read only":"Not mounted"}function Is(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Ha(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function Fa({state:s,busy:t,title:a="Compute",onScan:n,onSave:l,onDownloadSmolLm2:i,onCancelDownload:u}){const c=s?.inventory??null,[o,N]=r.useState(s?.settings.modelStorePath??null),[p,f]=r.useState(s?.settings.defaultDeviceIds[0]??"automatic");r.useEffect(()=>{N(s?.settings.modelStorePath??null)},[s?.settings.modelStorePath]),r.useEffect(()=>{f(s?.settings.defaultDeviceIds[0]??"automatic")},[s?.settings.defaultDeviceIds]);const d=o===(s?.settings.modelStorePath??null)&&p===(s?.settings.defaultDeviceIds[0]??"automatic"),h=r.useMemo(()=>c?.devices.filter(x=>x.kind!=="cpu"&&x.available)??[],[c?.devices]),m=c?.models.find(x=>x.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,j=[...c?.downloads??[]].reverse().find(x=>x.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,k=!!(j&&["queued","downloading","verifying","cancelling"].includes(j.status));async function S(x){x.preventDefault(),await l(o,s?.settings.datasetStorePath??null,p==="automatic"?[]:[p])}return e.jsxs("section",{className:"account-settings compute-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsx("h1",{children:a}),e.jsx("button",{className:"settings-icon-button",type:"button",title:"Scan compute","aria-label":"Scan compute",disabled:t!==null,onClick:()=>{n()},children:e.jsx(te,{size:15,className:t==="scan"?"settings-spin":void 0})})]}),e.jsx("div",{className:"account-summary",children:e.jsx("div",{className:"account-summary-main compute-summary-main",children:e.jsxs("div",{children:[e.jsx("strong",{children:c?`${c.host.operatingSystem} · ${c.host.architecture}`:t==="load"?"Loading this machine":"This machine has not been scanned"}),e.jsx("small",{children:c?`${c.devices.length} device${c.devices.length===1?"":"s"} · ${Ce(c.host.totalMemoryBytes)} memory · scanned ${Va(c.scannedAt)}`:"Run a bounded native scan to discover local training capabilities."})]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:x=>{S(x)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Defaults"})}),e.jsx(Xs,{disabled:t!==null,storageRoots:c?.storageRoots??[],value:o,onChange:N}),e.jsx("div",{className:"provider-settings-grid single compute-device-default",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default device"}),e.jsxs("select",{value:p,disabled:t!==null,onChange:x=>f(x.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),h.map(x=>e.jsx("option",{value:x.id,children:x.name},x.id))]})]})}),e.jsx("button",{className:"settings-primary",disabled:t!==null||d,children:t==="save"?"Saving":"Save compute settings"})]}),e.jsx($s,{title:"Devices",empty:"No devices discovered",rows:(c?.devices??[]).map(x=>({id:x.id,title:x.name,detail:Ga(x),meta:x.available?"Available":x.unavailableReason??"Unavailable"}))}),e.jsx($s,{title:"Runtimes",empty:"No runtimes discovered",rows:(c?.runtimes??[]).map(x=>({id:x.id,title:qa(x.kind),detail:x.version??x.detail??"Not installed",meta:x.state==="available"?"Available":"Unavailable"}))}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Models"}),e.jsxs("div",{className:"compute-heading-actions",children:[k&&j?e.jsx("button",{type:"button",className:"settings-secondary",disabled:j.status==="cancelling",onClick:()=>{u(j.id)},children:j.status==="cancelling"?"Cancelling":"Cancel"}):m?null:e.jsx("button",{type:"button",className:"settings-secondary",disabled:!s?.settings.modelStorePath,onClick:()=>{i()},children:"Download SmolLM2"}),e.jsx("small",{children:c?.models.length??0})]})]}),j&&!m?e.jsxs("div",{className:"compute-download-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"SmolLM2 135M Instruct"}),e.jsx("small",{children:j.status==="failed"?j.error:`${Wa(j.status)} · ${Ce(j.downloadedBytes)} of ${Ce(j.expectedBytes)} · Apache-2.0`})]}),e.jsx("progress",{max:j.expectedBytes,value:j.downloadedBytes})]}):null,c?.models.length?c.models.map(x=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:x.name}),e.jsxs("small",{children:[x.source," · ",x.format," · ",Ce(x.sizeBytes)]})]}),e.jsx("span",{children:x.trainingCompatible?"Trainable":x.inferenceCompatible?"Inference only":"Unsupported"})]},x.id)):j?null:e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"No recognized local models"})})]}),c?.warnings.length?e.jsxs("details",{className:"compute-diagnostics",children:[e.jsx("summary",{children:"Diagnostics"}),e.jsx("ul",{children:c.warnings.map(x=>e.jsx("li",{children:x},x))})]}):null]})}function $s({title:s,empty:t,rows:a}){return e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:s}),e.jsx("small",{children:a.length})]}),a.length?a.map(n=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:n.title}),e.jsx("small",{children:n.detail})]}),e.jsx("span",{children:n.meta})]},n.id)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t})})]})}function Ga(s){return[s.vendor,s.kind,s.totalMemoryBytes?Ce(s.totalMemoryBytes):null,s.computeCapability?`compute ${s.computeCapability}`:null].filter(Boolean).join(" · ")}function qa(s){return s==="trl_peft"?"TRL / PEFT":s.toUpperCase()}function Wa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Va(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Ce(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function Ka({state:s,catalog:t,busy:a,catalogLoading:n,onRefresh:l,onSave:i}){const[u,c]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{c(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const o=r.useMemo(()=>s?.inventory?.storageRoots.find(d=>Ms(d.datasetStorePath)===Ms(u))??null,[u,s?.inventory?.storageRoots]),N=u===(s?.settings.datasetStorePath??null),p=t?.datasets??[];async function f(d){d.preventDefault(),await i(u)}return e.jsxs("section",{className:"account-settings compute-settings dataset-storage-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Dataset Storage"}),e.jsx("p",{className:"dataset-storage-intro",children:"Choose where Dataset artifacts are saved and review registered Datasets without loading their rows."})]}),e.jsx("button",{"aria-label":"Refresh Dataset storage",className:"settings-icon-button",disabled:a!==null||n,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(te,{className:n?"settings-spin":void 0,size:15})})]}),e.jsx("div",{className:"account-summary",children:e.jsx("div",{className:"account-summary-main compute-summary-main",children:e.jsxs("div",{children:[e.jsx("strong",{children:o?.label??(u?"Manual location":"Not configured")}),e.jsx("small",{children:u??"Choose a writable local or mounted location before importing a Dataset."}),o?e.jsxs("small",{children:[Za(o.kind)," · ",o.freeBytes==null?"Free space unknown":`${et(o.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{f(d)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(Xs,{disabled:a!==null,onChange:c,purpose:"dataset",storageRoots:s?.inventory?.storageRoots??[],value:u}),e.jsx("button",{className:"settings-primary",disabled:a!==null||N,children:a==="save"?"Saving":"Save Dataset storage"})]}),e.jsxs("div",{className:"account-list dataset-storage-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Registered Datasets"}),e.jsx("small",{children:p.length})]}),p.length?p.map(d=>e.jsx(Ja,{dataset:d},d.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:n?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Ja({dataset:s}){const t=s.storageKind==="parquet"?"Parquet":"Inline Taskset";return e.jsxs("div",{className:"compute-row dataset-storage-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[st(s.rowCount)," rows"," · ",Ya(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":et(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?Qa(s.status):"Unavailable"})]})}function Ya(s){return[["train",s.splitCounts.train],["validation",s.splitCounts.validation],["test",s.splitCounts.test],["frozen eval",s.splitCounts.frozen_eval]].filter(([,a])=>Number(a)>0).map(([a,n])=>`${st(Number(n))} ${a}`).join(" · ")||"No split rows"}function et(s){if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let a=s,n=-1;do a/=1024,n+=1;while(a>=1024&&n<t.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${t[n]}`}function st(s){return new Intl.NumberFormat().format(s)}function Ms(s){return s?.replace(/[\\/]+$/,"")??""}function Qa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Za(s){return s.replace(/^./,t=>t.toUpperCase())}function ve(s){if(!s)return"Not yet";const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function ke(s){return s?s.slice(0,10):"none"}function Ue(s){return s.replaceAll("_"," ")}function Xa({review:s}){const t=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:t.map(([a,n])=>e.jsxs("div",{className:n?"linked":"pending",children:[e.jsx("span",{children:a}),e.jsx("code",{children:n?ke(n.contentHash):"Not created"})]},a))})}function el({accepting:s,onAcceptTasksetReview:t,review:a}){const n=a.classification==="taskset"&&a.nextAuthority==="human_review"&&a.tasksetProposal===null;return e.jsxs("article",{className:"harness-history-card harness-evaluation-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:`harness-status harness-status-${a.classification}`,children:Ue(a.classification)}),e.jsx("span",{children:Ue(a.nextAuthority)})]}),e.jsx("h2",{children:a.claim?.statement??a.reason})]}),e.jsx("time",{children:ve(a.createdAt)})]}),e.jsx("p",{children:a.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.claim?.independentOccurrences??0})," independent occurrences"]}),e.jsxs("span",{children:[e.jsxs("strong",{children:["$",a.maxEstimatedCostUsd.toFixed(2)]})," maximum cost"]})]}),e.jsx(Xa,{review:a}),n?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>t(a),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null,e.jsxs("footer",{children:[e.jsxs("span",{children:["Watermark ",ve(a.nextWatermark.throughCreatedAt)]}),e.jsx("code",{children:ke(a.nextWatermark.cursor)})]})]})}function sl({receipt:s}){return e.jsxs("article",{className:"harness-route-card harness-qualification-card",children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:Ue(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsx("time",{children:ve(s.createdAt)})]}),e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("small",{children:["Review ",ke(s.review.contentHash)," · Taskset ",ke(s.tasksetRelease?.contentHash)," · Baseline ",ke(s.baselineEvaluation?.contentHash)," · maximum $",s.maximumCostUsd.toFixed(2)]})]})}function tl({acceptingReviewId:s,backgroundReviewBusy:t,backgroundReviewEnabled:a,busy:n,onBackgroundReviewChange:l,onAcceptTasksetReview:i,reviews:u,qualifications:c,schedule:o,onReview:N,onSaveSchedule:p}){const[f,d]=r.useState(o.cadence),[h,m]=r.useState(o.enabled),[j,k]=r.useState(String(o.maxEstimatedCostUsd));r.useEffect(()=>{d(o.cadence),m(o.enabled),k(String(o.maxEstimatedCostUsd))},[o]);const S=Number(j),x=Number.isFinite(S)&&S>=0,R=u[0]??null,I=r.useMemo(()=>f!==o.cadence||h!==o.enabled||x&&S!==o.maxEstimatedCostUsd,[f,h,S,o,x]);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Continuous learning"}),e.jsx("p",{children:"Refine completed turns quickly, then review related evidence over time. Neither loop starts training or activates a Model."})]}),e.jsx("button",{className:"settings-primary compact",disabled:n||!x,onClick:()=>N(S),type:"button",children:n?"Reviewing…":"Review now"})]}),e.jsxs("section",{className:"account-list harness-review-controls","aria-label":"Continuous learning controls",children:[e.jsxs("div",{className:"account-list-row",children:[e.jsxs("div",{className:"account-list-copy",children:[e.jsx("strong",{children:"Refine completed turns"}),e.jsx("span",{children:"Run the fast model-driven Refiner after each completed turn. Already queued work may finish after this is turned off."})]}),e.jsxs("label",{className:"provider-toggle","aria-label":"Refine completed turns",children:[e.jsx("input",{checked:a,disabled:t,onChange:b=>l(b.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsxs("div",{className:"account-list-row",children:[e.jsxs("div",{className:"account-list-copy",children:[e.jsx("strong",{children:"Review recurring patterns"}),e.jsx("span",{children:"Let the model compare authorized evidence and prior Harness outcomes. Unchanged windows do not call the model."})]}),e.jsxs("label",{className:"provider-toggle","aria-label":"Review recurring patterns",children:[e.jsx("input",{checked:h,disabled:n,onChange:b=>{const D=b.target.checked,P=D&&f==="manual"?"daily":f;m(D),d(P),x&&p({enabled:D,cadence:P,maxEstimatedCostUsd:S})},type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsxs("div",{className:"harness-review-control-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Cadence"}),e.jsxs("select",{disabled:n,onChange:b=>{const D=b.target.value;d(D),D==="manual"&&m(!1)},value:f,children:[e.jsx("option",{value:"manual",children:"Manual only"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Maximum estimated cost (USD)"}),e.jsx("input",{disabled:n,min:0,onChange:b=>k(b.target.value),step:"0.01",type:"number",value:j})]}),e.jsx("button",{className:"settings-secondary compact",disabled:n||!I||!x,onClick:()=>p({enabled:h,cadence:f,maxEstimatedCostUsd:S}),type:"button",children:"Save schedule"})]}),e.jsxs("div",{className:"harness-review-status-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Last result"}),e.jsx("strong",{children:R?Ue(R.classification):"No review"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Last run"}),e.jsx("strong",{children:ve(o.lastRunAt)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Next run"}),e.jsx("strong",{children:o.enabled?ve(o.nextRunAt):"Manual"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Watermark"}),e.jsx("strong",{children:R?ve(R.nextWatermark.throughCreatedAt):"Not established"})]})]}),o.lastError?e.jsxs("p",{className:"harness-review-error",children:["Last scheduled run: ",o.lastError]}):null]})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Evaluation reviews"}),e.jsx("p",{children:"Immutable review receipts and their downstream lineage."})]}),e.jsx("span",{children:u.length})]}),u.length?u.map(b=>e.jsx(el,{accepting:s===b.id,onAcceptTasksetReview:i,review:b},`${b.id}:${b.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No model improvement reviews have run."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Training qualifications"}),e.jsx("p",{children:"Evidence-bound decisions that permit a specific training method or record why training is not warranted."})]}),e.jsx("span",{children:c.length})]}),c.length?c.map(b=>e.jsx(sl,{receipt:b},`${b.id}:${b.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No review has reached training qualification."})]})]})}const nl={enabled:!0,cadence:"daily",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null};function Ie(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Ae(s){return s?s.slice(0,10):"none"}function Es(s,t,a){return{workspaceId:s,baseRelease:t?{id:t.id,contentHash:t.contentHash}:null,targetRelease:{id:a.id,contentHash:a.contentHash},title:a.current?"Current Harness release":`Harness release ${Ae(a.contentHash)}`}}function al({change:s,onOpenDiff:t,onOpenSourceSession:a}){const n=s.trigger?.runRef??null,l=s.proposal;return e.jsxs("article",{className:"harness-history-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:`harness-status harness-status-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("span",{children:l?.route??(s.receipt.rollbackOf?"rollback":"workspace")})]}),e.jsx("h2",{children:l?.expectedOutcome??s.receipt.reason})]}),e.jsx("time",{children:Ie(s.receipt.createdAt)})]}),e.jsxs("div",{className:"harness-history-release-flow",children:[e.jsx("code",{children:Ae(s.receipt.previousRelease?.contentHash)}),e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("code",{children:Ae(s.receipt.nextRelease?.contentHash)}),e.jsxs("span",{children:["channel ",s.receipt.previousChannelRevision," → ",s.receipt.nextChannelRevision]})]}),e.jsx("p",{children:s.receipt.reason}),t||n&&a?e.jsxs("div",{className:"harness-history-actions",children:[t?e.jsx("button",{className:"settings-secondary compact",onClick:t,type:"button",children:"View release diff"}):null,n&&a?e.jsx("button",{className:"settings-secondary compact",onClick:()=>a(n),type:"button",children:"Open source conversation"}):null]}):null,l?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Review ",l.edits.length," exact edit",l.edits.length===1?"":"s"]}),e.jsx("div",{className:"harness-edit-list",children:l.edits.map(i=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[i.operation," · ",i.target]}),e.jsx("span",{children:i.summary})]}),i.content!==null?e.jsx("pre",{children:i.content}):e.jsx("p",{children:"File deleted."})]},i.id))})]}):null,s.validations.length?e.jsx("div",{className:"harness-validation-list",children:s.validations.map(i=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${i.status}`,children:i.status}),e.jsx("strong",{children:i.kind.replaceAll("_"," ")}),e.jsx("span",{children:i.summary})]},i.id))}):null,s.outcome?e.jsxs("footer",{children:[e.jsxs("span",{children:["Refiner: ",s.outcome.decision.replaceAll("_"," ")]}),e.jsxs("span",{children:["Estimated cost $",s.outcome.estimatedCostUsd.toFixed(4)]})]}):null]})}function ll({route:s}){return e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"recommendation"}),e.jsx("strong",{children:s.decision.route}),e.jsx("time",{children:Ie(s.decision.createdAt)})]}),e.jsx("p",{children:s.decision.reason}),s.trigger?e.jsxs("small",{children:["Triggered by ",s.trigger.reason]}):null]})}function il({review:s,busy:t,onReview:a}){return e.jsxs("article",{className:"harness-history-card harness-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"review required"}),e.jsxs("span",{children:[s.proposal.route," · ",s.proposal.edits[0]?.operation??"change"]})]}),e.jsx("h2",{children:s.proposal.expectedOutcome})]}),e.jsx("time",{children:Ie(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(n=>n.summary).join(" ")}),e.jsxs("details",{className:"harness-history-details",open:!0,children:[e.jsxs("summary",{children:["Review ",s.proposal.edits.length," exact edit",s.proposal.edits.length===1?"":"s"]}),e.jsx("div",{className:"harness-edit-list",children:s.proposal.edits.map(n=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[n.operation," · ",n.target]}),e.jsx("span",{children:n.summary})]}),n.content!==null?e.jsx("pre",{children:n.content}):e.jsx("p",{children:"File deleted."})]},n.id))})]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(n=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${n.status}`,children:n.status}),e.jsx("strong",{children:n.kind.replaceAll("_"," ")}),e.jsx("span",{children:n.summary})]},n.id))}),e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:t,onClick:()=>a(s,"decline"),type:"button",children:[e.jsx(ie,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:t||s.validations.some(n=>n.status!=="passed"),onClick:()=>a(s,"approve"),type:"button",children:[e.jsx(Os,{size:13})," Approve and release"]})]})]})}function rl({baseRelease:s,release:t,busy:a,onOpenDiff:n,onRollback:l}){const[i,u]=r.useState(!1);return e.jsxs("div",{className:"harness-release-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.current?"Current release":t.id}),e.jsxs("span",{children:[Ae(t.contentHash)," · ",t.files.length," files · ",Ie(t.createdAt)]})]}),i?e.jsxs("div",{className:"harness-inline-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:a,onClick:()=>u(!1),type:"button",children:[e.jsx(ie,{size:13})," Cancel"]}),e.jsxs("button",{className:"settings-primary compact",disabled:a,onClick:()=>{u(!1),l(t)},type:"button",children:[e.jsx(Te,{size:13})," Confirm rollback"]})]}):e.jsxs("div",{className:"harness-inline-actions",children:[t.current?e.jsx("span",{className:"harness-current-pill",children:"current"}):null,e.jsx("button",{className:"settings-secondary compact",onClick:()=>n(s,t),type:"button",children:"View changes"}),t.current?null:e.jsxs("button",{className:"settings-secondary compact",disabled:a,onClick:()=>u(!0),type:"button",children:[e.jsx(Te,{size:13})," Roll back"]})]})]})}function ol({connection:s,enabled:t,onAcceptEvaluationReview:a,onError:n,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:u,onToast:c}){const[o,N]=r.useState(null),[p,f]=r.useState(!1),[d,h]=r.useState(null),[m,j]=r.useState(null),[k,S]=r.useState(!1),[x,R]=r.useState(!1),[I,b]=r.useState(null),[D,P]=r.useState(!1),O=r.useCallback(async()=>{if(s){f(!0);try{const v=await $.harnessHistory(s);N(v);const A=v.releases.findIndex(J=>J.current),q=A>=0?v.releases[A]:null;v.workspace&&q&&l(Es(v.workspace.id,v.releases[A+1]??null,q)),n(null)}catch(v){n(v instanceof Error?v.message:String(v))}finally{f(!1)}}},[s,l,n]);r.useEffect(()=>{t&&O()},[t,O]);const g=r.useMemo(()=>o?.releases.find(v=>v.current)??null,[o]),C=r.useCallback(async v=>{if(!(!s||!o?.workspace)){S(!0);try{const A=await $.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:v});N(A.history),n(null),c?.(v?"Harness background review enabled.":"Harness background review disabled.","info")}catch(A){n(A instanceof Error?A.message:String(A))}finally{S(!1)}}},[s,o?.workspace,n,c]),w=r.useCallback(async v=>{if(!(!s||!o?.workspace)){R(!0);try{const A=await $.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:v});N(A.history),n(null),c?.(`Harness review completed: ${A.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(A){n(A instanceof Error?A.message:String(A))}finally{R(!1)}}},[s,o?.workspace,n,c]),y=r.useCallback(async v=>{if(!(!s||!o?.workspace)){P(!0);try{const A=await $.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,...v});N(A.history),n(null),c?.(v.enabled?"Harness review schedule saved.":"Harness review schedule disabled.","info")}catch(A){n(A instanceof Error?A.message:String(A))}finally{P(!1)}}},[s,o?.workspace,n,c]),E=r.useCallback(async v=>{if(o?.workspace){b(v.id);try{await a(o.workspace.id,{id:v.id,contentHash:v.contentHash})&&(n(null),c?.("Taskset review opened in Models.","success"))}catch(A){n(A instanceof Error?A.message:String(A))}finally{b(null)}}},[o?.workspace,a,n,c]),L=r.useCallback((v,A)=>{o?.workspace&&i(Es(o.workspace.id,v,A))},[o?.workspace,i]),G=r.useCallback(v=>{!o?.workspace||!v.receipt.nextRelease||i({workspaceId:o.workspace.id,baseRelease:v.receipt.previousRelease,targetRelease:v.receipt.nextRelease,title:v.proposal?.expectedOutcome??v.receipt.reason})},[o?.workspace,i]),K=r.useCallback(async v=>{if(!(!s||!o?.workspace)){h(v.contentHash);try{const A=await $.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:v.id,contentHash:v.contentHash}});N(A.history),n(null),c?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(A){n(A instanceof Error?A.message:String(A))}finally{h(null)}}},[s,o?.workspace,n,c]),Q=r.useCallback(async(v,A)=>{if(!(!s||!o?.workspace)){j(v.proposal.id);try{const q=await $.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:v.proposal.id,contentHash:v.proposal.contentHash},decision:A});N(q.history),n(null),c?.(A==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",A==="approve"?"success":"info")}catch(q){n(q instanceof Error?q.message:String(q))}finally{j(null)}}},[s,o?.workspace,n,c]);return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:"Harness"}),e.jsx("p",{children:"Immutable releases, Refiner changes, validation evidence, and rollback history."})]}),e.jsxs("button",{className:"settings-secondary",disabled:p,onClick:()=>{O()},type:"button",children:[e.jsx(te,{className:p?"settings-spin":void 0,size:14})," Refresh"]})]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&p&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-summary-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Workspace"}),e.jsx("strong",{children:o.workspace.name})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Current release"}),e.jsx("strong",{children:Ae(g?.contentHash)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Channel revision"}),e.jsx("strong",{children:o.workspace.currentChannel.revision})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Status"}),e.jsx("strong",{children:o.workspace.dirty?"Unreleased changes":"Clean"})]})]}),e.jsx(tl,{acceptingReviewId:I,backgroundReviewBusy:k,backgroundReviewEnabled:o.backgroundReview.enabled,busy:x||D,onBackgroundReviewChange:v=>{C(v)},onAcceptTasksetReview:v=>{E(v)},onReview:v=>{w(v)},onSaveSchedule:v=>{y(v)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??nl}),e.jsxs("section",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Releases"}),e.jsx("small",{children:"New runs use current; active runs stay pinned."})]}),o.releases.map((v,A)=>e.jsx(rl,{baseRelease:o.releases[A+1]??null,busy:d!==null,onOpenDiff:L,onRollback:K,release:v},`${v.id}:${v.contentHash}`))]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Needs review"}),e.jsx("p",{children:"Executable, Agent, destructive, and sensitive changes never advance without your approval."})]}),e.jsx("span",{children:o.pendingReviews.length})]}),o.pendingReviews.length?o.pendingReviews.map(v=>e.jsx(il,{busy:m!==null,onReview:Q,review:v},`${v.proposal.id}:${v.proposal.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No Harness proposals need review."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Applied history"}),e.jsx("p",{children:"Every release transition with its exact change and validation receipts."})]}),e.jsx("span",{children:o.changes.length})]}),o.changes.length?o.changes.map(v=>e.jsx(al,{change:v,onOpenDiff:v.receipt.nextRelease?()=>G(v):void 0,onOpenSourceSession:u},`${v.receipt.id}:${v.receipt.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No Harness changes have been applied."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Routed recommendations"}),e.jsx("p",{children:"Runtime, memory, product, Taskset, and training observations that did not mutate the Harness."})]}),e.jsx("span",{children:o.routes.length})]}),o.routes.length?o.routes.map(v=>e.jsx(ll,{route:v},`${v.decision.id}:${v.decision.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No external recommendations have been routed."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{children:"Bounded external memory available through search; it is not copied into every Agent prompt or sandbox."})]}),e.jsx("span",{children:o.memories.length})]}),o.memories.length?o.memories.map(v=>e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:v.key}),e.jsxs("span",{children:["revision ",v.revision]}),e.jsx("time",{children:Ie(v.updatedAt)})]}),e.jsx("p",{children:v.content}),v.tags.length?e.jsx("small",{children:v.tags.join(" · ")}):null]},`${v.id}:${v.revision}`)):e.jsx("div",{className:"harness-empty",children:"No Harness memory has been saved."})]})]}):null]})}function Ls(s){return s?s.slice(0,10):"initial"}function cl({connection:s,expanded:t,onResizeStart:a,onToggleExpanded:n,selection:l}){const[i,u]=r.useState(null),[c,o]=r.useState(null),[N,p]=r.useState(!0),f=r.useCallback(async()=>{o(null),p(!0);try{u(await $.harnessReleaseDiff(s,l))}catch(m){u(null),o(m instanceof Error?m.message:String(m))}finally{p(!1)}},[s,l]);r.useEffect(()=>{f()},[f]);const d=r.useMemo(()=>i?{appId:`harness:${l.workspaceId}`,repoPath:l.title,initialized:!0,dirty:i.filesChanged>0,filesChanged:i.filesChanged,additions:i.additions,deletions:i.deletions,repoFiles:i.files.map(m=>m.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),h=`${l.title} · ${Ls(l.baseRelease?.contentHash)} → ${Ls(l.targetRelease.contentHash)}`;return e.jsx(Zt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:d,editorPreferences:null,expanded:t,filesWithPreview:!0,loading:N,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:a,onToggleExpanded:n,readOnly:!0,workspaceError:c,workspaceInitialized:!0,workspaceName:h})}function dl({connection:s,onError:t,onPayload:a}){const[n,l]=r.useState(!1),[i,u]=r.useState(!1);async function c(f,d){if(s){l(!0),t(null);try{const h=await $.switchOpenPondAccount(s,{handle:f,baseUrl:d??null}),m=await $.savePreferences(s,{defaultTeamId:null});a({...h,preferences:m.preferences})}catch(h){t(h instanceof Error?h.message:String(h))}finally{l(!1)}}}async function o(f,d){if(!s)return!1;l(!0),t(null);try{return a(await $.removeOpenPondAccount(s,{handle:f,baseUrl:d??null})),!0}catch(h){return t(h instanceof Error?h.message:String(h)),!1}finally{l(!1)}}async function N(f){if(!(!s||!f.apiKey.trim())){l(!0),t(null);try{const d=f.handle?.trim(),h=f.environment?.trim(),m=await $.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:d||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:h||"custom",setActive:!0}),j=await $.savePreferences(s,{defaultTeamId:null});a({...m,preferences:j.preferences})}catch(d){throw t(d instanceof Error?d.message:String(d)),d}finally{l(!1)}}}async function p(){if(s){u(!0),t(null);try{a(await $.refreshOpenPondAccounts(s))}catch(f){t(f instanceof Error?f.message:String(f))}finally{u(!1)}}}return{refreshingAccounts:i,saving:n,refreshAccounts:p,removeAccount:o,saveAccount:N,switchAccount:c}}function ul({connection:s,onError:t,onPreferences:a,preferences:n,providers:l}){const[i,u]=r.useState(n.defaultBranchPrefix),[c,o]=r.useState(n.defaultNewProjectDirectory),[N,p]=r.useState(n.advancedWorkspaceControls),[f,d]=r.useState(n.contextCompaction.autoEnabled),[h,m]=r.useState(n.subagents.enabled),[j,k]=r.useState(n.subagents.delegationMode),[S,x]=r.useState(!n.subagents.defaultModelRef),[R,I]=r.useState(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),[b,D]=r.useState(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),[P,O]=r.useState(n.subagents.roles),[g,C]=r.useState(n.subagents.maxConcurrentRuns),[w,y]=r.useState(n.subagents.maxConcurrentRunsPerProvider),[E,L]=r.useState(n.subagents.maxConcurrentRunsPerWorkspaceTarget),[G,K]=r.useState(!1),Q=S?null:{providerId:R,modelId:b.trim()},v=h!==n.subagents.enabled||j!==n.subagents.delegationMode||!hl(Q,n.subagents.defaultModelRef)||g!==n.subagents.maxConcurrentRuns||w!==n.subagents.maxConcurrentRunsPerProvider||E!==n.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(P)!==JSON.stringify(n.subagents.roles);r.useEffect(()=>{u(n.defaultBranchPrefix),o(n.defaultNewProjectDirectory),p(n.advancedWorkspaceControls),d(n.contextCompaction.autoEnabled),m(n.subagents.enabled),k(n.subagents.delegationMode),x(!n.subagents.defaultModelRef),I(n.subagents.defaultModelRef?.providerId??n.defaultChatProvider),D(n.subagents.defaultModelRef?.modelId??n.defaultChatModel),O(n.subagents.roles),C(n.subagents.maxConcurrentRuns),y(n.subagents.maxConcurrentRunsPerProvider),L(n.subagents.maxConcurrentRunsPerWorkspaceTarget)},[n.defaultChatProvider,n.defaultChatModel,n.defaultBranchPrefix,n.defaultNewProjectDirectory,n.advancedWorkspaceControls,n.contextCompaction.autoEnabled,n.subagents]);function A(T){I(T),D(B=>ns(T,B,l))}function q(){return S?n.defaultChatProvider:R}function J(){return S?n.defaultChatModel:b}function W(T,B){O(H=>H.map(z=>z.id===T?B(z):z))}function X(T,B){W(T,H=>({...H,enabled:B}))}function Y(T,B){W(T,H=>({...H,background:B}))}function U(T,B){W(T,H=>{if(B)return{...H,modelRef:null};const z=H.modelRef?.providerId??q(),_=H.modelRef?.modelId??J();return{...H,modelRef:Ge(z,_,l)??null}})}function ne(T,B){W(T,H=>({...H,modelRef:Ge(B,H.modelRef?.modelId??J(),l)??null}))}function re(T,B){W(T,H=>{const z=H.modelRef?.providerId??q(),_=B.trim();return{...H,modelRef:_?{providerId:z,modelId:_}:null}})}function ce(T,B){W(T,H=>({...H,isolationMode:B}))}function V(T,B){W(T,H=>({...H,toolPolicy:B}))}function le(T,B){W(T,H=>({...H,peerMessages:B}))}function se(T,B){W(T,H=>({...H,maxConcurrentRuns:xe(B,1,16)}))}async function fe(){let T=null;if(window.openpond?.selectFolder){const B=await window.openpond.selectFolder();if(B.canceled)return;T=B.path}else T=window.prompt("Default new project directory",c);T?.trim()&&o(T.trim())}async function oe(T){if(T.preventDefault(),!!s){K(!0),t(null);try{a(await $.savePreferences(s,{defaultBranchPrefix:Ze(i),defaultNewProjectDirectory:c.trim(),advancedWorkspaceControls:N,contextCompaction:{...n.contextCompaction,autoEnabled:f},subagents:{enabled:h,workspaceDefaultsVersion:n.subagents.workspaceDefaultsVersion,toolDefaultsVersion:n.subagents.toolDefaultsVersion,delegationMode:j,defaultModelRef:S?null:Ge(R,b,l)??null,roles:P,maxConcurrentRuns:xe(g,1,32),maxConcurrentRunsPerProvider:w===null?null:xe(w,1,32),maxConcurrentRunsPerWorkspaceTarget:E===null?null:xe(E,1,32)}}))}catch(B){t(B instanceof Error?B.message:String(B))}finally{K(!1)}}}return{advancedWorkspaceControls:N,contextCompactionAutoEnabled:f,defaultBranchPrefix:i,defaultNewProjectDirectory:c,subagentsEnabled:h,subagentDelegationMode:j,subagentsUseDefaultModel:S,subagentsProvider:R,subagentsModel:b,subagentRoles:P,subagentsMaxConcurrentRuns:g,subagentsMaxConcurrentRunsPerProvider:w,subagentsMaxConcurrentRunsPerWorkspaceTarget:E,subagentsDirty:v,saving:G,chooseDefaultProjectDirectory:fe,saveDefaults:oe,changeSubagentsProvider:A,changeSubagentRoleProvider:ne,setAdvancedWorkspaceControls:p,setContextCompactionAutoEnabled:d,setDefaultBranchPrefix:u,setDefaultNewProjectDirectory:o,setSubagentsUseDefaultModel:x,setSubagentsModel:D,setSubagentsEnabled:m,setSubagentDelegationMode:T=>k(T),setSubagentsMaxConcurrentRuns:T=>C(xe(T,1,32)),setSubagentsMaxConcurrentRunsPerProvider:T=>y(T===null?null:xe(T,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:T=>L(T===null?null:xe(T,1,32)),setSubagentRoleBackground:Y,setSubagentRoleEnabled:X,setSubagentRoleIsolationMode:ce,setSubagentRoleMaxConcurrentRuns:se,setSubagentRoleModel:re,setSubagentRolePeerMessages:le,setSubagentRoleToolPolicy:V,setSubagentRoleUseDefaultModel:U}}function xe(s,t,a){return Number.isFinite(s)?Math.min(a,Math.max(t,Math.trunc(s))):t}function hl(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const ml=15e3,pl=100,gl=100,fl=2500;function xl({onError:s,section:t}){const[a,n]=r.useState(null),[l,i]=r.useState(null),[u,c]=r.useState(pl),[o,N]=r.useState([]),[p,f]=r.useState(null),[d,h]=r.useState(!0),m=r.useRef(null),[j,k]=r.useState(null),S=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),R=!!window.openpond?.readRecentLogs?`${o.length} of ${u} line${u===1?"":"s"}${d?" tailing":""}`:"Unavailable";r.useEffect(()=>{t==="diagnostics"&&I(u,"refresh",{quiet:!0})},[t]),r.useEffect(()=>{if(t!=="diagnostics"||!d||!window.openpond?.readRecentLogs)return;let C=!1;const w=window.setInterval(()=>{C||(C=!0,I(u,"refresh",{quiet:!0}).finally(()=>{C=!1}))},fl);return()=>window.clearInterval(w)},[t,d,u]),r.useEffect(()=>{if(t!=="diagnostics"||!d)return;const C=m.current;C&&(C.scrollTop=C.scrollHeight)},[t,d,o]);async function I(C=u,w="refresh",y={}){const E=window.openpond?.readRecentLogs;if(!E){const L="Log view is not available in this runtime.";y.quiet||(k({label:"Logs",value:L,warning:!0}),s(L));return}y.quiet||i(w);try{const L=await $e(E(C),"Read logs");if(!L.ok)throw new Error(L.error);c(L.lineLimit),f(L.logDir),N(L.lines),y.quiet?k(G=>G?.label==="Logs"?null:G):k(null)}catch(L){const G=L instanceof Error?L.message:String(L);k({label:"Logs",value:G,warning:!0}),y.quiet||s(G)}finally{y.quiet||i(null)}}function b(){h(!1),I(u+gl,"older")}function D(){const C=!d;h(C),C&&I(u,"refresh",{quiet:!0})}async function P(){const C=window.openpond?.openLogsFolder;if(!C){const w="Desktop logs are not available in this runtime.";k({label:"Logs",value:w,warning:!0}),s(w);return}n("logs"),s(null);try{const w=await $e(C(),"Open logs");if(!w.ok)throw new Error(w.error??"Could not open the logs folder.");k(null)}catch(w){const y=w instanceof Error?w.message:String(w);k({label:"Logs",value:y,warning:!0}),s(y)}finally{n(null)}}async function O(){const C=window.openpond?.copyRecentLogs;if(!C){const w="Recent log copy is not available in this runtime.";k({label:"Copy",value:w,warning:!0}),s(w);return}n("copy"),s(null);try{const w=await $e(C(1e3),"Copy recent logs");if(!w.ok)throw new Error(w.error??"Could not copy recent logs.");k({label:"Copy",value:w.lines?`Copied ${w.lines} recent log lines.`:"Copied recent logs."})}catch(w){const y=w instanceof Error?w.message:String(w);k({label:"Copy",value:y,warning:!0}),s(y)}finally{n(null)}}async function g(){const C=window.openpond?.exportDiagnostics;if(!C){const w="Diagnostics export is not available in this runtime.";k({label:"Export",value:w,warning:!0}),s(w);return}n("export"),s(null);try{const w=await $e(C(),"Export diagnostics");if(!w.ok)throw new Error(w.error??"Could not export diagnostics.");k({label:"Export",value:w.path?`Saved to ${w.path}`:"Diagnostics exported."})}catch(w){const y=w instanceof Error?w.message:String(w);k({label:"Export",value:y,warning:!0}),s(y)}finally{n(null)}}return{diagnosticsAvailable:S,diagnosticsBusy:a,diagnosticsStatus:j,logDir:p,logLineLimit:u,logLines:o,logViewBusy:l,logViewSummary:R,logViewportRef:m,tailLogs:d,copyRecentLogs:O,exportDiagnosticsBundle:g,loadOlderLogs:b,openLogsFolder:P,refreshLogView:I,toggleTailLogs:D}}async function $e(s,t){let a;try{return await Promise.race([s,new Promise((n,l)=>{a=window.setTimeout(()=>{l(new Error(`${t} did not receive a desktop response.`))},ml)})])}finally{a!==void 0&&window.clearTimeout(a)}}function jl({connection:s,enabled:t,onError:a,onPreferences:n,onToast:l,preferences:i}){const[u,c]=r.useState(i.editor),[o,N]=r.useState(null),[p,f]=r.useState(!1),[d,h]=r.useState(!1),[m,j]=r.useState(!1);r.useEffect(()=>{c(i.editor)},[i.editor]);const k=r.useCallback(async()=>{if(s){h(!0);try{N(await $.workspaceLspSettingsStatus(s))}catch(b){a(b instanceof Error?b.message:String(b))}finally{h(!1)}}},[s,a]);r.useEffect(()=>{!t||!s||k()},[s,t,k]);function S(b,D){c(P=>({...P,languages:{...P.languages,[b]:{...P.languages[b],mode:D}}}))}function x(b,D){c(P=>({...P,languages:{...P.languages,[b]:{...P.languages[b],customCommand:D}}}))}async function R(b){if(b.preventDefault(),!!s){f(!0),a(null);try{const D=await $.savePreferences(s,{editor:u});n(D),N(await $.workspaceLspSettingsStatus(s))}catch(D){a(D instanceof Error?D.message:String(D))}finally{f(!1)}}}async function I(){if(s){j(!0),a(null);try{await $.restartWorkspaceLsp(s),N(await $.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(b){a(b instanceof Error?b.message:String(b))}finally{j(!1)}}}return{editorPreferences:u,lspStatus:o,restarting:m,saving:p,statusLoading:d,refreshLspStatus:k,restartLanguageServers:I,saveEditorSettings:R,setEditorPreferences:c,setLanguageCustomCommand:x,setLanguageMode:S}}function vl({connection:s,onError:t,onPayload:a,personalization:n}){const l=r.useMemo(()=>n.templates.map(g=>({value:g.id,label:g.name,description:g.id===n.activeTemplateId?"Selected":g.source==="built_in"?g.description:void 0})),[n.activeTemplateId,n.templates]),[i,u]=r.useState(n.activeTemplateId),[c,o]=r.useState(n.soul),[N,p]=r.useState(""),[f,d]=r.useState(!1),[h,m]=r.useState(!1),j=n.templates.find(g=>g.id===i)??n.templates[0],k=j?.source==="custom",S=j?c!==j.content:!0,x=i!==n.activeTemplateId||c!==n.soul||S,R=!!(k&&c.trim()&&j&&x);r.useEffect(()=>{u(n.activeTemplateId),o(n.soul);const g=n.templates.find(C=>C.id===n.activeTemplateId);p(g?`${g.name} Copy`:""),d(!1)},[n.activeTemplateId,n.soul,n.templates]);async function I(g=!1){if(!g&&!k)return;const C=g?N:j?.name;if(!(!s||!c.trim()||!C?.trim())){m(!0),t(null);try{a(await $.savePersonalization(s,{activeTemplateId:i,templateName:C,soul:c,saveAsNew:g})),d(!1)}catch(w){t(w instanceof Error?w.message:String(w))}finally{m(!1)}}}async function b(g){const C=n.templates.find(w=>w.id===g);if(C&&(u(C.id),p(`${C.name} Copy`),o(C.content),d(!1),!!s)){m(!0),t(null);try{a(await $.savePersonalization(s,{activeTemplateId:C.id,templateName:C.name,soul:C.content,saveAsNew:!1}))}catch(w){t(w instanceof Error?w.message:String(w))}finally{m(!1)}}}function D(){j&&(p(`${j.name} Copy`),o(j.content),d(!1))}function P(g){o(g),j&&!k&&g!==j.content&&d(!0)}function O(){j&&(p(`${j.name} Copy`),d(!0))}return{canSaveCurrentTemplate:R,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:f,saving:h,selectedPersonalizationTemplate:j,selectedTemplateIsCustom:k,soulDraft:c,templateNameDraft:N,changePersonalizationTemplate:b,changeSoulDraft:P,openSaveAsNew:O,resetPersonalizationDraft:D,savePersonalization:I,setSaveAsNewOpen:d,setTemplateNameDraft:p}}function bl({connection:s,onError:t,onPreferences:a,onProviders:n,preferences:l,providers:i}){const[u,c]=r.useState(l.defaultChatProvider),[o,N]=r.useState(l.defaultChatModel),[p,f]=r.useState(!1),[d,h]=r.useState(null),[m,j]=r.useState(null);r.useEffect(()=>{c(l.defaultChatProvider),N(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function k(w){if(w.preventDefault(),!!s){f(!0),t(null);try{a(await $.savePreferences(s,{defaultChatProvider:u,defaultChatModel:ns(u,o,i)}))}catch(y){t(y instanceof Error?y.message:String(y))}finally{f(!1)}}}function S(w){c(w),N(y=>ns(w,y,i))}async function x(w,y,E){if(!s)return null;h(`${w}:${y}`),j(null),t(null);try{return await E()}catch(L){return t(L instanceof Error?L.message:String(L)),null}finally{h(null)}}async function R(w,y){await x(w,"config",async()=>{const E=await $.saveProviderSettings(s,{providers:{[w]:y}});return n(E),E})}async function I(w,y){await x(w,"credential",async()=>{const E=await $.saveProviderCredential(s,w,y);return n(E),E})}async function b(w){await x(w,"credential",async()=>{const y=await $.deleteProviderCredential(s,w,{});return n(y),y})}async function D(w){return x("openai","credential",async()=>{const y=await $.startOpenAiSubscriptionAuth(s,{method:w});return y.method==="browser"?(window.open(y.url,"_blank","noopener,noreferrer"),j("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(y.url,"_blank","noopener,noreferrer"),j(`OpenAI device login started. Enter code ${y.userCode}.`)),P(y.expiresAt),y})}async function P(w){if(s)for(;Date.now()<w;){await new Promise(y=>setTimeout(y,2500));try{const y=await $.providerSettings(s);n(y);const E=y.statuses.openai?.credential;if(E?.connected&&E.source==="chatgpt_subscription"){j("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function O(w){await x(w,"models",async()=>{const y=await $.refreshProviderModels(s,w,{force:!0});return n(y.providers),y})}async function g(w){await x(w,"models",async()=>{const y=await $.loadProviderModels(s,w,{limit:500});return n(y.providers),y})}async function C(w,y={}){await x(w,"validate",async()=>{const E=await $.validateProviderCredential(s,w,y);return j(E.ok?`${w} validated${E.modelId?` with ${E.modelId}`:""}.`:E.errors.join(`
|
|
6
|
+
`)||`${w} validation failed.`),n(E.providers),E})}return{defaultModel:o,defaultProvider:u,providerBusy:d,saving:p,validationMessage:m,changeDefaultProvider:S,deleteProviderCredential:b,loadProviderModels:g,refreshProviderModels:O,saveProviderConfig:R,saveProviderCredential:I,saveProviders:k,setDefaultModel:N,startOpenAiSubscriptionAuth:D,validateProvider:C}}function yl({connection:s,enabled:t,onError:a,onToast:n}){const[l,i]=r.useState(null),[u,c]=r.useState(null),[o,N]=r.useState(!1),p=r.useRef(null),f=r.useCallback(async(D={})=>{if(s){D.quiet||c("refresh");try{const P=await $.remoteAccess(s);i(P),a(null)}catch(P){a(P instanceof Error?P.message:String(P))}finally{D.quiet||c(null)}}},[s,a]);r.useEffect(()=>{!t||!s||f({quiet:!0})},[s,t,f]),r.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);function d(){p.current!==null&&window.clearTimeout(p.current),N(!1),window.setTimeout(()=>{N(!0),p.current=window.setTimeout(()=>{N(!1),p.current=null},1500)},0)}async function h(){if(a(null),!!s)try{i(await $.remoteAccess(s))}catch{}}async function m(){if(!s)return null;l&&!l.tailscale.running&&d(),c("enable");try{const D=await $.enableRemoteAccess(s);return i(D.status),a(null),D.status.tailscale.running?!D.status.serve.enabled&&D.status.serve.error&&n?.(D.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":D.message||D.status.serve.error,"error"):(d(),n?.(D.message||"Tailscale is not running. Run Tailscale up first.","error")),D.status}catch{return await h(),d(),n?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{c(null)}}async function j(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){c("disable");try{const D=await $.disableRemoteAccess(s);i(D.status),a(null)}catch{await h()}finally{c(null)}}}async function k(){l?.remoteWebUrl&&(c("copy-link"),await je(l.remoteWebUrl),c(null))}async function S(){l?.serveCommand&&(c("copy-command"),await je(l.serveCommand),c(null))}async function x(){l?.serve.setupUrl&&(c("copy-serve-setup"),await je(l.serve.setupUrl),c(null))}async function R(){l?.tailscaleUpCommand&&(c("copy-up-command"),await je(l.tailscaleUpCommand),c(null))}async function I(){l?.operatorCommand&&(c("copy-operator"),await je(l.operatorCommand),c(null))}async function b(){if(!l?.serve.enabled){const D=await m();D?.serve.enabled&&D.remoteWebUrl&&await je(D.remoteWebUrl);return}await k()}return{status:l,busy:u,flashTailscaleUp:o,refresh:f,enableRemoteAccess:m,disableRemoteAccess:j,copyRemoteLink:k,copyTailscaleUpCommand:R,copyServeCommand:S,copyServeSetupUrl:x,copyOperatorCommand:I,createRemoteLink:b}}function Nl(s){const{connection:t,enabled:a,onError:n}=s,[l,i]=r.useState(null),[u,c]=r.useState(null),o=r.useCallback(async()=>{if(t){c("load");try{const m=await $.computeState(t);i(m),n(null)}catch(m){n(Se(m))}finally{c(null)}}},[t,n]),N=r.useCallback(async()=>{if(t){c("scan");try{const m=await $.scanCompute(t),j=await $.computeState(t);i({...j,inventory:m,scanning:!1}),n(null)}catch(m){n(Se(m))}finally{c(null)}}},[t,n]),p=r.useCallback(async(m,j,k)=>{if(!t)return!1;c("save");try{const S=await $.updateComputeSettings(t,{modelStorePath:m,datasetStorePath:j,defaultDeviceIds:k}),x=await $.computeState(t);return i({...x,settings:S}),n(null),!0}catch(S){return n(Se(S)),!1}finally{c(null)}},[t,n]),f=r.useCallback(async()=>{if(t)try{await $.downloadSmolLm2(t),await o()}catch(m){n(Se(m))}},[t,n,o]),d=r.useCallback(async m=>{if(t)try{await $.cancelModelDownload(t,m),await o()}catch(j){n(Se(j))}},[t,n,o]);r.useEffect(()=>{a&&o()},[a,o]);const h=l?.inventory?.downloads.some(m=>["queued","downloading","verifying","cancelling"].includes(m.status))??!1;return r.useEffect(()=>{if(!a||!h)return;const m=window.setInterval(()=>{o()},1e3);return()=>window.clearInterval(m)},[a,h,o]),{state:l,busy:u,refresh:o,scan:N,save:p,downloadSmolLm2:f,cancelDownload:d}}function Se(s){return s instanceof Error?s.message:String(s)}function wl(s){const{connection:t,enabled:a,onError:n,profileId:l}=s,[i,u]=r.useState(null),[c,o]=r.useState(!1),N=r.useCallback(async()=>{if(t){o(!0);try{u(await $.datasetCatalog(t,l)),n(null)}catch(p){n(Sl(p))}finally{o(!1)}}},[t,n,l]);return r.useEffect(()=>{a&&N()},[a,N]),{catalog:i,loading:c,refresh:N}}function Sl(s){return s instanceof Error?s.message:String(s)}const Cl=r.lazy(()=>Ht(()=>import("./UsageSettingsSection-NbX7_3Uz.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Wl({payload:s,connection:t,diagnostics:a,onPayload:n,onError:l,onToast:i,onBack:u,onOpenSourceSession:c,onAcceptEvaluationReview:o,onOpenSkill:N,onOpenExtension:p,teamChatCurrentUserId:f,teamChatEnabled:d,teamChatNotificationMode:h,teamChatThreads:m,onTeamChatNotificationModeChange:j,onTeamChatThreadMuteChange:k,diffPanelWidth:S,diffPanelResizing:x,diffPanelExpanded:R,onDiffPanelResizeStart:I,onDiffPanelExpandedChange:b,initialSection:D="account"}){const[P,O]=r.useState(D),[g,C]=r.useState(null),[w,y]=r.useState(!1),E=s?.codex??null,L=r.useMemo(()=>Tt(s?.preferences),[s?.preferences]),G=s?.personalization??Ot,K=a??s?.diagnostics??[],Q=Ut()&&zt(t?.platform),v=r.useCallback(_=>{s&&n({...s,providers:_})},[n,s]),A=r.useCallback(_=>{s&&n({...s,preferences:_.preferences})},[n,s]),q=r.useCallback(_=>{s&&n({...s,extensionCatalog:_})},[n,s]),J=dl({connection:t,onError:l,onPayload:n}),W=bl({connection:t,onError:l,onPayload:n,onPreferences:A,onProviders:v,preferences:L,providers:s?.providers??null}),X=ul({connection:t,onError:l,onPayload:n,onPreferences:A,preferences:L,providers:s?.providers??null}),Y=jl({connection:t,enabled:P==="editor",onError:l,onPayload:n,onPreferences:A,onToast:i,preferences:L}),U=vl({connection:t,onError:l,onPayload:n,personalization:G}),ne=xl({onError:l,section:P}),re=yl({connection:t,enabled:P==="remote",onError:l,onToast:i}),ce=P==="dataset-storage",V=Nl({connection:t,enabled:P==="compute"||ce,onError:l}),le=wl({connection:t,enabled:ce,onError:l,profileId:s?.profile.activeProfile??"default"}),se=r.useCallback(_=>V.save(V.state?.settings.modelStorePath??null,_,V.state?.settings.defaultDeviceIds??[]),[V.save,V.state?.settings.defaultDeviceIds,V.state?.settings.modelStorePath]),fe=r.useCallback(async()=>{await Promise.all([V.refresh(),le.refresh()])},[V.refresh,le.refresh]),oe=r.useCallback(()=>P!=="subagents"||!X.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[X.subagentsDirty,P]),T=r.useCallback(_=>{_!==P&&oe()&&(y(!1),b(!1),O(_))},[oe,b,P]),B=r.useCallback(()=>{oe()&&(y(!1),b(!1),u())},[oe,u,b]);r.useEffect(()=>{O(D)},[D]),r.useEffect(()=>{if(P!=="subagents"||!X.subagentsDirty)return;const _=Ne=>{Ne.preventDefault(),Ne.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",_),()=>window.removeEventListener("beforeunload",_)},[X.subagentsDirty,P]);const H={"--diff-panel-width":`${S}px`},z=P==="harness"&&w&&g;return e.jsxs("div",{className:`settings-shell ${Q?"platform-macos":""} ${z?"harness-diff-open":""} ${R?"harness-diff-expanded":""} ${x?"diff-panel-resizing":""}`,style:H,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[P==="harness"?e.jsx("button",{type:"button",className:`topbar-diff-button ${z?"active":""}`,title:`${z?"Hide":"Show"} sidebar`,"aria-label":`${z?"Hide":"Show"} sidebar`,"aria-pressed":!!z,disabled:!g,onClick:()=>y(_=>!_),children:e.jsx(Bt,{size:16})}):null,e.jsx(_t,{platform:t?.platform})]}),e.jsx(Da,{section:P,onBack:B,onSectionChange:T}),e.jsx("main",{className:`settings-content ${P==="profile"||P==="harness"?"settings-content-wide":""}`,children:P==="account"?e.jsx(fn,{payload:s,connection:t,onPayload:n,onPreferences:A,onError:l,onToast:i,...J}):P==="notifications"?e.jsx(Ln,{currentUserId:f,enabled:d,mode:h,threads:m,onModeChange:j,onThreadMuteChange:k}):P==="harness"?e.jsx(ol,{connection:t,enabled:P==="harness",onAcceptEvaluationReview:o,onError:l,onDefaultReleaseDiff:C,onOpenSourceSession:c,onOpenReleaseDiff:_=>{C(_),y(!0)},onToast:i}):P==="profile"?e.jsx(Zn,{payload:s,connection:t,onPayload:n,onError:l,onToast:i}):P==="skills"?e.jsx($a,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:t,onExtensionCatalog:q,onError:l,onToast:i,onOpenSkill:N,onOpenExtension:p}):P==="providers"?e.jsx(ya,{account:s?.account??null,codex:E,providers:s?.providers??null,...W}):P==="compute"?e.jsx(Fa,{state:V.state,busy:V.busy,onScan:V.scan,onSave:V.save,onDownloadSmolLm2:V.downloadSmolLm2,onCancelDownload:V.cancelDownload}):P==="dataset-storage"?e.jsx(Ka,{state:V.state,catalog:le.catalog,busy:V.busy,catalogLoading:le.loading,onRefresh:fe,onSave:se}):P==="defaults"?e.jsx(bn,{preferences:L,...X}):P==="context"?e.jsx(kn,{preferences:L,...X}):P==="training"?e.jsx(Ma,{connection:t,onError:l,onPreferences:A,preferences:L,providers:s?.providers??null}):P==="subagents"?e.jsx(Pn,{preferences:L,providers:s?.providers??null,...X}):P==="editor"?e.jsx(Cn,{preferences:L,...Y}):P==="remote"?e.jsx(Ca,{...re}):P==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(Cl,{account:s?.account??null,connection:t,enabled:P==="usage",onError:l,onOpenSourceSession:c})}):P==="personalization"?e.jsx(On,{...U}):e.jsx(yn,{diagnostics:K,...ne})}),P==="harness"&&t&&z?e.jsx(cl,{connection:t,expanded:R,onResizeStart:I,onToggleExpanded:()=>b(!R),selection:z}):null]})}export{Wl as SettingsView};
|