openpond 0.0.37 → 0.0.39

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.
Files changed (219) hide show
  1. package/README.md +3 -7
  2. package/dist/api/core.d.ts +6 -0
  3. package/dist/api/types.d.ts +0 -50
  4. package/dist/api/vercel-protection.d.ts +1 -0
  5. package/dist/api.d.ts +2 -8
  6. package/dist/chunks/{app-layer-LF2HK2B2.js → app-layer-LTBWNA2F.js} +32 -10
  7. package/dist/chunks/app-server-runtime-VYYJ2AWX.js +18 -0
  8. package/dist/chunks/{apps-ZMCMQZKX.js → apps-CZAJBGE3.js} +6 -124
  9. package/dist/chunks/{chunk-MHBQWGCL.js → chunk-2SF6HLT7.js} +5463 -5535
  10. package/dist/chunks/{chunk-VFL2JVBZ.js → chunk-3CDPPVLE.js} +111 -84
  11. package/dist/chunks/{chunk-N6E6YSTP.js → chunk-3HW6OSHP.js} +1 -3
  12. package/dist/chunks/{chunk-43YI36NA.js → chunk-3KLQ52B2.js} +228 -5
  13. package/dist/chunks/chunk-4HIWFIMN.js +37172 -0
  14. package/dist/chunks/{chunk-WTA33KQQ.js → chunk-4N6E3OVF.js} +4 -4
  15. package/dist/chunks/{chunk-35PPAOWD.js → chunk-6V7MJVRO.js} +56 -11
  16. package/dist/chunks/{chunk-ICLLW5QD.js → chunk-BQQZNGI6.js} +154 -194
  17. package/dist/chunks/chunk-DBHSOTYZ.js +1552 -0
  18. package/dist/chunks/{chunk-ZZ4ECDTP.js → chunk-FCVVOMIP.js} +145 -5
  19. package/dist/chunks/{chunk-A3CJUBA7.js → chunk-JIEUB6OS.js} +1 -1
  20. package/dist/chunks/{chunk-WL76II47.js → chunk-JJPAMKXZ.js} +1 -1
  21. package/dist/chunks/{chunk-2WMGA5FE.js → chunk-JRROTGQT.js} +1 -110
  22. package/dist/chunks/chunk-KHNHUA2H.js +1737 -0
  23. package/dist/chunks/{chunk-LNKYEHIJ.js → chunk-L6XH4ZGZ.js} +1 -1
  24. package/dist/chunks/chunk-M2NXTLH2.js +4054 -0
  25. package/dist/chunks/{chunk-IATK3CIP.js → chunk-MIZHCABO.js} +2 -195
  26. package/dist/chunks/chunk-SMNFI2FU.js +113 -0
  27. package/dist/chunks/chunk-VCVQLECH.js +675 -0
  28. package/dist/chunks/{chunk-KT2BB4AR.js → chunk-ZJBJQCQZ.js} +179 -52
  29. package/dist/chunks/{cli-5NFIDCRL.js → cli-JS76LCW2.js} +9 -5
  30. package/dist/chunks/{core-commands-7223BEQL.js → core-commands-4MRJQZJV.js} +7 -5
  31. package/dist/chunks/{harness-OMJXIGEW.js → desktop-test-RNMWLOVU.js} +15 -14
  32. package/dist/chunks/{chunk-ZPL4GZML.js → extension-GDRW22N3.js} +5866 -3601
  33. package/dist/chunks/{help-YPPROIS7.js → help-LWNREJ7U.js} +1 -1
  34. package/dist/chunks/{opchat-K7IYFPX6.js → opchat-2K2JIGK3.js} +9 -10
  35. package/dist/chunks/{organizations-W3FMAWQ4.js → organizations-Z5HVD2E7.js} +11 -9
  36. package/dist/chunks/{profile-N4B3F7M7.js → profile-QNECVVGN.js} +12 -38
  37. package/dist/chunks/{project-agent-NA6SGU25.js → project-agent-W3V75WBR.js} +9 -411
  38. package/dist/chunks/{sandbox-command-AKCFJKKN.js → sandbox-command-X3FO74NX.js} +7 -5
  39. package/dist/chunks/{sandbox-template-5NKTAXCL.js → sandbox-template-5B4T4BGU.js} +8 -6
  40. package/dist/chunks/{src-XAVSQTVR.js → src-ESAILPUH.js} +32 -30
  41. package/dist/chunks/src-IC5RX4L6.js +63517 -0
  42. package/dist/chunks/{teams-bot-557NZC73.js → teams-bot-NTQ6VFFL.js} +6 -4
  43. package/dist/chunks/training-BR5A7SPU.js +320 -0
  44. package/dist/chunks/{workspaces-S2H75XQB.js → workspaces-XC3QBD2Y.js} +2 -2
  45. package/dist/cli.js +24 -12
  46. package/dist/client-types.d.ts +1 -9
  47. package/dist/client.d.ts +3 -3
  48. package/dist/config.d.ts +9 -3
  49. package/dist/index.js +1300 -1091
  50. package/dist/profile/local-profile-types.d.ts +16 -0
  51. package/dist/profile/local-profile.d.ts +50 -4
  52. package/dist/sandbox/client-handles.d.ts +33 -46
  53. package/dist/sandbox/client.d.ts +4 -26
  54. package/dist/sandbox/sandbox-instance-client.d.ts +5 -5
  55. package/dist/sandbox/types/client.d.ts +1 -2
  56. package/dist/sandbox/types/core.d.ts +0 -1
  57. package/dist/sandbox/types/org-project-agent.d.ts +3 -89
  58. package/dist/sandbox/types/record.d.ts +1 -2
  59. package/dist/sandbox/types/runtime-profiles.d.ts +2 -2
  60. package/dist/sandbox-template/manifest.d.ts +1 -1
  61. package/dist/skills/openpond-agent-authoring/SKILL.md +40 -0
  62. package/dist/skills/openpond-agent-authoring/references/action-and-chat-design.md +13 -0
  63. package/dist/skills/openpond-agent-authoring/references/integrations-and-setup.md +13 -0
  64. package/dist/skills/openpond-agent-authoring/references/profile-layout.md +29 -0
  65. package/dist/skills/openpond-agent-authoring/references/validation-and-repair.md +14 -0
  66. package/dist/skills/openpond-desktop-harness/SKILL.md +1 -1
  67. package/dist/skills/openpond-skill-authoring/SKILL.md +44 -0
  68. package/dist/skills/openpond-skill-authoring/references/copying-and-adaptation.md +16 -0
  69. package/dist/skills/openpond-skill-authoring/references/skill-package-layout.md +38 -0
  70. package/dist/skills/openpond-skill-authoring/references/validation-and-repair.md +24 -0
  71. package/dist/skills/openpond-skill-authoring/scripts/validate-skill.mjs +102 -0
  72. package/dist/skills/openpond-taskset-authoring/SKILL.md +64 -22
  73. package/dist/skills/openpond-taskset-authoring/artifact.json +39 -0
  74. package/dist/skills/openpond-taskset-authoring/references/graders-and-rewards.md +3 -0
  75. package/dist/skills/openpond-taskset-authoring/references/method-selection.md +1 -1
  76. package/dist/skills/openpond-taskset-authoring/references/privacy-and-provenance.md +2 -0
  77. package/dist/skills/openpond-taskset-authoring/references/task-design.md +32 -0
  78. package/dist/web/assets/{AppDialog-y6krB0MJ.js → AppDialog-Bua3f-6v.js} +1 -1
  79. package/dist/web/assets/{AppsView-4F6oLktr.js → AppsView-DrJkHeSO.js} +1 -1
  80. package/dist/web/assets/BrowserSidebar-Bf-4Vozm.js +1 -0
  81. package/dist/web/assets/CommandMenu-DDZlGQiB.js +1 -0
  82. package/dist/web/assets/CommunityView-BtcCrba7.js +1 -0
  83. package/dist/web/assets/ComposerCreateImproveStrip-DOe5Otg6.js +1 -0
  84. package/dist/web/assets/GetStartedView-CG4z0Dtw.js +1 -0
  85. package/dist/web/assets/GetStartedView-yVmnGZPw.css +1 -0
  86. package/dist/web/assets/LabModelVersionDetailPage-BEkmSKuv.js +1 -0
  87. package/dist/web/assets/LabSkillSidebar-BIotN_RB.js +1 -0
  88. package/dist/web/assets/LabsRoute-CfOe0Zt5.js +3 -0
  89. package/dist/web/assets/LabsRoute-CoSPO4HR.css +1 -0
  90. package/dist/web/assets/MainChatThread-C0-l1mHt.js +2 -0
  91. package/dist/web/assets/MainPane-Bky_Rqcx.css +1 -0
  92. package/dist/web/assets/MainPane-aOVlVyRK.js +6 -0
  93. package/dist/web/assets/MarkdownText-D7DT1k1k.js +9 -0
  94. package/dist/web/assets/Messages-CBIXruA9.js +9 -0
  95. package/dist/web/assets/NativeSkillSidebar-C4t69Y7B.js +1 -0
  96. package/dist/web/assets/NewProjectDialog-Bat65tYD.js +1 -0
  97. package/dist/web/assets/OutputsPage-C58n39Db.js +1 -0
  98. package/dist/web/assets/RightChatPanelStack-Bp7nZxQ0.js +1 -0
  99. package/dist/web/assets/ScheduledWorkPage-BXP0j_c_.js +1 -0
  100. package/dist/web/assets/SettingsView-CtWK_aQ0.css +1 -0
  101. package/dist/web/assets/SettingsView-DOOfhO9a.js +6 -0
  102. package/dist/web/assets/TeamChatView-Cgxm-pKA.css +1 -0
  103. package/dist/web/assets/TeamChatView-De2wdqyY.js +3 -0
  104. package/dist/web/assets/{TerminalOverlay-B56XmI-k.js → TerminalOverlay-BsuCH3NX.js} +1 -1
  105. package/dist/web/assets/TrainingCreationPanel-D2OFWyQ-.js +1 -0
  106. package/dist/web/assets/TrainingDraftPanel-DBpulXTz.js +1 -0
  107. package/dist/web/assets/{UsageSettingsSection-r3CqRm6Q.js → UsageSettingsSection-DzMLUXAO.js} +37 -37
  108. package/dist/web/assets/WorkspaceDiffPanel-B7yIhjNF.js +14 -0
  109. package/dist/web/assets/WorkspaceEnvironmentMenu-B6jXM9xG.js +32 -0
  110. package/dist/web/assets/WorkspaceGitDialogs-CQ0fl9Qk.js +1 -0
  111. package/dist/web/assets/{WorkspaceMonacoEditor-CHd22UcG.js → WorkspaceMonacoEditor-C2ctzITz.js} +3 -3
  112. package/dist/web/assets/arrow-up-right-ecwcx3xt.js +1 -0
  113. package/dist/web/assets/chevron-up-DP8PPfWd.js +1 -0
  114. package/dist/web/assets/circle-alert-envg1D6O.js +1 -0
  115. package/dist/web/assets/cloud-upload-5MGPLnaA.js +1 -0
  116. package/dist/web/assets/{cssMode-KFDYjM8T.js → cssMode-CFifcEfw.js} +1 -1
  117. package/dist/web/assets/folder-open-Dq3ZjeEP.js +1 -0
  118. package/dist/web/assets/folder-plus-EiZ5wbv_.js +1 -0
  119. package/dist/web/assets/git-branch-w29jmQ-X.js +1 -0
  120. package/dist/web/assets/{git-commit-horizontal-C8UFKlXy.js → git-commit-horizontal-CGZM0PZo.js} +1 -1
  121. package/dist/web/assets/{htmlMode-NbLN3n6Q.js → htmlMode-Ct1P-_lf.js} +1 -1
  122. package/dist/web/assets/index-ByIQyiUl.js +178 -0
  123. package/dist/web/assets/index-D4uCeiep.js +1 -0
  124. package/dist/web/assets/index-D9jTe16Q.css +1 -0
  125. package/dist/web/assets/info-Cd2HkIeb.js +1 -0
  126. package/dist/web/assets/{jsonMode-Bl3r4LM_.js → jsonMode-BAUNCNAX.js} +1 -1
  127. package/dist/web/assets/{lspLanguageFeatures-DH22w5XD.js → lspLanguageFeatures-fucFYI1A.js} +1 -1
  128. package/dist/web/assets/monaco.contribution-Ce4v5kei.js +2 -0
  129. package/dist/web/assets/monaco.contribution-DLLMi4cB.js +2 -0
  130. package/dist/web/assets/monaco.contribution-g9QiIm1d.js +2 -0
  131. package/dist/web/assets/monaco.contribution-nG-5Cyjz.js +2 -0
  132. package/dist/web/assets/monitor-DgHCnCKl.js +1 -0
  133. package/dist/web/assets/{play-2NDQ4-7K.js → play-Be0XDHBu.js} +1 -1
  134. package/dist/web/assets/{python-CQ0TmUW9.js → python-CEhEiPo7.js} +1 -1
  135. package/dist/web/assets/{refresh-cw-CyermMsy.js → refresh-cw-DH0KLbdD.js} +1 -1
  136. package/dist/web/assets/reply-D1TK2yV8.js +1 -0
  137. package/dist/web/assets/{save-Bij3cc3Q.js → save-C1MSeBnQ.js} +1 -1
  138. package/dist/web/assets/square-CemI-0g5.js +1 -0
  139. package/dist/web/assets/square-pen-CqfsvR_n.js +1 -0
  140. package/dist/web/assets/{toggleHighContrast-CxALivAH.js → toggleHighContrast-DrdQN3Rl.js} +1 -1
  141. package/dist/web/assets/training-BQVNUTZA.css +1 -0
  142. package/dist/web/assets/training-model-data-B7-1Bxil.js +1 -0
  143. package/dist/web/assets/{tsMode-vH4lMS7h.js → tsMode-CKB5oOUU.js} +1 -1
  144. package/dist/web/assets/{upload-DbJfEI3G.js → upload-t751LLqP.js} +1 -1
  145. package/dist/web/assets/useLocalAgentSchedules-CzC3wfIP.js +1 -0
  146. package/dist/web/assets/{wifi-off-BnVFBG28.js → wifi-off-CxTHH3JU.js} +1 -1
  147. package/dist/web/assets/{workers-CBihj7z6.js → workers-CqYddzCd.js} +1 -1
  148. package/dist/web/assets/{yaml-Bhkoq1sy.js → yaml-e5wBkc-C.js} +1 -1
  149. package/dist/web/index.html +2 -2
  150. package/docs/command-reference.md +76 -41
  151. package/package.json +3 -1
  152. package/dist/chunks/chunk-3VURZQHA.js +0 -864
  153. package/dist/chunks/chunk-BWA3COR4.js +0 -3535
  154. package/dist/chunks/chunk-HLCTINEP.js +0 -224
  155. package/dist/chunks/chunk-PGET7EZF.js +0 -3896
  156. package/dist/chunks/chunk-T4QXKU5Y.js +0 -1
  157. package/dist/chunks/chunk-XEJ7XXUQ.js +0 -1301
  158. package/dist/chunks/cli-AS3DZ7XB.js +0 -23
  159. package/dist/chunks/extend-6N5S5KA5.js +0 -89
  160. package/dist/chunks/extension-FJSVCG2Q.js +0 -121
  161. package/dist/chunks/fileFromPath-DHCRY3BD.js +0 -2151
  162. package/dist/chunks/src-SCS4KKP4.js +0 -105881
  163. package/dist/web/assets/BrowserSidebar-C0MHQaaD.js +0 -1
  164. package/dist/web/assets/CloudWorkView-DNoPIlMj.css +0 -1
  165. package/dist/web/assets/CloudWorkView-DwFIZoXy.js +0 -1
  166. package/dist/web/assets/CommandMenu-CYGFrMZi.js +0 -1
  167. package/dist/web/assets/CommunityView-C6n89YXz.js +0 -1
  168. package/dist/web/assets/ComposerCreateImproveStrip-C3RwXC3_.js +0 -1
  169. package/dist/web/assets/GetStartedView-DBLdduwr.css +0 -1
  170. package/dist/web/assets/GetStartedView-fwD0ZXo9.js +0 -1
  171. package/dist/web/assets/LabSkillSidebar-BSuc-NJr.js +0 -1
  172. package/dist/web/assets/LabsRoute-BrJkBNig.css +0 -1
  173. package/dist/web/assets/LabsRoute-D2y8dSsT.js +0 -3
  174. package/dist/web/assets/MainChatThread-Dj_Ry6WQ.js +0 -2
  175. package/dist/web/assets/MakeAgentTutorialLearningPanel-Bz2VDaRe.js +0 -2
  176. package/dist/web/assets/MarkdownText-B6Nu_0Fz.js +0 -7
  177. package/dist/web/assets/Messages-CH2wfv2a.js +0 -10
  178. package/dist/web/assets/NativeSkillSidebar-4iUfgwqO.js +0 -1
  179. package/dist/web/assets/NewProjectDialog-8M5-6-h-.js +0 -1
  180. package/dist/web/assets/PostTrainingLearningPanel-CdG5KHZs.js +0 -2
  181. package/dist/web/assets/PostTrainingStatusPill-COZ4qISQ.js +0 -1
  182. package/dist/web/assets/ProfileSettingsSection-Bo7dybgW.js +0 -1
  183. package/dist/web/assets/ProfileSettingsSection-Cg4tKO-C.css +0 -1
  184. package/dist/web/assets/RightChatPanelStack-Di8zoHJI.js +0 -1
  185. package/dist/web/assets/SettingsView-BcYyY66X.css +0 -1
  186. package/dist/web/assets/SettingsView-CAaKdDHt.js +0 -6
  187. package/dist/web/assets/TeamChatView-Bx44q3WV.css +0 -1
  188. package/dist/web/assets/TeamChatView-CzQYFBap.js +0 -3
  189. package/dist/web/assets/TrainingCreationPanel-C_ntWAAP.js +0 -1
  190. package/dist/web/assets/TrainingDraftPanel-3hJIxLNn.js +0 -1
  191. package/dist/web/assets/WorkspaceDiffPanel-By8PWUuE.js +0 -14
  192. package/dist/web/assets/WorkspaceEnvironmentMenu-7wmC-spz.js +0 -32
  193. package/dist/web/assets/WorkspaceGitDialogs-Hn--lsRh.js +0 -1
  194. package/dist/web/assets/activity-Dp5V58om.js +0 -1
  195. package/dist/web/assets/boxes-DE7WJaEv.js +0 -1
  196. package/dist/web/assets/chevron-up-BWx8gGab.js +0 -1
  197. package/dist/web/assets/circle-x-DnmOfZIg.js +0 -1
  198. package/dist/web/assets/copy-BjWvaXLC.js +0 -1
  199. package/dist/web/assets/create-pipeline-request-C4V6-lWN.js +0 -4
  200. package/dist/web/assets/credit-card-Bjg0Zaw5.js +0 -1
  201. package/dist/web/assets/file-BrC1KjAS.js +0 -1
  202. package/dist/web/assets/git-branch-DTeeARsp.js +0 -1
  203. package/dist/web/assets/index-BcZetaeD.css +0 -1
  204. package/dist/web/assets/index-DQalqxbw.js +0 -177
  205. package/dist/web/assets/index-DYxF_d9i.js +0 -1
  206. package/dist/web/assets/info-BXBpMeVU.js +0 -1
  207. package/dist/web/assets/make-agent-tutorial-CAnTPFCK.js +0 -2
  208. package/dist/web/assets/monaco.contribution-C0BsxYAz.js +0 -2
  209. package/dist/web/assets/monaco.contribution-CzpXjm9j.js +0 -2
  210. package/dist/web/assets/monaco.contribution-DK-g-i00.js +0 -2
  211. package/dist/web/assets/monaco.contribution-iAurj7TQ.js +0 -2
  212. package/dist/web/assets/monitor-Ba2FFblh.js +0 -1
  213. package/dist/web/assets/reply-BSExNLHM.js +0 -1
  214. package/dist/web/assets/rotate-cw-DJ-zYG9E.js +0 -1
  215. package/dist/web/assets/training-BN8CALIc.css +0 -1
  216. package/dist/web/assets/training-model-data-BXUCzS0p.js +0 -1
  217. package/dist/web/tokens/eth.svg +0 -1
  218. package/dist/web/tokens/usdc.svg +0 -1
  219. package/docs/agent-edit-check-status-json.md +0 -132
@@ -0,0 +1,6 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-DzMLUXAO.js","./index-ByIQyiUl.js","./index-D9jTe16Q.css","./arrow-up-right-ecwcx3xt.js","./index-D4uCeiep.js","./UsageSettingsSection-O8VK0qBL.css"])))=>i.map(i=>d[i]);
2
+ import{c as ge,j as e,r as o,au as ns,X as le,av as it,aw as rt,ax as ot,ay as ct,az as dt,aA as ut,P as me,aB as ht,aC as mt,n as I,aD as pt,aE as Ke,aF as gt,aG as ft,aH as xt,K as $s,s as Te,aI as jt,t as bt,L as Ie,aJ as vt,b as Ls,aK as Je,aL as Ue,ae as yt,C as Nt,aM as St,G as Ye,a0 as wt,F as Me,aN as ne,aO as Ct,aP as Ze,aQ as Xe,a3 as Ts,A as kt,a1 as Pt,a2 as Rt,B as At,a as Os,aR as Dt,aS as It,p as Mt,I as Qe,a8 as Be,aT as je,ai as $t,aU as Lt,aV as Tt,aW as Ot,Z as Et,aX as zt,_ as Ut}from"./index-ByIQyiUl.js";import{R as se}from"./refresh-cw-DH0KLbdD.js";import{D as we,T as be,P as Es,B as Oe,W as _e,C as Bt}from"./MarkdownText-D7DT1k1k.js";/* empty css */import{S as as}from"./save-C1MSeBnQ.js";import{F as zs}from"./folder-open-Dq3ZjeEP.js";import{C as _t}from"./chevron-up-DP8PPfWd.js";import{C as Us}from"./circle-alert-envg1D6O.js";import{P as Bs}from"./play-Be0XDHBu.js";import{B as _s,W as Ht,S as Ft}from"./wifi-off-CxTHH3JU.js";import{R as $e,u as Gt}from"./useLocalAgentSchedules-CzC3wfIP.js";import{C as pe}from"./cloud-upload-5MGPLnaA.js";import{F as Pe,M as qt}from"./monitor-DgHCnCKl.js";import{G as Le}from"./git-commit-horizontal-CGZM0PZo.js";import{S as Wt}from"./square-pen-CqfsvR_n.js";import{r as Vt}from"./index-D4uCeiep.js";import{F as Kt}from"./folder-plus-EiZ5wbv_.js";import{WorkspaceDiffPanel as Jt}from"./WorkspaceDiffPanel-B7yIhjNF.js";import"./training-model-data-B7-1Bxil.js";import"./info-Cd2HkIeb.js";const Yt=[["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"}]],Zt=ge("clipboard-copy",Yt);const Xt=[["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"}]],Qt=ge("hard-drive",Xt);const en=[["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",en);const sn=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],tn=ge("power",sn);const nn=[["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"}]],Hs=ge("radio-tower",nn);const an=[["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"}]],ln=ge("rotate-cw",an);const rn=[["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"}]],Fs=ge("sliders-horizontal",rn);const on=[["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"}]],cn=ge("circle-user",on);function cs({handle:s,image:t}){const n=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:n})})}function He({state:s,label:t}){return e.jsx("span",{className:`account-state ${s}`,children:t??s.replace("_"," ")})}const es="https://openpond.ai",ss="https://api.openpond.ai";function dn(s,t){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:t?.handle,currentBaseUrl:t?.baseUrl??null}}function ds(s,t){const n=t.trim().replace(/\/+$/,"");if(!n)throw new Error(`${s} is required.`);try{const a=new URL(n);if(a.protocol!=="http:"&&a.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return n}function us({account:s,busy:t,initialApiKey:n="",mode:a="update",onClose:l,onSave:i}){const u=o.useId(),r=a==="connect",[h,v]=o.useState(n),[g,f]=o.useState(!1),[c,p]=o.useState(s?.baseUrl??es),[m,j]=o.useState(s?.apiBaseUrl??ss),[C,P]=o.useState(null),[x,R]=o.useState(null);ns(x),o.useEffect(()=>{v(n),f(!1),p(s?.baseUrl??es),j(s?.apiBaseUrl??ss),P(null),R(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,n]);async function A(N){N.preventDefault(),P(null),R(null);const S=h.trim();if(r&&!S){P("API key is required.");return}let L,k;try{L=ds("Base URL",c),k=ds("API base URL",m)}catch(d){P(d instanceof Error?d.message:String(d));return}try{const d=dn(a,s);await i({...d,baseUrl:L,apiBaseUrl:k,apiKey:r?S:void 0,environment:r?un(L,k):s?.environment??null})}catch(d){R(d instanceof Error?d.message:String(d))}}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=>{A(N)},children:[e.jsx("button",{className:"git-dialog-close",disabled:t,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(le,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:r?e.jsx(ue,{size:18}):e.jsx(Fs,{size:18})}),e.jsx("h2",{id:u,children:r?"Add account":"Account endpoints"}),r?e.jsx("p",{children:"Enter your OpenPond API key to connect another account."}):null,r?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:h,onChange:N=>v(N.target.value)})]}):null,r?e.jsxs("label",{className:"git-dialog-toggle account-dialog-advanced-toggle",children:[e.jsx("input",{checked:g,disabled:t,type:"checkbox",onChange:N=>f(N.target.checked)}),e.jsx("span",{}),"Advanced"]}):null,!r||g?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:!r,disabled:t,inputMode:"url",value:c,onChange:N=>p(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:m,onChange:N=>j(N.target.value)})]})]}):null,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",disabled:t,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:t,type:"submit",children:[e.jsx(as,{size:14}),e.jsx("span",{children:t?"Saving":r?"Connect account":"Update account"})]})]})]})})}function un(s,t){return s===es&&t===ss?"production":"custom"}const hn="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 mn({payload:s,connection:t,saving:n,refreshingAccounts:a,saveAccount:l,refreshAccounts:i,switchAccount:u,removeAccount:r,onPayload:h,onPreferences:v,onError:g,onToast:f}){const c=s?.account,p=c?.state??"loading",m=p==="signed_in",j=p==="signed_out",C=p==="auth_error",P=c?.email?.trim()||null,x=c?.accounts??[],[R,A]=o.useState([]),[,N]=o.useState(!1),[S,L]=o.useState(null),[k,d]=o.useState(null),[w,y]=o.useState(null),[b,M]=o.useState(null),[E,G]=o.useState(!1),[K,Z]=o.useState(null),{confirmAction:$,confirmDialog:z,resolveConfirmDialog:Q}=it(),J=x.find(D=>D.isActive)??x[0]??null,H=s?.preferences.defaultTeamId?.trim()||null,ie=w??H,V=rt(c),U=s?.accountMeta.asOf??"",te=ye(c?.environment,J?.environment),ae=m?ye(J?.displayLabel,J?.handle,c?.label,c?.activeProfile?.handle,"Signed in"):C?"Account needs attention":j?"No account connected":"Loading account",q=m?P??hs(te):C?"Not connected":j?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",re=x.length>0,ce=C?pn(c?.error):null,ee=o.useMemo(()=>R.filter(D=>D.status==="active"),[R]),O=(o.useMemo(()=>ie?ee.find(D=>D.teamId===ie)??null:null,[ee,ie])??ot(ee))?.teamId??"",B=o.useMemo(()=>ee.map(D=>({value:D.teamId,label:ye(D.displayName,D.name,D.slug,"Team"),description:ct(D.role)})),[ee]),_=O||B[0]?.value||"",T=B.length>0,W=!t||!!k||!!S||ee.length===0,rs=b?Fe(b):null,os=!!(rs&&K===rs),Qs=m||C;o.useEffect(()=>{if(!t||!V){A([]),L(null),N(!1);return}let D=!1;const Y=dt(V);return Y?(A(Y),N(!1)):(A([]),N(!0)),L(null),ut({accountKey:V,force:!!U,fetchOrganizations:async()=>(await I.organizations(t)).organizations.map(pt).filter(X=>!!X).filter(X=>X.status==="active")}).then(F=>{D||A(F)}).catch(F=>{D||(Y||A([]),L(F instanceof Error?F.message:String(F)))}).finally(()=>{D||N(!1)}),()=>{D=!0}},[U,t,V]),o.useEffect(()=>{w&&H===w&&y(null)},[H,w]);async function et(D,Y={notify:!0}){const F=ee.find(X=>X.teamId===D)??null;if(!(!t||!F||k||(w??H)===F.teamId)){y(F.teamId),d(F.teamId),g(null),mt({teamId:F.teamId,accountKey:V,force:!0,fetchAgents:async X=>(await I.listSandboxAgents(t,{teamId:X})).agents}).catch(()=>{});try{v(await I.savePreferences(t,{defaultTeamId:F.teamId})),Y.notify&&f?.("Default team updated","success")}catch(X){y(null),g(X instanceof Error?X.message:String(X))}finally{d(null)}}}async function Ee(D="Continue"){return Qs?$({title:"Change active OpenPond account?",body:hn,confirmLabel:D,cancelLabel:"Cancel"}):!0}async function st(D){await Ee("Save account")&&(await l({apiKey:D.apiKey??"",handle:D.handle,baseUrl:D.baseUrl,apiBaseUrl:D.apiBaseUrl,environment:D.environment}),G(!1))}async function tt(D){if(!t||!b)throw new Error("OpenPond server connection is not ready.");if(b.isActive&&!await Ee("Save endpoints"))return;const Y=Fe(b);Z(Y),g(null);try{const F=await I.updateOpenPondAccountConfig(t,{handle:D.handle??b.handle,currentBaseUrl:D.currentBaseUrl,baseUrl:D.baseUrl,apiBaseUrl:D.apiBaseUrl,chatApiBaseUrl:null,environment:gn(D.environment),setActive:b.isActive});h(F),f?.("Account endpoints updated","success"),M(null)}catch(F){throw g(F instanceof Error?F.message:String(F)),F}finally{Z(null)}}async function nt(D){const Y=D.handle?.trim()||"";Y&&await Ee("Switch account")&&await u(Y,D.baseUrl)}async function at(D){const Y=D.handle?.trim()||"";if(!Y||D.isActive)return;const F=ye(D.displayLabel,D.email,D.handle,"this account");await $({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 r(Y,D.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||n,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||n||a,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{i()},children:e.jsx(se,{size:15,className:a?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(cs,{handle:ae,image:m?c?.avatarUrl??J?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:ae}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:m&&P?"private-account-email":m?void 0:"account-summary-copy",tabIndex:m&&P?0:void 0,children:q}),m&&T?e.jsx(we,{className:"account-team-dropdown",compact:!0,disabled:W,label:"Default team",options:B,value:_,onChange:D=>{et(D)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(He,{state:p,label:j?"not signed in":void 0})})]}),re?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(D=>{const Y=D.handle?.trim()||"",F=ye(D.displayLabel,D.handle,"Unknown account"),X=D.email?.trim()||null,ze=fn(D.environment),lt=Fe(D);return e.jsxs("div",{className:"account-row",children:[e.jsx(cs,{handle:F,image:D.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:F}),X?e.jsx("span",{className:"private-account-email",tabIndex:0,children:X}):null,e.jsx("span",{children:hs(D.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(He,{state:D.authHealth}),D.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:`account-env-toggle ${ze?"active":""}`,disabled:!t||n||!!K||!Y,type:"button","aria-label":`Configure ${F} environment endpoints`,"aria-pressed":ze,title:"Configure environment endpoints",onClick:()=>M(D),children:e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"})}),D.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:n||!Y,type:"button",onClick:()=>{nt(D)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:n||!Y,type:"button","aria-label":`Remove ${F}`,title:`Remove ${F}`,onClick:()=>{at(D)},children:e.jsx(be,{size:13})})]})]})]},lt)})]}):null,c?.products&&c.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:[c.products.length," active"]})]}),c.products.map(D=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:D.name}),e.jsx("span",{children:D.type})]}),e.jsx(He,{state:D.status})]},D.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:t?.serverUrl??"loading"})]}),ce?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:ce})]}):null,b?e.jsx(us,{account:b,busy:os,onClose:()=>{os||M(null)},onSave:tt}):null,E?e.jsx(us,{busy:n,mode:"connect",onClose:()=>{n||G(!1)},onSave:st}):null,e.jsx(ht,{state:z,onResolve:Q})]})}function Fe(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function ye(...s){for(const t of s){const n=t?.trim();if(n)return n}return""}function pn(s){const t=s?.trim();if(!t)return null;const n=t.toLowerCase();return n.includes("protected deployment")||n.includes("vercel_auth_enabled")?"Staging is protected by Vercel. Restart OpenPond after signing in to Vercel, then try again.":n.includes("unexpected token '<'")||n.includes("<!doctype")||n.includes("vercel.com/sso-api")?"OpenPond received a web login page instead of account data. Restart after signing in to Vercel, then try again.":n.includes("401")||n.includes("unauthorized")||n.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 hs(s){const t=s.trim().toLowerCase();return!t||t==="production"?"Production":"Environment"}function gn(s){const t=s?.trim();return!t||t.toLowerCase()==="production"?"custom":t}function fn(s){const t=s?.trim().toLowerCase();return!!(t&&t!=="production")}function xn({advancedWorkspaceControls:s,defaultBranchPrefix:t,defaultNewProjectDirectory:n,preferences:a,saving:l,chooseDefaultProjectDirectory:i,saveDefaults:u,setAdvancedWorkspaceControls:r,setDefaultBranchPrefix:h,setDefaultNewProjectDirectory:v}){const g=Ke(t)===a.defaultBranchPrefix&&n.trim()===a.defaultNewProjectDirectory&&s===a.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=>r(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=>h(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:n,disabled:l,placeholder:"~/Documents/OpenPond Projects",onChange:f=>v(f.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{i()},children:[e.jsx(zs,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||g,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:[Ke(t),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:n||a.defaultNewProjectDirectory})]})]})}function jn({diagnostics:s,diagnosticsAvailable:t,diagnosticsBusy:n,diagnosticsStatus:a,logDir:l,logLineLimit:i,logLines:u,logViewBusy:r,logViewSummary:h,logViewportRef:v,tailLogs:g,copyRecentLogs:f,exportDiagnosticsBundle:c,loadOlderLogs:p,openLogsFolder:m,refreshLogView:j,toggleTailLogs:C}){const P=s.filter(R=>R.name==="diagnostic"&&R.status==="failed").slice().reverse().map(bn),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:[P.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:P.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):P.map(R=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Us,{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:n!==null||!x?.openLogsFolder,onClick:()=>{m()},children:[e.jsx(zs,{size:15}),e.jsx("span",{children:n==="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:n!==null||!x?.exportDiagnostics,onClick:()=>{c()},children:[e.jsx(gt,{size:15}),e.jsx("span",{children:n==="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:n!==null||!x?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(Zt,{size:15}),e.jsx("span",{children:n==="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:h}),e.jsx("button",{type:"button",className:`settings-icon-button ${g?"active":""}`,title:g?"Pause tail":"Tail logs","aria-label":g?"Pause tail":"Tail logs",disabled:!x?.readRecentLogs,onClick:C,children:g?e.jsx(Es,{size:15}):e.jsx(Bs,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:r!==null||!x?.readRecentLogs,onClick:()=>{j(i,"refresh")},children:e.jsx(se,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:r!==null||!x?.readRecentLogs,onClick:p,children:[e.jsx(_t,{size:15}),e.jsx("span",{children:r==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:v,className:"diagnostics-log-viewer",role:"log","aria-live":g?"polite":"off",children:u.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:r?"Loading logs":"No log lines"}):u.map((R,A)=>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}:${A}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),a&&e.jsxs("div",{className:`settings-footnote ${a.warning?"warning":""}`,children:[e.jsx("span",{children:a.label}),e.jsx("strong",{children:a.value})]})]})}function bn(s){const t=ms(s.data),n=ms(t.context),l=he(t.stack)??he(t.detail)??he(n.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:yn(s.timestamp),message:vn(s,t),surface:he(t.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function vn(s,t){return he(s.error)??he(s.output)??he(t.message)??he(t.error)??"Diagnostic event"}function yn(s){const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function ms(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function he(s){return typeof s=="string"&&s.trim()?s.trim():null}const ps=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Nn({editorPreferences:s,lspStatus:t,preferences:n,restarting:a,saving:l,statusLoading:i,refreshLspStatus:u,restartLanguageServers:r,saveEditorSettings:h,setEditorPreferences:v,setLanguageCustomCommand:g,setLanguageMode:f}){const c=JSON.stringify(s)!==JSON.stringify(n.editor),p=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=>{h(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(we,{value:s.languageServers,disabled:l,label:"Language servers",options:ft,onChange:m=>v(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=>v(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=>v(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:ps.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:gs(p.get(m.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(we,{value:j.mode,disabled:l||s.languageServers==="off",label:`${m.label} language server mode`,options:xt,onChange:C=>f(m.id,C)})]}),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:C=>g(m.id,C.target.value)})]})]},m.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!c,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||a,onClick:()=>{u()},children:e.jsx(se,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||a,onClick:()=>{r()},children:[e.jsx(ln,{className:a?"settings-spin":void 0,size:15}),e.jsx("span",{children:a?"Restarting":"Restart"})]})]})]}),ps.map(m=>{const j=p.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:gs(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 gs(s,t){return t&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function Sn({contextCompactionAutoEnabled:s,preferences:t,saving:n,saveDefaults:a,setContextCompactionAutoEnabled:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:i=>{a(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:n,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:n||s===t.contextCompaction.autoEnabled,children:e.jsx("span",{children:n?"Saving":"Save context"})})]})]})}function wn({subagentsEnabled:s,subagentDelegationMode:t,subagentsUseDefaultModel:n,subagentsProvider:a,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:u,subagentsMaxConcurrentRunsPerProvider:r,subagentsMaxConcurrentRunsPerWorkspaceTarget:h,preferences:v,providers:g,saving:f,saveDefaults:c,changeSubagentsProvider:p,setSubagentsEnabled:m,setSubagentDelegationMode:j,setSubagentsUseDefaultModel:C,setSubagentsModel:P,setSubagentsMaxConcurrentRuns:x,setSubagentsMaxConcurrentRunsPerProvider:R,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:A,setSubagentRoleEnabled:N,setSubagentRoleIsolationMode:S,setSubagentRoleMaxConcurrentRuns:L,setSubagentRoleModel:k,setSubagentRolePeerMessages:d,setSubagentRoleToolPolicy:w,changeSubagentRoleProvider:y}){const b=$s(g,{enabledOnly:!0}),M=n?v.defaultChatProvider:a,E=n?v.defaultChatModel:l,G=Gs(Te(M,g),E),K=n?null:{providerId:a,modelId:l.trim()},Z=An({enabled:s,delegationMode:t,defaultModelRef:K,roles:i,maxConcurrentRuns:u,maxConcurrentRunsPerProvider:r,maxConcurrentRunsPerWorkspaceTarget:h},v);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:$=>{c($)},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${Z?"":" dirty"}`,disabled:f||Z,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:$=>m($.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:$=>j($.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:M,disabled:f||!s,onChange:$=>{C(!1),p($.target.value)},children:b.map($=>e.jsx("option",{value:$.value,children:$.label},$.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:E,disabled:f||!s,onChange:$=>{C(!1),P($.target.value)},children:G.map($=>e.jsx("option",{value:$.value,children:$.label},$.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map($=>{const z=jt.find(U=>U.id===$.id),Q=$.modelRef?.providerId??M,J=$.modelRef?.modelId||bt(Q,g)||E,H=Rn(b,g,{providerId:Q,modelId:J}),ie=De(Q,J),V=f||!s||!$.enabled;return e.jsxs("section",{className:`subagent-role-row${$.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:z?.label??$.id}),e.jsx("small",{children:z?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${z?.label??$.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:$.enabled,disabled:f||!s,onChange:U=>N($.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:ie,disabled:V,onChange:U=>{const te=H.find(ae=>ae.value===U.target.value);te&&(y($.id,te.providerId),k($.id,te.modelId))},children:H.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:$.isolationMode,disabled:V,onChange:U=>S($.id,U.target.value),children:Cn.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:$.toolPolicy,disabled:V,onChange:U=>w($.id,U.target.value),children:kn.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:$.peerMessages,disabled:V,onChange:U=>d($.id,U.target.value),children:Pn.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:$.maxConcurrentRuns,disabled:V,onChange:U=>L($.id,fs(U.target.value,1))})]})})]},$.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:$=>x(fs($.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:r??"",placeholder:"No cap",disabled:f||!s,onChange:$=>R(ts($.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:h??"",placeholder:"No cap",disabled:f||!s,onChange:$=>A(ts($.target.value))})]})]})]})]})})}const Cn=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],kn=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Pn=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function Gs(s,t){const n=t.trim();return!n||s.some(a=>a.value===n)?s:[{value:n,label:n},...s]}function De(s,t){return JSON.stringify([s,t])}function Rn(s,t,n){const a=[];for(const l of s){const i=Gs(Te(l.value,t),l.value===n.providerId?n.modelId:"");for(const u of i)a.push({value:De(l.value,u.value),label:`${l.label} / ${u.label}`,providerId:l.value,modelId:u.value})}return n.modelId&&!a.some(l=>l.value===De(n.providerId,n.modelId))&&a.unshift({value:De(n.providerId,n.modelId),label:`${Ie(n.providerId,t)} / ${n.modelId}`,providerId:n.providerId,modelId:n.modelId}),a}function ts(s){const t=s.trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)?n:null}function fs(s,t){return ts(s)??t}function An(s,t){const n=t.subagents;return s.enabled===n.enabled&&s.delegationMode===n.delegationMode&&Dn(s.defaultModelRef,n.defaultModelRef)&&s.maxConcurrentRuns===n.maxConcurrentRuns&&s.maxConcurrentRunsPerProvider===n.maxConcurrentRunsPerProvider&&s.maxConcurrentRunsPerWorkspaceTarget===n.maxConcurrentRunsPerWorkspaceTarget&&JSON.stringify(s.roles)===JSON.stringify(n.roles)}function Dn(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const In=[{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 Mn({currentUserId:s,enabled:t,mode:n,threads:a,onModeChange:l,onThreadMuteChange:i}){const[u,r]=o.useState(null),[h,v]=o.useState(null);ns(h);const g=o.useMemo(()=>a.filter(p=>p.archivedAt===null).map(p=>({thread:p,label:$n(p,s)})).sort((p,m)=>{const j=+!!m.thread.mutedAt-+!!p.thread.mutedAt;return j!==0?j:p.label.localeCompare(m.label)}),[s,a]),f=g.filter(({thread:p})=>!!p.mutedAt).length,c=o.useCallback(async p=>{r(p.id),v(null),await i(p.id,!p.mutedAt)||v("Could not update this conversation. Try again."),r(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:In.map(p=>e.jsxs("label",{className:`notification-mode-option${n===p.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:n===p.mode,onChange:()=>l(p.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:p.label}),e.jsx("small",{children:p.detail})]})]},p.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?g.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):g.map(({thread:p,label:m})=>{const j=!!p.mutedAt,C=u===p.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${j?" muted":""}`,children:j?e.jsx(vt,{size:15}):e.jsx(_s,{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:()=>{c(p)},children:C?"Saving":j?"Unmute":"Mute"})]},p.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 $n(s,t){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(n=>n.userId!==t)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(n=>n.userId!==t).map(n=>n.name).join(", ")||"Group conversation"}function Ln({canSaveCurrentTemplate:s,personalizationTemplateId:t,personalizationTemplateOptions:n,saveAsNewOpen:a,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:u,soulDraft:r,templateNameDraft:h,changePersonalizationTemplate:v,changeSoulDraft:g,openSaveAsNew:f,resetPersonalizationDraft:c,savePersonalization:p,setSaveAsNewOpen:m,setTemplateNameDraft:j}){function C(P){P.preventDefault(),p(a)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:C,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:a?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:h,onChange:P=>j(P.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(le,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!r.trim()||!h.trim(),onClick:()=>{p(!0)},children:e.jsx(Ls,{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||!r.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(we,{value:t,disabled:l||n.length===0,label:"Personalization template",options:n,onChange:P=>{v(P)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:r,onChange:P=>g(P.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:c,children:e.jsx($e,{size:15})}),u&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(as,{size:15})})]})]})]})}function Tn({connection:s,profile:t,selectedDefaultTeamId:n}){const a=Gt(s),l=zn(a.schedules);return ns(a.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(xs,{pending:a.pendingScheduleIds.has(i.id),schedule:i,refreshing:a.loading,onRefresh:()=>{a.refresh()},onRun:()=>{a.run(i)},onToggle:()=>{a.toggle(i)}},i.id)),e.jsx(On,{}),t.agents.map(i=>e.jsx(En,{agent:i,defaultAction:t.summary.defaultAction,profile:t,selectedDefaultTeamId:n},i.id)),l.paused.map(i=>e.jsx(xs,{pending:a.pendingScheduleIds.has(i.id),schedule:i,refreshing:a.loading,onRefresh:()=>{a.refresh()},onRun:()=>{a.run(i)},onToggle:()=>{a.toggle(i)}},i.id))]})]})})]})}function On(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Oe,{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(Ce,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Ce,{status:{state:"ready",label:"Built in"}})})]})}function En({agent:s,defaultAction:t,profile:n,selectedDefaultTeamId:a}){const l=_n(n,s,a);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Oe,{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(Ce,{status:l.check})}),e.jsx("td",{children:e.jsx(Ce,{status:l.sync})})]})}function xs({pending:s,refreshing:t,schedule:n,onRefresh:a,onRun:l,onToggle:i}){const u=Un(n),r=n.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(Oe,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.localProjectName}),e.jsxs("span",{title:n.scheduleName,children:["schedule: ",n.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:n.targetAction,children:n.targetAction})})}),e.jsx("td",{children:e.jsx(Ce,{status:u})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:Bn(n),children:n.enabled?n.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${n.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:a,children:e.jsx(se,{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 ${n.scheduleName} now`,onClick:l,children:e.jsx($e,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:r,"aria-label":`${r}: ${n.scheduleName}`,onClick:i,children:n.enabled?e.jsx(Es,{size:14}):e.jsx(Bs,{size:14})})]})]})})]})}function Ce({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function zn(s){const t=[],n=[];for(const a of s)a.enabled?t.push(a):n.push(a);return t.sort((a,l)=>js(a)-js(l)),{active:t,paused:n}}function js(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function Un(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 Bn(s){const t=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&t.push(`next ${bs(s.nextRunAt)}`),s.lastRunAt&&t.push(`last ${bs(s.lastRunAt)}`),t.join(" - ")}function bs(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 _n(s,t,n){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||Fn(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(Hn(s,n))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const a=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"}}:a&&l&&a!==l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function Hn(s,t){const n=s.hosted?.teamId?.trim()??"";return!!(n&&t&&n!==t)}function Fn(s,t){let n=0;s.diff.changedAgents.includes(t.id)&&(n+=1),s.diff.newAgents.includes(t.id)&&(n+=1),s.diff.deletedAgents.includes(t.id)&&(n+=1);const a=t.path.replace(/^profiles\/[^/]+\//,"");for(const l of s.diff.files){const i=l.path.replace(/^profiles\/[^/]+\//,"");(i===a||i.startsWith(`${a}/`)||i.startsWith(`agents/${t.id}/`))&&(n+=1)}return n}function Gn({actions:s,busy:t,library:n,onSelect:a}){const l=n.profiles.find(u=>Je(u.ref,n.lastUsed))??n.profiles[0]??null,i=l?Ue(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||n.profiles.length===0,value:i,onChange:u=>{const r=yt(n,u.currentTarget.value),h=n.profiles.find(v=>Je(v.ref,r));h&&a(h)},children:n.profiles.length?n.profiles.map(u=>e.jsx("option",{value:Ue(u.ref),children:u.name},Ue(u.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Nt,{"aria-hidden":"true",size:14})]}),s]})}function qn({addDisabled:s,commitDisabled:t,commitLabel:n,refreshDisabled:a,repoDisabled:l,syncDisabled:i,syncLabel:u,syncStatus:r,onAdd:h,onCommit:v,onRefresh:g,onRepo:f,onSync:c}){const[p,m]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{if(!p)return;function P(R){j.current?.contains(R.target)||m(!1)}function x(R){R.key==="Escape"&&m(!1)}return document.addEventListener("pointerdown",P),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",P),document.removeEventListener("keydown",x)}},[p]);function C(P){m(!1),P()}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":p,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>m(P=>!P),children:e.jsx(St,{size:15})}),p?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>C(v),children:[e.jsx(Le,{size:14}),e.jsx("span",{children:n})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>C(c),children:[e.jsx(pe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:u}),r?e.jsx("small",{children:r}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>C(f),children:[e.jsx(Pe,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:a,role:"menuitem",type:"button",onClick:()=>C(g),children:[e.jsx(se,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>C(h),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const Wn=[{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 Vn({connection:s,entry:t,onClose:n,onPublished:a}){const[l,i]=o.useState("github"),[u,r]=o.useState(""),[h,v]=o.useState(`${t.name}-profile`),[g,f]=o.useState("public"),[c,p]=o.useState(()=>t.state.agents.filter(b=>b.enabled).map(b=>b.id)),[m,j]=o.useState(()=>t.state.skills.filter(b=>b.enabled).map(b=>b.name)),[C,P]=o.useState([]),[x,R]=o.useState(null),[A,N]=o.useState(null),[S,L]=o.useState(null),k=o.useMemo(()=>({ref:t.ref,selection:{agentIds:c,skillNames:m,optionalContent:C},target:{provider:l,owner:u.trim()||null,repository:h.trim(),visibility:l==="github"?"public":g}}),[c,t.ref,C,u,l,h,m,g]);function d(b,M,E){return E?[...new Set([...b,M])]:b.filter(G=>G!==M)}async function w(b){if(b.preventDefault(),!(!h.trim()||A)){N("preview"),L(null);try{R(await I.profilePublicationPreview(s,k))}catch(M){L(M instanceof Error?M.message:String(M))}finally{N(null)}}}async function y(){if(!(!x||x.blockedReasons.length>0||A)){N("publish"),L(null);try{const b=await I.profilePublicationPublish(s,{...k,expectedSourceHash:x.sourceHash,confirmed:!0});a(`Published ${t.name} to ${b.owner}/${b.repository}`),n()}catch(b){L(b instanceof Error?b.message:String(b))}finally{N(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,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:w,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!A,type:"button","aria-label":"Close",onClick:n,children:e.jsx(le,{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(Kn,{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(Ye,{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(wt,{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=>r(b.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:h,onChange:b=>v(b.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:g,onChange:b=>f(b.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ge,{title:"Agents",empty:"No Agents in this Profile",children:t.state.agents.map(b=>e.jsx(qe,{checked:c.includes(b.id),label:b.name,detail:b.path,onChange:M=>p(E=>d(E,b.id,M))},b.id))}),e.jsx(Ge,{title:"Skills",empty:"No Skills in this Profile",children:t.state.skills.map(b=>e.jsx(qe,{checked:m.includes(b.name),label:b.name,detail:b.description||b.path,onChange:M=>j(E=>d(E,b.name,M))},b.name))}),e.jsx(Ge,{title:"Optional content",empty:"",children:Wn.map(b=>e.jsx(qe,{checked:C.includes(b.id),label:b.label,detail:b.detail,onChange:M=>P(E=>d(E,b.id,M))},b.id))})]}),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:!!A,type:"button",onClick:x?()=>R(null):n,children:x?"Back":"Cancel"}),x?e.jsxs("button",{className:"git-dialog-primary",disabled:!!A||x.blockedReasons.length>0,type:"button",onClick:()=>{y()},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:A==="publish"?"Publishing":x.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!A||!h.trim(),type:"submit",children:A==="preview"?"Building preview":"Review exact files"})]})]})})}function Ge({title:s,empty:t,children:n}){const a=Array.isArray(n)?n.length:n?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),a?n:e.jsx("span",{className:"profile-publication-empty",children:t})]})}function qe({checked:s,label:t,detail:n,onChange:a}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:l=>a(l.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t}),e.jsx("small",{children:n})]})]})}function Kn({preview:s}){const t=s.files.reduce((n,a)=>n+a.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 · ",vs(t)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(n=>e.jsx("div",{className:"profile-dialog-warning",children:n},n)),s.warnings.map(n=>e.jsx("div",{className:"profile-publication-warning",children:n},n)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(n=>e.jsxs("div",{children:[e.jsx("span",{title:n.path,children:n.path}),e.jsxs("small",{children:[n.category," · ",vs(n.sizeBytes)]})]},n.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(n=>e.jsx("code",{children:n},n))]}):null]})}function vs(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Jn({section:s="all",catalogPresentation:t="list",payload:n,connection:a,onPayload:l,onError:i,onToast:u,onSkillCommand:r,overviewContent:h}){const[v,g]=o.useState(""),[f,c]=o.useState(null),[p,m]=o.useState(!1),[j,C]=o.useState(null),[P,x]=o.useState(null),R=n?.profile??null,A=n?.preferences.defaultTeamId?.trim()||"",N=s==="all"||s==="profile"||s==="controls",S=s==="all"||s==="profile",L=s==="all"||s==="agents",k=s==="all"||s==="profile";async function d(z){a&&(l(await I.bootstrap(a)),u?.(z,"success"))}async function w(z,Q){if(!(!a||f)){c(z),i(null);try{await Q()}catch(J){i(J instanceof Error?J.message:String(J))}finally{c(null)}}}function y(){w("init",async()=>{await I.profileInit(a,{}),await d("Profile initialized")})}function b(){w("commit",async()=>{await I.profileCommit(a,{message:v.trim()||null}),g(""),await d("Profile commit complete")})}function M(){w("push",async()=>{if(!A)throw new Error("Select a default team before syncing a hosted profile.");await I.profileCheck(a,{kind:"all"}),await I.profilePush(a,{teamId:A,ensureHosted:!0,message:null}),await d("Profile synced to hosted profile repo")})}function E(z){w(`select:${z.ref.profileId}`,async()=>{await I.profileSelect(a,z.ref),await d(`Using ${z.name}`)})}function G(z){w("add",async()=>{z.source==="blank"?await I.profileInit(a,{path:z.path,profile:z.profile,template:"blank-profile"}):z.source==="local"?await I.profileLoad(a,z):await I.profileInstall(a,z),m(!1),await d(z.source==="blank"?`${z.profile} created`:"Profile added")})}function K(z){w("update",async()=>{await I.profileUpdate(a,z.ref),await d(`${z.name} updated`)})}function Z(z){w("remove",async()=>{await I.profileRemove(a,z.ref),C(null),await d("Profile removed from this device")})}function $(){w("refresh",async()=>{await d("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:[S&&t==="select"?e.jsx(Gn,{actions:e.jsx(ys,{connection:a,onAdd:()=>m(!0),onRefresh:$,presentation:"menu",profile:R,profileBusy:f,profileCommitMessage:v,selectedDefaultTeamId:A,syncDisabledReason:Ns(R,A),setProfileCommitMessage:g,submitProfileCommit:b,submitProfilePush:M}),busy:!!f,library:n?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:E}):e.jsxs(e.Fragment,{children:[S?e.jsx(Yn,{busy:!!f,library:n?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>m(!0),onRefresh:$,onRemove:C,onPublish:x,onUpdate:K,onSelect:E}):null,e.jsx(ys,{connection:a,profile:R,profileBusy:f,profileCommitMessage:v,selectedDefaultTeamId:A,syncDisabledReason:Ns(R,A),setProfileCommitMessage:g,submitProfileCommit:b,submitProfilePush:M})]}),h]}):null,L?e.jsx(Tn,{connection:a,profile:R,selectedDefaultTeamId:A}):null,k?e.jsx(ta,{onSkillCommand:r,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:!a||!!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:!a||!!f,type:"button",onClick:y,children:[e.jsx(me,{size:14}),e.jsx("span",{children:f==="init"?"Creating":"Create starter Profile"})]})]})]}),p?e.jsx(Zn,{busy:!!f,onClose:()=>m(!1),onSubmit:G}):null,j?e.jsx(Xn,{busy:!!f,entry:j,onClose:()=>C(null),onConfirm:()=>Z(j)}):null,P&&a?e.jsx(Vn,{connection:a,entry:P,onClose:()=>x(null),onPublished:z=>u?.(z,"success")}):null]})}function Yn({busy:s,library:t,onAdd:n,onRefresh:a,onRemove:l,onPublish:i,onSelect:u,onUpdate:r}){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:a,children:[e.jsx(se,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:n,children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),t.profiles.map(h=>{const v=Je(h.ref,t.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${v?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||u(h)},onKeyDown:g=>{s||g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),u(h))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Pe,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:h.name}),e.jsx("span",{title:h.repoPath,children:h.repoPath})]})]}),e.jsx(qs,{status:{state:h.state.error?"warning":"ready",label:h.state.error?"error":v?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:h.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:h.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[h.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),r(h)},onKeyDown:g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),g.stopPropagation(),r(h))},children:[e.jsx(se,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),i(h)},onKeyDown:g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),g.stopPropagation(),i(h))},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 ${h.name}`,onClick:g=>{g.stopPropagation(),l(h)},onKeyDown:g=>{g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),g.stopPropagation(),l(h))},children:[e.jsx(be,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${h.ref.source}:${h.ref.repositoryId}:${h.ref.profileId}`)})]})}function Zn({busy:s,onClose:t,onSubmit:n}){const[a,l]=o.useState("blank"),[i,u]=o.useState(""),[r,h]=o.useState(""),[v,g]=o.useState("");function f(c){if(c.preventDefault(),s)return;if(a==="blank"){const m=v.trim();if(!m)return;n({source:a,path:i.trim()||null,profile:m});return}if(a==="local"){const m=i.trim();if(!m)return;n({source:a,path:m,profile:v.trim()||null});return}const p=r.trim();p&&n({source:a,repositoryId:p,profile:v.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:c=>c.stopPropagation(),onSubmit:f,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:t,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Pe,{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:a==="blank",onChange:()=>l("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:a==="local",onChange:()=>l("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:a==="github",onChange:()=>l("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:a==="openpond_git",onChange:()=>l("openpond_git")}),"OpenPond Git"]})]}),a==="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:c=>u(c.currentTarget.value)})]}):a==="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:c=>u(c.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[a==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:r,placeholder:"owner/repository",onChange:c=>h(c.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:a==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:a==="blank",disabled:s,value:v,placeholder:a==="blank"?"research":"Uses repository default",onChange:c=>g(c.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||!(a==="blank"?v:a==="local"?i:r).trim(),type:"submit",children:a==="blank"?"Create Profile":"Add Profile"})]})]})})}function Xn({busy:s,entry:t,onClose:n,onConfirm:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,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:n,children:e.jsx(le,{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:n,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:a,children:"Remove"})]})]})})}function ys({connection:s,onAdd:t,onRefresh:n,presentation:a="toolbar",profile:l,profileBusy:i,profileCommitMessage:u,selectedDefaultTeamId:r,syncDisabledReason:h,setProfileCommitMessage:v,submitProfileCommit:g,submitProfilePush:f}){const[c,p]=o.useState(!1),[m,j]=o.useState(!1),[C,P]=o.useState(!1),x=!s||!!i;return e.jsxs(e.Fragment,{children:[a==="menu"&&t&&n?e.jsx(qn,{addDisabled:!!i,commitDisabled:x,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:x,repoDisabled:!!i||!l,syncDisabled:x||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?We(l,r):null,onAdd:t,onCommit:()=>j(!0),onRefresh:n,onRepo:()=>p(!0),onSync:()=>P(!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(Le,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:x||!l,type:"button",onClick:()=>P(!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:()=>p(!0),children:[e.jsx(Pe,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${We(l,r)}`,children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:We(l,r)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),c&&l?e.jsx(sa,{profile:l,profileBusy:i,onClose:()=>p(!1)}):null,m?e.jsx(Qn,{disabled:x,profileBusy:i,profileCommitMessage:u,setProfileCommitMessage:v,submitProfileCommit:g,onClose:()=>j(!1)}):null,C&&l?e.jsx(ea,{disabled:x,profile:l,profileBusy:i,selectedDefaultTeamId:r,syncDisabledReason:h,submitProfilePush:f,onClose:()=>P(!1)}):null]})}function Qn({disabled:s,profileBusy:t,profileCommitMessage:n,setProfileCommitMessage:a,submitProfileCommit:l,onClose:i}){function u(r){r.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:r=>r.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(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Le,{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:n,disabled:!!t,placeholder:"Update OpenPond profile",onChange:r=>a(r.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(Le,{size:14}),e.jsx("span",{children:t==="commit"?"Committing":"Commit"})]})]})]})})}function ea({disabled:s,profile:t,profileBusy:n,selectedDefaultTeamId:a,syncDisabledReason:l,submitProfilePush:i,onClose:u}){const r=aa(t,a),h=r.reduce((f,c)=>f+c.count,0),v=!s&&!l;function g(f){f.preventDefault(),v&&(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:g,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(le,{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:[h," ",h===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",ve(t.summary.localHead??t.git?.head)," - Last pushed"," ",ve(t.hosted?.lastPushedLocalHead)]})]}),r.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:r.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:!!n,type:"button",onClick:u,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!v,type:"submit",children:[e.jsx(pe,{size:14}),e.jsx("span",{children:n==="push"?"Syncing":"Confirm sync"})]})]})]})})}function sa({profile:s,profileBusy:t,onClose:n}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:a=>a.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!t,type:"button",title:"Close","aria-label":"Close",onClick:n,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Pe,{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"," · ",ve(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!t,type:"button",onClick:n,children:"Close"})})]})})}function ta({onSkillCommand:s,profile:t}){const n=t.skills.slice().sort((i,u)=>i.name.localeCompare(u.name)),a=!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"]})})]}),n.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:n.map(i=>e.jsx(na,{commandDisabled:a,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 na({commandDisabled:s,onSkillCommand:t,skill:n}){const a=n.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:n.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Me,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.name}),e.jsx("span",{title:n.path,children:n.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:n.description,children:n.description||"No description"}),e.jsx("td",{children:e.jsx(qs,{status:a})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:n.sourcePath,children:n.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:s||!n.enabled,type:"button",title:`Use ${n.name}`,onClick:()=>t(`$${n.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${n.name}`,onClick:()=>t(`/skill edit ${n.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function qs({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ve(s){return s?s.slice(0,10):"None"}function We(s,t){return Ws(s,t)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${ve(s.hosted.sourceCommitSha)}`:"Not pushed"}function Ns(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 aa(s,t){const n=[],a=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null,i=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(Ws(s,t)&&n.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!i&&!l?n.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):a&&l&&a!==l&&n.push({label:"Commit",detail:`Local ${ve(a)} has not been pushed since ${ve(l)}.`,count:1}),s.git?.dirty){const r=s.git.files.length||s.diff.files.length||1;n.push({label:"Uncommitted files",detail:`${r} local ${r===1?"file":"files"} changed.`,count:r,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&&n.push({label:"Profile changes",detail:la(s),count:u,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&n.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&n.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),n}function la(s){const t=[],n=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return n&&t.push(`${n} agent ${n===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 Ws(s,t){const n=s.hosted?.teamId?.trim()??"";return!!(n&&t&&n!==t)}const ia=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],ra=120,oa=new Set(["openai","xai","zai"]),ca=new Set(["chatgpt-subscription"]),da="https://api.z.ai/api/coding/paas/v4";function Ss(s){return s.split(/[\n,]/).map(t=>t.trim()).filter(Boolean)}function Vs(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 Ks(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function ws(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 ua(s){return s?.trim().replace(/\/+$/,"")??""}function Js(s,t){return s.id==="zai"&&ua(t.providers.zai?.baseUrl)===da}function ha(s,t){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":Js(s,t)?"Coding Plan key":"API key"}function ma(s,t){const n=t.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const a=Math.max(n?.models.length??0,s.modelIds.length),l=s.defaultModel?Xe(s.defaultModel,t,s.id):"",i=a===1?"1 model":`${a} models`,u=ha(s,t);return[Vs(s),u,n?i:"",l].filter(Boolean).join(" · ")}function pa(s){return s!=="openpond"&&Ze(s)}function ls(s){return s?oa.has(s.id)||s.credentialModes.some(t=>ca.has(t)):!1}function ga(s){return ls(s)?["api","subscription"]:["api"]}function Cs(s,t){return!s||!t||!ls(s)?"api":s.credential.source==="chatgpt_subscription"||Js(s,t)?"subscription":"api"}function ks(s,t){const n=Ct.filter(a=>!!s?.statuses[a]);return t?n.filter(a=>ls(s?.statuses[a])):n}function fa(s){if(!s)return"Never";const t=new Date(s);return Number.isNaN(t.getTime())?s:t.toLocaleString()}function xa(s,t,n=ra){const a=[],l=new Set,i=new Set(t.map(r=>r.trim()).filter(Boolean)),u=r=>{l.has(r.value)||a.length>=n||(l.add(r.value),a.push(r))};for(const r of s)i.has(r.value)&&u(r);for(const r of s)u(r);return a}function ja({account:s,codex:t,providers:n,providerBusy:a,validationMessage:l,deleteProviderCredential:i,loadProviderModels:u,refreshProviderModels:r,saveProviderConfig:h,saveProviderCredential:v,startOpenAiSubscriptionAuth:g,validateProvider:f}){const[c,p]=o.useState(null),[m,j]=o.useState(!1),C=o.useMemo(()=>ks(n,!1),[n]),P=o.useMemo(()=>ks(n,m),[n,m]),x=c?n?.statuses[c]??null:null;function R(A,N){p(A),N&&u(A)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),n?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:A=>j(A.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[P.length," of ",C.length," presets"]})]}),P.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:P.map(A=>{const N=n.statuses[A],S=n.modelCaches[A],L=N.modelIds.length>0&&(S?.models.length??0)<N.modelIds.length,k=a?.startsWith(`${A}:`)??!1,d=pa(A),w=A==="openpond"||!!n.providers[A]?.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:w,disabled:!d||k,onChange:y=>{R(A,!1),h(A,{enabled:y.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 ${Ks(N)}`,children:[k?e.jsx(ne,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:ma(N,n)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{R(A,L)},children:"Details"})]},A)})}):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,c&&x&&n?e.jsx(ba,{account:s,codex:t,providerId:c,providerBusy:a,settings:n,status:x,onClose:()=>p(null),onDeleteCredential:i,onRefreshModels:r,onSaveConfig:h,onSaveCredential:v,onStartOpenAiSubscriptionAuth:g,onValidate:f}):null]})}function ba({account:s,codex:t,providerId:n,providerBusy:a,settings:l,status:i,onClose:u,onDeleteCredential:r,onRefreshModels:h,onSaveConfig:v,onSaveCredential:g,onStartOpenAiSubscriptionAuth:f,onValidate:c}){const p=l.providers[n],m=l.modelCaches[n],j=o.useId(),C=o.useRef(n),P=Math.max(m?.models.length??0,i.modelIds.length),x=i.routing.localByok&&Ze(n)&&n!=="codex",R=o.useMemo(()=>x?ga(i):[],[x,i]),A=R.includes("subscription"),[N,S]=o.useState(()=>Cs(i,l)),L=x&&N==="subscription"&&A,k=w=>`${j}-${w}-panel`,d=n==="codex"?"Codex app server":p?.baseUrl??(n==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return o.useEffect(()=>{if(C.current!==n){C.current=n,S(Cs(i,l));return}x&&!R.includes(N)&&S("api")},[N,R,x,n,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:w=>w.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:u,children:e.jsx(le,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.displayName}),e.jsx("span",{children:Ie(n,l)})]}),e.jsx("div",{className:`provider-state-pill ${Ks(i)}`,children:Vs(i)})]}),x?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:R.map(w=>e.jsx("button",{type:"button",role:"tab",id:`${j}-${w}`,className:N===w?"active":void 0,"aria-selected":N===w,"aria-controls":k(w),onClick:()=>S(w),children:w==="api"?"API":"Subscription"},w))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:ws(i),children:ws(i)})]}),L?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:d,children:d})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:p?.defaultModel??i.defaultModel??void 0,children:p?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:m?.lastError??void 0,children:[P," cached · ",fa(m?.fetchedAt)]})]})]}),n==="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]}),n==="codex"?e.jsx(va,{providerBusy:a,status:i,onValidate:c}):x&&p&&m?e.jsx(ya,{credentialTab:N,credentialTabsId:j,hasSubscriptionTab:A,providerId:n,providerBusy:a,settings:l,status:i,onDeleteCredential:r,onRefreshModels:h,onSaveConfig:v,onSaveCredential:g,onStartOpenAiSubscriptionAuth:f,onValidate:c}):i.routing.localByok&&!Ze(n)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Us,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function va({providerBusy:s,status:t,onValidate:n}){const a=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:a,onClick:()=>{n("codex",{modelId:t.defaultModel??void 0})},children:[a?e.jsx(ne,{size:14,className:"settings-spin"}):e.jsx(Ts,{size:14}),e.jsx("span",{children:a?"Testing":"Test Codex login"})]})})]})}function ya({credentialTab:s,credentialTabsId:t,hasSubscriptionTab:n,providerId:a,providerBusy:l,settings:i,status:u,onDeleteCredential:r,onRefreshModels:h,onSaveConfig:v,onSaveCredential:g,onStartOpenAiSubscriptionAuth:f,onValidate:c}){const p=i.providers[a],m=o.useMemo(()=>Te(a,i),[a,i]),j=`provider-models-${a}`,C=o.useRef(a),[P,x]=o.useState(p.baseUrl??""),[R,A]=o.useState(p.defaultModel??""),[N,S]=o.useState(p.modelOverrides.join(`
3
+ `)),[L,k]=o.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[d,w]=o.useState("local_secret"),[y,b]=o.useState(""),[M,E]=o.useState(""),G=l===`${a}:config`,K=l===`${a}:credential`,Z=l===`${a}:validate`,$=l===`${a}:models`,z=l==="openai:credential",Q=a==="openai",J=a==="xai",H=a==="zai",V=(T=>`${t}-${T}-panel`)(s),U=s==="subscription"&&n,te=s==="subscription"&&H?"coding-plan":"api",ae=te==="coding-plan"?"Coding Plan key":"API key",q=u.credential.connected?te==="coding-plan"?"Replace saved plan key":"Replace saved key":ae,re=te==="coding-plan"?"Save plan key":"Save key",ce=o.useMemo(()=>xa(m,[R,...Ss(N)]),[R,m,N]),ee=Math.max(0,m.length-ce.length);o.useEffect(()=>{if(C.current!==a){C.current=a,k({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),x(p.baseUrl??""),A(p.defaultModel??""),S(p.modelOverrides.join(`
4
+ `));return}L.baseUrl||x(p.baseUrl??""),L.defaultModel||A(p.defaultModel??""),L.modelOverrides||S(p.modelOverrides.join(`
5
+ `))},[p.baseUrl,p.defaultModel,p.modelOverrides,L.baseUrl,L.defaultModel,L.modelOverrides,a]);const oe=d==="env"?!!M.trim():!!y.trim();async function xe(T){T.preventDefault(),await v(a,{enabled:!0,baseUrl:P.trim()||null,defaultModel:R.trim()||null,modelOverrides:Ss(N)}),k({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function O(T){if(T.preventDefault(),!!oe){if(d==="env"){await g(a,{source:"env",envVar:M.trim()});return}await g(a,{source:"local_secret",value:y}),b("")}}function B({panel:T=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:T?V:void 0,role:T?"tabpanel":void 0,"aria-labelledby":T?`${t}-${s}`:void 0,onSubmit:W=>{O(W)},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(we,{value:d,disabled:K,label:"Credential source",options:ia,onChange:W=>w(W)})]}),d==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:M,disabled:K,placeholder:"PROVIDER_API_KEY",onChange:W=>E(W.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:ae}),e.jsx("input",{type:"password",value:y,disabled:K,placeholder:q,autoComplete:"off",onChange:W=>b(W.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:K||!oe,children:[K?e.jsx(ne,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:K?"Saving":re})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:K||!u.credential.connected,onClick:()=>{r(a)},children:e.jsx(be,{size:15})})]})]})}function _(){return Q?e.jsxs("div",{className:"provider-subscription-panel",id:V,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:z,onClick:()=>{f("browser")},children:[z?e.jsx(ne,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:z?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:z,onClick:()=>{f("device")},children:[z?e.jsx(ne,{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:z||!u.credential.connected,onClick:()=>{r(a)},children:e.jsx(be,{size:15})})]})]}):J?e.jsx("div",{className:"provider-subscription-panel",id:V,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."})]})}):H?e.jsxs("div",{className:"provider-subscription-panel",id:V,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:T=>{xe(T)},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:P,disabled:G,placeholder:"https://api.example.com/v1",onChange:T=>{k(W=>({...W,baseUrl:!0})),x(T.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:T=>{k(W=>({...W,defaultModel:!0})),A(T.currentTarget.value)}}),e.jsx("datalist",{id:j,children:ce.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))}),ee>0?e.jsxs("small",{children:[ee," 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(ne,{size:14,className:"settings-spin"}):e.jsx(as,{size:14}),e.jsx("span",{children:G?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:$,onClick:()=>{h(a)},children:[$?e.jsx(ne,{size:14,className:"settings-spin"}):e.jsx(se,{size:14}),e.jsx("span",{children:$?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Z||!R.trim(),onClick:()=>{c(a,{baseUrl:P.trim()||void 0,modelId:R.trim()||void 0})},children:[Z?e.jsx(ne,{size:14,className:"settings-spin"}):e.jsx(Ts,{size:14}),e.jsx("span",{children:Z?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:U?_():B()})]})}function Na({status:s,busy:t,flashTailscaleUp:n,refresh:a,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:u,copyTailscaleUpCommand:r,copyServeCommand:h,copyServeSetupUrl:v,copyOperatorCommand:g,createRemoteLink:f}){const c=s?.tailscale.installed??!1,p=s?.serve.enabled??!1,m=s?.serve.reachable??!1,j=!!(s?.webUiAvailable&&c),C=p?!!s?.remoteWebUrl:j,x=(s?.tailscale.peers??[]).filter(N=>!N.isSelf),R=!!s?.tailscale.error?.includes("set --operator"),A=!!(p&&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":p?"configured":""}`,children:c?e.jsx(Hs,{size:18}):e.jsx(Ht,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:m?"Tailscale Serve is reachable":p?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Ca(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:()=>{a()},children:e.jsx(se,{className:t==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t!==null||!c||!p&&!j,onClick:()=>{p?i():l()},children:[e.jsx(tn,{size:15}),e.jsx("span",{children:p?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:A?"Browser UI":"Tailscale + Serve"})]})}),A&&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:n,actionLabel:t==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||t!==null,onAction:r}),e.jsx(de,{label:"Serve command",value:s?.serveCommand??null,actionLabel:t==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||t!==null,onAction:h}),s?.serve.setupUrl&&e.jsx(de,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:t==="copy-serve-setup"?"Copying":"Copy",disabled:t!==null,onAction:v}),R&&e.jsx(de,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:t==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||t!==null,onAction:g}),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||!C,onClick:()=>{f()},children:e.jsx("span",{children:p?"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(N=>e.jsx(wa,{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(Sa,{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:n,label:a,onAction:l,value:i}){return e.jsxs("div",{className:"product-row remote-access-value-row",children:[e.jsxs("div",{children:[e.jsx("strong",{className:n?"flash":void 0,children:a}),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 Sa({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"}],n=[{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(a=>e.jsx(Ps,{label:a.label,value:a.value},a.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:n.map(a=>e.jsx(Ps,{label:a.label,value:a.value},a.label))})]})}function Ps({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 wa({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 Ca(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 ka=[{items:[{section:"account",label:"Account",Icon:cn},{section:"notifications",label:"Notifications",Icon:_s},{section:"providers",label:"Providers",Icon:Pt},{section:"compute",label:"Compute",Icon:qt},{section:"dataset-storage",label:"Dataset Storage",Icon:Qt},{section:"usage",label:"Activity",Icon:Rt},{section:"defaults",label:"Defaults",Icon:Fs}]},{label:"Harness",items:[{section:"harness",label:"Harness",Icon:_e},{section:"skills",label:"Skills",Icon:Me},{section:"context",label:"Context",Icon:At},{section:"training",label:"Training",Icon:_e},{section:"subagents",label:"Subagents",Icon:_e}]},{items:[{section:"profile",label:"Legacy Profiles",Icon:Oe},{section:"editor",label:"Editor",Icon:Bt},{section:"remote",label:"Remote",Icon:Hs},{section:"personalization",label:"Personalization",Icon:Wt},{section:"diagnostics",label:"Diagnostics",Icon:Ft}]}];function Pa({section:s,onBack:t,onSectionChange:n}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back",onClick:t,children:[e.jsx(kt,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:ka.map((a,l)=>e.jsxs("div",{className:"settings-nav-group",children:[a.label?e.jsx("div",{className:"settings-nav-heading",children:a.label}):null,a.items.map(({section:i,label:u,Icon:r})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>n(i),children:[e.jsx(r,{size:16}),e.jsx("span",{children:u})]},i))]},a.label??`settings-${l}`))})]})}function Ra({catalog:s,connection:t,onCatalog:n,onError:a,onOpenExtension:l,onToast:i}){const[u,r]=o.useState(""),[h,v]=o.useState(""),[g,f]=o.useState(null),[c,p]=o.useState(null),[m,j]=o.useState(null),C=o.useCallback(d=>{const w=d instanceof Error?d.message:String(d);j(w),a(w),i?.(w,"error")},[a,i]),P=o.useCallback(()=>{j(null),a(null)},[a]),x=o.useCallback(async d=>{if(d?.preventDefault(),!(!t||!u.trim()||c)){P(),p("preview");try{const w=await I.extensionPreview(t,{source:u.trim(),...h.trim()?{ref:h.trim()}:{}});f(w)}catch(w){f(null),C(w)}finally{p(null)}}},[c,P,t,C,h,u]),R=o.useCallback(async()=>{if(!(!t||!g||c)){P(),p("install");try{const d=await I.extensionAdd(t,{source:g.repositoryUrl,ref:g.requestedRef});n(d.catalog),r(""),v(""),f(null),i?.(`Installed ${d.extension.owner}/${d.extension.repo}.`,"success")}catch(d){C(d)}finally{p(null)}}},[c,P,t,n,i,g,C]),A=o.useCallback(async d=>{if(!(!t||c)){P(),p(`update:${d.id}`);try{const w=await I.extensionUpdate(t,d);n(w.catalog);const y=w.extension.resolvedCommit===d.resolvedCommit&&w.extension.packageHash===d.packageHash;i?.(y?`${d.owner}/${d.repo} is already current.`:`Updated ${d.owner}/${d.repo}.`,"success")}catch(w){C(w)}finally{p(null)}}},[c,P,t,n,i,C]),N=o.useCallback(async()=>{if(!(!t||c||s.extensions.length===0)){P(),p("update-all");try{const d=await I.extensionUpdateAll(t);n(d.catalog);const w=`Updated ${d.updated.length}; ${d.unchanged.length} already current${d.failed.length?`; ${d.failed.length} failed`:""}.`;i?.(w,d.failed.length?"error":"success"),d.failed.length&&j(d.failed.map(y=>y.error).join(" "))}catch(d){C(d)}finally{p(null)}}},[c,s.extensions.length,P,t,n,i,C]),S=o.useCallback(async d=>{if(!(!t||c)&&window.confirm(`Remove ${d.owner}/${d.repo} and its ${d.skills.length} installed skill${d.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){P(),p(`remove:${d.id}`);try{const w=await I.extensionRemove(t,d);n(w.catalog),i?.(`Removed ${d.owner}/${d.repo}.`,"success")}catch(w){C(w)}finally{p(null)}}},[c,P,t,n,i,C]),L=o.useCallback(d=>{r(d),f(null),j(null)},[]),k=o.useCallback(d=>{v(d),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||c!==null||s.extensions.length===0,type:"button",onClick:()=>{N()},children:[c==="update-all"?e.jsx(ne,{className:"settings-spin",size:13}):e.jsx(se,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:d=>{x(d)},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||c!==null,placeholder:"owner/repo",value:u,onChange:d=>L(d.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!t||c!==null,placeholder:"Default branch",value:h,onChange:d=>k(d.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!u.trim()||c!==null,type:"submit",children:[c==="preview"?e.jsx(ne,{className:"settings-spin",size:14}):e.jsx(Ye,{size:14}),c==="preview"?"Checking":"Preview"]})]}),m||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:m??s.error}):null,g?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[g.owner,"/",g.repo]}),e.jsxs("span",{children:[g.skills.length," skill",g.skills.length===1?"":"s"," at ",g.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:g.skills.map(d=>e.jsx("span",{children:d.name},d.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:c!==null,type:"button",onClick:()=>{R()},children:[c==="install"?e.jsx(ne,{className:"settings-spin",size:14}):e.jsx(me,{size:14}),c==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(d=>{const w=c===`update:${d.id}`,y=c===`remove:${d.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${d.owner}/${d.repo} extension source`,className:"github-extension-open",disabled:!t||c!==null,type:"button",onClick:()=>l(d),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Ye,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[d.owner,"/",d.repo]}),e.jsx("span",{children:d.skills.map(b=>b.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[d.skills.length," skill",d.skills.length===1?"":"s"]}),e.jsxs("span",{children:[d.requestedRef," · ",d.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${d.validationStatus==="valid"?"":"invalid"}`,children:d.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(Os,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${d.owner}/${d.repo}`,className:"settings-icon-button ghost",disabled:c!==null,title:"Update extension",type:"button",onClick:()=>{A(d)},children:w?e.jsx(ne,{className:"settings-spin",size:14}):e.jsx(se,{size:14})}),e.jsx("button",{"aria-label":`Remove ${d.owner}/${d.repo}`,className:"settings-icon-button ghost danger",disabled:c!==null,title:"Remove extension",type:"button",onClick:()=>{S(d)},children:y?e.jsx(ne,{className:"settings-spin",size:14}):e.jsx(be,{size:14})})]})]},d.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function Aa({onOpenSkill:s,onOpenExtension:t,personalSkills:n,extensionCatalog:a,connection:l,onExtensionCatalog:i,onError:u,onToast:r}){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(Ra,{catalog:a,connection:l,onCatalog:i,onError:u,onOpenExtension:t,onToast:r}),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"})]}),n.length?n.map(h=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Me,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:h.name}),e.jsx("span",{children:h.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:h.resourceFiles.length?`${h.resourceFiles.length} packaged resource${h.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:h.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${h.validationStatus==="valid"?"":"invalid"}`,children:h.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},h.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"})]}),Dt.map(h=>{const v=It(h.provider)?.label??h.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(h),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Me,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:h.name}),e.jsx("span",{children:h.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:v}),e.jsx("span",{children:h.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(Os,{size:16,"aria-hidden":"true"})]},h.name)})]})]})}const is="default";function Da({connection:s,embedded:t=!1,onError:n,onPreferences:a,preferences:l,providers:i}){const u=l.training,[r,h]=o.useState(Ve(u.defaultModelRef)),[v,g]=o.useState(u.creationMode),[f,c]=o.useState(u.autoApproveEvidence),[p,m]=o.useState(!1),j=o.useMemo(()=>$s(i,{includeUnavailable:!0}),[i]),C=o.useMemo(()=>j.map(N=>({provider:N,models:Te(N.value,i)})).filter(N=>N.models.length>0),[j,i]),P=Ia(r),x=Mt(l.defaultChatProvider,l.defaultChatModel,i)?` · ${Ma(l.codexReasoningEffort)} reasoning`:"",R=$a(P,u.defaultModelRef??null)&&v===u.creationMode&&f===u.autoApproveEvidence;o.useEffect(()=>{h(Ve(u.defaultModelRef)),g(u.creationMode),c(u.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,u.autoApproveEvidence,u.creationMode,u.defaultModelRef]);async function A(N){if(N.preventDefault(),!!s){m(!0),n(null);try{a(await I.savePreferences(s,{training:{defaultModelRef:P,creationMode:v,autoApproveEvidence:f}}))}catch(S){n(S instanceof Error?S.message:String(S))}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:N=>{A(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:r,disabled:p,onChange:N=>h(N.target.value),children:[e.jsxs("option",{value:is,children:["Use chat default — ",Ie(l.defaultChatProvider,i)," · ",Xe(l.defaultChatModel,i,l.defaultChatProvider),x]}),C.map(N=>e.jsx("optgroup",{label:N.provider.label,children:N.models.map(S=>e.jsx("option",{value:Ve({providerId:N.provider.value,modelId:S.value}),children:S.label},S.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:v,disabled:p,onChange:N=>g(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:f,disabled:p,onChange:N=>c(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:p||R,children:e.jsx("span",{children:p?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:P?`${Ie(P.providerId,i)} / ${Xe(P.modelId,i,P.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 Ve(s){return s?JSON.stringify([s.providerId,s.modelId]):is}function Ia(s){if(s===is)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 Ma(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function $a(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}function Ys({disabled:s,onChange:t,purpose:n="model",storageRoots:a,value:l}){const i=o.useId(),[u,r]=o.useState(!1),h=Rs(l),v=c=>n==="dataset"?c.datasetStorePath:c.modelStorePath,g=n==="dataset"?"Dataset":"Model",f=a.find(c=>Rs(v(c))===h)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:i,children:[g," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${g} storage drive`,className:"model-storage-select",disabled:s,id:i,title:l??`No ${n} storage configured`,value:l??"",onChange:c=>t(c.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),l&&!f?e.jsx("option",{value:l,children:"Manual location"}):null,a.map(c=>e.jsxs("option",{disabled:!c.mounted||!c.writable,title:v(c),value:v(c),children:[c.label," · ",Ea(c.kind)," · ",za(c)]},c.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":`Add manual ${n} storage location`,onClick:()=>r(!0),children:e.jsx(me,{size:15})})]}),u?La(e.jsx(Ta,{initialPath:l??"",purpose:n,onClose:()=>r(!1),onUse:c=>{t(c),r(!1)}})):null]})}function La(s){return typeof document>"u"?s:Vt.createPortal(s,document.body)}function Ta({initialPath:s,onClose:t,onUse:n,purpose:a="model"}){const l=o.useId(),[i,u]=o.useState(s),r=Oa(i);o.useEffect(()=>{const v=g=>{g.key==="Escape"&&t()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[t]);function h(v){v.preventDefault(),v.stopPropagation(),!r&&n(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:h,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${a} storage`,onClick:t,children:e.jsx(le,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Kt,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",a," 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:a==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:v=>u(v.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()&&r?e.jsx("div",{className:"profile-dialog-warning",children:r}):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:!!r,type:"submit",children:"Use location"})]})]})})}function Oa(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 Ea(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function za(s){return s.mounted?s.writable?`${Ua(s.freeBytes)} free`:"Read only":"Not mounted"}function Rs(s){const t=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(t)?t.toLowerCase():t}function Ua(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let n=s,a=-1;do n/=1024,a+=1;while(n>=1024&&a<t.length-1);return`${n>=10?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Ba({state:s,busy:t,title:n="Compute",onScan:a,onSave:l,onDownloadSmolLm2:i,onCancelDownload:u}){const r=s?.inventory??null,[h,v]=o.useState(s?.settings.modelStorePath??null),[g,f]=o.useState(s?.settings.defaultDeviceIds[0]??"automatic");o.useEffect(()=>{v(s?.settings.modelStorePath??null)},[s?.settings.modelStorePath]),o.useEffect(()=>{f(s?.settings.defaultDeviceIds[0]??"automatic")},[s?.settings.defaultDeviceIds]);const c=h===(s?.settings.modelStorePath??null)&&g===(s?.settings.defaultDeviceIds[0]??"automatic"),p=o.useMemo(()=>r?.devices.filter(x=>x.kind!=="cpu"&&x.available)??[],[r?.devices]),m=r?.models.find(x=>x.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,j=[...r?.downloads??[]].reverse().find(x=>x.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct")??null,C=!!(j&&["queued","downloading","verifying","cancelling"].includes(j.status));async function P(x){x.preventDefault(),await l(h,s?.settings.datasetStorePath??null,g==="automatic"?[]:[g])}return e.jsxs("section",{className:"account-settings compute-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsx("h1",{children:n}),e.jsx("button",{className:"settings-icon-button",type:"button",title:"Scan compute","aria-label":"Scan compute",disabled:t!==null,onClick:()=>{a()},children:e.jsx(se,{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:r?`${r.host.operatingSystem} · ${r.host.architecture}`:t==="load"?"Loading this machine":"This machine has not been scanned"}),e.jsx("small",{children:r?`${r.devices.length} device${r.devices.length===1?"":"s"} · ${Se(r.host.totalMemoryBytes)} memory · scanned ${Ga(r.scannedAt)}`:"Run a bounded native scan to discover local training capabilities."})]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:x=>{P(x)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Defaults"})}),e.jsx(Ys,{disabled:t!==null,storageRoots:r?.storageRoots??[],value:h,onChange:v}),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:g,disabled:t!==null,onChange:x=>f(x.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),p.map(x=>e.jsx("option",{value:x.id,children:x.name},x.id))]})]})}),e.jsx("button",{className:"settings-primary",disabled:t!==null||c,children:t==="save"?"Saving":"Save compute settings"})]}),e.jsx(As,{title:"Devices",empty:"No devices discovered",rows:(r?.devices??[]).map(x=>({id:x.id,title:x.name,detail:_a(x),meta:x.available?"Available":x.unavailableReason??"Unavailable"}))}),e.jsx(As,{title:"Runtimes",empty:"No runtimes discovered",rows:(r?.runtimes??[]).map(x=>({id:x.id,title:Ha(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:[C&&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:r?.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:`${Fa(j.status)} · ${Se(j.downloadedBytes)} of ${Se(j.expectedBytes)} · Apache-2.0`})]}),e.jsx("progress",{max:j.expectedBytes,value:j.downloadedBytes})]}):null,r?.models.length?r.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," · ",Se(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"})})]}),r?.warnings.length?e.jsxs("details",{className:"compute-diagnostics",children:[e.jsx("summary",{children:"Diagnostics"}),e.jsx("ul",{children:r.warnings.map(x=>e.jsx("li",{children:x},x))})]}):null]})}function As({title:s,empty:t,rows:n}){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:n.length})]}),n.length?n.map(a=>e.jsxs("div",{className:"compute-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a.title}),e.jsx("small",{children:a.detail})]}),e.jsx("span",{children:a.meta})]},a.id)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t})})]})}function _a(s){return[s.vendor,s.kind,s.totalMemoryBytes?Se(s.totalMemoryBytes):null,s.computeCapability?`compute ${s.computeCapability}`:null].filter(Boolean).join(" · ")}function Ha(s){return s==="trl_peft"?"TRL / PEFT":s.toUpperCase()}function Fa(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Ga(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function Se(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let n=s,a=-1;do n/=1024,a+=1;while(n>=1024&&a<t.length-1);return`${n>=10?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function qa({state:s,catalog:t,busy:n,catalogLoading:a,onRefresh:l,onSave:i}){const[u,r]=o.useState(s?.settings.datasetStorePath??null);o.useEffect(()=>{r(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const h=o.useMemo(()=>s?.inventory?.storageRoots.find(c=>Ds(c.datasetStorePath)===Ds(u))??null,[u,s?.inventory?.storageRoots]),v=u===(s?.settings.datasetStorePath??null),g=t?.datasets??[];async function f(c){c.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:n!==null||a,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(se,{className:a?"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:h?.label??(u?"Manual location":"Not configured")}),e.jsx("small",{children:u??"Choose a writable local or mounted location before importing a Dataset."}),h?e.jsxs("small",{children:[Ja(h.kind)," · ",h.freeBytes==null?"Free space unknown":`${Zs(h.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:c=>{f(c)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(Ys,{disabled:n!==null,onChange:r,purpose:"dataset",storageRoots:s?.inventory?.storageRoots??[],value:u}),e.jsx("button",{className:"settings-primary",disabled:n!==null||v,children:n==="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:g.length})]}),g.length?g.map(c=>e.jsx(Wa,{dataset:c},c.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:a?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Wa({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:[Xs(s.rowCount)," rows"," · ",Va(s)," · ",t," · ",s.sizeBytes==null?"Size unavailable":Zs(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?Ka(s.status):"Unavailable"})]})}function Va(s){return[["train",s.splitCounts.train],["validation",s.splitCounts.validation],["test",s.splitCounts.test],["frozen eval",s.splitCounts.frozen_eval]].filter(([,n])=>Number(n)>0).map(([n,a])=>`${Xs(Number(a))} ${n}`).join(" · ")||"No split rows"}function Zs(s){if(s<1024)return`${s} B`;const t=["KB","MB","GB","TB"];let n=s,a=-1;do n/=1024,a+=1;while(n>=1024&&a<t.length-1);return`${n>=10?n.toFixed(0):n.toFixed(1)} ${t[a]}`}function Xs(s){return new Intl.NumberFormat().format(s)}function Ds(s){return s?.replace(/[\\/]+$/,"")??""}function Ka(s){return s.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Ja(s){return s.replace(/^./,t=>t.toUpperCase())}function Re(s){const t=new Date(s);return Number.isNaN(t.valueOf())?s:t.toLocaleString()}function ke(s){return s?s.slice(0,10):"none"}function Is(s,t,n){return{workspaceId:s,baseRelease:t?{id:t.id,contentHash:t.contentHash}:null,targetRelease:{id:n.id,contentHash:n.contentHash},title:n.current?"Current Harness release":`Harness release ${ke(n.contentHash)}`}}function Ya({change:s,onOpenDiff:t,onOpenSourceSession:n}){const a=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:Re(s.receipt.createdAt)})]}),e.jsxs("div",{className:"harness-history-release-flow",children:[e.jsx("code",{children:ke(s.receipt.previousRelease?.contentHash)}),e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("code",{children:ke(s.receipt.nextRelease?.contentHash)}),e.jsxs("span",{children:["channel ",s.receipt.previousChannelRevision," → ",s.receipt.nextChannelRevision]})]}),e.jsx("p",{children:s.receipt.reason}),t||a&&n?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,a&&n?e.jsx("button",{className:"settings-secondary compact",onClick:()=>n(a),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 Za({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:Re(s.decision.createdAt)})]}),e.jsx("p",{children:s.decision.reason}),s.trigger?e.jsxs("small",{children:["Triggered by ",s.trigger.reason]}):null]})}function Xa({review:s,busy:t,onReview:n}){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:Re(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(a=>a.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(a=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[a.operation," · ",a.target]}),e.jsx("span",{children:a.summary})]}),a.content!==null?e.jsx("pre",{children:a.content}):e.jsx("p",{children:"File deleted."})]},a.id))})]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(a=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${a.status}`,children:a.status}),e.jsx("strong",{children:a.kind.replaceAll("_"," ")}),e.jsx("span",{children:a.summary})]},a.id))}),e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:t,onClick:()=>n(s,"decline"),type:"button",children:[e.jsx(le,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:t||s.validations.some(a=>a.status!=="passed"),onClick:()=>n(s,"approve"),type:"button",children:[e.jsx(Ls,{size:13})," Approve and release"]})]})]})}function Qa({baseRelease:s,release:t,busy:n,onOpenDiff:a,onRollback:l}){const[i,u]=o.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:[ke(t.contentHash)," · ",t.files.length," files · ",Re(t.createdAt)]})]}),i?e.jsxs("div",{className:"harness-inline-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:n,onClick:()=>u(!1),type:"button",children:[e.jsx(le,{size:13})," Cancel"]}),e.jsxs("button",{className:"settings-primary compact",disabled:n,onClick:()=>{u(!1),l(t)},type:"button",children:[e.jsx($e,{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:()=>a(s,t),type:"button",children:"View changes"}),t.current?null:e.jsxs("button",{className:"settings-secondary compact",disabled:n,onClick:()=>u(!0),type:"button",children:[e.jsx($e,{size:13})," Roll back"]})]})]})}function el({connection:s,enabled:t,onError:n,onDefaultReleaseDiff:a,onOpenReleaseDiff:l,onOpenSourceSession:i,onToast:u}){const[r,h]=o.useState(null),[v,g]=o.useState(!1),[f,c]=o.useState(null),[p,m]=o.useState(null),[j,C]=o.useState(!1),P=o.useCallback(async()=>{if(s){g(!0);try{const k=await I.harnessHistory(s);h(k);const d=k.releases.findIndex(y=>y.current),w=d>=0?k.releases[d]:null;k.workspace&&w&&a(Is(k.workspace.id,k.releases[d+1]??null,w)),n(null)}catch(k){n(k instanceof Error?k.message:String(k))}finally{g(!1)}}},[s,a,n]);o.useEffect(()=>{t&&P()},[t,P]);const x=o.useMemo(()=>r?.releases.find(k=>k.current)??null,[r]),R=o.useCallback(async k=>{if(!(!s||!r?.workspace)){C(!0);try{const d=await I.updateHarnessBackgroundReview(s,{workspaceId:r.workspace.id,enabled:k});h(d.history),n(null),u?.(k?"Harness background review enabled.":"Harness background review disabled.","info")}catch(d){n(d instanceof Error?d.message:String(d))}finally{C(!1)}}},[s,r?.workspace,n,u]),A=o.useCallback((k,d)=>{r?.workspace&&l(Is(r.workspace.id,k,d))},[r?.workspace,l]),N=o.useCallback(k=>{!r?.workspace||!k.receipt.nextRelease||l({workspaceId:r.workspace.id,baseRelease:k.receipt.previousRelease,targetRelease:k.receipt.nextRelease,title:k.proposal?.expectedOutcome??k.receipt.reason})},[r?.workspace,l]),S=o.useCallback(async k=>{if(!(!s||!r?.workspace)){c(k.contentHash);try{const d=await I.rollbackHarness(s,{workspaceId:r.workspace.id,targetRelease:{id:k.id,contentHash:k.contentHash}});h(d.history),n(null),u?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(d){n(d instanceof Error?d.message:String(d))}finally{c(null)}}},[s,r?.workspace,n,u]),L=o.useCallback(async(k,d)=>{if(!(!s||!r?.workspace)){m(k.proposal.id);try{const w=await I.reviewHarnessProposal(s,{workspaceId:r.workspace.id,proposal:{id:k.proposal.id,contentHash:k.proposal.contentHash},decision:d});h(w.history),n(null),u?.(d==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",d==="approve"?"success":"info")}catch(w){n(w instanceof Error?w.message:String(w))}finally{m(null)}}},[s,r?.workspace,n,u]);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:v,onClick:()=>{P()},type:"button",children:[e.jsx(se,{className:v?"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&&v&&!r?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,r&&!r.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,r?.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:r.workspace.name})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Current release"}),e.jsx("strong",{children:ke(x?.contentHash)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Channel revision"}),e.jsx("strong",{children:r.workspace.currentChannel.revision})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Status"}),e.jsx("strong",{children:r.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:r.backgroundReview.enabled,disabled:j,onChange:k=>{R(k.target.checked)},type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]})}),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."})]}),r.releases.map((k,d)=>e.jsx(Qa,{baseRelease:r.releases[d+1]??null,busy:f!==null,onOpenDiff:A,onRollback:S,release:k},`${k.id}:${k.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:r.pendingReviews.length})]}),r.pendingReviews.length?r.pendingReviews.map(k=>e.jsx(Xa,{busy:p!==null,onReview:L,review:k},`${k.proposal.id}:${k.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:r.changes.length})]}),r.changes.length?r.changes.map(k=>e.jsx(Ya,{change:k,onOpenDiff:k.receipt.nextRelease?()=>N(k):void 0,onOpenSourceSession:i},`${k.receipt.id}:${k.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:r.routes.length})]}),r.routes.length?r.routes.map(k=>e.jsx(Za,{route:k},`${k.decision.id}:${k.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:r.memories.length})]}),r.memories.length?r.memories.map(k=>e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:k.key}),e.jsxs("span",{children:["revision ",k.revision]}),e.jsx("time",{children:Re(k.updatedAt)})]}),e.jsx("p",{children:k.content}),k.tags.length?e.jsx("small",{children:k.tags.join(" · ")}):null]},`${k.id}:${k.revision}`)):e.jsx("div",{className:"harness-empty",children:"No Harness memory has been saved."})]})]}):null]})}function Ms(s){return s?s.slice(0,10):"initial"}function sl({connection:s,expanded:t,onResizeStart:n,onToggleExpanded:a,selection:l}){const[i,u]=o.useState(null),[r,h]=o.useState(null),[v,g]=o.useState(!0),f=o.useCallback(async()=>{h(null),g(!0);try{u(await I.harnessReleaseDiff(s,l))}catch(m){u(null),h(m instanceof Error?m.message:String(m))}finally{g(!1)}},[s,l]);o.useEffect(()=>{f()},[f]);const c=o.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]),p=`${l.title} · ${Ms(l.baseRelease?.contentHash)} → ${Ms(l.targetRelease.contentHash)}`;return e.jsx(Jt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:c,editorPreferences:null,expanded:t,filesWithPreview:!0,loading:v,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:n,onToggleExpanded:a,readOnly:!0,workspaceError:r,workspaceInitialized:!0,workspaceName:p})}function tl({connection:s,onError:t,onPayload:n}){const[a,l]=o.useState(!1),[i,u]=o.useState(!1);async function r(f,c){if(s){l(!0),t(null);try{const p=await I.switchOpenPondAccount(s,{handle:f,baseUrl:c??null}),m=await I.savePreferences(s,{defaultTeamId:null});n({...p,preferences:m.preferences})}catch(p){t(p instanceof Error?p.message:String(p))}finally{l(!1)}}}async function h(f,c){if(!s)return!1;l(!0),t(null);try{return n(await I.removeOpenPondAccount(s,{handle:f,baseUrl:c??null})),!0}catch(p){return t(p instanceof Error?p.message:String(p)),!1}finally{l(!1)}}async function v(f){if(!(!s||!f.apiKey.trim())){l(!0),t(null);try{const c=f.handle?.trim(),p=f.environment?.trim(),m=await I.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:c||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:p||"custom",setActive:!0}),j=await I.savePreferences(s,{defaultTeamId:null});n({...m,preferences:j.preferences})}catch(c){throw t(c instanceof Error?c.message:String(c)),c}finally{l(!1)}}}async function g(){if(s){u(!0),t(null);try{n(await I.refreshOpenPondAccounts(s))}catch(f){t(f instanceof Error?f.message:String(f))}finally{u(!1)}}}return{refreshingAccounts:i,saving:a,refreshAccounts:g,removeAccount:h,saveAccount:v,switchAccount:r}}function nl({connection:s,onError:t,onPreferences:n,preferences:a,providers:l}){const[i,u]=o.useState(a.defaultBranchPrefix),[r,h]=o.useState(a.defaultNewProjectDirectory),[v,g]=o.useState(a.advancedWorkspaceControls),[f,c]=o.useState(a.contextCompaction.autoEnabled),[p,m]=o.useState(a.subagents.enabled),[j,C]=o.useState(a.subagents.delegationMode),[P,x]=o.useState(!a.subagents.defaultModelRef),[R,A]=o.useState(a.subagents.defaultModelRef?.providerId??a.defaultChatProvider),[N,S]=o.useState(a.subagents.defaultModelRef?.modelId??a.defaultChatModel),[L,k]=o.useState(a.subagents.roles),[d,w]=o.useState(a.subagents.maxConcurrentRuns),[y,b]=o.useState(a.subagents.maxConcurrentRunsPerProvider),[M,E]=o.useState(a.subagents.maxConcurrentRunsPerWorkspaceTarget),[G,K]=o.useState(!1),Z=P?null:{providerId:R,modelId:N.trim()},$=p!==a.subagents.enabled||j!==a.subagents.delegationMode||!al(Z,a.subagents.defaultModelRef)||d!==a.subagents.maxConcurrentRuns||y!==a.subagents.maxConcurrentRunsPerProvider||M!==a.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(L)!==JSON.stringify(a.subagents.roles);o.useEffect(()=>{u(a.defaultBranchPrefix),h(a.defaultNewProjectDirectory),g(a.advancedWorkspaceControls),c(a.contextCompaction.autoEnabled),m(a.subagents.enabled),C(a.subagents.delegationMode),x(!a.subagents.defaultModelRef),A(a.subagents.defaultModelRef?.providerId??a.defaultChatProvider),S(a.subagents.defaultModelRef?.modelId??a.defaultChatModel),k(a.subagents.roles),w(a.subagents.maxConcurrentRuns),b(a.subagents.maxConcurrentRunsPerProvider),E(a.subagents.maxConcurrentRunsPerWorkspaceTarget)},[a.defaultChatProvider,a.defaultChatModel,a.defaultBranchPrefix,a.defaultNewProjectDirectory,a.advancedWorkspaceControls,a.contextCompaction.autoEnabled,a.subagents]);function z(O){A(O),S(B=>Qe(O,B,l))}function Q(){return P?a.defaultChatProvider:R}function J(){return P?a.defaultChatModel:N}function H(O,B){k(_=>_.map(T=>T.id===O?B(T):T))}function ie(O,B){H(O,_=>({..._,enabled:B}))}function V(O,B){H(O,_=>({..._,background:B}))}function U(O,B){H(O,_=>{if(B)return{..._,modelRef:null};const T=_.modelRef?.providerId??Q(),W=_.modelRef?.modelId??J();return{..._,modelRef:Be(T,W,l)??null}})}function te(O,B){H(O,_=>({..._,modelRef:Be(B,_.modelRef?.modelId??J(),l)??null}))}function ae(O,B){H(O,_=>{const T=_.modelRef?.providerId??Q(),W=B.trim();return{..._,modelRef:W?{providerId:T,modelId:W}:null}})}function q(O,B){H(O,_=>({..._,isolationMode:B}))}function re(O,B){H(O,_=>({..._,toolPolicy:B}))}function ce(O,B){H(O,_=>({..._,peerMessages:B}))}function ee(O,B){H(O,_=>({..._,maxConcurrentRuns:fe(B,1,16)}))}async function oe(){let O=null;if(window.openpond?.selectFolder){const B=await window.openpond.selectFolder();if(B.canceled)return;O=B.path}else O=window.prompt("Default new project directory",r);O?.trim()&&h(O.trim())}async function xe(O){if(O.preventDefault(),!!s){K(!0),t(null);try{n(await I.savePreferences(s,{defaultBranchPrefix:Ke(i),defaultNewProjectDirectory:r.trim(),advancedWorkspaceControls:v,contextCompaction:{...a.contextCompaction,autoEnabled:f},subagents:{enabled:p,workspaceDefaultsVersion:a.subagents.workspaceDefaultsVersion,toolDefaultsVersion:a.subagents.toolDefaultsVersion,delegationMode:j,defaultModelRef:P?null:Be(R,N,l)??null,roles:L,maxConcurrentRuns:fe(d,1,32),maxConcurrentRunsPerProvider:y===null?null:fe(y,1,32),maxConcurrentRunsPerWorkspaceTarget:M===null?null:fe(M,1,32)}}))}catch(B){t(B instanceof Error?B.message:String(B))}finally{K(!1)}}}return{advancedWorkspaceControls:v,contextCompactionAutoEnabled:f,defaultBranchPrefix:i,defaultNewProjectDirectory:r,subagentsEnabled:p,subagentDelegationMode:j,subagentsUseDefaultModel:P,subagentsProvider:R,subagentsModel:N,subagentRoles:L,subagentsMaxConcurrentRuns:d,subagentsMaxConcurrentRunsPerProvider:y,subagentsMaxConcurrentRunsPerWorkspaceTarget:M,subagentsDirty:$,saving:G,chooseDefaultProjectDirectory:oe,saveDefaults:xe,changeSubagentsProvider:z,changeSubagentRoleProvider:te,setAdvancedWorkspaceControls:g,setContextCompactionAutoEnabled:c,setDefaultBranchPrefix:u,setDefaultNewProjectDirectory:h,setSubagentsUseDefaultModel:x,setSubagentsModel:S,setSubagentsEnabled:m,setSubagentDelegationMode:O=>C(O),setSubagentsMaxConcurrentRuns:O=>w(fe(O,1,32)),setSubagentsMaxConcurrentRunsPerProvider:O=>b(O===null?null:fe(O,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:O=>E(O===null?null:fe(O,1,32)),setSubagentRoleBackground:V,setSubagentRoleEnabled:ie,setSubagentRoleIsolationMode:q,setSubagentRoleMaxConcurrentRuns:ee,setSubagentRoleModel:ae,setSubagentRolePeerMessages:ce,setSubagentRoleToolPolicy:re,setSubagentRoleUseDefaultModel:U}}function fe(s,t,n){return Number.isFinite(s)?Math.min(n,Math.max(t,Math.trunc(s))):t}function al(s,t){return(s?.providerId??null)===(t?.providerId??null)&&(s?.modelId??null)===(t?.modelId??null)}const ll=15e3,il=100,rl=100,ol=2500;function cl({onError:s,section:t}){const[n,a]=o.useState(null),[l,i]=o.useState(null),[u,r]=o.useState(il),[h,v]=o.useState([]),[g,f]=o.useState(null),[c,p]=o.useState(!0),m=o.useRef(null),[j,C]=o.useState(null),P=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),R=!!window.openpond?.readRecentLogs?`${h.length} of ${u} line${u===1?"":"s"}${c?" tailing":""}`:"Unavailable";o.useEffect(()=>{t==="diagnostics"&&A(u,"refresh",{quiet:!0})},[t]),o.useEffect(()=>{if(t!=="diagnostics"||!c||!window.openpond?.readRecentLogs)return;let w=!1;const y=window.setInterval(()=>{w||(w=!0,A(u,"refresh",{quiet:!0}).finally(()=>{w=!1}))},ol);return()=>window.clearInterval(y)},[t,c,u]),o.useEffect(()=>{if(t!=="diagnostics"||!c)return;const w=m.current;w&&(w.scrollTop=w.scrollHeight)},[t,c,h]);async function A(w=u,y="refresh",b={}){const M=window.openpond?.readRecentLogs;if(!M){const E="Log view is not available in this runtime.";b.quiet||(C({label:"Logs",value:E,warning:!0}),s(E));return}b.quiet||i(y);try{const E=await Ae(M(w),"Read logs");if(!E.ok)throw new Error(E.error);r(E.lineLimit),f(E.logDir),v(E.lines),b.quiet?C(G=>G?.label==="Logs"?null:G):C(null)}catch(E){const G=E instanceof Error?E.message:String(E);C({label:"Logs",value:G,warning:!0}),b.quiet||s(G)}finally{b.quiet||i(null)}}function N(){p(!1),A(u+rl,"older")}function S(){const w=!c;p(w),w&&A(u,"refresh",{quiet:!0})}async function L(){const w=window.openpond?.openLogsFolder;if(!w){const y="Desktop logs are not available in this runtime.";C({label:"Logs",value:y,warning:!0}),s(y);return}a("logs"),s(null);try{const y=await Ae(w(),"Open logs");if(!y.ok)throw new Error(y.error??"Could not open the logs folder.");C(null)}catch(y){const b=y instanceof Error?y.message:String(y);C({label:"Logs",value:b,warning:!0}),s(b)}finally{a(null)}}async function k(){const w=window.openpond?.copyRecentLogs;if(!w){const y="Recent log copy is not available in this runtime.";C({label:"Copy",value:y,warning:!0}),s(y);return}a("copy"),s(null);try{const y=await Ae(w(1e3),"Copy recent logs");if(!y.ok)throw new Error(y.error??"Could not copy recent logs.");C({label:"Copy",value:y.lines?`Copied ${y.lines} recent log lines.`:"Copied recent logs."})}catch(y){const b=y instanceof Error?y.message:String(y);C({label:"Copy",value:b,warning:!0}),s(b)}finally{a(null)}}async function d(){const w=window.openpond?.exportDiagnostics;if(!w){const y="Diagnostics export is not available in this runtime.";C({label:"Export",value:y,warning:!0}),s(y);return}a("export"),s(null);try{const y=await Ae(w(),"Export diagnostics");if(!y.ok)throw new Error(y.error??"Could not export diagnostics.");C({label:"Export",value:y.path?`Saved to ${y.path}`:"Diagnostics exported."})}catch(y){const b=y instanceof Error?y.message:String(y);C({label:"Export",value:b,warning:!0}),s(b)}finally{a(null)}}return{diagnosticsAvailable:P,diagnosticsBusy:n,diagnosticsStatus:j,logDir:g,logLineLimit:u,logLines:h,logViewBusy:l,logViewSummary:R,logViewportRef:m,tailLogs:c,copyRecentLogs:k,exportDiagnosticsBundle:d,loadOlderLogs:N,openLogsFolder:L,refreshLogView:A,toggleTailLogs:S}}async function Ae(s,t){let n;try{return await Promise.race([s,new Promise((a,l)=>{n=window.setTimeout(()=>{l(new Error(`${t} did not receive a desktop response.`))},ll)})])}finally{n!==void 0&&window.clearTimeout(n)}}function dl({connection:s,enabled:t,onError:n,onPreferences:a,onToast:l,preferences:i}){const[u,r]=o.useState(i.editor),[h,v]=o.useState(null),[g,f]=o.useState(!1),[c,p]=o.useState(!1),[m,j]=o.useState(!1);o.useEffect(()=>{r(i.editor)},[i.editor]);const C=o.useCallback(async()=>{if(s){p(!0);try{v(await I.workspaceLspSettingsStatus(s))}catch(N){n(N instanceof Error?N.message:String(N))}finally{p(!1)}}},[s,n]);o.useEffect(()=>{!t||!s||C()},[s,t,C]);function P(N,S){r(L=>({...L,languages:{...L.languages,[N]:{...L.languages[N],mode:S}}}))}function x(N,S){r(L=>({...L,languages:{...L.languages,[N]:{...L.languages[N],customCommand:S}}}))}async function R(N){if(N.preventDefault(),!!s){f(!0),n(null);try{const S=await I.savePreferences(s,{editor:u});a(S),v(await I.workspaceLspSettingsStatus(s))}catch(S){n(S instanceof Error?S.message:String(S))}finally{f(!1)}}}async function A(){if(s){j(!0),n(null);try{await I.restartWorkspaceLsp(s),v(await I.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(N){n(N instanceof Error?N.message:String(N))}finally{j(!1)}}}return{editorPreferences:u,lspStatus:h,restarting:m,saving:g,statusLoading:c,refreshLspStatus:C,restartLanguageServers:A,saveEditorSettings:R,setEditorPreferences:r,setLanguageCustomCommand:x,setLanguageMode:P}}function ul({connection:s,onError:t,onPayload:n,personalization:a}){const l=o.useMemo(()=>a.templates.map(d=>({value:d.id,label:d.name,description:d.id===a.activeTemplateId?"Selected":d.source==="built_in"?d.description:void 0})),[a.activeTemplateId,a.templates]),[i,u]=o.useState(a.activeTemplateId),[r,h]=o.useState(a.soul),[v,g]=o.useState(""),[f,c]=o.useState(!1),[p,m]=o.useState(!1),j=a.templates.find(d=>d.id===i)??a.templates[0],C=j?.source==="custom",P=j?r!==j.content:!0,x=i!==a.activeTemplateId||r!==a.soul||P,R=!!(C&&r.trim()&&j&&x);o.useEffect(()=>{u(a.activeTemplateId),h(a.soul);const d=a.templates.find(w=>w.id===a.activeTemplateId);g(d?`${d.name} Copy`:""),c(!1)},[a.activeTemplateId,a.soul,a.templates]);async function A(d=!1){if(!d&&!C)return;const w=d?v:j?.name;if(!(!s||!r.trim()||!w?.trim())){m(!0),t(null);try{n(await I.savePersonalization(s,{activeTemplateId:i,templateName:w,soul:r,saveAsNew:d})),c(!1)}catch(y){t(y instanceof Error?y.message:String(y))}finally{m(!1)}}}async function N(d){const w=a.templates.find(y=>y.id===d);if(w&&(u(w.id),g(`${w.name} Copy`),h(w.content),c(!1),!!s)){m(!0),t(null);try{n(await I.savePersonalization(s,{activeTemplateId:w.id,templateName:w.name,soul:w.content,saveAsNew:!1}))}catch(y){t(y instanceof Error?y.message:String(y))}finally{m(!1)}}}function S(){j&&(g(`${j.name} Copy`),h(j.content),c(!1))}function L(d){h(d),j&&!C&&d!==j.content&&c(!0)}function k(){j&&(g(`${j.name} Copy`),c(!0))}return{canSaveCurrentTemplate:R,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:f,saving:p,selectedPersonalizationTemplate:j,selectedTemplateIsCustom:C,soulDraft:r,templateNameDraft:v,changePersonalizationTemplate:N,changeSoulDraft:L,openSaveAsNew:k,resetPersonalizationDraft:S,savePersonalization:A,setSaveAsNewOpen:c,setTemplateNameDraft:g}}function hl({connection:s,onError:t,onPreferences:n,onProviders:a,preferences:l,providers:i}){const[u,r]=o.useState(l.defaultChatProvider),[h,v]=o.useState(l.defaultChatModel),[g,f]=o.useState(!1),[c,p]=o.useState(null),[m,j]=o.useState(null);o.useEffect(()=>{r(l.defaultChatProvider),v(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function C(y){if(y.preventDefault(),!!s){f(!0),t(null);try{n(await I.savePreferences(s,{defaultChatProvider:u,defaultChatModel:Qe(u,h,i)}))}catch(b){t(b instanceof Error?b.message:String(b))}finally{f(!1)}}}function P(y){r(y),v(b=>Qe(y,b,i))}async function x(y,b,M){if(!s)return null;p(`${y}:${b}`),j(null),t(null);try{return await M()}catch(E){return t(E instanceof Error?E.message:String(E)),null}finally{p(null)}}async function R(y,b){await x(y,"config",async()=>{const M=await I.saveProviderSettings(s,{providers:{[y]:b}});return a(M),M})}async function A(y,b){await x(y,"credential",async()=>{const M=await I.saveProviderCredential(s,y,b);return a(M),M})}async function N(y){await x(y,"credential",async()=>{const b=await I.deleteProviderCredential(s,y,{});return a(b),b})}async function S(y){return x("openai","credential",async()=>{const b=await I.startOpenAiSubscriptionAuth(s,{method:y});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}.`)),L(b.expiresAt),b})}async function L(y){if(s)for(;Date.now()<y;){await new Promise(b=>setTimeout(b,2500));try{const b=await I.providerSettings(s);a(b);const M=b.statuses.openai?.credential;if(M?.connected&&M.source==="chatgpt_subscription"){j("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function k(y){await x(y,"models",async()=>{const b=await I.refreshProviderModels(s,y,{force:!0});return a(b.providers),b})}async function d(y){await x(y,"models",async()=>{const b=await I.loadProviderModels(s,y,{limit:500});return a(b.providers),b})}async function w(y,b={}){await x(y,"validate",async()=>{const M=await I.validateProviderCredential(s,y,b);return j(M.ok?`${y} validated${M.modelId?` with ${M.modelId}`:""}.`:M.errors.join(`
6
+ `)||`${y} validation failed.`),a(M.providers),M})}return{defaultModel:h,defaultProvider:u,providerBusy:c,saving:g,validationMessage:m,changeDefaultProvider:P,deleteProviderCredential:N,loadProviderModels:d,refreshProviderModels:k,saveProviderConfig:R,saveProviderCredential:A,saveProviders:C,setDefaultModel:v,startOpenAiSubscriptionAuth:S,validateProvider:w}}function ml({connection:s,enabled:t,onError:n,onToast:a}){const[l,i]=o.useState(null),[u,r]=o.useState(null),[h,v]=o.useState(!1),g=o.useRef(null),f=o.useCallback(async(S={})=>{if(s){S.quiet||r("refresh");try{const L=await I.remoteAccess(s);i(L),n(null)}catch(L){n(L instanceof Error?L.message:String(L))}finally{S.quiet||r(null)}}},[s,n]);o.useEffect(()=>{!t||!s||f({quiet:!0})},[s,t,f]),o.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);function c(){g.current!==null&&window.clearTimeout(g.current),v(!1),window.setTimeout(()=>{v(!0),g.current=window.setTimeout(()=>{v(!1),g.current=null},1500)},0)}async function p(){if(n(null),!!s)try{i(await I.remoteAccess(s))}catch{}}async function m(){if(!s)return null;l&&!l.tailscale.running&&c(),r("enable");try{const S=await I.enableRemoteAccess(s);return i(S.status),n(null),S.status.tailscale.running?!S.status.serve.enabled&&S.status.serve.error&&a?.(S.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":S.message||S.status.serve.error,"error"):(c(),a?.(S.message||"Tailscale is not running. Run Tailscale up first.","error")),S.status}catch{return await p(),c(),a?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{r(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.")){r("disable");try{const S=await I.disableRemoteAccess(s);i(S.status),n(null)}catch{await p()}finally{r(null)}}}async function C(){l?.remoteWebUrl&&(r("copy-link"),await je(l.remoteWebUrl),r(null))}async function P(){l?.serveCommand&&(r("copy-command"),await je(l.serveCommand),r(null))}async function x(){l?.serve.setupUrl&&(r("copy-serve-setup"),await je(l.serve.setupUrl),r(null))}async function R(){l?.tailscaleUpCommand&&(r("copy-up-command"),await je(l.tailscaleUpCommand),r(null))}async function A(){l?.operatorCommand&&(r("copy-operator"),await je(l.operatorCommand),r(null))}async function N(){if(!l?.serve.enabled){const S=await m();S?.serve.enabled&&S.remoteWebUrl&&await je(S.remoteWebUrl);return}await C()}return{status:l,busy:u,flashTailscaleUp:h,refresh:f,enableRemoteAccess:m,disableRemoteAccess:j,copyRemoteLink:C,copyTailscaleUpCommand:R,copyServeCommand:P,copyServeSetupUrl:x,copyOperatorCommand:A,createRemoteLink:N}}function pl(s){const{connection:t,enabled:n,onError:a}=s,[l,i]=o.useState(null),[u,r]=o.useState(null),h=o.useCallback(async()=>{if(t){r("load");try{const m=await I.computeState(t);i(m),a(null)}catch(m){a(Ne(m))}finally{r(null)}}},[t,a]),v=o.useCallback(async()=>{if(t){r("scan");try{const m=await I.scanCompute(t),j=await I.computeState(t);i({...j,inventory:m,scanning:!1}),a(null)}catch(m){a(Ne(m))}finally{r(null)}}},[t,a]),g=o.useCallback(async(m,j,C)=>{if(!t)return!1;r("save");try{const P=await I.updateComputeSettings(t,{modelStorePath:m,datasetStorePath:j,defaultDeviceIds:C}),x=await I.computeState(t);return i({...x,settings:P}),a(null),!0}catch(P){return a(Ne(P)),!1}finally{r(null)}},[t,a]),f=o.useCallback(async()=>{if(t)try{await I.downloadSmolLm2(t),await h()}catch(m){a(Ne(m))}},[t,a,h]),c=o.useCallback(async m=>{if(t)try{await I.cancelModelDownload(t,m),await h()}catch(j){a(Ne(j))}},[t,a,h]);o.useEffect(()=>{n&&h()},[n,h]);const p=l?.inventory?.downloads.some(m=>["queued","downloading","verifying","cancelling"].includes(m.status))??!1;return o.useEffect(()=>{if(!n||!p)return;const m=window.setInterval(()=>{h()},1e3);return()=>window.clearInterval(m)},[n,p,h]),{state:l,busy:u,refresh:h,scan:v,save:g,downloadSmolLm2:f,cancelDownload:c}}function Ne(s){return s instanceof Error?s.message:String(s)}function gl(s){const{connection:t,enabled:n,onError:a,profileId:l}=s,[i,u]=o.useState(null),[r,h]=o.useState(!1),v=o.useCallback(async()=>{if(t){h(!0);try{u(await I.datasetCatalog(t,l)),a(null)}catch(g){a(fl(g))}finally{h(!1)}}},[t,a,l]);return o.useEffect(()=>{n&&v()},[n,v]),{catalog:i,loading:r,refresh:v}}function fl(s){return s instanceof Error?s.message:String(s)}const xl=o.lazy(()=>Ut(()=>import("./UsageSettingsSection-DzMLUXAO.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function zl({payload:s,connection:t,diagnostics:n,onPayload:a,onError:l,onToast:i,onBack:u,onOpenSourceSession:r,onOpenSkill:h,onOpenExtension:v,teamChatCurrentUserId:g,teamChatEnabled:f,teamChatNotificationMode:c,teamChatThreads:p,onTeamChatNotificationModeChange:m,onTeamChatThreadMuteChange:j,diffPanelWidth:C,diffPanelResizing:P,diffPanelExpanded:x,onDiffPanelResizeStart:R,onDiffPanelExpandedChange:A,initialSection:N="account"}){const[S,L]=o.useState(N),[k,d]=o.useState(null),[w,y]=o.useState(!1),b=s?.codex??null,M=o.useMemo(()=>$t(s?.preferences),[s?.preferences]),E=s?.personalization??Lt,G=n??s?.diagnostics??[],K=Tt()&&Ot(t?.platform),Z=o.useCallback(T=>{s&&a({...s,providers:T})},[a,s]),$=o.useCallback(T=>{s&&a({...s,preferences:T.preferences})},[a,s]),z=o.useCallback(T=>{s&&a({...s,extensionCatalog:T})},[a,s]),Q=tl({connection:t,onError:l,onPayload:a}),J=hl({connection:t,onError:l,onPayload:a,onPreferences:$,onProviders:Z,preferences:M,providers:s?.providers??null}),H=nl({connection:t,onError:l,onPayload:a,onPreferences:$,preferences:M,providers:s?.providers??null}),ie=dl({connection:t,enabled:S==="editor",onError:l,onPayload:a,onPreferences:$,onToast:i,preferences:M}),V=ul({connection:t,onError:l,onPayload:a,personalization:E}),U=cl({onError:l,section:S}),te=ml({connection:t,enabled:S==="remote",onError:l,onToast:i}),ae=S==="dataset-storage",q=pl({connection:t,enabled:S==="compute"||ae,onError:l}),re=gl({connection:t,enabled:ae,onError:l,profileId:s?.profile.activeProfile??"default"}),ce=o.useCallback(T=>q.save(q.state?.settings.modelStorePath??null,T,q.state?.settings.defaultDeviceIds??[]),[q.save,q.state?.settings.defaultDeviceIds,q.state?.settings.modelStorePath]),ee=o.useCallback(async()=>{await Promise.all([q.refresh(),re.refresh()])},[q.refresh,re.refresh]),oe=o.useCallback(()=>S!=="subagents"||!H.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[H.subagentsDirty,S]),xe=o.useCallback(T=>{T!==S&&oe()&&(y(!1),A(!1),L(T))},[oe,A,S]),O=o.useCallback(()=>{oe()&&(y(!1),A(!1),u())},[oe,u,A]);o.useEffect(()=>{L(N)},[N]),o.useEffect(()=>{if(S!=="subagents"||!H.subagentsDirty)return;const T=W=>{W.preventDefault(),W.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",T),()=>window.removeEventListener("beforeunload",T)},[H.subagentsDirty,S]);const B={"--diff-panel-width":`${C}px`},_=S==="harness"&&w&&k;return e.jsxs("div",{className:`settings-shell ${K?"platform-macos":""} ${_?"harness-diff-open":""} ${x?"harness-diff-expanded":""} ${P?"diff-panel-resizing":""}`,style:B,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[S==="harness"?e.jsx("button",{type:"button",className:`topbar-diff-button ${_?"active":""}`,title:`${_?"Hide":"Show"} sidebar`,"aria-label":`${_?"Hide":"Show"} sidebar`,"aria-pressed":!!_,disabled:!k,onClick:()=>y(T=>!T),children:e.jsx(Et,{size:16})}):null,e.jsx(zt,{platform:t?.platform})]}),e.jsx(Pa,{section:S,onBack:O,onSectionChange:xe}),e.jsx("main",{className:`settings-content ${S==="profile"||S==="harness"?"settings-content-wide":""}`,children:S==="account"?e.jsx(mn,{payload:s,connection:t,onPayload:a,onPreferences:$,onError:l,onToast:i,...Q}):S==="notifications"?e.jsx(Mn,{currentUserId:g,enabled:f,mode:c,threads:p,onModeChange:m,onThreadMuteChange:j}):S==="harness"?e.jsx(el,{connection:t,enabled:S==="harness",onError:l,onDefaultReleaseDiff:d,onOpenSourceSession:r,onOpenReleaseDiff:T=>{d(T),y(!0)},onToast:i}):S==="profile"?e.jsx(Jn,{payload:s,connection:t,onPayload:a,onError:l,onToast:i}):S==="skills"?e.jsx(Aa,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:t,onExtensionCatalog:z,onError:l,onToast:i,onOpenSkill:h,onOpenExtension:v}):S==="providers"?e.jsx(ja,{account:s?.account??null,codex:b,providers:s?.providers??null,...J}):S==="compute"?e.jsx(Ba,{state:q.state,busy:q.busy,onScan:q.scan,onSave:q.save,onDownloadSmolLm2:q.downloadSmolLm2,onCancelDownload:q.cancelDownload}):S==="dataset-storage"?e.jsx(qa,{state:q.state,catalog:re.catalog,busy:q.busy,catalogLoading:re.loading,onRefresh:ee,onSave:ce}):S==="defaults"?e.jsx(xn,{preferences:M,...H}):S==="context"?e.jsx(Sn,{preferences:M,...H}):S==="training"?e.jsx(Da,{connection:t,onError:l,onPreferences:$,preferences:M,providers:s?.providers??null}):S==="subagents"?e.jsx(wn,{preferences:M,providers:s?.providers??null,...H}):S==="editor"?e.jsx(Nn,{preferences:M,...ie}):S==="remote"?e.jsx(Na,{...te}):S==="usage"?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(xl,{account:s?.account??null,connection:t,enabled:S==="usage",onError:l,onOpenSourceSession:r})}):S==="personalization"?e.jsx(Ln,{...V}):e.jsx(jn,{diagnostics:G,...U})}),S==="harness"&&t&&_?e.jsx(sl,{connection:t,expanded:x,onResizeStart:R,onToggleExpanded:()=>A(!x),selection:_}):null]})}export{zl as SettingsView};
@@ -0,0 +1 @@
1
+ .main-pane.team-active{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);min-height:0;overflow:hidden}.main-pane.team-active.diff-open{--right-panel-chat-reserve: 440px;grid-template-columns:minmax(0,1fr) minmax(320px,max(320px,min(var(--diff-panel-width),calc(100% - var(--right-panel-chat-reserve)))))}.main-pane.team-active>.team-chat-view{grid-column:1;grid-row:1}.team-chat-view{display:grid;grid-template-columns:minmax(0,1fr);width:100%;height:100%;min-width:0;min-height:0;background:var(--bg)}.team-chat-pro-view{place-items:center;padding:32px}.team-chat-pro-content{display:grid;justify-items:center;width:min(440px,100%);gap:8px;text-align:center}.team-chat-pro-icon{display:inline-grid;width:48px;height:48px;margin-bottom:6px;place-items:center;border-radius:14px;background:#2dd4bf1a;color:#67d4c0}.team-chat-pro-content h1{margin:0;color:var(--text);font-size:22px;font-weight:650}.team-chat-pro-content p,.team-chat-pro-content small{margin:0}.team-chat-pro-content p{color:var(--muted-strong);font-size:14px}.team-chat-pro-content small{max-width:390px;color:var(--muted);font-size:12px;line-height:1.5}.team-chat-main{position:relative;display:grid;grid-template-rows:minmax(0,1fr) auto;min-width:0;min-height:0}.team-chat-error{position:absolute;display:flex;align-items:center;gap:10px;z-index:3;top:12px;left:50%;max-width:min(520px,calc(100% - 32px));transform:translate(-50%);border:1px solid rgba(248,113,113,.35);border-radius:6px;background:#321b1d;color:#fecaca;padding:8px 11px;font-size:12px}.team-chat-error button{display:inline-flex;flex:0 0 auto;align-items:center;gap:5px;border:0;background:transparent;color:inherit;padding:2px;font:inherit;font-weight:600;cursor:pointer}.team-chat-error button:hover,.team-chat-error button:focus-visible{color:#fff}.team-chat-error button:focus-visible{outline:2px solid currentColor;outline-offset:2px}.team-chat-messages,.team-ai-thread-messages{min-height:0;overflow-y:auto;scrollbar-color:rgba(255,255,255,.2) transparent;scrollbar-width:thin}.team-chat-messages{padding:18px max(22px,calc((100% - 790px)/2)) 30px}.team-chat-empty{display:grid;min-height:180px;place-items:center;color:var(--muted);font-size:13px}.team-chat-load-older{display:block;min-height:28px;margin:0 auto 10px;border:0;border-radius:5px;background:transparent;color:#67d4c0;padding:0 8px;font-size:11px}.team-chat-load-older:hover:not(:disabled){background:#2dd4bf17}.team-chat-load-older:disabled{opacity:.55}.team-chat-message{position:relative;display:grid;grid-template-columns:34px minmax(0,1fr);gap:10px;padding:8px 6px}.team-chat-message:hover{background:#ffffff06}.team-chat-message:focus{outline:none;background:#2dd4bf12;box-shadow:inset 2px 0 #2dd4bf}.team-chat-avatar{display:inline-grid;flex:0 0 auto;place-items:center;overflow:hidden;border-radius:6px;background:#29433b;color:#d1fae5;object-fit:cover;font-weight:700}.team-chat-avatar{width:34px;height:34px;font-size:11px}.team-chat-message-content{min-width:0;color:#e8e8e8;font-size:13px;line-height:1.5}.team-chat-message-content>header{display:flex;align-items:baseline;gap:7px;min-height:20px}.team-chat-message-content>header strong{color:var(--text);font-size:13px}.team-chat-message-content>header time,.team-chat-message-content>header>span{color:#777;font-size:10px}.team-chat-message-content>header>span.failed{color:#d97a70}.team-chat-message-content>div:not(.team-chat-message-actions){overflow-wrap:anywhere;white-space:pre-wrap}.team-chat-message-content .deleted{color:#777;font-style:italic}.team-chat-message-reply-quote{display:grid;width:min(520px,100%);min-width:0;margin:3px 0 5px;border:0;border-left:3px solid #2dd4bf;border-radius:4px;background:#2dd4bf13;color:var(--muted-strong);padding:6px 9px;text-align:left}.team-chat-message-reply-quote:hover{background:#2dd4bf1f}.team-chat-message-reply-quote strong{overflow:hidden;color:#67d4c0;font-size:11px;line-height:1.35;text-overflow:ellipsis;white-space:nowrap}.team-chat-message-reply-quote span{overflow:hidden;font-size:11px;line-height:1.4;text-overflow:ellipsis;white-space:nowrap}.team-chat-message-content>.team-chat-message-images{display:grid;grid-template-columns:repeat(2,minmax(0,240px));gap:6px;max-width:486px;margin-top:6px;white-space:normal}.team-chat-message-images>a,.team-chat-message-images img,.team-chat-message-image-loading,.team-chat-message-image-retry{display:block;width:100%;aspect-ratio:4 / 3;border:1px solid var(--border);border-radius:6px;background:#181818;object-fit:cover}.team-chat-message-images>a{overflow:hidden}.team-chat-message-images img{border:0}.team-chat-message-image-loading,.team-chat-message-image-retry{background:#202020}.team-chat-message-image-retry{display:grid;place-items:center;color:var(--muted-strong);padding:0}.team-chat-message-image-retry:hover{background:#292929;color:var(--text)}.team-chat-load-older:focus-visible,.team-chat-message-actions button:focus-visible,.team-chat-message-reply-quote:focus-visible,.team-chat-icon-button:focus-visible,.team-chat-thread-link:focus-visible,.team-chat-message-images>a:focus-visible,.team-chat-message-image-retry:focus-visible{outline:2px solid #67d4c0;outline-offset:2px}.team-chat-message-actions{display:inline-flex;gap:2px;margin-left:auto;opacity:0}.team-chat-message:hover .team-chat-message-actions,.team-chat-message-actions:focus-within,.team-chat-message-actions.visible{opacity:1}.team-chat-message-actions button,.team-chat-icon-button{display:inline-grid;width:25px;height:25px;place-items:center;border:0;border-radius:5px;background:transparent;color:var(--muted)}.team-chat-message-actions button:hover,.team-chat-icon-button:hover{background:#ffffff14;color:var(--text)}.team-chat-thread-link{display:inline-flex;align-items:center;gap:6px;min-height:28px;margin-top:7px;border:0;border-radius:5px;background:transparent;color:#67d4c0;padding:0 6px;font-size:12px;font-weight:600}.team-chat-thread-link:hover{background:#2dd4bf17}.team-chat-thread-link small{color:var(--muted);font-size:10px;font-weight:500}.team-chat-message-edit textarea{width:100%;min-height:72px;resize:vertical;border:1px solid rgba(45,212,191,.45);border-radius:6px;background:#191919;color:var(--text);padding:8px;font:inherit}.team-chat-message-edit>div{display:flex;justify-content:flex-end;gap:6px;margin-top:5px}.team-chat-message-edit button{min-height:27px;border:1px solid var(--border);border-radius:5px;background:#202020;color:var(--text);padding:0 9px;font-size:11px}.team-chat-composer-shell,.team-ai-thread-composer{padding:10px max(22px,calc((100% - 790px)/2)) 16px;background:linear-gradient(to bottom,transparent,var(--bg) 14px)}.team-chat-composer-reply{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:9px;min-height:48px;margin-bottom:6px;border:1px solid var(--border);border-left:3px solid #2dd4bf;border-radius:7px;background:#1d2422;color:#67d4c0;padding:5px 7px 5px 10px}.team-chat-composer-reply-target{display:grid;min-width:0;border:0;background:transparent;color:inherit;padding:0;text-align:left}.team-chat-composer-reply-target strong,.team-chat-composer-reply-target span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.team-chat-composer-reply-target strong{font-size:11px}.team-chat-composer-reply-target span{color:var(--muted-strong);font-size:11px}.team-chat-composer-reply-target:hover span{color:var(--text)}.team-chat-composer-reply-target:focus-visible{outline:2px solid #67d4c0;outline-offset:2px}.team-chat-message-context-menu{position:fixed;z-index:100;width:150px;border:1px solid var(--border);border-radius:7px;background:#222;padding:4px;box-shadow:0 12px 30px #00000061}.team-chat-message-context-menu button{display:flex;width:100%;min-height:32px;align-items:center;gap:8px;border:0;border-radius:5px;background:transparent;color:var(--text);padding:0 9px;font-size:12px;text-align:left}.team-chat-message-context-menu button:hover,.team-chat-message-context-menu button:focus-visible{outline:none;background:#2dd4bf1f;color:#a7f3d0}.team-chat-composer-shell .composer,.team-ai-thread-composer .composer{width:100%}.team-chat-model-toggle{display:inline-flex;align-items:center;gap:6px;min-height:28px;color:var(--muted-strong);font-size:11px;white-space:nowrap}.team-chat-model-toggle input{accent-color:#2dd4bf}.team-ai-thread-panel{display:grid;grid-template-rows:auto minmax(0,1fr) auto;min-width:0;min-height:0;border-left:1px solid var(--border);background:#171717}.team-ai-thread-panel>header{display:flex;min-height:54px;align-items:center;justify-content:space-between;gap:10px;border-bottom:1px solid var(--border);padding:8px 12px 8px 16px}.team-ai-thread-panel>header>div,.team-ai-message-author{display:flex;align-items:center;gap:7px}.team-ai-thread-panel>header strong{font-size:13px}.team-ai-thread-panel>header span,.team-ai-message-author span{color:var(--muted);font-size:10px}.team-ai-thread-messages{padding:14px 16px 24px}.team-ai-message{padding:10px 0 14px;color:#e6e6e6;font-size:12px;line-height:1.55}.team-ai-message+.team-ai-message{border-top:1px solid rgba(255,255,255,.055)}.team-ai-message>.markdown-message{margin-top:5px;overflow-wrap:anywhere}.team-ai-message.assistant .team-ai-message-author{color:#67d4c0}.team-ai-message.streaming{opacity:.88}.team-ai-running{color:var(--muted);padding:12px 0;font-size:11px}.team-ai-turn-state{margin-top:8px;border-left:2px solid #777;color:var(--muted);padding:7px 9px;font-size:11px}.team-ai-turn-state.failed,.team-ai-turn-state.interrupted{border-left-color:#f87171;color:#fca5a5}.team-ai-thread-composer{padding-right:12px;padding-left:12px}@media(max-width:980px){.main-pane.team-active.diff-open{grid-template-columns:minmax(0,1fr)}.team-ai-thread-panel{position:absolute;z-index:5;inset:0 0 0 auto;width:min(430px,100%);box-shadow:-12px 0 30px #00000047}}@media(max-width:620px){.team-chat-messages,.team-chat-composer-shell{padding-inline:10px}.team-chat-composer-controls{flex-wrap:wrap}}
@@ -0,0 +1,3 @@
1
+ import{j as t,c1 as H,X as R,r as o,c2 as le,c3 as K,a1 as N,n as re,au as de,av as ce,c4 as me,c5 as ue,c6 as ge,aB as he,c7 as fe,c8 as xe}from"./index-ByIQyiUl.js";/* empty css */import{d as E}from"./MainPane-aOVlVyRK.js";import{T as ve,B as T,b as k}from"./MarkdownText-D7DT1k1k.js";import{R as X}from"./refresh-cw-DH0KLbdD.js";import{R as L}from"./reply-D1TK2yV8.js";import{S as Ce}from"./square-pen-CqfsvR_n.js";import{r as ye}from"./index-D4uCeiep.js";import"./cloud-upload-5MGPLnaA.js";import"./arrow-up-right-ecwcx3xt.js";import"./square-CemI-0g5.js";import"./folder-open-Dq3ZjeEP.js";function be(e,l){const s=new Set(Array.from(e.matchAll(/(?:^|\s)@([a-zA-Z0-9_-]+)/g),n=>(n[1]??"").toLowerCase()));return l.filter(n=>{const d=n.handle?.toLowerCase(),r=n.name.toLowerCase().replace(/[^a-z0-9_-]+/g,"-");return d&&s.has(d)||s.has(r)}).map(n=>n.userId)}function je(e){return t.jsxs("div",{className:"team-chat-composer-reply",role:"status",children:[t.jsx(L,{size:15,"aria-hidden":"true"}),t.jsxs("button",{type:"button",className:"team-chat-composer-reply-target","aria-label":`Jump to message from ${e.authorLabel}`,onClick:e.onJump,children:[t.jsxs("strong",{children:["Replying to ",e.authorLabel]}),t.jsx("span",{children:H(e.target)})]}),t.jsx("button",{type:"button",className:"team-chat-icon-button","aria-label":"Cancel reply","data-tooltip":"Cancel reply",onClick:e.onCancel,children:t.jsx(R,{size:14})})]})}function we(e){return t.jsxs("button",{type:"button",className:"team-chat-message-reply-quote","aria-label":`Jump to replied message from ${e.authorLabel}`,onClick:e.onJump,children:[t.jsx("strong",{children:e.authorLabel}),t.jsx("span",{children:H(e.target)})]})}function Te(e){const l=o.useRef(null);if(o.useEffect(()=>{if(!e.menu)return;l.current?.focus();const n=()=>e.onClose(),d=r=>{r.key==="Escape"&&n()};return window.addEventListener("click",n),window.addEventListener("blur",n),window.addEventListener("keydown",d),window.addEventListener("scroll",n,!0),()=>{window.removeEventListener("click",n),window.removeEventListener("blur",n),window.removeEventListener("keydown",d),window.removeEventListener("scroll",n,!0)}},[e.menu,e.onClose]),!e.menu||typeof document>"u")return null;const s=t.jsx("div",{className:"team-chat-message-context-menu",role:"menu","aria-label":"Message actions",style:{left:e.menu.x,top:e.menu.y},onClick:n=>n.stopPropagation(),children:t.jsxs("button",{ref:l,type:"button",role:"menuitem",onClick:()=>{e.onReply(e.menu.message),e.onClose()},children:[t.jsx(L,{size:14}),"Reply"]})});return ye.createPortal(s,document.body)}function Me(e){const d=e.clientX||e.fallbackX,r=e.clientY||e.fallbackY;return{x:Math.max(8,Math.min(d,e.viewportWidth-150-8)),y:Math.max(8,Math.min(r,e.viewportHeight-42-8))}}function Y(e){return`team-chat-message-${encodeURIComponent(e)}`}function Re(e){const[l,s]=o.useState(!1),[n,d]=o.useState(e.message.body),r=e.message.refs.find(a=>a.refType==="hosted_ai_thread"),m=e.message.refs.find(a=>a.refType==="agent_run"),v=typeof r?.preview.status=="string"?r.preview.status:null,h=typeof e.message.metadata.deliveryStatus=="string"?e.message.metadata.deliveryStatus:null,C=typeof e.message.metadata.uploadProgress=="string"?e.message.metadata.uploadProgress:null,c=!e.message.deletedAt&&!h,g=le(e.message,e.messagesById),b=g?K(g,e.membersById):null;return t.jsxs("article",{id:Y(e.message.id),className:`team-chat-message${e.own?" own":""}`,tabIndex:-1,onContextMenu:a=>{if(!c)return;a.preventDefault();const y=a.currentTarget.getBoundingClientRect();e.onOpenReplyMenu(e.message,{clientX:a.clientX,clientY:a.clientY,fallbackX:y.right-12,fallbackY:y.top+24})},children:[t.jsx(Ie,{member:e.author}),t.jsxs("div",{className:"team-chat-message-content",children:[t.jsxs("header",{children:[t.jsx("strong",{children:e.author?.name??"Team member"}),t.jsx("time",{children:Se(e.message.createdAt)}),e.message.editedAt?t.jsx("span",{children:"edited"}):null,h==="sending"?t.jsx("span",{children:"sending"}):null,h==="sending"&&C?t.jsxs("span",{children:["uploaded ",C]}):null,h==="failed"?t.jsx("span",{className:"failed",children:"not sent"}):null,h==="failed"?t.jsxs("div",{className:"team-chat-message-actions visible",children:[t.jsx("button",{type:"button","data-tooltip":"Retry message","aria-label":"Retry message",onClick:()=>{e.onRetry(e.message)},children:t.jsx(X,{size:13})}),t.jsx("button",{type:"button","data-tooltip":"Remove failed message","aria-label":"Remove failed message",onClick:()=>e.onDismissFailed(e.message),children:t.jsx(R,{size:13})})]}):c||e.own&&!e.message.deletedAt?t.jsxs("div",{className:"team-chat-message-actions",children:[c?t.jsx("button",{type:"button","data-tooltip":"Reply","aria-label":"Reply to message",onClick:()=>e.onReply(e.message),children:t.jsx(L,{size:13})}):null,e.own&&!r?t.jsx("button",{type:"button","data-tooltip":"Edit message","aria-label":"Edit message",onClick:()=>s(!0),children:t.jsx(Ce,{size:13})}):null,e.own?t.jsx("button",{type:"button","data-tooltip":"Delete message","aria-label":"Delete message",onClick:()=>{e.onDelete(e.message)},children:t.jsx(ve,{size:13})}):null]}):null]}),g&&b?t.jsx(we,{authorLabel:b,target:g,onJump:()=>e.onJumpToMessage(g.id)}):null,l?t.jsxs("form",{className:"team-chat-message-edit",onSubmit:a=>{a.preventDefault(),e.onEdit(e.message,n).then(y=>{y&&s(!1)})},children:[t.jsx("textarea",{autoFocus:!0,value:n,onChange:a=>d(a.currentTarget.value),onKeyDown:a=>{a.key==="Escape"&&(a.preventDefault(),s(!1),d(e.message.body))}}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>s(!1),children:"Cancel"}),t.jsx("button",{type:"submit",disabled:!n.trim(),children:"Save"})]})]}):t.jsx("div",{className:e.message.deletedAt?"deleted":"",children:e.message.deletedAt?"Message deleted":e.message.body}),!e.message.deletedAt&&e.message.attachments.length>0?t.jsx(Ae,{message:e.message,connection:e.connection}):null,r?t.jsxs("button",{type:"button",className:"team-chat-thread-link",onClick:()=>{e.onOpenAiThread(r.refId)},children:[t.jsx(N,{size:14}),t.jsx("span",{children:"Thread"}),v&&v!=="completed"?t.jsx("small",{children:J(v)}):null,t.jsx("span",{"aria-hidden":"true",children:"›"})]}):null,m?t.jsxs("button",{type:"button",className:"team-chat-thread-link",onClick:()=>{e.onOpenAgentConversation(m.refId)},children:[t.jsx(T,{size:14}),t.jsx("span",{children:"Agent run"}),t.jsx("small",{children:J(String(m.preview.status??"queued"))}),t.jsx("span",{"aria-hidden":"true",children:"›"})]}):null]})]})}function Ae(e){const l=new Map(Array.isArray(e.message.metadata.localAttachmentPreviews)?e.message.metadata.localAttachmentPreviews.flatMap(s=>{if(!s||typeof s!="object")return[];const n=s;return typeof n.id=="string"&&typeof n.url=="string"?[[n.id,n.url]]:[]}):[]);return t.jsx("div",{className:"team-chat-message-images",children:e.message.attachments.map(s=>t.jsx(Pe,{attachmentId:s.id,alt:s.name,teamId:e.message.teamId,connection:e.connection,localUrl:l.get(s.clientAttachmentId)??null},s.id))})}function Pe(e){const[l,s]=o.useState(e.localUrl),[n,d]=o.useState(!1),r=o.useRef(0);async function m(){if(!e.connection||e.localUrl){e.localUrl||d(!0);return}d(!1);try{const v=await re.teamChatAttachmentDownload(e.connection,e.teamId,e.attachmentId);s(v.url)}catch{s(null),d(!0)}}return o.useEffect(()=>{s(e.localUrl),d(!1),r.current=0,e.localUrl||m()},[e.attachmentId,e.connection,e.localUrl,e.teamId]),l?t.jsx("a",{href:l,target:"_blank",rel:"noreferrer","aria-label":`Open ${e.alt}`,children:t.jsx("img",{src:l,alt:e.alt,loading:"lazy",onError:()=>{if(!e.localUrl&&r.current<1){r.current+=1,m();return}s(null),d(!0)}})}):n?t.jsx("button",{type:"button",className:"team-chat-message-image-retry","aria-label":`Retry ${e.alt}`,"data-tooltip":"Retry image",onClick:()=>{r.current=0,e.localUrl?(d(!1),s(e.localUrl)):m()},children:t.jsx(X,{size:18})}):t.jsx("div",{className:"team-chat-message-image-loading",role:"status","aria-label":`Loading ${e.alt}`})}function J(e){return e==="pending"?"Starting":e==="running"?"Responding":e==="failed"?"Failed":e==="interrupted"?"Interrupted":e==="cancelled"?"Cancelled":e}function Ie({member:e}){if(e?.image)return t.jsx("img",{className:"team-chat-avatar",src:e.image,alt:""});const l=(e?.name??"T").split(/\s+/).slice(0,2).map(s=>s[0]?.toUpperCase()??"").join("");return t.jsx("span",{className:"team-chat-avatar fallback",children:l})}function Se(e){const l=new Date(e);return Number.isFinite(l.getTime())?l.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):""}const U={value:"none",label:"No project",detail:"Team conversation",options:[],busy:!1},z={value:"local",label:"Local",detail:"Local execution",options:[],action:{value:"local",label:"Local",detail:"Local execution",disabled:!1},busy:!1},G=new Set(["codex","openai","xai","openrouter","deepseek","zai","moonshot","together","groq","custom-openai-compatible"]);function ke(e,l){return!l||e===l?e:e?`${l}
2
+
3
+ ${e}`:l}function _e(){return t.jsx("section",{className:"team-chat-view team-chat-pro-view","aria-label":"Team Chat",children:t.jsxs("div",{className:"team-chat-pro-content",children:[t.jsx("span",{className:"team-chat-pro-icon","aria-hidden":"true",children:t.jsx(N,{size:22})}),t.jsx("h1",{children:"Team Chat"}),t.jsx("p",{children:"Team Chat is available with Pro mode."}),t.jsx("small",{children:"Create or join a Pro team to chat with teammates, coordinate work, and share agents."})]})})}function Je(e){de(e.error);const[l,s]=o.useState(""),[n,d]=o.useState(!1),[r,m]=o.useState(null),[v,h]=o.useState(null),[C,c]=o.useState(0),g=o.useRef(null),b=o.useRef(!0),a=o.useRef(e.detail?.thread.id??null);a.current=e.detail?.thread.id??null;const{confirmAction:y,confirmDialog:V,resolveConfirmDialog:Q}=ce(),A=o.useMemo(()=>new Map(e.members.map(i=>[i.userId,i])),[e.members]),D=o.useMemo(()=>new Map((e.detail?.messages??[]).map(i=>[i.id,i])),[e.detail?.messages]),Z=e.detail?.thread.id??null,O=r?.threadId===Z?D.get(r.message.id)??r.message:null,M=O?.deletedAt?null:O,j=M?me(M):null,B=j?K(j,A):null,p=e.detail?ue(e.detail.thread,e.currentUserId):"Team",P=G.has(e.provider)?e.provider:"codex",q=P===e.provider?e.model:"gpt-5.6-sol",ee=o.useMemo(()=>ge({hostedActions:e.agents,profile:e.profile,teamId:e.teamId}),[e.agents,e.profile,e.teamId]),te=e.detail?.messages.at(-1)?.sequence??0;o.useEffect(()=>{if(!b.current)return;const i=g.current;i&&(i.scrollTop=i.scrollHeight)},[te,e.detail?.thread.id]);const $=o.useCallback(i=>{i.deletedAt||i.id.startsWith("pending:")||typeof i.metadata.deliveryStatus=="string"||(m({threadId:i.threadId,message:i}),d(!1),h(null),c(f=>f+1))},[]),ne=o.useCallback(()=>h(null),[]),ae=o.useCallback((i,f)=>{const x=Me({...f,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});h({message:i,...x})},[]),F=o.useCallback(i=>{const f=document.getElementById(Y(i));f&&(f.scrollIntoView({behavior:"smooth",block:"center"}),f.focus({preventScroll:!0}))},[]);async function se(i=[],f=null){if(i.some(u=>u.kind!=="image"||!["image/png","image/jpeg","image/webp","image/gif"].includes(u.mediaType)))return e.showToast("Team chat supports PNG, JPEG, WebP, and GIF images.","error"),!1;let x=f;if(M&&x)return e.showToast("Remove the agent action before replying to a message.","error"),!1;if(fe(x)){const u=xe(x);if(!u)throw new Error("The selected profile agent is missing its profile id.");if(!await y({title:`Publish ${x.label??x.name??"agent"} to Team?`,body:`This will upload the committed agent source to ${e.teamName??"this Team"}, create its hosted runtime, and then send your message.`,confirmLabel:"Publish and send",tone:"default"}))return!1;x=await e.onPublishProfileAgent(u)}const I=x?.approvalPolicy?.risk;let W=null;if(x?.approvalPolicy?.required&&I&&I!=="read"){const u=I==="destructive";if(!await y({title:u?"Approve destructive action?":"Approve external write?",body:`${x.label??x.name??"This agent action"} will use the workspace connection to ${u?"perform a destructive operation":"write external data"}. Approve this run only?`,confirmLabel:u?"Approve destructive action":"Approve write",tone:u?"danger":"default"}))return!1;W=crypto.randomUUID()}const S=l,oe=e.detail?.thread.id??null,w=M,_=()=>{a.current===oe&&(s(u=>ke(u,S)),w&&m(u=>u??{threadId:w.threadId,message:w}))};s(""),w&&m(null);try{const u=await e.onSendMessage({body:S,useModel:n,providerId:P,modelId:q,mentionUserIds:be(S,e.members),attachments:i,replyToMessage:w,selectedActionKey:x?.id??null,approvalId:W});return u?n&&d(!1):_(),u}catch(u){throw _(),u}}return t.jsxs("section",{className:"team-chat-view",children:[t.jsxs("div",{className:"team-chat-main conversation-surface-main",children:[t.jsxs("div",{className:"team-chat-messages conversation-message-scroll",role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":e.loading,"aria-label":p,tabIndex:0,ref:g,onScroll:i=>{const f=i.currentTarget;b.current=f.scrollHeight-f.scrollTop-f.clientHeight<72},children:[e.detail?.hasMoreBefore?t.jsx("button",{type:"button",className:"team-chat-load-older",disabled:e.loading,onClick:()=>{e.onLoadMoreMessages()},children:e.loading?"Loading...":"Load older messages"}):null,e.loading&&!e.detail?t.jsx("div",{className:"team-chat-empty",children:"Loading messages..."}):e.detail?.messages.length?e.detail.messages.map(i=>t.jsx(Re,{message:i,author:i.authorUserId?A.get(i.authorUserId)??null:null,own:i.authorUserId===e.currentUserId,onOpenAiThread:e.onOpenAiThread,onOpenAgentConversation:e.onOpenAgentConversation,onEdit:e.onEditMessage,onDelete:e.onDeleteMessage,onRetry:e.onRetryMessage,onDismissFailed:e.onDismissFailedMessage,membersById:A,messagesById:D,onReply:$,onOpenReplyMenu:ae,onJumpToMessage:F,connection:e.connection},i.id)):t.jsx("div",{className:"team-chat-empty",children:"No messages yet"})]}),t.jsxs("div",{className:"team-chat-composer-shell conversation-composer-shell",children:[j&&B?t.jsx(je,{authorLabel:B,target:j,onCancel:()=>m(null),onJump:()=>F(j.id)}):null,t.jsx(E,{mode:"dock",surface:"team",teamUseModel:n,teamUseModelLocked:!!j,teamMentionMembers:e.members.filter(i=>i.userId!==e.currentUserId),actionCatalog:ee,onTeamUseModelChange:d,prompt:l,contextWindowStatus:e.contextWindowStatus,busy:e.busy,running:!1,focusRequestId:C,submissionScopeKey:`team:${e.detail?.thread.id??"none"}`,showProjectFooter:!1,connection:e.connection,providerSettings:e.providerSettings,provider:P,model:q,projectTarget:U,workspaceTarget:z,codexPermissionMode:e.codexPermissionMode,codexReasoningEffort:e.codexReasoningEffort,openPondCommandAccessMode:e.openPondCommandAccessMode,onProviderChange:e.onProviderChange,onProviderSetupOpen:e.onOpenProviderSettings,onProjectTargetChange:()=>{},onWorkspaceTargetChange:()=>{},onModelChange:e.onModelChange,onCodexPermissionModeChange:e.onCodexPermissionModeChange,onCodexReasoningEffortChange:e.onCodexReasoningEffortChange,onOpenPondCommandAccessModeChange:e.onOpenPondCommandAccessModeChange,onPromptChange:s,showToast:e.showToast,onSubmit:async(i,f)=>se(i??[],f??null),onStop:()=>!1})]})]}),t.jsx(Te,{menu:v,onClose:ne,onReply:$}),t.jsx(he,{state:V,onResolve:Q})]})}function He(e){const[l,s]=o.useState(""),n=e.agentConversation,d=o.useRef(null),r=o.useRef(null),m=o.useRef(null),v=n.messages.at(-1)?.sequence??0,h=["pending","queued","running"].includes(n.run.status);o.useEffect(()=>{const c=d.current;c&&(c.scrollTop=c.scrollHeight)},[v,n.run.status]),o.useEffect(()=>{r.current?.focus();const c=g=>{g.key==="Escape"&&(g.preventDefault(),e.onCloseAgentConversation())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e.onCloseAgentConversation]);async function C(){const c=m.current??crypto.randomUUID();m.current=c;const g=await e.onSendAgentTurn({body:l,clientRequestId:c});return g&&(m.current=null,s("")),g}return t.jsxs("aside",{className:"workspace-diff-panel team-ai-thread-panel","aria-label":`${n.agent.name} run`,children:[e.onResizeStart?t.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agent run panel",onPointerDown:e.onResizeStart}):null,t.jsxs("header",{children:[t.jsxs("div",{children:[t.jsx(T,{size:15}),t.jsx("strong",{children:n.agent.name}),t.jsx("span",{children:n.run.status})]}),t.jsx("button",{ref:r,type:"button",className:"team-chat-icon-button","aria-label":"Close agent run",onClick:e.onCloseAgentConversation,children:t.jsx(R,{size:16})})]}),t.jsxs("div",{className:"team-ai-thread-messages",ref:d,role:"log","aria-live":"polite","aria-relevant":"additions text",tabIndex:0,children:[n.messages.map(c=>t.jsxs("article",{className:`team-ai-message ${c.role}`,children:[t.jsxs("div",{className:"team-ai-message-author",children:[c.role==="assistant"?t.jsx(T,{size:14}):null,t.jsx("strong",{children:c.role==="user"?"Team member":n.agent.name})]}),t.jsx(k,{connection:e.connection,content:c.body})]},c.id)),n.messages.length===0?t.jsx("div",{className:"team-chat-empty",children:"The agent run is starting."}):null]}),t.jsx("div",{className:"team-ai-thread-composer",children:t.jsx(E,{mode:"dock",surface:"team",teamUseModel:!1,teamUseModelLocked:!0,prompt:l,contextWindowStatus:e.contextWindowStatus,busy:e.busy||h,running:h,submissionScopeKey:`team-agent:${n.conversationId}`,showProjectFooter:!1,connection:e.connection,providerSettings:e.providerSettings,provider:e.provider,model:e.model,projectTarget:U,workspaceTarget:z,codexPermissionMode:e.codexPermissionMode,codexReasoningEffort:e.codexReasoningEffort,openPondCommandAccessMode:e.openPondCommandAccessMode,onProviderChange:e.onProviderChange,onProviderSetupOpen:e.onOpenProviderSettings,onProjectTargetChange:()=>{},onWorkspaceTargetChange:()=>{},onModelChange:e.onModelChange,onCodexPermissionModeChange:e.onCodexPermissionModeChange,onCodexReasoningEffortChange:e.onCodexReasoningEffortChange,onOpenPondCommandAccessModeChange:e.onOpenPondCommandAccessModeChange,onPromptChange:c=>{m.current=null,s(c)},showToast:e.showToast,onSubmit:C,onStop:()=>!1})})]})}function Ke(e){const[l,s]=o.useState(""),n=e.aiThread,d=new Map(e.members.map(a=>[a.userId,a])),r=n.turns.at(-1)??null,m=o.useRef(null),v=n.messages.at(-1)?.sequence??0,h=o.useRef(null),C=G.has(e.provider)?e.provider:"codex",c=C===e.provider?e.model:"gpt-5.6-sol",g=!!(n.activeTurn&&(n.activeTurn.status==="pending"||n.activeTurn.status==="running"));o.useEffect(()=>{const a=m.current;a&&(a.scrollTop=a.scrollHeight)},[v,n.activeTurn?.partialBody]),o.useEffect(()=>{h.current?.focus();const a=y=>{y.key==="Escape"&&(y.preventDefault(),e.onCloseAiThread())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e.onCloseAiThread]);async function b(){const a=await e.onSendAiTurn({body:l,providerId:C,modelId:c});return a&&s(""),a}return t.jsxs("aside",{className:"workspace-diff-panel team-ai-thread-panel","aria-label":"AI thread",children:[e.onResizeStart?t.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-label":"Resize AI thread panel","aria-orientation":"vertical",onPointerDown:e.onResizeStart}):null,t.jsxs("header",{children:[t.jsxs("div",{children:[t.jsx(N,{size:15}),t.jsx("strong",{children:"AI thread"}),t.jsxs("span",{children:[n.messages.length," messages"]})]}),t.jsx("button",{ref:h,type:"button",className:"team-chat-icon-button","data-tooltip":"Close thread","aria-label":"Close thread",onClick:e.onCloseAiThread,children:t.jsx(R,{size:16})})]}),t.jsxs("div",{className:"team-ai-thread-messages",ref:m,role:"log","aria-live":"polite","aria-relevant":"additions text",tabIndex:0,children:[n.messages.map(a=>t.jsxs("article",{className:`team-ai-message ${a.role}`,children:[t.jsxs("div",{className:"team-ai-message-author",children:[a.role==="assistant"?t.jsx(T,{size:14}):null,t.jsx("strong",{children:a.role==="assistant"?"Model":a.createdByUserId?d.get(a.createdByUserId)?.name??"Team member":"Team member"})]}),t.jsx(k,{connection:e.connection,content:a.body})]},a.id)),n.activeTurn?.partialBody?t.jsxs("article",{className:"team-ai-message assistant streaming",children:[t.jsxs("div",{className:"team-ai-message-author",children:[t.jsx(T,{size:14}),t.jsx("strong",{children:"Model"}),t.jsx("span",{children:n.activeTurn.status})]}),t.jsx(k,{connection:e.connection,content:n.activeTurn.partialBody})]}):n.activeTurn?t.jsx("div",{className:"team-ai-running",children:n.activeTurn.status==="pending"?"Starting model...":"Model is responding..."}):r&&["failed","interrupted","cancelled"].includes(r.status)?t.jsx("div",{className:`team-ai-turn-state ${r.status}`,children:r.status==="failed"?"Model response failed":r.status==="interrupted"?"Model response was interrupted":"Model response was cancelled"}):null]}),t.jsx("div",{className:"team-ai-thread-composer",children:t.jsx(E,{mode:"dock",surface:"team",teamUseModel:!0,teamUseModelLocked:!0,prompt:l,contextWindowStatus:e.contextWindowStatus,busy:g,running:g,submissionScopeKey:`team-ai:${n.conversationId}`,showProjectFooter:!1,connection:e.connection,providerSettings:e.providerSettings,provider:C,model:c,projectTarget:U,workspaceTarget:z,codexPermissionMode:e.codexPermissionMode,codexReasoningEffort:e.codexReasoningEffort,openPondCommandAccessMode:e.openPondCommandAccessMode,onProviderChange:e.onProviderChange,onProviderSetupOpen:e.onOpenProviderSettings,onProjectTargetChange:()=>{},onWorkspaceTargetChange:()=>{},onModelChange:e.onModelChange,onCodexPermissionModeChange:e.onCodexPermissionModeChange,onCodexReasoningEffortChange:e.onCodexReasoningEffortChange,onOpenPondCommandAccessModeChange:e.onOpenPondCommandAccessModeChange,onPromptChange:s,showToast:e.showToast,onSubmit:b,onStop:e.onStopAiTurn})})]})}export{He as TeamAgentConversationPanel,Ke as TeamAiThreadPanel,_e as TeamChatProView,Je as TeamChatView,ke as restoreFailedTeamChatPrompt};